Skip to content

fix(gateway): resume session-scoped operators after restart - #179564

Closed
steipete wants to merge 1 commit into
mainfrom
steipete/perf-micro-restart-recovery-missing-operator-write-20260919
Closed

steipete wants to merge 1 commit into
mainfrom
steipete/perf-micro-restart-recovery-missing-operator-write-20260919

Conversation

@steipete

@steipete steipete commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes interrupted turns repeatedly failing restart recovery with missing scope: operator.write when their original caller was admitted with operator.sessions.write.

User Impact

Session-only operators, including trusted-proxy users and delegated parent continuations, can resume their own interrupted work without receiving broader permissions. Confirmed revocation records a visible interruption instead of repeatedly deferring the same input. Saved final replies and other unfinished recovery obligations remain preserved.

Why This Change Was Made

Recovery already persists the original operator authority and revalidates its current profile, role, device, and access grant. Its internal agent dispatch omitted the existing exact-session binding used by other session continuations. Bind the captured session/run/lifecycle before dispatch, retaining the original scopes and normal own-session checks.

Classify definitive authorization loss separately from storage, lifecycle, and temporarily unavailable policy failures. Route denied pre-admission recovery through the existing guarded notice/settlement owner. No schema, permission, or configuration changes.

Evidence

  • Regression reproduced the exact missing-scope rejection for trusted-proxy and delegated session-only callers before the binding change; broad-write recovery succeeded.
  • 76 focused tests passed across operator-run-recovery.test.ts, server-instance-runtime.operator-recovery.test.ts, and server-instance-runtime.native-restart-recovery.test.ts. Coverage includes cold authority restoration, retained scopes, revocation, cron-owned interruption, exact claims, repeated recovery without duplicate turns/notices, and saved-final preservation. The recovery/router and persistence boundaries are real; the model/turn executor is stubbed.
  • Last owning-boundary run: 38 tests / 2 files, 67.76 s including compilation; authority-restoration run: 38 tests / 1 file, 65.92 s including compilation. This is correctness evidence, not a performance comparison; no latency or GC claim.
  • Targeted core typecheck, changed-file lint/format, export collision guard, and 22 closure checks passed. Final independent autoreview was clean at P0/P1. The simplification pass reuses the existing guarded settlement owner and preserves saved delivery custody.
  • CI caught a stale child-completion consumer of the old access-denied error. The original exact-head run failed subagent-registry.completion-authority.test.ts at “revalidates revoked grant for a cold-loaded interrupted child batch without widening the parent”; local replay reproduced 91 passing / 1 failing. The restoration owner now recognizes the typed definitive denial as well as a live access denial. The unchanged 92-test file passes after the fix (88.74 s including compilation). Changed-file lint/format and an additional independent P0/P1 review passed.
  • A second selected CI shard caught changed revocation wording in requester and automation consumers (3 failures reproduced locally). Recovery now preserves the established public error message and its cause while retaining the typed denial. The two failing files plus the main restart regression pass: 38 tests, 95.80 s including compilation. Changed-file lint/format and a further independent P0/P1 review are clean.
  • Production LOC delta: +105. Growth is the required typed denial/settlement behavior; the fix reuses existing authority, session-binding, and recovery-state owners rather than introducing storage or a parallel recovery path.

A full isolated Gateway/model restart is not yet verified. Production acceptance remains the next operator-coordinated restart. Production grants and configuration were not changed; incident logs alone do not identify each original caller's authentication method.

Bind recovery to its captured session without broadening persisted operator scopes. Record definitive authorization loss with the existing guarded interruption notice, preserving pending delivery and other recovery custody.
@steipete
steipete marked this pull request as ready for review October 21, 2026 14:31
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Oct 21, 2026
@clawsweeper

clawsweeper Bot commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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 ✅ Completed 2026-10-21T14:45:54.320568Z d469cbf Draft marked ready
ℹ️ 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.

@steipete

Copy link
Copy Markdown
Contributor Author

Continued in #179579 from the same branch. This PR's recorded head remained at d469cbff8a9d1efea394285c469850e5afd2244e after the branch was updated, and GitHub refused to reopen it during CI-attachment recovery. The replacement carries the reviewed fix plus both CI repairs: definitive child-recovery denials now settle, and revocation keeps its established public error message. Focused regressions pass; fresh CI will run on the replacement's exact head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant