Skip to content

fix: resume running channel threads after graceful restarts - #188402

Merged
steipete merged 4 commits into
mainfrom
codex/channel-thread-restart-resume
Oct 30, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/channel-thread-restart-resume

Conversation

@steipete

@steipete steipete commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes missing restart continuations for running main and channel-thread conversations when shutdown closes agent databases before marker persistence, session writes take more than one second, or sessions_send ancestry redirects an ordinary conversation to an excluded session.

User Impact

Running conversations in non-default agents retain their own restart continuation and recorded reply route. Shutdown reports per-agent marked/skipped counts; startup reports resumed/skipped counts as each physical store becomes ready.

Crashes and SIGKILL without a completed marker remain intentionally lossy. A blocked writer can still exhaust the lifecycle deadline, which is now reported. Embedded shutdown callers without a process cleanup budget retain their existing one-second fallback. Cron and externally owned sessions keep their existing exclusions. No configuration, schema, dependency, or migration changes.

Why This Change Was Made

Only actual subagent keys should traverse requester ancestry: ordinary main and thread sessions own their own resume, even if previously targeted by sessions_send. Marker persistence now shares the lifecycle owner's absolute shutdown deadline. Admission fences synchronously; the lifecycle starts its cleanup prelude and releases database retention only after marker persistence settles or reaches that deadline. Idle executors follow this cleanup phase instead of the earlier drain signal. The session replacement owner resolves and writes each selector without an upfront discovery pass over every store; shared stores can receive one commit per logical selector.

The existing session-event owner still consumes markers, checks current authority, carries the recorded channel/account/recipient/thread, and preserves queued-input order. The legacy upgrade bridge remains intact. Production +74 LOC (including outcome logging), tests net zero LOC, docs +3 LOC.

Evidence

  • Red on base bffe87c77f90495888101edc0e019a01645a668a: the real-Gateway SIGTERM case with a 1.4-second session writer hold exited with Shutdown session persistence did not settle within 1000ms; the non-default thread marker was absent. The owner regression also lost non-default ordinary-session markers through a cron requester.
  • Original implementation proof: 11 focused unit cases and both real-process restart cases. Delayed-writer SIGTERM persisted markers in 1562ms and shut down in 2137ms; managed restart shut down in 656ms. Checks include exactly one resume input, idle sessions staying idle, queued-input ordering, child settlement, shared/separate stores, repeated graceful stops, and SIGKILL followed by a fresh input.
  • Targeted core, gateway-server, gateway-root, and root-test typechecks; core and root-test lint; formatting and git diff --check: pass.
  • Local Codex autoreview of the complete production change and test fixture changes against the base above: no actionable P0–P2 findings. That review covered the original implementation; the ordering repair has a fresh review recorded below.

The process tests use an isolated real Gateway/agent with a synthetic provider and thread session keys. Slack service delivery was not exercised; reply routing reuses the unchanged recorded-delivery-context path. No live Gateway or real user state was accessed.

Bun CI repair — 34d66bd

The original checks-node-changed-4 failure occurred in the fixture's BEGIN IMMEDIATE, before SIGTERM. Its external fault-injection connection used the native zero busy timeout and could race an active Gateway writer. The one-line repair sets a bounded native busy timeout before acquisition. The 1.4-second hold still starts after acquisition; marker, exactly-once, FIFO, and shutdown assertions are unchanged. No sleeps, JavaScript retries, production changes, or test-line growth were added.

The targeted old-head Bun run passed locally, confirming the failure is intermittent rather than claiming a passing replay proves a repair. A controlled held-writer probe reproduced the zero-timeout acquisition failure on both pinned Bun and Node, and verified successful acquisition after the existing writer released with the bounded policy. The unmodified main Bun case passed at 66004e076d4dcfb7e6d1ff14c1a894a03f475908 after preparing that checkout's frozen dependencies; the PR install was then restored from its own frozen lockfile.

At 34d66bd8b8e0, the repaired process suite and both requested owner suites passed 13/13 cases under Bun and 13/13 under Node, each with nice -n 5 and --maxWorkers=1:

OPENCLAW_VITEST_RUNTIME=bun nice -n 5 node scripts/run-vitest.mjs test/gateway-restart-resume.e2e.test.ts src/gateway/session-restart-resume.test.ts src/gateway/server-close.cleanup-scope.test.ts --maxWorkers=1
OPENCLAW_VITEST_RUNTIME=node nice -n 5 node scripts/run-vitest.mjs test/gateway-restart-resume.e2e.test.ts src/gateway/session-restart-resume.test.ts src/gateway/server-close.cleanup-scope.test.ts --maxWorkers=1

Targeted lint, formatting, git diff --check, and fresh isolated autoreview through P2 pass. The original PostgreSQL conformance failure is proven inherited, with a matching main CI signature and an already-landed config-owner repair. Exact-head CI run 41077232850 completed SUCCESS for 34d66bd8b8e014e79bceb822b495a4d9b31e7df2. Both reported required openclaw/ci-gate entries are SUCCESS. The bounded watcher used a 600-second polling interval. No CI rerun or further push was needed.

Shutdown ordering repair — 1fb7145

The coordinator supplied a second Team journal from 2026-10-30, release 5ed4aa23 without this PR:

15:24:42.447 shutdown budget: drain=74968ms shutdown=84968ms (systemd TimeoutStopUSec=90000ms)
15:24:42.462 [state/agent-db] agent database clean-close receipt: checkpoint-incomplete; agent=roboclaw
15:24:43.504 shutdown step restart.close.session-abort settled after 1035ms
15:24:54.318 shutdown step failed (gateway close): Shutdown session persistence did not settle within 1000ms

The affected agent database was 50 GB. Five running sessions were killed; no restart markers or resume inputs appeared, and the process exited with status 1.

Source tracing found an additional early-close trigger before the prelude: run-loop.ts:721 signaled shutdown cleanup before server close. gateway-work-admission.ts:298 aborts the cleanup signal; the agent database lifecycle queues an idle native close (openclaw-agent-db-lifecycle.ts:223–265), which checkpoints, closes, and releases its lease (openclaw-agent-db-close.ts:36–80). The receipt is emitted after that close. Idle executors separately retired on the earlier restart-drain signal.

The prelude does not directly call the agent database close owner, but it starts cleanup that can settle final speech (talk/session-registry.ts:148–167) and cancels scheduler/model/account owners. Both the prelude and database cleanup now start from the existing run-shutdown callback after marker persistence settles or reaches its lifecycle deadline, before received work is cancelled. Request and channel admission still fence synchronously before persistence. Idle executors use this same cleanup signal, preserving their existing bounded pool through persistence. No new protocol, option, schema, or retry was added.

The existing process case now reads the isolated file log, including worker close receipts, and requires the marker summary before the first clean-close receipt. Existing physical-marker, exactly-once resume, queue ordering, and shutdown assertions remain. Both Bun and Node fail this regression on prior PR head 34d66bd8b8e014e79bceb822b495a4d9b31e7df2 for an actual pre-marker clean close during managed SIGTERM. Console-only diagnostic attempts did not expose worker receipts and are not counted as red proof.

Prior ordering proof on 1fb7145ebfbf7a07acfce0f9017c2199937731f5: 45/45 cases pass under Bun and 45/45 under Node. This includes both requested owner suites, both real-process cases, idle executor retention, worker-store persistence/cleanup, and Gateway catalog/workspace/OAuth cleanup. The process suite took 78.7 seconds under Bun (84.5 seconds Vitest wall time) and 133.0 seconds under Node (143.0 seconds wall time). Whole wrapper runs took 895.7 seconds and 342.7 seconds respectively; Bun included a fresh Gateway build. The existing process suite needs real process stops and restarts to exercise this lifecycle boundary; no process, timer, or size budget was raised.

OPENCLAW_VITEST_RUNTIME=bun nice -n 5 node scripts/run-vitest.mjs test/gateway-restart-resume.e2e.test.ts src/gateway/session-restart-resume.test.ts src/gateway/server-close.cleanup-scope.test.ts src/state/openclaw-agent-execution.idle.test.ts src/state/openclaw-agent-worker-store.test.ts src/gateway/server-lifecycle.catalog-write.test.ts --maxWorkers=1
OPENCLAW_VITEST_RUNTIME=node nice -n 5 node scripts/run-vitest.mjs test/gateway-restart-resume.e2e.test.ts src/gateway/session-restart-resume.test.ts src/gateway/server-close.cleanup-scope.test.ts src/state/openclaw-agent-execution.idle.test.ts src/state/openclaw-agent-worker-store.test.ts src/gateway/server-lifecycle.catalog-write.test.ts --maxWorkers=1

