Skip to content

feat(gateway): scope guest sessions to explicit invitations - #177257

Closed
vincentkoc wants to merge 1 commit into
mainfrom
fix/guest-session-access-20261019
Closed

vincentkoc wants to merge 1 commit into
mainfrom
fix/guest-session-access-20261019

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Fixes #135631

What Problem This Solves

Guest roles currently have no invitation-only session view: allowing foreign-session reads exposes unrelated conversations, while sessions.others: "none" also blocks explicit members.

User Impact

Operators can set gateway.roles.definitions.guest.sessions.others to "invited", assign the intended profiles, and reconnect them. Guests see their own sessions and foreign sessions where they are members. A creator or administrator can invite a guest by selecting a human @mention and sending the message.

Review decision: public access continues through existing sanitized published transcript links. Ordinary shared visibility does not put a session in a guest's sidebar or expose its raw history and files.

Existing role definitions keep their behavior. Invitation membership does not grant operator scopes: operator.sessions.write still permits changes to the caller's own sessions only. No live server configuration is changed by this PR.

Why This Change Was Made

Use the existing session membership store as the authority across lists, search, direct reads, events, and session resources. Apply the cap even to broad read/write connections; administrators retain their existing access.

Only a creator/admin's selected mentions in the committed original human input grant membership. Plain text, assistant output, rejected selections, and other participants cannot invite. Draft/incognito restrictions remain in force. Removing membership revokes access, and replaying an old message cannot restore it after a restart.

Membership and the existing mention watermark commit together without a schema-version change. The composer explains invitation behavior, and the sender receives a visible notice if a post-ACK invitation cannot be confirmed.

Evidence

  • 275 focused tests passed across gateway/storage access, invitation lifecycle, UI, and the responsive mention picker.
  • Core/UI and affected test typechecks, targeted lint/formatting, protocol/mobile coverage, configuration docs, UI catalogs, and the line-cap check passed.
  • Full pnpm build passed.
  • Pre-PR validation used an isolated Blacksmith Testbox run. PR CI remains unqualified; live Team rollout is untested.

Real Control UI against a synthetic Gateway fixture.

Before:

Before: guest mention notification label

After:

After: guest mention invitation label

A post-ACK invitation failure stays visible to the sender:

Invitation failure notice

Implementation and validation scope

The production increase implements one permission boundary and carries canonical membership through its existing readers; it does not introduce a second ACL store. Production +621 LOC; tests +635 LOC; docs/generated metadata +41 LOC.

Focused coverage includes broad and session-only scopes, membership removal, draft changes, cache/event filtering, queued-input commit, approval rewriting, non-manager attempts, transaction rollback, restart/replay, and visible failure reporting.

Independent P0/P1 autoreview found no findings. Subsequent fixes address validation fixtures, typing, lint, and the mobile event-coverage declaration.

Validation used the repository's run-vitest, run-tsgo-core-test-shards, and scoped run-oxlint wrappers, plus protocol:check, check:protocol-coverage, config:docs:check, ui:i18n:verify, lint:docs, the line-cap ratchet, and pnpm build.

The local Testbox wrapper could not load its pinned tooling. Remote validation used the installed CLI on the same Testbox, with candidate file hashes verified before and after execution. The build covers the final production source; the subsequent change only types a test assertion without changing its expected behavior.

@vincentkoc vincentkoc self-assigned this Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 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 app: web-ui App: web-ui gateway Gateway runtime scripts Repository scripts size: XL labels Oct 19, 2026
@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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 19, 2026
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Adds opt-in invitation-only session access and lets creators or administrators grant membership through selected human mentions.

Example: Alice invites Bob to agent:main:marketing while agent:main:credentials remains unrelated.

  • Before: Bob must either see all non-draft sessions with view or see no foreign sessions with none.
  • After: With invited, Bob can see marketing while he remains a member, without seeing credentials.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The direction is useful and uses existing owners, but a definite Visitor Access integration failure blocks the patch and the security-boundary proof remains incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Team operators cannot expose only explicitly invited conversations without exposing unrelated non-draft sessions.
Reason: Multiple deployment reports establish value, and the maintainer-authored PR supplies direction for an opt-in mode that preserves existing role semantics.

Merge readiness

⛔ Blocked before merge - 7 items remain

Keep open: this maintainer-authored PR addresses a concrete collaboration need, but the newly documented guest configuration is rejected by Visitor Access.

Priority: P2
Reviewed head: aa973a4610275eca922fd8911bcd2d84e77d382c

