Skip to content

fix(gateway): pause restart recovery while the crash-loop breaker is tripped - #166238

Merged
steipete merged 8 commits into
mainfrom
steipete/restart-crashloop-pause-20261006
Oct 7, 2026
Merged

steipete merged 8 commits into
mainfrom
steipete/restart-crashloop-pause-20261006

Conversation

@steipete

@steipete steipete commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Restart recovery could replay a crashing interrupted turn while the Gateway crash-loop breaker was tripped. This supersedes #160434. Interrupted sessions now remain quarantined without charging an attempt, sending a notice, settling, or tombstoning them. The existing generation-owned scheduler re-arms once the breaker's full window clears in the same healthy process. Another crash extends the pause; shutdown or lifecycle replacement cancels recovery.

Existing manual channel stops and channel/provider skip flags remain effective. There are no new config options, schema changes, persisted shapes, or migration requirements. Thanks to @masatohoshino (Masato Hoshino) for the original containment proposal; his co-author credit is preserved.

Recovery ownership follow-up

The channel manager already knows whether this boot suppressed autostart. Recovery now consumes that prepared fact instead of independently inspecting the breaker database on every startup or exact-target call. Healthy preparation completes synchronously. Suppressed preparation returns the breaker's deadline through its existing owner, inside startup's root-work admission, then releases admission before the scheduler's unref'd wait.

The Gateway scheduler owns cancellation of the shared breaker read. Individual callers can cancel their waits without aborting another caller's shared transition. Close prevents new reads and channel starts. A committed boot identity is retained when close overtakes the worker reply, so shutdown records the correct boot. The duplicate recovery wrapper and direct agent-side breaker reads are removed.

Using the requested non-test/non-doc filter, the full PR is currently +482/-223 (+259 LOC); this follow-up is +134/-111 (+23 LOC). Growth implements the required in-process deadline, cancellation, and committed boot handoff contracts. The existing synchronous runtime transition and duplicated suppression predicates are removed.

Pinned head-versus-base comparison

Provider blacksmith-testbox, profile openclaw-check, lease tbx_01m4a70n3yjvszkmdj12jwbsqv; Node 24.19.0, pnpm 12.5.1. Separate immutable remote worktrees tested original head 67e2c63ca9d053c2726d76ac7872716d85e55d79 and merge base d1b89023368ed6d76788e38fc33276d39f562c21. Each file ran three times with node scripts/run-vitest.mjs <file> --maxWorkers=1.

Test file Head passes Base passes Head wall seconds Base wall seconds
src/worker/worker.chat-abort.test.ts 0/3 0/3 77, 59, 38 93, 35, 45
src/agents/harness/gateway-question.authority-worker.test.ts 3/3 3/3 41, 29, 27 32, 29, 29
src/gateway/server-methods/chat-send-global-identity.test.ts 0/3 0/3 56, 41, 44 53, 43, 43
src/gateway/server.chat-queued-followup.test.ts 0/3 0/3 36, 23, 20 37, 21, 22
src/gateway/server.chat.gateway-server-chat-b.test.ts 0/3 0/3 98, 91, 104 93, 89, 87

The comparison completed in 26m13s. The collector exited 0 while preserving each failing test exit; the table is not a passing test claim. Worker cancellation timeouts, closed agent-DB admission, and chat-B paging failures reproduce on the pinned base. Global identity's exact config store changes after ACK case fails all six runs. Other fence/chat case occurrences vary; no individual case failed all three head runs while passing all three base runs. Those case-specific differences remain a limit of attribution. The question-authority lock did not reproduce in the initial six runs. It later reproduced in the candidate’s prepared-cancel case. Three further base-only runs with --maxWorkers=4 produced pass/fail/pass (51, 42, 40 seconds); the failing caller case hits the same revokePolicy statement at line 229 with SQLite errcode 5. The contention therefore exists on the pre-PR base, although the parameterized case varies.

A temporary call trace on the original head observed four async breaker inspections during the three Gateway files, and zero during worker-abort/question-authority. The candidate reruns still reproduced these failure families: the final five-file replay had 26 failed and 104 passed tests. Removing the unnecessary reads is not presented as a fix for all baseline failures.

Evidence

All commands ran on blacksmith-testbox, profile openclaw-check, through the installed Crabbox CLI. Raw synchronization timed out twice; the supported repository source-capsule wrapper resolved synchronization while verifying the pinned source and changed-file hashes. No tests, typechecks, or builds ran on the Mac.