Delayed-writer SIGTERM persisted markers in 1456.4ms / 1557.8ms and exited in 1892ms / 2002ms (Bun / Node). Managed restart persisted markers before clean-close receipts and exited in 1181ms / 665ms. Targeted source/test lint, formatting, core typecheck, git diff --check, and fresh isolated Codex autoreview through P2 all pass. This repair changes six files with 47 additions and 52 deletions: production −4 LOC, tests −1 LOC. The complete PR is 13 files, 418 additions and 342 deletions: production +74, tests −1, docs +3.

CI run 41087819764 completed FAILURE with three attributable jobs, repaired below. No CI rerun was issued. The repair was committed once and pushed once; no merge, deployment, live-state access, dependency change, or budget increase was performed.

Ordering CI repair — ec720b1

Run 41087819764 failed checks-node-changed-compact-small-15 (two kernel close cases), checks-node-changed-compact-large-15 (managed SIGTERM lease case), and checks-node-changed-compact-large-23 (rewind close case). All four cases reproduced locally at the prior head. These failures are attributable to this PR; none is classified inherited.

The lifecycle now aborts the scheduler and invalidates cron reconciliation synchronously with request admission. Database/resource cleanup still starts only after marker persistence settles or exhausts the lifecycle deadline, but uses the existing subagent-termination callback before run claims are released. The public-close fixture waits for the actual reload-stop event rather than one event-loop turn. The managed SIGTERM fixture settles the membership projection created by its setup before stopping; that existing read was retaining the native handle. Its empty-leases assertion remains before the blocked sidecar settles. The same test now runs on macOS and Linux. No sleeps, polling retries, SQLite error masking, or weakened assertions were added.

Current local proof on ec720b1303066184c20726681e665dc4d5dbcc56: 59/59 cases pass under Bun and 59/59 under Node, including all three previously failing suites and both real-process restart cases:

OPENCLAW_VITEST_RUNTIME=bun nice -n 5 node scripts/run-vitest.mjs test/gateway-restart-resume.e2e.test.ts src/gateway/session-restart-resume.test.ts src/gateway/server-close.cleanup-scope.test.ts src/state/openclaw-agent-execution.idle.test.ts src/state/openclaw-agent-worker-store.test.ts src/gateway/server-lifecycle.catalog-write.test.ts src/gateway/server-kernel.test.ts src/gateway/server-close.session-rewind.test.ts src/gateway/server-close.agent-databases.test.ts --maxWorkers=1
OPENCLAW_VITEST_RUNTIME=node nice -n 5 node scripts/run-vitest.mjs test/gateway-restart-resume.e2e.test.ts src/gateway/session-restart-resume.test.ts src/gateway/server-close.cleanup-scope.test.ts src/state/openclaw-agent-execution.idle.test.ts src/state/openclaw-agent-worker-store.test.ts src/gateway/server-lifecycle.catalog-write.test.ts src/gateway/server-kernel.test.ts src/gateway/server-close.session-rewind.test.ts src/gateway/server-close.agent-databases.test.ts --maxWorkers=1

The delayed-writer SIGTERM marker/exit times were 1536.5ms/1936ms under Bun and 1476.0ms/1888ms under Node. Managed marker/exit times were 36.3ms/512ms and 41.1ms/454ms. The process suite took 65.20s under Bun and 96.85s under Node (Vitest wall time); wrapper totals were 518.81s including a rebuild, and 282.30s. Core typecheck, targeted source/test lint, formatting, git diff --check, and fresh isolated Codex autoreview through P2 pass. The repair is one new commit and one push. Complete PR: 15 files, 433 additions and 356 deletions; production 284+/210− (net +74), tests 146+/146− (net zero), docs +3. No caps, baselines, or budgets changed.

Exact-head CI run 41094977806 completed SUCCESS for ec720b1303066184c20726681e665dc4d5dbcc56. Both required openclaw/ci-gate entries are SUCCESS: the CI workflow gate and the status gate in run 41097856777. No failed jobs remain on this head. The watcher polled at 600-second intervals and exited green; no CI rerun, further push, or merge was issued. The PR remains open, ready, and mergeable for coordinator review.

Keep ordinary main and channel-thread sessions in their own agent when
recording restart work, including sessions previously targeted by
sessions_send. Only actual subagent keys traverse requester ancestry.

Use the lifecycle shutdown deadline for marker writes and remove the
upfront store-discovery pass. Report per-agent marker/resume outcomes and
skip reasons so an incomplete snapshot is visible.

