Skip to content

fix: preserve resumed runs through temporary access policy outages - #198729

Merged
steipete merged 3 commits into
mainfrom
steipete/perf-micro-restart-recovery-cancels-on-unavailable-20260919
Nov 14, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/perf-micro-restart-recovery-cancels-on-unavailable-20260919

Conversation

@steipete

@steipete steipete commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Related: #198245

What Problem This Solves

Fixes resumed turns and their subagents being cancelled when a subagent completion encounters a temporarily unavailable Gateway access policy.

User Impact

Accepted work survives temporary policy outages and completion delivery uses its existing retry path. Individual operations still refuse unavailable authorization, and definite denial or a real authority change still cancels work. No configuration or schema changes are required.

Why This Change Was Made

Recovery and several steering/completion boundaries treated failed evaluation as permanent revocation. Preserve custody for unavailable checks and retain known-undelivered steering fallback; keep definite revocation fail-closed. Detached completion retries also need a fresh plugin operation scope after the requester yields, while retaining the original operator authority.

Production code grows by 35 lines across the existing owners. This adds error classification and reuses the existing detached-work helper, without another retry mechanism, cache, or state owner.

Evidence

  • All 350 focused owner tests pass across recovery, access-policy invalidation, steering, requester settlement, and subagent lifecycle. New regressions fail on 520f18975936. Five focused CI replays across four files also pass after the test/tooling repair; production code is unchanged.
  • A real subprocess Gateway restart with a synthetic HTTP model provider reproduces the cancellation on 520f18975936. With this fix, a one-shot policy failure during child completion leaves the resumed requester active; existing retry delivers the result after it yields. This exercises one child, not a six-child load test.
  • Codex P2 autoreview: zero actionable findings in the full local diff against 569bf22dba45, committed as 9d7887a5610c, and in the fixture-only type correction at 8dcfe3fc65fb; the subsequent CI repair delta at e8658a87b8c7 also has zero findings. No changed module is imported by Control UI.
  • pnpm check:changed caught a fixture scope-array typing error; corrected with the canonical OperatorScope[] type and all four test-root typecheck shards now pass. All other changed-file checks passed except the inherited dead-export scan below; the full invocation retains its failed result, with the corrected typecheck recorded separately. Three inherited dead-export regressions reproduce on the exact main parent 569bf22dba45: normalizeDiscoveredAgentModel (introduced by consumer replacement 730ce41827c4, perf(models): reduce catalog normalization allocations #198591), MEMBER_ROLE_PRESETS and openclawIdMemberRoleDefinition (introduced by 4fc7acf90a73, feat(openclaw-id): member roles come from gateway.roles.definitions #197739). These are main regressions requiring follow-up.
  • Synthetic fixture: 35.13 GiB database, 10,000 sessions, 1,000,000 events, 62,000 workspace files / 1.116 GB, generated without production data. Healthy recovered-owner checks use 40 plugins and one access policy, with exactly one retained assertion/check and no authorize/resume callbacks. On Linux/btrfs, counterbalanced A/A and B/B runs give pooled wall/CPU medians of 2.490/2.482 µs before and 2.745/2.747 µs after (about 10% higher, with substantial candidate variability). Sampled allocation stays flat: 3804.5 → 3803.1 bytes/check. APFS timings remain within the baseline's 5% A/A variation; allocation 3835.4 → 3831.9 bytes/check. These measure owner checks, not whole-Gateway throughput.

Initial CI run 43572114354 exposed three authored proof defects, now repaired: the benchmark suppression inventory, publication tests expecting transient unavailability after explicit visitor revocation, and the outage fixture relying on a one-second readiness wait. The fixture now uses its existing 15-second phase bound while retaining the same outage, active-run, and eventual-completion assertions; the real Gateway replay passes in 45.2 seconds. Targeted typecheck, format, script lint, benchmark serialization smoke, and Codex review pass.

The separate plugin-reload product fixture timed out at 120 seconds on exact parent 569bf22dba45 with no candidate production changes. Its preparation owner changed from full to runtime in 7cd145595bf9 (#197783); restoring only that prior argument on the same parent passes in 92.7 seconds. The unchanged fixture also passes on the candidate in 86.3 seconds. This is a timing-sensitive main regression requiring follow-up, not a claimed fix or automatic CI waiver; the next exact-head CI remains required.

Keep restart recovery and known-undelivered completion/steering custody alive when operator policy evaluation is unavailable. Definite denial and authority changes still revoke. Detached completion retries reacquire plugin scope while preserving original operator authority.
@clawsweeper

clawsweeper Bot commented Nov 14, 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 scripts Repository scripts agents Agent runtime and tooling size: L labels Nov 14, 2026
@steipete
steipete marked this pull request as ready for review November 14, 2026 07:39
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T08:17:31.491729Z e8658a8 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.

@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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 Nov 14, 2026
@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserve resumed runs and undelivered steering or completion custody when access-policy evaluation is temporarily unavailable.

Example: After a Gateway restart, a child completes for agent:main:main:thread:yield-restart while its access policy throws once.

  • Before: The failed evaluation permanently revokes the resumed requester's authority and cancels accepted work.
  • After: The affected operation refuses authorization, retained work survives, and existing completion delivery can retry.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and the earlier defects are repaired; public behavior evidence does not yet satisfy the proof gate.
Proof confidence 🧂 unranked krab (1/6) 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.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A temporary access-policy outage during child completion can cancel a resumed conversation and its accepted subagent work.
Reason: Preserving accepted work during temporary evaluation failure follows the existing policy contract and the maintainer-authored direction.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses a current recovery defect, resolves both prior findings, and introduces no identified code defect.

Priority: P2
Reviewed head: e8658a87b8c708dd85b25ed6ff674dc4f96cb249

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Attach redacted Gateway/RPC output from the reported restart scenario showing the injected outage, requester remaining active, and eventual child-result delivery; redact IPs, API keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

Gateway recovery reconstructs the original operator authority; session and subagent owners use it to authorize queued input and completion delivery.

flowchart TD
  A[Interrupted operator turn] --> B[Gateway recovery]
  B --> C[Original access grant]
  C --> D[Policy evaluation]
  D --> E[Unavailable operation refused]
  E --> F[Retained delivery custody]
  F --> D
  D --> G[Authorized completion or definite revocation]
Loading

Technical review

Best possible solution:

Keep temporary evaluation failure separate from revocation throughout existing recovery and custody owners, while retaining original-grant authorization and existing delivery retries.

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

Current-main recovery code converts policy-check exceptions into permanent revocation, and the submitted subprocess fixture targets that path; this review executed no target code.

Is this the best way to solve the issue?

Temporary evaluation failure must refuse an operation without ending its original grant; classifying the existing unavailable error at recovery and custody boundaries and reusing detached admission is a focused repair.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 1c1814a0bf78.

Provenance checked

  • Recovered operator authority and retained access grants changes intended behavior with a stated reason (961f5c0: Restore interrupted operator authority under its original scope ceilings and terminate it on real identity, credential, grant, or ownership changes; later grant reuse retained those checks.)
  • Steering fallback custody keeps the original intent (36adaa8: Recover proven withdrawn input as a followup while preventing replay of accepted or indeterminate input.)
  • Latched injection-authority refusal changes intended behavior with a stated reason (e3ce08c: Bind steering and question admission to the originating control authority and keep genuinely revoked controls from reviving.)
  • Detached subagent lifecycle work keeps the original intent (36e277d: Give session work one controller and revalidate restored work when detached recovery capacity becomes available.)
  • Authority benchmark persistence boundary keeps the original intent (60361b1: Measure recovered source-policy checks using decoded persisted authority rather than an already-issued policy identity.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +35, Tests +252, Docs +4, Other +7. Total +298 across 20 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 10 66 31 +35
Tests 8 376 124 +252
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 1 11 4 +7
Total 20 457 159 +298

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Benchmark option 1 new flag: --root The offline authority benchmark can reuse and retain a synthetic fixture directory; this adds no Gateway configuration setting.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove merge-risk: 🚨 automation: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Temporary access-policy failures can cancel resumed work and suppress completion delivery, with impact limited to the affected recovery and custody paths.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦪 silver shellfish.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-14T07:54:56.574Z sha 8dcfe3f :: blocked before merge. :: [P2] Register the intentional JSON-roundtrip suppression | [P2] Update the publication consumer's revoked-grant expectation

Reviewed November 14, 2026, 3:22 AM ET / 08:22 UTC (Revision 2).

Keep the benchmark JSON persistence boundary explicit without a lint suppression. Require terminal refusal after visitor revocation, and wait for actual Gateway fixture readiness within the existing phase budget before injecting the outage.
@steipete

Copy link
Copy Markdown
Contributor Author

Addressing all three open items from the review of 8dcfe3fc65fb, on new head e8658a87b8c708dd85b25ed6ff674dc4f96cb249:

  1. JSON-roundtrip suppression: removed it. The benchmark explicitly serializes then decodes persisted bytes, preserving omission of undefined fields. The existing suppression-inventory test, script lint, and a recovery-source benchmark smoke pass without an allowlist change.
  2. Revoked-grant publication expectation: both original and restored requesters now must produce the publication owner's terminal refusal. The prior expectations reproduce locally; both corrected parameterized cases pass. Live-grant and exact-snapshot assertions remain.
  3. Remaining CI failures: checks-node-changed-2 failed in the new outage fixture before injection because its one-second default readiness wait expired while the child continuation was still starting. Readiness and observed-failure waits now use the fixture's existing 15-second phase bound; active-run and eventual-completion assertions remain and the real Gateway replay passes in 45.2 seconds. The plugin-reload 120-second timeout also reproduces on exact parent 569bf22dba45, without these production changes. Its preparation owner changed from full to runtime in perf(ci): trim plugin reload fixture compilation #197783 (7cd145595bf9); restoring only that prior argument on the same parent passes in 92.7 seconds. The unchanged fixture passes on this candidate in 86.3 seconds. This remains a timing-sensitive main regression for follow-up, not a claimed repair or blanket CI exception. New exact-head CI must complete before landing.

All five focused CI-replay cases across four files pass. The repair delta also passed Codex P2 review, typecheck, format, and script lint. Production code is unchanged by this repair.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. labels Nov 14, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Final-head status for e8658a87b8c708dd85b25ed6ff674dc4f96cb249: ClawSweeper revision 2 has zero open items and no code findings. Native preparation is complete.

CI run 43574894383 finished with one failed test job plus its aggregate gate. The failure is prepared-model-catalog-worker.pool.integration.test.ts → keeps Gateway catalogs available across temporary skill environments: Gateway catalog environment changed without retiring its plugin generation. All other selected checks passed, including the restart-recovery E2E and the previously failing plugin-reload fixture.

The failing case passes on the candidate locally and on the exact CI main parent 2e77b6be8b673742f5849e6a386829203f2a1fd2 under the pinned Bun on macOS and isolated Linux. The matching five-file Linux group also passes all 101 tests; temporary key-name-only diagnostics observed no environment mismatch. These passing replays neither explain the CI failure nor qualify an inherited-red exception. The earlier logging initialization regression was fixed by #197736 and that fix is already present.

Leaving the PR open at the reviewed head. No CI rerun or admin merge requested. The unresolved catalog failure needs attribution before landing; the recovery fix and its red-on-520f1897 / green-after-fix proof remain unchanged.

@steipete
steipete merged commit 9a3b527 into main Nov 14, 2026
256 of 261 checks passed
@steipete
steipete deleted the steipete/perf-micro-restart-recovery-cancels-on-unavailable-20260919 branch November 14, 2026 09:06
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 15, 2026
…penclaw#198729)

* fix: preserve resumed runs through temporary access policy outages

Keep restart recovery and known-undelivered completion/steering custody alive when operator policy evaluation is unavailable. Definite denial and authority changes still revoke. Detached completion retries reacquire plugin scope while preserving original operator authority.

* test: type restart recovery fixture operator scopes

* test: verify revocation and await recovery readiness

Keep the benchmark JSON persistence boundary explicit without a lint suppression. Require terminal refusal after visitor revocation, and wait for actual Gateway fixture readiness within the existing phase budget before injecting the outage.
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…penclaw#198729)

* fix: preserve resumed runs through temporary access policy outages

Keep restart recovery and known-undelivered completion/steering custody alive when operator policy evaluation is unavailable. Definite denial and authority changes still revoke. Detached completion retries reacquire plugin scope while preserving original operator authority.

* test: type restart recovery fixture operator scopes

* test: verify revocation and await recovery readiness

Keep the benchmark JSON persistence boundary explicit without a lint suppression. Require terminal refusal after visitor revocation, and wait for actual Gateway fixture readiness within the existing phase budget before injecting the outage.

Release adaptation: Separate baseline-policy repair eeb2ecfd: preserve typed operator-policy unavailable error in followup catch (+4/-1). Not source7/R3 and absent from401018. Prepared onUI8fbc; no branch commit or runtime claim.

(cherry picked from commit 9a3b527)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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. docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts 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