Skip to content

fix(#661,#618,#589,#670,#634): remote page removal decides every page it removes - #67

Merged
PMQ9 merged 2 commits into
wiki-v2from
fix/661-618-589-670-page-removal
Nov 5, 2026
Merged

PMQ9 merged 2 commits into
wiki-v2from
fix/661-618-589-670-page-removal

Conversation

@PMQ9

@PMQ9 PMQ9 commented Nov 5, 2026 •

Copy link
Copy Markdown

TL;DR

Remote-mode page removal now decides every page it removes. A trash needs page#edit on every page it trashes. A purge needs space admin on every space it touches and never runs in an archived space. Retention never purges archived, live or unexpired pages. A delegated service account is decided under the same locks.

Paired with super PR cccvu/wiki-v2#707, which carries the platform side, ADR 0033 and the seam records. Review them together.

Implementation plan, progress and tradeoffs (canonical, on the super repo): https://github.com/cccvu/wiki-v2/issues/661#issuecomment-6650012688

Related issues

cccvu/wiki-v2 issues 661, 618, 589, 670, 634 (closed by super PR 707)

What changed (apps/server/src/, remote mode only)

  • RemoteTrashService (new) runs both trash routes (the native /pages/delete, through RemotePurgeInterceptor, and conditional-delete).
    • It locks the subtree FOR NO KEY UPDATE and decides page#edit for the human, then the service account, on every live page.
    • It trashes exactly that set through seam §172 removePage(…, { pageIds }), never a re-walk.
    • A deny is settled once outside the transaction and retried.
    • Codes: 403 trash_needs_edit, 409 trash_subtree_changed, 503 trash_unconfirmed.
  • RemotePurgeService: space#administer on every space of the subtree (Paste multiple images processing bug docmost/docmost#618). The spaces are locked FOR SHARE, and an archived one refuses with 409 space_archived ([Feature Request] PWA (Progressive web app) support docmost/docmost#589). With the header, it decides the service leg too ([Feature Request]: Custom Emojis docmost/docmost#670).
  • RemoteTrashRetentionService (new, seam §183 core/page/page.module.ts): purges only fully-trashed, fully-expired subtrees outside archived spaces, under locks. Unarchive restarts the clock, and it never cascades into a live child.
  • g1 guard: ccc_page_archived_space_move refuses a move out of an archived space.
  • x-ccc-acting-service: a strict parse; it only ADDS checks, the human is decided first, and it never reaches audit or logs.
  • Shared helpers: page-subtree.ts, page-delete-decision.ts, page-delete-errors.ts, acting-service.ts.
  • Contract docs: service-bridge 1.11.0 (descriptions only).

How this was tested

  • tsc --noEmit: clean.
  • Unit (src/authz src/service-bridge src/editor-compat src/common/helpers/prosemirror src/core/page): 173 suites pass. The only 2 red suites are the pre-existing lib0 ESM load failures in core/page, which are red on base and not in the CI lane.
  • Real Postgres (--runInBand 'src/(service-bridge|authz)/.*\.pg\.spec\.ts$', AUTHZ_REQUIRE_PG=1): 35/35 suites, 517/517 tests. Covered:
    • a concurrent restore during a trash;
    • a restrict during a trash (no workspace-wide block);
    • a child insert during a trash;
    • an archive during a purge;
    • unarchive restarts the clock;
    • a live child under trash;
    • the archived move-out guard;
    • the service-leg matrix.
  • Mutation-proven: the service leg (purge and trash), every archived check, the pageIds seam, the retention live-row skip, the g1 clause, and FOR UPDATE versus FOR NO KEY UPDATE on trash. Each went red.

🤖 Generated with Claude Code

PMQ9 and others added 2 commits November 4, 2026 22:27
…ote page removal decides every page it removes

Remote mode only; native mode keeps upstream behaviour.

- Trash (docmost#661, docmost#634): RemoteTrashService runs both trash routes. It locks the subtree
  FOR NO KEY UPDATE, decides page#edit on every live page for the human and the
  delegated service account, and trashes exactly that set (seam docmost#172 pageIds). A deny
  is settled once outside the transaction before it refuses. Codes: 403
  trash_needs_edit, 409 trash_subtree_changed, 503 trash_unconfirmed.
- Purge (docmost#618, docmost#589): space#administer on every space of the subtree; the spaces are
  locked FOR SHARE and an archived one refuses with 409 space_archived.
- Retention (docmost#589): seam docmost#183 swaps in RemoteTrashRetentionService. It purges only
  fully-trashed, fully-expired subtrees outside archived spaces, under locks;
  unarchive restarts the clock; it never purges a live child.
- g1 guard: ccc_page_archived_space_move refuses a move out of an archived space.
- Delegated leg (docmost#670): x-ccc-acting-service is parsed strictly and only ADDS checks
  (the human first), under the same locks and fence.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…'s answer count and seam 172's side effects

Review round 1 on cccvu/wiki-v2 PR 707:
- RemoteTrashService runs each attempt in an OpSemaphore slot (TRASH_MAX_CONCURRENT=2,
  2 s wait, then 503 engine_busy). An attempt holds a pooled connection, row locks and an
  xid across its PDP calls, so an uncapped trash could drain the pool under a slow PDP.
  The settle between attempts holds no slot. The docstring no longer claims one round trip.
- page-delete-decision.spec.ts: decideAll refuses short, long and empty answers, in every
  chunk; null is unavailable; an empty set asks nothing.
- remote-trash.pg.spec.ts: seam 172 revokes the share links of exactly the trashed rows and
  emits one page.soft_deleted with them; a refused trash does neither.

Mutation-proven: no slot / slot held across the settle; no length check; no share delete,
empty affected set, no emit: each reds its test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@PMQ9
PMQ9 merged commit 1af5522 into wiki-v2 Nov 5, 2026
@PMQ9
PMQ9 deleted the fix/661-618-589-670-page-removal branch November 5, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant