Repository navigation
fix(wiki-v2 636/401/503): remote mode refuses native admin routes, inert users.role, fenced purge - #63
Merged
Conversation
…ase sessions and self-dealers no authority - authz/remote-refusal: one table-driven RemoteNativeRefusalInterceptor absorbs the docmost#502/docmost#598 refusals and 404s (with an audit row) native workspace admin, group admin, space-member writes and /api/users/update email changes in AUTHZ_MODE=remote. Every family is pinned both ways by fitness specs. - authz/mode/workspace-ability (seam docmost#177, core/casl/casl.module.ts): in remote mode workspace CASL gives every role the member ability, so users.role confers no authority. - authz/page-restriction: one domain-audit row per applied native page-ACL write. - authz/page-delete: in remote mode a permanent delete runs one locked, settle-fenced routine that requires page#edit on every page it removes (native route via RemotePurgeInterceptor, conditional route directly). - Contract 1.10.0: README + openapi version; contract smoke gains native controls and the remote leg (e) refusals. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012MtB3UoudTUG3zK7fjrBpC
…tbox pg specs
`ReservedSql` and the insert helpers' bare `Sql | ReservedSql` are `<{}>`, while
the factories return `<{ bigint: number }>`. `tsc --noEmit` reports 13 errors
across both specs. ts-jest surfaced them on one CI runner (wiki-v2 PR 666's
authz compat lane), which turned it red. Annotation only; no behaviour change.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012MtB3UoudTUG3zK7fjrBpC
In remote mode the server ignores users.role and refuses the native workspace, group and space-member admin routes, so a native-phase owner/admin session saw enabled admin controls that only failed with "Not Found". useUserRole now derives its flags from member in remote mode; native mode is unchanged. Vitest pins both modes. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012MtB3UoudTUG3zK7fjrBpC
… fix/636-401-503-remote-native-authority Conflicts: narrowing-routes.ts and static-route-scan.ts keep this branch's side (the table-driven refusal header; handlerText/handlerCalls/httpPath in place of per-feature booleans). The two outbox pg specs take wiki-v2's identical typing fix. docmost#542's SpaceMemberMutationInterceptor refused the same three native space-member routes as this branch's spaceMember refusal family, under a second audit event. It is folded into the table: the interceptor and its two specs are removed, the table gains a targetUserField so a self-targeted attempt is still flagged targetsActor, and NativeRouteAuthzModule keeps only the breadcrumb redaction. native-route-authz.fitness.spec.ts keeps the breadcrumb pins on handlerCalls; space-member.fitness.spec.ts pins the member writes. The event stays space.native_member_refused (neither name has shipped). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_012MtB3UoudTUG3zK7fjrBpC
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
Remote-mode hardening of the engine's native admin and purge paths:
users.roleconfers no workspace authority inAUTHZ_MODE=remote;page#editon every page it removes.This is the fork half of a paired change. The super PR (https://github.com/cccvu/wiki-v2/pull/666, private) is the one cohesive PR and carries the rationale, the owner decisions and the residuals. Review the two together.
Context
In remote mode the platform owns identity, membership and group administration. These native routes duplicated that authority, and the permanent delete decided on space settings alone. Contract version 1.10.0. Design record: wiki-v2 ADR amendments 0001, 0025, 0026, 0028 and 0029 (super repo).
Related issues
What changed
W1:
authz/remote-refusal/.RemoteNativeRefusalInterceptorandremote-refusal.table.tsreplace the Dev docmost/docmost#502 and custom drawio server by docker not ok docmost/docmost#598 interceptors. The table has six families and 20Controller.handlerkeys:spaceHardDelete,spaceNativeCreate(unchanged events);workspaceAdmin,groupAdmin,spaceMember;userEmail, refused whenever the body has anemailkey.Each refusal is a 404 before CASL, plus one best-effort audit row. The row never reads the body.
The Dev docmost/docmost#502 and custom drawio server by docker not ok docmost/docmost#598 specs moved here with
git mv.static-route-scan.tsexposeshandlerText,handlerCallsandhttpPathin place of the per-feature booleans.app.module.tsseam fix(authz): harden PLATFORM_AUTHZ_TIMEOUT_MS parse (empty/typo → deny-all self-DoS) #4: two providers become one.W2:
authz/mode/workspace-ability.ts. In remote mode,RemoteWorkspaceAbilityFactorycomputes the stock MEMBER ability for every known role, on a copy of the user. An unknown role throws (fail closed). New upstream seam:core/casl/casl.module.ts(No way to delete users docmost/docmost#177), one provider swap.W3:
authz/page-restriction/acl-audit.ts.PageRestrictionServiceemits one domain audit row per applied ACL write, after commit, using upstream event names. Rows carry ids and roles only (never titles), withmetadata.surface:'engine'.AUDIT_SERVICEis@Optional, because the collab app has no audit module.PAGE_ACL_AUDIT_FAILEDand leaves the write committed.W6:
authz/page-delete/.RemotePurgeServiceis the only remote purge routine. Both entry points use it:ConditionalPageOpsController.conditionalDelete;PageController.delete {permanentlyDelete:true}, throughRemotePurgeInterceptorin seam fix(authz): harden PLATFORM_AUTHZ_TIMEOUT_MS parse (empty/typo → deny-all self-DoS) #4, with no controller edit.The steps, in order:
FOR UPDATEin id order, and re-walk until it is stable.maxCommittedPositionread after the locks, thensettleProjection.page#editon every locked id.forceDelete, and require the deleted set to equal the locked set.New codes:
403 purge_needs_edit;503 purge_unconfirmed(retryable);409 purge_subtree_changed. Log tokens:REMOTE_PURGE_BUSY,REMOTE_PURGE_UNCONFIRMED,REMOTE_PURGE_UNSTABLEandREMOTE_PURGE_SET_MISMATCH.Contract 1.9.0 → 1.10.0. The integrator README lists the refused families, inert
users.roleand the purge rule.contract-smoke.shgains a native-phase control and a remote leg (e) that refuses five routes for the OWNER, each proven against the database.How this was tested
Fork unit:
jest src/authz src/service-bridge src/editor-compat …, 149 suites, 2175 pass (333 pg-gated skips).pg specs: 28 suites, 361 pass on real Postgres. This includes the deterministic purge race specs: a concurrent restrict on a descendant, a concurrent child insert, a deleted-set mismatch rolling back, and a lock timeout giving 503.
Server build:
nest buildgreen.check-upstream-boundary.shgreen.Isolated real-boot smokes:
fork-contract-replacement-smoke: ALL CHECKS PASSED, including the new leg (e);fork-standalone-smoke: ALL CHECKS PASSED.HTTP specs boot the real controllers on Fastify for every refusal key (refused in remote; 200 with the interceptor removed, as anti-vacuity), for the W2 icon routes, and for
PageController.delete.Mutation proof:
Examples: drop a table key or the email predicate; always use the stock factory; pass the user through unchanged; emit the audit inside the transaction; skip the fence; skip one descendant.
AWS / infra apply
N/A. Fork code only.
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
Tracked in the super PR and its follow-up issues. Behaviour notes for integrators:
POST /api/users/updaterefuses any body that has anemailkey in remote mode, even an unchanged email.users.roleis owner/admin sees native admin UI that answers 404 or 403 in remote mode.🤖 Generated with Claude Code
https://claude.ai/code/session_012MtB3UoudTUG3zK7fjrBpC