Skip to content

fix(gateway): keep session access and Stop bound to the original caller - #154991

Merged
vincentkoc merged 17 commits into
mainfrom
fix/visitor-authority-followup-20260921
Sep 22, 2026
Merged

vincentkoc merged 17 commits into
mainfrom
fix/visitor-authority-followup-20260921

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Session-scoped operators can be blocked from their own conversations, and delayed Stop work can cancel a replacement run after the original target or caller authority changes. Accepted child creation can also lose its source authority when the parent request finishes.

User Impact

Session-only callers can read permitted conversations, create and modify their own sessions, and stop their original work without gaining global configuration or catalog access. Shared viewing and existing broad operator, administrator and trusted internal behavior remain supported.

This is an authorization foundation. Question access, filtered catalogs and optional model/action restrictions are separate follow-ups. No new configuration, protocol or storage schema is introduced. Deployment, native sandbox and recovery qualification remain separate.

Why This Change Was Made

Request and cancellation owners retain the original caller, admitted scope, exact session incarnation and captured run entries through delayed work and commit boundaries. Accepted children survive normal parent closure while source revocation still denies later effects. Stop preserves successor runs and queued work, completes already-detached cleanup, and cannot overwrite a replacement run's outcome.

The integration preserves main's asynchronous worker inventory, committed state publication, continuation source lifetime and final release. Its continuation caller uses the canonical three-argument resolver so synthetic scopes, system-source classification and the Gateway resolver remain intact. Shared read/frame/type helpers replace duplicated ownership checks.

Related contributor work by @shakkernerd: #153987

Evidence

  • Signed candidate 1da6fe2c4cdc373e1a1158b5c5189492f369870e, tree f07086c10238666d7f0062ab07d69e9a4f9009ca, integrates frozen main 73f058a4e653471383c473a93571f043ddc05587. Native source transport verifies every selected file and binds source, tree, comparison base and carrier before execution.
  • 142/142 focused Linux tests across ten files: 80 worker/inference/store/Stop tests in seven files (63.19s), and 62 release-fixture/cohort tests in three files (8.34s). The current canonical main fixtures and all original provenance, restoration and migration-order assertions are preserved.
  • Production core types and targeted formatting passed. The full Linux build passed in 7m22.5s. Enforcing UI comparison against frozen 73f058a passed: startup JavaScript 369,888 B under the unchanged 370,876 B limit; CSS 51,165 B → 51,165 B, no growth. The CSS advisory target remains a warning; hard limits are unchanged. All 1,016 finalized sidecars were verified. Exact-source native Testbox run: command exit 0 and owned lease stopped; workflow lifecycle status is separate from required PR CI.
  • Fresh native P1 AutoReview on this exact candidate against frozen main is scoped-clean. Root and independent owner reviews checked the asynchronous-inventory integration and canonical fixture reconciliation. Exact-head ClawSweeper review and required PR CI are pending; historical results do not qualify those gates.
  • Retained boundary proof includes 100/100 continuation, accepted-child, scope and catalog tests on the previous integrated source; all 32 changed-check commands, full build and enforcing UI comparison passed there. The malformed continuation union produced one intended failure with 12 passing controls. The receipt-identity regression produced two intended failures with two controls before repair, then passed 47/47 across three owner/sibling files. These runs overlap and are not summed. Prior focused proof, prior changed checks/build/UI.
  • The earlier required-CI failure was inherited release-cohort fixture setup. Its repair is now canonical main ancestry and the three owning Linux suites pass above. Provider callbacks are test doubles; no live visitor or production deployment proof is claimed.

Production: 39 files, +2220/-1150 (net +1070); tests/helpers: 30 files, +4260/-157 (net +4103); baseline: -1 line. Test classification includes test/support/helper paths and test/spec/suite files. Production growth supplies original-authority, exact-session lifetime and receipt-identity checks across existing request and cancellation owners; no second registry or public worker API is added.

Admit narrow session operations through verified caller and canonical row ownership, preserving shared reads and independently granted broad authority. Retain the original request through aliases and exact creation handoffs. Fence Stop against replacement queued, active, pending and worker registrations while preserving accepted partials. Keep global model and agent catalogs behind broad read.

