Skip to content

feat: support narrowly scoped Gateway publication readers - #201073

Merged
vincentkoc merged 3 commits into
mainfrom
feat/session-share-reader-host-20261118
Nov 18, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
feat/session-share-reader-host-20261118

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

A Gateway needs a way to admit a publication-reader device without giving it a person's private access or ordinary operator powers.

User Impact

No sessions are published by this change alone. Ordinary operator and paired-node access remain unchanged.

Why This Change Was Made

Adds a closed signed-device admission and SDK attestation for exactly operator.session-share.read. The stored token and requested scope must both be singleton. Human profiles, private RPCs, scope upgrades, broadcasts and writes remain unavailable. A source plugin must separately grant a device and choose what to publish.

This is the inert foundation of the Session Share read stack; it adds no reader transport or UI polling.

Evidence

The host-only candidate passed 121 tests across four files, scoped typechecking/lint/config checks, a full pnpm build, and production SDK declaration smoke checks. Tests exercise signed admission, denied private methods and late-response suppression after credential authority changes.

The earlier formal review raised one finding; it was adjudicated against the actual four-argument wrapper and rejected. It is not being represented as an originally finding-free review. Independent review of the reconstructed exact slices subsequently accepted publication.

No steering or reader write privilege is included. No live deployment was performed.

Exact revision and proof entry points
  • Reviewed head: 9791bcc978653f1ddb25beef5bf49c93e4327269
  • Reviewed base: d59d976e74c07ac69d37d038cba9e9ebde6545aa
  • Tree: 1ec65f83dc9addffdf2efeff5cfdac1ad3c27019
  • Delta: 20 files, +763/−13.

Focused runs used node scripts/run-vitest.mjs with isolated repository-suite configurations, maxWorkers: 1 and file parallelism disabled, selecting:

  • src/gateway/server.auth.publication-reader.test.ts
  • src/gateway/server-methods.dispatch-authorization.test.ts
  • src/gateway/method-scopes.own-session.test.ts
  • src/gateway/server-broadcast.transport.test.ts

SDK command: node --import ./scripts/tsx.mjs scripts/build-all.mts pluginSdkStrictSmoke.

Full-build command: pnpm build (host-only tree for slice 1; identical cumulative frozen tree for slice 4).

Stack order

1/4: inert host capability → device-granted source reads → outbound reader → visible polling. Targets main; its reviewed pinned base is above. Later main commits are not part of this head.

@clawsweeper

clawsweeper Bot commented Nov 18, 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 plugin: file-transfer size: L labels Nov 18, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 18, 2026 07:46
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 5678d5a2aad0aaafb06ea027ccd58ec74ef05791
  • Maintainer: @vincentkoc
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/operator-scopes.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server-methods/method-authorization.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/authenticated-request-dispatch.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-auth.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-device-pairing.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-model-catalog.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-operator-access.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-publication-reader.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/connect-session.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/gateway/server/ws-connection/message-handler-types.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-approval.kernel.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-core.kernel.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-identity.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-publication.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-roles.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-state.kernel.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.
  • src/infra/device-pairing-tokens.kernel.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR adds signed, device-only Gateway admission and an SDK attestation for narrowly scoped publication readers.

Example: A paired device requests only operator.session-share.read.

  • Before: The Gateway has no dedicated publication-reader admission path separate from ordinary operator identity.
  • After: The device receives a stripped hello and can call only independently registered publication-reader methods.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The feature has clear value, but the credential-revocation defect, introduced architecture failure, and harness-only proof prevent readiness.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: A remote publication reader needs a device identity without inheriting a person's private access or ordinary operator powers.
Reason: The maintainer-authored direction supplies a missing host boundary for the concrete dependent source-plugin work while leaving publication itself plugin-owned.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open: this maintainer-approved capability has a concrete consumer, but the patch loses shared-credential revocation and introduces a static import cycle.

Priority: P2
Reviewed head: 9791bcc978653f1ddb25beef5bf49c93e4327269

Before merge

  • Preserve the reader token's shared-auth generation binding (P1) - An administrator can narrow an existing browser device token to ["operator.session-share.read"] using device.token.rotate; rotateDeviceTokenInWorker preserves its shared-gateway-auth issuer. Authentication correctly records that issuer in state.sessionUsesSharedGatewayAuth and state.sessionSharedGatewaySessionGeneration, but this attachment hardcodes false and drops the generation. After shared credentials rotate without immediate process exit, disconnectStaleSharedGatewayAuthClients skips this client and dispatch skips its generation check. The paired token and identity remain unchanged, so the reader can start further registered reads even though reconnecting with that token is rejected as issuer-generation-stale. Copy the authenticated generation fields as ordinary client attachment does, and cover a new request after rotation.
  • Break the new pairing-publication import cycle (P2) - This value import creates device-pairing-publication → device-pairing-identity → device-pairing-state.kernel → device-pairing-store → device-pairing-publication. The exact-head architecture check reports both import-cycle guards failing. Keep the existing identity policy, but separate its pure role-normalization dependencies from the mutation-loading kernel so publication validation does not import its own storage consumer; do not suppress the cycle check.
  • Resolve security concern: Revoked issuer generation remains usable on an established reader - The affected principal is a reader using a shared-auth-issued device token; subsequent publication RPCs remain reachable after shared-auth rotation because both client invalidation and dispatch generation checks depend on metadata discarded during attachment.

