From 2bf7a6c694594062af59686679ec7f4d5c2f02d8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:24:31 +0000 Subject: [PATCH 1/5] =?UTF-8?q?CS4:=20the=20cirrus=20standard=20=E2=80=94?= =?UTF-8?q?=20no=20kiox,=20generated=20component=20docs,=20the=20context?= =?UTF-8?q?=20pack?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove kiox.yaml/kiox.lock and their two blueprint modules: nothing ran the kiox pin (v2.15.0); every workflow pins orun through orun-action. docs/phases/01-product.md no longer lists a kiox pin. - Generate docs/{overview,architecture,runbook}.md for every component (web, web-tests) from what it declares (tooling/catalog/gen-component-docs.py), and fail Baseline CI when they drift (--check). - Add ai/context/{current,decisions,open-risks}.md (this repository's own; nothing places them). - Qualify the Presentation live preview as unchanged in code but not yet exercised in a browser (risk CS-H, open) in the README and design.md; the blog's README asks its owner to check it once. - Close out CS3 (shipped, tagged baseline-v1) and record CS4 (CS-5). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- .baseline/product/README.md | 5 +- .github/workflows/baseline.yml | 6 + README.md | 5 +- ai/context/current.md | 44 ++ ai/context/decisions.md | 20 + ai/context/open-risks.md | 16 + apps/web/docs/architecture.md | 16 + apps/web/docs/overview.md | 20 + apps/web/docs/runbook.md | 40 ++ docs/phases/01-product.md | 2 +- kiox.lock | 11 - kiox.yaml | 6 - repo-blueprint.yaml | 12 +- specs/epics/README.md | 2 +- .../epics/cms-sanity/IMPLEMENTATION-STATUS.md | 38 +- specs/epics/cms-sanity/README.md | 7 +- specs/epics/cms-sanity/design.md | 2 +- specs/epics/cms-sanity/epic.yaml | 7 + specs/epics/cms-sanity/implementation-plan.md | 30 +- tasks/CS-5.TaskContract.yaml | 30 + testing/phases.test.sh | 2 +- tests/web/docs/architecture.md | 11 + tests/web/docs/overview.md | 18 + tests/web/docs/runbook.md | 26 + tooling/catalog/gen-component-docs.py | 519 ++++++++++++++++++ tooling/rebrand/rebrand.mjs | 1 - 26 files changed, 854 insertions(+), 42 deletions(-) create mode 100644 ai/context/current.md create mode 100644 ai/context/decisions.md create mode 100644 ai/context/open-risks.md create mode 100644 apps/web/docs/architecture.md create mode 100644 apps/web/docs/overview.md create mode 100644 apps/web/docs/runbook.md delete mode 100644 kiox.lock delete mode 100644 kiox.yaml create mode 100644 tasks/CS-5.TaskContract.yaml create mode 100644 tests/web/docs/architecture.md create mode 100644 tests/web/docs/overview.md create mode 100644 tests/web/docs/runbook.md create mode 100644 tooling/catalog/gen-component-docs.py diff --git a/.baseline/product/README.md b/.baseline/product/README.md index a6e9826..9e3bda3 100644 --- a/.baseline/product/README.md +++ b/.baseline/product/README.md @@ -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. diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index 1fa7ea1..1490342 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -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. # diff --git a/README.md b/README.md index 6934681..73c8e91 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 `-web-{stage,prod}` on merge to `main` and smoke-tests it (`apps/web/component.yaml`) | diff --git a/ai/context/current.md b/ai/context/current.md new file mode 100644 index 0000000..4d699e2 --- /dev/null +++ b/ai/context/current.md @@ -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. diff --git a/ai/context/decisions.md b/ai/context/decisions.md new file mode 100644 index 0000000..ce7a8c3 --- /dev/null +++ b/ai/context/decisions.md @@ -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` | diff --git a/ai/context/open-risks.md b/ai/context/open-risks.md new file mode 100644 index 0000000..9f2a429 --- /dev/null +++ b/ai/context/open-risks.md @@ -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). diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md new file mode 100644 index 0000000..d402ed6 --- /dev/null +++ b/apps/web/docs/architecture.md @@ -0,0 +1,16 @@ +# 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` | diff --git a/apps/web/docs/overview.md b/apps/web/docs/overview.md new file mode 100644 index 0000000..d19e0cf --- /dev/null +++ b/apps/web/docs/overview.md @@ -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) diff --git a/apps/web/docs/runbook.md b/apps/web/docs/runbook.md new file mode 100644 index 0000000..4d5118d --- /dev/null +++ b/apps/web/docs/runbook.md @@ -0,0 +1,40 @@ +# 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 + +- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream + has not applied for this environment yet. Within one convergence the plan + runs it first; on its own, re-run that lane. +- **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. diff --git a/docs/phases/01-product.md b/docs/phases/01-product.md index d7a4bc6..4661db1 100644 --- a/docs/phases/01-product.md +++ b/docs/phases/01-product.md @@ -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 diff --git a/kiox.lock b/kiox.lock deleted file mode 100644 index 6e14690..0000000 --- a/kiox.lock +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: kiox.io/v1 -kind: WorkspaceLock -metadata: - name: example-platform -providers: - - alias: orun - provider: sourceplane/orun - source: ghcr.io/sourceplane/orun:v2.15.0 - version: v2.15.0 - resolved: ghcr.io/sourceplane/orun@sha256:1d28be8612dc8d8083b508f97cd71a24c090f6472c43c71f68455e3709a6a3c1 - store: e02472f57f2eb5fb5168b7d270ea547e5bffbf83824c4286abd7ba20f87cb9d1 diff --git a/kiox.yaml b/kiox.yaml deleted file mode 100644 index d654da0..0000000 --- a/kiox.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kiox.io/v1 -kind: Workspace -metadata: - name: example-platform -providers: - orun: ghcr.io/sourceplane/orun:v2.15.0 diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 513246a..3c463d2 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -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 @@ -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 diff --git a/specs/epics/README.md b/specs/epics/README.md index 53043de..b2eb6b0 100644 --- a/specs/epics/README.md +++ b/specs/epics/README.md @@ -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`. diff --git a/specs/epics/cms-sanity/IMPLEMENTATION-STATUS.md b/specs/epics/cms-sanity/IMPLEMENTATION-STATUS.md index 81e8df2..d22fc64 100644 --- a/specs/epics/cms-sanity/IMPLEMENTATION-STATUS.md +++ b/specs/epics/cms-sanity/IMPLEMENTATION-STATUS.md @@ -8,7 +8,8 @@ the code departed from `design.md` or from the upstream template. | CS0 — the spec | ✅ Shipped | [#1](https://github.com/sourceplane/cms-sanity/pull/1) | | CS1 — the blog on Workers | ✅ Shipped | [#2](https://github.com/sourceplane/cms-sanity/pull/2) | | CS2 — ready to instantiate | ✅ Shipped | [#3](https://github.com/sourceplane/cms-sanity/pull/3) | -| CS3 — a baseline | 🟡 In review | this PR (CS-4), to be tagged `baseline-v1` | +| CS3 — a baseline | ✅ Shipped | [#4](https://github.com/sourceplane/cms-sanity/pull/4) (CS-4), tagged `baseline-v1` | +| CS4 — the cirrus standard | ✅ Shipped | CS-5 — on `main` after `baseline-v1`, not yet tagged | ## Departures from the upstream template @@ -143,6 +144,41 @@ Settings document's initial title. The sample posts are signed with it. | discovery roots | `apps/`, `tests/` only | `infra/.gitkeep`, `packages/.gitkeep` too | `orun plan` refuses a missing discovery root | | `tasks/CS-1..3` | no `metadata` | `metadata.name` and `title` | `orun work check` (2.79) | +## The cirrus standard (CS4) + +Nothing about the blog changed. What changed is the baseline around it: + +| What | Before | After | Why | +|---|---|---|---| +| orun pin | `kiox.yaml` (v2.15.0) + `kiox.lock`, shipped to every blog | gone; orun is pinned where it runs, the `orun-action` `version:` in each workflow | nothing ran the kiox pin, and it disagreed with the lanes (v2.78.4) | +| `root-kiox`, `root-kiox-lock` modules | in `01-product` | removed (`testing/phases.test.sh`, the rebrand's skip list and `docs/phases/01-product.md` follow) | a blog is placed with 93 − 2 + 6 = 97 files: no kiox, plus the docs below | +| component docs | none | `apps/web/docs/` and `tests/web/docs/` — `overview.md`, `architecture.md`, `runbook.md` | cirrus-baseline documents every component; the workspace Docs library renders `docs/` beside each `component.yaml` | +| how the docs stay true | — | `tooling/catalog/gen-component-docs.py` derives them from the manifest, the Worker config, Terraform, migrations and package scripts; Baseline CI runs it with `--check` | a hand-written copy of a manifest drifts silently | +| context pack | `operations.md`, `deployment.md` | plus `current.md`, `decisions.md`, `open-risks.md` | cirrus-baseline's shape; the three new pages are this repository's own and no module places them (the leak gate still allows exactly two) | +| the Presentation preview in the READMEs and `design.md` | "Unchanged" (the root README's opening line and mapping table) | unchanged in code, not yet exercised in a browser (risk CS-H); the blog's README asks its owner to open the Presentation tool once after adding the token | CS-H is open: the draft-mode route is tested with a mocked client only | +| status | CS3 "in review … to be tagged `baseline-v1`" | CS3 shipped and tagged `baseline-v1` | the tag existed; the documents had not caught up | + +## Verified (CS4) + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green; `gen-component-docs.py --check` green (2 components, 6 pages). +- `testing/leak.test.sh` (v2.58.11): 97 files derived (93 − 2 kiox + 6 docs + pages), every one read; ai/context still exactly the two declared pages; + no shipped file names a factory path; no provenance prose. +- `testing/placement.test.sh` (v2.78.4, as `baseline.yml` runs it): 97 files + placed, both landings, branded, re-tenanted; the blog's own `orun plan` + deploys `web` to stage and prod side by side with the Sanity refs + optional; `--resume` changes nothing. +- `pnpm install --frozen-lockfile`, `wire:fixture` (and `git diff + --exit-code`), `typecheck`, `lint` (0 errors, the one upstream warning), + `test` (18 tests in 5 files), `build` green, with no Sanity values set. +- `testing/e2e.test.sh` (v2.78.4) green with no Sanity credentials: both + landings under the Checks sequence, every run step of the stage lane in a + staged job tree (the dry run bundles 7872 KiB, 1628 KiB gzip), `wrangler + dev` over the staged Worker, the component's smoke and every route the + blog promises. +- `orun task check CS-5` complete. + ## Verified (CS3) - `orun new --status` reads the blueprint at v2.58.11 (the bootstrap floor), diff --git a/specs/epics/cms-sanity/README.md b/specs/epics/cms-sanity/README.md index b910f3d..5d3359e 100644 --- a/specs/epics/cms-sanity/README.md +++ b/specs/epics/cms-sanity/README.md @@ -8,15 +8,15 @@ The upstream code stays the code: the GROQ queries, the schemas, the Portable Te | Field | Value | |-------|-------| -| Status | 🟡 CS0–CS2 shipped (#1, #2, #3); CS3 — a baseline — in this PR (CS-4), not yet proven by a live bootstrap | -| Cluster | **CS** (CS0–CS3) | +| Status | ✅ CS0–CS3 shipped (#1–#4), CS3 tagged `baseline-v1`; CS4 (the cirrus standard, CS-5) on `main`, not yet tagged. Not yet proven by a live bootstrap (risk CS-M) | +| Cluster | **CS** (CS0–CS4) | | Owner(s) | `apps/web` (the blog and the Studio) · `tests/web` (image URLs, the date component, the draft-mode route, the unconnected blog) · the baseline (`blueprint.yaml`, `repo-blueprint.yaml`, `.baseline/`, `testing/`) | | Builds on | `cirrus-baseline` conventions; the `portfolio-starter-kit` port's build shape (static-assets incremental cache + `populateCache`) and its analytics beacon; the `turso-starter` port's `force-dynamic` answer to a read-only cache | | Upstream | [vercel/next.js `examples/cms-sanity`](https://github.com/vercel/next.js/tree/canary/examples/cms-sanity) at `a871df1` (2026-10-14) | | Changes | Adds the Workers build, the monorepo wrapper, tests and the deploy contract; makes the blog routes dynamic; mounts the Studio client-side; swaps Speed Insights for one Cloudflare beacon; moves next-sanity/sanity to their Next 16 lines and Tailwind to 4 | | Decisions locked | (1) OpenNext on Workers + Static Assets, the static-assets incremental cache. (2) Blog routes `force-dynamic` + `fetchCache = "force-no-store"`; Sanity's API CDN is the cache; no R2/DO cache. (3) The Studio loads through `next/dynamic` with `ssr: false`; the Studio layout's metadata is written out, not re-exported. (4) Project id and dataset are build-time values the Orun build reads from the product's secrets — best-effort since CS3 (`optionalSecretEnv`): with none, the blog renders bundled sample posts under a "connect your Sanity project" notice; the read token is an optional Worker secret. (5) Tailwind 4, CSS-first. (6) CS3: two phases, one landing (cirrus-baseline v22). | | Gate | CS1 is the first user-visible rung. | -| Shipped as | `main` after [#3](https://github.com/sourceplane/cms-sanity/pull/3); verified locally under `wrangler dev` with no Sanity project, deploy gated until a workspace is linked | +| Shipped as | `baseline-v1` ([#4](https://github.com/sourceplane/cms-sanity/pull/4)), then CS4 on `main`; proven offline (Baseline CI, with no Sanity project), deploy gated until a workspace is linked | ## Read order @@ -33,3 +33,4 @@ The upstream code stays the code: the GROQ queries, the schemas, the Portable Te | CS1 — the blog on Workers | `apps/web` built by OpenNext, `tests/web`, green checks | `wrangler dev` serves the Studio shell, its chunks, a 401 and a 404; the Worker bundle holds no Studio code; Checks green | | CS2 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it against their own Sanity project | | CS3 — a baseline | card, build document, rename, bootstrap tooling, tests; the unconnected blog | a new blog goes from nothing to live in one landing with no Sanity project; Baseline CI green | +| CS4 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags | Baseline CI green with the docs check | diff --git a/specs/epics/cms-sanity/design.md b/specs/epics/cms-sanity/design.md index bfb1766..30d28d4 100644 --- a/specs/epics/cms-sanity/design.md +++ b/specs/epics/cms-sanity/design.md @@ -29,7 +29,7 @@ sanity typegen generate`. Tailwind 3 with the typography plugin, Inter from | `NEXT_PUBLIC_SANITY_PROJECT_ID`, `NEXT_PUBLIC_SANITY_DATASET` from the project's env | Build-time public values: `next build` inlines them into the server bundle and the Studio's chunks. The Orun build exports them from the product's secrets (`apps/web/component.yaml` `secretEnv`); locally `.env.local` (`apps/web/.env.example`). Unset — in Checks, on a fresh clone — the `typegen` and `build` scripts substitute `placeholder`, so the credential-free build runs and the Worker simply has no project until a real build | | `SANITY_API_READ_TOKEN` from the project's env | A Worker secret, set once per environment with `wrangler secret put` (README → Deploying); `.dev.vars` for `wrangler dev` (`apps/web/.dev.vars.example`); a `build-placeholder` at build time because `sanity/lib/token.ts` asserts it at import and `next build` evaluates the route modules. Nothing at build sends it: no page pre-renders and `generateStaticParams` is gone | | Time-based ISR (`revalidate: 60` on every published fetch, `generateStaticParams` for the posts) | `dynamic = "force-dynamic"` and `fetchCache = "force-no-store"` on `app/(blog)/layout.tsx`: `/` and `/posts/[slug]` render on every request against Sanity's API CDN (`useCdn: true`), whose 60 s TTL is the interval the ISR matched. `generateStaticParams` and its `postSlugs` query are removed — there is nothing to pre-render, and the call reached Sanity at build | -| Draft mode / live preview (`draftMode()`, `/api/draft-mode/enable`, `VisualEditing`, the `disableDraftMode` action) | Unchanged. Cookies and `fetch` are what they are on Workers; the Presentation tool opens the enable route with its secret and the `__prerender_bypass` cookie flips `sanityFetch` to the drafts perspective with the token. `VisualEditing` is imported from `next-sanity/visual-editing` (where next-sanity 13 exports it) | +| Draft mode / live preview (`draftMode()`, `/api/draft-mode/enable`, `VisualEditing`, the `disableDraftMode` action) | Unchanged. Cookies and `fetch` are what they are on Workers; the Presentation tool opens the enable route with its secret and the `__prerender_bypass` cookie flips `sanityFetch` to the drafts perspective with the token. `VisualEditing` is imported from `next-sanity/visual-editing` (where next-sanity 13 exports it). Unchanged in code; not yet exercised in a browser against a Sanity project (risk CS-H) | | Vercel Visual Editing on preview deployments (`VERCEL_ENV === "preview"` turns stega on outside draft mode) | Never true on Workers; stega is on in draft mode only, which is the Presentation-tool path. Kept as written | | The embedded Studio (`/studio/[[...tool]]`, `force-static`, `` rendered from the page) | Still `force-static`, still `sanity.config.ts` as written. The page renders a client component that loads the Studio with `next/dynamic` and `ssr: false`, and the Studio layout writes out the `metadata`/`viewport` values instead of re-exporting them from `next-sanity/studio`. Both re-exports put the whole `sanity` package into the Worker's server-rendering chunks (31 MB / 7 MB gzip); now the Studio is 10 MB of `_next/static` chunks served as assets and the Worker uploads 7.6 MB / 1.6 MB gzip | | `sanity schema extract && sanity typegen generate` at `prebuild` | Unchanged (offline, against the schema files); `--force` because sanity 6 refuses to overwrite the committed `schema.json` | diff --git a/specs/epics/cms-sanity/epic.yaml b/specs/epics/cms-sanity/epic.yaml index d61ca2b..ccc2ac1 100644 --- a/specs/epics/cms-sanity/epic.yaml +++ b/specs/epics/cms-sanity/epic.yaml @@ -33,3 +33,10 @@ spec: - "a blog built from it carries the blog only, renamed throughout to its own name, repository and Worker through one seam (apps/web/app/site.ts), the upstream template's links left alone, and no shipped file names a factory path" - "Baseline CI is green: contract tests, the blueprint read by the pinned orun, the leak gate, the offline bootstrap and the end-to-end tier — the stage lane's planned steps in a staged job tree with no Sanity credentials, the Worker served by wrangler dev and smoke-tested" tasks: [CS-4] + - name: "CS4 — the cirrus standard" + exitCriteria: + - "no file names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" + - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" + - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a blog" + - "every milestone's status row agrees with the tags" + tasks: [CS-5] diff --git a/specs/epics/cms-sanity/implementation-plan.md b/specs/epics/cms-sanity/implementation-plan.md index dea9a47..d2fba3f 100644 --- a/specs/epics/cms-sanity/implementation-plan.md +++ b/specs/epics/cms-sanity/implementation-plan.md @@ -32,7 +32,7 @@ token; `NEXT_PUBLIC_CF_BEACON_TOKEN`), `IMPLEMENTATION-STATUS.md`, epic - the README quick start works from a fresh clone - the status file lists every PR and departure -## CS3 — a baseline (CS-4) +## CS3 — a baseline (CS-4) ✅ `blueprint.yaml`, `repo-blueprint.yaml`, `.baseline/` (identity, task contracts, the blog's README), `tooling/rebrand`, `tooling/bootstrap`, @@ -54,9 +54,35 @@ Studio's connect page, draft mode's 401) and best-effort Sanity secret refs - the status file records what is proven offline and what only a live bootstrap (and a real Sanity project) can prove +## CS4 — the cirrus standard (CS-5) ✅ + +Bring the baseline to cirrus-baseline's standard, with nothing about the +blog itself changing. + +- **No kiox.** `kiox.yaml`/`kiox.lock` pinned an orun (v2.15.0) that nothing + ran: every workflow installs orun itself through `orun-action` with its own + `version:`. The files, their two modules and the rebrand's skip entry go. +- **Component docs.** `tooling/catalog/gen-component-docs.py` writes each + component's `docs/overview.md`, `docs/architecture.md` and `docs/runbook.md` + from what the component declares, as cirrus-baseline's do; the pages ship + with the component. Baseline CI runs it with `--check`. +- **The context pack.** `ai/context/current.md`, `decisions.md` and + `open-risks.md` beside the two pages a blog ships with — this + repository's own, so no module places them. +- **Status that agrees with the tags.** CS3 is shipped and tagged + `baseline-v1`; the READMEs no longer call the Presentation preview simply + "unchanged" while CS-H is open. + +**Done when** +- `git grep -i kiox` finds nothing, and the leak gate and the offline + bootstrap pass without the two modules +- the docs check is green in Baseline CI +- this file, the status file and `epic.yaml` agree + ## After CS3 (outside this repository) -1. Cut `baseline-v1` with `tag.yml` from the merged `main`. +1. Cut `baseline-v1` with `tag.yml` from the merged `main` — done: `baseline-v1` + is [#4](https://github.com/sourceplane/cms-sanity/pull/4)'s merge. 2. Register the row in orun-cloud's `infra/baselines-registry/baselines.yaml` (unlisted) with the card vendored at the tag. 3. Bootstrap one blog from the tag against a workspace; record its timings; diff --git a/tasks/CS-5.TaskContract.yaml b/tasks/CS-5.TaskContract.yaml new file mode 100644 index 0000000..8d20957 --- /dev/null +++ b/tasks/CS-5.TaskContract.yaml @@ -0,0 +1,30 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: CS-5 + title: "The cirrus standard" +spec: + goal: The baseline meets cirrus-baseline's standard — no kiox pin (orun is pinned where CI runs it), every component documented by generated overview/architecture/runbook pages that CI keeps in step with the manifests, the agent context pack, and status documents that agree with the tags + affects: + - kiox.yaml + - kiox.lock + - repo-blueprint.yaml + - testing/phases.test.sh + - tooling/rebrand/** + - tooling/catalog/** + - .github/workflows/baseline.yml + - apps/web/docs/** + - tests/web/docs/** + - ai/context/** + - docs/phases/** + - README.md + - .baseline/product/README.md + - specs/** + - tasks/** + doneWhen: + - no file names kiox, and the leak gate and the offline bootstrap place a blog without it + - every component has docs/overview.md, docs/architecture.md and docs/runbook.md, and `python3 tooling/catalog/gen-component-docs.py --check` is green in Baseline CI + - ai/context carries current.md, decisions.md and open-risks.md for this repository (none of them ships) + - every milestone's status row agrees with the tags + gates: + - checks diff --git a/testing/phases.test.sh b/testing/phases.test.sh index 4d2a667..ef31195 100755 --- a/testing/phases.test.sh +++ b/testing/phases.test.sh @@ -45,7 +45,7 @@ if not phases: PARTITION = { "01-product": ["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-package-json", "root-pnpm-lock", "root-pnpm-workspace", "root-readme", "root-turbo", "tooling-eslint", "tooling-tsconfig", "tooling-wire", "vscode", "web", "web-tests"], "02-docs": [], diff --git a/tests/web/docs/architecture.md b/tests/web/docs/architecture.md new file mode 100644 index 0000000..793db79 --- /dev/null +++ b/tests/web/docs/architecture.md @@ -0,0 +1,11 @@ +# web-tests — architecture + +A test package at `tests/web`. Its lane runs the suite before it builds. + +## Suites (5) + +- `date.test.ts` +- `draft-mode.test.ts` +- `sanity-utils.test.ts` +- `site.test.ts` +- `unconnected.test.ts` diff --git a/tests/web/docs/overview.md b/tests/web/docs/overview.md new file mode 100644 index 0000000..6e02b2d --- /dev/null +++ b/tests/web/docs/overview.md @@ -0,0 +1,18 @@ +# web-tests + +The test suite for **web**. It deploys nothing: its lane installs, builds and runs the tests. + +| | | +|---|---| +| Type | `turbo-package` | +| Source | `tests/web` | +| Package | `@app/web-tests` | +| Environments | `dev`: `quick-check` | + +## Depends on + +- (none) + +## Depended on by + +- (none) diff --git a/tests/web/docs/runbook.md b/tests/web/docs/runbook.md new file mode 100644 index 0000000..c687de2 --- /dev/null +++ b/tests/web/docs/runbook.md @@ -0,0 +1,26 @@ +# web-tests — runbook + +## How it runs + +Its lane runs on every pull request that changes it; it has no deployed surface. +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-tests build +pnpm --filter @app/web-tests test +pnpm --filter @app/web-tests typecheck +pnpm --filter @app/web-tests lint +``` + +## 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 + +- **A dependent fails to build after a change here**: run `pnpm typecheck` + across the workspace before merging. diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py new file mode 100644 index 0000000..2a6a8b8 --- /dev/null +++ b/tooling/catalog/gen-component-docs.py @@ -0,0 +1,519 @@ +#!/usr/bin/env python3 +"""Generate each component's docs (overview / architecture / runbook). + + python3 tooling/catalog/gen-component-docs.py # write + python3 tooling/catalog/gen-component-docs.py --check # fail on drift (CI) + +The Orun workspace's Docs library renders the `docs/` folder next to every +`component.yaml`. These pages are generated, not hand-written, because almost +everything in them is already declared somewhere CI validates: the component's +manifest (type, description, dependencies, environments, the secrets a lane +resolves, the smoke), its Worker config (bindings, triggers, the wiring the +deploy fills in), its Terraform (resources and outputs), its migrations and its +package scripts. A hand-written copy of those facts drifts the first time one +changes; a generated one cannot, because `--check` fails the pull request that +changes the fact without the page. + +What is NOT derivable (why a component exists, what a failure means for this +product in particular) belongs in the component's `description` and in the +product's own docs, not here. + +The pages ship with the component into every product built from this tree, so +they say nothing about where they came from: no factory paths, no generator +path, no provenance. Zero dependencies beyond PyYAML. +""" + +from __future__ import annotations + +import json +import pathlib +import re +import sys + +try: + import yaml +except ImportError: # pragma: no cover - the contract job installs it + sys.exit("gen-component-docs needs PyYAML (pip install pyyaml)") + +ROOT = pathlib.Path(__file__).resolve().parents[2] +ROOTS = ("apps", "packages", "infra", "tests") +SKIP_DIRS = {"node_modules", "dist", ".turbo", "docs", ".next", ".open-next", + ".wrangler", ".svelte-kit", ".nuxt", ".output", ".astro", "coverage"} + +# Paths a shipped page must never name: products are not placed with them. +FACTORY = re.compile( + r"repo-blueprint|BOOTSTRAP\.md|(? str: + """JSONC → JSON: drop comments outside strings, then trailing commas.""" + out, i, n, in_str = [], 0, len(text), False + while i < n: + c = text[i] + if in_str: + out.append(c) + if c == "\\" and i + 1 < n: + out.append(text[i + 1]) + i += 2 + continue + if c == '"': + in_str = False + i += 1 + continue + if c == '"': + in_str = True + out.append(c) + i += 1 + elif text.startswith("//", i): + j = text.find("\n", i) + i = n if j < 0 else j + elif text.startswith("/*", i): + j = text.find("*/", i + 2) + i = n if j < 0 else j + 2 + else: + out.append(c) + i += 1 + return re.sub(r",(\s*[}\]])", r"\1", "".join(out)) + + +def read_json(path: pathlib.Path) -> dict | None: + try: + return json.loads(strip_jsonc(path.read_text(encoding="utf-8"))) + except (OSError, ValueError): + return None + + +def rel(p: pathlib.Path) -> str: + return p.relative_to(ROOT).as_posix() + + +def discover() -> list[dict]: + found = [] + for root in ROOTS: + base = ROOT / root + if not base.is_dir(): + continue + stack = [base] + while stack: + d = stack.pop() + for entry in sorted(d.iterdir()): + if entry.is_dir(): + if entry.name in SKIP_DIRS or entry.name.startswith("."): + continue + if (entry / "main.tf").exists() and not (entry / "component.yaml").exists(): + continue + if len(entry.relative_to(base).parts) <= 3: + stack.append(entry) + elif entry.name == "component.yaml": + found.append(read_component(entry)) + comps = [c for c in found if c["name"] and c["type"]] + return sorted(comps, key=lambda c: c["name"]) + + +def read_component(file: pathlib.Path) -> dict: + doc = yaml.safe_load(file.read_text(encoding="utf-8")) or {} + meta, spec = doc.get("metadata") or {}, doc.get("spec") or {} + params = spec.get("parameters") or {} + deps = [d.get("component") for d in (spec.get("dependsOn") or []) if isinstance(d, dict)] + envs = [] + for e in ((spec.get("subscribe") or {}).get("environments") or []): + rules = [(r.get("profile"), ((r.get("when") or {}).get("triggerRef"))) + for r in (e.get("profileRules") or [])] + envs.append({"name": e.get("name"), "profile": e.get("profile"), "rules": rules}) + return { + "dir": file.parent, + "path": rel(file.parent), + "name": meta.get("name"), + "description": (meta.get("description") or "").strip(), + "type": spec.get("type"), + "deps": [d for d in deps if d], + "secret_env": sorted((spec.get("secretEnv") or {}).keys()), + "envs": envs, + "params": params, + "migrations_path": spec.get("path") if spec.get("type") == "db-migrate" else None, + } + + +def package_of(c: dict) -> dict | None: + return read_json(c["dir"] / "package.json") + + +def worker_config(c: dict) -> tuple[str | None, dict | None]: + """The config a deploy uses: the template when wiring renders one.""" + names = ["wrangler.template.jsonc", c["params"].get("wranglerConfig") or "", + "wrangler.jsonc", "wrangler.json"] + for name in names: + if name and (c["dir"] / name).is_file(): + return name, read_json(c["dir"] / name) + return None, None + + +WIRING = re.compile(r"@@wiring\(([^/)]+)/__ENV__:([^)]+)\)@@") + + +def wired(value) -> str | None: + m = WIRING.search(str(value)) if value is not None else None + return f"`{m.group(2)}` from `{m.group(1)}`" if m else None + + +def bindings(cfg: dict) -> list[tuple[str, str, str]]: + rows = [] + for kv in cfg.get("kv_namespaces") or []: + rows.append((kv.get("binding"), "Workers KV namespace", wired(kv.get("id")) or "declared in the config")) + for b in cfg.get("r2_buckets") or []: + rows.append((b.get("binding"), "R2 bucket", wired(b.get("bucket_name")) or f"`{b.get('bucket_name')}`")) + for d in cfg.get("d1_databases") or []: + rows.append((d.get("binding"), "D1 database", wired(d.get("database_id")) or "declared in the config")) + for h in cfg.get("hyperdrive") or []: + rows.append((h.get("binding"), "Hyperdrive (pooled Postgres)", wired(h.get("id")) or "declared in the config")) + if isinstance(cfg.get("ai"), dict) and cfg["ai"].get("binding"): + rows.append((cfg["ai"]["binding"], "Workers AI", "account-level; no resource to provision")) + for d in ((cfg.get("durable_objects") or {}).get("bindings") or []): + rows.append((d.get("name"), "Durable Object", f"class `{d.get('class_name')}`")) + for s in cfg.get("services") or []: + rows.append((s.get("binding"), "Service binding", f"Worker `{s.get('service')}`")) + for q in ((cfg.get("queues") or {}).get("producers") or []): + rows.append((q.get("binding"), "Queue producer", f"queue `{q.get('queue')}`")) + for r in cfg.get("ratelimits") or []: + simple = r.get("simple") or {} + rows.append((r.get("name"), "Rate limiter", + f"{simple.get('limit')} requests / {simple.get('period')}s per location")) + assets = cfg.get("assets") or {} + if assets.get("binding"): + rows.append((assets["binding"], "Static assets", f"`{assets.get('directory')}`")) + return [r for r in rows if r[0]] + + +def tf_facts(c: dict) -> dict: + tf_dir = c["dir"] / (c["params"].get("terraformDir") or "terraform") + resources, outputs, variables, backend = [], [], [], None + for f in sorted(tf_dir.glob("*.tf")) if tf_dir.is_dir() else []: + text = f.read_text(encoding="utf-8") + resources += [f"{t}.{n}" for t, n in re.findall(r'^resource\s+"([^"]+)"\s+"([^"]+)"', text, re.M)] + outputs += re.findall(r'^output\s+"([^"]+)"', text, re.M) + variables += re.findall(r'^variable\s+"([^"]+)"', text, re.M) + m = re.search(r'backend\s+"([^"]+)"', text) + backend = backend or (m.group(1) if m else None) + imports = (tf_dir / "adopt.tf").is_file() if tf_dir.is_dir() else False + return {"dir": rel(tf_dir) if tf_dir.is_dir() else None, "resources": resources, + "outputs": outputs, "variables": variables, "backend": backend, "adopt": imports} + + +def published(c: dict) -> list[tuple[str, str]]: + spec = c["params"].get("secretOutputs") or "" + pairs = [] + for part in str(spec).split(","): + if "=" in part: + k, v = part.split("=", 1) + pairs.append((k.strip(), v.strip())) + return pairs + + +def test_files(c: dict) -> list[str]: + out = [] + for p in sorted(c["dir"].rglob("*")): + if any(part in SKIP_DIRS for part in p.relative_to(c["dir"]).parts): + continue + if p.is_file() and re.search(r"\.(test|spec)\.(ts|tsx|js|mjs|cjs)$", p.name): + out.append(p.name) + return out + + +def migrations(c: dict) -> list[str]: + path = c["migrations_path"] + if not path: + return [] + d = ROOT / path + if not d.is_dir(): + return [] + return sorted(p.name for p in d.iterdir() if p.is_dir() or p.suffix == ".sql") + + +# ── phrasing ───────────────────────────────────────────────────────────── + +KIND = { + "cloudflare-worker-turbo": "A Cloudflare Worker, deployed per environment by its CI lane.", + "cloudflare-workers-assets-turbo": "A Cloudflare Worker with Static Assets (server rendering plus " + "static files), deployed per environment by its CI lane.", + "terraform": "Terraform-managed infrastructure, planned and applied per environment by its CI lane.", + "db-migrate": "Applies this repository's ordered database migrations per environment: " + "plan on pull requests, apply on merge to `main`.", + "turbo-package": "A workspace package built by the turbo pipeline. It deploys nothing itself: " + "its lane type-checks, lints, tests and builds it.", +} + +TRIGGER = {"github-push-main": "a push to `main`", "github-pull-request": "a pull request"} + + +def env_line(e: dict) -> str: + s = f"`{e['name']}`: `{e['profile']}`" + for profile, ref in e["rules"]: + s += f", `{profile}` on {TRIGGER.get(ref, f'`{ref}`')}" + return s + + +def is_tests(c: dict) -> bool: + return c["name"].endswith("-tests") or c["path"].startswith("tests/") + + +def subject_of(c: dict, by_name: dict) -> str | None: + if c["name"].endswith("-tests"): + s = c["name"][: -len("-tests")] + return s if s in by_name else None + return None + + +def bullet_list(names: list[str], by_name: dict) -> list[str]: + if not names: + return ["- (none)"] + out = [] + for n in names: + d = by_name.get(n) + out.append(f"- **{n}** — {d['description']}" if d and d["description"] else f"- **{n}**") + return out + + +# ── pages ──────────────────────────────────────────────────────────────── + +def overview(c: dict, by_name: dict, dependents: list[str]) -> str: + pkg = package_of(c) + kind = KIND.get(c["type"], f"A `{c['type']}` component.") + subject = subject_of(c, by_name) + if is_tests(c): + kind = (f"The test suite for **{subject}**. " if subject else "A test suite. ") + \ + "It deploys nothing: its lane installs, builds and runs the tests." + lines = [f"# {c['name']}", ""] + if c["description"]: + lines += [c["description"], ""] + lines += [kind, "", "| | |", "|---|---|", f"| Type | `{c['type']}` |", f"| Source | `{c['path']}` |"] + if pkg and pkg.get("name"): + lines.append(f"| Package | `{pkg['name']}` |") + if c["envs"]: + lines.append(f"| Environments | {' · '.join(env_line(e) for e in c['envs'])} |") + lines += ["", "## Depends on", "", *bullet_list(c["deps"], by_name), + "", "## Depended on by", "", *bullet_list(dependents, by_name), ""] + return "\n".join(lines) + + +def architecture(c: dict, by_name: dict) -> str: + lines = [f"# {c['name']} — architecture", ""] + t = c["type"] + + if t == "terraform": + f = tf_facts(c) + lines += [f"A `terraform` root at `{f['dir'] or c['path']}`.", ""] + if f["backend"] == "http": + lines += ["- **State** lives in the Orun Cloud HTTP state backend — no local state and", + " no state bucket to manage."] + lines += ["- **Credentials are brokered per run** from the workspace's provider", + " connections and resolved by name; none is stored in this repository."] + if f["adopt"]: + lines += ["- **Adoption** (`adopt.tf`): when state is empty but the resource already", + " exists, plan-time import adopts it instead of failing."] + lines.append("") + if f["resources"]: + lines += ["## Resources", "", *[f"- `{r}`" for r in f["resources"]], ""] + pub = published(c) + if pub: + lines += ["## Published outputs", "", + "Written as job-output secrets on each environment after an apply; deploy", + "lanes downstream resolve them by name.", "", + "| Secret | Terraform output |", "|---|---|", + *[f"| `{k}` | `{v}` |" for k, v in pub], ""] + elif f["outputs"]: + lines += ["## Outputs", "", *[f"- `{o}`" for o in f["outputs"]], ""] + if c["secret_env"]: + lines += ["## Resolved at run time (names only)", "", + *[f"- `{k}`" for k in c["secret_env"]], ""] + return "\n".join(lines) + + if t == "db-migrate": + migs = migrations(c) + lines += [f"Applies the migrations under `{c['migrations_path']}` in order, recording each one", + "it applies so a run only ever applies what is new. An already-applied migration", + "is never edited: a change is a new, later migration.", ""] + if migs: + lines += ["## Migrations", "", *[f"- `{m}`" for m in migs], ""] + if c["secret_env"]: + lines += ["## Resolved at run time (names only)", "", + *[f"- `{k}`" for k in c["secret_env"]], ""] + return "\n".join(lines) + + pkg = package_of(c) + if t.startswith("cloudflare-"): + cfg_name, cfg = worker_config(c) + lines += [f"Built by the turbo pipeline from `{c['path']}` and deployed with wrangler.", ""] + if cfg: + lines += ["| | |", "|---|---|", f"| Worker config | `{c['path']}/{cfg_name}` |"] + if cfg.get("main"): + lines.append(f"| Entry | `{cfg['main']}` |") + if cfg.get("compatibility_date"): + lines.append(f"| Compatibility date | `{cfg['compatibility_date']}` |") + if cfg.get("compatibility_flags"): + lines.append(f"| Compatibility flags | {', '.join(f'`{x}`' for x in cfg['compatibility_flags'])} |") + lines.append("") + rows = bindings(cfg) + lines += ["## Bindings", ""] + if rows: + lines += ["| Binding | Kind | Source |", "|---|---|---|", + *[f"| `{b}` | {k} | {s} |" for b, k, s in rows], ""] + if any("from `" in s for _, _, s in rows): + lines += ["Identifiers marked *from* a component are filled in at deploy time from", + "that component's published outputs for the environment being deployed.", ""] + else: + lines += ["None: the Worker binds no storage or service.", ""] + crons = (cfg.get("triggers") or {}).get("crons") or [] + if crons: + lines += ["## Scheduled triggers", "", *[f"- `{x}`" for x in crons], ""] + env_names = sorted((cfg.get("env") or {}).keys()) + var_names = sorted((cfg.get("vars") or {}).keys()) + if var_names: + lines += ["## Variables", "", ", ".join(f"`{v}`" for v in var_names) + + (f" — overridden per environment ({', '.join(f'`{e}`' for e in env_names)})." + if env_names else "."), ""] + wiring = [k for k in c["secret_env"] if k.startswith("WIRING_")] + others = [k for k in c["secret_env"] if not k.startswith("WIRING_")] + if wiring: + lines += ["## Wiring", "", + "Resolved at deploy time from secrets the infrastructure lanes publish (names only):", + "", *[f"- `{k}`" for k in wiring], ""] + if others: + lines += ["## Secrets resolved by the lane (names only)", "", *[f"- `{k}`" for k in others], ""] + return "\n".join(lines) + + # turbo-package + if is_tests(c): + files = test_files(c) + lines += [f"A test package at `{c['path']}`. Its lane runs the suite before it builds.", ""] + if files: + lines += [f"## Suites ({len(files)})", "", *[f"- `{f}`" for f in files], ""] + return "\n".join(lines) + lines += [f"A workspace package at `{c['path']}`, consumed at build time by the components", + "that depend on it. It holds no credentials and opens no connections of its own.", ""] + if pkg and pkg.get("exports"): + ex = pkg["exports"] + keys = sorted(ex.keys()) if isinstance(ex, dict) else ["."] + lines += ["## Exports", "", *[f"- `{k}`" for k in keys], ""] + return "\n".join(lines) + + +def runbook(c: dict, by_name: dict) -> str: + t = c["type"] + pkg = package_of(c) + lines = [f"# {c['name']} — runbook", "", "## How it runs", ""] + deploys = [e["name"] for e in c["envs"] + if any(ref == "github-push-main" for _, ref in e["rules"])] + if deploys and t in ("terraform", "db-migrate"): + lines += [f"Pull requests plan it; a merge to `main` applies it to " + f"{', '.join(f'`{e}`' for e in deploys)}."] + elif deploys: + lines += [f"Pull requests verify it; a merge to `main` deploys it to " + f"{', '.join(f'`{e}`' for e in deploys)}."] + else: + lines += ["Its lane runs on every pull request that changes it; it has no deployed surface."] + lines += ["CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`;", + "the plan orders a component after everything it depends on.", ""] + + if pkg and pkg.get("scripts"): + name = pkg.get("name") + wanted = [s for s in ("dev", "build", "test", "typecheck", "lint", "preview") if s in pkg["scripts"]] + if name and wanted: + lines += ["## Local commands", "", "```bash", + *[f"pnpm --filter {name} {s}" for s in wanted], "```", ""] + + smoke = c["params"].get("smokeCommand") + if smoke and "No smoke" not in str(smoke): + lines += ["## Verify", "", "After a deploy the lane runs this smoke against the environment it", + "deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL:", "", + "```bash", str(smoke).strip(), "```", ""] + + lines += ["## 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", ""] + if t == "terraform": + lines += ["- **Provider authentication fails**: the workspace's provider connection is", + " missing or revoked. Reconnect it in the console; credentials are brokered", + " from it per run.", + "- **\"Already exists\" on a first apply**: state is empty but the resource is", + " not." + (" `adopt.tf` imports it at plan time; if it still fails, the resource" + " was renamed outside Terraform." if tf_facts(c)["adopt"] else + " Import it, or delete the stray resource, then re-run."), ""] + elif t == "db-migrate": + lines += ["- **An applied migration's file changed**: the run stops rather than guess.", + " Restore the file and write the change as a new migration.", + "- **The database is unreachable**: the infrastructure lane it depends on has", + " not applied for this environment; that lane runs first in a convergence.", ""] + elif t.startswith("cloudflare-"): + lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", + " has not applied for this environment yet. Within one convergence the plan", + " runs it first; on its own, re-run that lane.", + "- **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.", ""] + else: + lines += ["- **A dependent fails to build after a change here**: run `pnpm typecheck`", + " across the workspace before merging.", ""] + return "\n".join(lines) + + +# ── main ───────────────────────────────────────────────────────────────── + +def main() -> int: + check = "--check" in sys.argv[1:] + comps = discover() + if not comps: + print("no component.yaml found", file=sys.stderr) + return 1 + by_name = {c["name"]: c for c in comps} + dependents: dict[str, list[str]] = {c["name"]: [] for c in comps} + for c in comps: + for d in c["deps"]: + dependents.setdefault(d, []).append(c["name"]) + + drifted, written, leaks = [], 0, [] + for c in comps: + pages = { + "overview.md": overview(c, by_name, sorted(dependents.get(c["name"], []))), + "architecture.md": architecture(c, by_name), + "runbook.md": runbook(c, by_name), + } + for fname, body in pages.items(): + target = c["dir"] / "docs" / fname + for n, line in enumerate(body.splitlines(), 1): + m = FACTORY.search(line) + if m: + leaks.append(f"{rel(target)}:{n} would name {m.group(0)!r}") + current = target.read_text(encoding="utf-8") if target.exists() else None + if current == body: + continue + if check: + drifted.append(rel(target)) + continue + target.parent.mkdir(parents=True, exist_ok=True) + target.write_text(body, encoding="utf-8") + written += 1 + + if leaks: + print("✗ a generated page would name a path products do not have:", file=sys.stderr) + for l in leaks: + print(f" {l}", file=sys.stderr) + return 1 + if check: + if drifted: + print(f"✗ {len(drifted)} component doc(s) differ from what the manifests say:", file=sys.stderr) + for f in drifted: + print(f" {f}", file=sys.stderr) + print("\nRun: python3 tooling/catalog/gen-component-docs.py", file=sys.stderr) + return 1 + print(f"✓ component docs match {len(comps)} component.yaml file(s)") + return 0 + print(f"✓ wrote {written} page(s) for {len(comps)} component(s)") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tooling/rebrand/rebrand.mjs b/tooling/rebrand/rebrand.mjs index 2b7178a..3bd0835 100755 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -182,7 +182,6 @@ const EXCLUDE_RE = new RegExp( // product claim to be a baseline called by the product's own name. "^\\.baseline/", "^pnpm-lock\\.yaml$", - "^kiox\\.lock$", "\\.(png|jpg|jpeg|ico|gif|webp|woff2?|ttf|eot)$", ].join("|"), ); From 92d517d9b2974f6c035bd169425497941eb19f26 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:26:06 +0000 Subject: [PATCH 2/5] CS4: the kiox exit criterion names what it can mean This milestone's own record (the status file, the plan, epic.yaml, the task contract, ai/context) says that kiox was removed, so "no file names kiox" could never hold literally. The criterion is now that nothing outside this milestone's own record names kiox. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- specs/epics/cms-sanity/epic.yaml | 2 +- specs/epics/cms-sanity/implementation-plan.md | 5 +++-- tasks/CS-5.TaskContract.yaml | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/specs/epics/cms-sanity/epic.yaml b/specs/epics/cms-sanity/epic.yaml index ccc2ac1..6d48cb1 100644 --- a/specs/epics/cms-sanity/epic.yaml +++ b/specs/epics/cms-sanity/epic.yaml @@ -35,7 +35,7 @@ spec: tasks: [CS-4] - name: "CS4 — the cirrus standard" exitCriteria: - - "no file names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" + - "nothing outside this milestone's own record names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a blog" - "every milestone's status row agrees with the tags" diff --git a/specs/epics/cms-sanity/implementation-plan.md b/specs/epics/cms-sanity/implementation-plan.md index d2fba3f..159022d 100644 --- a/specs/epics/cms-sanity/implementation-plan.md +++ b/specs/epics/cms-sanity/implementation-plan.md @@ -74,8 +74,9 @@ blog itself changing. "unchanged" while CS-H is open. **Done when** -- `git grep -i kiox` finds nothing, and the leak gate and the offline - bootstrap pass without the two modules +- nothing outside this milestone's own record names kiox (`git grep -i + kiox`), and the leak gate and the offline bootstrap pass without the two + modules - the docs check is green in Baseline CI - this file, the status file and `epic.yaml` agree diff --git a/tasks/CS-5.TaskContract.yaml b/tasks/CS-5.TaskContract.yaml index 8d20957..5b279dc 100644 --- a/tasks/CS-5.TaskContract.yaml +++ b/tasks/CS-5.TaskContract.yaml @@ -22,7 +22,7 @@ spec: - specs/** - tasks/** doneWhen: - - no file names kiox, and the leak gate and the offline bootstrap place a blog without it + - nothing outside this milestone's own record names kiox, and the leak gate and the offline bootstrap place a blog without it - every component has docs/overview.md, docs/architecture.md and docs/runbook.md, and `python3 tooling/catalog/gen-component-docs.py --check` is green in Baseline CI - ai/context carries current.md, decisions.md and open-risks.md for this repository (none of them ships) - every milestone's status row agrees with the tags From a8de71bc9f68016018d2f439e596a71ca9717573 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:27:55 +0000 Subject: [PATCH 3/5] Regenerate component docs: prettier-padded tables, accurate wording The generator now lays tables out the way prettier does (an app whose lint is `prettier --check` accepts the pages as written), lists the WIRING_* failure only for Workers that take wiring, and no longer claims a package holds no credentials. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- apps/web/docs/architecture.md | 14 +++---- apps/web/docs/overview.md | 10 ++--- apps/web/docs/runbook.md | 3 -- tests/web/docs/overview.md | 10 ++--- tooling/catalog/gen-component-docs.py | 53 +++++++++++++++++---------- 5 files changed, 51 insertions(+), 39 deletions(-) diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md index d402ed6..eb30077 100644 --- a/apps/web/docs/architecture.md +++ b/apps/web/docs/architecture.md @@ -2,15 +2,15 @@ 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` | +| | | +| ------------------- | ----------------------------------------------- | +| 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 | -|---|---|---| +| Binding | Kind | Source | +| -------- | ------------- | ------------------- | | `ASSETS` | Static assets | `.open-next/assets` | diff --git a/apps/web/docs/overview.md b/apps/web/docs/overview.md index d19e0cf..e7325ea 100644 --- a/apps/web/docs/overview.md +++ b/apps/web/docs/overview.md @@ -4,11 +4,11 @@ The Sanity-backed blog and its embedded Studio (Next.js on Cloudflare Workers + 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` | +| | | +| ------------ | ------------------------------------------------------------------------------------------------------------------ | +| 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 diff --git a/apps/web/docs/runbook.md b/apps/web/docs/runbook.md index 4d5118d..3603429 100644 --- a/apps/web/docs/runbook.md +++ b/apps/web/docs/runbook.md @@ -32,9 +32,6 @@ state; nothing was changed out of band, so there is nothing else to undo. ## Common failures -- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream - has not applied for this environment yet. Within one convergence the plan - runs it first; on its own, re-run that lane. - **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. diff --git a/tests/web/docs/overview.md b/tests/web/docs/overview.md index 6e02b2d..3534e6b 100644 --- a/tests/web/docs/overview.md +++ b/tests/web/docs/overview.md @@ -2,11 +2,11 @@ The test suite for **web**. It deploys nothing: its lane installs, builds and runs the tests. -| | | -|---|---| -| Type | `turbo-package` | -| Source | `tests/web` | -| Package | `@app/web-tests` | +| | | +| ------------ | -------------------- | +| Type | `turbo-package` | +| Source | `tests/web` | +| Package | `@app/web-tests` | | Environments | `dev`: `quick-check` | ## Depends on diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py index 2a6a8b8..cda768f 100644 --- a/tooling/catalog/gen-component-docs.py +++ b/tooling/catalog/gen-component-docs.py @@ -232,6 +232,18 @@ def migrations(c: dict) -> list[str]: return sorted(p.name for p in d.iterdir() if p.is_dir() or p.suffix == ".sql") +# ── markdown ───────────────────────────────────────────────────────────── + +def md_table(header: list[str], rows: list[list[str]]) -> list[str]: + """A table laid out the way prettier lays it out, so a repo whose lint is + `prettier --check` accepts the page as written.""" + cols = len(header) + width = [max(3, len(header[i]), *(len(r[i]) for r in rows)) for i in range(cols)] + def line(cells): + return "| " + " | ".join(c.ljust(width[i]) for i, c in enumerate(cells)) + " |" + return [line(header), "| " + " | ".join("-" * w for w in width) + " |", *(line(r) for r in rows)] + + # ── phrasing ───────────────────────────────────────────────────────────── KIND = { @@ -288,11 +300,12 @@ def overview(c: dict, by_name: dict, dependents: list[str]) -> str: lines = [f"# {c['name']}", ""] if c["description"]: lines += [c["description"], ""] - lines += [kind, "", "| | |", "|---|---|", f"| Type | `{c['type']}` |", f"| Source | `{c['path']}` |"] + facts = [["Type", f"`{c['type']}`"], ["Source", f"`{c['path']}`"]] if pkg and pkg.get("name"): - lines.append(f"| Package | `{pkg['name']}` |") + facts.append(["Package", f"`{pkg['name']}`"]) if c["envs"]: - lines.append(f"| Environments | {' · '.join(env_line(e) for e in c['envs'])} |") + facts.append(["Environments", " · ".join(env_line(e) for e in c["envs"])]) + lines += [kind, "", *md_table(["", ""], facts)] lines += ["", "## Depends on", "", *bullet_list(c["deps"], by_name), "", "## Depended on by", "", *bullet_list(dependents, by_name), ""] return "\n".join(lines) @@ -321,8 +334,7 @@ def architecture(c: dict, by_name: dict) -> str: lines += ["## Published outputs", "", "Written as job-output secrets on each environment after an apply; deploy", "lanes downstream resolve them by name.", "", - "| Secret | Terraform output |", "|---|---|", - *[f"| `{k}` | `{v}` |" for k, v in pub], ""] + *md_table(["Secret", "Terraform output"], [[f"`{k}`", f"`{v}`"] for k, v in pub]), ""] elif f["outputs"]: lines += ["## Outputs", "", *[f"- `{o}`" for o in f["outputs"]], ""] if c["secret_env"]: @@ -347,21 +359,20 @@ def architecture(c: dict, by_name: dict) -> str: cfg_name, cfg = worker_config(c) lines += [f"Built by the turbo pipeline from `{c['path']}` and deployed with wrangler.", ""] if cfg: - lines += ["| | |", "|---|---|", f"| Worker config | `{c['path']}/{cfg_name}` |"] + facts = [["Worker config", f"`{c['path']}/{cfg_name}`"]] if cfg.get("main"): - lines.append(f"| Entry | `{cfg['main']}` |") + facts.append(["Entry", f"`{cfg['main']}`"]) if cfg.get("compatibility_date"): - lines.append(f"| Compatibility date | `{cfg['compatibility_date']}` |") + facts.append(["Compatibility date", f"`{cfg['compatibility_date']}`"]) if cfg.get("compatibility_flags"): - lines.append(f"| Compatibility flags | {', '.join(f'`{x}`' for x in cfg['compatibility_flags'])} |") - lines.append("") + facts.append(["Compatibility flags", ", ".join(f"`{x}`" for x in cfg["compatibility_flags"])]) + lines += [*md_table(["", ""], facts), ""] rows = bindings(cfg) lines += ["## Bindings", ""] if rows: - lines += ["| Binding | Kind | Source |", "|---|---|---|", - *[f"| `{b}` | {k} | {s} |" for b, k, s in rows], ""] + lines += [*md_table(["Binding", "Kind", "Source"], [[f"`{b}`", k, s] for b, k, s in rows]), ""] if any("from `" in s for _, _, s in rows): - lines += ["Identifiers marked *from* a component are filled in at deploy time from", + lines += ["Identifiers marked _from_ a component are filled in at deploy time from", "that component's published outputs for the environment being deployed.", ""] else: lines += ["None: the Worker binds no storage or service.", ""] @@ -391,8 +402,8 @@ def architecture(c: dict, by_name: dict) -> str: if files: lines += [f"## Suites ({len(files)})", "", *[f"- `{f}`" for f in files], ""] return "\n".join(lines) - lines += [f"A workspace package at `{c['path']}`, consumed at build time by the components", - "that depend on it. It holds no credentials and opens no connections of its own.", ""] + lines += [f"A workspace package at `{c['path']}`, consumed by the components that depend", + "on it. It has no deployed surface of its own.", ""] if pkg and pkg.get("exports"): ex = pkg["exports"] keys = sorted(ex.keys()) if isinstance(ex, dict) else ["."] @@ -448,10 +459,14 @@ def runbook(c: dict, by_name: dict) -> str: "- **The database is unreachable**: the infrastructure lane it depends on has", " not applied for this environment; that lane runs first in a convergence.", ""] elif t.startswith("cloudflare-"): - lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", - " has not applied for this environment yet. Within one convergence the plan", - " runs it first; on its own, re-run that lane.", - "- **The smoke fails right after a first deploy**: a new workers.dev route can", + _, cfg = worker_config(c) + takes_wiring = any(k.startswith("WIRING_") for k in c["secret_env"]) or \ + bool(cfg and WIRING.search(json.dumps(cfg))) + if takes_wiring: + lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", + " has not applied for this environment yet. Within one convergence the plan", + " runs it first; on its own, re-run that lane."] + lines += ["- **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.", ""] else: From 02a7d6df302e24509f5db8b92533fb07ae556ae1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:35:06 +0000 Subject: [PATCH 4/5] Component docs: list optional and per-environment secrets The generator now reads `optionalSecretEnv` (listed as "(optional)") and secrets declared per environment under `subscribe.environments[]`, so a page no longer leaves out a secret its component declares. Its tables are laid out as prettier lays them out, the WIRING_* failure is listed only for Workers that take wiring, and a package is no longer said to hold no credentials. Every starter now carries the identical generator. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- apps/web/docs/architecture.md | 5 ++++ tooling/catalog/gen-component-docs.py | 37 ++++++++++++++++++--------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md index eb30077..8d154f8 100644 --- a/apps/web/docs/architecture.md +++ b/apps/web/docs/architecture.md @@ -14,3 +14,8 @@ Built by the turbo pipeline from `apps/web` and deployed with wrangler. | 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) diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py index cda768f..9a39931 100644 --- a/tooling/catalog/gen-component-docs.py +++ b/tooling/catalog/gen-component-docs.py @@ -119,7 +119,13 @@ def read_component(file: pathlib.Path) -> dict: params = spec.get("parameters") or {} deps = [d.get("component") for d in (spec.get("dependsOn") or []) if isinstance(d, dict)] envs = [] + # Secrets may be declared for the whole component or per environment + # (`subscribe.environments[].secretEnv`); a page lists both. + req_env = set((spec.get("secretEnv") or {}).keys()) + opt_env = set((spec.get("optionalSecretEnv") or {}).keys()) for e in ((spec.get("subscribe") or {}).get("environments") or []): + req_env |= set((e.get("secretEnv") or {}).keys()) + opt_env |= set((e.get("optionalSecretEnv") or {}).keys()) rules = [(r.get("profile"), ((r.get("when") or {}).get("triggerRef"))) for r in (e.get("profileRules") or [])] envs.append({"name": e.get("name"), "profile": e.get("profile"), "rules": rules}) @@ -130,7 +136,8 @@ def read_component(file: pathlib.Path) -> dict: "description": (meta.get("description") or "").strip(), "type": spec.get("type"), "deps": [d for d in deps if d], - "secret_env": sorted((spec.get("secretEnv") or {}).keys()), + "secret_env": sorted(req_env), + "optional_env": sorted(opt_env - req_env), "envs": envs, "params": params, "migrations_path": spec.get("path") if spec.get("type") == "db-migrate" else None, @@ -278,6 +285,14 @@ def subject_of(c: dict, by_name: dict) -> str | None: return None +def names_list(c: dict, keep) -> list[str]: + """Secret names a lane resolves, required first; an optional one (from + `optionalSecretEnv`) is resolved when it exists and skipped when not.""" + req = [f"- `{k}`" for k in c["secret_env"] if keep(k)] + opt = [f"- `{k}` (optional)" for k in c["optional_env"] if keep(k)] + return req + opt + + def bullet_list(names: list[str], by_name: dict) -> list[str]: if not names: return ["- (none)"] @@ -337,9 +352,8 @@ def architecture(c: dict, by_name: dict) -> str: *md_table(["Secret", "Terraform output"], [[f"`{k}`", f"`{v}`"] for k, v in pub]), ""] elif f["outputs"]: lines += ["## Outputs", "", *[f"- `{o}`" for o in f["outputs"]], ""] - if c["secret_env"]: - lines += ["## Resolved at run time (names only)", "", - *[f"- `{k}`" for k in c["secret_env"]], ""] + if c["secret_env"] or c["optional_env"]: + lines += ["## Resolved at run time (names only)", "", *names_list(c, lambda k: True), ""] return "\n".join(lines) if t == "db-migrate": @@ -349,9 +363,8 @@ def architecture(c: dict, by_name: dict) -> str: "is never edited: a change is a new, later migration.", ""] if migs: lines += ["## Migrations", "", *[f"- `{m}`" for m in migs], ""] - if c["secret_env"]: - lines += ["## Resolved at run time (names only)", "", - *[f"- `{k}`" for k in c["secret_env"]], ""] + if c["secret_env"] or c["optional_env"]: + lines += ["## Resolved at run time (names only)", "", *names_list(c, lambda k: True), ""] return "\n".join(lines) pkg = package_of(c) @@ -385,14 +398,14 @@ def architecture(c: dict, by_name: dict) -> str: lines += ["## Variables", "", ", ".join(f"`{v}`" for v in var_names) + (f" — overridden per environment ({', '.join(f'`{e}`' for e in env_names)})." if env_names else "."), ""] - wiring = [k for k in c["secret_env"] if k.startswith("WIRING_")] - others = [k for k in c["secret_env"] if not k.startswith("WIRING_")] + wiring = names_list(c, lambda k: k.startswith("WIRING_")) + others = names_list(c, lambda k: not k.startswith("WIRING_")) if wiring: lines += ["## Wiring", "", "Resolved at deploy time from secrets the infrastructure lanes publish (names only):", - "", *[f"- `{k}`" for k in wiring], ""] + "", *wiring, ""] if others: - lines += ["## Secrets resolved by the lane (names only)", "", *[f"- `{k}`" for k in others], ""] + lines += ["## Secrets resolved by the lane (names only)", "", *others, ""] return "\n".join(lines) # turbo-package @@ -460,7 +473,7 @@ def runbook(c: dict, by_name: dict) -> str: " not applied for this environment; that lane runs first in a convergence.", ""] elif t.startswith("cloudflare-"): _, cfg = worker_config(c) - takes_wiring = any(k.startswith("WIRING_") for k in c["secret_env"]) or \ + takes_wiring = any(k.startswith("WIRING_") for k in c["secret_env"] + c["optional_env"]) or \ bool(cfg and WIRING.search(json.dumps(cfg))) if takes_wiring: lines += ["- **A `WIRING_*` secret is missing at deploy**: an infrastructure lane upstream", From 3686c28e68cae4b5aa8763074327253d38a253eb Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 12:04:56 +0000 Subject: [PATCH 5/5] CS4: read the workers.dev subdomain from the Cloudflare connection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - blueprint.yaml: the subdomain input declares `from: connection.cloudflare.workersSubdomain`, with the reason at the input, as cirrus-baseline's card does since baseline-v23; key, label, pattern, help and example unchanged - testing/manifest.test.sh: cirrus-baseline's rule, byte for byte: the source is accepted and its provider must be in spec.requires.integrations (mutation-checked) - repo-blueprint.yaml, BOOTSTRAP.md, docs/phases/README.md: a console or --from bst_… build reads it from the connection; only a hand-run build passes --set subdomain - records: CS-6 under CS4; CS4 tagged baseline-v2 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- BOOTSTRAP.md | 6 +++ ai/context/current.md | 7 ++-- ai/context/decisions.md | 1 + blueprint.yaml | 12 ++++++ docs/phases/README.md | 6 ++- repo-blueprint.yaml | 7 +++- specs/epics/README.md | 2 +- .../epics/cms-sanity/IMPLEMENTATION-STATUS.md | 41 ++++++++++++++++++- specs/epics/cms-sanity/README.md | 6 +-- specs/epics/cms-sanity/epic.yaml | 3 +- specs/epics/cms-sanity/implementation-plan.md | 6 +++ tasks/CS-6.TaskContract.yaml | 24 +++++++++++ testing/manifest.test.sh | 15 ++++++- 13 files changed, 121 insertions(+), 15 deletions(-) create mode 100644 tasks/CS-6.TaskContract.yaml diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index c1538fb..9077a66 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -62,6 +62,12 @@ orun new --blueprint repo-blueprint.yaml \ --set subdomain= ``` +`subdomain` is the workers.dev subdomain of the Cloudflare account you deploy +into (Workers & Pages → your subdomain). A build started from the console, or +with `orun baseline new --from bst_…`, never asks for it: the platform reads +it from the workspace's Cloudflare connection, the same one the deploy token +is minted from. Only a hand-run build like this one passes it. + **`--run-hooks` is the difference between placing files and bootstrapping a blog.** Without it `orun new` writes the tree and stops: no repository, no landing, no convergence watch, no probe. That is deliberate — it is what diff --git a/ai/context/current.md b/ai/context/current.md index 4d699e2..918d536 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -21,8 +21,8 @@ component; Sanity stays the owner's SaaS. | | | |---|---| -| Latest tag | `baseline-v1` (CS3) | -| On `main` since | CS4 — the cirrus standard (no kiox, generated component docs, this context pack) | +| Latest tag | `baseline-v2` (CS4 — the cirrus standard: no kiox, generated component docs, this context pack, and the workers.dev subdomain read from the Cloudflare connection instead of asked) | +| Before it | `baseline-v1` (CS3 — the baseline, one landing) | | 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 @@ -37,8 +37,7 @@ component; Sanity stays the owner's SaaS. ## Next -1. Bootstrap one blog from the next tag against a workspace, and record its +1. Bootstrap one blog from `baseline-v2` 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. diff --git a/ai/context/decisions.md b/ai/context/decisions.md index ce7a8c3..ef11983 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -18,3 +18,4 @@ reads in order. | 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` | +| 13 | The workers.dev subdomain is read from the Cloudflare connection (`from: connection.cloudflare.workersSubdomain`), not asked; only a hand-run build passes `--set subdomain` | It belongs to the account like its id and has one right answer; a typed one could only be wrong, and wrong showed up after deploy in the smoke and the probes (cirrus-baseline since baseline-v23) | IMPLEMENTATION-STATUS (CS-6) | diff --git a/blueprint.yaml b/blueprint.yaml index d828162..630cbca 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -94,6 +94,18 @@ spec: pattern: "^[a-z0-9][a-z0-9-]{0,62}$" help: The workers.dev subdomain of the Cloudflare account the blog deploys into. example: acme + # READ FROM THE CLOUDFLARE CONNECTION, not asked. The subdomain belongs + # to the account the same way its id does, and there is exactly one + # right answer — a typed one could only be wrong, and wrong showed up + # after deploy, in the deploy's smoke, 01-product's probes and the + # verify URL below. The integration reads it from Cloudflare at connect + # and on its hourly health check; the bootstrap door fills this input + # from the connection the build is BOUND to, the same one + # CLOUDFLARE_ACCOUNT_ID and the deploy token mint from, so all three + # name one account. The console renders no field for it, and an account + # with no workers.dev subdomain refuses the build at the door, naming + # the fix, before anything is created. + from: connection.cloudflare.workersSubdomain # ── PREVIEW ONLY. repo-blueprint.yaml's `orun.integrations/reconcile@v1` # hooks mint these, brokered, during 01-product. ────────────────────────── diff --git a/docs/phases/README.md b/docs/phases/README.md index 92091bd..50fdf8b 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -71,8 +71,10 @@ the blueprint's **required** inputs — `reponame`, `productname`, must be supplied on every invocation, single-phase ones included. A `--values` file is easier than repeating `--set`. -- `subdomain` — the workers.dev subdomain of the Cloudflare account. It is - in every URL the phases probe and in the URL the deploy's smoke reads. +- `subdomain` — the workers.dev subdomain of the Cloudflare account you + deploy into. It is in every URL the phases probe and in the URL the + deploy's smoke reads. A console or `--from bst_…` build reads it from the + Cloudflare connection; pass it only for a hand-run build. - `orunWorkspace` — workspace id (`ws_…`). Unset, it is the workspace the build runs in (`from: workspace`); with none anywhere, a placeholder that fails loudly rather than silently claiming another tenant's workspace. diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 3c463d2..86da4bc 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -51,7 +51,12 @@ inputs: subdomain: type: string default: "your-workers-subdomain" - description: The workers.dev subdomain of the Cloudflare account the blog deploys into — its URLs, the deploy's smoke, the probes. + description: >- + The workers.dev subdomain of the Cloudflare account the blog deploys + into — its URLs, the deploy's smoke, the probes. A console or + `--from bst_…` build gets it from the workspace's Cloudflare connection + (blueprint.yaml declares `from: connection.cloudflare.workersSubdomain`); + pass it with --set only for a hand-run build. repoPrivate: type: boolean default: true diff --git a/specs/epics/README.md b/specs/epics/README.md index b2eb6b0..b43cdc1 100644 --- a/specs/epics/README.md +++ b/specs/epics/README.md @@ -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** | ✅ 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) | +| [`cms-sanity/`](./cms-sanity/) | **CS** | ✅ Shipped (`baseline-v2`); 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`. diff --git a/specs/epics/cms-sanity/IMPLEMENTATION-STATUS.md b/specs/epics/cms-sanity/IMPLEMENTATION-STATUS.md index d22fc64..566e367 100644 --- a/specs/epics/cms-sanity/IMPLEMENTATION-STATUS.md +++ b/specs/epics/cms-sanity/IMPLEMENTATION-STATUS.md @@ -9,7 +9,7 @@ the code departed from `design.md` or from the upstream template. | CS1 — the blog on Workers | ✅ Shipped | [#2](https://github.com/sourceplane/cms-sanity/pull/2) | | CS2 — ready to instantiate | ✅ Shipped | [#3](https://github.com/sourceplane/cms-sanity/pull/3) | | CS3 — a baseline | ✅ Shipped | [#4](https://github.com/sourceplane/cms-sanity/pull/4) (CS-4), tagged `baseline-v1` | -| CS4 — the cirrus standard | ✅ Shipped | CS-5 — on `main` after `baseline-v1`, not yet tagged | +| CS4 — the cirrus standard | ✅ Shipped | [#5](https://github.com/sourceplane/cms-sanity/pull/5) (CS-5), [#6](https://github.com/sourceplane/cms-sanity/pull/6) (CS-6), tagged `baseline-v2` | ## Departures from the upstream template @@ -158,6 +158,45 @@ Nothing about the blog changed. What changed is the baseline around it: | the Presentation preview in the READMEs and `design.md` | "Unchanged" (the root README's opening line and mapping table) | unchanged in code, not yet exercised in a browser (risk CS-H); the blog's README asks its owner to open the Presentation tool once after adding the token | CS-H is open: the draft-mode route is tested with a mocked client only | | status | CS3 "in review … to be tagged `baseline-v1`" | CS3 shipped and tagged `baseline-v1` | the tag existed; the documents had not caught up | +### The subdomain from the Cloudflare connection (CS-6) + +The card's `subdomain` input was typed by hand, though it belongs to the +Cloudflare account the same way its id does and has exactly one right +answer; a wrong value surfaced only after deploy, in the deploy's smoke and +`01-product`'s probes. It now declares `from: +connection.cloudflare.workersSubdomain`, as cirrus-baseline's card does since +baseline-v23: the Cloudflare integration reads the subdomain at connect and on +its hourly health check, the bootstrap door fills the input from the +connection the build is bound to (the one `CLOUDFLARE_ACCOUNT_ID` and the +deploy token come from), the console renders no field for it, and an account +with no workers.dev subdomain is refused at the door. Nothing a blog runs +changes. + +- `blueprint.yaml`: the `from:` source and the reason, at the input; key, + label, pattern, help and example unchanged. +- `testing/manifest.test.sh`: cirrus-baseline's rule, byte for byte — the + source is accepted, and a `connection..…` source whose provider + `spec.requires.integrations` does not list fails (the card lists + `cloudflare`). +- `repo-blueprint.yaml`, `BOOTSTRAP.md`, `docs/phases/README.md`: a console or + `--from bst_…` build reads it from the connection; only a hand-run build + passes `--set subdomain`. The default is unchanged. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green; `gen-component-docs.py --check` green (2 components). +- Mutation: `cloudflare` removed from `spec.requires.integrations` → + `manifest.test.sh` fails with exactly one finding, `inputs[subdomain].from + is 'connection.cloudflare.workersSubdomain' but spec.requires.integrations + does not list cloudflare`; restored, green. +- `orun new --status` (v2.58.11) reads the blueprint: `01-product` pending + (97 files). `testing/leak.test.sh` (v2.58.11): 97 files derived, every one + read, no factory path named. +- `testing/placement.test.sh` (v2.78.4): 97 files placed, both landings, + `--resume` changes nothing. +- `orun task check CS-6` complete. + ## Verified (CS4) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` diff --git a/specs/epics/cms-sanity/README.md b/specs/epics/cms-sanity/README.md index 5d3359e..4e61399 100644 --- a/specs/epics/cms-sanity/README.md +++ b/specs/epics/cms-sanity/README.md @@ -8,7 +8,7 @@ The upstream code stays the code: the GROQ queries, the schemas, the Portable Te | Field | Value | |-------|-------| -| Status | ✅ CS0–CS3 shipped (#1–#4), CS3 tagged `baseline-v1`; CS4 (the cirrus standard, CS-5) on `main`, not yet tagged. Not yet proven by a live bootstrap (risk CS-M) | +| Status | ✅ CS0–CS4 shipped (#1–#6), CS3 tagged `baseline-v1`; CS4 (the cirrus standard, CS-5, and the subdomain read from the Cloudflare connection, CS-6) tagged `baseline-v2`. Not yet proven by a live bootstrap (risk CS-M) | | Cluster | **CS** (CS0–CS4) | | Owner(s) | `apps/web` (the blog and the Studio) · `tests/web` (image URLs, the date component, the draft-mode route, the unconnected blog) · the baseline (`blueprint.yaml`, `repo-blueprint.yaml`, `.baseline/`, `testing/`) | | Builds on | `cirrus-baseline` conventions; the `portfolio-starter-kit` port's build shape (static-assets incremental cache + `populateCache`) and its analytics beacon; the `turso-starter` port's `force-dynamic` answer to a read-only cache | @@ -16,7 +16,7 @@ The upstream code stays the code: the GROQ queries, the schemas, the Portable Te | Changes | Adds the Workers build, the monorepo wrapper, tests and the deploy contract; makes the blog routes dynamic; mounts the Studio client-side; swaps Speed Insights for one Cloudflare beacon; moves next-sanity/sanity to their Next 16 lines and Tailwind to 4 | | Decisions locked | (1) OpenNext on Workers + Static Assets, the static-assets incremental cache. (2) Blog routes `force-dynamic` + `fetchCache = "force-no-store"`; Sanity's API CDN is the cache; no R2/DO cache. (3) The Studio loads through `next/dynamic` with `ssr: false`; the Studio layout's metadata is written out, not re-exported. (4) Project id and dataset are build-time values the Orun build reads from the product's secrets — best-effort since CS3 (`optionalSecretEnv`): with none, the blog renders bundled sample posts under a "connect your Sanity project" notice; the read token is an optional Worker secret. (5) Tailwind 4, CSS-first. (6) CS3: two phases, one landing (cirrus-baseline v22). | | Gate | CS1 is the first user-visible rung. | -| Shipped as | `baseline-v1` ([#4](https://github.com/sourceplane/cms-sanity/pull/4)), then CS4 on `main`; proven offline (Baseline CI, with no Sanity project), deploy gated until a workspace is linked | +| Shipped as | `baseline-v1` ([#4](https://github.com/sourceplane/cms-sanity/pull/4)), then `baseline-v2` (CS4: [#5](https://github.com/sourceplane/cms-sanity/pull/5), [#6](https://github.com/sourceplane/cms-sanity/pull/6)); proven offline (Baseline CI, with no Sanity project), deploy gated until a workspace is linked | ## Read order @@ -33,4 +33,4 @@ The upstream code stays the code: the GROQ queries, the schemas, the Portable Te | CS1 — the blog on Workers | `apps/web` built by OpenNext, `tests/web`, green checks | `wrangler dev` serves the Studio shell, its chunks, a 401 and a 404; the Worker bundle holds no Studio code; Checks green | | CS2 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it against their own Sanity project | | CS3 — a baseline | card, build document, rename, bootstrap tooling, tests; the unconnected blog | a new blog goes from nothing to live in one landing with no Sanity project; Baseline CI green | -| CS4 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags | Baseline CI green with the docs check | +| CS4 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags; the subdomain read from the Cloudflare connection | Baseline CI green with the docs check; the card asks for no subdomain | diff --git a/specs/epics/cms-sanity/epic.yaml b/specs/epics/cms-sanity/epic.yaml index 6d48cb1..60ff95c 100644 --- a/specs/epics/cms-sanity/epic.yaml +++ b/specs/epics/cms-sanity/epic.yaml @@ -39,4 +39,5 @@ spec: - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a blog" - "every milestone's status row agrees with the tags" - tasks: [CS-5] + - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" + tasks: [CS-5, CS-6] diff --git a/specs/epics/cms-sanity/implementation-plan.md b/specs/epics/cms-sanity/implementation-plan.md index 159022d..70e2f4a 100644 --- a/specs/epics/cms-sanity/implementation-plan.md +++ b/specs/epics/cms-sanity/implementation-plan.md @@ -72,6 +72,12 @@ blog itself changing. - **Status that agrees with the tags.** CS3 is shipped and tagged `baseline-v1`; the READMEs no longer call the Presentation preview simply "unchanged" while CS-H is open. +- **The subdomain from the Cloudflare connection (CS-6).** The card's + `subdomain` input declares `from: connection.cloudflare.workersSubdomain`, + as cirrus-baseline's does since baseline-v23: the bootstrap door fills it + from the connection the build is bound to, so the console asks for nothing + a typo could get wrong. `testing/manifest.test.sh` takes cirrus-baseline's + rule, which requires the provider in `spec.requires.integrations`. **Done when** - nothing outside this milestone's own record names kiox (`git grep -i diff --git a/tasks/CS-6.TaskContract.yaml b/tasks/CS-6.TaskContract.yaml new file mode 100644 index 0000000..f5f6866 --- /dev/null +++ b/tasks/CS-6.TaskContract.yaml @@ -0,0 +1,24 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: CS-6 + title: "The subdomain from the Cloudflare connection" +spec: + goal: "The console card stops asking for the workers.dev subdomain and reads it from the Cloudflare connection the build is bound to (`from: connection.cloudflare.workersSubdomain`), as cirrus-baseline does since baseline-v23 — the same account CLOUDFLARE_ACCOUNT_ID and the deploy token come from, so a wrong typed value can no longer surface after deploy in the smoke and the probes" + affects: + - blueprint.yaml + - repo-blueprint.yaml + - testing/manifest.test.sh + - BOOTSTRAP.md + - docs/phases/README.md + - ai/context/current.md + - ai/context/decisions.md + - specs/** + - tasks/** + doneWhen: + - "blueprint.yaml's `subdomain` input declares `from: connection.cloudflare.workersSubdomain`, and its comment says why" + - testing/manifest.test.sh accepts that source and fails a card whose `spec.requires.integrations` does not list the provider (mutation-checked) + - repo-blueprint.yaml, BOOTSTRAP.md and docs/phases/README.md say a console or `--from bst_…` build reads it from the connection and only a hand-run build passes `--set subdomain` + - every milestone's status row agrees with the tags + gates: + - checks diff --git a/testing/manifest.test.sh b/testing/manifest.test.sh index 3fd6af8..5374cb5 100755 --- a/testing/manifest.test.sh +++ b/testing/manifest.test.sh @@ -217,9 +217,20 @@ for path in manifests: # field for it (saas-bootstrap-console BC-K5). Two ways to get it # wrong, and the platform refuses both — check them here too, so the # mistake is caught in this repo rather than at a live bootstrap. + # + # A `connection..` source is read from the connection + # the build is bound to, so the provider must be one the manifest + # requires — the platform's parser refuses it otherwise. + sources_known = ("repo.name", "repo.owner", "repo.fullName", + "connection.cloudflare.workersSubdomain") src = field.get("from") - if src is not None and src not in ("repo.name", "repo.owner", "repo.fullName"): - B(f"inputs[{key}].from is {src!r} — must be repo.name, repo.owner or repo.fullName") + if src is not None and src not in sources_known: + B(f"inputs[{key}].from is {src!r} — must be one of {', '.join(sources_known)}") + if isinstance(src, str) and src.startswith("connection."): + provider = src.split(".")[1] + if provider not in ((spec.get("requires") or {}).get("integrations") or []): + B(f"inputs[{key}].from is {src!r} but spec.requires.integrations " + f"does not list {provider} — there is no connection to read it from") # ── secrets: BOTH or NEITHER, checked both ways ─────────────────────── declared = {s.get("key"): (s.get("provider"), s.get("template")) for s in (spec.get("secrets") or [])}