Lease tbx_01m4ae4d1cwkk9as8g9sa72nw7:

  • node scripts/run-vitest.mjs src/agents/main-session-recovery src/gateway/server-channels.test.ts src/infra/gateway-boot-lifecycle.test.ts src/cli/gateway-cli/crash-loop-recovery.test.ts --maxWorkers=4: 443 passed across 18 files, 221.18 seconds in the test runner (4m32.6s remote command).
  • Runtime/startup/health-monitor/CLI sibling files: 221 passed across six files, 66.88 seconds in the test runner.
  • After simplifying startup input forwarding, startup and recovery-admission files: 99 passed. The production startup module shrinks rather than increasing its line-cap baseline.
  • Replacing the recovery runtime with the original 67e2c63 version makes both healthy and closed exact-target cases fail because each performs one forbidden breaker inspection. The candidate performs zero.
  • Reverting the shared-cancellation and committed-result fixes makes their two lifecycle regressions fail for the intended reasons. Both pass with the candidate.
  • The real-worker quarantine fixture passes its virtual clock through the writer's existing nowMs input; the production writer continues to use its own clock. This fixes the fixture's scheduler/worker clock mismatch without stubbing a recovery decision or result.

Lease tbx_01m4ah48dg29rxfaz5v2qpa3ne:

  • node scripts/run-vitest.mjs src/gateway/server-plugin-reload.recovery.test.ts --maxWorkers=4: 94 passed, 42.65 seconds in the test runner.
  • node scripts/check-changed.mjs: exit 1 on seven full-tree unused exports in src/agents/auth-profiles.runtime.ts after every typecheck passed (26m30s remote command). Running the identical dead-export scanner on pinned base d1b8902 reproduces the exact seven findings. No skip flag or baseline exception was used. All later commands from the canonical changed-check plan were then run separately and passed, including lint, storage/schema guards, and zero runtime import cycles. Earlier owned line-cap, fixture-type, and test-variable lint findings were fixed without exceptions.

Lease tbx_01m4amhrttndqxvcdjxsag34c9: pnpm build passed in 3m30.5s (4m50.4s remote command), including the public SDK and Control UI build checks. All task leases are stopped.

Fresh detached Codex autoreview of the exact staged follow-up: scoped-clean, P0–P2. The committed tree matches the validated source tree.

Exact-head CI and remaining failures

Follow-up head: cccf0f1ae59ecc595973b9a5b543ec3b46135173. CI run 37589892669 completed with 65 successful, 22 skipped, and 3 failed jobs. CI is not green. Eight additional pull-request workflows, including CodeQL and Build Artifacts, passed. No CI rerun or extra push was used to seek green.

Failed job Failure Evidence / attribution
checks-node-changed-1 x-publication-owner-composition.e2e.test.ts: commits and anonymously reads maintainer work; denies guest and revoked creation, 404 instead of 200 at line 544 Pre-existing: the exact failure reproduced on pinned base d1b8902 using the real CI runShardPlans target launcher and OPENCLAW_E2E_USE_PREBUILT_DIST=1.
checks-node-changed-compact-large-2-2 chat-metadata-session-writes.test.ts: metadata read across sibling cache replacement with exact cache, database is locked Unresolved attribution: three complete-file runs passed on each revision; the original 17-file CI group also passed all 298 tests on the pinned base. Passing replays do not prove a fix or inheritance.
openclaw/ci-gate Aggregate failure Follows the two test jobs above.

Final attribution proof used blacksmith-testbox lease tbx_01m4apheb98jrxyv7p17ghe4s7, with separate immutable checkouts of published head cccf0f1 and base d1b8902:

Complete-file replay (node scripts/run-vitest.mjs <file> --maxWorkers=1) Head passes Base passes
src/gateway/server-methods/chat-metadata-session-writes.test.ts 3/3 3/3
src/gateway/x-publication-owner-composition.e2e.test.ts 3/3 3/3

The standalone X runs did not reproduce CI. Switching to CI's actual launcher and prebuilt-runtime setting reproduced the exact 404/200 assertion on the base; the head passed that single launcher replay. This is evidence that the failure predates the PR, not a claim that the passing head replay fixed it. The metadata group replay used the original configs, include patterns, and worker override from the failed CI job.

All task leases are stopped. The working tree is clean, the PR remains open, and auto-merge is disabled. The lead owns landing. The metadata lock and pre-existing unused-export gate remain explicit gaps.

…tripped

Quarantine interrupted main-session turns while the crash-loop window is
active, preserving their entries and retry budget. Re-arm the existing
recovery scheduler in the same healthy process when the window drains,
with the original cutoff and lifecycle ownership.

Reuse the breaker owner and rotate the boot segment before replay. Run
runtime state access in workers and preserve manual channel stops and
environment suppression during recovery.

