#!/usr/bin/env python3
"""A run in the Matthew pack's own shape: two lines of the vision that collide, roots only crossing, no sentence of any source. The passage is the session's (2026-11-28). The script checks the two source lines at their places and measures the longest run of words the passage shares with each source."""
import re, pathlib
R = pathlib.Path(__file__).resolve().parents[3]
SRC = {"Pearl":"AXN-0472","the Epistle":"AXN-00D3","Walt":"AXN-022B","Antioch":"AXN-022E","I Am X":"AXN-0255","the Feist Source":"AXN-0360"}
T = {k: (R/f"data/texts/{v}-text.md").read_text(encoding="utf-8") for k, v in SRC.items()}
P = T["Pearl"].split("\n")
def at(a, b, s):
    span = re.sub(r"\s+", " ", " ".join(P[a-1:b])); assert s in span, (a, b, s, span[:120]); return s
S1 = at(1326, 1328, "I put it there for you, on purpose, so that you could find and sell it.")
S2 = at(3040, 3041, "I invented myself out of thin air and was created by my environment.")
PASSAGE = """A woman said to Jack, “When you are gone and we find what you left, what are we to do with it?”

He said, “The kingdom of literature is like someone who stood thirty years on the line at a plant. He had no trade and no papers. On his breaks he made a thing from scrap off the floor, and what he needed to know to make it, he invented. When it was finished he put it in his locker and taped a name to the door. The name was not his.

“In the thirtieth year he died, and the plant cut the lock and sent for the name on the door. She was behind on her rent. On the first of the month she carried the thing to a pawnshop to sell it.

“The man at the counter turned it over. He said, ‘Who made this?’ She said, ‘He did, out of nothing. Nobody taught him.’ He said, ‘Then it has no mark and no paper, and I cannot sell what came out of the air.’

“So she went to the plant for a paper. The office said, ‘It was made on our clock, from our steel. What this floor makes is ours. Leave it at the desk.’

“She said to the one at the desk, ‘When he asked you for a trade you told him he had none, and that you had given him none. Is the thing yours because the man was not?’ And she carried it home.

“So it will be with the work: what no one can sell, no one can take back.”"""
def toks(s): return re.findall(r"[a-z']+", s.lower().replace("’", "'"))
pt = toks(PASSAGE)
def longest(src):
    st = toks(src); best = (0, "")
    for n in range(12, 2, -1):
        grams = {" ".join(st[i:i+n]) for i in range(len(st)-n+1)}
        for i in range(len(pt)-n+1):
            g = " ".join(pt[i:i+n])
            if g in grams: return n, g
    return best
