Repository navigation
refactor: reduce live digest scheduling allocations - #137655
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 3, 2026, 7:56 PM ET / 23:56 UTC. ClawSweeper reviewWhat this changesThe PR avoids allocating a pending-note array during live-digest readiness checks and clears contextless terminal-run bookkeeping on observer disposal. Merge readiness⛔ Blocked before merge - 2 items remain Keep open. The introduced scheduling check is equivalent to the prior filtered-count check under the note producer’s ordered, prefix-evicted buffer invariant, and the disposal cleanup is owner-aligned; the failed exact-head CI gate and pending combined-build Gateway validation remain landing blockers. Priority: P3 Review scores
Verification
How this fits togetherThe Gateway session observer turns agent activity into ordered notes, schedules utility-model progress digests, then broadcasts and persists them for the Control UI. Its disposal path releases the observer’s in-memory lifecycle bookkeeping. flowchart LR
A[Agent events] --> B[Activity note producer]
B --> C[Ordered bounded note buffer]
C --> D[Digest readiness check]
D --> E[Utility-model digest]
E --> F[Control UI broadcast and persistence]
G[Observer disposal] --> H[Clear terminal bookkeeping]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1. Total +1 across 1 file. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the single ordered-buffer readiness check and disposal cleanup, then complete the failed exact-head CI and combined-build Gateway validation before merge. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR is a behavior-preserving internal refactor, and source inspection establishes the relevant ordered-buffer invariant. Is this the best way to solve the issue? Yes. It reuses the note producer’s existing sequence and prefix-eviction contract, while preserving exact filtering only where the digest snapshot is actually needed. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0b3c5f9dc1b9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…date-command * origin/main: fix(ci): retry transient npm advisory timeouts (#137716) fix: keep restored Usage navigation from being replaced by Chat (#137402) fix: keep Usage day totals within the selected session scope (#137396) refactor: reduce live digest scheduling allocations (#137655) fix(ui): submit selected slash arguments in new sessions (#137571) fix(ui): expand collapsed task progress on final (#137569) fix(test): prevent auth discovery from stalling MCP replacement proof (#137639) test(cli): reuse canonical directory mock call helper (#137640)
What Problem This Solves
Live session digests repeatedly allocated pending-note arrays just to decide whether four notes were ready. Disposed observers also kept up to 256 contextless terminal-run entries while the service remained referenced.
Why This Change Was Made
The note producer already maintains increasing sequence numbers and evicts only an oldest prefix. Readiness can inspect the fourth note from the end; actual digest execution still captures the same pending-note snapshot. Disposal now clears its bounded contextless-terminal map alongside the other owned maps.
User Impact
Digest timing, selected notes, visibility behavior and model output stay unchanged. Scheduling does less collection work, and disposal releases the remaining bounded terminal bookkeeping.
Evidence
An unchanged before/after public-owner probe matched all 11 stage snapshots, four model calls, four broadcasts and persisted digests. It covers the three/four-note threshold, the 12-second boundary, count/byte eviction, cursor retirement, visibility suspension/resumption and rollover. Note-filter arrays fell from 25 to 4; inspected notes from 204 to 43. Disposal retained 256 contextless entries before and zero after. These are operation counts and bounded-retention evidence, not a whole-Gateway RSS or latency claim.
All 41 existing observer, digest-budget and note-producer tests passed. The canonical full changed gate passed, and independent Codex review found no actionable P0–P2 findings.
Production +6/−5 (net +1); tests unchanged. The remaining line is justified by disposal cleanup and the ordered-note invariant comment after deleting the old readiness helper. No protocol, configuration, dependency, storage schema or retention-policy changes. Combined-build live Gateway validation remains pending before landing.
The twelve-change composite abbd728d2d602594eaf04fc56bdaf8adccfca651 passed the unchanged ten-admission real OpenAI Gateway workload (14 stages, 50 observations), with independent offline acceptance. Separate live integration delivered eight observer events during six successful file reads, including utility-model assessment and terminal completion. Side chat also passed explicit workspace reads, reset, in-flight cancellation, empty-state verification and recovery. All owned Gateway/CLI processes exited cleanly and their ports/runtime were released.
The first untimed feature attempt is retained as failed: a vague recovery question did not recover a fact absent from inherited user/assistant text. The corrected attempt asks the same explicit file-read question before and after cancellation, without supplying the answer. No product source changed to obtain that pass. This does not isolate the readiness threshold or disposal memory effect; the owner proof above does.
ClawSweeper follow-up: its requested CI and combined-build proof are now complete. The failed lint job had timed out downloading pnpm before lint ran; one failed-only retry passed at the unchanged PR head. The combined run observed lower idle RSS, but no per-PR RSS benefit is claimed.