Repository navigation
feat(#501): re-check live realtime connections after narrowing access changes (fork, Part A) - #54
Merged
Merged
Conversation
… access changes Upstream authorizes a collab editor socket and a notifications/tree socket once, at connect. A restrict, a space-member removal or demotion, an archive or a group-grant removal therefore never reached an open editor (it kept syncing) or an open notifications socket (it kept its space rooms: tree titles and comment bodies). The only eviction was the per-page force-disconnect, which covered a user's page-grant removal and re-checked view only. - authz/live-access: LiveAccessRevalidator re-checks every live connection on this node against the PDP and only narrows. Collab: a mirror of onAuthenticate (decideCollabAccess, pinned by a parity spec against the real extension); deny, or read on a writable connection, closes it. socket.io: leave each space room the user can no longer view; disconnect a missing/disabled user. A PDP failure is "unknown" (no action) until 3 consecutive passes. Never widens (static spec). - POST /api/collab/revalidate (empty body, service secret, remote only) replaces the per-page POST /api/collab/force-disconnect; a trailing pass 2 s later, and a sweep on every node (LIVE_ACCESS_SWEEP_INTERVAL_MS, default 60 s). - Seams: collaboration.gateway getResidentDocuments() (#3g); the per-page forceDisconnectUserFromPage wrapper and forceDisconnect handler are removed. - Restrict invalidates the socket.io "space has restrictions" cache. - Change feed: a wake counter captured before the first read closes the lost-NOTIFY race; rows withheld by the xmin gate re-poll every 250 ms instead of sleeping the whole 25 s wait; LISTEN re-subscribe re-wakes. Real-Postgres spec included. - service-bridge.openapi.json 1.5.0. Refs cccvu/wiki-v2#501 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
… connection; unknown cap is time-bounded - page-editor seam (169) + features/editor-ux/collab-access: a per-document server CLOSE on a live socket reconnects so the server re-decides; a non-expiry refusal stops editing and shows the connection-lost status; a read-only authentication (demoted user) stops editing. Upstream's editor ignored the close entirely. - LiveAccessRevalidator: narrow on unknown only after UNKNOWN_CAP passes spanning UNKNOWN_GRACE_MS (120 s) — a pass count alone collapsed to seconds under a burst of fast-path signals and could evict every editor on a PDP blip. That narrowing now logs LIVE_ACCESS_REVALIDATE_FAILED (the I/O-failure case never threw). - Specs: burst-during-blip never narrows (mutation-checked), consecutive-only reset, the alarm token; realistic controller failure case; client unit tests. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…reopen on disconnect, not a timer - The auth-failed handler decoded the token captured at mount; a refresh only updates remote.configuration.token. In a tab open past the token's life every later refusal read as an expiry: refetch -> reconnect -> refused, forever, never reaching the lost state. Now currentCollabToken + isCollabTokenExpired (fork-owned, unit-tested) judge the token the provider actually sends. - The forced reconnect after a server close re-opens on the socket's own 'disconnect' event: disconnect() keeps the status Connected until the browser's close event and connect() is a no-op while it reads Connected, so the 100 ms timer could strand the editor. Also never reconnects after unmount. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Author
|
Heads-up from wiki-v2 issue 524 (fork PR 55). Once that PR merges,
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
The fork now re-checks every live collab editor and notifications socket against the PDP after a narrowing access change (and on a per-node sweep), closing or narrowing the ones that lost access. It also fixes a lost-wakeup / xmin stall in the authz change feed. Fork half of wiki-v2 issue 501, Part A.
Context
Upstream authorizes a collab socket (
onAuthenticate) and a notifications socket (ws.gateway) once, at connect. A restrict, a space-member removal or demotion, an archive or a group-grant removal never reached an open editor (it kept syncing) or an open notifications socket (it kept itsspace-*rooms and received tree titles and comment bodies). The only eviction was the per-pageforce-disconnect, which covered a user's page-grant removal and re-checked view only. Design: ADR 0026 in cccvu/wiki-v2.Related issues
fix/501-live-access.What changed
authz/live-access/collab-access.decision.ts: a pure four-state mirror ofonAuthenticate(deny | read | write | unknown);collab-access-parity.spec.tsdrives the REAL extension and the mirror over the same facts (a mutation made it red).authz/live-access/live-access.revalidator.ts: re-checks every resident collab connection (close on deny, or read on a writable connection) and every local socket.io socket (leave eachspace-*room it can no longer view; disconnect a missing/disabled user). Uses onlytryCheckBulk(failure = unknown, no action; closed after 3 consecutive unknown passes). Never widens (static spec). Coalesced (one running + one queued pass), trailing pass 2 s after a signal, sweep on every node (LIVE_ACCESS_SWEEP_INTERVAL_MS, default 60 000, 0 = off, remote mode only).POST /api/collab/revalidate(empty body,RemoteOnlyGuard+CollabServiceSecretGuard, bounded 5 s wait) replacesPOST /api/collab/force-disconnect.collaboration.gateway.tsgainsgetResidentDocuments()(#3g); the per-pageforceDisconnectUserFromPagewrapper (#3a) andforceDisconnecthandler (chore(wiki-v2): promote #57 platform-admin entry seam onto the durable branch #2) are removed.ws.gateway.ts: comment corrected (itsforceDisconnectUseris cluster-wide).page-restriction.service.ts: restrict invalidates the socket.io "space has restrictions" cache.authz-change-feed.service.ts: a wake counter captured before the first read closes the lost-NOTIFY race; while committed rows are withheld by the xmin gate the long-poll re-polls every 250 ms instead of sleeping 25 s; LISTEN re-subscribe re-wakes.service-bridge.openapi.json1.5.0 (+ contract README / architecture notes).How this was tested
npx jest src/authz src/service-bridge src/collaboration src/ws— 85 suites, 871 passed (pg specs skip without a DB).AUTHZ_TEST_PG_URL, throwaway container):authz-outbox-commit-safety.pg.spec.ts+page-restriction.pg.spec.ts— 22 passed; the new withheld-row case FAILS on the old feed code and passes on the new one.npx tsc --noEmit -p tsconfig.build.jsonclean;scripts/check-upstream-boundary.sh(super) green on the committed HEAD; eslint/prettier: no new findings in changed files.AWS / infra apply
N/A for this PR (the paired super PR adds CloudWatch alarms).
Checklist
Scope
Tests
Docs & contracts
README/docs// an ADR), or N/A.Safety (this is a security-first, deny-by-default platform)
UPSTREAM_MODIFICATIONS.md); proprietary/authz logic stays out-of-process.Housekeeping
Known limitations / follow-ups
/api/collab/force-disconnectis removed; its only caller is the platform in the same task (the paired super PR switches torevalidate), and the ALB denies/api/collab/*.🤖 Generated with Claude Code