Repository navigation
refactor(main-session-recovery): deslop main-session recovery - #165974
Conversation
|
🦞👀 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: needs maintainer review before merge. Reviewed October 6, 2026, 3:31 AM ET / 07:31 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR removes an unused recovery reservation result, consolidates interruption and checkpoint helpers into their existing owners, updates callers, and reuses existing test fixtures. Merge readiness✅ Ready for maintainer review The cleanup remains useful and is not superseded by current main. No actionable correctness or security findings remain; the benchmark import is repaired, and pending CI is ordinary merge gating. Priority: P3 Review scores
Verification
How this fits togetherMain-session recovery reads persisted session state and transcript checkpoints after a Gateway restart. It decides whether interrupted work can resume or settle, then coordinates admission and delivery through the existing runtime owners. flowchart TD
A[Gateway restart] --> B[Persisted session state]
B --> C[Recovery state machine]
D[Transcript checkpoint reader] --> C
C --> E{Resume or settle}
E --> F[Gateway run admission]
E --> G[Terminal settlement]
F --> H[Continued agent work]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -22, Tests -42, Other 0. Total -64 across 11 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep recovery decisions in the existing state and checkpoint owners while preserving durable identity, lifecycle guards, and regression coverage. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a behavior-preserving refactor, and source inspection confirms the redundant result and helper modules. Is this the best way to solve the issue? Yes: removing the unused result and consolidating identical helpers into their existing owners is a narrow, maintainable cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b673acd58485. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
Remove the unused reservation identity result after the admitted-run cutover. Fold admitted interruption and checkpoint reads into their existing owners, keeping persisted state and all recovery guards. Reuse existing fixtures without removing regression cases. Internal refactor; no user-visible behavior or persisted-shape changes.
4ab38e4 to
16b2c5c
Compare
|
Merged via squash.
|
…aw#165974) Remove the unused reservation identity result after the admitted-run cutover. Fold admitted interruption and checkpoint reads into their existing owners, keeping persisted state and all recovery guards. Reuse existing fixtures without removing regression cases. Internal refactor; no user-visible behavior or persisted-shape changes.
What Problem This Solves
Main-session restart recovery retains an unused reservation result and unnecessary single-consumer modules after the admission-owner cutover.
User Impact
No user-visible behavior changes. Persisted recovery state, execution identity, terminal evidence, retries, and post-await ownership checks are preserved.
Why This Change Was Made
executionIdentityAdmissionfield and its composition. The last dispatch consumer was removed in 73a9eed (refactor(audit): add canonical admitted-run context #120534); Gateway admission reads the persisted execution identity. Tests now assert that retained state directly.src/gateway/session-history-worker.integration.test.tsandscripts/bench-agent-database-holds.ts.This uses the deletion target escape hatch: 64 net lines removed (22 production, 42 tests), below the 2,000-line target. The large suite already lost 998 net lines in #161204; no test cases are deleted here. The terminal settlement writer was already unified in #165469 (
main-session-recovery-clear.ts:53), and #165612 already deleted the private execution-capacity modules.Further deletion stopped at concrete contracts:
src/agents/main-session-recovery/main-session-recovery-state.ts:582: current cycle, attempt, run and generation checks protect admitted-interruption ownership. Terminal residue at:212represents retained persisted evidence, not a duplicate live owner.src/agents/main-session-recovery/main-session-restart-recovery-resume-policy.ts:227: the legacy abort reader accepts persisted pre-upgrade transcript rows. Both legacy and current Code Mode abort regressions remain inmain-session-restart-recovery.test.ts:4906and:4945.src/agents/main-session-recovery/main-session-restart-recovery-runtime.ts:419: the deferred-admission continuation and its original startup cutoff are today's scheduler contract.src/gateway/server-startup-post-attach.ts:75andsrc/gateway/server-startup-post-attach.test.ts:154: removing the recovery barrel requires changing outside-lane dynamic-import composition and mocks, beyond the permitted mechanical import updates.Evidence
Before: 25 production modules / 5,852 lines; after: 23 modules / 5,830 lines.
git diff --shortstat origin/main...HEAD: 11 files changed, 75 insertions, 139 deletions. Production/tooling: +59/-81; tests: +16/-58. No runtime performance improvement is claimed.Baseline on Blacksmith Testbox
tbx_01m47smnys5ztfm3mrdxxzcen7, base98262d8b5fda:node scripts/run-vitest.mjs src/agents/main-session-recovery --maxWorkers=1passed 288 tests across 13 files in 290.45 seconds. The lease needed onepnpm install --frozen-lockfile; it is stopped.Independent Codex autoreview: scoped-clean through P2. The test audit also checked fixture-helper equivalence against the unchanged helper definition. The diff-scoped deslop pass found no additional safe removal.
Fresh Blacksmith Testbox
tbx_01m47wdww98vqh87jc4grddskg, candidate tree at5f40d4473bd6:pnpm install --frozen-lockfile: passed once on the fresh synced checkout.node scripts/run-vitest.mjs src/agents/main-session-recovery src/gateway/session-history-worker.integration.test.ts --maxWorkers=1: 296 tests passed across 14 files, 324.12 seconds. This retains all 288 baseline recovery tests and adds the eight existing checkpoint-reader integration tests to the proof set; no tests were added to the repository.Blacksmith Testbox
tbx_01m47x9r4ctrhsz3vsbddbj1y7: shallow pinned-base fetch, source hashes, and one frozen dependency install passed.node scripts/check-changed.mjs --base e560dccc6d050d86ddff74886b0dc40599ab2add -- <the ten changed paths>passed, exit 0 (remote command 1,827.53 seconds). Core typecheck, all 27 test type graphs, five lint shards, line-cap and storage guards passed; unused exports and runtime import cycles were both zero. Lint retained one warning in untouchedsrc/gateway/server-close.agent-databases.test.ts(1,001 lines versus 1,000), with no errors.The initial CI run failed
check-test-typesbecause the benchmark script still imported the deleted module. That missed consumer is now included in the mechanical import cutover. Follow-up autoreview was scoped-clean through P2. On Blacksmith Testboxtbx_01m480qbdbvv1p6ztafyec688q,node scripts/check-changed.mjs --base 4ab38e4d7e5932f5d306d6de22c7cbd1f475f79a -- scripts/bench-agent-database-holds.tspassed, including scripts typecheck, lint and export guards.node --import ./scripts/tsx.mjs scripts/bench-agent-database-holds.ts 10 5also passed on isolated synthetic state; its recovery checkpoint samples performed zero caller-thread SQLite queries or write holds. Combined remote command: 300.56 seconds.All lane leases are stopped. Final head
16b2c5c72034f142f384ad3e66b4018c4b4d30f1preserves the reviewed and Testbox-validated recovery files and includes the validated script import. Exact-head CI run 37429443828 passed, includingopenclaw/ci-gate; workflow wall time was 540 seconds (07:24:17–07:33:17 UTC). No tests or CI test cases were added.