Prove the lost-marker failures on the base with a real SIGTERM writer
stall and a non-default main/thread session pointing to a cron requester.
Preserve existing marker consumption, queued-input ordering, delivery
context, and the legacy upgrade bridge. No persisted shape changes.
@clawsweeper

clawsweeper Bot commented Oct 30, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-30T17:02:52.830648Z
We couldn’t complete this review. Comment @codex review to try again.
ec720b1 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 30, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR preserves ordinary conversations as their own restart targets, gives marker writes the process shutdown budget, and logs recovery outcomes.

Example: Restart while agent:other:main:thread:123.456 is running and its session database writer is held for 1.4 seconds.

  • Before: The one-second persistence timeout can leave the conversation without a restart marker.
  • After: Marker persistence can finish within the lifecycle deadline, allowing the conversation to receive its normal continuation.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful owner-level production repair with focused reported process proof, held back by an observed fault-fixture failure.
Proof confidence 🐚 platinum hermit (4/6) The ordinary contributor proof gate is exempt for this maintainer-authored PR; supplied evidence describes isolated real-Gateway delayed-writer restart runs, with synthetic model responses and no claim of Slack delivery.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Running main and channel-thread conversations can remain inactive after a graceful restart.
Reason: The maintainer-authored direction restores the documented restart contract using existing session, database, and lifecycle owners.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR addresses source-confirmed restart failures and merits keeping open, but the shared-store fault fixture needs a focused repair before merge.

Priority: P1
Reviewed head: ee76bc98b3149ad3aba02a9ab8b0584a83538728

Before merge

  • Wait for the live writer before acquiring the fixture lock (P2) - The new SIGTERM branch opens the actively used shared session database with a default DatabaseSync connection and immediately executes BEGIN IMMEDIATE. When the Gateway already holds a write transaction, lock acquisition throws before SIGTERM is sent, so the regression never exercises delayed marker persistence. The exact-head check reports database is locked at line 533: https://github.com/openclaw/openclaw/actions/runs/41068599197/job/124107316675. Configure a bounded SQLite busy wait on this fixture connection before acquiring the lock, then send SIGTERM only after acquisition succeeds.

Findings

  • [P2] Wait for the live writer before acquiring the fixture lock — test/gateway-restart-resume.e2e.test.ts:527-531
Agent review details

How this fits together

Gateway shutdown captures live session work into existing SQLite session markers; startup consumes those markers through ordinary session-event admission and queued-input recovery.

flowchart TD
  A[Live conversation work] --> B[Resolve root conversation]
  B --> C[Persist restart marker]
  C --> D[Process shutdown deadline]
  C --> E[Startup recovery]
  E --> F[Current session authority]
  F --> G[Resume input and queued messages]
Loading

Technical review

Best possible solution:

Keep the existing recovery owners and production fix, and make the fault fixture acquire its SQLite lock with a bounded wait before signaling shutdown.

Do we have a high-confidence way to reproduce the issue?

Current-main source exposes both lost-marker paths, and the PR records baseline failures; this read-only review ran no target code.

Is this the best way to solve the issue?

Restricting ancestry traversal and reusing the lifecycle deadline fixes the responsible owners without adding recovery machinery; the test lock acquisition needs correction.

Full review comments:

  • [P2] Wait for the live writer before acquiring the fixture lock — test/gateway-restart-resume.e2e.test.ts:527-531
    The new SIGTERM branch opens the actively used shared session database with a default DatabaseSync connection and immediately executes BEGIN IMMEDIATE. When the Gateway already holds a write transaction, lock acquisition throws before SIGTERM is sent, so the regression never exercises delayed marker persistence. The exact-head check reports database is locked at line 533: https://github.com/openclaw/openclaw/actions/runs/41068599197/job/124107316675. Configure a bounded SQLite busy wait on this fixture connection before acquiring the lock, then send SIGTERM only after acquisition succeeds.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 63dbee6a5145.

