Skip to content

fix: filter watched-session presence by recipient visibility - #130764

Merged
steipete merged 1 commit into
mainfrom
steipete/beautiful-sutherland-c43d59
Aug 27, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/beautiful-sutherland-c43d59

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Closes #130732 — watched-session presence references ignore recipient visibility.

Related: #130664 (People activity cards) and #130649 (feature context); those remain separate work.

Additional instructions

This branch is in the main repository and remains editable by maintainers.

What Problem This Solves

Resolves a problem where Gateway clients receive watched-session references that their own session list omits. Hello snapshots, system-presence, and presence events previously returned the raw watched-key array, including creator-only drafts, incognito sessions, role-hidden sessions, and stale references. Pairing-only and node connections could also receive those nested references.

Why This Change Was Made

One recipient projection now applies the existing createSessionListEntryFilter policy at all three presence transport boundaries. It resolves sessions read-only, caches exact lookups only within a synchronous fanout, preserves agent-qualified sentinel keys, and omits missing sessions even for admins. The broadcaster never falls back to a raw roster when its projector is absent.

Filtering declarations cannot account for other recipients, and UI-only masking leaves the references on the wire. This leaves the raw producer and existing authorization policy intact, including established admin grants, while removing the three unprojected egress paths. It does not change UI/person cards, timing/time-zone policy, health summaries, configuration, protocol schemas, storage schemas, or dependencies.

User Impact

Presence carries only watched-session references visible to the receiving operator under the existing session-list policy. Clients without session read access, and pending non-admin identities, retain the non-session roster without watched references. Person/device metadata, timestamps, event sequence numbers, and state versions remain unchanged. Hidden and missing references have no counts or omission markers.

This is a consistency repair within the existing shared-agent trust model, not a new multi-tenant isolation guarantee. Documentation: https://docs.openclaw.ai/concepts/presence.

Evidence

The pre-fix isolated Gateway/WebSocket reproduction at 99539badfd6fac6a4daa7d903ada250bfa5a2da3 recorded 16 failing recipient/surface assertions while 13 existing identity-scope tests passed. The regression uses disposable state, synthetic trusted-proxy identities, real authentication/profile/session paths, and real WebSocket clients; TypeBox validates the returned presence shape. It compares hello, RPC, and event output with each recipient's canonical sessions.list result.

Synchronized candidate: 00410f54ed1eaca596a26485cabc805e6e75db7d. The rebase was conflict-free and git range-diff confirmed the reviewed patch was unchanged.

Local validation on the candidate (all exit 0):

  • Focused Gateway and infra suite: 12 files, 225 tests passed.
  • Changed formatting, typecheck, lint, dead-code, import-cycle and owner guards passed.
  • Full build passed, including CLI bootstrap imports, SDK exports and UI build checks. The four existing web-tree-sitter eval warnings match the prior build; no ineffective-dynamic-import warning was emitted.

Exact commands:

node scripts/run-vitest.mjs src/gateway/server-broadcast.serialization.test.ts src/gateway/server.auth.identity-scopes.test.ts src/gateway/session-message-events.test.ts src/gateway/server/health-state.test.ts src/gateway/server/ws-connection/connect-hello.update-scope.test.ts src/gateway/server/ws-connection/connect-hello.setup-completion.test.ts src/gateway/server/ws-connection/message-handler.post-connect-health.test.ts src/gateway/gateway-misc.test.ts src/gateway/session-sharing.test.ts src/gateway/session-viewer-presence.test.ts src/gateway/server-methods/sessions-viewers.test.ts src/infra/system-presence.test.ts
node scripts/check-changed.mjs
git diff --check HEAD^ HEAD
pnpm build

Hosted CI run 33047015467 completed successfully on this exact head. The exact-head watcher and native OPENCLAW_TESTBOX=1 scripts/pr prepare-run 130764 both exited 0; preparation reused the hosted proof without changing the head.