Findings

  • [P1] Preserve the reader token's shared-auth generation binding — src/gateway/server/ws-connection/connect-publication-reader.ts:53-54
  • [P2] Break the new pairing-publication import cycle — src/infra/device-pairing-publication.ts:10
  • [high] Revoked issuer generation remains usable on an established reader — src/gateway/server/ws-connection/connect-publication-reader.ts:53

Tests

  • Missing end-to-end proof: Supply a redacted terminal capture or logs from a running Gateway showing signed reader admission, an allowed registered read, denied private RPCs, and rejection of new reads after shared-auth rotation.
Agent review details

How this fits together

Gateway WebSocket admission consumes signed device credentials and requested scopes, then supplies restricted RPC access and device attestation to source plugins that separately authorize published data.

flowchart LR
  A[Paired reader] --> B[Device token owner]
  B --> C[Reader admission]
  C --> D[RPC authorization]
  D --> E[SDK attestation]
  E --> F[Source plugin]
Loading

Technical review

Best possible solution:

Preserve the device-only lane while carrying its authenticated shared-generation binding and keeping token identity checks independent of mutation-store imports.

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

Source establishes both the new import cycle and the issuer-bound token path that escapes shared-auth invalidation; no target code was executed.

Is this the best way to solve the issue?

The narrow host seam fits the source-plugin consumer, but it must reuse existing credential-lifetime metadata and avoid importing mutation storage into publication validation.

Full review comments:

  • [P1] Preserve the reader token's shared-auth generation binding — src/gateway/server/ws-connection/connect-publication-reader.ts:53-54
    An administrator can narrow an existing browser device token to ["operator.session-share.read"] using device.token.rotate; rotateDeviceTokenInWorker preserves its shared-gateway-auth issuer. Authentication correctly records that issuer in state.sessionUsesSharedGatewayAuth and state.sessionSharedGatewaySessionGeneration, but this attachment hardcodes false and drops the generation. After shared credentials rotate without immediate process exit, disconnectStaleSharedGatewayAuthClients skips this client and dispatch skips its generation check. The paired token and identity remain unchanged, so the reader can start further registered reads even though reconnecting with that token is rejected as issuer-generation-stale. Copy the authenticated generation fields as ordinary client attachment does, and cover a new request after rotation.
    Confidence: 0.98
  • [P2] Break the new pairing-publication import cycle — src/infra/device-pairing-publication.ts:10
    This value import creates device-pairing-publication → device-pairing-identity → device-pairing-state.kernel → device-pairing-store → device-pairing-publication. The exact-head architecture check reports both import-cycle guards failing. Keep the existing identity policy, but separate its pure role-normalization dependencies from the mutation-loading kernel so publication validation does not import its own storage consumer; do not suppress the cycle check.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 74e5127c0c3d.

Provenance checked

  • Operator device-source identity keeps the original intent (961f5c0: Preserve the exact accepted credential through operator restart recovery and reject replacement credentials discovered during preparation.)
  • Committed pairing publication keeps the original intent (05117d9: Move pairing database access into workers while retaining committed owner facts for synchronous authority checks.)
  • Scoped broadcasts keeps the original intent (282fc78: Provide scoped session reading and organization without granting broad operator access.)

Testing

Proof path: in-process harness.

Security

Needs attention: The reader attachment drops an existing credential-revocation boundary.

Evidence

Security concerns:

  • [high] Revoked issuer generation remains usable on an established reader — src/gateway/server/ws-connection/connect-publication-reader.ts:53
    The affected principal is a reader using a shared-auth-issued device token; subsequent publication RPCs remain reachable after shared-auth rotation because both client invalidation and dispatch generation checks depend on metadata discarded during attachment.
    Confidence: 0.98

What I checked:

PR surface

Source +417, Tests +307, Docs +26, Generated 0. Total +750 across 20 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 17 428 11 +417
Tests 1 307 0 +307
Docs 1 26 0 +26
Config 0 0 0 0
Generated 1 2 2 0
Other 0 0 0 0
Total 20 763 13 +750

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
New authority surface 1 reserved operator scope and 1 versioned SDK preparer Adds a public device-only admission contract without a new configuration key or default.

Labels

Label changes:

  • add P2: A useful, opt-in feature foundation needs repair before it ships; no current-release incident is established.
  • add merge-risk: 🚨 compatibility: The PR introduces a public SDK admission contract and currently fails to preserve an existing device-token lifecycle guarantee.
  • add merge-risk: 🚨 security-boundary: An issuer-bound reader connection can retain access for new requests after its shared-auth generation is revoked.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: A useful, opt-in feature foundation needs repair before it ships; no current-release incident is established.
  • merge-risk: 🚨 security-boundary: An issuer-bound reader connection can retain access for new requests after its shared-auth generation is revoked.
  • merge-risk: 🚨 compatibility: The PR introduces a public SDK admission contract and currently fails to preserve an existing device-token lifecycle guarantee.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 18, 2026, 3:05 AM ET / 08:05 UTC.

@vincentkoc
vincentkoc merged commit 5795128 into main Nov 18, 2026
140 checks passed
@vincentkoc
vincentkoc deleted the feat/session-share-reader-host-20261118 branch November 18, 2026 09:08
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…01073)

* feat: support narrowly scoped Gateway publication readers

* fix: keep paired-device identity imports acyclic

* fix: preserve publication reader credential generation

Co-authored-by: Vincent Koc <[email protected]>
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: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. security-sensitive-changed size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant