Repository navigation
fix: keep other chats responsive during cold history restoration - #200930
Conversation
Prepare restore payloads before writer admission, reuse retained navigation, and replay bounded batches while the cold marker owns reader visibility. Preserve recoverable partial replay for current and legacy archives without schema or configuration changes.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis 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. |
|
Codex review: needs maintainer review before merge. What this changesRestore archived transcripts in bounded transactions so other conversations can write between batches. Example: Restore a 50,000-event archive while another conversation submits 100 transcript appends.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a remaining writer-contention problem on main; both earlier findings are resolved, and no actionable defect remains in the reviewed head. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe session archive worker reads verified cold chunks, prepares transcript payloads, and writes through the existing agent database admission owner; the cold marker controls reader visibility until final publication. flowchart TD
A[Restore request] --> B[Archive worker queue]
B --> C[Verify chunks and prepare payloads]
C --> D[Bounded writer admissions]
E[Other conversation writes] --> D
D --> F[Final hot publication]
G[History readers] --> H[Complete cold archive]
F --> G
Technical reviewBest possible solution: Use the existing archive worker and writer admission owner for bounded replay, retaining cold visibility until accepted final publication. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the monolithic writer hold, supported by the supplied base-failing regression and controlled measurements; no target code was executed during this read-only review. Is this the best way to solve the issue? This is a focused repair using existing ownership: prepare outside admission, replay bounded units, and preserve the cold marker until completion without adding a schema or competing queue. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b8029b40bd9f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +174, Tests +203, Docs +4, Other +30. Total +411 across 18 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 17, 2026, 11:09 PM ET / November 18, 2026, 04:09 UTC (Revision 2). |
Keep provisional restore batches cold and recoverable, and preserve accepted close and cancellation custody for final hot publication. Migrate benchmark consumers and verify refused-publication recovery without changing the existing commit owner.
|
Addressed all three items from the previous review on
Final proof: 45 custody/lifecycle/admission tests plus 4 filesystem tests passed; The PR body now includes final five-cycle A/A/B and separate profiles. Median maximum writer holds are 24.8/19.3 s in controls versus 236 ms; worst candidate hold is 735 ms. Median append queue p99 is 35.1/23.2 s versus 75 ms. All 18 timed/profiled 50,000-event restores passed exact verification. Owner allocation falls about 12%; whole-process lifetime sampled allocation rises about 9–10%, explicitly retained in the evidence. Exact-head CI is still running; no inherited-failure exception is claimed. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…nclaw#200930) * fix: keep other chats responsive during cold history restoration Prepare restore payloads before writer admission, reuse retained navigation, and replay bounded batches while the cold marker owns reader visibility. Preserve recoverable partial replay for current and legacy archives without schema or configuration changes. * docs(perf): describe bounded restore measurements * test(perf): qualify restore runtime policy before timing * fix(sessions): accept cold restore at final publication Keep provisional restore batches cold and recoverable, and preserve accepted close and cancellation custody for final hot publication. Migrate benchmark consumers and verify refused-publication recovery without changing the existing commit owner.
* fix(update): include cold archives in candidate snapshots Co-authored-by: steipete <[email protected]> * fix(update): preserve file archives in rehearsal snapshots Co-authored-by: steipete <[email protected]> * fix(update): preserve source WAL state during archive inventory Classify cold archive SQL under its existing candidate-state subprocess owner. Preserve incomplete WAL source families so header inspection retains private cleanup custody. Co-authored-by: steipete <[email protected]> --------- Co-authored-by: steipete <[email protected]> Release adaptation: the baseline does not contain the #195487 header-cleanup suite. Keep that unrelated suite absent; carry the new incomplete-WAL inventory assertions into the existing inventory suite instead. Add a per-change 214-line allocation for the source regression, chunk fallback, and WAL preservation tests. No schema, updater protocol, authority, or archive-integrity changes. Companion audit at 9e917f0: - #200733 is selected as the next dependency-closure repair: missing archives must warn instead of blocking updates, and Windows copies must not share live read-only inode attributes. Do not qualify this intermediate checkpoint alone. - #200076 and #200930 are independent cold-history performance changes, not prerequisites for this snapshot repair. - #201009, #200994, #200866, #200577, #200805, #200802, and #200732 overlap only adjacent update documentation and independent repair flows; not prerequisites. Proof on base 309067b: - New production-subprocess regression: 4/4 fail before, 4/4 pass after. - Cold archives, chunks, and inventory: 31/31 pass after. - Additional budget/cleanup/import siblings: 46/47 pass. Configured-cache containment fails identically on the unchanged base at budget.test.ts:737; retained as an independent failure, not weakened or repaired here. - Targeted lint and format, documentation links, SQLite worker ratchet, and test-line ratchet pass. SQLite T1 counts remain 170; compatibility 15. - Worker typecheck was blocked at dependency custody, without guard bypass. Parent canonical core typecheck, typed lint (five files), and formatting passed with its owned dependencies. Full installed-upgrade/FRV proof remains pending the assembled candidate, including selected companion #200733. (cherry picked from commit 802e3f7) Co-authored-by: RomneyDa <[email protected]> Co-authored-by: vincentkoc <[email protected]>
Related: #200076
What Problem This Solves
Restoring a large archived conversation holds the agent database writer while it decodes and rebuilds the whole transcript. Messages in other conversations then wait behind that restore, even when storage is otherwise idle.
User Impact
Other conversations can write between restore batches. Readers continue to see the complete cold archive until restoration finishes; an interrupted restore remains cold and can be retried. No schema, configuration, or retention changes are required.
Why This Change Was Made
Prepare payloads outside writer admission and reuse the navigation and identity projections already retained by cold storage. Replace the full-session delete and replay with batches of at most 256 records, releasing the shared writer reservation after each batch. The existing cold marker remains the visibility boundary. The existing worker accepts its commit grant only for final hot publication, then retains custody through settlement. Published legacy archives still rebuild their missing projections.
Production source grows by 174 lines (+277/-103) for bounded orchestration, admission release, and prepared-payload replay. This removes the monolithic restore path without introducing a scheduler, durable progress state, or schema change. The obsolete rollback-only navigation benchmark restore arm is replaced by the real restore-flow harness; the memory benchmark retains its explicit frozen pre-batched baseline interface.
Evidence
Final measured head:
6fb80f96f82abf462f65a99abffd60fa491a1fca. Five serial A1/A2/B cycles used fresh copies of a synthetic 37.3 GiB agent database: 2,401 sessions, 6.05 million events, a 50,000-event cold target, and 100 concurrent real transcript appends to another session. Controls use parent7f395779d12a0c5d16ed28d8cf4d37fbe8c098ec. Host: Apple M3 Ultra, 512 GiB RAM, Node 26.12.1, APFS, shared host load. These are synthetic measurements, not production filesystem latency guarantees.Every candidate hold and p99 queue wait beat every control. Candidate maximum holds ranged from 181 to 735 ms; the 735 ms sample spent 721 ms at COMMIT and 13.6 ms in the transaction body. Candidate queue p99 ranged from 52 to 230 ms. All 15 runs passed exact JSON/sequence/timestamp verification for all 50,000 restored events, plus identity, active-row and FTS counts. No median elapsed/CPU regression exceeded the predeclared 20% limit; both improved substantially.
Separate A/A/B profiles included collected-object heap sampling across all observed transaction isolates. Cold-owner sampled allocations fell from 4.449/4.431 GB to 3.900 GB (about 12%); sampled owner CPU fell from 21.34/18.59 s to 10.12 s. Whole-process lifetime sampled allocations increased from 13.820/13.754 GB to 15.115 GB (about 9–10%, 24 observed isolates versus 22). These are allocation traffic estimates, not retained-heap measurements; the whole-process increase is retained in the result. All three profiled restores also passed exact verification.
pnpm check:changed, final focused lint/typechecks, and runtime/Control UI artifact builds passed. Final independent Codex review found no actionable P0–P2 findings.CI run 44224828739 exposed two PR-caused defects (accepted custody and old benchmark API callers); both are fixed at the measured head. No failure is being classified as inherited. Exact-head CI run 44231605844 and the final ClawSweeper review gate landing.