Supersedes #160434.

Co-authored-by: Masato Hoshino <[email protected]>
@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 docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes scripts Repository scripts agents Agent runtime and tooling size: XL labels Oct 6, 2026
@steipete
steipete marked this pull request as ready for review October 6, 2026 18:19
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: cccf0f1ae59ecc595973b9a5b543ec3b46135173
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-secrets-reload.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/gateway/server-startup-secret-surfaces.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper

clawsweeper Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 7, 2026, 5:31 AM ET / 09:31 UTC (Revision 10).

ClawSweeper review

What this changes

The PR pauses interrupted-session recovery during crash-loop safe mode, resumes it after the full breaker window clears, and moves runtime boot-history operations into database workers.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: current main still permits restart recovery during crash-loop safe mode, and this maintainer-owned candidate remains useful. No introduced correctness defect was found.

Likely related people: @steipete (high-confidence routing candidate) and @sjf-oa (medium-confidence routing candidate).

Priority: P0
Reviewed head: cccf0f1ae59ecc595973b9a5b543ec3b46135173

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation and focused validation are useful, but candidate-specific published-state lifecycle proof remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 12 items Pinned change ownership: Reviewed the introduced delta from d1b8902 to cccf0f1. Raw head parentage matches the supplied original-head record. The stale test merge was not used to infer removal of current-main behavior.
Current main still needs containment: Current main's startup recovery attempt proceeds to orphan marking and recovery without consulting channel autostart suppression or waiting for a breaker deadline.
Latest release check: The runtime source retrieved from v2026.9.8 likewise contains the unguarded recovery attempt and lacks the candidate's preparation/pause path. Local release-object inspection failed, so the release source was checked through GitHub.
Findings None None.
Security None None.

How this fits together

The Gateway uses persisted boot history to contain repeated crashes. Its restart-recovery scheduler consumes that decision before resuming interrupted agent work or restoring channel startup.

flowchart TD
  A[Persisted boot history] --> B[Crash-loop breaker owner]
  B --> C{Full window cleared?}
  C -->|No| D[Preserve interrupted work]
  D --> E[Cancelable scheduler wait]
  E --> B
  C -->|Yes| F[Record recovered boot]
  F --> G[Restore channels and resume work]
Loading

Before merge

  • Resolve merge risk (P1) - The candidate has not demonstrated preservation of published interrupted state during quarantine followed by exactly one automatic resumption in the same healthy process.
  • Complete next step (P2) - Provide candidate-specific published-driver upgrade evidence showing unchanged transcripts and counters during quarantine, followed by exactly one automatic resumption in the same healthy process.
Agent review details

Security

None.

PR surface

Source +248, Tests +514, Docs +9, Other +10. Total +781 across 64 files.

View PR surface stats
Area Files Added Removed Net
Source 27 469 221 +248
Tests 33 705 191 +514
Docs 2 10 1 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 2 11 1 +10
Total 64 1195 414 +781

Review metrics

Metric Value Why it matters
Production versus test growth production/tooling +259; tests/support +514 net lines Excluding docs and config baselines, production growth is justified by deadline scheduling, worker access, cancellation, and committed-boot handoff.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #144772
Summary: This candidate addresses crash-loop amplification; completed legacy-session eligibility remains distinct.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Validate published-state recovery (recommended)
    Supply a redacted published-driver upgrade transcript showing preserved transcripts and counters during quarantine, then one automatic same-process resumption through the candidate.

Technical review

Best possible solution:

Contain crashing replay without discarding interrupted work, with published-state upgrade evidence confirming one automatic resumption after the stable window.

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

Yes, source establishes that current main can dispatch interrupted work despite breaker-tripped channel suppression; the related contributor PR also records a real CLI crash/replay reproduction. No runtime was executed during this read-only review.

Is this the best way to solve the issue?

Yes, reusing the boot breaker, channel manager, and existing generation-owned scheduler is a focused repair; the candidate still needs the repository-required published-driver validation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5077ad4f99aa.

Labels

Label changes:

No label changes.

Label justifications:

  • P0: The underlying replay loop can repeatedly terminate the Gateway and disable every channel until manual recovery.
  • merge-risk: 🚨 compatibility: The changed recovery lifecycle consumes existing interrupted state, and candidate-specific published-state upgrade behavior remains unproven.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.

Evidence

