Repository navigation
Conversation
…CMS on the CDN
- newRevisionId / REVISION_ID_RE: <inv>-<uuidv7>, newest first (contract 1.2)
- blockVersion: sha256(canonicalJson(block))[0..16] base64url (contract 1.3)
- delivery store: revisions/<id>/{data,meta}.json keys, DELIVERY_KEY_PREFIX
(test-only), conditional PUTs on a maxAttempts: 1 client, 429/5xx/network
-> DeliveryUnavailableError, putText and a paged delimiter listPage
- record store: the private bucket's schema.json (plain PUT, conditional GET)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ntext The hosted CMS names drafts in a Postgres table unique on (site, name), replacing the KV entry per (project, branch). StudioContext.auth now says which credential authenticated the request (and on-behalf-of keys), so the server sets a revision's via. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- drafts: one public object {set, delete, editors} plus a drafts row; create
inserts if absent; editors stamped in the JSON
- content storage over latest revision + draft: saves read the draft once,
guard against the draft only, PUT with If-Match, no retries; a lost race
or R2 429/5xx is Unavailable; conflicts carry value, version and editor
from the save's own read
- publish steps 1-6 with 3 attempts reusing the draft read, previous in meta,
escaped data.json, previewHosts in latest.json only, purge failure only
logged; rollback steps 1, 4, 5 with reapplyOf, never-live refused
- releases paged by revision folder, live walk through previous
- the git-free save guards and blocksMajor marker writer move to their own
modules (the v8 git path re-exports them)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drafts (list, create, resolve, discard), the content-protocol RPC, publish, releases, rollback, schema push (sets blocksMajor) and site tokens, behind today's checks in order: caller (401), cms plan (403), org_sites (404), then a configured bucket (503). A lifecycle test runs every step with the git-providers module set to throw. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An oxlint jsPlugin keeps git-providers, the repo readers and the v8 git path's modules out of the CMS route, hosted/cms-* and the web CMS client. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
- content protocol on /api/:org/cms/:site/drafts/:branch/rpc, the site
from the project's metadata.siteSlug; opening the editor POSTs /drafts
{name: branch} for the preview pointer; a save's bare ETag moves it
- held-copy guards use blockVersion (sha256 of canonicalJson, 22 chars)
- the conflict dialog names who and when from the refusal's
draft[name].editor; no separate changedBy read
- the v8 gate is the project's blocksMajor marker; main's schema is not
read
Co-Authored-By: Claude Opus 5.5 <[email protected]>
POST /api/:org/cms/:site/drafts/:branch/publish; production_moved shows the "published meanwhile" message; no publish review read. The test file puts the real sandbox-git-api back after it mocks the module. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The hosted publish, releases, reapply and Try again routes, the git draft storage, MainMovedError and the latest.json/revisions/<sha>.json writer are gone: /api/:org/hosted/* is unmounted, and decofile.ts keeps only its v7 Fast Preview answers. v8 is the blocksMajor marker that deco schema push writes: the admin backfill, thread create and project create read it and never read git for it. delivery-store loses its sha-keyed revision reader. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A cms-runtime session on a site marked v8 answers 404 hosted_cms on /:vm/:branch/git/*: its content is on the hosted CMS. v7 sessions and v8 sandboxes keep their git routes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ban-cms-git-imports now covers apps/api/src/hosted/** (tests included) next to the cms routes and the web CMS client. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The editor no longer sends or handles the main-schema header; v8 is the project marker alone. Publish is live once it answers: no Try again, no Not live yet, no also-changed-on-main review. Releases read /api/:org/cms/:site/releases and Make current posts its rollback; site tokens use the cms route. Preview links name revision ids, not shas. Co-Authored-By: Claude Opus 5.5 <[email protected]>
MAIN_SCHEMA_HEADER, MAIN_SCHEMA_CHANGED, HOSTED_DELIVERY_UNCONFIGURED, hostedRevision(Parts), isV8SchemaText and schemaGenPath had no users left. The one-v8-detector guard follows the marker-based deciders. The e2e spec of the git-backed v8 editor goes with its routes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…v8 site The branch removed every v8 guard from decofile.ts, so a client in the v7 editor (a stale session, or one open when deco schema push set the marker) could PATCH .deco/blocks onto the branch through GitHub and Publish could merge it into main. A project with the blocksMajor marker now gets 409 hosted_cms on PATCH and POST publish, before any repository lookup. v7 projects are served as today. The route test replaces the deleted v8-gates.test.ts for this case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Releases walk meets revisions in listing order and follows previous from latest.json. Ids were minted from the local clock alone, so a publish from an instance whose clock ran behind the one that wrote its previous revision sorted after it: the walk then marked that previous revision, and every older one, never-live, while the rollback walk (wentLive) still accepted them. The id is now minted at max(now, previous's UUIDv7 time + 1 ms); publishedAt keeps the instance's clock. Contract §1.2 amended. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…backend The rule left out the files that pick and drive the hosted backend (use-content-backend.ts, content-protocol-api.ts) and the hosted Publish and Releases clients, so a decofile-api or git import could return there. They are covered now. content-protocol-api.ts imported its write keys and patch types from decofile-api.ts, the v7 git client; those move to content-write-keys.ts (no network), re-exported from decofile-api.ts so v7 callers are unchanged. decofile.ts and sandbox-proxy.ts stay outside the rule: they serve v7 from git and refuse v8 projects before any repository lookup. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The CMS rpc route answers 404 draft_not_found while the draft has no row,
and the only code that created the row (the pointer read) waited for the
probe to succeed. On a new thread branch, or after deco drafts discard of
it, the probe failed every 5 s forever and the editor never loaded. The
probe now runs POST /drafts {name: branch} (idempotent) first, then
describe and schema.get.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t follows" This reverts commit 984aea2. Owner decision: revision ids use the minting instance's clock only, as the design says; the clock-skew display risk is accepted. Contract §1.2 amendment removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… meta cache - Migration 261 (edited in place): drafts.site REFERENCES org_sites(slug) ON DELETE CASCADE, so releaseSite works for a site with drafts (new integration test). - Draft discard deletes the R2 object before the row: a failed delete keeps the row and the discard can run again. - delivery-store delete and listPage map R2 429/5xx/network to DeliveryUnavailableError, like get and the conditional PUTs. - A meta.json that is there but unparseable is MalformedObjectError, and so is a missing one on the rollback's previous walk: a broken chain answers 500 malformed, not 409 never_live. - Parsed meta.json files are cached by (site, id) (written once, create-only); an absent one is never cached. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The CLI no longer names an org (no .deco/link.json; the site comes from DECO_SITE), so the hosted CMS routes move out of /api/:org to /api/cms/:site, mounted in app.ts before the /api/:org catch-all. The site's organization is the org_sites row's (slug is the key). Gates, in order (contract §4.1): - 401 with no caller; - 404 site_not_found, one body, for an unknown site, a tombstone, or a site of an org the caller can't reach. Admission runs the same checks /api/:org does (archived org, API key / token bound to another org, membership or the task-board admin rule), through helpers extracted from resolveOrgFromPath with its behaviour unchanged, then binds the org scope; - 403 feature_not_in_plan, on the resolved org; - 403 org_blocked for a blocked org's writes, as enforceOrgBlock does; - 503 hosted_delivery_unconfigured. "Organization scope required" goes with the org in the path. Error codes: a delivery object Studio didn't write is 500 malformed (MalformedObjectError). The site-tokens "not configured" 503 now carries hosted_delivery_unconfigured. Web: cmsUrl(site, path) and every caller (editor draft and rpc, publish, releases, rollback, site tokens) use /api/cms/:site. A new test drives a v8 project with GitHub off (ensure, probe, read, save, publish) against a mocked fetch and asserts every request is under /api/cms/:site, never /decofile/ nor a sandbox's /git/*. blockVersion stays a copy in apps/api and the web: @decocms/blocks has no preview releases, and a git dependency on the branch installs the unbuilt monorepo root without the /protocol subpath. Noted as a known deviation in the contract (§1.3). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…led list
GET /api/cms/:site/releases no longer fails when a revision's meta.json
doesn't parse, its GET fails, or the folder the live walk expects has
none: that folder is {id, status: "unreadable"} with no meta, and the
walk stops at it, so older revisions are never-live (what the list shows
when the walk can't reach them). A rollback to or through it still
answers 500 malformed. The web Releases tab lists it as a plain row with
its date only, no Make current or Preview.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lure Only a meta read and parsed is cached (TTL unchanged); a fixed object is seen on the next read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
/api/cms/:site (the hosted CMS) shadows /api/cms/... of an org named cms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Owner decision: the Releases list drops the live / never-live status. It is
a plain prefix listing of revisions/ (newest first, the same cursor, now
{token} only): the revision latest.json names is `current`, every other
readable one `listed`, an unparseable meta.json an `unreadable` row. A
meta.json GET that fails (R2 429/5xx/network) now fails the list with 503
`unavailable` instead of becoming an unreadable row. No walk of
meta.previous (it is still written by publish).
Rollback reapplies any revision with a readable meta.json and data.json:
the 409 `never_live` answer and wentLive are gone. Its target meta.json
unparseable is 500 `malformed`; no folder or no meta.json stays 404
`revision_not_found`. Before the first latest.json it applies over an
empty site, as publish does (previous null).
Web: every listed revision is shown; Make current on every row but the
current one and unreadable ones.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t_published)
POST /api/cms/:site/releases/:revision/rollback with no latest.json now
answers 409 {"error","code":"not_published"} and writes nothing, instead
of applying the target over an empty site (contract §4.3, §4.11). The
target's meta.json checks (404 revision_not_found, 500 malformed) still
come first. The rollback answer's previous/revision are never null now.
Releases: "Make current" is offered only once the site was published
(the page's live revision), and a not_published answer gets its own
toast ("Your site hasn't been published yet...").
Co-Authored-By: Claude Opus 5.5 <[email protected]>
After Publish (or "Make current") the draft is emptied and the frame navigated to its pointer, which the site layers over the release it serves. A site that hasn't picked the new latest.json up yet (an edge before the purge lands, a missed purge) rendered the OLD release, and the frame stayed on it until something reloaded it. The write's answer names the new revision: until the next content change the hosted previews (frame, new tab, every preview link) send that revision id as __draft (the SDK reads revisions/<id>/data.json, immutable), with the "Preview as" options. Any other change (a save, a discard, someone else's change) goes back to the draft pointer. Forced variants keep the draft pointer (a revision id can't carry them). Co-Authored-By: Claude Opus 5.5 <[email protected]>
revisionContent, encodeCursor, readSiteSchema, applyAttempt, conflictBlocks, recordKeys, createS3RecordStore, REVISION_ID_RE and isApplyCall had no importer, which failed bun run knip. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The deco serve spec made its v8 project by seeding a v8 schema on the GitHub stub main and reading it through the decofile rpc, the deleted v8 git path (404 now). It now pushes the schema to PUT /api/cms/:site/schema, which stores it and sets the blocksMajor marker, as deco schema push does. The e2e server gets a record bucket for that: the delivery stub, under the records/ key prefix. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
force-pushed
the
cdn-cms/studio-r2
branch
from
November 5, 2026 12:15
5a1cd2c to
5fe5ea8
Compare
Conflicts: - apps/api/migrations/index.ts: main added 261-remove-user-registered-sso-providers (already released). Keep it and rename this branch's unreleased 261-cms-drafts to 262-cms-drafts so it sorts after the executed one (Kysely refuses to run a pending migration ordered before an executed one). The table is created ifNotExists, so databases that already ran 261-cms-drafts are fine. - apps/api/src/core/studio-context.ts: keep both StudioAuth additions (method/onBehalfOf from this branch, boundThreadId from main). Co-Authored-By: Claude Opus 5.5 <[email protected]>
tlgimenes
marked this pull request as ready for review
November 6, 2026 12:42
Contributor
Author
|
Folded into #8379: one PR for this project. That branch contains every commit from this one, plus the merge of main. |
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.
Blocks v8 CMS on the CDN: Studio API on R2, with the v8 git path deleted. Design: https://claude.ai/artifact/GktQvu5uBYvPbcR7ZDGtyu
API
/api/cms/:site/.... The org is looked up fromorg_sites. Gates run in this order:latest.json(the only commit point, written with If-Match / If-None-Match),revisions/<id>/{data,meta}.json, anddrafts/<slug>.json{set, delete, editors}.schema.jsongoes in the private record bucket.blocks.apply): each block'sifMatchis checked against the draft. A save is all or nothing, with no retries. A conflict returns the other editor's value, user and time. R2 answers of 429 or 5xx returnunavailable.production_moved. A failed purge is only logged.not_published.revisions/. Rows arecurrent,listedorunreadable(a brokenmeta.json), and a transient R2 failure answersunavailable.draftstable (migration 261,ON DELETE CASCADEonorg_sites).{error, code}, includingmalformedfor broken delivery objects.Deleted
hosted_cmsto edits and publishes from a Blocks v8 site. v7 is unchanged.Web
Known deviation
blockVersionuntil a@decocms/blocksrelease exports it (contract §1.3).Tests
spikes/e2e/, cleaned up afterwards).Update with main: main is merged in (f045976). Main had already released a migration numbered 261 (
261-remove-user-registered-sso-providers, #8339), so the CMS drafts migration is now262-cms-drafts. The table is created only if it doesn't exist, so databases that already ran it under the old number are fine. TheStudioAuthconflict kept both sides' fields.Related: decocms/blocks
cdn-cms/sdk-cli, deco-sites/demo-storefrontcdn-cms/sdk-8.2.🤖 Generated with Claude Code