Skip to content

refactor: share operator permissions across Gateway calls and events - #153979

Merged
steipete merged 3 commits into
mainfrom
codex/unify-operator-scope-authority
Sep 20, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/unify-operator-scope-authority

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Related: #141865

What Problem This Solves

Background continuations previously failed read-only checks such as GitHub identity verification despite holding write permission. #141865 fixed that dispatch path, but RPC authorization and event delivery still maintained separate copies of the same permission rules.

User Impact

Gateway calls, background tool calls, and event delivery now share one operator-scope policy. Existing permissions, session checks, and execution-lifetime checks are preserved; no configuration or migration is needed.

Why This Change Was Made

Expose the existing shared scope predicate and use it in RPC authorization and broadcast filtering. Transport grants retain exact matching while the role adapter retains its established normalization. The predicate reads existing arrays, avoiding per-recipient allocations. Write still implies read and Talk, and does not grant admin, approvals, pairing, Talk secrets, or arbitrary future scopes.

Extend the existing completion-dispatch regression to invoke the real GitHub identity status tool after requester settlement. This is the maintainer-requested follow-up to consolidate ownership of the incident fix.

Evidence

  • 298 tests pass across shared scope policy, Gateway method authorization, continuation dispatch, and event delivery.
  • The continuation case uses the real completion dispatcher, Gateway facade, RPC authorization, and GitHub identity tool, with model execution and the status response mocked.
  • Independent review through P2 is clean after removing an avoidable broadcast allocation.
  • Linux Testbox repeats all 298 tests successfully and passes structural guards, including the repaired file-size gate. Formatting and git diff --check pass.
  • Rebased onto main containing the deferred-migration callback typecheck repair.
  • CI exposed a checkout-dependent Stylelint expectation in the existing lane-selection test. The original case fails before the repair; it and two new present/deleted-file CLI fixtures pass afterward. Lane/type assertions and production tooling behavior remain unchanged.
  • A subsequent integration run found a stale codec import in task-identifier tests. All nine cases passed after correcting the import; main now contains the identical correction through fix(ci): use the subagent codec in state migration tests #154014, so the final branch inherits it without a duplicate patch.
  • Independent review through P2 is clean. ClawSweeper revision 3 is ready on a405f038 with no remaining findings; its test-cost reporting request is resolved.
  • Current-head CI run 35537743091 passed, and both required openclaw/ci-gate checks are successful.
  • No live Gateway configuration, credentials, or service lifecycle was changed.

Test cost

Measured on macOS with Node 26.8.2 and OPENCLAW_VITEST_MAX_WORKERS=1. Wrapper wall time includes startup and any compiler preparation; these are observed runs, not a warm-cache speed comparison.

Selected coverage Result Vitest duration Wrapper wall time
Shared scope, method policy, event delivery, and continuation authorization 298 passed 0.219 s shared + 50.08 s Gateway 53.93 s
Extracted authorization and continuation suites 41 passed 34.11 s 38.35 s
Original lane-selection case plus present/deleted Stylelint CLI fixtures 3 passed, 351 unselected 1.22 s 2.43 s
Task-identifier suite after the codec import correction 9 passed 19.51 s 22.82 s

Available job wall times from successful run 35535929857 on af6f73b7 before the final main reconciliation (including setup and other tests in each shard): test types core 2 passed in 4m24s; task-identifier shard passed in 4m40s; tooling shard passed in 7m48s.

@clawsweeper

clawsweeper Bot commented Sep 20, 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 size: S maintainer Maintainer-authored PR labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 19:25
@github-actions

github-actions Bot commented Sep 20, 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: a405f038382da469c1b02c2c313cc0f7735c61bd
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/method-scopes.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/shared/operator-scope-compat.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 5:18 PM ET / 21:18 UTC (Revision 3).

ClawSweeper review

What this changes

The PR shares operator permission checks across Gateway calls and event delivery, extends background-continuation coverage, documents the behavior, and isolates Stylelint test fixtures.

Merge readiness

✅ Ready for maintainer review

No blocking findings remain. The previous test-cost request is addressed, and this maintainer-requested consolidation remains distinct from the already-merged continuation fix.

Priority: P3
Reviewed head: a405f038382da469c1b02c2c313cc0f7735c61bd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused consolidation with useful boundary coverage, resolved review feedback, and no blocking correctness findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-author exemption applies to this behavior-preserving refactor; the reported 298-test run includes real Gateway dispatch boundaries with mocked model execution and status responses, and no material authority change requires additional final-effect proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-author exemption applies to this behavior-preserving refactor; the reported 298-test run includes real Gateway dispatch boundaries with mocked model execution and status responses, and no material authority change requires additional final-effect proof.
Evidence reviewed 9 items Introduced production change preserves permission semantics: The introduced patch replaces duplicated scope predicates with the existing shared policy. RPC requirements belong to the closed operator-scope set; plugin event scopes are validated as read, write, or admin before broadcast. Transport grants remain exact, and role-level normalization remains in its existing adapter.
Authorization and queued-delivery safeguards remain: The broadcaster still excludes worker and non-operator clients where required, checks current recipient scopes, and re-enters those checks when draining queued events. Existing tests cover scope revocation before pending sends, and continuation authorization tests retain expired-authority and foreign-session rejection cases. The refactor does not materially change authority recipients or lifetimes.
Previous review request resolved: The captured PR body now reports single-worker wrapper times of 53.93 seconds for the 298-test selection, 38.35 seconds for extracted authorization/continuation suites, and 2.43 seconds for the three selected tooling cases, plus available CI job durations. This addresses the previous review's sole concrete rank-up request; those measurements are contributor-reported, not rerun during this read-only review.
Findings None None.
Security None None.

How this fits together

The Gateway checks operator permissions before dispatching requests or delivering events. The shared policy evaluates granted scopes while existing identity, session-access, and execution-lifetime checks remain with their owners.

flowchart TD
  A[Authenticated Gateway calls] --> D[Shared operator permission policy]
  B[Background tool calls] --> D
  C[Outgoing Gateway events] --> D
  D --> E[Identity and session checks]
  E --> F[Authorized handler or recipient]
  D --> G[Reject insufficient permission]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -24, Tests +86, Docs +8. Total +70 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 3 21 45 -24
Tests 6 242 156 +86
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 271 201 +70

Review metrics

None.

Technical review

Best possible solution:

Keep one shared scope-implication owner while preserving transport matching, role normalization, and existing session and lifetime enforcement.

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

Not applicable: this PR consolidates existing behavior; source comparison supports equivalent permission decisions, and no new failure was identified.

Is this the best way to solve the issue?

Yes. Reusing the existing predicate removes competing permission logic without adding a new API contract, configuration option, or migration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6b1495903b21.

Labels

Label justifications:

  • P3: This is a behavior-preserving consolidation following an already-merged incident fix, with focused regression and fixture maintenance.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-author exemption applies to this behavior-preserving refactor; the reported 298-test run includes real Gateway dispatch boundaries with mocked model execution and status responses, and no material authority change requires additional final-effect proof.

Evidence

