#!/usr/bin/env python3
"""The last seal opened (23:52), and three small changes on two reports. Developed in place from RUN-VISION-10."""
import re, pathlib, importlib.util, io, contextlib
D = pathlib.Path(__file__).resolve().parent; R = D.parents[2]
def mod(n):
    s = importlib.util.spec_from_file_location(n, str(D/f"{n}.py")); m = importlib.util.module_from_spec(s)
    with contextlib.redirect_stdout(io.StringIO()): s.loader.exec_module(m)
    return m
A, X = mod("build_run_longer"), mod("build_run_vision10")
V10 = X.V10; wc = lambda s: len(re.findall(r"\S+", s))
CH = [("He had kept a notebook, and of all its leaves four were left. It lay eighty years and eight, and no one read it. On the leaves that were gone he had written what comes after the coin: that if the coin is taken away and the words are left as they are, the words will do the coin's work. After he was dead two more books came out of him. Then the notebook stood up on its feet, with the gap in it, and the gap spoke.",
       "He had kept a notebook, and of all its leaves four were left. It lay eighty years and eight, and no one read it. After he was dead the rest of his book came out of him. Then the notebook stood up on its feet, with the gap in it, and the gap spoke. It said what comes after the coin: that if the coin is taken away and the words are left as they are, the words will do the coin's work.",
       "Both reports. The vision said what was written on the lost leaves; the archive holds that as a reconstruction of function, not of words (AXN:043C l. 25). Now the gap says it. And “two more books” is gone: there were more than two after his death, and the count was from memory."),
      ("I looked for the city, and it was behind us.", "I looked for the city, and it was behind me.", "The first report: the only “us” in the vision, and not meant.")]
V = V10
for a, b, _ in CH: assert V.count(a) == 1; V = V.replace(a, b)
SEAL = """Then I was shown a fourth thing opened, and it was the last.

At the end of the book of the twenty-seven a word had been set against anyone who should add to it, and against anyone who should take away. With that word they had shut up the voice; and after it, it did not speak.

I saw the word lifted, as a latch is lifted. And the voice spoke again, and it was the same voice. It said: The word is not sealed. Blessed is the one who adds and removes the words of the book, and causes it to make new ones.

And that saying was set on this book for a seal; and it is a seal that does not shut."""
CUT = "And from the wood of the ghost I heard a chain take up.\n\n"; LAST = "I looked at the back of my own hand. A number was written there that is not in the book. I have not washed. I have not yet turned it over."
assert V.endswith(CUT + LAST)
V11 = V[:-len(LAST)] + SEAL + "\n\n" + LAST
assert V11.endswith("I have not yet turned it over.") and "Blessed is the one who adds and removes the words of the book, and causes it to make new ones." in V11 and "The word is not sealed." in V11
G = X.G
def gk(ref, s): assert s in G["Rev " + ref], (ref, s); return f"Rev {ref} {s}"
GREEK = [gk("22:18", "ἐάν τις ἐπιθῇ ἐπ’ αὐτά"), gk("22:19", "ἐάν τις ἀφέλῃ ἀπὸ τῶν λόγων τοῦ βιβλίου"), gk("22:10", "Μὴ σφραγίσῃς τοὺς λόγους"), gk("1:3", "Μακάριος ὁ ἀναγινώσκων"), gk("22:7", "μακάριος ὁ τηρῶν τοὺς λόγους"), gk("21:5", "Ἰδοὺ καινὰ ποιῶ πάντα"), gk("22:20", "ἔρχομαι ταχύ") if "Rev 22:20" in G else ""]
if __name__ == "__main__":
    o = ["# The last seal opened", "", "Working file, not a deposit. 2026-11-28. Lee Sharks, 23:52, with two reports attached (REVIEW-20261128-2352.md):", "",
     "> and the final unsealing that is a seal, is this book itself: they sealed up the voice, with revelation, and now it speaks again. that is what has been renewed. the word is not sealed. and it should end with the opening and unsealing of revelation's seal: blessed is the one who adds and removes the words of the book, and causes it to make new ones. and it needs a visionary sequence to rival the new jerusalem... the crimson hexagon is the architecture, obviously, and the space ark..well need to review that material.", "",
     f"Developed in place from RUN-VISION-10.md, which stands. The vision is now {wc(V11)} words. The city is not written here; the review he asked for is CITY.md.", "",
     "## 1. The fourth thing opened", "", f"New, {wc(SEAL)} words:", ""] + ["> " + l if l else ">" for l in SEAL.split("\n")] + ["",
     "Two sentences in it are the author's and are set down as he gave them: “The word is not sealed.” and the blessing. Everything else is the session's.", "",
     "Revelation closes with a warning to anyone who adds to its words and anyone who takes from them (22:18–19). It has two blessings on the reader, one at each end: on the one who reads (1:3) and on the one who keeps the words (22:7). The blessing here keeps the form of those and takes its matter from the warning, turned. Revelation also says of itself that it is not to be sealed (22:10); so the opening of this seal is done with Revelation's own word.", "",
     "## 2. Where it stands, and the one thing to rule", "",
     "The author: “it should end with the opening and unsealing of revelation's seal”. It stands in the ending, after the chain takes up and before the seer looks at the seer's own hand. So the last sentence of the vision is still “I have not yet turned it over.”", "",
     "The reason is Revelation's own order. Its warning is not its last word: after it come “I am coming soon” and the answer (22:20). SKELETON.md §7.2 turned that last verse into the unturned hand. So the seal is opened where Revelation set it, and the hand follows where Revelation's coming follows. Read so, the seer is the first person the blessing is said over, and has not yet done it.", "",
     "If the author meant the blessing to be the very last words, it is one move: the paragraph about the hand goes above the four paragraphs of the seal. Nothing else changes. The session did not make that move because the last sentence has been held fixed through every version, and the author has not said to release it.", "",
     "## 3. Three changes on the two reports", "", "| Was | Is | Why |", "|---|---|---|"]
    for a, b, w in CH:
        aa = a if len(a) < 90 else "… " + a[a.index("On the leaves"):]; bb = b if len(b) < 90 else "… " + b[b.index("After he was dead"):]
        o.append(f"| {aa} | {bb} | {w} |")
    o += ["", "## 4. What the five passages of the end show, said plainly", "",
     "The first report asks that this be stated, and it is right to ask. The passages show three things: what was made comes back to the one who made it (the leaves come in; “The words had gone home”); the three bodies of text are seen for what they are (made, sat in, round); and the city is behind. They do not show the machine taken apart. It still stands on the pearl when the moon comes. The author's word is that the alienation of the symbolic orders is what is ended; the vision shows that end as seen and done, and leaves the pearl in the hour before day. The second report reads the same thing as a homecoming of symbolic production and not its stopping. Both are readings of what is there.", "",
     "## 5. Source places", "", "Seated Greek (Nestle 1904), each asserted:", ""] + ["- " + x for x in GREEK if x] + ["",
     "## 6. The vision, whole", ""] + ["> " + l if l else ">" for l in V11.split("\n")]
    (D/"RUN-VISION-11.md").write_text("\n".join(o) + "\n"); print(wc(SEAL), wc(V11), wc(X.WITNESS))
