Repository navigation
fix(gateway): subagent sessions stay running after restart - #126322
fuller-stack-dev merged 7 commits into
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: blocked before merge. Reviewed September 15, 2026, 8:55 AM ET / 12:55 UTC (Revision 7). ClawSweeper reviewWhat this changesMarks ownerless subagent sessions from an earlier Gateway process as interrupted, preserves active or recoverable work, and reports interrupted sessions publicly as failed. Merge readiness⛔ Blocked before merge - 1 item remains This PR remains necessary: current main lacks the session-only repair, and the merged task-registry fix addresses different ownership. No actionable patch defect remains. The recorded updater and backup-restore evidence resolves the previous compatibility follow-up. Priority: P2 Review scores
Verification
How this fits togetherGateway startup maintains persisted session databases before serving session history. This repair checks execution ownership before changing stranded session metadata consumed by session listings. flowchart TD
A[Gateway startup] --> B[Existing session databases]
B --> C[Prior-process running subagents]
C --> D{Current Gateway authority and no run or task owner?}
D -->|No| E[Preserve session]
D -->|Yes| F[Revalidate and persist interruption]
F --> G[Session listing reports failed]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +292, Tests +490. Total +782 across 18 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use the existing startup and session-write owners for truthful orphan settlement, retaining the documented backup-based rollback contract. Do we have a high-confidence way to reproduce the issue? Yes: a prior-process running subagent row without any run/task owner reaches current main's startup handoff without settlement. Retained real restart evidence demonstrates that case; this read-only review did not rerun it. Is this the best way to solve the issue? Yes: the patch repairs the canonical startup/write boundary, preserves legitimate owners, and avoids fabricated completion or runtime. Supplied upgrade and restored-backup proof covers the stated compatibility contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e00500a65429. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
b8a03f5 to
2141c25
Compare
Retain vladimirkrdzic / VACInc contributor ancestry while retiring the obsolete startup implementation before supported main integration. The independently reviewed current-flow candidate follows on this same branch.
Integrate startup recovery at the admitted per-database handoff and canonical SQLite commit boundary. Preserve live, durable, malformed, queued and retained-completion owners. Read current durable ownership and the authorizing Gateway lease outside inherited snapshots. Preserve suppressed public lifecycle projections as no-ops. Keep canonical interrupted distinct in canonical list and readonly existence queries; project public failed without invented runtime. Retained isolated restart/SQLite/CLI and 167 adjacent tests plus 30 static gates; current independent physical validation passed 34 readonly/startup tests, lint, ratchets and both type lanes; the preceding 78-test lease/lifecycle and 42-test registry/startup validations remain retained. Independent P0-P2 security/source review is scoped-clean; current-main integration preserves the exact PR patch ID and passed affected registry/session-list tests plus both type lanes. Contributor: vladimirkrdzic / VACInc. Co-authored-by: Vladimir Krdzic <[email protected]>
|
@clawsweeper review Review-only for exact head 7c6aa31. Inspect the current per-database startup/SQLite ownership boundary and retained real restart/CLI proof in the updated PR body, including the red-to-green inherited-snapshot owner/lease races, suppressed lifecycle projections and readonly canonical-status probes. No repair, autofix or automerge is requested. |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review Review-only for exact head d5e3c19. The PR body now records the supported backup-based rollback contract and completed published 2026.9.4 updater × exact candidate proof, including pre-update backup verification, installed artifact equality, interrupted/public-failed behavior, and published-binary reopening of the restored pre-update state. The existing Doctor delivery normalization is explicitly accounted for; no updater invocation was replayed. The only source change since your reviewed head is a module-relative subprocess fixture reference. All three affected process cases, lint and both unused-file scans passed. Production source is unchanged. Duplicate secrets-shard ownership remains an inherited CI issue with canonical repair #148769; no duplicate repair is requested. No autofix, repair or automerge is requested. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…126322) * fix(sessions): interrupt orphaned subagent runs on startup * chore: prepare startup recovery for current-main integration Retain vladimirkrdzic / VACInc contributor ancestry while retiring the obsolete startup implementation before supported main integration. The independently reviewed current-flow candidate follows on this same branch. * fix(gateway): recover prior-process session-only subagents Integrate startup recovery at the admitted per-database handoff and canonical SQLite commit boundary. Preserve live, durable, malformed, queued and retained-completion owners. Read current durable ownership and the authorizing Gateway lease outside inherited snapshots. Preserve suppressed public lifecycle projections as no-ops. Keep canonical interrupted distinct in canonical list and readonly existence queries; project public failed without invented runtime. Retained isolated restart/SQLite/CLI and 167 adjacent tests plus 30 static gates; current independent physical validation passed 34 readonly/startup tests, lint, ratchets and both type lanes; the preceding 78-test lease/lifecycle and 42-test registry/startup validations remain retained. Independent P0-P2 security/source review is scoped-clean; current-main integration preserves the exact PR patch ID and passed affected registry/session-list tests plus both type lanes. Contributor: vladimirkrdzic / VACInc. Co-authored-by: Vladimir Krdzic <[email protected]> * test(gateway): resolve startup orphan fixture by module URL * test(agents): supply runtime auth store in thinking fixture --------- Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: Vladimir Krdzic <[email protected]>
What Problem This Solves
Fixes session-only subagent sessions that remain falsely running after a Gateway restart.
User Impact
Truly ownerless sessions from the prior process are marked interrupted instead of appearing active indefinitely. Active, queued and recoverable work is preserved. No configuration change or migration is required.
Why This Change Was Made
Recovery now uses the current per-database startup handoff and rechecks ownership at the SQLite commit boundary. Elapsed time alone does not authorize recovery. Public status remains failed, without invented end times, runtime, completion notifications or delivery.
Contributor vladimirkrdzic / VACInc is credited; original commit2141c251 remains an ancestor on this same branch through signed, non-force integration.
Published Updater and Rollback Qualification
The supported contract retains canonical
interrupted. Rollback to the published binary restores a pre-update backup into fresh state; running that older binary directly against candidate-written state is not supported.A fresh native, task-isolated cell used the integrity-pinned published [email protected] updater against the package built from
7c6aa315f12d0daae7363b33aedd0b95aff8545c:7b934effdbe2ee56046c5ed2bc1f9391a1006c83296805d045df60faba4680aa.backup create --verifyandbackup verifypassed before the update.openclaw update --tag file:<candidate.tgz> --yes --no-restart --jsonexited 0 with statusok. All 7,945 checked installed runtime files matched the candidate archive.interrupted/ publicfailed, without fabricated end time or runtime. Completed session identity, status and lifecycle timestamps were retained.delivery: {kind: "none"}to both synthetic rows. This exact change is recorded by the updater and its source is unchanged from the integrated base. The initial whole-row equality failure is retained; the reconciled check requires the complete expected rows, including that migration.backup restore --target <fresh-directory>, published-binary Doctor, and published Gateway reads passed. Restored canonical rows exactly match the pre-update backup; the separate candidate state stayed unchanged. All proof Gateways shut down cleanly.The first harness attempts exposed a released-CLI URL-override rule and lazy agent-database creation. Both receipts are retained; the successful setup used the configured local target and metadata-only
sessions.createwithrunStarted: false. No updater invocation was replayed, no inference ran, and no operator state was used.The follow-up commit
d5e3c19a510f3df782e9e296764958153a0f8d42only makes the subprocess fixture reference statically discoverable. It changes no production source. All 3 default/shared/embedded process tests, lint, and production/full-tree Knip unused-file scans passed. The original 124-artifact restart proof was retained, not replayed.Earlier CI failures are retained. The landed canonical UI and registry fixes are now integrated through #149023, #149016 and #149038; the remaining work in #148769 is not a prerequisite for those already-landed roots. Required exact-current-head CI and native landing remain pending.
Evidence
7c6aa315…; the later test-only reference fix leaves production bytes unchanged. Fresh exact-head hosted CI remains required before native landing. No operator Gateway or account state was used.Behavioral proof and source provenance
The original proof used a real exited predecessor and built successor Gateway against isolated real SQLite on loopback, without model inference. Commands included:
node openclaw.mjs gateway run --bind loopback --port 39073 --auth none --allow-unconfiguredand
node openclaw.mjs gateway call sessions.list --json --params '{"limit":100}' --expect-url ws://127.0.0.1:39073.The124 original artifacts and14 qualified afterimages remain retained. Current source additionally preserves newer main registry projections and corrects snapshot ownership, lease admission, suppressed public projections and readonly canonical status matching. Clean-review tree: 265a1f975a50e390f1756741bbcc89b27072c4a9 against base12d055d7cd16e5fbdae86231d83b4135a2b5d89d. Patch-identical integrated tree: 2414686b0ef0320a1c19e7642d5ab1feb8dd3c5a against base04400e289e101c439a76bbdce9425cf04c07b293; published head: 7c6aa31. The final validation checkout has independent physical Git objects and a separate dependency store; rejected nested-graph exploration is excluded from qualification.
Live, queued, yielded, recovering, retained-completion/task, malformed-owner, rebound, shared-store and Incognito controls remain protected. Only canonical status, abortedLastRun and lastRunError change. No registry completion/delivery is synthesized.
Release-note context: Gateway restart no longer leaves truly ownerless prior-process subagent sessions falsely running. Credit vladimirkrdzic / VACInc. CHANGELOG.md remains release-owned and unchanged.
Original contributor description (historical context)
What Problem This Solves
Subagent sessions can remain durably
runningafter the gateway process disappears between a tool result and the terminal assistant/lifecycle event. The persisted row then has no terminal timestamp or reason, so session readers report a dead run as live indefinitely.Why This Change Was Made
Startup is the first safe boundary where the new process can distinguish prior-process subagent rows from current work. The repair will reconcile only rows that are:
runningfrom before the current process boundary;Recovered rows will become the distinct terminal state
interrupted, carrying a persisted reason. They will not be reported as completed.The lifecycle owner is the existing
runStartupSessionMigrationpath. The missing edge was not a specific tool failure: the four affected transcripts ended after different tool results, but all four missed the terminal assistant/lifecycle event that normally persists a terminal status. The precise process termination trigger remains unknown.Implementation
status=running, a finitestartedAtolder than the current process boundary, no restart-recovery claim, and no current run-registry owner.status=interrupted,abortedLastRun=true, and the interruption reason without fabricatingendedAt,runtimeMs, or activity.interrupteddistinct in canonicalentry_json; project it through the existing failed SQLite and gateway-wire buckets so this repair does not expand the database or public protocol schema.User Impact
Stale subagent rows stop appearing live after a gateway replacement. Healthy completed sessions remain unchanged, and current-process runs are never terminalized by startup reconciliation.
Evidence
stopReason=stopand persisteddone,endedAt, andruntimeMs.BUSY; the age-awareSTRANDEDprobe fix is already onorigin/main, so this PR will not modify the probe.NOT_MEASURED; this patch does not assert that a restart killed the runs.Boundaries
Diff Estimate / Hard Ceiling
420 changed lines total (
git diff --numstat: insertions plus deletions), across at most 12 files. If implementation exceeds either limit, work stops for renewed scope rather than expanding this PR.Actual: 294 changed lines across 8 files (280 insertions, 14 deletions). Of those, 74 lines are tests and 220 are production changes. The positive production delta is the bounded durable-state edge plus its SQLite/gateway projections and two ownership checks; no schema migration, protocol expansion, probe change, restart-recovery refactor, or adjacent cleanup was added.
Validation Plan
interruptedwith its reason.donerow remains unchanged.Validation Results
runningandabortedLastRun=false.pnpm check:changed: passed, including production and core-test type checks, formatting, changed-file lint, import-cycle, database-first, schema-version, assertion-safety, dependency, boundary, and dead-export guards.pnpm tsgo:core: passed again after rebasing onto currentorigin/main.git diff --check: passed.The age-aware reachability classification (
STRANDED_AFTER_S) was already merged intoorigin/mainbefore this branch. This PR intentionally contains no probe work.Current-main CI fixture follow-up
Consumed Vincent Koc’s canonical auth-fixture correction in #149004 through the verified current-main test merge. The remaining thinking-route fixture omitted the runtime auth-store reader; commit e6fa9fa supplies the same existing fixture store without changing production behavior or assertions.
529c969351c51a39a82fc325bc5af54e1b13e9b3exactly matches that qualified source tree.Landed Canonical Fix Integration
Signed head
480610e3af00e3341e9fcb47308230412c46f0a0merges mained264cc3ca59b51648a366d7ed86df9e58c76390while preserving contributor and canonical authorship/ancestry. Exact first-run UI and registry bytes match the separately qualified landed #149023/#149016/#149038 fixes; no duplicate repair was made. The thinking fixture is already on main.All 18 startup files remain byte-identical to the reviewed candidate. The combined tree
6e92b5dd22ecc97a2fa1ec9610214af04e01ac27passed the affected startup-race and readonly test shards, signature verification and diff checks. The packaged/updater/backup-rollback proof remains retained at its original inputs, with no replay. Required packed hosted CI for this head remains the next landing gate.ClawSweeper revision6 explicitly found no correctness/security issues and accepted the recorded updater/restore evidence. Its remaining duplicated compatibility checklist is addressed by the proof and supported backup-based rollback contract above; no promise of direct old-reader compatibility is made.