What I checked:

  • Introduced production change preserves permission semantics: The introduced patch replaces duplicated scope predicates with the existing shared policy. RPC requirements belong to the closed operator-scope set; plugin event scopes are validated as read, write, or admin before broadcast. Transport grants remain exact, and role-level normalization remains in its existing adapter. (src/shared/operator-scope-compat.ts:10, a405f038382d)
  • Authorization and queued-delivery safeguards remain: The broadcaster still excludes worker and non-operator clients where required, checks current recipient scopes, and re-enters those checks when draining queued events. Existing tests cover scope revocation before pending sends, and continuation authorization tests retain expired-authority and foreign-session rejection cases. The refactor does not materially change authority recipients or lifetimes. (src/gateway/server-broadcast.ts:172, a405f038382d)
  • Previous review request resolved: The captured PR body now reports single-worker wrapper times of 53.93 seconds for the 298-test selection, 38.35 seconds for extracted authorization/continuation suites, and 2.43 seconds for the three selected tooling cases, plus available CI job durations. This addresses the previous review's sole concrete rank-up request; those measurements are contributor-reported, not rerun during this read-only review. (af6f73b7ea34)
  • Review continuity verified by file identity: The complete GitHub tree for the previous reviewed revision was retrieved without truncation. All ten currently introduced paths have identical blob IDs at that revision and the current checkout. This independently supports the PR body's claim that reconciliation preserved the reviewed task-file bytes. (af6f73b7ea34)
  • Still distinct from main and the latest release: Fetched main retains the separate RPC and broadcast implementations. The v2026.9.5 source also retains the separate RPC predicate. The merged continuation repair at fix: background continuations lose session access and GitHub tools #141865 already addressed synthetic scope narrowing, but did not perform this consolidation. (src/gateway/method-scopes.ts:272, 6b1495903b21)
  • Proof scope and trusted-author exemption: The continuation test exercises the real completion dispatcher, Gateway facade, RPC permission owner, and GitHub identity tool, with model execution and the status response mocked. This is supplemental boundary coverage, not live GitHub proof. Repository State identifies a MEMBER author, and the supplied security guard records repository admin authority on the pinned head; the ordinary external-contributor proof gate does not apply. (src/gateway/server-plugin-in-process-dispatch.continuation.test.ts:34, a405f038382d)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; 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-20T19:50:04.278Z sha 480d02d921c1cc75700454b9c7a8dedaa0ff493c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T20:46:49.785Z sha af6f73b7ea3469b200048f5249aaca91c96ea59d :: needs changes before merge. :: none

@steipete
steipete force-pushed the codex/unify-operator-scope-authority branch 3 times, most recently from 8e6a344 to af6f73b Compare September 20, 2026 20:33
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 20, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added the requested single-worker measurements and available final-head CI job durations to the PR's Test cost section. Both repaired CI lanes are green. The code remains unchanged at af6f73b7ea3469b200048f5249aaca91c96ea59d.

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Use the existing shared operator-scope policy for RPC and broadcast authorization, keeping raw transport grants exact and avoiding per-recipient allocations. Extend completion-dispatch coverage through the GitHub identity status tool and preserve denial of stronger privileges. Follow-up to #141865.
Keep completion and GitHub identity regressions together in a sibling suite and share the existing Gateway fixtures, preserving coverage within the file-size gate.
The lane-routing test assumed a UI test path was absent; adding that file on main correctly changed the Stylelint plan. Preserve lane assertions and exercise present/deleted files in an owned fixture through the real dry-run CLI.
@steipete
steipete force-pushed the codex/unify-operator-scope-authority branch from af6f73b to a405f03 Compare September 20, 2026 21:08
@steipete
steipete merged commit 68a2efb into main Sep 20, 2026
229 of 230 checks passed
@steipete
steipete deleted the codex/unify-operator-scope-authority branch September 20, 2026 21:32
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
…penclaw#153979)

* refactor: share operator permissions across Gateway calls and events

Use the existing shared operator-scope policy for RPC and broadcast authorization, keeping raw transport grants exact and avoiding per-recipient allocations. Extend completion-dispatch coverage through the GitHub identity status tool and preserve denial of stronger privileges. Follow-up to openclaw#141865.

* test: separate continuation authorization coverage

Keep completion and GitHub identity regressions together in a sibling suite and share the existing Gateway fixtures, preserving coverage within the file-size gate.

* test: isolate changed Stylelint targets from checkout contents

The lane-routing test assumed a UI test path was absent; adding that file on main correctly changed the Stylelint plan. Preserve lane assertions and exercise present/deleted files in an owned fixture through the real dry-run CLI.
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 maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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