Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .baseline/product/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ opening a Studio with nothing behind it. To make it read your content:
```

Without it the Studio's live preview is refused (the draft-mode route
answers 401 and says why); everything else works.
answers 401 and says why); everything else works. With it, open the
Presentation tool once and confirm the preview loads: the draft-mode
cookies it relies on inside the Studio's iframe (`SameSite=None;
Partitioned`) are tested with a mocked client, not yet in a browser.

Then write at `/studio`. Published changes show on the blog within a minute
(Sanity's API CDN cache) — no deploy.
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ jobs:
echo "── $t"
bash "testing/$t.test.sh"
done
# Every component's docs/{overview,architecture,runbook}.md is generated
# from what the component declares (its manifest, Worker config,
# Terraform, migrations, package scripts). A pull request that changes
# one of those facts without regenerating the pages fails here.
- name: Component docs match their manifests
run: python3 tooling/catalog/gen-component-docs.py --check

# Tier 1. THE BLUEPRINT, READ AND PLACED BY THE BINARY A BOOTSTRAP RUNS.
#
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

Vercel's [Blog with Sanity CMS](https://github.com/vercel/next.js/tree/canary/examples/cms-sanity)
— posts, authors and settings in a Sanity dataset read over GROQ with
`next-sanity`, draft mode with live preview through the Presentation tool,
`next-sanity`, draft mode with live preview through the Presentation tool
(unchanged in code; not yet exercised in a browser — risk CS-H),
Sanity TypeGen, AI Assist and Unsplash presets, and the Sanity Studio
embedded at `/studio` — running on **Cloudflare Workers + Static Assets**
through [`@opennextjs/cloudflare`](https://opennext.js.org/cloudflare), and
Expand Down Expand Up @@ -130,7 +131,7 @@ pnpm preview # wrangler dev over the built Worker
| Project env vars in the dashboard | Build time: project id and dataset from optional Orun secrets, inlined by `next build`. Run time: the read token as a Worker secret |
| A missing env var fails every route | An unconnected blog: sample posts, a notice, a connect page — deployable before a Sanity project exists |
| Time-based ISR (`revalidate: 60`) | Sanity's API CDN, same 60 s TTL; nothing is pre-rendered or revalidated in the Worker |
| Draft mode / Presentation live preview | Unchanged (`/api/draft-mode/enable`, cookies, `VisualEditing`) |
| Draft mode / Presentation live preview | Unchanged in code (`/api/draft-mode/enable`, cookies, `VisualEditing`); not yet exercised in a browser against a Sanity project — risk CS-H |
| The Studio rendered on the server | Loaded client-side only; megabytes of static chunks, a small Worker |
| Vercel Speed Insights | Cloudflare Web Analytics beacon (`app/(blog)/analytics.tsx`) |
| Deploy on push | Orun deploys `<repo>-web-{stage,prod}` on merge to `main` and smoke-tests it (`apps/web/component.yaml`) |
Expand Down
44 changes: 44 additions & 0 deletions ai/context/current.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# cms-sanity — where this repository stands

The entry page for anyone (or any agent) picking this repository up. It is
this repository's own state and does not ship to a blog built from it; the
two pages that do are [operations.md](operations.md) and
[deployment.md](deployment.md).

## What it is

Vercel's Blog with Sanity CMS on Cloudflare Workers + Static Assets
(`@opennextjs/cloudflare`) — posts read over GROQ from a Sanity dataset, the
Studio embedded at `/studio` and loaded client-side — packaged as an Orun
baseline: `orun new --blueprint repo-blueprint.yaml` builds a new blog in its
own repository and takes it to live on stage and prod in one landing
(`01-product`), then records what went live (`02-docs`). It deploys before
its owner has a Sanity project: unconnected, the blog serves bundled sample
posts under a "connect your Sanity project" notice. There is no infra
component; Sanity stays the owner's SaaS.

## Release

| | |
|---|---|
| Latest tag | `baseline-v1` (CS3) |
| On `main` since | CS4 — the cirrus standard (no kiox, generated component docs, this context pack) |
| Proven live | No. Everything short of the platform is proven offline in Baseline CI, unconnected; a live bootstrap (risk CS-M) and a connected blog reading a real dataset, its Presentation preview included (risk CS-H), are still to come |

## Where to read

| Question | Page |
|---|---|
| What shipped, and every departure from upstream | `specs/epics/cms-sanity/IMPLEMENTATION-STATUS.md` |
| Why it is built this way | [decisions.md](decisions.md), then `specs/epics/cms-sanity/design.md` |
| What could still go wrong | [open-risks.md](open-risks.md), then `specs/epics/cms-sanity/risks-and-open-questions.md` |
| How to instantiate it | `BOOTSTRAP.md`, `docs/phases/` |
| What each component is | `apps/web/docs/`, `tests/web/docs/` (generated; `python3 tooling/catalog/gen-component-docs.py`) |

## Next

1. Bootstrap one blog from the next tag against a workspace, and record its
timings (closes CS-M).
2. Connect a Sanity project to it, see the samples give way, and open the
Presentation tool once to confirm the preview loads (closes CS-H).
3. Cut the next `baseline-vN` with `tag.yml` so the registry can pin CS4.
20 changes: 20 additions & 0 deletions ai/context/decisions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# cms-sanity — decisions

The choices that shape this repository, one line each, with where the full
reasoning lives. Superseded decisions stay listed, marked, so the history
reads in order.

| # | Decision | Why | Source |
|---|---|---|---|
| 1 | OpenNext on Workers + Static Assets (`cloudflare-workers-assets-turbo`), the static-assets incremental cache; no R2 or Durable Object cache | Nothing in the Worker is revalidated | `specs/epics/cms-sanity/README.md`, design.md §2 |
| 2 | Blog routes `force-dynamic` + `fetchCache = "force-no-store"`; Sanity's API CDN (60 s) is the cache | Time-based ISR needs a writable cache the static-assets one is not; the CDN's TTL was what the ISR interval matched | risk CS-A |
| 3 | The Studio loads client-side (`next/dynamic`, `ssr: false`), its layout's metadata written out | Rendered on the server it put 7 MB gzip in the Worker; client-side the Worker is 1.6 MB gzip | risk CS-B |
| 4 | Sanity on its Next 16 lines (next-sanity 13, sanity 6), and Tailwind 4, CSS-first | Upstream's lines do not declare Next 16; Studio v6's stylesheet uses cascade layers Tailwind 3 rejects | risks CS-C, CS-E |
| 5 | The unconnected blog: no Sanity project at build serves bundled samples, a notice, a connect page and draft mode's 401 — nothing throws | The platform brokers Cloudflare, not Sanity, so a bootstrap deploys before the owner has a project (CS3) | design.md §6, risks CS-G, CS-J |
| 6 | Project id and dataset are `optionalSecretEnv`, read at build; the read token is an optional Worker secret | A required ref fails the lane before its first step on a fresh product; a deploy never touches a Worker secret | IMPLEMENTATION-STATUS (CS3) |
| 7 | Setting a Sanity secret redeploys nothing; the owner bumps the `# orun: redeploy` stamp in `apps/web/component.yaml` | `orun plan --changed` plans a component only when its files change | risk CS-K |
| 8 | The Cloudflare Web Analytics beacon in place of Speed Insights, opt-in by token | Speed Insights has no Cloudflare twin; the beacon reports Core Web Vitals | risk CS-F |
| 9 | Two phases, one landing (`01-product`, `02-docs`), no infra component | A landing has a fixed cost (cirrus-baseline since baseline-v22); the blog provisions nothing | design.md §6 |
| 10 | `ci.yml` plans nothing while `intent.yaml` names `ws_CHANGE_ME` (replaced the `ORUN_CI` gate); stack-tectonic 0.19.0, not 0.20.0 | A bootstrap cannot set a repository variable; Turbopack refuses 0.20.0's out-of-tree `node_modules` | IMPLEMENTATION-STATUS (CS3) |
| 11 | orun is pinned only where it runs (the `orun-action` `version:` in each workflow); no kiox | `kiox.yaml` pinned a version nothing ran | IMPLEMENTATION-STATUS (CS4) |
| 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph and bindings drifts silently | `tooling/catalog/gen-component-docs.py` |
16 changes: 16 additions & 0 deletions ai/context/open-risks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# cms-sanity — open risks

