Skip to content

feat(core): document state strategies with review and direct built-ins (4a) - #27

Merged
jherr merged 1 commit into
mainfrom
cursor/phase-4a-strategy-interface-02f8
Nov 6, 2026
Merged

jherr merged 1 commit into
mainfrom
cursor/phase-4a-strategy-interface-02f8

Conversation

@jherr

@jherr jherr commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Implements cms-refactor-plan.md § Phase 4 (4a), together with § 7 (document state strategy) and § "Decided: core owns live". It also implements the phase 4 decisions from the phase 0 PRs: bugs #1, #3, #6, #8, #9 and #10, rules 6 and 7, grants/migrate, and auditing rejected decisions.

Merge chain: step 11 of 24. Base: main. Merge it right after #26. The branch is main 3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit 2c2f565 (tree d75a715).

Restacked on 2b:

  • 4a's own context builders are gone. The scheduler and import paths use 2b's systemContext(reason, { actor: 'scheduler' | 'import' }), and ActorType is AccessActor['kind'].
  • Only agentContext stays internal, because 2b has no builder for an agent without a session.
  • actOnDocument, availableDocumentActions and documentStateLabel are now exported from @tanstack/cms-core/server.

What

Breaking or behaviour changes

  • Audit rows. Document audit entries carry action, and decision gains discarded and refused. Direct commits, scheduled publishes and imports now add audit rows.
  • Discard. discardDraft no longer emits review.rejected.
  • Auto-approve. With auto-approve, saveDoc reports staged: false.
  • Event actor. After approve, the actor on document.* and review.approved events is the approver.
  • Imports. Import and seeding emit import.document and import.completed.

Assumptions (tasks 8–12 defaults)

  1. Actor types: 2b's union, user | agent | system | scheduler | import | public | preview.
  2. Agent publish floor: grants: { publish?: ActorType[] }. reviewStrategy grants agents publish only when autoApprove is set, because an auto-approved agent write goes live today. directStrategy grants nothing.
  3. Strategy versioning: migrate is on the interface but not called yet, because change sets store no strategy state until 4b.
  4. Import: every document is decided before the first write. If any one document is refused, the whole import aborts and the refusal is audited.

Divergence from plan

How verified

  • Unit tests: a new document-state.test.ts with 18 tests covers each core rule, both built-ins, the per-collection override, publish(revision) restore and a refusal partway through an import.
  • Characterization: every unlabelled row is unchanged and green, on SQLite (37/37), store-libsql (63/63) and store-postgres (100/100, against real Postgres).
  • Package suites after the restack: core 591 passed, api 202 passed.
  • pnpm test:pr: covers 47 projects and passes except the cms-api oxlint error that main already has.
  • Other checks: test:dts, knip, sherif and test:docs are clean.

Merge chain (local verification, CI down)

This PR's commits are squashed into one commit on the linear merge chain. That commit holds this PR's own changes, resolved against every PR before it, with the integration rehearsal's fixes for this PR applied. Two files conflicted, both on import lists: packages/core/src/schema.ts and packages/ui-react/src/routes/review.tsx.

The chain tip's tree is exactly the integration rehearsal plus #46 (c4e6d7c), and the tip passes the full local suite. I simulated merging every PR in order, with a merge commit or a fast-forward at each step, and every step is clean. A plain squash of the next PR would conflict, because the squash commit isn't an ancestor of the next branch. To squash instead, first rebase the branch's one commit onto the new main; that rebase is always clean.

Open in Web Open in Cursor 

@changeset-bot

changeset-bot Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8558d8e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@tanstack/cms-core Minor
@tanstack/cms-api Minor
@tanstack/cms-ui-react Minor
@tanstack/cms-cli Minor
@tanstack/cms-client Minor
@tanstack/cms-connect-atproto Patch
@tanstack/cms-migrate-wp Patch
@tanstack/cms-skills Patch
@tanstack/cms-media-s3 Minor
@tanstack/search-cms Patch
@tanstack/cms-store-libsql Minor
@tanstack/cms-store-postgres Patch
@tanstack/cms-ui-dom Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: TanStack/cms
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 4f8e841
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Free
  • Run ID: 45095f24-3582-4a76-ade0-ce357ecf328f
Commits

Reviewing files that changed from the base of the PR and between 4f8e841 and 8558d8e.

Files selected for processing: 38

  • .changeset/document-state-strategy.md
  • docs/agents/review-queue.md
  • docs/api/cli.md
  • docs/api/cms-core-server.md
  • docs/architecture/terminology.md
  • packages/api/src/ops.ts
  • packages/api/src/outputs.ts
  • packages/api/tests/characterization/save-paths.test.ts
  • packages/api/tests/ops.test.ts
  • packages/core/src/config.ts
  • packages/core/src/document-state.ts
  • packages/core/src/events.ts
  • packages/core/src/index.ts
  • packages/core/src/schema.ts
  • packages/core/src/server.ts
  • packages/core/src/server/access-context.ts
  • packages/core/src/server/dispatcher.ts
  • packages/core/src/server/outbox.ts
  • packages/core/src/server/store.ts
  • packages/core/src/server/store/document-state.ts
  • packages/core/src/server/store/review.ts
  • packages/core/src/server/store/scheduling.ts
  • packages/core/src/server/store/write.ts
  • packages/core/src/server/transfer.ts
  • packages/core/src/storage.ts
  • packages/core/src/storage/sql-storage.ts
  • packages/core/src/storage/types.ts
  • packages/core/tests/characterization/workflow-suite.ts
  • packages/core/tests/document-state-strategy.acceptance.test.ts
  • packages/core/tests/document-state-strategy.sketch.test.ts
  • packages/core/tests/document-state.test.ts
  • packages/core/tests/draft/acceptance-harness.ts
  • packages/core/tests/draft/document-state-strategy.ts
  • packages/core/tests/draft/legal-review.xstate.ts
  • packages/core/tests/transfer.test.ts
  • packages/store-postgres/tests/invariants.test.ts
  • packages/ui-react/src/lib/i18n.ts
  • packages/ui-react/src/routes/review.tsx

TanStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.

  • Ask an admin to upgrade

Open in CodeRabbit

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…s (4a) (#27)

Chain step 11 of the linear merge chain onto main 3b4a112: this PR's own changes, resolved against the PRs before it in the merge order.

Co-authored-by: jherr <jherr@pobox.com>
@jherr
jherr force-pushed the cursor/phase-4a-strategy-interface-02f8 branch from 2c2f565 to 8558d8e Compare November 6, 2026 15:07
@jherr
jherr merged commit 260814f into main Nov 6, 2026
@jherr
jherr deleted the cursor/phase-4a-strategy-interface-02f8 branch November 8, 2026 01:55
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.

2 participants