Repository navigation
feat(core): document state strategies with review and direct built-ins (4a) - #27
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 8558d8e The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
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 |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 58 minutes. View limit details
TanStack is on CodeRabbit Free, which includes PR summaries. Ask your admin to upgrade for code reviews.
|
cursor
Bot
force-pushed
the
cursor/phase-4a-strategy-interface-02f8
branch
from
November 6, 2026 03:21
be3eae1 to
859ec72
Compare
cursor
Bot
changed the base branch from
main
to
cursor/access-context-threading-a931
November 6, 2026 03:29
This was referenced Nov 6, 2026
cursor
Bot
force-pushed
the
cursor/access-context-threading-a931
branch
from
November 6, 2026 14:50
f70436c to
a2c8059
Compare
cursor
Bot
force-pushed
the
cursor/phase-4a-strategy-interface-02f8
branch
from
November 6, 2026 14:50
859ec72 to
2c2f565
Compare
cursor
Bot
changed the base branch from
cursor/access-context-threading-a931
to
main
November 6, 2026 14:54
jherr
force-pushed
the
cursor/phase-4a-strategy-interface-02f8
branch
from
November 6, 2026 15:07
2c2f565 to
8558d8e
Compare
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.
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 ismain3b4a112, then one commit for each PR before this one in the merge order, then this PR's own commit2c2f565(treed75a715).Restacked on 2b:
systemContext(reason, { actor: 'scheduler' | 'import' }), andActorTypeisAccessActor['kind'].agentContextstays internal, because 2b has no builder for an agent without a session.actOnDocument,availableDocumentActionsanddocumentStateLabelare now exported from@tanstack/cms-core/server.What
The strategy API, exported from
@tanstack/cms-coreand client-safe:Effectand its constructors (stage,commit,publish(revision?),unpublish,schedule,discard,emit);DecisionandDocumentStateStrategy(decide,availableActions,label,grants,migrate);defineDocumentStateStrategyandactorOf(ctx);reviewStrategy({ autoApprove? }), the default and today's flow, anddirectStrategy().Configuration.
defineCms({ documentState })sets the app's strategy, and a collection'sdocumentStateoverrides it.The executor runs a decision's effects in one transaction and enforces core's rules on every decision:
publish;document.*events (rule 7);Core writes the audit entry for every decision that commits, discards or is refused. A refusal is audited and thrown as
FORBIDDENwith{ action, rule, reason }.Every write path goes through the strategy:
commitDocument(edit);stageWritefor MCP, agents and author saves (submit);saveDraft,approve,rejectanddiscardDraft;scheduler;importContent, as actorimport.The new
submitWritereturns the strategy outcome, so callers can tell a staged change from a live one.Known bugs fixed. Each fix updates only its labelled characterization rows:
discardedand emits nothing.import.*events.authorfield.docs: add architecture diagrams to the README (data loading, storage, mutations) #2, store-postgres tests: start an embedded Postgres when POSTGRES_TEST_URL is unset #4, ci(assembly): move concurrency to job level #5 and docs(architecture): add mermaid architecture diagrams #7 stay labelled for 4b.
Changeset: core and api minor, ui-react patch.
Breaking or behaviour changes
action, anddecisiongainsdiscardedandrefused. Direct commits, scheduled publishes and imports now add audit rows.discardDraftno longer emitsreview.rejected.saveDocreportsstaged: false.approve, the actor ondocument.*andreview.approvedevents is the approver.import.documentandimport.completed.Assumptions (tasks 8–12 defaults)
user | agent | system | scheduler | import | public | preview.grants: { publish?: ActorType[] }.reviewStrategygrants agents publish only whenautoApproveis set, because an auto-approved agent write goes live today.directStrategygrants nothing.migrateis on the interface but not called yet, because change sets store no strategy state until 4b.Divergence from plan
import.*but notdocument.*, so restores and seeds don't refire webhooks or indexing.deleteDocumentpath isn't routed through the strategy. It already wrote an audit row.scheduleeffect writes the document's schedule columns. Scheduling on the change set, which fixes docs(architecture): add mermaid architecture diagrams #7, is 4b.review.rejectedkeeps the combined actor, because chore(deps): lock file maintenance #9 covers approvals only.How verified
document-state.test.tswith 18 tests covers each core rule, both built-ins, the per-collection override,publish(revision)restore and a refusal partway through an import.pnpm test:pr: covers 47 projects and passes except thecms-apioxlint error thatmainalready has.test:dts, knip, sherif andtest:docsare 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.tsandpackages/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 newmain; that rebase is always clean.