Repository navigation
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 October 5, 2026, 2:55 PM ET / 18:55 UTC (Revision 2). ClawSweeper reviewWhat this changesThe PR records restart-aborted child sessions as interrupted, aligns session events with that outcome, and repairs older ownerless restart markers during startup. Merge readiness⛔ Blocked before merge - 2 items remain Keep this intentionally held fallback open. Current main retains the restart-terminal writer defect, and the proposed replacement remains open and conflicted; no introduced correctness defect was identified. Priority: P2 Review scores
Verification
How this fits togetherGateway shutdown cancels unfinished agent runs, and lifecycle writers persist their session outcomes. Startup recovery and session projections consume those records to resume eligible work and display activity. flowchart TD
A[Restart drain expires] --> B[Cancel active runs]
B --> C[Session lifecycle writer]
C --> D{Eligible main session?}
D -->|Yes| E[Retain restart recovery]
D -->|No| F[Record interruption]
G[Older restart markers] --> F
F --> H[Session events and activity display]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +91, Tests +359, Docs +1. Total +451 across 6 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use the approved outcome-only cutover to give run liveness one owner while preserving recovery custody, retaining this narrow repair until that implementation lands. Do we have a high-confidence way to reproduce the issue? Yes: source establishes that restart cancellation persists running while child metadata excludes main-session recovery. The captured failing-before regression exercises shutdown and SQLite persistence; this read-only review did not rerun it. Is this the best way to solve the issue? Yes as a bounded fallback, though the approved outcome-only cutover is the better permanent solution because it removes competing durable liveness state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f0d34cbd05b8. 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 (1 earlier review cycle)
|
|
Holding this PR unmerged as a fallback. Peter approved the broader cutover this fix pointed at: persisted session |
|
Closing as superseded by #165733, which removes the persisted |
What Problem This Solves
Fixes child sessions that remain
status: "running"with no active run after a cut-short Gateway restart drain, including dashboard-created children.This narrow fix is superseded by #165733 (#165733), which makes persisted session status outcome-only and derives liveness from the run registry and queue. Keep this PR open until that cutover lands; the cutover removes the need for this narrower fix.
Solution
The lifecycle writer now records restart cancellation as the existing
interruptedstate for sessions excluded from main-session automatic resume. Session events carry the same state. Eligible main sessions keep their recovery cycle and can still resume and complete.Before readiness, the existing recovery scan also repairs an ownerless child's older restart-only marker through the session store writer. It preserves native subagent recovery, pending delivery, live execution, and session admission owners, rechecking ownership at commit. The repair is idempotent and retains the recorded interruption timestamp. No schema, sidecar, configuration, or protocol changes.
User Impact
Affected child sessions stop showing an indefinite Working badge in the sidebar and Workboard. Restart recovery and parent-owned continuation remain available. Existing affected rows are repaired on startup when their saved restart marker and lack of another owner establish that repair is safe.
Why This Change Was Made
Restart cancellation previously kept every session
runningto preserve main-session recovery. However, that recovery excludes children byspawnDepth/subagentRole, while the separate startup orphan repair recognizes:subagent:keys. A dashboard child can therefore be excluded by both owners and remain running indefinitely.The local regression proves this dashboard-child path. The supplied Team evidence does not include the affected rows' child/recovery metadata, so it does not establish that every reported Team row has this exact cause. Pending eligible main-session recovery is deliberately preserved.
Evidence
Supplied Team evidence (read-only, 2026-10-04)
Journal:
Ninety minutes later
sessions.liststill reported, for severalagent:roboclaw:dashboard:…sessions:status: "running", hasActiveRun: false,updatedAt: 2026-10-04T20:28:24Z(five rows share that second), last activity hours earlier. Nothing is running for them (no live run in the registry), yet every surface that reads the persisted status (sidebar "Working" badge, Workboard) shows them as running. The run registry is right; the persisted session status is stale.Regression
The test starts registered runs through lifecycle events, invokes the real
prepareGatewayRunShutdownwith an exhausted drain budget, observesOPENCLAW_RESTART_ABORT, and persists the real Gateway lifecycle handler's events to SQLite. It checks the row immediately and after the startup recovery boundary, includinghasActiveRun: false. It also proves main-session recovery admission and successful completion, startup idempotency, retained native ownership, and execution/admission acquisition before commit. This is an isolated owner-boundary test, not a live Team restart or a full Gateway process reboot.Failing-before output on the original production code:
The initial cold run included 43.14 seconds compiling the worker generation. The final fixture shares one SQLite state owner across its cases; it adds no real sleeps, polling, per-test Gateway boots, or worker pins.
Local proof
pnpm install --frozen-lockfile: passed, 27.9 s.node scripts/run-vitest.mjs src/gateway/server-run-shutdown.recovery.test.ts --maxWorkers=1: 5 passed, 100.46 s wall; individual test bodies totaled 15.44 s. This exceeds the 5 s target because the shutdown-to-SQLite case initializes the real runtime/store and proves persistence across recovery ownership; mocking those writers would omit the defect. The three commit-ownership cases took 0.204 s total. No case uses a real sleep or polling.Gateway lifecycle persistence, recovery projection, and event payload siblings plus recovery marking: 93 passed across six files in 316.97 s. After the final admission guard and fixture changes, the new regression and recovery-marking sibling were rerun: 16 passed in 187.11 s. Unchanged lifecycle proof was reused.
pnpm tsgo:core: passed, 5.84 s.pnpm tsgo:core:test: passed all shards, 436.38 s. The first attempt found two newly authored fixture literals widened toboolean; explicit session-entry types fixed them.oxfmt --checkon all six changed files: passed.oxlintthroughscripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.jsonon all five TypeScript files: passed, 450.76 s including waiting for generated SDK artifacts.pnpm check:deprecated-api-usage: passed, 72.30 s.pnpm check:madge-import-cycles: 0 cycles, 100.05 s; subsequent changes added no dependency edges.SQLite worker, line-cap, and max-lines ratchets: passed.
git diff --check: passed.pnpm changed:lanes --json:core,coreTests,docs; no UI, extension, or live-service lane.git merge-tree --write-tree origin/main HEAD: clean (exit 0).Pre-commit direct Codex review and the requested committed-branch direct Codex review: scoped-clean, no accepted/actionable P0/P1 findings.
Reviewed head:
d1f85931f1994e05b940290d3b10731b237987af.Branch autoreview status:
{ "schema_version": 1, "status": "scoped-clean", "exit_code": 0, "engine": "codex", "report_produced": true, "reason": null, "reviewer_exit_code": null, "timed_out": false }CI seconds are not yet available; CI has not been dispatched manually. No live Team state was changed.