Ticket #251: multi-ticket and token verification
- Date: 2026-11-11
- Branch:
ticket/251-multiticket-verification - Base:
integration/terminal-turnsat78107c6(merge of #250; includes #246–#249) - Review-fix branch:
ticket/251-review-fixesonintegration/terminal-turnsat3ca0837(merge of #251) - Spec: parent #245; ticket #251
- Unit gate:
npm run verify(strict typecheck + full test suite) - Live gate:
npm run test:live:vera— seed 2/2, run 54/54, flows 45/45, restart 39/39, exit 0 - Host matrix: OpenCode 2.2.7, Node 26.12.1, npm 12.2.1, tmux 3.5a
- Provider: isolated local
ensemble-fakeOpenAI-compatible provider; no model API, external network request, or user credential
Scenario
scripts/live-vera-regression.sh (npm run test:live:vera) keeps the #241 seed → upgrade-store → run → restart shape and adds a second VeraFlows workspace. The existing seed/run/restart phases and their assertions are unchanged; the run phase's durability counts are scoped to VeraProbe because the new workspace shares the roster.
The flows phase drives real terminal review/synthesis turns and real ensemble_dispatch tool calls through the isolated host. A normal native kickoff is not a terminal turn, so each first dispatch is seeded by a worker completion review (the terminal continuation path) rather than by a kickoff tool call:
- Five-hop relay. A native leader turn starts a leader-owned command root with one worker. The worker relays to five named siblings through
$Namefinal-text routing. Every intermediate parent relays; the command root is the only synthesis task. The terminal synthesis mentions two workers; those mentions are references, so no peer turns are created. - Multi-ticket continuation. The relay root's terminal turn calls
ensemble_dispatchwith a five-way ticket-two assignment batch. Ticket two is a new parentless leader-owned command root with a fresh group/command budget (5/8group hops,5/24command hops). It gets exactly one synthesis. Its terminal turn mentions all five workers, creates no peer turns, and posts the visible no-work notice. - Refused dispatch above the new command ceiling. With command hops pinned to
8, the next ticket's terminal turn callsensemble_dispatchwith nine assignments. The command-layer preflight refuses it (9/8) as a batch-too-large command, the refusal tells the leader to reduce or split the batch (not to ask for a new command), no task is created, and the terminal notice is posted. - Worker route. A leader-owned command root assigns one worker whose final text names a sibling. The peer turn is created and replies; the root still gets exactly one synthesis.
Every command root is leader-owned, so the #247 ancestor guard skips every worker completion. The driver asserts the task graph, leader turn counts, leader-authored message counts, terminal suppressions, terminal notices, the dispatch ledger, and the refusal. The fake provider emits the ensemble_dispatch tool call once from the review/synthesis marker, then streams the deterministic reply after the tool result (the summary for a synthesis turn, the start line for a normal turn).
Bug found and fixed
The live flow exposed two real issues in the root-synthesis path. Both fixes are narrow and covered by tests.
- Early root synthesis over a pending descendant. A replied peer turn can route a new
$Nameturn after it settles.maybeSynthesizechecked only the direct children of a parent, so an intermediate parent whose child had just routed a pending grandchild could relay upward and promote the root synthesis before the grandchild finished. The live relay reproduced this at hop two.branch-digest.tsnow exposespendingDescendantResolver(and thehasPendingDescendantwrapper);maybeSynthesizeandreconcileWaitingWorkwait for the whole non-completion subtree. A replied intermediate parent also propagates a new child completion to its ancestor instead of returning early. The memoized resolver keeps the 5k-task reconciliation inside its latency budget. - Synthesis context on a reused leader session. The leader's workspace session first ran the native kickoff turn. The host kept that first instruction snapshot for later prompts, so the first synthesis request still carried the native turn's recent-transcript context and not the root request or branch digest, even though the instruction entry was updated. The run path now appends the bounded synthesis context to the synthesis prompt text as well as writing it as the context entry. The live provider request records both
hasRootRequestandhasBranchResultstrue for every synthesis turn.
Review-fix pass
ensemble_dispatchis terminal-turn-only. The Vera flows seed each first ticket with a worker completion review (a real terminal turn) instead of a normal native kickoff, so the live proof exercises the same boundary.- The command-cap live refusal is now the batch-too-large copy: reduce or split the batch, not a request for a fresh user command.
- The restart checks scope completion turns to the ticket command groups; the seed completion reviews are intentional and live in their own groups.
- The subagent probe is pinned to the explicit legacy path. Its one-task and barrier assertions predate native-first default-on, where the host mints a synthetic native turn for the subagent completion; native ingestion is covered by its own suites.
Regression assertions
| Check | Result |
|---|---|
| Relay command root | Parentless, leader-owned; 7 tasks (root + six workers) |
| Relay worker path | Phoenix → Kakiko → Clark → Juno → Mira → Wren; five $Name hops |
| Relay leader turns | 1 synthesis task, 1 leader message, 0 completion tasks |
| Relay terminal mentions | 2 suppressed as terminal-turn; 0 peer turns; no no-work notice because it dispatched |
| Relay branch digest | Synthesis request carried the root request and branch digest |
| Ticket two root | New parentless leader root, different group, usedHops=5, commandUsedHops=5, commandMaxHops=24 |
| Ticket two fan-out | 5 worker turns, 1 synthesis task/message, 0 completion tasks, 0 peer turns |
| Ticket two terminal turn | 5 terminal suppressions; visible no-work notice; no dispatch |
| Refused dispatch | Command layer 9/8, visible refusal copy, 0 work rows created |
| Refused ticket terminal turn | 2 terminal suppressions; visible no-work notice |
| Worker route | One turn child to the named sibling, replied; route log present |
| Worker-route ticket | 1 synthesis task/message, 0 completion tasks; 1 terminal suppression |
| Kickoff turns | 3 native leader turns; every one settled |
| Completion reviews anywhere in the flow | 0 |
Measurements
The fake provider logs counts and schema lengths only. Token counts use the documented chars/4 proxy. Leader output is the deterministic fixture summary, not a model-quality measurement.
| Ticket | Leader synthesis turns | Leader output chars | Leader output tokens | Synthesis prompt chars | Synthesis context chars |
|---|---|---|---|---|---|
| One (relay) | 1 | 236 | 59 | 2,140 | 301 |
| Two (fan-out) | 1 | 254 | 64 | 2,295 | 447 |
| Three (refused dispatch) | 1 | 238 | 60 | 2,075 | 254 |
| Four (worker route) | 1 | 229 | 58 | 2,052 | 246 |
| Total | 4 | 957 | 240 | 8,562 | 1,248 |
The flow also runs three completion-review seed turns (one per dispatched ticket; ticket two is started by ticket one's terminal synthesis). A normal native kickoff cannot call ensemble_dispatch; the completion review is the terminal continuation. Per ticket, the post-work leader turn count is one synthesis. There are no per-hop leader messages and no per-child completion reviews. Per-ticket token values are rounded up; the total uses the total character count (ceil(957/4) = 240).
npm run benchmark:synthesis on the fixed five-branch fan-out reports context 2,033 chars / 509 tokens, prompt text 335 / 84, total 2,368 / 593, removed last-20 transcript 1,492 / 373, and a representative concise summary of 303 / 76. The live synthesis prompts are in the same range (2,052–2,295 chars).
Tool surface
| Surface | Tools | Schema chars | Est. tokens |
|---|---|---|---|
| Native (live request) | 6 | 3,131 | 783 |
| Legacy (live request) | 11 | 5,481 | 1,371 |
Native (benchmark:tools) | 6 | 2,771 | 693 |
Legacy baseline (benchmark:tools) | 11 | 4,821 | 1,206 |
The live request schemas include host/provider fields; the benchmark numbers are the reproducible source-level comparison. The native surface is 588 tokens smaller than the live legacy request (42.9%) and 513 tokens smaller in the benchmark (42.5%).
Before/after leader output
| Flow | Before (pre-merge evidence) | After (live) | Delta |
|---|---|---|---|
| Five-writer relay | 8,333 chars / 2,084 tokens | 236 chars / 59 tokens | -8,097 chars / -2,025 tokens |
| Fan-out | 5,761 chars / 1,441 tokens (3-way) | 254 chars / 64 tokens (5-way) | -5,507 chars / -1,377 tokens |
| Leader turns | 5 relay / 4 fan-out | 1 per ticket | -4 / -3 |
The before values are the measured pre-merge evidence in #245. The live after values are the deterministic fake summary. The source-level synthesis benchmark reports a representative concise summary of 303 chars; using that instead of the fixture output gives a relay delta of 8,030 chars / 2,008 tokens. The fixture is intentionally short; the turn-count reduction is the structural result.
npm run benchmark:tools also reports prompt tokens 3,347 → 2,001 (-40.2%), tool schemas 1,206 → 693 (-42.5%), tool calls 1 → 0, and model round-trips 2 → 1.
Commands
| Command | Result |
|---|---|
npm run verify | PASS — strict typecheck; 1,915 tests, 0 failed, 0 skipped |
npm run test:live:vera | PASS — seed 2/2, run 54/54, flows 45/45, restart 39/39 |
npm run test:live:subagent | PASS — barrier probe on the explicit legacy path; the probe now pins nativeFirst: "off" before workspace creation because its one-task/barrier assertions predate the native-first synthetic completion turn. |
npm run test:live:native-first | PASS — main 66/66, restart 18/18, 0 gaps |
npm run test:live:sizes | PASS — 80x24, 100x30, 120x40, 160x50, NO_COLOR=1 |
npm run test:live:fake:all | PASS — fake 458s, fake-empty 9s; 2 passed, 0 failed, 0 skipped |
npm run test:live:all | PASS — fake 451s, fake-empty 9s, real 54s; 3 passed, 0 failed, 0 skipped |
npm run benchmark:tools | PASS — measurement only; values above |
Skips
- None in the deterministic fake suite. The full
test:live:allmatrix also ran the real-runtime scenario on the local catalog; no scenario reported a skip. - No real-model multi-ticket measurement was added. The ticket requires a deterministic fake-provider suite; a real-model run would be a separate measurement and is not claimed here.
Privacy
The committed record contains fixture names, stored roster titles/roles, task and group counts, lengths, versions, and token estimates only. It contains no prompt or answer text, conversation transcript, credentials, file bytes, or absolute private paths. The live script gates the driver outputs for the harness root, project directories, password, and every #251 marker family, and gates the service logs for the same markers and home paths. The relay marker is kept out of the first 80 characters of the peer-turn text because the service logs a peer-turn title.
Conflict risk
- #246–#250: this ticket changes only the root-synthesis settlement check (
maybeSynthesize/reconcileWaitingWork), the synthesis prompt delivery, the Vera driver, the fake provider, and the verification record. The service changes are behind the existing root-only synthesis and terminal-turn paths. - #249 compact context: the context entry is still written by
contextForTask; the synthesis prompt also carries the same bounded block so the reused leader session sees it. The benchmark and context tests still pass. - #250 continuation dispatch: the flow uses the existing native
ensemble_dispatchtool, the existing dispatch ledger, and the existing command-cap preflight. No new work model or tool surface was added. - Live harness: the Vera scenario now has a second workspace and a flows phase. The existing #241 assertions are scoped to
VeraProbe; the seed/run/ restart phases still run on the same host and the restart phase checks the new roots and notices.