Skip to content

refactor(main-session-recovery): deslop main-session recovery - #165974

Merged
steipete merged 1 commit into
mainfrom
steipete/deslop-restart-main-recovery-20261005
Oct 6, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/deslop-restart-main-recovery-20261005

Conversation

@steipete

@steipete steipete commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Remove the ephemeral reservation executionIdentityAdmission field 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.
  • Fold admitted-interruption transitions into their only consumer, the recovery state machine, without changing guards or mutations.
  • Fold the checkpoint reader forwarder into the checkpoint owner. Its outside-directory edits are mechanical import updates in src/gateway/session-history-worker.integration.test.ts and scripts/bench-agent-database-holds.ts.
  • Reuse the existing main-session fixture in ten tests. Keep every scenario, input, assertion, and ordering contract.

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 :212 represents 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 in main-session-restart-recovery.test.ts:4906 and :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:75 and src/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, base 98262d8b5fda: node scripts/run-vitest.mjs src/agents/main-session-recovery --maxWorkers=1 passed 288 tests across 13 files in 290.45 seconds. The lease needed one pnpm 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 at 5f40d4473bd6:

  • 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.
  • All eight changed source/test files matched local SHA-256 values; both deleted modules were absent. Crabbox retains its bootstrap Git HEAD, so the changed gate uses the explicit ten-file lane scope and pinned base. The initial HEAD assertion and missing-base comparison were Testbox setup failures; neither is counted as a passing gate.

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 untouched src/gateway/server-close.agent-databases.test.ts (1,001 lines versus 1,000), with no errors.

The initial CI run failed check-test-types because 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 Testbox tbx_01m480qbdbvv1p6ztafyec688q, node scripts/check-changed.mjs --base 4ab38e4d7e5932f5d306d6de22c7cbd1f475f79a -- scripts/bench-agent-database-holds.ts passed, including scripts typecheck, lint and export guards. node --import ./scripts/tsx.mjs scripts/bench-agent-database-holds.ts 10 5 also 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 16b2c5c72034f142f384ad3e66b4018c4b4d30f1 preserves the reviewed and Testbox-validated recovery files and includes the validated script import. Exact-head CI run 37429443828 passed, including openclaw/ci-gate; workflow wall time was 540 seconds (07:24:17–07:33:17 UTC). No tests or CI test cases were added.

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 6, 2026
@steipete
steipete marked this pull request as ready for review October 6, 2026 06:54
@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 3:31 AM ET / 07:31 UTC (Revision 3).

ClawSweeper review

What this changes

The 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
Reviewed head: 16b2c5c72034f142f384ad3e66b4018c4b4d30f1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving cleanup with intact guards, equivalent fixtures, and recorded validation.
Proof confidence 🌊 off-meta tidepool Not applicable: The verified repository-admin author is exempt from external-contributor proof. Recorded synthetic-state benchmark evidence exercises the moved checkpoint reader; recovery tests are supplemental. No material authority or stored-data contract changes require additional proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The verified repository-admin author is exempt from external-contributor proof. Recorded synthetic-state benchmark evidence exercises the moved checkpoint reader; recovery tests are supplemental. No material authority or stored-data contract changes require additional proof.
Evidence reviewed 9 items Introduced changes preserve recovery guards: The pinned introduction diff moves the admitted-interruption implementation verbatim into the state machine. Session, cycle, attempt, run, generation, reservation, foreground-claim, and repeatability checks remain intact.
Persisted identity remains authoritative: Gateway recovery admission reads mainRestartRecovery.executionIdentity directly. Removing the ephemeral reservation result does not change that reader or the persisted state shape; enabled retry retention and disabled collection behavior remain covered.
Complete checkpoint caller cutover: The checkpoint reader retains its original worker-backed operation. Searches found all three callers using the checkpoint owner and no references to either deleted module.
Findings None None.
Security None None.

How this fits together

Main-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]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -22, Tests -42, Other 0. Total -64 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 58 80 -22
Tests 4 16 58 -42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 11 75 139 -64

Review metrics

None.

Technical review

Best 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.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This bounded internal cleanup preserves user-visible behavior and persisted contracts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The verified repository-admin author is exempt from external-contributor proof. Recorded synthetic-state benchmark evidence exercises the moved checkpoint reader; recovery tests are supplemental. No material authority or stored-data contract changes require additional proof.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • joshavant: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-06T06:54:15.858Z sha 4ab38e4d7e5932f5d306d6de22c7cbd1f475f79a :: needs maintainer review before merge. :: none
  • reviewed 2026-10-06T06:59:46.872Z sha 4ab38e4d7e5932f5d306d6de22c7cbd1f475f79a :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 6, 2026
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.
@steipete
steipete force-pushed the steipete/deslop-restart-main-recovery-20261005 branch from 4ab38e4 to 16b2c5c Compare October 6, 2026 07:24
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 6, 2026
@steipete
steipete merged commit fc9078d into main Oct 6, 2026
141 of 142 checks passed
@steipete
steipete deleted the steipete/deslop-restart-main-recovery-20261005 branch October 6, 2026 07:48
@steipete

steipete commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant