Repository navigation
refactor(agents): consolidate main-session recovery ownership - #117383
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 12:30 PM ET / 16:30 UTC. ClawSweeper reviewWhat this changesThis PR moves main-session restart recovery retries, repair scheduling, exact session/run admission, and terminal notices into a shared lifecycle owner used by agent and gateway recovery paths. Merge readinessKeep this PR open for explicit maintainer review, not because a discrete patch defect was found. The inspected head consolidates retry and deferred mutation repair behind a shared lifecycle owner, and the submitted exact-head Testbox transcript exercises the key startup, owner-release, exact-row, exhaustion, and terminal-notice paths. Because this refactor coordinates durable session recovery with gateway shutdown and the branch is behind current main, a human should review the latest merge result after the remaining checks finish. Likely related people: steipete (current recovery refactor) and Dallin Romney (recent current-main contributor on these files). Priority: P3 Review scores
Verification
How this fits togetherMain-session restart recovery resumes interrupted agent work after gateway shutdown or startup. Gateway and command paths record recovery state, the shared lifecycle logic fences and retries exact rows, and recovery either dispatches the original session or records a visible terminal outcome. flowchart TD
A[Gateway shutdown or startup] --> B[Mark interrupted main session]
B --> C[Durable recovery state]
C --> D[Shared lifecycle owner]
D --> E{Exact session and generation valid?}
E -->|Yes| F[Retry or resume agent work]
E -->|No| G[Skip stale recovery]
F --> H[Clear state or send terminal notice]
Decision needed
Why: The code changes a shared durable recovery owner across gateway shutdown, startup recovery, command ingress, state persistence, and terminal notice paths; the protected maintainer label requires a human acceptance decision even though no line-level defect was established. Before merge
Agent review detailsSecurityNone. PR surfaceSource -387, Tests +75. Total -312 across 22 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one canonical recovery owner and merge only after a maintainer confirms the current-main merge preserves startup cutoff, owner-release fencing, shutdown joining, and terminal-notice behavior. Do we have a high-confidence way to reproduce the issue? Not applicable as a defect report: this is a refactor PR. The contributor supplies exact-head Testbox terminal proof for eight targeted lifecycle cases and reports larger focused lifecycle coverage. Is this the best way to solve the issue? Yes, provisionally: consolidating duplicate retry and repair ownership is the maintainable direction, and the head adds boundary coverage for the preserved invariants. A maintainer must still validate the latest current-main merge result because this is shared recovery infrastructure. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1296ab3b4135. LabelsLabel 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
HistoryReview history (3 earlier review cycles) |
589bf38 to
624b09b
Compare
|
Merged via squash.
|
* origin/main: (26 commits) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (#117493) ...
* origin/main: (35 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) fix(gateway): preserve Responses usage details (#117533) perf(gateway): skip empty session recovery stores (#117498) fix(ci): update canonical Kova performance pin (#117508) fix(system-agent): emit the wizard cancel hint once per message (#113731) refactor: dedupe secrets runtime snapshot fixtures (#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (#117555) fix(cli): explain filtered plugin policy without unsafe recovery (#117556) fix(irc): strip markdown from outbound text (#112961) refactor(plugins): consolidate registry snapshots (#117561) fix(plugins): fail blocked enable commands (#117536) test(secrets): dedupe runtime state fixtures (#117563) feat(gateway): advertise chat attachment limits on hello-ok (#116188) fix(ui): preserve full graphemes in session owner initials (#117350) refactor(tui): consolidate runtime ownership (#117368) fix(update): return failure when dirty checkout blocks update (#117452) fix(auto-reply): apply mixed chat directives in one session transaction (#117542) refactor(ui): unify channel status and setup controls (#117499) fix(doctor): preserve surviving lint selections (#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (#112464) refactor(channels): consolidate lightweight plugin discovery (#117541) fix(imessage): prevent duplicate messages after delayed sends (#110853) refactor(memory): unify authoritative dreaming state and presentation (#117538) refactor(agents): consolidate main-session recovery ownership (#117383) fix(proxy-capture): make path-based session cleanup atomic (#98852) refactor(agents): consolidate compaction and context-engine ownership (#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
…aw#117383) * refactor(agents): consolidate main-session recovery ownership * test(agents): cover recovery owner boundaries
* origin/main: (26 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (35 commits) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence test(openai): dedupe realtime voice fixtures (openclaw#117503) fix(google): flush lazy prompts on provider readiness fix(gateway): keep canonical hooks on pristine startup path (openclaw#117493) ...
* origin/main: (491 commits) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) fix(gateway): preserve Responses usage details (openclaw#117533) perf(gateway): skip empty session recovery stores (openclaw#117498) fix(ci): update canonical Kova performance pin (openclaw#117508) fix(system-agent): emit the wizard cancel hint once per message (openclaw#113731) refactor: dedupe secrets runtime snapshot fixtures (openclaw#117502) test(google): cover ready callback close precedence ...
* origin/main: (325 commits) fix(skills): preserve profile in ClawHub command hints (openclaw#117555) fix(cli): explain filtered plugin policy without unsafe recovery (openclaw#117556) fix(irc): strip markdown from outbound text (openclaw#112961) refactor(plugins): consolidate registry snapshots (openclaw#117561) fix(plugins): fail blocked enable commands (openclaw#117536) test(secrets): dedupe runtime state fixtures (openclaw#117563) feat(gateway): advertise chat attachment limits on hello-ok (openclaw#116188) fix(ui): preserve full graphemes in session owner initials (openclaw#117350) refactor(tui): consolidate runtime ownership (openclaw#117368) fix(update): return failure when dirty checkout blocks update (openclaw#117452) fix(auto-reply): apply mixed chat directives in one session transaction (openclaw#117542) refactor(ui): unify channel status and setup controls (openclaw#117499) fix(doctor): preserve surviving lint selections (openclaw#117543) fix(media): keep an unquoted MEDIA path with spaces as one media item (openclaw#112464) refactor(channels): consolidate lightweight plugin discovery (openclaw#117541) fix(imessage): prevent duplicate messages after delayed sends (openclaw#110853) refactor(memory): unify authoritative dreaming state and presentation (openclaw#117538) refactor(agents): consolidate main-session recovery ownership (openclaw#117383) fix(proxy-capture): make path-based session cleanup atomic (openclaw#98852) refactor(agents): consolidate compaction and context-engine ownership (openclaw#117482) ... # Conflicts: # extensions/xai/realtime-voice-bridge.ts
What Problem This Solves
Main-session restart recovery spread retry, repair, scheduling, exact-row admission, and terminal-notice ownership across several wrappers. That duplicated lifecycle policy and made restart/crash behavior harder to reason about and change safely.
This is a maintainer-requested refactor. It does not add a new public feature or change the persisted/config/protocol contract.
Why This Change Was Made
The change gives recovery one canonical lifecycle owner for bounded retries/backoff, mutation repair, exact
(runId, lifecycleGeneration)admission, and scheduled retry cleanup. Startup recovery and owner-release recovery now share that machinery while retaining their distinct registration-cutoff and provider-lifecycle boundaries.Connected one-use wrappers and duplicate state/store/notice branches were removed, including
main-session-recovery-restore.ts. Production code is reduced by 402 lines (+947/-1349); tests are net -7 lines (+24/-31).The preserved invariants are:
No SQLite schema/version, configuration, gateway protocol, or public API surface changed. The touched lifecycle/state/doctor code mutates only existing recovery rows and statuses; there is no migration or backfill shape change. No Codex provider, protocol, runtime, or integration path is touched, so the repository's dependency-specific
../codexinspection gate is not applicable to this PR.User Impact
No intentional user-visible behavior change. Operators retain restart/crash recovery, owner-release wakeups, bounded retries, terminal diagnostics, and shutdown behavior with less duplicated policy and a smaller regression surface.
Evidence
tbx_01kyyjvrteeajgm6wn1vpdx1cn. Provider-owned one-shot cleanup cancels the carrier Actions job after the remote command completes; the authoritative wrapper result wasrunStatus=succeeded,exitCode=0,commandMs=72851. Carrier Actions runRedacted exact-head verbose transcript
This trace covers gateway mark-before-abort ordering, startup mark-before-channel ordering, registration-cutoff preservation, in-flight shutdown joining, exact final-owner-row admission, startup and owner-release final-charge tombstones, and one canonical visible terminal notice.
tbx_01kyyfk737vxhdbtmhd10qj7vt.tbx_01kyyg4bm5aa42x5v3tqz1r3ba, covering state/store transitions, startup registration cutoff, exact owner/run fencing, dispatch/terminal probes, retry exhaustion, gateway startup/close ordering, and agent request preflight.tbx_01kyyg16n6wk0qtt4eajjpcf0t.tbx_01kyygvjn2yf4z0fnbr7bfxfdd: structural guards, formatting, core and test TypeScript lanes, complete core lint fan-out, native state schema v6 and database-first guards, and import-cycle checks. Actions rungit diff --checkpassed.gpt-5.6-solatxhighfound no accepted/actionable findings; secret scan clean.Risk is localized to recovery lifecycle orchestration. Rollback is the single commit
589bf3809af2009f3d932c3477fa5bf87a19a127.