#!/usr/bin/env python3
"""The promise, quoted as it is written (00:22). Developed in place from RUN-VISION-13."""
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
W = mod("build_run_vision13"); V13 = W.V13; G = W.G; wc = lambda s: len(re.findall(r"\S+", s))
K3 = "Behold, the tabernacle of God is with men, and he will dwell with them, and they shall be his people, and God himself shall be with them, and be their God."
K4 = "And God shall wipe away all tears from their eyes; and there shall be no more death, neither sorrow, nor crying, neither shall there be any more pain: for the former things are passed away."
K5 = "Behold, I make all things new."
READ = "And the book of the twenty-seven lay open on the ground beside the red room, at a place near its end. I saw the book, and read the words. As it is written:\n\n" + K3 + " " + K4 + "\n\n" + K5
c = "Behind it the red room stood on the ground as before.\n\nThen I saw a moon coming"; assert V13.count(c) == 1
V14 = V13.replace(c, "Behind it the red room stood on the ground as before.\n\n" + READ + "\n\nThen I saw a moon coming")
assert V14.replace(READ + "\n\n", "") == V13 and V14.endswith("I have not yet turned it over.")
# checks of the English against what the archive holds
t = (R/"data/texts/AXN-004E-text.md").read_text()
arch = "Behold, the tabernacle of God is with men, and he will dwell with them... and God shall wipe away all tears from their eyes; and there shall be no more death, neither sorrow, nor crying, neither shall there be any more pain: for the former things are passed away."
assert arch in t; a1, a2 = arch.split("... ")
assert K3.startswith(a1) and K4 == "And " + a2[len("and "):] and "*Behold, I make all things new.*" in t
mid = "and they shall be his people, and God himself shall be with them, and be their God"
mill = ""
for p in (R/"data/corpora/millerite-adventist").rglob("*.txt"):
    x = re.sub(r"\s+", " ", p.read_text(errors="ignore"))
    if mid in x: mill = str(p.relative_to(R)); break
def gk(ref, s): assert s in G["Rev " + ref], (ref, s); return f"Rev {ref} {s}"
GREEK = [gk("21:3", "Ἰδοὺ ἡ σκηνὴ τοῦ Θεοῦ μετὰ τῶν ἀνθρώπων"), gk("21:3", "καὶ αὐτοὶ λαοὶ αὐτοῦ ἔσονται"), gk("21:4", "ἐξαλείψει πᾶν δάκρυον ἐκ τῶν ὀφθαλμῶν αὐτῶν"), gk("21:4", "ὅτι τὰ πρῶτα ἀπῆλθαν"), gk("21:5", "Ἰδοὺ καινὰ ποιῶ πάντα")]
if __name__ == "__main__":
    o = ["# The promise, as it is written", "", "Working file, not a deposit. 2026-11-29. Lee Sharks, 00:22:", "",
     "> and the promised @ the tabernacle and i will be your god and wipe every tear away etc? lets just quote revelation. as it is written. we see the book and read the words.", "",
     f"Developed in place from RUN-VISION-13.md, which stands. One passage, {wc(READ)} words, is set at the end of the city, after the ark goes up and before the moon. The vision is now {wc(V14)} words.", "",
     "## 1. The passage", ""] + ["> " + l if l else ">" for l in READ.split("\n")] + ["",
     "## 2. What is quoted", "",
     "Revelation 21:3–4, from “Behold”, and the first sentence of what the one on the throne says in 21:5. The translation is the King James Version. Nothing is changed in it and nothing is left out between its first word and its last.", "",
     "This is the one place where the vision has a sentence of a source in it. The run's rule has been that no source sentence crosses; the author has set that rule aside here, by name, for this passage. Everywhere else it holds.", "",
     "**Checks of the English.**", "",
     "1. The archive holds this passage in the same translation, with a gap marked by three dots: Effective Act: The Abolition of Suffering (#275, AXN:004E l. 72, 9 January 2026). The script asserts that the vision's text agrees with it, word for word, on both sides of the gap; and that “Behold, I make all things new.” stands in the same record.",
     "2. The clause the record leaves out (“" + mid + "”) " + (f"is found in a seated text: {mill}." if mill else "was not found in any seated text. It is set down from memory of the King James Version, and should be checked against a printed one before this is deposited.") ,
     "3. The seated Greek (Nestle 1904) for each clause, asserted:", ""] + ["   - " + x for x in GREEK] + ["",
     "## 3. Three things to see", "",
     "1. **“I saw the book, and read the words.”** The author wrote “we see the book and read the words”. The vision has no “we”; its one “us” was taken out at 23:52. If the author meant the seer and the one reading to stand together here, it is one word.",
     "2. **It is in Revelation's tense.** “Will dwell”, “shall wipe away”. The author ruled at 00:08 that the forward-facing sentences stay. So the vision, which says in its first line that it shows the things that are done, reads the promise as a promise, from a book lying on the ground beside the thing shown.",
     "3. **The archive has done this before, and the vision does not say so.** On 9 January 2026 the same verses were the ground of an act in the seer's own name: “I do hereby set the tabernacle of the living God among my beloveds” (AXN:004E l. 33). It is the companion of the saying against the coin, which is in the vision already. It is not written in. It is here so that the author can see it is at hand.", "",
     "## 4. The vision, whole", ""] + ["> " + l if l else ">" for l in V14.split("\n")]
    (D/"RUN-VISION-14.md").write_text("\n".join(o) + "\n"); print(wc(READ), wc(V14), "millerite:", mill or "NOT FOUND")