Provenance checked

  • Requester ancestry keeps the original intent (9344233: The restart redesign follows root requesters so running subagents do not resume independently.)
  • Marker persistence deadline changes intended behavior with a stated reason (9344233: The redesign bounded marker persistence before promptly cancelling active work; this PR documents why the fixed one-second allowance loses markers under writer contention.)
  • Physical-store batching changes intended behavior with a stated reason (9344233: The redesign grouped markers into one write per physical store; this PR explicitly accepts per-selector commits to avoid an upfront discovery pass delaying all writes.)
  • Startup marker consumption keeps the original intent (9bf3231: Recovery shares the database startup owner, waits for preparation, and preserves current-authority and queued-input admission.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test:e2e:gateway test/gateway-restart-resume.e2e.test.ts --maxWorkers=1
  • Verify lock acquisition waits for an existing writer before SIGTERM and retains the delayed-marker assertions.
  • git diff --check

What I checked:

PR surface

Source +78, Tests 0, Docs +3. Total +81 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 264 186 +78
Tests 3 104 104 0
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 371 290 +81

Review metrics

Metric Value Why it matters
Production versus test growth Production +78 LOC; tests net 0 LOC Growth supports marker outcome reporting and lifecycle deadline handling while removing duplicate store discovery; existing regression suites are extended.

Labels

Label changes:

  • add P1: The underlying bug prevents running conversations from continuing after ordinary graceful restarts.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: The underlying bug prevents running conversations from continuing after ordinary graceful restarts.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 30, 2026, 10:20 AM ET / 14:20 UTC.

@steipete

Copy link
Copy Markdown
Contributor Author

The original PostgreSQL conformance (2/3) failure is inherited from main, independently of the restart fixture failure being repaired here.

Matching main evidence: run 41063477930 / job 124089262163, head f80ab2ad1c1a0d01ce5a73c39959c27daf425248. Its check annotations name the same archive-restore.postgres.test.ts case (publishing recovered PostgreSQL/SQLite selection from a captured config alias) and the same ConfigMutationConflictError: included config target changed since last load, with the matching write-safety → snapshot → backup-shared → backup-create stack and retryable: false.

Main already contains 34a4e118dc1d, which explicitly records reproduction of this case on main and passing proof for all four PostgreSQL archive-restore cases. It repairs resolved config-alias reads while preserving the guarded publication path. This PR does not change those config/backup owners. No PostgreSQL retry or unrelated repair is being added here.

Give the external fault-injection connection bounded native busy handling
before BEGIN IMMEDIATE. Its zero default could race an active Gateway
write and fail before SIGTERM, preventing the intended shutdown fault.

Keep the 1.4-second hold after acquisition and all marker, exactly-once,
FIFO, and shutdown assertions unchanged. Bun and Node each pass all 13
requested cases; the stock main Bun case also passes. No test-line growth.
Keep request and channel admission fenced while marker persistence owns
its lifecycle deadline. Start the close prelude and database cleanup from
the existing post-persistence run-shutdown callback instead of the CLI.
Idle agent executors now retire on cleanup rather than restart drain.

Extend the existing process proof to require marker persistence before
worker clean-close receipts. Preserve marker, exactly-once resume, queue
ordering, and deadline assertions; keep test lines net negative.
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Oct 30, 2026
@steipete
steipete merged commit e051130 into main Oct 30, 2026
140 of 141 checks passed
@steipete
steipete deleted the codex/channel-thread-restart-resume branch October 30, 2026 17:25
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…penclaw#188402)

On Team (2026-10-30 15:24Z stop) restart resume produced nothing: marker persistence hit a hard 1000 ms cutoff while the close prelude was already releasing agent databases (roboclaw clean-close began 15 ms in), so no session got resumeAfterRestart and five running sessions ended killed. Channel/thread and non-default-agent sessions were also lost because shutdown followed sessions_send requester ancestry into excluded cron roots.

Shutdown now fences admission (requests, scheduler, cron) immediately but starts database and plugin cleanup only after marker persistence settles; persistence is bounded by the lifecycle cleanup deadline instead of 1 s and failures are logged. Resume root resolution follows only subagent ancestry, so ordinary conversations keep their own marker. Shutdown and startup log per-agent marker outcomes. Crashes without committed markers remain lossy by design.
RomneyDa added a commit that referenced this pull request Nov 13, 2026
Backport the bounded marker-persistence deadline and regression from #188402 (e051130). Retain existing failure and cancellation semantics; broader shutdown ordering is not included.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
(cherry picked from commit 5e10588f32a38612bc354de8f69e0c76a7005ec3)
RomneyDa added a commit that referenced this pull request Nov 13, 2026
Backport the bounded cleanup-ordering slice of #188402 (e051130). Keep candidate admission, mention inbox, and observer fences immediate while postponing idle-store retirement until restart marker persistence settles.

Regression: idle stores previously retired at drain; now 15 owner/kernel/real queued-input restart tests pass, plus 162 CLI and state-ownership tests. Core and gateway test types, typed lint, and format pass.

Co-authored-by: RomneyDa <[email protected]>

Co-authored-by: vincentkoc <[email protected]>
(cherry picked from commit 7e916fe0e58347aaa279aa948465fa1ffd9ac8d0)
RomneyDa added a commit that referenced this pull request Nov 13, 2026
Complete the shutdown-phase fixture migration from #188402. Preserve blocked-writer settlement and physical lease assertions for all four ending paths.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
obviyus added a commit that referenced this pull request Nov 19, 2026
…ned children (#201970)

Problem: after a Gateway restart, OpenClaw stops running subagents and resumes only their ordinary root, which re-instructs its children. Root discovery walked up the ancestry only while the session key looked like a hidden subagent. A visible spawned child (a dashboard session from sessions_spawn visible:true) stopped the walk, its restart marker was rejected as a spawned child, and the real root was never marked. On a live Gateway a root chat -> visible coordinator -> hidden workers tree stalled after a restart until a human wrote.

Fix: follow recorded native spawn ownership (session spawnedBy, or createdVia spawn with parent/controller/requester fallback) up to the ordinary root, for visible and hidden native children, keeping the cycle guard, the recorded child-authority check and the session-incarnation match. sessions_send edges carry no spawn metadata and stay independent roots, which keeps the case #188402 protected. Selection snapshots live owners before the worker reads, keeps live-root-before-parked precedence, and stays inside the existing shutdown persistence budget.

User impact: a root whose work runs through a visible spawned coordinator or worker is resumed after a restart and can re-instruct its children, instead of stalling until someone writes.

Proof: new ancestry regression (hidden worker under a visible coordinator; visible worker under the root) red on unchanged main and green with the fix through a real shutdown marker and startup enqueue; 11 restart-resume and registry files (110 tests); tsgo, test types, type-aware oxlint, format and the line-cap ratchet; ocx build --dts plus a packed install smoke on the head.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…ned children (openclaw#201970)

Problem: after a Gateway restart, OpenClaw stops running subagents and resumes only their ordinary root, which re-instructs its children. Root discovery walked up the ancestry only while the session key looked like a hidden subagent. A visible spawned child (a dashboard session from sessions_spawn visible:true) stopped the walk, its restart marker was rejected as a spawned child, and the real root was never marked. On a live Gateway a root chat -> visible coordinator -> hidden workers tree stalled after a restart until a human wrote.

Fix: follow recorded native spawn ownership (session spawnedBy, or createdVia spawn with parent/controller/requester fallback) up to the ordinary root, for visible and hidden native children, keeping the cycle guard, the recorded child-authority check and the session-incarnation match. sessions_send edges carry no spawn metadata and stay independent roots, which keeps the case openclaw#188402 protected. Selection snapshots live owners before the worker reads, keeps live-root-before-parked precedence, and stays inside the existing shutdown persistence budget.

User impact: a root whose work runs through a visible spawned coordinator or worker is resumed after a restart and can re-instruct its children, instead of stalling until someone writes.

Proof: new ancestry regression (hidden worker under a visible coordinator; visible worker under the root) red on unchanged main and green with the fix through a real shutdown marker and startup enqueue; 11 restart-resume and registry files (110 tests); tsgo, test types, type-aware oxlint, format and the line-cap ratchet; ocx build --dts plus a packed install smoke on the head.

Co-authored-by: Ayaan Zaidi <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
…penclaw#188402)

On Team (2026-10-30 15:24Z stop) restart resume produced nothing: marker persistence hit a hard 1000 ms cutoff while the close prelude was already releasing agent databases (roboclaw clean-close began 15 ms in), so no session got resumeAfterRestart and five running sessions ended killed. Channel/thread and non-default-agent sessions were also lost because shutdown followed sessions_send requester ancestry into excluded cron roots.

Shutdown now fences admission (requests, scheduler, cron) immediately but starts database and plugin cleanup only after marker persistence settles; persistence is bounded by the lifecycle cleanup deadline instead of 1 s and failures are logged. Resume root resolution follows only subagent ancestry, so ordinary conversations keep their own marker. Shutdown and startup log per-agent marker outcomes. Crashes without committed markers remain lossy by design.

(cherry picked from commit e051130)

Private LOCAL11.8 preparation; canonical integration pending.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 6ddb173d0115eb412b00cfb688cd0f0c871f10dd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant