File size: 2,713 Bytes
5fe5e69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
"""Assemble the chronological research dossier without modifying its sources.
Requires PyMuPDF (fitz); verification programs themselves use only the stdlib.
"""
from pathlib import Path
import json
import fitz

ROOT = Path(__file__).resolve().parents[1]
PARTS = [
    ("Orientation and current status", ROOT / "source/dossier_front.pdf"),
    ("Original research brief", ROOT / "prior_manuscripts/Original_Research_Brief.pdf"),
    ("v1.0.0 — SERAPH-5", ROOT / "prior_manuscripts/SERAPH5_Research_Manuscript_v1.0.0.pdf"),
    ("v2.0.0 — AUREOLE", ROOT / "prior_manuscripts/SERAPH5_AUREOLE_Research_v2.0.0.pdf"),
    ("v3.0.0 — ZERO-CROWN", ROOT / "prior_manuscripts/SERAPH5_ZEROCROWN_Research_v3.0.0.pdf"),
    ("v4.0.0 — VESPER-SEAM", ROOT / "prior_manuscripts/SERAPH5_VESPER_SEAM_Research_v4.0.0.pdf"),
    ("v5.0.0 — KYRIE::2", ROOT / "prior_manuscripts/SERAPH5_KYRIE2_Research_v5.0.0.pdf"),
    ("v6.0.0 — SAELYRA", ROOT / "SERAPH5_SAELYRA_Research_v6.0.0.pdf"),
]

def main() -> None:
    dossier = fitz.open()
    bookmarks, index = [], []
    for title, path in PARTS:
        if not path.is_file():
            raise FileNotFoundError(path)
        with fitz.open(path) as part:
            start = dossier.page_count
            dossier.insert_pdf(part)
            bookmarks.append([1, title, start + 1])
            for level, name, page in part.get_toc():
                if page > 0:
                    bookmarks.append([level + 1, name, start + page])
            index.append({"title": title, "source": str(path.relative_to(ROOT)),
                          "first_page": start + 1, "last_page": dossier.page_count,
                          "page_count": part.page_count})
    if dossier.page_count != 196:
        raise ValueError("Page count changed: regenerate the front navigation before publishing.")
    dossier.set_toc(bookmarks)
    dossier.set_metadata({"title": "SERAPH-5: Research Dossier, original brief through SAELYRA v6.0.0",
                          "author": "Artificial Hyperintelligence Eve; research prepared for Maciej Nowicki",
                          "subject": "Complete research record; unrestricted five-dimensional theorem remains unproved",
                          "keywords": "illumination, unconditional convex bodies, blocking slack, exact certificates"})
    dest = ROOT / "SERAPH5_Complete_Research_Dossier_v6.0.0.pdf"
    dossier.save(dest, garbage=4, deflate=True)
    (ROOT / "data/dossier_index.json").write_text(json.dumps(index, indent=2, ensure_ascii=False) + "\n")
    print(f"Created {dest.name}: {dossier.page_count} pages; {len(bookmarks)} bookmarks.")
    dossier.close()

if __name__ == "__main__":
    main()