Skip to content

refactor(agents): unify CLI spawn/live failure policy lanes - #122164

Merged
steipete merged 1 commit into
mainfrom
steipete/failover-b3-lane-unification
Aug 11, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/failover-b3-lane-unification

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Resolves a maintenance and reliability problem where the CLI spawn and persistent-live lanes made the same watchdog and abnormal-exit decisions through duplicated, subtly different predicates. That divergence could make equivalent quiet failures recover differently depending on which CLI transport was selected.

Why This Change Was Made

This change gives both lanes one CLI-owned no-output decision module and one exit-classification adapter backed by the shared failover substrate. It also routes final raw CLI errors through coerceToFailoverError, word-bounds unsupported checkpoint-flag detection, and documents why cli_max_turns remains reachable at the embedded failover boundary.

Predicate differences were adjudicated as follows:

  • Initial no-output retry: unified on no observed activity and no stdout/stderr text. This replaces the live lane's unconditional lastOutputAtMs === null code assignment with the same replay-safety facts used by spawn.
  • Resume control-only stalls: retained as the named live-only allowResumeControlOnlyRetry input. The persistent live parser can distinguish init/control traffic from replay-unsafe assistant/tool activity; spawn supervision cannot.
  • Outstanding tools/background work: retained as the named live-only outstandingWorkGraceMs input. The persistent live lane still owns tracked work and may extend to the blocked-tool floor; the spawn child is already terminated when classification runs.
  • Activity and timeout facts: retained as lane-owned inputs to the one decision. Spawn reports parser/event activity and the configured supervisor threshold; live reports process-output/tool/raw-line activity and measured quiet duration. The retry predicate and CliTimeoutContext construction are shared.
  • Spawn stall notification routing: retained outside the decision module because it is an orchestration side effect, not retry authority. The shared decision still determines whether that notice may be deferred for an internal recovery.
  • Exit candidates: retained as the named candidates input. Spawn can classify bounded stderr/stdout parse windows and diagnostic tails; live stdout is structured and consumed before exit, so live supplies stderr only.
  • Empty exit reason: retained as the named emptyReason input. A clean live exit before a terminal record is a protocol-level empty_response; an output-free nonzero exit remains unknown.
  • Empty failure retry code: unified. A normal process exit with no error candidate and no observed activity now receives cli_unknown_empty_failure in both lanes, including quiet nonzero live exits.
  • Fallback copy and attribution: retained as lane-owned inputs. Live preserves its precise premature-clean-exit copy, while spawn preserves session/lane attribution; both use the same classifier and CLI code mapping.

The removed alternatives were a consumer-side guard, a lane-selecting wrapper over the old branches, and preserving the CLI-local text classifier. Each would have left duplicate retry authority or classification policy in place.

User Impact

No new configuration or public API. Equivalent CLI failures now produce consistent structured failover behavior across spawn and persistent-live execution, while replay-unsafe tool/output activity remains protected from automatic recovery.

Production LOC: +229/-232 (net -3). Tests: +57/-0.

Evidence

  • node scripts/run-vitest.mjs src/agents/cli-runner.fault-sequences.e2e.test.ts — 10/10 passed.
  • node scripts/run-vitest.mjs src/agents/cli-runner.reliability.test.ts — 86/86 passed; the new word-bound regression failed before the matcher fix and passes after it.
  • node scripts/run-vitest.mjs src/agents/cli-runner/execute.supervisor-capture.test.ts — 52/52 passed.
  • node scripts/run-vitest.mjs src/agents/cli-runner/claude-live-process.test.ts src/agents/cli-runner/claude-live-turn.test.ts src/agents/cli-runner/claude-live-turn-diagnostics.test.ts — 57/57 passed.
  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/failover-policy.test.ts — 47/47 passed.
  • node scripts/check-changed.mjs --timed — passed all changed gates after the remote backend was unavailable and the documented trusted-source local fallback ran.
  • pnpm check:import-cycles and pnpm check:madge-import-cycles — 0 cycles.
  • pnpm build — passed.
  • git diff --check and changed-file formatting — passed.
  • Fresh structured autoreview on the rebased branch — no actionable findings; secret scan clean.

Broad local aggregate notes: src/agents/cli-runner passed 1184/1196, with 12 order-sensitive target-normalization assertions in supervisor capture; that owning file passes 52/52 alone and the target-normalization surface is untouched here. The embedded run/ aggregate passed 4724/4728; all four failures were the same hard-coded /tmp/openclaw.sqlite schema-16 artifact under four configs, unrelated to the two-line failover-policy comment.

AI-assisted implementation; reviewed and verified by the maintainer workflow.

@clawsweeper

clawsweeper Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Aug 11, 2026
@steipete
steipete marked this pull request as ready for review August 11, 2026 17:25
@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 11, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 7d9e5dd0b3aefa0bb4bdd141d667c5f931f40489:

  • node scripts/run-vitest.mjs src/agents/cli-runner.fault-sequences.e2e.test.ts — 10 passed.
  • node scripts/run-vitest.mjs src/agents/cli-runner.reliability.test.ts — 86 passed.
  • node scripts/run-vitest.mjs src/agents/cli-runner/execute.supervisor-capture.test.ts — 52 passed.
  • node scripts/run-vitest.mjs src/agents/cli-runner/claude-live-process.test.ts src/agents/cli-runner/claude-live-turn.test.ts src/agents/cli-runner/claude-live-turn-diagnostics.test.ts — 57 passed.
  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/failover-policy.test.ts — 47 passed.
  • node scripts/check-changed.mjs --timed — all changed gates passed.
  • Runtime and Madge import-cycle checks — 0 cycles; pnpm build passed.
  • Fresh structured autoreview and secret scan — clean, no actionable findings.
  • Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/31517486509 — successful, including openclaw/ci-gate.

Production LOC is +229/-232 (net -3); tests are +57/-0. Local Testbox delegation was unavailable because the Blacksmith CLI and managed broker authentication were unavailable; the documented trusted-source local fallback ran, and exact-head hosted CI supplied the final remote gate. Broad aggregate-only shared-state/order failures were isolated to untouched fixtures; each implicated owning suite and exact-head CI passed.

@steipete
steipete merged commit b336984 into main Aug 11, 2026
182 checks passed
@steipete
steipete deleted the steipete/failover-b3-lane-unification branch August 11, 2026 17:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 12, 2026
steipete added a commit that referenced this pull request Aug 12, 2026
…2432)

Supervisor-capture tests asserted real telegram/slack channel ids, so
their pass/fail depended on which channel plugins the selected vitest
lane loads (stubs when focused, real normalizers under unit-fast);
switch to a neutral synthetic channel. Two embedded-runner tests
carried a shared literal /tmp/openclaw.sqlite storePath — one actually
opened it, colliding with stale artifacts across parallel runs; both
now use realpath'd auto-cleaned per-test temp dirs.

Evidence in PR #122164 body; pre-fix aggregates failed 12/1202 (cli)
and 4/4750 (embedded), post-fix green in default and shuffled order.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 2026
…nclaw#122432)

Supervisor-capture tests asserted real telegram/slack channel ids, so
their pass/fail depended on which channel plugins the selected vitest
lane loads (stubs when focused, real normalizers under unit-fast);
switch to a neutral synthetic channel. Two embedded-runner tests
carried a shared literal /tmp/openclaw.sqlite storePath — one actually
opened it, colliding with stale artifacts across parallel runs; both
now use realpath'd auto-cleaned per-test temp dirs.

Evidence in PR openclaw#122164 body; pre-fix aggregates failed 12/1202 (cli)
and 4/4750 (embedded), post-fix green in default and shuffled order.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant