Skip to content

perf(pa-tui): feed the tray context usage off the attach snapshot, not a blocking first-frame stats fetch - #3334

Open
kevinjosethomas wants to merge 3 commits into
mainfrom
lane/perf-stats-defer-fast
Open

kevinjosethomas wants to merge 3 commits into
mainfrom
lane/perf-stats-defer-fast

Conversation

@kevinjosethomas

@kevinjosethomas kevinjosethomas commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Evidence

Full-suite VM gate — fleet_pipeline.fleet_gate

  • verdict: RED_KNOWN_REDS
  • run: gate_1791028107_2563054 (host logs: /home/ubuntu/fleet-pipeline-runs/gate_1791028107_2563054)
  • head ac49924362d223230a0ce789005d966603dbadf4 on org/rust tip e38702160795b172b1f9f66a4a97a5debd060f57 (merge-base e38702160795b172b1f9f66a4a97a5debd060f57, base folded)
  • toolchain 1.98.1 pin, VM rust:1-bookworm (sandbox jlyaqo3a4nele1u22zxqzfp7)
  • cargo fmt --all --check: rc 0
  • cargo clippy --workspace --all-targets -D warnings: rc 0
  • cargo test --workspace --no-fail-fast: rc 101
  • test-result lines: 80
  • failures classified: tui_prompt_stash_restores_a_pasted_image_with_the_draft -> KNOWN-RED (auto-attached): rotating flake (pa-cli interactive_daemon_e2e): red in a concurrent full-suite VM run, green in CI on the same head (evidence: 2026-09-25 review run review_1790305784 (head 0a1b73f, VM-0): tui_prompt_stash_restores_a_pasted_image_with_the_draft red in the concurrent focused-test run while CI (check+clippy+test workspace, same head) is green; the cursor-glitch lane (pa-tui: hide the hardware cursor by default (TS showHardwareCursor parity), position it for IME on every frame #2734, merged) hit the prompt-stash family in its VM gate and solo-proved it green; the sibling member tui_prompt_stash_round_trips_across_in_place_switch passed in the same run RENEWED 2026-09-28 (digest-capture placement lane, expired-entry re-triage per the rule): fired co-scheduled in the fresh-VM full gate gate_1790623213 at the folded head 24ef25d (with its territory-sibling tui_refused_draft, the bounded_wait_starvation member); SOLO-GREEN x3 at the exact head on the same fresh VM (6.91s/5.97s/5.42s); the same head's GitHub CI pa-cli shards green. Expiry aligned with the same-day bounded_wait_starvation family. | RENEWED 2026-09-29 (pre-expiry sweep; quiet triage VM t2llr6av8eb4g1dxyt9wzp8a; pinned tip 3e98be8; gate-env recipe; --test-threads=1): SOLO x3 GREEN (15.61s/8.61s/9.99s). | CENSUS (fleet gate/review runs 2026-09-24..29; 921 verdict-carrying): 14 fires (11 auto-classified + 3 unknown/expired-classified) across 11 heads / 10 VMs / 3 days (2026-09-25..2026-09-29), last 2026-09-29 | REOPEN: a NEW stash/draft signature, a solo red, or a CI reproduction (the family is CI-green to date; module-mates share the interactive_daemon_e2e harness). Expiry extended to 2026-10-06.); tui_refused_submit_restores_the_draft_after_the_round_trip -> KNOWN-RED (auto-attached): MEMBER (first fire; the test landed with perf(pa-tui): submit prompt off the render path - TS onSubmit parity (ordered FIFO worker; ack p50 1.8->0.2ms) #2868 on 2026-09-26) of the FULL-SUITE CO-SCHEDULED BOUNDED-WAIT STARVATION (not a product bug; the bounded-wait/turn/timing tests added ~2026-09-26 starve under the full-suite's parallel load on the pooled gate VMs: the 60s held-provider wait, the 60s follow-up wait, and the TUI error-row render wait overrun their bounds while the same suites run GREEN in the CI's 4-shard split and GREEN SOLO). The family rotates: run-1 fires abort_and_send_queued_acks (run-2 passes it), run-2 fires kill_cancels_mid_provider_wait + tui_refused_draft - never the same member twice in a row, never solo, never in CI. [SWEEP 2026-09-29: a solo red on the sweep VM's fsync regime - the 5731b28 environmental class's stall arm; 2/3 green] (evidence: ROTATION PROOF at the digest-capture lane head 4c015e7 (test-only PR test(pa-core): the compact digest-capture placement oracles - the ENTER capture is the TS-parity shield (byte-identity across placements in frozen windows; the racing class) #3006, pa-core harness_digest.rs tests; the pa-daemon/pa-cli trees BYTE-IDENTICAL to base b89b8ff): full gate_1790615320 RED on worker::turn_stream_tests::abort_and_send_queued_acks_before_the_follow_up_delivery alone ('the follow-up never started after the abort ack', 60s+ overrun; SOLO-GREEN x3 at the exact head 2.11s/1.01s/1.55s); the 1+1 rerun gate_1790616926 (same head, same VM ffi1sgbkvh9iuasrslibcuab) RED on a DIFFERENT pair - tui_refused_submit_restores_the_draft_after_the_round_trip (pa-cli interactive_daemon_e2e.rs:4716 'the refused submit surfaced the error row'; SOLO-GREEN x3 4.29s/3.56s/2.99s) + worker::tests::kill_cancels_a_mid_provider_wait_turn_and_surfaces_the_aborted_row (worker/tests.rs:1430 'kill waited out the held provider response (60.017s)'; SOLO-GREEN x3 1.12s/1.07s/1.10s) - while run-1's member PASSED. The same head's GitHub CI: test shards 4/4 GREEN (the sharded split runs the same suites without the starvation). CENSUS: kill_cancels has fired UNKNOWN-classified in 9 co-scheduled full-suite gates 2026-09-26..28 (gate_1790397365/398917/400664/401934/455545/464592/549076 + both digest-capture gates) - never registered, always co-scheduled; abort_and_send_queued_acks red only in co-scheduled runs per the dead_sidecar entry's census (09-25/09-27 eras); tui_refused is a first fire (the test landed with perf(pa-tui): submit prompt off the render path - TS onSubmit parity (ordered FIFO worker; ack p50 1.8->0.2ms) #2868, 2026-09-26). RERUN DISCIPLINE honored: 1+1 then stop (no third rerun attempted). FALSIFICATION ANNOTATION (2026-09-28, the operator's ruling: annotate, do not rescope): the member's classification was VALID at 24ef25d (solo-green x3, the co-scheduled-only fire); at the final folded head ae542c6 it is a DETERMINISTIC BASE RED — SOLO-RED 3/3 at the lane head AND at the pure base c85b8e0 (7.37/6.34/6.44s and 6.95/6.53/6.47s), GREEN on the CI's runners at the same head (pa-cli#test:interactive_daemon_e2e PASS 22.5s) — a NEW environment-sensitive base red in the 30808d2..c85b8e0 window (the TUI render territory; pa-tui: the terminal-state differential - every armed mode restores on every exit route #3002 the terminal-state differential and pa-tui/pa-ai/pa-agent: /tier command + Default service tier settings row + footer badge + completions service_tier forwarding + proxy serviceTier (TS #2144 half + #2491 half) #2735 the /tier badge the flagged suspects; the bisect triage owns the separation). The member's reopen trigger fired correctly (the head-bound receipt discipline caught what the entry's blanket would have masked); the OTHER members' classifications stand with their receipts at their heads. BISECT OUTCOME (2026-09-28, the wave-6 triage lane perf-refused-submit-bisect; bench record 20260928-214900-triage-tui-refused-base-red-window-falsified, evidence sha b2d079f7): the window attribution above is FALSIFIED - no culprit commit exists in 30808d2..c85b8e0. (1) An 11-head walk (2 runs/head) + spaced isolated batteries (6 runs/head, 15s spacing) on the pinned gate VM kbfkp829: the red fires at the GREEN endpoint 30808d2 (2R/4G), at PRE-window b89b8ff pa-cli: print_boundary.rs split - the 4 stages: events, compaction_arms, autorefine, tests #2989 (1R/5G), and at this lane's own green head 24ef25d (2R/4G) - all the uniform 4716 signature; a fresh-VM control (the same recipe, tree-clean asserted) runs all four heads 24/24 GREEN in the calm regime (fsync p50 41-110ms). The 'DETERMINISTIC BASE RED' was a regime drawing (their post-gate writeback-stalled VM), not a head property. (2) The mechanism, byte-level (strace -f -tt at c85b8e0): GREEN = the Kill resolves by +413ms (the tombstone+teardown fsyncs ~6ms) and the +906ms submit is REFUSED ('Unknown active session') in 0.8ms -> submit_prompt Err -> the error row + draft render (the TS onSubmit-catch ladder); RED (induced on demand by a 3-writer fsync storm, 1/13) = the tombstone fsync stalls 652.7ms, the submit lands +903ms INSIDE the stalled window, the daemon ACCEPTS it (success:true), the kill lands mid-turn and the turn dies with NO rendered outcome -> assert 4716. The flip rate is the regime's fsync-stall probability (a 627.7ms natural fsync stall observed on the same VM; CI's sub-ms fsyncs keep a ~490ms margin -> CI green is the contract). The race contract (the test's sleep(400ms)+WaitMs(900) clock vs the Kill handler's persist_stop_tombstone fsync: routing.rs:401 + descriptor.rs write_file_atomic sync_all) is byte-identical at PRE-window b89b8ff. GATE USAGE: a VM-gate red of this member cites the record - the standing environmental class (I/O-regime-gated kill-vs-submit race), NOT a base regression, NOT window-caused; the solo-fire arm refines the family's trigger beyond co-scheduled CPU starvation to stalled-fsync regimes (post-build/post-gate writeback included). The fix decision routes to the test's owner (both sides the port's own, pre-window): margin-widening alone is green-fishing-adjacent; a deterministic barrier needs a kill-visible frame signal (the kill produces no frame change today) or an external-condition wait; the product-side mid-turn-kill parity question is separate scope. | RENEWED 2026-09-29 (pre-expiry sweep; quiet triage VM t2llr6av8eb4g1dxyt9wzp8a; pinned tip 3e98be8; gate-env recipe; --test-threads=1): SOLO x3: 2 GREEN (2.28s/2.58s) + 1 RED (iter 2, 2.73s: panicked at interactive_daemon_e2e.rs:5401 'the refused submit surfaced the error row' - the entry's own standing environmental class per record 5731b28, the fixed-clock race vs the persist_stop_tombstone fsync stall, fired solo on this VM's fsync regime; NOT re-run past x3 per the no-green-fishing discipline) | CENSUS (fleet gate/review runs 2026-09-24..29; 921 verdict-carrying): 16 fires (14 auto-classified + 2 unknown/expired-classified) across 14 heads / 9 VMs / 2 days (2026-09-28..2026-09-29), last 2026-09-29 | REOPEN: a NEW failure signature outside the class, a REPRODUCIBLE solo red on a calm-regime VM (the 2026-09-29 sweep observed 1/3 on the sweep VM's fsync regime, the 5731b28 stall arm; the refused-submit-bisect calm-regime control was 24/24 green - a reproducible calm-regime solo red reopens the code question), or a CI-shard reproduction. Expiry extended to 2026-10-06. | TRIAGE (x24 calm-control battery on triage VM h4zf5ktroa5f2dqj0lcmibi0, same pinned tip, --test-threads=1, fsync probe /tmp p50=210.14ms = NOT the calm regime): 23 GREEN (2.7s typ) + 1 RED (iter 13, 2.7s, the same error-row signature) = 1/24 on the slow-regime VM - consistent with the 5731b28 standing environmental class's stall arm (that lane's CALM-regime control was 24/24 green; the natural-stall rate here matches its storm-rate class); in-class, no re-run past the x24 control.); worker::compaction_admission_tests::steer_mid_compaction_defers_and_delivers_after_the_window -> KNOWN-RED (auto-attached): MEMBER (appended 2026-09-28 per the operator's disposition: fix(pa-daemon): the compacting admission gate - a racing turn defers through the compaction window, the parked work delivers after it #3021's own admission test, fired co-scheduled-only in the fresh-VM full gate gate_1790625123 at the folded head ae542c6 with its own SOLO-GREEN x3 at that head, 1.51s x3) of the FULL-SUITE CO-SCHEDULED BOUNDED-WAIT STARVATION (not a product bug; the bounded-wait/turn/timing tests added ~2026-09-26 starve under the full-suite's parallel load on the pooled gate VMs: the 60s held-provider wait, the 60s follow-up wait, and the TUI error-row render wait overrun their bounds while the same suites run GREEN in the CI's 4-shard split and GREEN SOLO). The family rotates: run-1 fires abort_and_send_queued_acks (run-2 passes it), run-2 fires kill_cancels_mid_provider_wait + tui_refused_draft - never the same member twice in a row, never solo, never in CI. (evidence: ROTATION PROOF at the digest-capture lane head 4c015e7 (test-only PR test(pa-core): the compact digest-capture placement oracles - the ENTER capture is the TS-parity shield (byte-identity across placements in frozen windows; the racing class) #3006, pa-core harness_digest.rs tests; the pa-daemon/pa-cli trees BYTE-IDENTICAL to base b89b8ff): full gate_1790615320 RED on worker::turn_stream_tests::abort_and_send_queued_acks_before_the_follow_up_delivery alone ('the follow-up never started after the abort ack', 60s+ overrun; SOLO-GREEN x3 at the exact head 2.11s/1.01s/1.55s); the 1+1 rerun gate_1790616926 (same head, same VM ffi1sgbkvh9iuasrslibcuab) RED on a DIFFERENT pair - tui_refused_submit_restores_the_draft_after_the_round_trip (pa-cli interactive_daemon_e2e.rs:4716 'the refused submit surfaced the error row'; SOLO-GREEN x3 4.29s/3.56s/2.99s) + worker::tests::kill_cancels_a_mid_provider_wait_turn_and_surfaces_the_aborted_row (worker/tests.rs:1430 'kill waited out the held provider response (60.017s)'; SOLO-GREEN x3 1.12s/1.07s/1.10s) - while run-1's member PASSED. The same head's GitHub CI: test shards 4/4 GREEN (the sharded split runs the same suites without the starvation). CENSUS: kill_cancels has fired UNKNOWN-classified in 9 co-scheduled full-suite gates 2026-09-26..28 (gate_1790397365/398917/400664/401934/455545/464592/549076 + both digest-capture gates) - never registered, always co-scheduled; abort_and_send_queued_acks red only in co-scheduled runs per the dead_sidecar entry's census (09-25/09-27 eras); tui_refused is a first fire (the test landed with perf(pa-tui): submit prompt off the render path - TS onSubmit parity (ordered FIFO worker; ack p50 1.8->0.2ms) #2868, 2026-09-26). RERUN DISCIPLINE honored: 1+1 then stop (no third rerun attempted). MEMBER APPEND (2026-09-28, the digest-capture lane's final-head gate): steer_mid_compaction_defers_and_delivers_after_the_window (crates/pa-daemon worker::compaction_admission_tests — the fix(pa-daemon): the compacting admission gate - a racing turn defers through the compaction window, the parked work delivers after it #3021 compacting-admission-gate lane's own test) fired co-scheduled in the fresh-VM full gate gate_1790625123 at ae542c6; SOLO-GREEN x3 at the exact head on the same fresh VM (1.51s x1.51s x1.51s); the rotation-consistent shape (never solo-red). Appended per the Hillclimb operator's disposition with the family's append rule met (own solo x3 + census). | RENEWED 2026-09-29 (pre-expiry sweep; quiet triage VM t2llr6av8eb4g1dxyt9wzp8a; pinned tip 3e98be8; gate-env recipe; --test-threads=1): SOLO x3 GREEN (1.60s/1.60s/1.60s). | CENSUS (fleet gate/review runs 2026-09-24..29; 921 verdict-carrying): 5 fires (3 auto-classified + 2 unknown/expired-classified) across 5 heads / 3 VMs / 2 days (2026-09-28..2026-09-29), last 2026-09-29 | REOPEN: a NEW failure signature outside the starvation class, a SOLO red at any head (the class is solo-green at the tip), a CI-shard reproduction (the family is CI-clean to date), or the family's red shape with a solo reproduction (then it is a code red, not load). Expiry extended to 2026-10-06.)

What

The TUI's open path — and every agents-view switch re-entry — no longer blocks its first frame on a get_session_stats daemon round-trip just to paint the tray's context-usage row. The worker's attach snapshot now carries contextUsage, the field TS's createAgentConnectionState fills on every attach (packages/coding-agent/src/modes/agent-connection/snapshot.ts:56, contextUsage: session.getContextUsage()); the client reads it off the snapshot exactly like the other reconstructed session fields. TS's open path never blocks its first frame on getSessionStats — its stats refreshes (refreshConnectionContextUsage) run only after a turn or a compaction settles, which the loop's settle arms keep doing unchanged.

The port's AgentConnectionState.context_usage field already existed on the wire but was always None; the port compensated with the blocking fetch the TS open path never had. This restores the TS shape and removes the round-trip.

Where

  • pa-daemon connection_state_locked: fills context_usage with the same store walk get_session_stats serves (session_stats::store_context_usage), under the same core lock the attach already holds; None without a model context window, exactly like the stats response (scripted-engine goldens unchanged).
  • pa-tui reconstruct: reads state.contextUsage (ContextUsage::from_wire, the same parse refresh_stats used — unknown tokens right after a compaction clear the tray, TS patchConnectionState).
  • pa-tui attach_session: applies it with the other reconstructed fields (TS applyConnectionStateSnapshot replaces the usage at every attach).
  • pa-tui open path (interactive/run.rs), /new, and /switch: the blocking refresh_stats() before the rebuild is gone. The settled-turn and post-compaction refreshes are untouched.

Evidence — authoritative clean campaign (fresh VM, 40/40 host-downloaded legs)

  • Mechanism: before the incident, instrumented arms proved the open-window get_session_stats census 3/3 at tip → 0/3 at cut. The original current-tip refresh_stats span was 11–13 ms in the 7,390-message fixture. The cut moves the same context-usage walk into the attach snapshot, matching the TS createAgentConnectionState source; turn/compaction refreshes remain.
  • Authoritative ABBA: new VM sbrstgcgisdh0cz3hckqpc6k, exact source tip e3870216079 and cut ac49924362d2, fresh release binary SHAs 471e092c… and f1c499e0… asserted per leg. Same exact fixture SHAs; tip/cut/cut/tip/tip/cut ×3 blocks per class, 36 raw trials plus four pyte-fed controls. Every leg was downloaded and SHA-logged to the host before the next leg; 201 cumulative process-census snapshots were empty after scoped worker TERM/reap, 40 binary receipts, 83 I/O probes (80 per-leg + pre/post campaign + one harmless extra probe before a failed pre-control label format). No benchmark trial excluded or selectively rerun.
  • Small (9 messages): agents→chat pooled p50 across 18 exposures/arm 7.793 → 7.234 ms (−0.559 ms, −7.2%); paired cut−tip trial-mean differences by block [−0.366,−2.119,−12.980], [−0.144,+1.128,−1.015], [−0.846,−0.808,+0.771] ms. Tails and adverse pairs are retained.
  • Canon (7,390 messages): NO WALL WIN. Agents→chat pooled p50 156.233 → 160.334 ms (+4.101 ms, +2.6%). Adjacent cut−tip trial-mean differences by block [−20.377,−26.954,+15.620], [+12.265,−29.164,+20.927], [−1.549,−9.115,+11.392] ms. The ±20–30 ms swings and fresh-write probe p50 moving between ~0.7–1 ms and ~25–33 ms make the canonical wall result regime-dominated: claim neither a canonical speedup nor a robust regression. The original 144.2 ms current-tip number is method history only, not the authority.
  • TUI byte oracle: offline true-bracket CSI ?2026 raw-byte parser PASS on both classes (9 tip + 9 cut trials each), zero cross-arm frame diffs, zero A/A diffs after masking only the trial-name title; first-screen tray rows byte-identical (9.4k (7%) small; 130 (0%) canon). The real empty-store daemon/TUI oracle ran after the benchmark: tip/cut/cut/tip first screens all show the same 0 (0%) tray; sole row difference is the volatile trial-name title, within the A/A floor.
  • Incident and disclosure: the original shared-VM campaign overlapped a successor oracle and leaked benchmark workers. Its contaminated blocks are excluded; its pre-incident instrumented wire census remains valid. The first clean repeat was killed by the original worker deleting the shared VM after 30/36 locally observed raw legs, before any clean data were downloaded; those data are lost and excluded. This second fresh-VM full 40/40 campaign is the sole wall authority. Its host archive sha256 286657b444183045e9c558be3e61dad055bbaccc17dc624b723fe7962c71f9f2 (18.16 MB, every leg trace/raw/probes/census/sha plus both oracle verdicts). The original archive sha de4f8040… remains the method-history/instrumentation receipt.

Gates and CI

  • MERGE-TIME FOLD IN PROGRESS (2026-10-03 17:33Z): folded the reviewed d949b04c2 into main e22fcd5fbda6 as PR head 747ade73617095459d2f931cf002795828a39c56 (fold fold_1791048745_2791105). Diff verification: main moved exactly 17 files, all in pa-daemon parent/child/registry areas, with zero overlap with this lane’s 11 touched paths; each of the 11 lane-touched blobs is byte-identical at old and folded heads. The old-head exact review review_1791047772_2791105 is GREEN (fmt/clippy/focused tests rc0, zero blockers). The folded-head full gate gate_1791048804_2791105 is GREEN (fmt/clippy/full workspace test rc0, zero failures/unknowns). Folded-head focused review review_1791048804_2791105 RED on one active registered worker-route flake; authorized same-SHA 1+1 rerun review_1791049741_2791105 finished GREEN (fmt/clippy/focused tests rc0, zero blockers/unknowns). No solo or third rerun. CI is 25 pass, two non-required skips, zero failure/pending. New stale-base advisory: org/main moved again from e22fcd5 to e78f11f by review completion. Operator RULING: hold the current reviewed/gated 747ade736 while main is actively moving; do NOT re-fold now. At Kevin's merge election (including the journal DROP-vs-LAND choice), if main remains ahead, perform ONE final fold on the stabilized tip with byte-identity mapping verification and re-gate/re-review/CI on the exact combined head before merge. R4’s standing verdict must bind to this folded head; no merge until all receipts and Kevin’s incident-journal election.

  • Exact source head ac49924362d2 on org/rust base e3870216079: cargo fmt --all --check and cargo clippy --workspace --all-targets -- -D warnings pass in both full-suite VM gates.

  • Gate gate_1791028107_2563054: RED_KNOWN_REDS, exactly three ACTIVE registered timing reds, zero unknown. Authorized sole 1+1 rerun gate_1791030386_2791105: three active known-red families (queued-prompts render replaces gate1 prompt-stash; refused-draft and steer-mid-compaction recur) plus one first-fire UNKNOWN kill_cancels_goal_and_heartbeat_and_no_wake_revives_the_session. Head-bound triage: same-head solo 3/3 green (14.44/14.19/14.80 s) on a fresh pinned-toolchain VM; closelistener3 independently traced the pre-existing supervisor tombstone-adoption race on main (outside this TUI stats cut). No third gate. Both verdicts and triage receipts are in the bench record.

  • Previous PR head d949b04c2f9b024e4480f939a26445203793ddfd added only the LANE-STATE.md incident journal atop gated source ac4992436; production tree was byte-identical. Its CI passed (8/8 shards) and exact review review_1791047772_2791105 was GREEN (fmt/clippy/focused tests rc0, zero blockers/unknown). The unresolved Bugbot journal thread remains an explicit Kevin election, not a silent pass.

Parity

  • TS mechanism restored, no frozen surface changes: attach snapshots carry contextUsage; the open path never blocks on a stats fetch; turn/compaction refreshes unchanged.
  • Wire: an existing field is now filled — additive; older readers ignore it; the daemon and TUI ship as one binary.
  • /new, /switch, the supersede-rebind, and the recovery reattach now update the tray from their attach snapshots (the same values the removed blocking fetch returned); disclosed in the bench record.
  • No overlap with fix(kernel): close the provisioner's four residual mid-boot lifecycle gaps #3303 (kernel provisioner + kernel tests); this lane touches the tray-stats surfaces only.

Bench record: data/hillclimb/experiments/20261003-125000-interaction-statsdefer-firstframe.json at bench commit bdbbdcb6c8bc58d89c8894d0b268e1cdd980966d; authoritative fresh evidence archive sha 286657b444183045e9c558be3e61dad055bbaccc17dc624b723fe7962c71f9f2 (18.16 MB, host-saved 40/40 legs and both oracle verdicts). Original archive sha de4f8040… is method history only.


Note

Low Risk
First-frame UX/perf path only: an existing wire field is populated and blocking stats fetches are removed on attach paths; turn/compaction refreshes unchanged. Tray may clear sooner when usage is unknown on the wire.

Overview
Aligns the Rust TUI with TypeScript: tray context usage (N (P%)) comes from the attach snapshot’s contextUsage on first paint, instead of a blocking get_session_stats round-trip on open, /new, and session switch.

The daemon now fills context_usage in the attach connection state via the same store_context_usage walk as get_session_stats (omitted when there is no model context window). The TUI reconstructs that field from the snapshot, applies it on attach/rebind, and centralizes wire parsing in ContextUsage::from_wire (unknown/null tokens clear the tray, matching TS patchConnectionState). Post-turn and post-compaction refresh_stats behavior is unchanged.

Adds daemon and snapshot unit tests for snapshot/stats parity and the three wire shapes. Also adds LANE-STATE.md as an operator bench/gate journal (non-runtime).

Reviewed by Cursor Bugbot for commit 747ade7. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Feed pa-tui tray context usage from attach snapshot, not blocking stats fetch

  • Daemon attach/session summaries now compute context usage from the session store and engine context window in Worker::summary_locked (summary.rs); the field is omitted when no store or model context window exists.
  • TUI parses state.contextUsage via new ContextUsage::from_wire (chrome.rs) and reconstructs it in the attach snapshot (snapshot.rs).
  • Removes awaited refresh_stats calls from startup (run.rs), new-session, and session-switch paths; the view rebuild uses the attach snapshot instead.
  • Behavioral Change: connection-state updates without valid numeric tokens/contextWindow fields now clear the tray context usage, including the post-compaction unknown-usage shape (lifecycle.rs).

Macroscope summarized 747ade7.

Comment thread crates/pa-tui/src/session_ui/sessions_fork.rs
…or's coordination log; durable state documentation per the orchestrator's ruling)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d949b04. Configure here.

Comment thread LANE-STATE.md
2026-10-03 12:36Z Small block1 complete 12/36 raw legs, small block2 starting, no process census failures. Parent updated; original gate binding known-red-only, gate2 queued.
2026-10-03 12:40Z Clean ABBA 18/36 raw legs, all small-class blocks complete, every before/after leg census empty after scoped TERM/reap; canon class next. Sole gate rerun queued pool, driver alive.
2026-10-03 12:45Z Clean replication 24/36 raw legs (canon block0 full six legs) complete, per-leg process census zero after scoped reaping; canon blocks 1/2 remain. Gate2 driver alive waiting pool, no verdict.
2026-10-03 12:50Z Clean replication 30/36 raw legs (canon block1 complete), every pre/post process census zero following scoped worker TERM/reap; canon block2 and pyte controls remain. Gate2 queued, driver live.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental lane recovery journal

Low Severity

LANE-STATE.md is a live operator recovery journal with PIDs, VM ids, and experiment notes. Nothing in the repo reads it, and the PR's intended bench record lives under data/hillclimb. Merging it would land stale working notes at the repository root.

Fix in Cursor Fix in Web

Triggered by project rule: Review rules

Reviewed by Cursor Bugbot for commit d949b04. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged: LANE-STATE.md is an operator recovery journal, not a runtime dependency or product API. It was intentionally committed as the durable incident/coordination receipt after two live workers collided on the same bench VM; the PR body and bench record now carry the final signed outcomes. I am leaving the file on this PR for the operator's explicit disposition rather than rewriting the reviewed head only to erase the incident trail. It does not affect the production tree or test selection; CI is green. If the maintainer wants it kept only outside the product repository, it can be dropped at the merge-time fold without carrying into main. The bot's low-severity hygiene concern is valid and disclosed in the approval packet.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant