Repository navigation
feat(#501): Part B — narrowing routes answer only once the PDP enforces them - #56
Merged
Merged
Conversation
… enforces them A request on a route that takes access away (restrict + page grants, move / move-to-space, native member remove / change-role, group-member remove, service-bridge archive + member writes) now waits, after the handler succeeds, for the platform relay to project it: - fence = the max COMMITTED authz_outbox position (`maxCommittedPosition`, ungated; never the xmin-gated head(), which sits before this request's rows while any older transaction is open — a real-PG spec pins it) - `POST /sync/settle` on the platform (bounded; a 404 / timeout / malformed answer is pending) - on confirmed, this node's live connections get a re-check (<= 1.5 s) - `Authz-Propagation: confirmed | pending` on the response; status and body untouched, handler errors pass through, never throws APP_INTERCEPTOR registered from the fork-owned CollabDisconnectModule (no upstream file changes). Route table keyed <Controller>.<handler>, cross-checked against the static route scan. Budget: AUTHZ_NARROWING_SETTLE_TIMEOUT_MS (default 3000, max 5000; 0 = pass-through rollback switch), whole request kept under 6 s (below the platform's 8 s relay timeout). Contracts: authorization-service 1.1.0 (optional /sync/settle op), service-bridge 1.6.0 (Authz-Propagation on archive + member writes). Refs cccvu/wiki-v2#501 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…no-verdict pendings, report dropped rows - interceptor: read the fence BEFORE the handler too; unchanged after it means the request committed no access change (a same-parent reorder, a no-op), so nothing is settled and no header is sent (Performance). - a pending the platform gave NO verdict for (unreachable / no route / rejected / past the deadline) is logged here with the alarmed AUTHZ_PROPAGATION_PENDING (reason=settle-*); platform-answered pendings stay a plain warn. - unrestrict (PageRestrictionController.removeRestriction) is a narrowing route: it drops every grant. - settle margin 500 -> 1500 ms (the platform's confirm step can exceed 500 ms); a third-party reason string is sanitised before it is logged. - feed: report `dropped` rows (known table, no event) so the platform dead-letters the batch and a settle cannot answer a false confirmed over an unprojected change (Correctness F2). service-bridge 1.6.0 schema + pin. - contracts: positions/cursors order as an integer pair (xact_id, id), never as strings (Architecture). - tests: fence skip + ordering, no-verdict alarm line, failing/capped live-session pass, non-HTTP, reason sanitising. Refs cccvu/wiki-v2#501 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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
A fork request that takes access away now responds only after the platform confirms the PDP enforces it, and says so in an
Authz-Propagation: confirmed | pendingresponse header. Fork half of wiki-v2 issue 501, Part B.Context
A narrowing change (restrict, grant removal or downgrade, member removal or demotion, archive, move) commits in the fork DB first. It then reaches SpiceDB through the outbox → platform relay, and until then every decision still allows the old access. Before this change the response came back at once, so the actor would restrict a page and then paste the confidential text into it while the old readers could still see it (the Zanzibar "new enemy" problem). Design: ADR 0026 §4 in cccvu/wiki-v2.
Related issues
What changed
authz/live-access/narrowing-settle.interceptor.ts(newAPP_INTERCEPTOR, registered from the fork-ownedCollabDisconnectModule, so no upstream file changes). Runs only in remote mode, on the routes in the table, and only after the handler succeeds:P= the max COMMITTED outbox position.POST /sync/settle {position: P}on the platform.confirmed,LiveAccessRevalidator.signal('narrowing'), awaited for at most 1.5 s.Authz-Propagationheader.It never throws and never changes the status or body. Handler errors pass through untouched.
authz/live-access/narrowing-routes.ts: the table, keyed<Controller>.<handler>.PageRestrictionController.{restrict, addPermission, removePermission, updatePermission}PageController.{movePage, movePageToSpace}SpaceController.{removeSpaceMember, updateSpaceMemberRole}GroupController.removeGroupMemberServiceSpaceController.{archive, addMember, changeMemberRole, removeMember}addPermissionandaddMemberare upserts that can demote.narrowing-routes.spec.tschecks every entry against the static route scan.service-bridge/authz-change-feed.service.ts:maxCommittedPosition(db), which reads with no xmin gate. It must never behead(): head is gated by the oldest open transaction, so while any unrelated transaction is open it sits before this request's rows. A settle fenced there would be a falseconfirmed. A real-PG spec pins this.authz/http-authz.client.ts:settleProjection(position, waitMs). It resolvesconfirmedonly on a well-formed 200 that says so. A 404 (a platform without the route), a timeout, a transport error or a malformed body resolvespending. Its deadline is the wait + 500 ms.Budget.
AUTHZ_NARROWING_SETTLE_TIMEOUT_MS: default 3000, clamped to 5000.0= pass-through, which is the rollback switch.Contracts.
authorization-service.openapi.json1.1.0 adds/sync/settleas an OPTIONAL op. A 404 makes every narrowing responsepending, so a third-party authorization service still works.service-bridge.openapi.json1.6.0 documents the header on archive and the member writes.How this was tested
npx jest src/authz src/service-bridge src/collaboration src/ws, with real Postgres (AUTHZ_TEST_PG_URL): 87 suites, 1019 passed.=0pass-throughs;settleProjection(7): unit tests, plus 2 consumer-contract tests against the canonical OpenAPI example.head()is still before it;0.0.npx tsc --noEmit -p tsconfig.build.jsonis clean, and eslint is clean on the changed files.scripts/check-upstream-boundary.shpasses on the committed HEAD (no upstream files touched).AWS / infra apply
N/A for this PR. The paired super PR adds one CloudWatch alarm and its scripted apply.
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
pending, never a wrongconfirmed. A per-request fence could under-wait; ADR 0026 §4 explains why.confirmedis about the PDP. Only this node's live sessions get the bounded re-check. Other nodes rely on their sweep (≤ 60 s).🤖 Generated with Claude Code