Before merge

  • Add real behavior proof - Authority-chain proof required: the inspected screenshots establish composer wording and the failure notice against a synthetic Gateway fixture; tests exercise handlers and stores, but no supplied runtime trace shows an authorized creator granting membership, a non-manager failing to grant it, and nonmember or revoked guests denied history, files, and events before final effects, including queued commit and restart/replay. Provide redacted Gateway output or logs for those cases, omitting credentials, IPs, and non-public endpoints; latest-stable upgrade evidence preserving existing roles, memberships, and replay watermarks is also absent. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Teach Visitor Access to accept the documented invited role (P1) - Following this revised Team Server example makes visitor_invite fail for both new invitations and renewals: createVisitorAccessReader.assertInvitable calls resolveVisitorRole, whose isRestrictedVisitorRole still requires sessions.others === "view" in extensions/visitor-access/src/roles.ts:24. The configuration passes the new core schema but is rejected before the visitor grant is updated. Extend the existing plugin validator to accept invited while preserving supported view configurations, update its guidance, and cover invitation and renewal with the documented role.
  • Resolve security concern: Qualify durable invitation authority - The grant producer rechecks creator/admin authority and the worker commits membership with its replay watermark, but supplied runtime evidence does not demonstrate rejection of a non-manager sender or a revoked/nonmember recipient before final persistence and disclosure; this is an evidence gap, not a demonstrated bypass.
  • Resolve merge risk - Before merge, establish that durable mention-based grants cannot disclose session data to nonmembers or retain revoked authority through queued and replayed work.
  • Improve patch quality - Add final-effect proof for non-manager senders and nonmember guests, and prove revocation invalidates queued or replayed authority before persistence and disclosure.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.
  • Explain or restore the original intent of Visitor Access role validation - feat: validate visitor permissions before granting access #153987: Visitor invitations validate the configured restricted role before changing grants or provider admission; the revised example fails this retained contract.

Findings

  • [P1] Teach Visitor Access to accept the documented invited role — docs/gateway/team-server.md:271
  • [medium] Qualify durable invitation authority — src/gateway/human-mention-policy.ts:405

Provenance

Tests

  • Missing end-to-end proof: Supplied evidence does not show the real Gateway invitation grant, forbidden-principal and revocation final effects, a latest-stable upgrade preserving config and membership state, or red-on-base execution of the new regressions.
Agent review details

How this fits together

The Gateway combines authenticated profiles, role policy, session metadata, and canonical membership to authorize session discovery, reads, mutations, resources, and events.

flowchart TD
  A[Selected human mention] --> B[Committed input owner]
  B --> C[Current invitation policy]
  C --> D[Membership and watermark transaction]
  D --> E[Committed sharing facts]
  E --> F[Session reads and events]
  F --> G[Guest connection]
Loading

Technical review

Best possible solution:

Keep the opt-in mode on the existing membership owner, align Visitor Access with it, and qualify the complete grant-and-revoke flow.

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

Source establishes both the missing invited-only mode on current main and the Visitor Access rejection of the revised example; no target code was executed.

Is this the best way to solve the issue?

Reusing canonical membership and its committed publication owner is appropriate, but the bundled Visitor Access consumer must support the new role value in the same change.

Full review comments:

  • [P1] Teach Visitor Access to accept the documented invited role — docs/gateway/team-server.md:271
    Following this revised Team Server example makes visitor_invite fail for both new invitations and renewals: createVisitorAccessReader.assertInvitable calls resolveVisitorRole, whose isRestrictedVisitorRole still requires sessions.others === "view" in extensions/visitor-access/src/roles.ts:24. The configuration passes the new core schema but is rejected before the visitor grant is updated. Extend the existing plugin validator to accept invited while preserving supported view configurations, update its guidance, and cover invitation and renewal with the documented role.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Qualify the invitation boundary (recommended)
    Provide Gateway evidence of authorized grants, non-manager rejection, nonmember read/event denial, and revocation before final effects during queued or replayed work.
  2. Keep the feature in draft
    Pause landing until the durable invitation authority can be qualified.

Provenance checked

Testing

Proof path: in-process harness.

Security

Needs attention: Durable mention-based grants change a security boundary whose final-effect behavior is not yet demonstrated.

Evidence

Security concerns:

  • [medium] Qualify durable invitation authority — src/gateway/human-mention-policy.ts:405
    The grant producer rechecks creator/admin authority and the worker commits membership with its replay watermark, but supplied runtime evidence does not demonstrate rejection of a non-manager sender or a revoked/nonmember recipient before final persistence and disclosure; this is an evidence gap, not a demonstrated bypass.
    Confidence: 0.98

What I checked:

PR surface

PR surface statistics unavailable: the file list is incomplete.

Root-cause cluster

Relationship: same_root_cause
Canonical: #135631
Summary: This PR implements the opt-in membership-scoped visibility requested by the linked issue.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a useful opt-in collaboration capability with limited rollout scope.
  • merge-risk: 🚨 compatibility: The newly documented invited guest role fails the bundled Visitor Access validator, blocking invitations and renewals.
  • merge-risk: 🚨 security-boundary: Selected mentions now create durable membership authority that controls disclosure across session transports.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 October 19, 2026, 6:58 AM ET / 10:58 UTC.

@vincentkoc

Copy link
Copy Markdown
Member Author

Superseded by 13 narrow, dependent draft PRs for review.

The stack fixes Visitor Access role acceptance, targeted Inbox invalidations, invitation ownership after run completion, atomic transcript/membership/watermark persistence, the HelloOk cap, and the administrator media exception. It also covers approved-input recovery and retained membership publication.

Validation: 448 focused tests, each intermediate branch's core typecheck, affected UI/test/plugin types, scoped lint/format checks, and the packaged runtime/UI build passed. The final tree matches the validated source. The root still conflicts with newer main; restacking, hosted CI, live Team-server and latest-stable upgrade qualification remain before landing.

Closing this monolithic draft in favor of the linked stack; its branch and discussion remain available.

@vincentkoc vincentkoc closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui 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. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Session list ignores explicit membership, leaving no way to scope visibility to invited sessions

1 participant