Repository navigation
perf(sessions): bound transcript append writer residency - #171540
Conversation
Keep settled append bodies in receipts and canonical SQLite rather than actor residency. Reuse the existing navigation projector and carry exact context byte metadata through settlement. Large append streams stay bounded instead of serializing retained history or exhausting the writer heap. Report primary append payloadBytes in slow SQLite hold diagnostics. SQL phase timing includes JavaScript work inside the transaction. No schema or transcript format changes. Validated focused residency, kernel, context metadata, memory history, payload, rewrite, receipt, and append postimage contracts. Independent subagent review clean after autoreview route refusal. Team-shaped synthetic 4.6 GB database: 6 MiB append worker p50 63.9 to 22.7 ms, round-trip p99 133.9 to 83.6 ms.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 43dc994ee2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if ( | ||
| command.type !== "session.actor.appendTranscriptEvent" && | ||
| command.type !== "session.actor.appendToolResult" | ||
| ) { | ||
| return undefined; |
There was a problem hiding this comment.
Attribute payloads for every turn-writing phase
When a large user or assistant message is persisted through session.actor.acceptInput, session.actor.adoptRun, or the turn-bearing form of session.actor.completeTurn, this guard returns before inspecting the command's turn or append, even though those phases execute the same transcript writers. Their slow-transaction warnings therefore omit context.payloadBytes, leaving the primary production paths that can incur large-payload holds without the attribution introduced by this change; handle every phase whose contract can carry a SessionTurnPlan or SessionActorAppend.
Useful? React with 👍 / 👎.
* commit '976cc974fab1912c696d1101bd17a1abf05eb77e': (82 commits) perf(sessions): reuse rows after unrelated plugin reloads (#171519) fix(doctor): treat an explicit Skill Workshop deny as an opt-out (#171314) perf(sessions): bound transcript append writer residency (#171540) fix(workboard): a review card with done parents cannot be claimed (#171414) fix: reduce New Session typing lag after models load (#171530) test(gateway): isolate external auth refresh fixture writes perf(plugins): filter agent event subscriptions by phase before cloning (#171534) refactor(ui): render retained chat panes with Solid (#169835) fix(ui): match rail pin icon size and selection fill to rail buttons (#171517) fix(auth): move bundled inference and logout SQLite into workers (#171510) fix(ci): include desktop staging tests in Knip graph test(ui): await terminal panel commit before handoff readiness fix(update): reclaim runtimes under protected systemd user managers (#171488) fix(sdk): account for async model auth preparation fix(update): release the writer during delayed host admission (#171493) fix(update): resume progress after offline maintenance (#171454) fix: identify update snapshot failures before activation (#171457) fix(memory): recover worker-backed managers after terminal worker loss (#171494) fix(talk): keep accepted agent work after client failures (#171377) fix(qa): generate canonical Code Mode matrix config (#171520) ...
…1540) * perf(sessions): bound transcript append writer residency Keep settled append bodies in receipts and canonical SQLite rather than actor residency. Reuse the existing navigation projector and carry exact context byte metadata through settlement. Large append streams stay bounded instead of serializing retained history or exhausting the writer heap. Report primary append payloadBytes in slow SQLite hold diagnostics. SQL phase timing includes JavaScript work inside the transaction. No schema or transcript format changes. Validated focused residency, kernel, context metadata, memory history, payload, rewrite, receipt, and append postimage contracts. Independent subagent review clean after autoreview route refusal. Team-shaped synthetic 4.6 GB database: 6 MiB append worker p50 63.9 to 22.7 ms, round-trip p99 133.9 to 83.6 ms. * fix(ci): attach navigation safety note to its assertion
What Problem This Solves
Large transcript append streams progressively slow the agent database writer and can exhaust its heap, delaying other session writes behind it.
User Impact
Appends keep bounded writer residency while preserving exact persisted transcript bytes, commit receipts, retry identity, model-context navigation, and byte accounting. Slow transaction warnings now include
context.payloadBytesfor the primary prepared event/message (or summed turn messages; optional initialization/header excluded). No schema, stored format, or configuration changes.Why This Change Was Made
The append owner added full parsed events to both the actor payload map and navigation. Residency then serialized the entire retained state on every settlement to enforce its 8 MiB budget. Large bodies therefore caused increasing JavaScript work, eviction/re-hydration, and eventually worker heap exhaustion.
phases.sqlMsincludes JavaScript executed inside the transaction; it is not a sum of SQLite statement timings.Reuse the existing memory actor navigation projector for durable appends. Build detached receipts first, retain exact context byte metadata, then discard settled payload bodies at the residency owner. Retry reads use the existing canonical SQLite fallback. Remove the obsolete resident-payload rewrite loop and move message identity lookup into its existing owner.
Production LOC: +42 (153 added / 111 removed, excluding tests/support/docs). The required new payload-size diagnostic contract needs command-shape handling and forwarding through worker transaction contexts; the navigation projector and identity lookup are moves. This adds no second cache or residency mechanism.
Evidence
Synthetic production-shaped fixture on an isolated 128-core Linux sandbox: 5,000 sessions, 6,000 retained runs, approvals/cron/projects/worktrees; initial agent database 4,641,595,392 bytes. All commands restricted to allocated CPUs 64–127, 64 GiB memory, nice/idle I/O, isolated state. No production databases or services accessed. Node 26.8.2. Actual durable actor transport and writer worker; 6 MiB cache-TTL events. Five initial append samples excluded for lazy startup/warmup.
Queue measurement includes actor dispatch/admission and worker serialization, rather than isolating only SQLite reservation wait. No individual SQLite statement exceeded 50 ms during these measured runs. In an 80-event session stress case the old worker exhausted its heap on append 56 (preceding writer-phase p99 189.80 ms); the changed worker completed all 80 appends on a matched 80-event session, p50 27.54 ms / p99 104.79 ms after warmup. The median improvement is clear; the stress p99 narrowly exceeds 100 ms. This does not reproduce or claim to eliminate every reported 0.94–1.44 s production hold, nor qualify a 43 GB cold database. Payload attribution will help distinguish remaining causes.
Regression fails on the old retention behavior: reading another session forces the large append actor to rehydrate. Changed behavior preserves residency, exact receipt/stored bytes, UTF-8 byte totals, ancestry, and warm/cold context equivalence. Existing rewrite, receipt, append-postimage, kernel, context-metadata, memory-history, and transcript-payload contracts passed focused checks.
Local proof: changed-file
oxfmt, changed-file repooxlint,git diff --check; focusedpnpm test <files> --maxWorkers=1only. Final residency/kernel: 7 passed; rewrite/receipt/append-postimage: 17 passed; earlier context-metadata/memory-history/payload contracts passed. No Testbox/Crabbox lease: operator policy assigns full typecheck, suites, and closure gates to PR CI.Review: independent subagent review (autoreview route unavailable), scoped clean at P2+. Autoreview refused because its requested provider did not match operator config; config unchanged. Full PR CI passed on the corrected head.
CI follow-up: initial head
43dc994ee299e17ab0553f3be4a2a01b8a089438passed every selected broad gate except assertion-safety. Its existing safety note was above the projection call rather than the nested assertion. Commitc21b2437b187places the note immediately beside the same assertion; no behavior/types/assertions changed. Targetedcheck-assertion-safety-ratchetnow passes, changed-file formatting/lint pass, and the independent reviewer approved the exact correction. This failure was caused by this diff and was fixed; it is not being treated as inherited. Full CI run 38499135883 and the required repository review gate passed on corrected headc21b2437b187eb153660457567330ad75e92b579. Merged asa15b5c7109401c35c8fad9edeb3e28de913f7e0f.