rows = [(k, *longest(v)) for k, v in T.items()]
roots = ["put", "find", "sell", "invented", "air", "made", "for"]
md = f"""# The Matthew transform, forward and back: one run each

Working file, 2026-11-28. Not a deposit.

## 0. Why this run

Lee Sharks, 19:24, on the packs, the run of Pack A and the bank-box attempt:

> its not really the matthew transform tho..its mostly pastiche of existing sources. the matthew transform hid in plain sight for two thousand years.

And at 19:27, to the proposal of one attempt in the transform's actual shape: “yup, lets try that”. And at 19:28, while the run was being written:

> forget the through the mouth constraint. this is the matthew transform forward and back

So the rule that source sentences be kept unedited is withdrawn by the author, for the whole project. The four-kind sentence log (KEPT, ALTERED, TURNED, MADE) no longer governs a run; the operator log does. The pilot, RUN-A and the bank-box attempt stand as run, as centos. This file has the transform forward (§§1–5) and back (§6).

What was wrong, measured against the paper's exemplar (Revelation 22:12–13 to Matthew 20:1–16): two verses become sixteen; three roots and one ordered pair cross; the rest is made, forced by a collision between two things the vision says side by side. The earlier runs kept the sources' sentences (seven of nine in RUN-A forward, nine of fourteen in the pilot), took many lines down to few, had no collision, and ran under a rule in PACKS.md that a passage “mostly MADE has failed”. That rule is withdrawn for this run and should come out of the packs.

## 1. The source: two lines of the vision

> {S1}

*Pearl ll. 1326–1328*

> {S2}

*Pearl ll. 3040–3041*

**The relation:** put … for you … find … sell. **The pair:** out of thin air / by my environment. In the vision both stand in one voice and do not meet.

## 2. The operators

**P1.** The speaker gets a past: a teacher in a land, with followers who ask. **P2.** Third-person past; he teaches by likenesses from the common life of the land; nothing the speaker says of himself stands free, and each surviving predicate is what a person in the likeness does or says.

**D / M-D.** The first person dissipates. Only roots cross: *put*, *for* (a name), *find*, *sell*; and both terms of the pair, *air* and *made* (with *invent*). The pearl, the rib-cage, the child, the website and every sentence of every source stay behind.

**C1. The speaker's making becomes a worker's.** M1: the likeness formula with a human maker.

**C2. “So that you could … sell it” becomes an attempted sale at a set time.** M2: a dated clause (“On the first of the month”) and a carrying to a place of sale.

**C3. The pair becomes two refusals, in the source's order (ENACT).** A person cannot bear “out of thin air” and “created by my environment” as a title. Conserved as the two answers the finder gets: first from the one who needs a maker's mark, then from the one who claims to be the maker. M3: two speeches in parallel form, air first, floor second.

**C4. The collision.** In a told economy the two terms collide with the relation. A thing can be sold only with a title to it. If it came out of the air it has no title; if the environment made it, the title is the environment's. Either way it cannot be sold by the one it was put there for. And the two refusals collide with each other: the same place that says the man was nothing says the thing is theirs. M4: two voices; the office's claim in direct speech, and the finder's answer to one person, in the second person, as a question.

**C5. “For you” becomes a name.** M5: a name written on the place the thing is put, which is not the maker's.

**C6. The closing line says the operation.** What cannot be sold cannot be taken back. M6: one line, future, two clauses that mirror (“no one can sell … no one can take back”). The source's own line on the gift that cannot be revoked was not used; the passage arrives at it.

**L1** (the world): the common life of the land behind the land, Redford and the plants. The figure taken is a thing made by a worker for himself on the plant's time from the plant's scrap. This is from the session's general knowledge of shop life and was not looked up. **L2** (anchors C3): in Isaiah, the made thing and its maker disputing who made it (29:16, in the same chapter as the sealed book; from memory, not opened). Taken: the form of a dispute over making. Here it is turned: the makers claim, and the buyer denies there is any maker.

**E.** Occasioned by a follower's question about what to do with what is found.

## 3. The passage

{chr(10).join('> ' + l if l else '>' for l in PASSAGE.split(chr(10)))}

{len(pt)} words, from two lines of {len(toks(S1 + ' ' + S2))} words.

## 4. What crossed, measured

Longest run of consecutive words the passage shares with each source (lower-cased, punctuation dropped):

| Source | Words in the longest shared run | The run |
|---|---|---|
""" + "\n".join(f"| {k} | {n} | “{g}” |" for k, n, g in rows) + f"""

Roots of the two source lines that stand in the passage: {', '.join(r for r in roots if r in pt)}. The words *pearl*, *rib*, *ribcage*, *child*, *poem*, *website* and *revoked* do not occur: {all(w not in pt for w in ['pearl','rib','ribcage','child','poem','website','revoked'])}.

## 5. What to look at

1. **Whether the story is forced.** Each made thing was meant to follow from the one before: a line worker has breaks and scrap; a locker has a door and a lock; a death clears the locker; rent sends the thing to a counter; a counter asks for a maker; the lack of one sends her to the office; the office's claim is the second term of the pair arriving by itself. Whether it reads that way is for the author.
2. **The answer at the desk.** “Is the thing yours because the man was not?” is the collision said in one question. It was not planned as a line; it came from having the office refuse him a trade earlier in the passage.
3. **What the passage does not say.** What the thing is. Whose name is on the door, beyond that it is hers. That the gift cannot be revoked: the last line gets there from the failed sale.
4. **Not blind.** The session has read the Feist Source, which has a pearl a jeweler cannot price (§18). The counter in this passage sits where that jeweler sits. The path to it here runs through the pair, which §18 does not use.
5. **A possible echo.** The two-voice form with a closing question is the form the Matthew pack forces, and the session knows Matthew 20. One word that leaned on it (“Friend”) was taken out before this file was written.
"""

BSRC = (R/"data/texts/AXN-0360-text.md").read_text(encoding="utf-8").split("\n")
for n, s_ in [(1301,"## 33. The Review Tribunal"),(1327,"This man has written."),(1333,"This man has preserved more than he has damaged."),(1335,"What does it matter if some of the vessels are strange?"),(1337,"But the machinery cried out:"),(1339,"Take down the vessels."),(1345,"If the work remains, the judgment will not hold.")]:
    assert s_ in BSRC[n-1], (n, s_)