What I checked:

  • Pinned change ownership: Reviewed the introduced delta from d1b8902 to cccf0f1. Raw head parentage matches the supplied original-head record. The stale test merge was not used to infer removal of current-main behavior. (cccf0f1ae59e)
  • Current main still needs containment: Current main's startup recovery attempt proceeds to orphan marking and recovery without consulting channel autostart suppression or waiting for a breaker deadline. (src/agents/main-session-recovery/main-session-restart-recovery-runtime.ts, 5077ad4f99aa)
  • Latest release check: The runtime source retrieved from v2026.9.8 likewise contains the unguarded recovery attempt and lacks the candidate's preparation/pause path. Local release-object inspection failed, so the release source was checked through GitHub. (src/agents/main-session-recovery/main-session-restart-recovery-runtime.ts, fc23bc864e45)
  • Single recovery owner and cancellation: The scheduler prepares recovery inside root-work admission, releases admission before its unreferenced deadline wait, and retains its original cutoff. Shared breaker work uses the Gateway signal; individual callers cancel only their waits. The CLI retains a committed recovered boot identity when shutdown overtakes the reply. (src/agents/main-session-recovery/main-session-restart-recovery-runtime.ts:307, cccf0f1ae59e)
  • Candidate coverage and remaining proof gap: The admission regression exercises real SQLite boot workers and production recovery owners for resume, further crash, stop, lifecycle replacement, and healthy startup. Agent dispatch remains mocked. The captured PR body reports successful focused Testbox validation, but supplies no published-driver upgrade transcript for this candidate's automatic same-process resumption. (src/agents/main-session-recovery/main-session-restart-recovery-admission.test.ts:131, cccf0f1ae59e)
  • Scoped upgrade requirement and review continuity: Root policy explicitly requires a published-driver × candidate cell for service-lifecycle changes. The prior completed review's published-state rank-up remains applicable. The maintainer author's ordinary contributor-proof exemption does not supply this stronger repository-required evidence. (AGENTS.md:70, cccf0f1ae59e)

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted published-driver upgrade output showing preserved transcripts and retry counters during quarantine, then exactly one automatic same-process resumption.

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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-06T20:36:20.211Z sha 07e1000 :: blocked before merge. :: none
  • reviewed 2026-10-07T00:35:54.897Z sha 4f9c2ba :: blocked before merge. :: none
  • reviewed 2026-10-07T00:46:24.297Z sha c0e8f72 :: blocked before merge. :: none
  • reviewed 2026-10-07T01:15:34.196Z sha e914dbd :: blocked before merge. :: [P2] Await canceled worker-read settlement in the shutdown regression
  • reviewed 2026-10-07T03:04:38.695Z sha 7c358d3 :: blocked before merge. :: none
  • reviewed 2026-10-07T03:32:09.170Z sha 67e2c63 :: blocked before merge. :: none
  • reviewed 2026-10-07T08:00:26.684Z sha cccf0f1 :: blocked before merge. :: none
  • reviewed 2026-10-07T09:20:44.123Z sha cccf0f1 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 7, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 7, 2026
The crash-loop check now reads breaker state through a worker before
startup recovery reaches Gateway root admission. Advancing fake timers
by zero does not wait for that I/O or its cancellation cleanup, so the
old immediate stopped flag assertion could fail without a shutdown hang.

Observe the real admission request through the existing call-through
helper, then await stop while suspension remains closed. Only reopen
admission after stop settles and retain the no-dispatch and unchanged
interrupted-entry assertions. This preserves the shutdown contract and
removes an incidental fake-clock ordering assumption; production
cancellation behavior does not change.
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 7, 2026
Use the channel manager's prepared boot suppression instead of inspecting
breaker storage on every startup or exact-target recovery call. Keep the
healthy path synchronous and admit startup before recovery preparation.

Return the owner's deadline to the existing scheduler. Let the Gateway
cancel shared recovery work while individual callers cancel only their
waits, and retain a committed boot identity if close overtakes its reply.

The integration fixture forwards its virtual clock through the writer's
existing time input because SQLite workers do not inherit fake timers.
@steipete
steipete merged commit 49c1815 into main Oct 7, 2026
161 of 167 checks passed
@steipete
steipete deleted the steipete/restart-crashloop-pause-20261006 branch October 7, 2026 09:38
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

