Skip to content

feat(core,api,ui-react)!: ship the document state acceptance suite (XState parallel approval passes on all three stores); Mermaid from a strategy's graph; the review queue follows the strategy (4c) - #36

Merged
jherr merged 1 commit into
mainfrom
cursor/phase-4c-parallel-approval-02f8
Nov 6, 2026

Conversation

@jherr

@jherr jherr commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Implements cms-refactor-plan.md § Phase 4 (4c):

  • the XState parallel-approval example passes the phase 0 acceptance test;
  • that test ships as a suite the caller gives a test runner to, and store-postgres and store-libsql both run it;
  • Mermaid charts are generated from a strategy's graph;
  • the admin review UI moves here from 4b.

Merge chain: step 13 of 24. Base: main. Merge it right after #29. The branch is main 3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit 7c2edf0 (tree 6ac2404).

What

  • The phase 0 acceptance test is unskipped and passes. The XState parallel-approval example has:

    • legal and editorial approvals in parallel regions;
    • a changes-requested loop;
    • scheduling;
    • a version bump, with and without migrate.

    It passes all eleven steps plus core's rules. The example lives in packages/core/tests/document-state/legal-review.xstate.ts and is printed in full in the docs.

  • The suite ships as runDocumentStateAcceptance(name, { database, strategies }, runner) from @tanstack/cms-core/document-state/acceptance, like runStorageConformance.

    • The suite boots a real defineCms, reopens storage to cover restarts, and reads the audit log and the events.
    • store-libsql and store-postgres run it. Postgres follows the conformance pattern.
    • Core rules covered:
      • an agent edit stages;
      • the agent publish floor;
      • a reserved document.* emit is rejected;
      • an edit decision that neither stages nor commits is rejected;
      • a refused decision is audited with its reason.
  • Mermaid from a strategy's graph. stateGraphToMermaid(graph) renders describe() as a stateDiagram-v2, including composite states, parallel regions and final states. review-queue.md and the new custom-strategies.md embed the charts. A drift test fails if a chart or the printed source goes stale.

  • Core now handles stranded change sets. It checks for one before asking the strategy, and refuses every action except discard (rule stranded). It runs that discard itself, for a reviewer (review.decide, not an agent).

  • Audit to on closing decisions records the returned state (e.g. published) instead of null.

  • New server export: readChangeSet(collection, id).

  • The review UI follows the strategy:

    • reviewSnapshot items carry review: { label, actions, stranded? }.
    • A new actOnChange({ id, action, publishAt?, reason?, expectedVersion? }) op runs the offered actions that carry no document. It's also available as a Start server function.
    • /review shows the strategy's label as a badge, and a Publishes … badge for scheduled change sets. Its buttons come from the offered actions, with Schedule and Clear schedule when schedule is offered.
    • A stranded change set offers only Discard change set.
    • New i18n keys: review.stranded, review.scheduledFor, review.scheduleAt, review.schedule, review.clearSchedule.
  • Docs: a new "Custom Document State Strategies" page, plus updates to review-queue.md and the op tables.

Breaking changes

  • document-state-acceptance.md (core minor):
    • Core decides stranded change sets before the strategy is asked, and the strategy's emits on that discard no longer run.
    • An audit entry's to records a closing decision's returned state instead of null.
  • review-queue-strategy-actions.md (api and ui-react minor):
    • reviewSnapshot also lists stranded drafts.
    • The Approve and Reject buttons follow the strategy's offered actions.

How verified

GitHub Actions is out of billing, so everything ran locally. On a scratch branch, I merged head 7073625 into origin/main at 3b4a112.

Check Result
pnpm install --frozen-lockfile passes
pnpm test:ci Only the known @tanstack/cms-api:test:oxlint fails. The first run also failed cms-api:build because ChangeSetReview wasn't exported; 7073625 exports it.
test:dts / test:dialects / test:scripts pass / pass / 59
E2E blog / base blog 28/28; base 12/12 on a re-run
Characterization core / libsql / postgres 37 / 83 / 120, including the acceptance suite (18 tests per store)
Packages core 624, api 205, ui-react 85. tsc, knip, test:docs and kiira (128/128) are clean.