Coverage includes creator, ordinary reader, restricted reader, admin, pairing-only and node clients; pending identity and solo/system authority; both fanout orders; targeted delivery; frozen raw input; current visibility, deletion and role-policy changes; agent-qualified global/unknown; and absence of missing-store creation. Subscription and hello/update siblings remain covered.

This is authenticated Gateway/WebSocket fixture proof, not a separately built live UI or external provider/channel test. The absence of raw references is a wire assertion; there is no visual change to screenshot. No operator Gateway or live state was modified.

Production LOC: +109/-5 (net +104). Tests: +435/-6 (net +429). Docs: +37/-10 (net +27). The production growth adds the missing recipient ownership boundary and read-only exact resolution shared by three egress paths; no existing net-neutral equivalent could preserve these contracts without duplicating or changing the session policy.

Fresh Codex autoreview reported no actionable P0 findings; its requested threshold was P0, not an exhaustive lower-priority review. Independent source review also found no verified blocker. The watched-session field was introduced by #111225 (authored and merged by @steipete, commit 5c9916950e63ca0fbfb52abf7e9ecb2e43a4d43d, 2026-07-19); this report proves current source behavior and makes no stable-release impact claim.

AI-assisted. The repair, owning visibility policy, transport call paths, and regression evidence were inspected before publication.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 06:45
@steipete
steipete requested a review from a team as a code owner August 27, 2026 06:45
@steipete steipete self-assigned this Aug 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for 00410f54ed1eaca596a26485cabc805e6e75db7d.

The canonical recipient projection now protects hello snapshots, system-presence, and all presence broadcasts while retaining the raw producer and existing session-list policy. The authenticated WebSocket regression checks each recipient against sessions.list; non-session metadata and event sequencing remain intact. Pre-fix evidence recorded 16 disclosure assertion failures; the synchronized candidate passes 225 tests in 12 files.

Exact local commands (all exit 0):

node scripts/run-vitest.mjs src/gateway/server-broadcast.serialization.test.ts src/gateway/server.auth.identity-scopes.test.ts src/gateway/session-message-events.test.ts src/gateway/server/health-state.test.ts src/gateway/server/ws-connection/connect-hello.update-scope.test.ts src/gateway/server/ws-connection/connect-hello.setup-completion.test.ts src/gateway/server/ws-connection/message-handler.post-connect-health.test.ts src/gateway/gateway-misc.test.ts src/gateway/session-sharing.test.ts src/gateway/session-viewer-presence.test.ts src/gateway/server-methods/sessions-viewers.test.ts src/infra/system-presence.test.ts
node scripts/check-changed.mjs
git diff --check HEAD^ HEAD
pnpm build

CI run 33047015467 completed successfully on the exact head, with no failed-job retry. node scripts/watch-pr-ci.mjs 130764 00410f54ed1eaca596a26485cabc805e6e75db7d returned GREEN and exit 0. Native review artifacts validated, and OPENCLAW_TESTBOX=1 scripts/pr prepare-run 130764 exited 0 using hosted exact-head evidence; no separate Testbox run or new push was needed.

Production +109/-5 (net +104); tests +435/-6 (net +429). The growth adds the missing recipient boundary and shared read-only exact resolution; no auth, config, schema, persistence, dependency, UI/person-card, timing or health-summary policy was changed.

Proof limits: this is real authenticated Gateway/WebSocket fixture execution with synthetic state, not a separately packaged UI or external provider/channel test. No visual change or operator Gateway mutation is involved. Fresh Codex autoreview had no actionable P0 findings, and independent source review found no verified blocker; the automated review was P0-scoped. The latest ClawSweeper comment still says review started and contains no findings or rank-up moves; its review is not represented as complete.

Proceeding through native scripts/pr merge-run 130764. Closes the watched-session visibility issue #130732 only; People activity cards #130664 and their feature context #130649 remain separate.

@steipete
steipete merged commit 1d872fe into main Aug 27, 2026
276 checks passed
@steipete
steipete deleted the steipete/beautiful-sutherland-c43d59 branch August 27, 2026 07:07
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Presence watched-session references ignore recipient visibility

1 participant