Entries, Drafts & Publishing
The 5-state entry lifecycle, dual draft/published snapshots, optimistic locking, explicit null/clear semantics, scheduling, version history, redirects, and draft previews.
OvertCMS Core models every content item with a pure 5-state lifecycle and dual-snapshot isolation (draftData vs. publishedData), ensuring in-progress edits never leak to public visitors and concurrent editors never silently overwrite each other.
The 5-State Entry Lifecycle#
Every entry is in exactly one of five canonical states: draft, scheduled, published, archived, or trashed.
stateDiagram-v2
[*] --> draft: Create (default)
[*] --> scheduled: Create (status=scheduled)
[*] --> published: Create (status=published)
draft --> scheduled: Schedule (scheduledAt > now + 30s)
draft --> published: Publish
draft --> archived: Archive
draft --> trashed: Trash
scheduled --> published: Worker Auto-Publish or Publish Now
scheduled --> draft: Unpublish / Failed Auto-Publish Demotion
scheduled --> archived: Archive
scheduled --> trashed: Trash
published --> published: PATCH (updates draftData ONLY) / Re-Publish (promotes draftData)
published --> draft: Unpublish (confirmUnpublish=true) / Worker Auto-Unpublish
published --> archived: Archive (confirmUnpublish=true)
published --> trashed: Trash (confirmUnpublish=true)
archived --> draft: Restore
archived --> trashed: Trash
trashed --> draft: Restore (checks slug & singleton uniqueness)
trashed --> [*]: Purge (permanent delete, Admin)
Dual-Snapshot Isolation (draftData vs. publishedData)#
Every Entry stores two independent JSON snapshots:
draftData: Always holds the latest working copy. Updated byPATCH.publishedData: Holds the live immutable snapshot served by the Delivery Plane. Populated or promoted only whenPublishEntryruns (or onCreateEntrywithstatus: "published").
When an entry is published and an editor or AI agent calls PATCH:
draftDatais updated,versionincrements, and an immutableEntryVersionis recorded.publishedData,entry.slug, andentry.publicUrlremain strictly pinned to the live published version—so public Delivery URLs and search/filter indexes (entry_field_index) never leak unfinished edits.- Calling Publish re-validates
draftDatain strictpublishmode (checkingrequiredOn: "publish"fields andimagealt text), promotesdraftData->publishedData, updates the public slug/URL, creates an automatic 301 redirect if the live slug changed, and purges Delivery caches.
Optimistic Locking & Concurrency Control#
All mutating operations on existing entries (PATCH, publish, schedule, unpublish, archive, trash, restore) support optimistic concurrency control to prevent lost updates:
- Pass the
If-MatchHTTP header with the entry's currentETag(for example,If-Match: "v3-..."), or - Pass
expectedVersion(integer) orexpectedEtagin the JSON request body.
If another editor or agent modified the entry in the meantime, OvertCMS Core rejects the write with 409 Conflict (version_conflict) and guarantees applied: false.
No-Op Detection#
If a PATCH produces identical canonical draftData, slug, and unpublishAt compared to the current entry, OvertCMS Core detects the no-op and returns changed: false without bumping version, inserting a redundant EntryVersion, or emitting an outbox event.
Partial PATCH, Null Semantics & clearFields#
By default, OvertCMS Core uses safe partial-merge semantics on PATCH so omitted or null fields from an LLM or form never accidentally wipe existing content:
| Input | Default Behavior | With X-Null-Semantics: clear |
|---|---|---|
Key omitted from data |
Unchanged | Unchanged |
"subtitle": null in data |
Ignored (unchanged) | Clears subtitle |
"clearFields": ["subtitle"] |
Explicitly clears subtitle |
Explicitly clears subtitle |
- Setting a field in both
dataandclearFieldsin the same request is rejected withfield_both_set_and_cleared. - For surgical edits inside long
rich_htmlbodies without resending the entire article, usebodyPatches(replace_exact,append_after,prepend_before)—see Rich HTML &<cms-block>.
Live Takedown Confirmation#
To prevent accidental outages from automated scripts or hasty clicks, taking down a currently published entry via Unpublish, Archive, or Trash requires explicit confirmation:
{
"expectedVersion": 4,
"confirmUnpublish": true,
"commitMessage": "Retiring Q1 promo landing page"
}Omitting confirmUnpublish: true on a published entry returns 409 live_takedown_confirmation_required with details.confirmField = "confirmUnpublish".
Scheduling & Automatic Unpublishing#
- Minimum lead time: Both
scheduledAt(when scheduling) andunpublishAt(when publishing) must be strictly more than 30 seconds in the future (minScheduleLeadTime). - Ordering invariant: When both are set,
unpublishAtmust be strictly afterscheduledAt. - Early publish rule: Manually publishing a
scheduledentry before itsscheduledAttime clearsscheduledAtand resetspublishedAt = now(). - Worker execution: The Worker Plane's
worker:schedulerjob keyset-paginates due entries across all sites (preventing starvation even if individual entries fail).- If an entry's
unpublishAtalready passed before the scheduler ran, it transitions straight todraftwithout ever going live. - If a scheduled entry fails publish-mode validation at publish time (for example, after a breaking schema update), the scheduler safely demotes it back to
draftwithdiffSummary: "schedule_failed_to_draft"and records anentry.schedule_failedaudit log so it does not spin forever.
- If an entry's
Automatic 301 Redirects & Chain Collapsing#
Whenever a previously published entry on a PostType with a urlTemplate is re-published with a new slug:
- OvertCMS Core atomically inserts a
301Redirectfrom the old public path (/blog/old-slug) to the new public path (/blog/new-slug). - Chain collapsing: Existing redirects pointing to
/blog/old-slugare atomically collapsed to point directly to/blog/new-slug(preventing multi-hop redirect chains). - Loop prevention: If an entry is published at a path that previously had an outbound redirect (
fromPath == newPublicPath), that stale redirect is automatically cleared.
Public clients and edge routers fetch active redirects from GET /delivery/v1/redirects (cached with the redirects Surrogate-Key).
Immutable Version History & Restoration#
Every create, update, publish, schedule, unpublish, archive, trash, and restore writes an immutable EntryVersion row containing:
version,status, fulldataSnapshot,diffSummary, optionalcommitMessage,actor,idempotencyKey, andcreatedAt.
Restoring a historical version rolls draftData back to that snapshot, creates a new monotonically increasing version (history is never rewritten), and leaves publishedData untouched until you explicitly publish.
Localization & Singletons#
- Locales: Configured per site (
localesanddefaultLocale, default["en"]). Every entry belongs to a single validatedlocaleand can optionally share atranslationGroupIdto link translated siblings across locales. - Slug uniqueness: Enforced atomically per
(site, postType, locale, slug)among non-trashed entries. - Non-slug
uniquefields: Enforced atomically at the database level viaentry_unique_valuesper(site, postType, locale, fieldKey). - Singletons: PostTypes with
"kind": "singleton"allow at most one non-trashed entry per locale (returning409 singleton_already_existson duplicate create or trash restore).
Single-Entry Signed Draft Previews#
To let editors or clients preview unpublished drafts without exposing drafts globally:
- An Admin or authorized Agent requests a preview token for a specific entry (
POST .../entries/{id}/preview-token, optionalttlSeconds, default 30 minutes, max 24 hours). - OvertCMS Core returns a one-time plaintext token (
pv_...) and stores only its hash inpreview_tokens. - The client fetches
GET /delivery/v1/{postType}/{idOrSlug}(or/delivery/v1/singletons/{slug}) with the header:
X-Preview-Token: pv_...- The Delivery Plane verifies the token matches that exact entry ID and has not expired, serves
draftData, bypasses the L2 cache completely, omitsSurrogate-Keyheaders, and setsVary: X-Preview-Token.