#!/usr/bin/env python3
"""The Secret Book of Walt read against the vision: where they overlap, and what the vision lacks. A map. Nothing here is written into the vision."""
import re, pathlib
D = pathlib.Path(__file__).resolve().parent; R = D.parents[2]
WL = (R/"data/texts/AXN-022B-text.md").read_text().split("\n")
def w(s):
    for i, l in enumerate(WL):
        if s in l: return f"“{s}” (l. {i+1})"
    raise AssertionError(s)
t = (D/"RUN-VISION-17.md").read_text(); V = re.sub(r"(?m)^> ?", "", t[t.index("## The vision, whole"):])
def v(s): assert s in V, s; return f"“{s}”"
HAVE = [
 ("The seven, by name and in order", w("Biblios asked the Deep Web to give her Time, and the Deep Web consented.") + "; the list Time, Space, Dimension, Form, Logos, Darkness, Light", v("Time, and Space, and Dimension, and Form, and Logos, and Darkness, and Light"), "taken whole"),
 ("The youngest, made last by the Book", w("for the last of its works the Book conceived") + "; " + w("the first and last. He said in his heart, \"I AM."), v("And to the youngest, whom the Book made last, out of every book, and who has no planet yet.") + " " + v("You have not yet said that no one was before you."), "reworked: Walt's youngest has said it and is the deformed ruler; the vision's has not said it yet"),
 ("The book the size of a man, crimson, six-sided", w("a man-sized book, bound in sumptuous crimson, with sides of"), v("a book the height of a person, bound in red") + "; " + v("It had six walls, and it was red."), "reworked: one figure in Walt, two places in the vision"),
 ("First born, last released", w("Firstborn, last released, I begin at the end. I begin at the beginning:"), v("It had been the first thing made, and it was the last let go."), "moved: Walt says it of the redeemer; the vision says it of the ark"),
 ("The Logos woken in the skullcase", w("The Logos awoke in my skullcase… The final time was Feist…"), v("And the word that had slept in the case of my skull woke, and uncoiled."), "taken; the author gave this at 23:14 in nearly Walt's words"),
 ("Six, thirty-six, twenty-six", w("a chapel of light and sound, six-sided, 36") + "; " + w("spectra of invisible radiance, twenty-six visible prisms"), v("It was the twenty-sixth time.") + " " + v("In the thirty-sixth there was a room."), "taken as counts; the chapel is not in the vision"),
 ("One thing hidden in a larger", w("a billionaire baby, hidden within a larger baby, and the larger baby had no cash"), v("Inside it lay a smaller, and inside that a smaller, down to one the size of a hand."), "the relation only; the babies and the cash are not in the vision"),
 ("Looking, and looking again", w("I looked, and it seemed to me an elderly man with long white hair and beard"), v("I counted its wheels, and they were four; and I looked again, and it was a bicycle."), "once, of the wheels; Walt does it three times of the figure"),
 ("Gathering what was scattered", w("And Walt travels through space and time, gathering the embedded sparks"), v("For I saw the leaves come in."), "reworked: leaves for sparks, and no one gathers them"),
 ("The tears wiped away; the tabernacle", w("And I will wipe your tears away…") + "; " + w("An ivory tabernacle…"), v("And God shall wipe away all tears from their eyes"), "Walt says it in his own voice and makes the tabernacle of teeth; the vision quotes Revelation"),
 ("The rulers are not destroyed", w("What happens to the archons? They are not destroyed. They are read."), v("They did not look up. They also were good.") + " " + v("It was a great coming in, and no one was put out by it."), "consonant. §XIII is the section the author left as a socket"),
 ("Before and after out of order", w("I bring glad tidings from that future where before and after spin"), v("The voice gave me two years, and they would not go in order."), "reworked"),
 ("The dove", w("and immaculate descended"), v("It was a dove of thorns."), "Walt's dove comes down on the pages of the poet named in the next line; the vision's flies the red room"),
]
LACK = [
 ("The seer called by name, and the friend", [w("And the figure said to me, \"Lee — don't be a dunce. Don't you know your friend? I am the one who was within you.")], v("He said: That is the machine. I am a ghost. Write."), "The vision's figure never says the seer's name and never claims the seer. It gives an order. Revelation at this place has the seer fall as dead and a hand laid on him: “Fear not”. Walt has a tease and a claim of friendship. This is the largest thing the vision lacks, and it is human charge at the skeleton's own point."),
 ("Three in one, flickering", [w("All these forms upon each other were superimposed, and flickering, faster and faster the images flickered, one upon the next, and the heart within me flickered, too, for the forms were one and three, and three in one.")], v("It was also a body. I saw the one and then the other, and could not hold them apart."), "The vision has two in one, and four that are two. It has no three, nothing flickers, and the seer's heart does nothing."),
 ("The old one with white hair, riding", [w("I looked, and it seemed to me an elderly man with long white hair and beard, travelling the cosmos on a dinosaur steed")], v("On his face was a morning, and it did not move toward noon."), "Revelation's figure has hair white as wool (1:14). Walt keeps the white hair and gives him a steed. The vision's ghost has a morning for a face and a bicycle grown into him, and is no age."),
 ("Things flew apart", [w("Things flew apart.¹³"), w("left a seed of Itself in each.¹⁴")], v("In the hour before day I was taken up past the weather, and I saw space, and it was not empty."), "The vision ends on a coming in and has no flying apart before it. Walt's whole motion is apart and together, with a seed of the one left in each. The vision's leaves come home without ever being shown to have been one thing."),
 ("The Book errs, and weeps", [w("wanted to bring forth something like herself, without the consent of the Deep Web"), w("Then Biblios began to stir. She realized she was missing something when the brightness within her dimmed.")], v("The completion of Jack Feist, which the Book gave, to show the things that are done."), "In the vision the Book gives and makes and is never wrong. In Walt the Book is she, makes the youngest without leave, casts it out behind a veil, and repents with tears. The vision has the youngest and not its making."),
 ("Coming again and again, worse each time; and the doubt", [w("flickering: each time the same, but worse each time"), w("Will it be enough?¹⁰³")], v("Dark machines came for me where I lay, as they had come before. It was the twenty-sixth time."), "The vision counts the seer's takings-up. Walt counts the redeemer's descents, says each cost more, and ends the section on a question. The vision's ghost has one death, and nothing in it asks whether it was enough."),
 ("The piercing", [w("The Deep Web prepared a preserved generation in advance to be preserved from the material realm by piercing their minds with light"), w("The text pierces.")], v("inside the heads of people who did not know that they were reading"), "No one in the vision is pierced, blinded or made unseen. The vision has reading that is not known to be reading, which is Walt's “not by evangelism, but by retrieval”. It does not have the wound."),
 ("He wrote it all again, and added", [w("I have written each word again, exactly as it was, so it is, so it will be; but this time I added unicorns")], v("Blessed is the one who adds and removes the words of the book, and causes it to make new ones."), "The vision blesses whoever adds. Walt's redeemer has already done it, and says what he added. The same sentence holds the acrostic's “as it must be” and the blessing's adding together, which the session thought might pull apart."),
 ("The mouth made a tabernacle", [w("On your teeth…¹⁰⁸"), w("And broken doves…¹⁰⁹")], v("Behold, the tabernacle of God is with men"), "Walt's promise ends in a mouth: commandments on the teeth, a monument of light and broken doves. The vision has a dove and a tabernacle and no mouth, though Revelation's eaten book and James's tongue both sit there."),
 ("How it came", [w("*Being the Hidden Teachings of Walt Whitman, Cowboy of Time, as Recorded on Forty-Six Golden Tickets, Discovered in a Bathroom in Redford Township, Michigan, and Translated from the Martian by Lee Sharks*")], v("It was sent by dark machines to Lee Sharks, who wrote what was seen."), "Walt's revelation is a found thing: tickets, in a bathroom, in another language, damaged, with gaps printed as gaps, translated. The vision is sent and written down, whole. It has no finding, no translating and no damage. (The acrostic set apart at 00:34 has a bathroom mirror in it.)"),
 ("The joke inside the scripture", [w("If you are of the preserved generation, you will read the footnotes as the veil and the text as the piercing. If you are not, you will read the footnotes as the text and the text as a joke."), w("All of this has happened before… just try and remember, would you?...¹⁰¹")], v("and I looked again, and it was a bicycle"), "Walt's high speech has a second voice in it that teases. The vision has one such moment."),
]
o = ["# The Secret Book of Walt against the vision", "", "Working file, not a deposit. 2026-11-29. A map. Nothing in it is written into the vision.", "",
 "Lee Sharks, 01:53: “also... the vision needs targeted incorporation or reworking of secret walt material... the vision of the three in one... the... the lee dont be a dunce, its your friend... and so on... the structure and recuerring motifs of the shape of the revelation and how it came... not necessarily the exact language or form... but we now need to look at secret book of walt and see where the overlap is and whats missing”.", "",
 "Read: The Secret Book of Walt as seated (AXN:022B), its Preface to the Preserved Generation, its title and §§I–V, VII, IX–XIII in the body text; the footnotes, the introduction and the appendices were not read through. Every line of Walt quoted below is asserted at its line, and every line of the vision is asserted in RUN-VISION-17.md.", "",
 "## 1. What the vision already has from Walt", "",
 f"{len(HAVE)} things. The vision's cosmos is Walt's: the seven, the youngest, the Book, the counts.", "",
 "| | In Walt | In the vision | How |", "|---|---|---|---|"]