RomneyDa pushed a commit that referenced this pull request Oct 7, 2026
…tripped (#166238)

* fix(gateway): pause restart recovery while the crash-loop breaker is tripped

Quarantine interrupted main-session turns while the crash-loop window is
active, preserving their entries and retry budget. Re-arm the existing
recovery scheduler in the same healthy process when the window drains,
with the original cutoff and lifecycle ownership.

Reuse the breaker owner and rotate the boot segment before replay. Run
runtime state access in workers and preserve manual channel stops and
environment suppression during recovery.

Supersedes #160434.

Co-authored-by: Masato Hoshino <[email protected]>

* fix(gateway): break the channel autostart recovery import cycle

* fix(gateway): type autostart recovery suppression by identity

* test(agents): await recovery admission before testing suspended stop

The crash-loop check now reads breaker state through a worker before
startup recovery reaches Gateway root admission. Advancing fake timers
by zero does not wait for that I/O or its cancellation cleanup, so the
old immediate stopped flag assertion could fail without a shutdown hang.

Observe the real admission request through the existing call-through
helper, then await stop while suspension remains closed. Only reopen
admission after stop settles and retain the no-dispatch and unchanged
interrupted-entry assertions. This preserves the shutdown contract and
removes an incidental fake-clock ordering assumption; production
cancellation behavior does not change.

* fix(gateway): scope restart preparation to active crash-loop suppression

Use the channel manager's prepared boot suppression instead of inspecting
breaker storage on every startup or exact-target recovery call. Keep the
healthy path synchronous and admit startup before recovery preparation.

Return the owner's deadline to the existing scheduler. Let the Gateway
cancel shared recovery work while individual callers cancel only their
waits, and retain a committed boot identity if close overtakes its reply.

The integration fixture forwards its virtual clock through the writer's
existing time input because SQLite workers do not inherit fake timers.

---------

Co-authored-by: Masato Hoshino <[email protected]>

Backport notes (release/2026.10.1): no prerequisites taken. Startup orphan
marking still lives in startGatewaySidecars on this line, so the crash-loop
suppression guard is applied there, extracted to
server-startup-main-session-orphans.ts to keep the over-cap file from growing
(regression test in
server-startup-main-session-orphans.test.ts), and the release-only
main-session-restart-dispatch-capacity.test.ts fixture gains prepareRestartRecovery. The recovery runtime keeps the release
structure and takes only this fix's gate, pause loop, and rotation handler;
state registries and the worker inventory take only the gatewayBoot entries.

(cherry picked from commit 49c1815)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
…tripped (openclaw#166238)

* fix(gateway): pause restart recovery while the crash-loop breaker is tripped

Quarantine interrupted main-session turns while the crash-loop window is
active, preserving their entries and retry budget. Re-arm the existing
recovery scheduler in the same healthy process when the window drains,
with the original cutoff and lifecycle ownership.

Reuse the breaker owner and rotate the boot segment before replay. Run
runtime state access in workers and preserve manual channel stops and
environment suppression during recovery.

Supersedes openclaw#160434.

Co-authored-by: Masato Hoshino <[email protected]>

* fix(gateway): break the channel autostart recovery import cycle

* fix(gateway): type autostart recovery suppression by identity

* test(agents): await recovery admission before testing suspended stop

The crash-loop check now reads breaker state through a worker before
startup recovery reaches Gateway root admission. Advancing fake timers
by zero does not wait for that I/O or its cancellation cleanup, so the
old immediate stopped flag assertion could fail without a shutdown hang.

Observe the real admission request through the existing call-through
helper, then await stop while suspension remains closed. Only reopen
admission after stop settles and retain the no-dispatch and unchanged
interrupted-entry assertions. This preserves the shutdown contract and
removes an incidental fake-clock ordering assumption; production
cancellation behavior does not change.

* fix(gateway): scope restart preparation to active crash-loop suppression

Use the channel manager's prepared boot suppression instead of inspecting
breaker storage on every startup or exact-target recovery call. Keep the
healthy path synchronous and admit startup before recovery preparation.

Return the owner's deadline to the existing scheduler. Let the Gateway
cancel shared recovery work while individual callers cancel only their
waits, and retain a committed boot identity if close overtakes its reply.

The integration fixture forwards its virtual clock through the writer's
existing time input because SQLite workers do not inherit fake timers.

---------

Co-authored-by: Masato Hoshino <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 17, 2026
The native subagent restart live proof SIGKILLs the Gateway three times in
about two minutes. The third unclean boot trips the documented restart-loop
breaker (3 unclean boots within 5 minutes, #166238), which pauses restart
settlement, including interrupted subagent recovery (#166846), until the
unclean window drains. The orphan assertion added with the #169144 backport
only waited 30 seconds, so the nonannouncing child was still `running`.

Wait up to 360 seconds for the orphan settlement so the proof covers the
breaker pause and the automatic resume after its window. Assertions are
unchanged. 2026.10.4 passed because it predates the breaker pause, startup
subagent reconciliation, and this assertion.

Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an
exec-blocked child passes with one prior kill; with two warm-up kills it logs
"restart-loop breaker tripped" and the parent continuation never arrives
within 60 seconds; with a 400-second wait it settles and passes (338s).
RomneyDa added a commit that referenced this pull request Oct 20, 2026
The native subagent restart live proof SIGKILLs the Gateway three times in
about two minutes. The third unclean boot trips the documented restart-loop
breaker (3 unclean boots within 5 minutes, #166238), which pauses restart
settlement, including interrupted subagent recovery (#166846), until the
unclean window drains. The orphan assertion added with the #169144 backport
only waited 30 seconds, so the nonannouncing child was still `running`.

Wait up to 360 seconds for the orphan settlement so the proof covers the
breaker pause and the automatic resume after its window. Assertions are
unchanged. 2026.10.4 passed because it predates the breaker pause, startup
subagent reconciliation, and this assertion.

Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an
exec-blocked child passes with one prior kill; with two warm-up kills it logs
"restart-loop breaker tripped" and the parent continuation never arrives
within 60 seconds; with a 400-second wait it settles and passes (338s).

(cherry picked from commit 1a4c2a0)
RomneyDa added a commit that referenced this pull request Oct 20, 2026
…7319)

* fix(test): treat the env-gated Agents API live proof as optional shard evidence

test/gateway-agentsapi.live.test.ts (new since 2026.10.4) skips its only case
unless OPENCLAW_LIVE_AGENTS_API=1, which the native live test-harness shard
never sets, so the shard's no-passing-assertions guard failed it on every
2026.10.5 candidate once the other harness tests went green. Register it in
the existing whole-file opt-in map like the other env-gated live proofs.

(cherry picked from commit 761ef64)

* fix(test): decode the Codex CLI JSON error after plugin uninstall

The live Codex npm plugin lane matched the expected post-uninstall error
against raw --json stdout, where quotes are escaped, so the correct
owner-plugin-not-activatable error never matched. Decode the canonical CLI
error message first, as the 2026.10.4 release line does (a9fd56d).

(cherry picked from commit e8772a9)

* fix(test): scope CLI announcement barrier to parent probe

(cherry picked from commit d5c0db7)
(cherry picked from commit a48d4a8)

* test(live): wait out the crash-loop breaker before the orphan settles

The native subagent restart live proof SIGKILLs the Gateway three times in
about two minutes. The third unclean boot trips the documented restart-loop
breaker (3 unclean boots within 5 minutes, #166238), which pauses restart
settlement, including interrupted subagent recovery (#166846), until the
unclean window drains. The orphan assertion added with the #169144 backport
only waited 30 seconds, so the nonannouncing child was still `running`.

Wait up to 360 seconds for the orphan settlement so the proof covers the
breaker pause and the automatic resume after its window. Assertions are
unchanged. 2026.10.4 passed because it predates the breaker pause, startup
subagent reconciliation, and this assertion.

Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an
exec-blocked child passes with one prior kill; with two warm-up kills it logs
"restart-loop breaker tripped" and the parent continuation never arrives
within 60 seconds; with a 400-second wait it settles and passes (338s).

(cherry picked from commit 1a4c2a0)

* test(qa-lab): skip user-role runtime carriers in visible-child send proof

The sessions_send visible-child proof timed out on every 2026.10.5
candidate: its synthetic provider picked the latest user item that lacked
the legacy <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> marker as the user prompt.

Since #168546 (backport 8d66b94), OpenAI-compatible Responses
endpoints, including mock-openai, keep runtime context in a user-role
"OpenClaw runtime context:" carrier after the user turn instead of a
developer message. The fixture then read that carrier as the prompt, never
saw the "send" prompt on turn 2, answered PARENT_READY again, and the test
waited for PARENT_DONE until timeout.

Captured provider requests: v2026.10.4 sends the turn-2 carrier with role
developer; the 10.5 tip sends it with role user. Reverting a293f2e
(#168410) left the failure unchanged.

Select the prompt with the shared qa-lab isInternalRuntimeContextCarrierText
helper, which already accepts current and legacy carrier shapes.

(cherry picked from commit d3a06e7)

* test(buzz): skip real reconnect backoff in cold-start recovery

(cherry picked from commit fa2049a)

* fix(release): let the Telegram release lane finish its 25 scenarios

The isolated Telegram candidate job hit its 60-minute limit at scenario 24/25
on every 2026.10.5 candidate (about 62 minutes needed at 102-108s per packaged
Gateway start). main carries the same Telegram scenario set and job, so
raise the job budget to 90 minutes; the calling release-checks job keeps its
210-minute bound.

Also carry the 2026.10.4 release-line fixture fix for
telegram-prepared-delivery-recovery (8b78670): keep the audit receipt in
the shared Gateway workspace and create it up front so the isolated SUT can
append without EACCES. main still writes it under the private tempRoot.

(cherry picked from commit 3cb49f0, adapted to main's runner anchor)

* test(gateway): probe startup readiness on fresh connections

The deferred-fleet startup test failed twice in 2026.10.5 FRV #12 with
`fetch failed` / `read ECONNRESET`. Its Gateway shares the test process's
event loop. A /healthz or /readyz probe could reuse a keep-alive socket
that Undici still treated as live; when the request was written and a
synchronous main-thread startup stall followed, the server's idle-timer
callback ran before the poll phase read the request and destroyed the
socket with the request unread, so the kernel reset the connection.

main still probes with default keep-alive fetches. Probe with
`Connection: close`, matching existing Gateway test probes. Assertions are
unchanged.

(cherry picked from commit e3c63f2, adapted to main's probe sites)

* test(live): expect review effort for Skill Workshop background reviews in the Ultra lane

Since #161057 the Skill Workshop counts iterations per session, so Ultra probe
sessions trigger a background review after idling. The review runs under its
own skill-workshop-review: run and does not inherit the session's thinking
level, so the lane's every-request-is-max assertion failed on 2026.10.5
whenever a review reached the provider.

On main, #173889 pins review runs to thinkLevel "low" (review-run.ts), which
the OpenAI stream wrapper sends as effort "low". Expect that effort for review
runs; Ultra runs and their sessions must still be max, and independent
heartbeats stay medium.

The live file is over the line cap, so the Ultra wire effort policy moves to
a sibling helper with its observation type, and the deterministic review
cases run in the normal helper suite.

(cherry picked from commit ca15213, adapted to main's review thinking level)

* test(release): forward-port 2026.10.4-line upgrade-survivor and runtime-smoke harness fixes

Release-line harness fixes that 2026.10.1-2026.10.5 carried but main never
received:

- cron-scheduled-authority: seed the cron authority specimen through the
  published baseline's own SQLite writer (seedPublishedCronJobs) instead of a
  raw cron/jobs.json that current candidates treat as a retired pre-July
  store; drop owner fields for pre-2026.7.1 baselines
  (usesCronOwnerAtBaseline). The dispatcher passes the package root to
  seedState, and the scenario now requires a published baseline.
- bundled plugin runtime smoke: join deferred read-only update discovery via
  update.status before the package-manager child watchdog. main still defers
  install discovery (`<manager> root -g`) until after ready, so it can race
  the watchdog's no-package-manager-children check.

Skips the codex npm plugin live source-reply grep from the release commit:
main already probes dynamic-tool-source-reply.ts and dynamic-tools.ts.

(cherry picked from commit fcdf0d1, codex grep hunk dropped; cron seed
test adapted to main's executable-mode fixture writes)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…nclaw#177319)

* fix(test): treat the env-gated Agents API live proof as optional shard evidence

test/gateway-agentsapi.live.test.ts (new since 2026.10.4) skips its only case
unless OPENCLAW_LIVE_AGENTS_API=1, which the native live test-harness shard
never sets, so the shard's no-passing-assertions guard failed it on every
2026.10.5 candidate once the other harness tests went green. Register it in
the existing whole-file opt-in map like the other env-gated live proofs.

(cherry picked from commit 761ef64)

* fix(test): decode the Codex CLI JSON error after plugin uninstall

The live Codex npm plugin lane matched the expected post-uninstall error
against raw --json stdout, where quotes are escaped, so the correct
owner-plugin-not-activatable error never matched. Decode the canonical CLI
error message first, as the 2026.10.4 release line does (a9fd56d).

(cherry picked from commit e8772a9)

* fix(test): scope CLI announcement barrier to parent probe

(cherry picked from commit d5c0db7)
(cherry picked from commit a48d4a8)

* test(live): wait out the crash-loop breaker before the orphan settles

The native subagent restart live proof SIGKILLs the Gateway three times in
about two minutes. The third unclean boot trips the documented restart-loop
breaker (3 unclean boots within 5 minutes, openclaw#166238), which pauses restart
settlement, including interrupted subagent recovery (openclaw#166846), until the
unclean window drains. The orphan assertion added with the openclaw#169144 backport
only waited 30 seconds, so the nonannouncing child was still `running`.

Wait up to 360 seconds for the orphan settlement so the proof covers the
breaker pause and the automatic resume after its window. Assertions are
unchanged. 2026.10.4 passed because it predates the breaker pause, startup
subagent reconciliation, and this assertion.

Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an
exec-blocked child passes with one prior kill; with two warm-up kills it logs
"restart-loop breaker tripped" and the parent continuation never arrives
within 60 seconds; with a 400-second wait it settles and passes (338s).

(cherry picked from commit 1a4c2a0)

* test(qa-lab): skip user-role runtime carriers in visible-child send proof

The sessions_send visible-child proof timed out on every 2026.10.5
candidate: its synthetic provider picked the latest user item that lacked
the legacy <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> marker as the user prompt.

Since openclaw#168546 (backport 8d66b94), OpenAI-compatible Responses
endpoints, including mock-openai, keep runtime context in a user-role
"OpenClaw runtime context:" carrier after the user turn instead of a
developer message. The fixture then read that carrier as the prompt, never
saw the "send" prompt on turn 2, answered PARENT_READY again, and the test
waited for PARENT_DONE until timeout.

Captured provider requests: v2026.10.4 sends the turn-2 carrier with role
developer; the 10.5 tip sends it with role user. Reverting a293f2e
(openclaw#168410) left the failure unchanged.

Select the prompt with the shared qa-lab isInternalRuntimeContextCarrierText
helper, which already accepts current and legacy carrier shapes.

(cherry picked from commit d3a06e7)

* test(buzz): skip real reconnect backoff in cold-start recovery

(cherry picked from commit fa2049a)

* fix(release): let the Telegram release lane finish its 25 scenarios

The isolated Telegram candidate job hit its 60-minute limit at scenario 24/25
on every 2026.10.5 candidate (about 62 minutes needed at 102-108s per packaged
Gateway start). main carries the same Telegram scenario set and job, so
raise the job budget to 90 minutes; the calling release-checks job keeps its
210-minute bound.

Also carry the 2026.10.4 release-line fixture fix for
telegram-prepared-delivery-recovery (8b78670): keep the audit receipt in
the shared Gateway workspace and create it up front so the isolated SUT can
append without EACCES. main still writes it under the private tempRoot.

(cherry picked from commit 3cb49f0, adapted to main's runner anchor)

* test(gateway): probe startup readiness on fresh connections

The deferred-fleet startup test failed twice in 2026.10.5 FRV openclaw#12 with
`fetch failed` / `read ECONNRESET`. Its Gateway shares the test process's
event loop. A /healthz or /readyz probe could reuse a keep-alive socket
that Undici still treated as live; when the request was written and a
synchronous main-thread startup stall followed, the server's idle-timer
callback ran before the poll phase read the request and destroyed the
socket with the request unread, so the kernel reset the connection.

main still probes with default keep-alive fetches. Probe with
`Connection: close`, matching existing Gateway test probes. Assertions are
unchanged.

(cherry picked from commit e3c63f2, adapted to main's probe sites)

* test(live): expect review effort for Skill Workshop background reviews in the Ultra lane

Since openclaw#161057 the Skill Workshop counts iterations per session, so Ultra probe
sessions trigger a background review after idling. The review runs under its
own skill-workshop-review: run and does not inherit the session's thinking
level, so the lane's every-request-is-max assertion failed on 2026.10.5
whenever a review reached the provider.

On main, openclaw#173889 pins review runs to thinkLevel "low" (review-run.ts), which
the OpenAI stream wrapper sends as effort "low". Expect that effort for review
runs; Ultra runs and their sessions must still be max, and independent
heartbeats stay medium.

The live file is over the line cap, so the Ultra wire effort policy moves to
a sibling helper with its observation type, and the deterministic review
cases run in the normal helper suite.

(cherry picked from commit ca15213, adapted to main's review thinking level)

* test(release): forward-port 2026.10.4-line upgrade-survivor and runtime-smoke harness fixes

Release-line harness fixes that 2026.10.1-2026.10.5 carried but main never
received:

- cron-scheduled-authority: seed the cron authority specimen through the
  published baseline's own SQLite writer (seedPublishedCronJobs) instead of a
  raw cron/jobs.json that current candidates treat as a retired pre-July
  store; drop owner fields for pre-2026.7.1 baselines
  (usesCronOwnerAtBaseline). The dispatcher passes the package root to
  seedState, and the scenario now requires a published baseline.
- bundled plugin runtime smoke: join deferred read-only update discovery via
  update.status before the package-manager child watchdog. main still defers
  install discovery (`<manager> root -g`) until after ready, so it can race
  the watchdog's no-package-manager-children check.

Skips the codex npm plugin live source-reply grep from the release commit:
main already probes dynamic-tool-source-reply.ts and dynamic-tools.ts.

(cherry picked from commit fcdf0d1, codex grep hunk dropped; cron seed
test adapted to main's executable-mode fixture writes)
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security-sensitive-changed size: XL 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