Skip to content

refactor: the API stores and serves only the rich Paper (#1957) - #1958

Merged
quanvu309 merged 89 commits into
mainfrom
refactor/1957-api-rich-only-paper
Nov 25, 2026
Merged

quanvu309 merged 89 commits into
mainfrom
refactor/1957-api-rich-only-paper

Conversation

@quanvu309

@quanvu309 quanvu309 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Part B of #1954 (one stored Paper format). Part A was #1955 (PR 1956, merged).

Summary

The API now stores, lists and serves only the rich Paper document. Word pages are unchanged.

  • paper.create makes a rich blank only. It takes a kind, an optional name and an optional Job. A starting document or a template is refused.
  • Removed commands: paper.revertEdit, paper.sync, paper.setTemplate, paper.share, paper.unshare, paper.dismissCheck, paper.keepTwoPages and paper.attachPhoto. Removed reads: paper.pageCount, paper.shared and paper.keywordGap. Their routes /shared and /:id/pages are gone too.
  • The list, rename, status, favorite and duplicate paths admit only rich Papers, using the rich editor's writer. paper.get refuses every non-Word Paper and points to the rich editor. The Coach's CV drafting skips a Paper it cannot read.
  • paper.nativeSync now declares that it changes paper.list, because the list shows each Paper's last change. The invalidation check found this once the check listed rich Papers.
  • Old Undo receipts for paper.revertEdit and paper.attachPhoto stay in the activity feed but refuse Undo with a clear reason.
  • Migration 0026_paper_rich_only deletes every paper_docs row whose stored document is not the rich document (version 4, schema revision 2). Owner decision: all data is test data.
  • The ownership harness and the command coverage cases now read Papers with the rich editor's writer. The harness adds the writer itself, and Paper rows now open through paper.document. Tests that seeded old block Papers now seed rich ones.

Evidence

  • npx tsc --noEmit in apps/api, apps/web and packages/domain: 0 errors each.
  • npx vitest run in apps/api: 208 files passed, 4 skipped. 1421 tests passed, 1 expected fail, 0 failed.
  • pnpm test in packages/domain: 337 passed, 0 failed. npx vitest run in packages/paper-crdt: 36 files, 336 passed, 1 expected fail.
  • node --test scripts/*.test.mjs packages/guards/*.test.mjs: 1044 passed. The one failure was the unused domain export check, which is fixed: the removed commands' input schemas are deleted from paper.ts. That check now passes.
  • node --test scripts/catalog.integration.mjs: 37 passed, 0 failed.
  • Branch judge (branchVerdict against origin/main): 0 refusals after the retirements below.

Caught by CI, fixed here

The first two CI runs failed the guards (ordinary) job in scripts/outcome/revoke-every-tool.test.mjs. An earlier commit on this branch had made apps/api/src/registry/owned.ts import RICH_NATIVE_WRITER from @workspace/domain. test/write-log.ts loads owned.ts while the API test global setup starts, and that loader resolves only built packages. The revoke check runs the API tests in a copied tree with no build, so vitest crashed at startup.

  • Root fix: owned.ts again imports only types. The ownership harness adds the rich writer to paper.list, paper.get and paper.document itself.
  • Guard: scripts/global-setup-imports.test.mjs with scripts/lib/global-setup-imports.mjs follows the global setup's relative imports. It fails on any runtime import of a @workspace/ package. Its mistake fixture fires, its type-only fixture stays quiet, and it fails on the bad commit's owned.ts and passes on the fix. Ledger row: scripts/guard-ledger/global-setup-imports.json.
  • Evidence: with every packages/*/dist moved aside, as in the CI guards job, node --test scripts/outcome/revoke-every-tool.test.mjs failed before the fix with the same startup crash, and passes after it (1 of 1).

Merge Danger

Door: one-way for data. The migration deletes stored Papers that are not rich documents. All data is test data (owner decision, 2026-11-04). Code is two-way: a revert restores the commands, but not the deleted rows.

Blast Radius: Paper storage and every Paper command. Rich Papers and Word pages behave as before, which the coverage cases and the content-rich tests show. An old block Paper disappears from the list. The Coach no longer drafts from such a Paper, but it already could not read one.

Migration: apps/api/drizzle/0026_paper_rich_only.sql runs DELETE FROM "opencv_app"."paper_docs" WHERE "crdt_document" IS NULL OR NOT (version 4 and schemaRevision 2). It needs allow-migration:0026_paper_rich_only.

Retired checks: scripts/retired/1957.json records 62 files whose cases drove the removed commands, sharing, old block sync and Coach edits on old Papers. The owned-rows ledger proof restored an old store.ts that no longer compiles, so its row now carries the reason instead.

Findings

  • A Paper could be marked Favorite only from the old CV toolbar. The rich editor has no Favorite toggle, so no button in the web calls paper.setFavorite. Only the Coach can.
  • The Coach cannot read a rich Paper's text (paper.get refuses it), so Letter drafting and Coach focus fail for rich CVs. This was already true on main before this change.

Closes #1957

@quanvu309 quanvu309 added the allow-migration:0026_paper_rich_only The owner allowed this migration to change existing things label Nov 25, 2026
@quanvu309
quanvu309 merged commit 0d911f4 into main Nov 25, 2026
17 of 19 checks passed
@quanvu309
quanvu309 deleted the refactor/1957-api-rich-only-paper branch November 25, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-migration:0026_paper_rich_only The owner allowed this migration to change existing things

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: the API stores and serves only the rich Paper

1 participant