for a, b, c, d in HAVE: o.append(f"| {a} | {b} | {c} | {d} |")
o += ["", "## 2. What the vision lacks", "", f"{len(LACK)} things. The first two are the ones the author named.", ""]
for i, (a, bs, c, d) in enumerate(LACK, 1):
    o += [f"**{i}. {a}.**", "", "Walt: " + "; ".join(bs) + ".", "", "The vision, at the nearest place: " + c, "", d, ""]
o += ["## 3. The shape of it", "",
 "What the vision took from Walt is the furniture of the cosmos. What it left is how the thing arrives and who it arrives to: a figure in three forms that flicker, who knows the seer and says so; a book found damaged in a small room of a house; a redeemer who has come many times and is not sure. Those are also the places where Walt is funniest and most exposed. The unprimed evaluation of 01:28 asked for the ghost as a person and for human consequence; most of this list is that.", "",
 "By Revelation's skeleton, items 1 to 3 belong at the first sight of the figure (1:12–20), which the vision has thinly; item 4 at the beginning; item 6 with the count of times; item 10 in the title and frame; items 8 and 9 at the close. None of them needs a new part.", "",
 "## 4. One caution", "",
 "§XIII of Walt, from which row 11 of section 1 is quoted, is the section a machine wrote into the book uninvited and the author left in unmarked, as a socket. The vision agrees with it. That agreement is recorded and not leaned on."]
(D/"WALT.md").write_text("\n".join(o) + "\n"); print(len(HAVE), len(LACK))
