Skip to content

fix(gateway): pending approvals are rejected when an unrelated agent is added or removed - #160856

Merged
steipete merged 3 commits into
mainfrom
fix/approval-authority-roster-fence
Sep 29, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/approval-authority-roster-fence

Conversation

@steipete

@steipete steipete commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Related: #160136 (reported in #160136 (comment); ClawSweeper confirmed it is pre-existing on main and outside that PR's scope). Same over-broad-revocation class as the 2026-09-27 identity-scopes incident (#159939).

What Problem This Solves

Fixes: resolving, reading, or waiting on a pending approval fails with "approval not found" when an operator adds or removes an unrelated agent (or changes an unrelated agent's store) while the request is in flight, even though the requester and the approval's session are unchanged.

User Impact

Operator approval decisions through approval.get/approval.resolve and the legacy exec.approval.*/plugin.approval.* get/resolve/waitDecision calls survive unrelated roster and store edits. A change to the approval's own route or store, or to approval auth, still revokes the request permanently, including when the change is restored before the commit check. No config, schema, or stored bytes change.

Why This Change Was Made

Worker-family approval commits cannot load config or session rows, so each request retains a config fence that stands in for session visibility at commit time. Since #150237 that fence captured the complete agent roster and session-store inventory for the whole request, which is correct only until the request knows which approval it is acting on: before that, any roster or store edit can change what a lookup may reach.

The fence now has two phases. Until the request binds the approval's source session, it keeps the whole-inventory discovery fence unchanged. The request binds the source as soon as it is known and visible: from the live pending record before the durable lookup, from the durable row after it (transport refs and non-live rows), or from the legacy lookup/wait snapshot. From then on the fence keeps the routing, auth, store-owner, and compatibility facts plus only the store facts that source resolves through: its canonical identity, each owner's roster membership, configured flag, and store path. A sessionless approval resolves no session store, so it keeps only the routing and auth facts. Two cases deliberately keep more, because store discovery reads more: a shared fixed store keeps every co-tenant on the same physical path (owner selection dedupes across them), and a retired/unconfigured owner keeps the full store inventory (its discovery scans every configured store root). Binding first re-verifies the discovery facts against the current config, so an unpublished commit cannot become the narrowed baseline; a later bind with a different source fails closed; revocation stays latched.

#160136 landed on main during this work and edits the same fence. The branch merges current main and keeps its per-identity auth-policy check inside the shared observeConfig step, so it runs on every publication and again at bind time.

Evidence

New cases in src/gateway/server-methods/approval.request-authority.test.ts drive the real approval handlers against stored rows:

  • config-unrelated-agent / native-config-unrelated-agent: a pending approval for agent:main:main; during the in-flight resolution a config that only adds other (agents.list = [{ id: "main", default: true }, { id: "other" }]) is published; the approval still resolves (worker and native-compatible families).
  • config-target-routing-aba / config-target-store-aba: the same session-bound approval with its own route (session.mainKey) or store path changed and restored mid-flight stays rejected; row, waiter, and events untouched.
  • transport-unrelated-agent: a transport-ref resolution that has not yet bound its source keeps the discovery fence and is rejected by the same roster edit.
  • keeps a legacy decision wait when an unrelated agent is added: exec.approval.waitDecision receives the decision after an unrelated agent is added mid-wait.

RED on base (Testbox tbx_01m3n93acrnpmgv8ct0en6xqad: the four production files restored from 0a5ef7d9e0c6, new tests kept): 3 failed / 44 passed. Exactly the three must-survive cases fail: config-unrelated-agent and native-config-unrelated-agent return approval not found, and the legacy wait rejects with Approval requester authority changed. The target-ABA and transport cases already pass on base, as intended guards.

GREEN at the merged head 3b1e7ae7, fresh Blacksmith Testbox tbx_01m3nbtyw757q65st61wc215jc: CI=1 pnpm test src/gateway/server-methods/approval.request-authority.test.ts --maxWorkers=1 → 1 file, 49/49 passed, including the identity-scope cases from main; 30.46 s wall (Vitest 28.64 s, 84% transform). Pre-merge runs measured 29.70 s (aa3a2b25) and 34.65 s (3b32f218). The six new tests cost 5–11 ms each. A local run on the shared Mac also passed 47/47 but took 772 s under load ~50, so it is not a meaningful timing. CI seconds will follow once the run exists.

Other gates on Testbox at the merged head: pnpm tsgo:core (41 s), pnpm tsgo:core:test (1021 s), oxlint on the changed files, format:check, and check:import-cycles passed. Before the merge, dead-code exports, check:assertion-safety, and check:coercion-helpers also passed. Before the merge, node scripts/check-changed.mjs stopped early at the env-var budget ratchet (OPENCLAW_* count 477 exceeds budget 476) inherited from the old base; this diff adds no OPENCLAW_* names. After the merge, scripts/check-env-var-count.mts reports 476/476. Codex autoreview (P0–P2) was scoped-clean on the original production commit and again on the merged candidate.

CI note: the first PR run (36508995885, attempt 1) failed one unrelated Control UI test, ui/src/e2e/people-activity-card.e2e.test.ts › "opens focused details inside a narrow touch viewport and follows the session's saved face". After Tab then Escape, the People card stayed open (expect.poll(card.count()).toBe(0) received 1). This PR touches no UI code, and the same checks-ui-e2e (7/9) shard passed on main's scheduled runs 36518039325 and 36513735118. I requested one rerun of the failed jobs, and a separate root-cause lane is filed for the likely focus race with the mobile nav transition.

Not covered: no live Gateway or channel proof. The change is confined to the in-process request fence, and the handler-level tests drive the real approval handlers, worker admission, and stored rows.

@clawsweeper

clawsweeper Bot commented Sep 29, 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.

@github-actions

github-actions Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 3b1e7ae74d0814676ab51e512bc1a8cc7c44e417
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-methods/approval-request-authority.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Sep 29, 2026
…y-roster-fence

# Conflicts:
#	src/gateway/server-methods/approval-request-authority.ts
#	src/gateway/server-methods/approval.request-authority.test.ts
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 29, 2026
@clawsweeper

clawsweeper Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 12:44 AM ET / 04:44 UTC (Revision 3).

ClawSweeper review

What this changes

The branch narrows Gateway approval config checks after binding an approval to its source session, and adds regression tests and storage documentation.

Merge readiness

✅ Ready for maintainer review

Current main still revokes an in-flight approval when an unrelated agent changes. This PR addresses that remaining bug, and the reviewed authority and stored-row checks reveal no actionable patch defect.

Priority: P2
Reviewed head: 3b1e7ae74d0814676ab51e512bc1a8cc7c44e417

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch has source-aligned stored-row proof and no supported correctness finding; it has no live Gateway replay.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The reported Testbox run exercises registered approval handlers and worker admission against real durable approval rows at this head. Its cases observe an allowed row after an unrelated-agent edit and unchanged pending rows after target-route, target-store, or authority revocation; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The reported Testbox run exercises registered approval handlers and worker admission against real durable approval rows at this head. Its cases observe an allowed row after an unrelated-agent edit and unchanged pending rows after target-route, target-store, or authority revocation; no stored-data contract changes.
Evidence reviewed 5 items Current main still has the reported behavior: The fetched main revision captures the complete agent and store inventory for the request and has no source-binding phase.
Introduced authority change: The pinned merge-base-to-head diff adds a two-phase fence: the full inventory remains until the source is bound, after which the captured policy tracks the source identity, owners, and relevant store paths. The config publication listener retains permanent revocation.
Final decision boundary: The approval resolve handler carries the bound authority into its commit guard before the durable decision and checks the original live approval binding.
Findings None None.
Security None None.

How this fits together

Operator clients send approval read, resolve, and wait requests to the Gateway. The Gateway checks request authority and session visibility before reading or changing durable approval rows.

flowchart LR
  A[Operator approval request] --> B[Gateway authority check]
  C[Config publication] --> B
  B --> D{Source session known?}
  D -->|No| E[Full discovery fence]
  D -->|Yes| F[Source route and store fence]
  E --> G[Approval store decision]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +96, Tests +91, Docs +5. Total +192 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 4 119 23 +96
Tests 2 92 1 +91
Docs 1 7 2 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 218 26 +192

Review metrics

Metric Value Why it matters
Production and test growth production +119/−23 lines; tests +92/−1 lines The production growth implements the source-bound authority fence; the added tests exercise allowed and rejected durable decisions.

Technical review

Best possible solution:

Keep approval authority bound to the original request and source store through the final decision, while preserving whole-inventory checks until the source is known.

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

Yes. Current-main source retains the whole roster for an in-flight request, and the submitted handler regression reports the resulting rejection on the base; this review did not execute it.

Is this the best way to solve the issue?

Yes. Narrowing the existing Gateway authority fence after source binding addresses the observed interruption while retaining full discovery checks before binding and commit checks afterward.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6f4c801c18f9.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: An unrelated roster edit can interrupt an approval already in flight, but the failure requires a specific concurrent configuration change.
  • merge-risk: 🚨 security-boundary: The PR narrows a revocation fence for approval decisions; stored-row controls cover both permitted completion and rejection after relevant authority changes.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The reported Testbox run exercises registered approval handlers and worker admission against real durable approval rows at this head. Its cases observe an allowed row after an unrelated-agent edit and unchanged pending rows after target-route, target-store, or authority revocation; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The reported Testbox run exercises registered approval handlers and worker admission against real durable approval rows at this head. Its cases observe an allowed row after an unrelated-agent edit and unchanged pending rows after target-route, target-store, or authority revocation; no stored-data contract changes.

Evidence

What I checked:

Likely related people:

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

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 (2 earlier review cycles)
  • reviewed 2026-09-29T01:17:33.331Z sha aa3a2b2 :: blocked before merge. :: none
  • reviewed 2026-09-29T01:49:47.986Z sha 3b1e7ae :: needs maintainer review before merge. :: none

@steipete
steipete enabled auto-merge (squash) September 29, 2026 04:32
@steipete
steipete merged commit 6922a50 into main Sep 29, 2026
429 of 438 checks passed
@steipete
steipete deleted the fix/approval-authority-roster-fence branch September 29, 2026 04:54
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 30, 2026
…is added or removed (openclaw#160856)

* fix(gateway): keep approvals alive when an unrelated agent or store changes

* test(gateway): list the native unrelated-agent case in the custody stage switch
steipete added a commit that referenced this pull request Sep 30, 2026
…161571)

The narrow touch-viewport Activity card test opened the navigation drawer
with a mouse click. That parks a hover pointer at the toggle while the drawer
slides in underneath it, so the drawer's header buttons can receive synthetic
pointerover events after focus has entered the card. Their tooltip then owns
the next Escape (Tooltip.consumeEscape), and the card stays open for the whole
poll. #160140 made the window hot: the Online person link's "counts
unavailable" title tooltip closes when the card opens and arms the tooltip
provider's zero-delay skip window across Tab and Escape.

Open the drawer with tap(), matching the touch scenario and the sibling touch
tests, and assert Tab moved focus into the portaled card before Escape.

First sighting: #160856 (run 36508995885, checks-ui-e2e 7/9).
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 1, 2026
…penclaw#161571)

The narrow touch-viewport Activity card test opened the navigation drawer
with a mouse click. That parks a hover pointer at the toggle while the drawer
slides in underneath it, so the drawer's header buttons can receive synthetic
pointerover events after focus has entered the card. Their tooltip then owns
the next Escape (Tooltip.consumeEscape), and the card stays open for the whole
poll. openclaw#160140 made the window hot: the Online person link's "counts
unavailable" title tooltip closes when the card opens and arms the tooltip
provider's zero-delay skip window across Tab and Escape.

Open the drawer with tap(), matching the touch scenario and the sibling touch
tests, and assert Tab moved focus into the portaled card before Escape.

First sighting: openclaw#160856 (run 36508995885, checks-ui-e2e 7/9).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: M 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