Source-reviewed checkpoint. Targeted oxfmt 0.67.0, Node syntax checks and diff checks passed. Runtime and type qualification remain pending in the owned proof controller. Commit hooks skipped under the documented code-only workflow after equivalent formatting and privacy checks; configured content-guard state was preserved.
@vincentkoc vincentkoc self-assigned this Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 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 gateway Gateway runtime size: XL maintainer Maintainer-authored PR labels Sep 21, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 21, 2026 16:12
@github-actions

github-actions Bot commented Sep 21, 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: 1da6fe2c4cdc373e1a1158b5c5189492f369870e
  • Maintainer: @vincentkoc
  • 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/gateway/server-methods.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/chat-abort-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/shared/session-method-scopes-base.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

Move queued Stop ownership selection into its authorization owner, split sharing read projections and session creation contracts, and isolate pure worker frame helpers. Preserve the existing sharing facade, original creation COMMIT handoff, and exact worker registration cancellation bodies. Move Stop currentness cases and persistence assertions without removing coverage.

Root and independent source review accepted the extraction. Line-cap and max-lines ratchets passed on the exact proof copy; the moved suggestion assertion now documents its typed producer. Qualified oxfmt 0.67.0, syntax and diff checks passed. Runtime/type qualification remains pending. Documented code-only hook bypass follows equivalent formatting/privacy checks; staged-content guard configuration remains unchanged.
Correct test ownership and direct-call outcome assertions without changing authorization. Preserve exact queued registration snapshots while applying mechanical lint corrections, and remove the earned obsolete session-sharing assertion baseline entry.

Root and independent source review accepted the exact 13-path repair. Qualified oxfmt 0.67.0, syntax, diff and three cheap ratchet checks passed. Runtime and type qualification remain pending. Use the documented code-only formatting hook route; staged-content guard configuration remains unchanged.
@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 8:46 PM ET / September 22, 2026, 00:46 UTC (Revision 10).

ClawSweeper review

What this changes

The PR preserves the original caller’s permissions and session identity through session access, child creation, queued work, and Stop cancellation.

Merge readiness

✅ Ready for maintainer review

The PR remains necessary and has no actionable findings in the pinned diff. The earlier Stop-adapter finding is fixed, and the supplied boundary proof covers original, foreign, replaced, and revoked authority. Maintainer authorship also excludes automatic closure.

Priority: P2
Reviewed head: 1da6fe2c4cdc373e1a1158b5c5189492f369870e

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong authority-boundary coverage and focused ownership repairs support the patch, with no remaining actionable finding.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The supplied native-run evidence maps to inspected production Gateway, queue, cancellation, and child-input persistence harnesses, covering allowed effects and rejection after foreign ownership, replacement, or revocation. Provider callbacks are doubles; deployment is not claimed. The blocked raw-log redirect is a reviewer limitation, not missing contributor proof.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The supplied native-run evidence maps to inspected production Gateway, queue, cancellation, and child-input persistence harnesses, covering allowed effects and rejection after foreign ownership, replacement, or revocation. Provider callbacks are doubles; deployment is not claimed. The blocked raw-log redirect is a reviewer limitation, not missing contributor proof.
Evidence reviewed 9 items Pinned review identity: The checkout matches the requested head and records the previous reviewed head followed by frozen main as its raw parents. Review ownership uses the supplied merge-base-to-head delta; the stale GitHub test merge was not used to infer removals.
Central repair remains absent from main: Fetched main still authorizes these methods through their broad required scopes without the PR’s session-scope alternative. No merged replacement fixing the complete requested behavior was established.
Established restricted-role contract: Visitor Access already specifies session-only scopes and explicitly separates invitation policy from Gateway session/tool qualification. The merged related contribution #153987 supplies adjacent invitation behavior, not a replacement for this Gateway repair.
Findings None None.
Security None None.

How this fits together

The Gateway authorizes requests from connected clients and hosted agent tools before passing them to session, queue, and worker owners. These changes keep delayed reads, writes, and cancellation tied to the caller and session originally authorized.

flowchart TD
  A[Client or agent tool] --> B[Gateway scope admission]
  B --> C[Original caller and session binding]
  C --> D[Session reads and writes]
  C --> E[Queued work and accepted children]
  C --> F[Stop target capture]
  E --> G[Current authority check]
  F --> G
  G --> H[Commit or cancel original work]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +1070, Tests +4103, Other -1. Total +5172 across 70 files.

View PR surface stats
Area Files Added Removed Net
Source 39 2220 1150 +1070
Tests 30 4260 157 +4103
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 70 6480 1308 +5172

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +1070 lines; tests/helpers net +4103 lines The stated growth supports authority and exact-target checks across existing owners, with substantial boundary regression coverage.

