Repository navigation
feat(#454): slice decisions context, script PR ops, shrink commands - #465
Merged
Merged
Conversation
Parse the per-spawn counts the wave needs: a resumed flag on each request (an end_turn answered by a coordinator message), Read re-reads, exact repeats and ranged reads, ledger index and body reads, ADR/PF citations in assistant text, the DECISIONS_CONTEXT shape (full, slice, pointer, none) with its UTF-8 bytes, Bash result bytes by class, files written by Edit and Write, and the OPERATION of the spawn prompt. Spawn calls keep their parent message id and command and Skill calls keep their arguments. Two new limits, maxReadPaths (4,096) and maxCitationIds (512), bound the tracking sets; a stream that reaches one reports it in its stats.
Report what the parser now counts. Each agent type gains p90 turns, median, p90 and max peak context, first-turn cache hit share, median first-turn read ratio, the first-turn cache read against a static-prefix estimate, a sibling count and a staggered subset (a later same-type spawn under five minutes after another, not launched with it). New tables: reads, decisions context shape, Bash results by class, files written against turns for Code implement spawns, and a run distribution per workflow (median and p90 spawns and ce per run, by type with zero-type runs included, a plan-document split for /implement, Code-fix spawns by OPERATION). Cache misses are sorted by cause: ttl, within-ttl, within-ttl-resume or unknown. The CLI passes the parser counts, the commands and the sibling flag through, and reports a reached read-path or citation cap as a notice. A new fixture directory holds one session of three spawns whose counts the tests pin by hand.
--since and --until bounded token usage only. The wave-4C signals (reads, re-reads, ledger reads, citations, Bash calls and result bytes by class, quiet test runs, files written) were counted over the whole transcript, so a spawn still running after --until kept adding calls while its token totals stayed fixed, and a spawn that began before --since counted its earlier calls. The parser now takes the window and counts a tool_use, a tool_result or an assistant text block only when its own entry's timestamp is inside it, by the request filter's convention: --since inclusive, --until exclusive, an undated entry outside a bounded window. An entry outside the window is not seen at all, a repeated tool_use is judged at its first sighting, and the spawn prompt (operation, decisions shape) is kept because it describes the spawn, not activity. The window type and test move to types.ts so the parser and the report share them; report.ts re-exports both.
Gate 2 offered Revise with no limit, and each revision spawns five agents (Plan x3, Synthesize, Design). Revise now runs only while fewer than 2 revisions have run; after that Gate 2 offers Accept, Cancel, or "Restart /plan with these constraints". The Error Handling rule says the same, and the Architecture diagram shows the Phase 1 and Phase 14 Git spawns and the bounded Revise loop. The first-pass fan-out is unchanged: there is no quality evidence to cut a perspective. A guard reads both learning builds and holds the bound, the replacement menu and the diagram, each with a known-bad probe.
verify-evidence.cjs gains two subcommands. `publish` is the whole update-pr-evidence operation: verify, scrub the composed block, splice it (the compare-and-swap), edit the body, read it back, then scrub and post the evidence comment. It makes at most 8 gh writes under a deadline of its own, retries a 5xx once, makes no gh write after a scrub that did not exit 0, and prints exactly the `## PR Evidence` block or `TRACEABILITY: DEGRADED (evidence unavailable)`. `readiness` is check-merge-readiness: it reads the thread count, the review decision and CI (through ci-wait's classifier) and the evidence at the head, applies the ladder, and prints the `## Merge Readiness` block. Both answers are re-parsed and re-rendered at the output boundary before they print. Both operations stay defined Git operations. update-pr-evidence's steps are now "run the script, print its stdout", so its reference holds no gh call, no --body-file and no scrubber chain; the scrub-before-post check runs against the script under a gh fake. check-merge-readiness keeps its specification steps (the frozen status-line fixture samples two of them) and leads with the script run. The posting-ops floor falls 9 -> 8 because the op's reference no longer carries the --body-file posts the script makes: a written, user-accepted exception recorded in the floor's description.
/implement Phase 11, /resolve Step 9b-3 and /dynamic-build step 7 run `verify-evidence.cjs publish`, and /resolve Phase 9c runs `readiness`, from the main session through Bash instead of spawning a Git agent for each. Both operations stay defined and route to the same scripts. Each call site keeps its gates: the evidence path and TARGET_DIR_REL shapes that reach the shell, the publication values, the Bash timeout above the script's two deadlines, and "never blocks" for the refresh and "report-only" for readiness. The caller-fence floor falls 14 -> 12 because two operations no longer have a Git spawn fence: a written, user-accepted exception recorded in the floor's description. The flow tests for the three commands now hold the script calls instead of the spawns, and the docs-root guard names the two repo-relative --evidence paths that resolve under the cd on their own line.
Add a codexQuota segment next to the Claude quota on line 2. It reads the newest rate-limit record Codex writes to its own session logs under ~/.codex/sessions, so it opens no credential file and makes no network call. - A window is identified by window_minutes, never by primary/secondary slot, so weekly-only (prolite) and 5h+7d (team) plans both label correctly. - The newest-modified rollout wins, searched in the 14 newest day directories and ignored once untouched for 8 days. Only the file tail is read: 1 MB, then one 4 MB retry. - A window past its reset time renders as 0% with no countdown. A red "limited" marker shows while Codex reports a reached limit and a window is still counting down. - The parsed result is cached for 30 s. Users without Codex see no change. Regenerates the install-snapshot goldens for the two new HUD files.
The 2000 ms overall-timeout timer in the HUD entry point was never cleared, so node stayed alive until it fired: every status-line render took about 2.1 s of wall time after the line was already printed. Clear the timer in a finally block. A render that outlasts the budget still prints nothing. The new test imports the entry point under fake timers with the gatherers and renderer stubbed. It asserts no timer is left pending after a finished or a failed render, and that a render which outlasts the timeout prints nothing.
The orchestrating model now cuts the decisions index per agent instead of passing it whole: the index lines that touch the agent's work, verbatim, behind a "(slice: N of M entries - full index: <path>)" marker and ahead of the footer. Siblings over one diff share one slice, and the model includes a line when unsure. No script cuts the slice, so the index stays a pre-rendered file read. - _decisions.mds: a decisions_slice leaf states the rule once; the loader, the release host and the authoring preamble expand it inside their learning-on arms. The locator and the loader's Step 1 and Step 2 prose are shortened to pay for it. - Fan-out notes in code-review and plan name one shared slice; the Knowledge spawn block takes the slice for its directories. - session-start-context: the direct-delegation pass rule names the slice. - apply-decisions: an agent reads the full index at the named path only when its work leaves the slice's scope. Net 0 bytes, so every Code variant's preload ceiling holds. - Learning-off builds are byte-identical: every touched arm is learning-on. Tests: new tests/decisions/decisions-slice.test.ts (rule and pointer in all 14 learning-on hosts, none in learning-off, known-bad probes); the session-start pass-rule pin follows the new wording.
CLAUDE.md loads into every session. The 13 Architecture Overview paragraphs move byte-identical to docs/reference/architecture.md. CLAUDE.md keeps the intro, 42 one-line invariants and a plain-path pointer. CLAUDE.md goes from 22,268 to 13,210 bytes. Also: the Architecture entry in Reference Documents, the agent-references wording (commands read it by path too), and the agent-references tree in file-organization.md. Tests: the Tracker block and skill-installation checks read architecture.md; a new claude-md-max-chars ceiling holds CLAUDE.md at 13,150 characters; the shadow-path check covers architecture.md; a new test pins each moved paragraph by length and SHA-256.
The session-start rule now tells the main model to read the index once and pass each agent only the lines that touch its work, behind a slice marker and with the footer. Match hooks.md to the shipped wording.
Since the window fix, both flags bound every tool-call signal as well as token usage. The help text said only requests.
Adds a Changed section under Unreleased: the Revise bound, the evidence refresh and readiness check as scripts, the scoped decisions slice, and the smaller command bodies with size ceilings.
…nces Move four branches out of the main-session command into two hand-authored files under the agent-references skill, each read by explicit path only when its condition holds (D-CMD-REF-HAND): - implement-evidence-asks.md: the ticket-link ask, the exception grammar (the body of the retired evidence_exception() define; implement was its only host), the record paragraph and the missing-test-plan ask. - implement-revalidate.md: the re-validation continuation path. The command keeps each condition and a read step. The text moves byte for byte; the new command-reference-move guard pins each section by length and SHA-256 against what main held. Only text with no learning arm and no Git fence moves. /implement compiles smaller: learning-on 57,888 -> 53,808 bytes, learning-off 55,028 -> 50,948 (main: 57,212 / 54,369). Tests that pinned the moved text now read the reference: ticket-gate, implement-flow, contract-parity, release-flow, handoff-sections and partial-wiring (the partial holds one define). A fence-aware section reader keeps the grammar's `## Evidence Exceptions` template line inside its section. The install goldens regenerate in the next commit.
The agent-references skill installs a references/commands/ directory with implement-evidence-asks.md and implement-revalidate.md (three lines per config). No other section changed.
A cut in the shared partial lands in every host (eight load hosts, five write-back hosts). Each cut names the line that keeps its text in the same context: - knowledge_load's closing summary restated Steps 1-4, which each name their own read; its anchor line stays (feature-knowledge-delivery ends the load section there). - knowledge_load Step 2's closing sentence restated Step 3's fallback fields (`description` + `directories`). - The Knowledge spawn no longer restates how the agent writes the index (replace, append or create), that frontmatter is the authority, that it writes the two files directly, or the commit steps. The agent body holds each: steps 6-8, the Direct Write Protocol and the Commit Protocol, which also carries the non-blocking rule. The spawn keeps the root, slug, directories, files, the two paths, the index line format and its caps. Learning arms are untouched. Per host (learning-on): load hosts -312 bytes, write-back hosts -1,071 (implement 53,808 -> 52,737, resolve 56,029 -> 54,958).
Cut only text that a phase of the same command already states. The frozen fixture's six resolve anchors and every pinned diagram, edge-case and principle line stay byte for byte. - Architecture: the sub-bullets under Phases 0-4 and 8 restated the Step 0a-0d headings, the Phase 1b/2/3/4/8 bodies and spawn blocks. The Phase lines and the Step 9b/9c lines stay. - Edge Cases, ten rows, each with its staying line: incomplete review directory and legacy flat layout (Step 0c steps 3 and 5); worktree pre-flight fails (Step 0b "If BLOCKED"); empty FIX_NOW list (Phase 3's opening rule); ESCALATED security issues (Phase 2's closing rule); DUPLICATE without duplicate_of (the completeness assertion); DUPLICATE in THREAD_MAP (Step 9b-1's primary-verdict rule); gate FAILED after 2 attempts (Phase 7's step 4 and its "Route after push"); THREAD_MAP empty or DEGRADED (Phase 1b's DEGRADED rule and Step 9b-1's skip rule); no PR for post-resolution-summary (Step 9b-2's DEGRADED rule). - Principles: five restated a phase (parallel execution: Phase 3; honest reporting: Phase 7 step 4; complete tracking: the completeness assertion; latest review by default: Step 0c; auto-discover worktrees: Step 0a) or Phase 2's single global Triage spawn. Four remain, renumbered. /resolve compiles from 56,029 to 52,422 bytes (learning-on) and 52,805 to 49,220 (learning-off); main: 54,899 / 51,692.
Cut only text that a phase of the same command already states. The diagram lines the tests pin (Phase 6, Phase 8, the PR timing lines for Phases 9 and 10, the re-validation path) and the principles they pin (orchestration only, loop limits, CI awareness) stay. - Architecture: every sub-bullet restated its phase's body or spawn block (Phase 1: Plan Document Handling, the setup-task spawn, the ticket-link stub and the Test plan paragraphs; Phase 2: the strategy table; Phases 3-8: each phase's spawn and its pass/fail rules; Phase 9: the ensure-pr-ready spawn and COMMIT_UNCOMMITTED paragraph; Phase 10: the ci-wait steps; Phase 11: the push and "It never blocks" paragraphs). The phase lines stay as the index. - Principles: four restated a phase (plan-first: Plan Document Handling step 5 and the Tip; coherence-first: the strategy table's SINGLE row; clean handoffs: the Handoff Protocol; simplification pass: Phase 3). Eight remain, renumbered, so the tests that found a principle by its number now find it by its label. The diagram sub-bullet "Push the branch (never force; a failure is DEGRADED, not a stop)" was pinned by implement-flow; the pin now reads the Phase 11 sentences that say the same. /implement compiles from 53,808 (after the move) to 50,197 bytes (learning-on) and from 50,948 to 47,337 (learning-off).
Cut thirteen Edge Cases rows that restate a step of the same command. The rows the tests pin (the class rows, the comment-marker row, the publication rows) and the rows that carry something no step says (--full across worktrees, concurrent sessions) stay. Step 0c, with its Git fence, is untouched. Row -> staying line: - no new commits; rebase invalidates the head SHA; same-minute collision; --full: Step 0d steps 1-3 (the message, the cat-file check, the seconds suffix, the --full branch) and Step 0e step 5; - detached HEAD, mid-rebase, same branch, protected branch: Step 0a's filter and dedup line, which the worktree-support discovery reference repeats; - pre-flight fails: Step 0c's "If BLOCKED" line; - many worktrees: Step 0a step 4's "Found N worktrees" report; - first review; fp_ratio denominator 0; parsing failure: Step 0e steps 3 and the fp_ratio rules. /code-review compiles from 36,743 to 35,246 bytes (learning-on) and from 33,996 to 32,499 (learning-off); main: 36,680 / 33,996.
The diagram's sub-bullets under Phases 3, 5, 8 and 10 listed the Explore, Design and Plan foci that the focus tables of those phases list again; the Synthesize, Design-review and AskUserQuestion sub-bullets restated each phase's own spawn and gate text. The phase lines stay as the index, with the three lines the guards pin: the Phase 1 fetch spawn, the bounded Revise loop under Gate 2 and the Phase 14 ensure-traceable-issue spawn. The disposition table drops its sixth COMPLIANCE_ACTIVE site, the diagram line, because the focus-table row that carries the same gate phrase stays. The diagram's non-vacuity floor falls from 40 to 25 lines. /plan compiles from 39,499 (after the knowledge cut) to 38,096 bytes (learning-on) and from 36,476 to 35,126 (learning-off); main: 39,153 / 36,166.
New command-size guard plus 28 numeric-floors ceilings: command-<name>-max (learning-on) and command-<name>-learning-off-max for all 14 compiled commands, at the sizes measured at the close of #456 (no headroom). The guard asserts the table covers exactly the compiled commands in both builds, no command is above its ceiling, a learning-off build never exceeds its learning-on build, and /implement, /resolve, /plan and /code-review end below the sizes main held, in both builds. Bytes, main -> now (learning-on / learning-off): - implement 57,212 / 54,369 -> 50,197 / 47,337 - resolve 54,899 / 51,692 -> 52,422 / 49,220 - plan 39,153 / 36,166 -> 38,096 / 35,126 - code-review 36,680 / 33,996 -> 35,246 / 32,499
…d calls in verify-evidence
- verify-evidence.cjs: the publish bounds comment now gives the real worst case. A scrub is bounded by its own 20 s timeout, not by the writes' deadline, so the run can take 90 s + 60 s + 20 s, still inside the callers' 180 s Bash timeout. - implement-evidence-asks.md: the header said every "above" meant the Phase 1 text, but "the exception grammar above" and "the record above" name sections of this file. The header now says which is which. The moved sections are unchanged.
…audit window test Name the rule that keeps CLAUDE.md to binding invariant lines at the size ceiling, and label the date-window test by its design decision rather than an unrelated acceptance-criterion id.
Owner
Author
Test Plan Evidence — b951aeaVerified 22/27: VERIFIED-CI 22, ATTESTED-LOCAL 0, UNVERIFIED 5, STALE 0, FAILED 0, INDETERMINATE 0
|
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.
Summary
This is PR C1 of Token Diet wave 4C (epic #442, parent #417). It closes #454, #455 and #456.
C2 (#452, #453) follows after this PR merges and is installed, and after the M-1b measurement.
Changes
Audit tool (scripts/token-audit)
The audit has new signals:
--sinceand--untilnow bound every tool-call signal as well as token usage.M-1 (after wave B, 14.2 h window)
The window had 16 spawns and 10.03M ce.
Git took 47.3% of subagent ce. Rule R-455 therefore selects outcome A: script both operations.
The window had no /implement, /plan or /resolve runs. The C2 rules need the M-1b window, after this PR is installed.
#455: scripted Git operations and a bounded /plan Revise
verify-evidence.cjs publishposts the PR test-plan block and the evidence comment.verify-evidence.cjs readinessruns the merge-readiness ladder. Both replace Git-agent spawns at the /implement, /resolve and /dynamic-build call sites.#454: scope-filtered decisions context
(slice: N of M entries — full index: <path>)and the footer.#456: smaller commands and a shorter CLAUDE.md
agent-references/references/commands/. They are read by explicit path: the ticket-link ask, the missing-test-plan ask, the exception grammar and record, and the re-validation path.docs/reference/architecture.md. CLAUDE.md keeps 42 one-line invariants and a plain-path pointer. It shrinks from 22,268 to 13,210 bytes, held by a new character ceiling.Also on this branch
At the user's request, from another session:
Breaking Changes
None.
--sinceand--untilnow also bound tool-call signals.Testing
Build:
Full suite:
QA:
Security:
Follow-ups
Post-merge checks:
Not in this PR:
buildReportfunction. It is a pre-existing long function: 348 lines on main, 377 lines now.Related Issues
Closes #454
Closes #455
Closes #456
Test Plan