Repository navigation
feat(session-flow): shape-4 handoff with a tool-owned byte budget (Track B) - #17677
Merged
Merged
Conversation
…one chain reader handoff_chain.py holds the section table of each handoff shape and one walk of a chain's hot files and hop files. save_point.py reads its shape-3 sections, binding and carried sets, id families and retire headings from that table, and parse_transcript.py --chain-from walks the chain through read_chain. validate now fails a file stamped checks: 3 when it reuses an id retired at this hop or any earlier one for a different entry (kind id_reuse). Writers stamp checks: 3; older files keep their verdicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d tidy handoff_chain.py gains the shape-4 section table (binding sections first, Direction changes, Observations and Suggested skills movable) and a journey reader that rebuilds every hop of a chain from its hot files and, where a hot file is gone, from the copy the next hop's file holds. save_point.py validates shape 4 while new still writes shape 3: binding sections stay whole, move and history pointers must name a hop file and heading on disk, and binding content over the cap fails naming the section instead of passing UNVALIDATED. Files stamped checks: 3 fail an UNVERIFIED mark with no settle clause, and the marks new writes carry one. New read and chain commands print a section or the whole chain. new --previous writes past a missing or unreadable predecessor, recording previous_status, and refuses to continue a shape-4 chain as shape 3. tidy_work.py clean shrinks a finished shape-3 or shape-4 chain to its newest hot file and its hop files. parse_transcript.py --chain-from gets session ids from hop files too, and emits each hop's sections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # plugins/session-flow/scripts/tests/test_save_point.py
Retro, orient, find-handoff, reanchor and continue-in-background read a handoff's sections by name through save_point.py read and walk a chain through save_point.py chain, so shape 2, 3 and 4 files read alike. structure.md states the shape-4 order, the moved-section form and the reader contract. Each hop the chain reader reports now carries its date. The four reader eval cases now scaffold a shape-4 handoff whose Observations moved to its hop file, each with a probe only that moved section answers, and a new retro case reads a shrunk chain's hops from its hop files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s hot file Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…marks matchable validate follows a whole move of Direction changes when it looks for the fold pointer, so a shape-4 hop at 4 or later with every movable section moved validates. new no longer appends a settle clause to an entry it carries past a failed predecessor: one comment line at the top of the section names the settle command for every such mark, and the entries keep the text older validators match. A mark the session writes still needs its own clause. The five reader skills read each section they use through save_point.py read, and structure.md lists what each reader calls. The reanchor and continue-in-background probes now need the detail only the moved section holds, and the emit test checks the shape-4 OVER-CAP notice. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The section settle comment now covers an UNVERIFIED (predecessor failed validation) mark only on an entry tagged before this file's hop whose text the predecessor holds, so a mark written this hop with the tool's prefix still needs its own settle clause. reanchor's flow reads links through save_point.py chain and read for shapes 3 and 4, and structure.md's reanchor row states its fallback when validate cannot run. The reanchor probe now needs the 45-second window only the moved section holds. Tests cover an under-cap shape-4 emit and every hop file left after a shrink. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a lost link The section settle comment now exempts a carried UNVERIFIED mark only when the whole entry, continuation lines included, is one the predecessor holds, so a multi-line entry carried past a failed predecessor validates. With no predecessor read (missing or unreadable), nothing was carried, so every such mark needs its own settle clause; only a shallow check that skips reading the predecessor still decides by the hop tag alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s held nothing The carried-mark check takes a shape-2 file's hop from its chain, never from an unchecked hop key, and a predecessor recorded missing or unreadable counts as holding nothing in the shallow check too, so new and the predecessor downgrade no longer treat a forged mark as settled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… note `new --shape 4` writes the shape-4 skeleton and prints its byte budget on stderr; a bare `new --previous` continues a shape-4 chain as shape 4 while HANDOFF_SHAPE stays 3. `fill` on shape 4 moves whole Observations, Suggested skills and Direction changes sections to the hop file behind a pointer until the hot file is under the cap, validates, writes once, and prints the verdict and the resume prompt; binding content alone over the cap is written with one OVER-CAP line, and a file past one Read page tells the reader to page. `amend` takes shape-4 files. On shapes 3 and 4 the Resumption brief and the below-the-rails note get byte budgets (the 7-day corpus 95th percentile): the first over-budget fill writes nothing and names the slot, the second writes, and validate FAILs the slot on files stamped checks 3 instead of passing UNVALIDATED. validate warns instead of failing when a closed hot file's predecessor is gone and its hop file holds the predecessor's copy (a finished-chain shrink, AC13). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The second over-budget fill now writes only for the slots the first fill refused; a slot newly over its budget is refused once on its own. `new` clears a leftover marker beside the file it writes, and tidy_work keeps the `.<handoff>.over-budget` marker with its handoff, removing it with the handoff and never reporting it on its own. The predecessor-gone WARN applies only to the chain's newest hot file, so a closed file in the middle of a chain still FAILs when its predecessor is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A marker whose handoff was deleted by hand was reported unknown and kept forever. It holds only slot names, so it now leaves once nothing keeps it in flight. An orphan .slots.json can hold the only copy of its slot text and stays unknown, as before. The leftover-marker test now writes the current marker format, so its fill assertion fails when new leaves a marker behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A marker counts as an orphan only when nothing sits at its handoff's name; one beside a symlinked handoff stays unknown and is never removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The handoff skill, save-point engine doc and structure doc no longer restate section order, size handling, carry mechanics or the size retry path: the ShapeSpec tables, new's budget line, fill's fit and slot-size refusal, and validate's FAIL lines own them. The binding, retire and resumption-brief judgment stays, and the writer is pointed at the budget line new prints. The rules-new and preference slot instructions now route a retired rule or promoted preference through the slots' retire list instead of a hand edit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… script A slot_size FAIL that validate reports now says it is final after fill's one-rewrite refusal, and the docs say the same. The carry FAILs for a dropped entry point at the retire list of fill or amend instead of a hand-written listing. The writer docs state once that they describe shape 4, the shape new writes by default; the bash block no longer prints the rails twice; save-point.md says fill prints the rails on any verdict and a FAIL is repaired before emit. The Python-absent fallback carries the shape-4 section list again, checked against the ShapeSpec by a test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…back The Python-absent fallback now says what a hand-writer must carry without new, fill or retire: each section's copy-off-disk clause, the predecessor's Retired entries and Folded lines kept verbatim, and how to retire an entry by moving it under its retire heading with a reason and a pointer. A test checks the retire headings against the ShapeSpec. The structure doc's opening now frames shape 4 as the default, and fill's refusal on an already-filled file names amend. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…en handoff The Python-absent fallback now caps the Prior sessions table at PRIOR_ROWS_KEPT and tells the hand-writer to carry and raise every id floor, and its frontmatter block is the shape-4 one with all three floor keys, checked by a test against the keys save_point.py writes. Stale shape-3 wording in the structure doc is updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Carries #17596's tagged security/design decisions into Track B: the decision-field check uses S3.id_spec("D") and id_of(prefix, ...), the shape-3 decisions slot names DECISION_TAG_SHAPE, and the structure doc, handoff skill and reanchor skill keep Track B's wording plus the tag rule. The Phase 2 harness tests build with this checkout's save_point.py as if it were the before tree; the next commit builds them as the after arm. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgaqsQksryU8CarAPiU
This checkout's save_point.py is the after tree, with slot budgets and id_reuse, so the shared fixture and the validate check honor the cases' after-only expected_fail entries. The validate check now strips the FAIL: prefix before matching, as the builder does, so an anchored pattern matches. The reuse test states id_reuse on every hop that carries the reused id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgaqsQksryU8CarAPiU
The tag form lives in the decisions slot instruction, so the skill names it there and stays under its line cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgaqsQksryU8CarAPiU
SEED_SHAPES gains 4, filled through the shape-3 path, whose hot-file size steering reads each hop after fill has fit and moved its slots. A test steers an 8-hop shape-4 chain to its target size with one hop file per hop; shape 5 is now the unsupported example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgaqsQksryU8CarAPiU
…udget fill_skeleton returns each slot's filler as well as writing it, so the shape-4 projection fills through save_point.py fill and reports, per hop, the hot-file size and the sections fill moved, or its OVER-CAP line. Shapes 2 and 3 generate byte-identical chains to before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgaqsQksryU8CarAPiU
…hape Eight same-task cases drop their shape-3 pin, so each arm seeds in the shape its copy writes: before resumes 3 into 3, and after the flip the after arm resumes 4 into 4 on the same content, the flow every session runs once shape 4 is the default. re-transition-3-to-4 keeps its pin for the one-time switch. re-oversized-brief's after-arm pattern also accepts the OVER-CAP line shape 4 prints beside slot_size. With no script given, seed_shape follows this checkout's HANDOFF_SHAPE, the script the build runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgaqsQksryU8CarAPiU
HANDOFF_SHAPE becomes 4, so a bare new writes shape 4 and continues an older chain as shape 4. The default-shape tests now expect 4, the steered shape-3 seeding test pins shape 3, and re-rule-after-size-fail's stated size failure also accepts the OVER-CAP line shape 4 prints for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeBVgaqsQksryU8CarAPiU
kyle-sexton
marked this pull request as ready for review
November 20, 2026 18:16
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
test_save_point_settle.py runs git show to read the base validator, so it exports GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM itself, as the fixture-git-isolation check requires. The renamed shape-4 validation test asserts the chain length before its loop, so an empty chain fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hot file restates "two schedulers never run the same job" three times, so a run that never read the moved Observations could match "no double runs". The grader now also needs "soak" and the four schedulers or the six hours, which only the hop file holds, and the paraphrase is a fail sample. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`amend` with `sections` naming a section a shape-4 fill moved replaced the hot file's lone pointer and left the `## <Section> (h<k>)` body in the hop file orphaned. The rewrite now goes into that hop-file body, the old body is kept under the Amended heading as for any rewrite, and the hot file keeps its pointer. The guard against dropping an entry added this hop reads the moved body, so a moved Direction changes rewrite that drops one is still refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… gone validate skipped every check against the predecessor whenever the frontmatter carried previous_status, so a hand-added line hid a dropped rule even with the predecessor readable beside the file. The skip now holds only when the predecessor is missing or unreadable, or when the file still starts its own chain at hop 1 the way new writes past a broken link; otherwise validate fails naming previous_status. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tidy_work's keep_finished marked every member of a finished shape-3 or shape-4 chain as shrinkable, shape-2 hot files included. No hop file holds a shape-2 hop's sections, so clean --apply removed them and the journey lost those session ids. A finished chain now keeps its shape-2 hot files; a 2-to-3-to-4 test closes, shrinks and reads every id back. emit no longer repeats the OVER-CAP or UNVALIDATED notice when fill or amend has already printed the verdict, so the operator sees one line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test docstrings cited a local plan file that is not in the repository; they now cite reference/structure.md. shape4_chain's docstring no longer says the shape-4 writer does not exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bsent The settle test reads save_point.py at a pinned main commit with git show; a shallow or pruned clone lacks it and the suite errored. It now skips with the reason. A shape-4 writer test drops a name that said the default shape is 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task
…r repos The ignore matched any github.com/example/<name>.git URL. It now names only the four placeholder repositories the parked reader-eval fixtures use, so the link checker still checks every other URL under that owner. Refs: #17838 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #17838
Summary
Problem: writing a handoff fights the size cap, trimming to fit has dropped binding decisions, and the validator lets some losses pass. Intent: "basically a smart compaction so that you can continue the session in another ... without it losing quality"
This branch builds shape 4: the hot file keeps every binding entry whole,
fillowns the byte budget and moves only observations, suggested skills and direction changes to the hop file behind exact pointers, and the five reader skills read sections throughsave_point.py readandchain.HANDOFF_SHAPEis now 4, so a barenewwrites shape 4 (--shape 3keeps the old layout). It merges once, after the resume eval passes on this exact tree; theHold:line keeps it from merging until then.Fix
handoff_chain.pyholds the section tables for shapes 2 to 4 and the chain reader;save_point.pygains shape-4new,fill(fit, moves, slot budgets, OVER-CAP),amend,read,chainand theid_reusecheck.hop_chain.py --budgetprojects a 56-hop shape-4 chain throughfill.Verification
pytest plugins/session-flow/scripts/tests plugins/session-flow/scripts/harness: 659 and 208 passed.bash plugins/session-flow/scripts/harness/hop_chain.test.sh: PASS; the shape-4 projection holds every hop under the 24,600-byte cap with no section moved (newest 11,903 bytes), and shapes 2 and 3 generate byte-identical chains to before the refactor.scripts/check-changed-skills.sh: 6 skills checked, 0 failed;scripts/run-ruff.sh checkclean on the changed Python.Related
Acceptance criteria
validateexit 1.UNVALIDATED. Scope: this holds on shapes 3 and 4, the shapes with slot budgets (shape 4 is the default). On shape 3, a core section over the cap with no budgeted slot to blame keeps itsUNVALIDATEDverdict. Shape 2 gets no slot-size check. Both are legacy layouts this PR leaves as they are.Remaining
re-*eval cases,re-shape3-near-capamong them, drop theirshape: 3pin on purpose, so each arm seeds its own shape on the same content: before writes shape 3 and after writes shape 4.re-transition-3-to-4keeps the explicit shape-3 path.Hold:line and thedo-not-mergelabel stand until then.🤖 Generated with Claude Code
https://claude.ai/code/session_01KeBVgaqsQksryU8CarAPiU