Technical review

Best possible solution:

Keep authorization and cancellation with the existing Gateway and lifecycle owners, preserving broad grants while binding narrow operations to the original person and session.

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

Yes, from source: current main rejects session-only grants where these methods require broad read/write scopes. The cancellation regressions have concrete production-boundary fixtures, but this read-only review did not execute them.

Is this the best way to solve the issue?

Yes. The patch extends existing admission, persistence, and cancellation owners rather than introducing competing authority state, and preserves independently granted broad access.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 000a635e3423.

Labels

Label justifications:

  • P2: This repairs restricted-session access and cancellation races without evidence of a widespread active outage.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The supplied native-run evidence maps to inspected production Gateway, queue, cancellation, and child-input persistence harnesses, covering allowed effects and rejection after foreign ownership, replacement, or revocation. Provider callbacks are doubles; deployment is not claimed. The blocked raw-log redirect is a reviewer limitation, not missing contributor proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied native-run evidence maps to inspected production Gateway, queue, cancellation, and child-input persistence harnesses, covering allowed effects and rejection after foreign ownership, replacement, or revocation. Provider callbacks are doubles; deployment is not claimed. The blocked raw-log redirect is a reviewer limitation, not missing contributor proof.

Evidence

What I checked:

  • Pinned review identity: The checkout matches the requested head and records the previous reviewed head followed by frozen main as its raw parents. Review ownership uses the supplied merge-base-to-head delta; the stale GitHub test merge was not used to infer removals. (1da6fe2c4cdc)
  • Central repair remains absent from main: Fetched main still authorizes these methods through their broad required scopes without the PR’s session-scope alternative. No merged replacement fixing the complete requested behavior was established. (src/gateway/method-scopes.ts:277, 000a635e3423)
  • Established restricted-role contract: Visitor Access already specifies session-only scopes and explicitly separates invitation policy from Gateway session/tool qualification. The merged related contribution feat: validate visitor permissions before granting access #153987 supplies adjacent invitation behavior, not a replacement for this Gateway repair. (extensions/visitor-access/README.md:70, 1da6fe2c4cdc)
  • Prior Stop finding resolved: The sessions.abort adapter forwards the original handler authority into chat cancellation. Supplemental timeout publication also compares the captured receipt entry before replacing an outcome. (src/gateway/server-methods/sessions-abort.ts:593, 1da6fe2c4cdc)
  • Continuation integration retained: The continuation path passes the canonical three resolver arguments, retains the captured operator source, and releases it in finally. Targeted comparison with the previous reviewed head showed no changes to this file or the inference manager. (src/gateway/server-plugin-in-process-dispatch.ts:165, 1da6fe2c4cdc)
  • Stop final-effect coverage: The inspected harness enters the real Gateway router and cancellation/queue owners with stored session entries and AbortControllers. Assertions cover successful original-target cancellation, preservation of foreign work and successors, revocation before later effects, and settlement of already-detached work. (src/gateway/server-methods/sessions.abort-queue-authority.test.ts:107, 1da6fe2c4cdc)

Likely related people:

  • shakkernerd: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: 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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-21T19:00:20.754Z sha 2fa2098 :: needs changes before merge. :: none
  • reviewed 2026-09-21T19:18:30.170Z sha 2fa2098 :: needs changes before merge. :: none
  • reviewed 2026-09-21T21:14:35.594Z sha 9348634 :: needs changes before merge. :: none
  • reviewed 2026-09-21T22:26:47.469Z sha 43af373 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-21T22:41:23.455Z sha 43af373 :: needs changes before merge. :: none
  • reviewed 2026-09-21T23:30:16.441Z sha b7b208b :: needs changes before merge. :: none
  • reviewed 2026-09-21T23:41:29.777Z sha b7b208b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-22T00:10:19.027Z sha bc594d0 :: blocked before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 21, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Updated head: 2fa2098c3ee00a87249d3f157897c9b6c72e5132. The PR body records the authority repairs, 390 passing runtime tests, native changed checks, full build and enforcing UI comparison.

Both prior rank-up moves are covered: sessions.abort retains the admitted narrow authority and original target through its fast paths. The passing alias fixtures dispatch through the real Gateway router into the cancellation and queue owners with SQLite session entries and real AbortControllers; provider callbacks are test doubles.

