Repository navigation
fix(gateway): pending approvals are rejected when an unrelated agent is added or removed - #160856
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
…y-roster-fence # Conflicts: # src/gateway/server-methods/approval-request-authority.ts # src/gateway/server-methods/approval.request-authority.test.ts
|
Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 12:44 AM ET / 04:44 UTC (Revision 3). ClawSweeper reviewWhat this changesThe 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 Review scores
Verification
How this fits togetherOperator 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
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +96, Tests +91, Docs +5. Total +192 across 7 files. View PR surface stats
Review metrics
Technical reviewBest 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. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
…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
…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).
…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).
Related: #160136 (reported in #160136 (comment); ClawSweeper confirmed it is pre-existing on
mainand 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.resolveand the legacyexec.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
mainduring this work and edits the same fence. The branch merges currentmainand keeps its per-identity auth-policy check inside the sharedobserveConfigstep, so it runs on every publication and again at bind time.Evidence
New cases in
src/gateway/server-methods/approval.request-authority.test.tsdrive the real approval handlers against stored rows:config-unrelated-agent/native-config-unrelated-agent: a pending approval foragent:main:main; during the in-flight resolution a config that only addsother(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.waitDecisionreceives the decision after an unrelated agent is added mid-wait.RED on base (Testbox
tbx_01m3n93acrnpmgv8ct0en6xqad: the four production files restored from0a5ef7d9e0c6, new tests kept): 3 failed / 44 passed. Exactly the three must-survive cases fail:config-unrelated-agentandnative-config-unrelated-agentreturnapproval not found, and the legacy wait rejects withApproval requester authority changed. The target-ABA and transport cases already pass on base, as intended guards.GREEN at the merged head
3b1e7ae7, fresh Blacksmith Testboxtbx_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 frommain; 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, andcheck:import-cyclespassed. Before the merge, dead-code exports,check:assertion-safety, andcheck:coercion-helpersalso passed. Before the merge,node scripts/check-changed.mjsstopped early at the env-var budget ratchet (OPENCLAW_* count 477 exceeds budget 476) inherited from the old base; this diff adds noOPENCLAW_*names. After the merge,scripts/check-env-var-count.mtsreports 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". AfterTabthenEscape, the People card stayed open (expect.poll(card.count()).toBe(0)received 1). This PR touches no UI code, and the samechecks-ui-e2e (7/9)shard passed onmain'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.