What is not yet proven or not yet decided. The full write-up of every risk,
including the accepted and resolved ones, is
`specs/epics/cms-sanity/risks-and-open-questions.md`; this page lists only
what is still live, so it should be short.

| ID | Risk | State | What closes it |
|---|---|---|---|
| CS-M | Not proven live: repository creation, the brokered token, a real deploy and the probes, and a connected blog reading a real dataset through the Worker | OPEN | One bootstrap from a tag against a workspace, then a Sanity project connected to it |
| CS-H | Draft-mode cookies inside the Presentation iframe (`SameSite=None; Partitioned` on workers.dev) are tested with a mocked client, never in a browser against a Sanity project | OPEN | The first connected product opens the Presentation tool once and confirms the preview loads |

Accepted, and worth knowing before you change them: CS-F (Speed Insights has
no one-to-one twin), CS-I (upstream's perspective precedence, kept as
written), CS-K (setting a secret redeploys nothing), CS-L (a connected blog
with a wrong project answers 500, unmasked).
21 changes: 21 additions & 0 deletions apps/web/docs/architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# web — architecture

Built by the turbo pipeline from `apps/web` and deployed with wrangler.

| | |
| ------------------- | ----------------------------------------------- |
| Worker config | `apps/web/wrangler.jsonc` |
| Entry | `.open-next/worker.js` |
| Compatibility date | `2026-10-01` |
| Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` |

## Bindings

| Binding | Kind | Source |
| -------- | ------------- | ------------------- |
| `ASSETS` | Static assets | `.open-next/assets` |

## Secrets resolved by the lane (names only)

- `NEXT_PUBLIC_SANITY_DATASET` (optional)
- `NEXT_PUBLIC_SANITY_PROJECT_ID` (optional)
20 changes: 20 additions & 0 deletions apps/web/docs/overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# web

The Sanity-backed blog and its embedded Studio (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment)

A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane.

| | |
| ------------ | ------------------------------------------------------------------------------------------------------------------ |
| Type | `cloudflare-workers-assets-turbo` |
| Source | `apps/web` |
| Package | `@app/web` |
| Environments | `dev`: `verify` · `stage`: `verify`, `deploy` on a push to `main` · `prod`: `verify`, `deploy` on a push to `main` |

## Depends on

- (none)

## Depended on by

- (none)
37 changes: 37 additions & 0 deletions apps/web/docs/runbook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# web — runbook

## How it runs

Pull requests verify it; a merge to `main` deploys it to `stage`, `prod`.
CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`;
the plan orders a component after everything it depends on.

## Local commands

```bash
pnpm --filter @app/web dev
pnpm --filter @app/web build
pnpm --filter @app/web typecheck
pnpm --filter @app/web lint
pnpm --filter @app/web preview
```

## Verify

After a deploy the lane runs this smoke against the environment it
deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL:

```bash
html=$(curl -sfL "${DEPLOYED_URL}/") && echo "${html}" | grep -q 'bg-white text-black' && test "$(curl -s -o /dev/null -w '%{http_code}' "${DEPLOYED_URL}/api/draft-mode/enable")" = 401
```

## Rollback

Revert the commit on `main`. The next convergence applies the previous desired
state; nothing was changed out of band, so there is nothing else to undo.

## Common failures

- **The smoke fails right after a first deploy**: a new workers.dev route can
answer 4xx for a few seconds and the lane retries. A failure that persists
is a regression in the deployed code.
2 changes: 1 addition & 1 deletion docs/phases/01-product.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Places** everything a blog built from this baseline is made of, as ONE
pull request: the root manifests (`intent.yaml`, `package.json`, the pnpm
workspace and lockfile, `turbo.json`, the kiox pin), `.github/workflows`
workspace and lockfile, `turbo.json`), `.github/workflows`
(`ci.yml` and `checks.yml` — the baseline's own `baseline.yml` and
`tag.yml` are ignored), the shared TypeScript/ESLint config and the wrangler
renderer, the blog's README and its two context pages, the identity file
Expand Down
11 changes: 0 additions & 11 deletions kiox.lock

This file was deleted.

6 changes: 0 additions & 6 deletions kiox.yaml

This file was deleted.

12 changes: 1 addition & 11 deletions repo-blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,6 @@ modules:
source: baseline
from: turbo.json
to: turbo.json
- name: root-kiox
mode: copy
source: baseline
from: kiox.yaml
to: kiox.yaml
- name: root-kiox-lock
mode: copy
source: baseline
from: kiox.lock
to: kiox.lock
- name: root-gitignore
mode: copy
source: baseline
Expand Down Expand Up @@ -392,7 +382,7 @@ phases:
await: "One convergence is deploying the blog to stage and prod: install, the Next.js build, deploy and a smoke in each. The build is the long pole; nothing is stuck."
done: "{{ .inputs.reponame }} is live on stage and prod — {{ .meta.files }} files on main, branded as {{ .inputs.productname }}, serving its sample posts until a Sanity project is connected. That took {{ .meta.elapsed }}."
failed: "The blog did not come up. The failing lane above names the step — the build, the deploy or the smoke — and a provider error is in its log; whatever deployed is still there."
modules: [ai-deployment, ai-operations, discovery-roots, github-workflows, rebrand-values, root-gitignore, root-intent, root-kiox, root-kiox-lock, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, tooling-eslint, tooling-tsconfig, tooling-wire, vscode, web, web-tests]
modules: [ai-deployment, ai-operations, discovery-roots, github-workflows, rebrand-values, root-gitignore, root-intent, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, tooling-eslint, tooling-tsconfig, tooling-wire, vscode, web, web-tests]
# THE PLATFORM MUST BE ABLE TO SEE THE REPOSITORY BEFORE IT EXISTS. Every
# phase lands a pull request that files under its task, and the platform
# learns of a PR only through the GitHub App installation on the account
Expand Down
2 changes: 1 addition & 1 deletion specs/epics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ folder is the adoption; the merge creates the epic in the workspace.

| Epic | Cluster | Status | What it is |
|------|---------|--------|------------|
| [`cms-sanity/`](./cms-sanity/) | **CS** | 🟡 In progress | Vercel's Sanity CMS blog, equivalent in code and function, running on Cloudflare Workers + Static Assets via OpenNext — and an Orun baseline that instantiates it in one landing, deployable before a Sanity project exists (CS3) |
| [`cms-sanity/`](./cms-sanity/) | **CS** | ✅ Shipped (`baseline-v1`); live bootstrap pending | Vercel's Sanity CMS blog, equivalent in code and function, running on Cloudflare Workers + Static Assets via OpenNext — and an Orun baseline that instantiates it in one landing, deployable before a Sanity project exists (CS3) |

As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`.
Loading
Loading