Observed boundary outcomes: an allowed original target stops; foreign and previous-incarnation targets remain untouched; a successor created by an earlier callback remains untouched for narrow Stop; source revocation prevents subsequent Stop effects; detached cleanup still settles and unrelated queued work remains runnable. These are runtime fixture results, not a production deployment claim.

@clawsweeper

clawsweeper Bot commented Sep 21, 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:

@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 21, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Updated head: 62287ceeffa1d320c9542395a52564f66e5e3b20. The PR body records the merged-main authority integration, 465 distinct runtime passes, completed native changed checks, full build and enforcing UI comparison. Native Testbox command evidence is separate from the PR's required CI.

Both prior rank-up moves are covered: sessions.abort retains the admitted narrow authority and original target through its fast paths. The passing alias fixtures dispatch through the real Gateway router into the cancellation and queue owners with SQLite session entries and real AbortControllers; provider callbacks are test doubles.

Observed boundary outcomes: an allowed original target stops; foreign and previous-incarnation targets remain untouched; a successor created by an earlier callback remains untouched for narrow Stop; source revocation prevents subsequent Stop effects; detached cleanup still settles and unrelated queued work remains runnable. Accepted children survive normal parent closure but reject inherited invocation or authorization-policy revocation. These are runtime fixture results, not a production deployment claim.

@clawsweeper

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

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 1da6fe2c4cdc373e1a1158b5c5189492f369870e, integrating frozen main 73f058a4e653471383c473a93571f043ddc05587. Independent source review checked the asynchronous worker inventory and canonical release-fixture union. Fresh native P1 review is scoped-clean; exact-tree Linux proof passed 142 tests across ten files, production core types, full build and the enforcing UI comparison. The body separates retained earlier proof from new-head required CI, which remains pending. No automatic merge is enabled.

@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc
vincentkoc merged commit da27b33 into main Sep 22, 2026
203 of 204 checks passed
@vincentkoc
vincentkoc deleted the fix/visitor-authority-followup-20260921 branch September 22, 2026 01:06
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
…er (openclaw#154991)

* fix(gateway): bind narrow session authority to exact Stop targets

Admit narrow session operations through verified caller and canonical row ownership, preserving shared reads and independently granted broad authority. Retain the original request through aliases and exact creation handoffs. Fence Stop against replacement queued, active, pending and worker registrations while preserving accepted partials. Keep global model and agent catalogs behind broad read.

Source-reviewed checkpoint. Targeted oxfmt 0.67.0, Node syntax checks and diff checks passed. Runtime and type qualification remain pending in the owned proof controller. Commit hooks skipped under the documented code-only workflow after equivalent formatting and privacy checks; configured content-guard state was preserved.

* refactor(gateway): split session authority owner modules

Move queued Stop ownership selection into its authorization owner, split sharing read projections and session creation contracts, and isolate pure worker frame helpers. Preserve the existing sharing facade, original creation COMMIT handoff, and exact worker registration cancellation bodies. Move Stop currentness cases and persistence assertions without removing coverage.

Root and independent source review accepted the extraction. Line-cap and max-lines ratchets passed on the exact proof copy; the moved suggestion assertion now documents its typed producer. Qualified oxfmt 0.67.0, syntax and diff checks passed. Runtime/type qualification remains pending. Documented code-only hook bypass follows equivalent formatting/privacy checks; staged-content guard configuration remains unchanged.

* test(gateway): align session authority regression fixtures

Correct test ownership and direct-call outcome assertions without changing authorization. Preserve exact queued registration snapshots while applying mechanical lint corrections, and remove the earned obsolete session-sharing assertion baseline entry.

Root and independent source review accepted the exact 13-path repair. Qualified oxfmt 0.67.0, syntax, diff and three cheap ratchet checks passed. Runtime and type qualification remain pending. Use the documented code-only formatting hook route; staged-content guard configuration remains unchanged.

* fix(gateway): retain accepted child input authority beyond spawning calls

* fix(gateway): preserve exact session authority through Stop aliases

* fix(gateway): preserve narrow session grants in hosted dispatch

* fix(gateway): narrow captured Stop owner before key checks

* test(gateway): type the child custody message hook

* test(gateway): await retained descendant scheduler start

* test(gateway): assert committed child admission failure

* test(gateway): align abort fixtures with bound session targets

* fix(gateway): preserve successor receipts during session abort

* test(e2e): prepare survivor fixtures for release cohorts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. security-sensitive-changed size: XL 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