On the first base E2E run, one flaky test clicked Approve & publish and read the result before the approval had finished. #41 fixes that test, and #41 is step 1 of the merge chain.

Assumptions (tasks 8–12 defaults)

  1. The suite's sessions get wide permissions, so the strategy's own role checks are what's under test.
  2. The stranded discard is limited to reviewers: non-agents holding review.decide.
  3. actOnChange needs only content.read. What the caller may do comes from the strategy's offered actions, and core re-checks write and publish access whenever live content changes.
  4. actOnChange refuses edit, submit, draft and import, because those actions carry a document.
  5. The example strategies stay in core's tests, and the store packages import them by relative path.

Divergence from plan

  1. Steps 7 and 8 expect document.updated, not document.published. The document is already live at those steps, and under the 2026-11-06 vocabulary ruling document.published fires only when a document goes live.
  2. The suite's dates are in 2999, because the scheduler sweep uses the real clock.
  3. Core decides stranded change sets, because an XState strategy can't safely read state written by another version.
  4. Audit to on closing decisions now records the returned state.
  5. The spec's two todos became tests, and a third test was added.
  6. The phase 0 draft harness was removed. tests/draft/ moved to tests/document-state/.
  7. Stranded drafts appear in the review queue.
  8. tsconfig.docs.json maps xstate.
  9. ai-images.md moved from docs order 4 to 5.

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. No conflicts.

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: 4863e04

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: 2b1aee0
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Free
  • Run ID: 826e6756-1c67-4783-bfe3-3f6fd5b2773e
Commits

Reviewing files that changed from the base of the PR and between 2b1aee0 and 4863e04.

Files selected for processing: 35

  • .changeset/document-state-acceptance.md
  • .changeset/review-queue-strategy-actions.md
  • docs/agents/ai-images.md
  • docs/agents/custom-strategies.md
  • docs/agents/review-queue.md
  • docs/api/cms-api.md
  • docs/api/routes-and-endpoints.md
  • docs/config.json
  • docs/mcp/operations-registry.md
  • examples/blog/e2e/cms.spec.ts
  • packages/api/src/index.ts
  • packages/api/src/ops.ts
  • packages/api/src/start.ts
  • packages/api/tests/act-on-change.test.ts
  • packages/core/package.json
  • packages/core/src/document-state.ts
  • packages/core/src/document-state/acceptance.ts
  • packages/core/src/index.ts
  • packages/core/src/server.ts
  • packages/core/src/server/store.ts
  • packages/core/src/server/store/document-state.ts
  • packages/core/src/storage/types.ts
  • packages/core/tests/document-state-docs.test.ts
  • packages/core/tests/document-state-strategy.acceptance.test.ts
  • packages/core/tests/document-state-strategy.sketch.test.ts
  • packages/core/tests/document-state/contexts.ts
  • packages/core/tests/document-state/legal-review.xstate.ts
  • packages/core/tests/draft/acceptance-harness.ts
  • packages/core/tests/draft/document-state-strategy.ts
  • packages/core/tsdown.config.ts
  • packages/store-libsql/tests/document-state-acceptance.test.ts
  • packages/store-postgres/tests/document-state-acceptance.test.ts
  • packages/ui-react/src/lib/i18n.ts
  • packages/ui-react/src/routes/review.tsx
  • tsconfig.docs.json

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

…State parallel approval passes on all three stores); Mermaid from a strategy's graph; the review queue follows the strategy (4c) (#36)

Chain step 13 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-4c-parallel-approval-02f8 branch from 7c2edf0 to 4863e04 Compare November 6, 2026 15:08
@jherr
jherr merged commit 18d8f0f into main Nov 6, 2026
1 check passed
@jherr
jherr deleted the cursor/phase-4c-parallel-approval-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