bsrc_words = len(toks(" ".join(BSRC[1302:1345])))
BACK = """These are the words of the one who was taken down and remains, whose vessels are strange: I know your finding, that you looked and had nothing to say against the work. And I know the voice among you that cries, Take it down. I am coming. A judgment that cannot hold a work will not hold."""
bt = toks(BACK)
def longest2(src, pt_):
    st = toks(src)
    for n in range(12, 2, -1):
        grams = {" ".join(st[i:i+n]) for i in range(len(st)-n+1)}
        for i in range(len(pt_)-n+1):
            g = " ".join(pt_[i:i+n])
            if g in grams: return n, g
    return 0, ""
brows = [(k, *longest2(v, bt)) for k, v in T.items()]
md += f"""
## 6. Back: a told scene compressed into the vision

The paper, XIV.7: every pairing “can be read from right to left, as the work of a seer who had Matthew and compressed it”. The backward run is that reading done as a transform: the operators of §2 inverted, roots only crossing, many words down to few.

**The source** is a scene of the told life that no row of the ledger reaches from any vision: the Feist Source §33, The Review Tribunal (ll. 1301–1345, {bsrc_words} words). It is not copied here; it stands in the seated text. In outline: friends petition for review; a tribunal examines the record and finds writings, teaching, languages, reading, and no reason the work should be destroyed; its chair says what the man has done and asks what it matters “if some of the vessels are strange”; the machinery cries out to take down the vessels, the names and the writings, because “If the work remains, the judgment will not hold.”

**The relation:** work … remains; judgment … holds. **What the scene does twice:** take down; remain. **The rare word:** vessels, strange.

**D back.** The told world dissipates: the friends, the petition, the tribunal, its chair, the record, the list of what was found. Roots cross: *work*, *remain*, *judgment*, *hold*, *take down*, *find*; and the rare word. **M.** First person, present, one voice.

**C1 back. What a person in the scene says of the man becomes what the speaker is.** The chair's findings (“This man has …”) are let go as a list and return as the standing to speak. M: a sender's clause in the form In the Midst of the Seven describes, taking one attribute.

**C3 back. The rule becomes the title (the inverse of ENACT).** In the scene, taking down and remaining are an order of events: the work remains, so they take it down, and it remains. A told life can only narrate that. The vision predicates both of the speaker at once. M: an ordered pair as a title, in the scene's order: “taken down and remains”.

**C4 back. Two voices become two things known.** The chair and the machinery answer each other in the scene. In the vision neither answers; the speaker knows both, side by side. M: “I know … And I know …”.

**C2 back. The procedure becomes an advent.** The review after the condemnation is a bounded proceeding. M: “I am coming.”

**C5 back.** The kinds found (writings, teaching, languages, reading) become one word: “the work”.

**C6 back.** The scene's conditional (“If the work remains, the judgment will not hold”) loses its *if*. M: a statement, future, with *hold* said twice.

**The passage:**

> {BACK}

{len(bt)} words, from {bsrc_words}.

| Source | Words in the longest shared run | The run |
|---|---|---|
""" + "\n".join(f"| {k} | {n} | “{g}” |" for k, n, g in brows) + """

**What to look at.**

1. **The title.** “The one who was taken down and remains” was not in the scene as a title; the scene has the two verbs as things done to writings. As a title it is no longer about a tribunal. Run forward, it could be told as the purge of the writings, as a death and a return, as a ban, as an account closed and a record that passed into other hands. The Feist Source tells several of those (§34, §§43–44), and the session knew them when it wrote the line, so this is not a test of what the title generates. That test needs a reader who has not seen the Feist Source.
2. **What was let go.** Everything the scene is made of as a scene. The chair's sentence about strange vessels survives as three words.
3. **The ratio.** The forward run took two lines up to a scene. This took a scene down to four sentences. That is the direction the paper's exemplar runs in each case.
4. **The form of the first clause** is the station letter's, as In the Midst of the Seven describes it. No station is named.
"""

(R/"rebuild/unfolding-map/feist/RUN-COLLISION.md").write_text(md, encoding="utf-8")
print(len(bt), bsrc_words, brows)
print(len(pt), rows)
