From bba85bafdd607e492e5dbbf339ee92d3210bd76f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 13:46:18 +0000 Subject: [PATCH 1/5] =?UTF-8?q?HA4:=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. - Generate docs/{overview,architecture,runbook}.md for every component 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). - Close out HA3 (shipped, tagged baseline-v1) and record HA4 (HA-5). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- .github/workflows/baseline.yml | 6 + ai/context/current.md | 37 ++ ai/context/decisions.md | 18 + ai/context/open-risks.md | 16 + apps/api/docs/architecture.md | 18 + apps/api/docs/overview.md | 20 + apps/api/docs/runbook.md | 39 ++ docs/phases/01-product.md | 2 +- kiox.lock | 11 - kiox.yaml | 6 - repo-blueprint.yaml | 12 +- specs/epics/README.md | 2 +- specs/epics/hono-api/IMPLEMENTATION-STATUS.md | 32 +- specs/epics/hono-api/README.md | 7 +- specs/epics/hono-api/design.md | 2 +- specs/epics/hono-api/epic.yaml | 7 + specs/epics/hono-api/implementation-plan.md | 25 +- tasks/HA-5.TaskContract.yaml | 28 + testing/phases.test.sh | 2 +- tests/api/docs/architecture.md | 7 + tests/api/docs/overview.md | 18 + tests/api/docs/runbook.md | 26 + tooling/catalog/gen-component-docs.py | 519 ++++++++++++++++++ tooling/rebrand/rebrand.mjs | 1 - 24 files changed, 823 insertions(+), 38 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/api/docs/architecture.md create mode 100644 apps/api/docs/overview.md create mode 100644 apps/api/docs/runbook.md delete mode 100644 kiox.lock delete mode 100644 kiox.yaml create mode 100644 tasks/HA-5.TaskContract.yaml create mode 100644 tests/api/docs/architecture.md create mode 100644 tests/api/docs/overview.md create mode 100644 tests/api/docs/runbook.md create mode 100644 tooling/catalog/gen-component-docs.py diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index c877295..109707d 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -49,6 +49,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/ai/context/current.md b/ai/context/current.md new file mode 100644 index 0000000..82e7da8 --- /dev/null +++ b/ai/context/current.md @@ -0,0 +1,37 @@ +# hono-api — 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 an API built from it; the two +pages that do are [operations.md](operations.md) and +[deployment.md](deployment.md). + +## What it is + +Vercel's Hono boilerplate as one Cloudflare Worker, packaged as an Orun +baseline: `orun new --blueprint repo-blueprint.yaml` builds a new API 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`). + +## Release + +| | | +|---|---| +| Latest tag | `baseline-v1` (HA3) | +| On `main` since | HA4 — 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; a live bootstrap from a tag is still to come (risk HA-F) | + +## Where to read + +| Question | Page | +|---|---| +| What shipped, and every departure from upstream | `specs/epics/hono-api/IMPLEMENTATION-STATUS.md` | +| Why it is built this way | [decisions.md](decisions.md), then `specs/epics/hono-api/design.md` | +| What could still go wrong | [open-risks.md](open-risks.md), then `specs/epics/hono-api/risks-and-open-questions.md` | +| How to instantiate it | `BOOTSTRAP.md`, `docs/phases/` | +| What each component is | `apps/api/docs/`, `tests/api/docs/` (generated; `python3 tooling/catalog/gen-component-docs.py`) | + +## Next + +1. Bootstrap one API from the next tag against a workspace, and record its + timings (closes HA-F). +2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin HA4. diff --git a/ai/context/decisions.md b/ai/context/decisions.md new file mode 100644 index 0000000..ca32294 --- /dev/null +++ b/ai/context/decisions.md @@ -0,0 +1,18 @@ +# hono-api — 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 | A plain Worker (`cloudflare-worker-turbo`), no adapter and no Pages Functions | Hono's default export already is a Workers module handler | `specs/epics/hono-api/design.md` | +| 2 | `wrangler.jsonc` is committed, not rendered | The Worker binds nothing, so there is nothing to wire; the lane's structure check finds it before any build | design.md, `apps/api/component.yaml` | +| 3 | Per-environment deploys through wrangler `env` sections | `hono-api-api-{stage,prod}`, the same shape cirrus-baseline's workers deploy with | design.md | +| 4 | No infra root | Nothing to provision; `infra/` and `packages/` stay as empty discovery roots | `repo-blueprint.yaml` (`discovery-roots`) | +| 5 | `GET /health` and one name seam (`apps/api/src/identity.ts`) | The deploy smoke and the bootstrap's probes read it; the rename rewrites one literal | IMPLEMENTATION-STATUS (HA3) | +| 6 | One landing (`01-product`) then the record (`02-docs`) | A landing has a fixed cost; the plan, not the phases, carries deploy order (cirrus-baseline since baseline-v22) | `repo-blueprint.yaml` | +| 7 | `ci.yml` plans nothing while `intent.yaml` names `ws_CHANGE_ME` | A bootstrap cannot set a repository variable (replaced the `ORUN_CI` gate) | IMPLEMENTATION-STATUS (HA3) | +| 8 | stack-tectonic 0.19.0, not 0.20.0 | The family's one pin: 0.20.0's linked install breaks the Next.js baselines | risk HA-J | +| 9 | 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 (HA4) | +| 10 | 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..92316c8 --- /dev/null +++ b/ai/context/open-risks.md @@ -0,0 +1,16 @@ +# hono-api — 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/hono-api/risks-and-open-questions.md`; this page lists only what +is still live, so it should be short. + +| ID | Risk | State | What closes it | +|---|---|---|---| +| HA-F | No live bootstrap yet: the repository created and linked, the deploy token minted, a real `wrangler deploy`, the smoke and the probes against workers.dev are all unproven | OPEN | One bootstrap from a tag against a workspace | +| HA-G | `orun plan --changed` plans nothing for a push with no `before`; the first landing relies on merging into orun's seeded initial commit | WATCH | Confirmed by the first live bootstrap | + +Accepted, and worth knowing before you change them: HA-C (wrangler's +multi-environment warning on the local build), HA-H (a custom domain is the +owner's step), HA-J (stack-tectonic 0.19.0), HA-K (`/` does not carry the +API's name). diff --git a/apps/api/docs/architecture.md b/apps/api/docs/architecture.md new file mode 100644 index 0000000..2269eeb --- /dev/null +++ b/apps/api/docs/architecture.md @@ -0,0 +1,18 @@ +# api — architecture + +Built by the turbo pipeline from `apps/api` and deployed with wrangler. + +| | | +|---|---| +| Worker config | `apps/api/wrangler.jsonc` | +| Entry | `src/index.ts` | +| Compatibility date | `2026-10-01` | +| Compatibility flags | `nodejs_compat` | + +## Bindings + +None: the Worker binds no storage or service. + +## Variables + +`ENVIRONMENT` — overridden per environment (`dev`, `prod`, `stage`). diff --git a/apps/api/docs/overview.md b/apps/api/docs/overview.md new file mode 100644 index 0000000..f812616 --- /dev/null +++ b/apps/api/docs/overview.md @@ -0,0 +1,20 @@ +# api + +The Hono API (a plain Cloudflare Worker, per environment) + +A Cloudflare Worker, deployed per environment by its CI lane. + +| | | +|---|---| +| Type | `cloudflare-worker-turbo` | +| Source | `apps/api` | +| Package | `@app/api` | +| 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/api/docs/runbook.md b/apps/api/docs/runbook.md new file mode 100644 index 0000000..6970618 --- /dev/null +++ b/apps/api/docs/runbook.md @@ -0,0 +1,39 @@ +# api — 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/api dev +pnpm --filter @app/api build +pnpm --filter @app/api typecheck +pnpm --filter @app/api lint +``` + +## Verify + +After a deploy the lane runs this smoke against the environment it +deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL: + +```bash +base="${DEPLOYED_URL:-https://hono-api-api-${ORUN_ENVIRONMENT}.your-workers-subdomain.workers.dev}" && health="$(curl -sf --max-time 20 "${base}/health")" && echo "${health}" | grep -q "\"status\":\"ok\"" && echo "${health}" | grep -q "\"environment\":\"${ORUN_ENVIRONMENT}\"" +``` + +## 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 8de7a93..7472544 100644 --- a/docs/phases/01-product.md +++ b/docs/phases/01-product.md @@ -2,7 +2,7 @@ **Places** everything an API 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 API'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 742a6c5..5e860ef 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -175,16 +175,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 @@ -381,7 +371,7 @@ phases: await: "One convergence is deploying the API to stage and prod: install, build, deploy and a smoke against /health in each. Nothing is stuck." done: "{{ .inputs.reponame }} is live on stage and prod — {{ .meta.files }} files on main, branded as {{ .inputs.productname }}, /health answering on both. That took {{ .meta.elapsed }}." failed: "The API 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, api, api-tests, 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] + modules: [ai-deployment, ai-operations, api, api-tests, 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] # 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 c1e56af..63bb420 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 | |------|---------|--------|------------| -| [`hono-api/`](./hono-api/) | **HA** | 🟡 In progress | Vercel's Hono boilerplate, equivalent in code and function, as a Cloudflare Worker — and an Orun baseline that instantiates it in one landing (HA3) | +| [`hono-api/`](./hono-api/) | **HA** | ✅ Shipped (`baseline-v1`); live bootstrap pending | Vercel's Hono boilerplate, equivalent in code and function, as a Cloudflare Worker — and an Orun baseline that instantiates it in one landing (HA3) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/hono-api/IMPLEMENTATION-STATUS.md b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md index 15c34c9..4743c35 100644 --- a/specs/epics/hono-api/IMPLEMENTATION-STATUS.md +++ b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md @@ -8,7 +8,8 @@ the code departed from `design.md` or from the upstream template. | HA0 — the spec | ✅ Shipped | [#1](https://github.com/sourceplane/hono-api/pull/1) | | HA1 — the API on Workers | ✅ Shipped | [#2](https://github.com/sourceplane/hono-api/pull/2) | | HA2 — ready to instantiate | ✅ Shipped | [#3](https://github.com/sourceplane/hono-api/pull/3) | -| HA3 — a baseline | 🟡 In review | this PR (HA-4), to be tagged `baseline-v1` | +| HA3 — a baseline | ✅ Shipped | [#4](https://github.com/sourceplane/hono-api/pull/4) (HA-4), tagged `baseline-v1` | +| HA4 — the cirrus standard | ✅ Shipped | HA-5 — on `main` after `baseline-v1`, not yet tagged | ## Departures from the upstream template @@ -54,6 +55,35 @@ unchanged. | discovery roots | `apps/`, `tests/` only | `infra/.gitkeep`, `packages/.gitkeep` too | `orun plan` refuses a missing discovery root (`stat infra: no such file or directory`) — `ci.yml` had never planned here | | `tasks/HA-1..3` | no `metadata` | `metadata.name` and `title` | `orun work check` (2.79) refused them | +## The cirrus standard (HA4) + +Nothing about the API changed. What changed is the baseline around it: + +| What | Before | After | Why | +|---|---|---|---| +| orun pin | `kiox.yaml` (v2.15.0) + `kiox.lock`, shipped to every API | 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` follows) | an API is placed with 38 + 6 files: no kiox, plus the docs below | +| component docs | none | `apps/api/docs/` and `tests/api/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) | +| status | HA3 "in review" | HA3 shipped and tagged `baseline-v1` | the tag existed; the documents had not caught up | + +## Verified (HA4) + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green; `gen-component-docs.py --check` green. +- `testing/leak.test.sh`: 44 files derived (40 − 2 kiox + 6 docs pages), every + one read; ai/context still exactly the two declared pages; the generated + pages name no factory path. +- `testing/placement.test.sh`: 44 files placed, both landings, branded, + re-tenanted; the API's own `orun plan` deploys `api` to stage and prod. +- `pnpm install --frozen-lockfile`, `wire:fixture`, `typecheck`, `lint`, + `test` (5 tests), `build` green. +- `testing/e2e.test.sh` green: the stage lane's planned steps in a staged job + tree, `wrangler dev --env stage`, the component's own smoke. +- `orun task check HA-5` complete. +- Locally with orun 2.85.0; CI pins v2.58.11 (blueprint) and v2.78.4 (lanes). + ## Verified (HA3) - `orun new --status` reads the blueprint at v2.58.11 (the bootstrap floor), diff --git a/specs/epics/hono-api/README.md b/specs/epics/hono-api/README.md index ffd130e..6a19a37 100644 --- a/specs/epics/hono-api/README.md +++ b/specs/epics/hono-api/README.md @@ -8,15 +8,15 @@ The upstream code stays the code. The port adds the Worker's config (`wrangler.j | Field | Value | |-------|-------| -| Status | 🟡 HA0–HA2 shipped (#1, #2, #3); HA3 — a baseline — in this PR (HA-4), not yet proven by a live bootstrap | -| Cluster | **HA** (HA0–HA3) | +| Status | ✅ HA0–HA3 shipped (#1–#4), tagged `baseline-v1`; HA4 (the cirrus standard, HA-5) on `main`, not yet tagged. Not yet proven by a live bootstrap (risk HA-F) | +| Cluster | **HA** (HA0–HA4) | | Owner(s) | `apps/api` (the Worker) · `tests/api` (the in-process request tests) | | Builds on | `cirrus-baseline` conventions (intent, components, `checks.yml` gate, gated `ci.yml`) and the `cloudflare-worker-turbo` composition its workers deploy with — no bounded context of the fleet is needed | | Upstream | [vercel/examples `framework-boilerplates/hono`](https://github.com/vercel/examples/tree/main/framework-boilerplates/hono) | | Changes | Adds the Worker config, the monorepo wrapper, tests and the deploy contract; the template's app code is untouched but for the welcome line's link | | Decisions locked | (1) A plain Worker (`cloudflare-worker-turbo`), not Pages Functions and not an adapter: Hono's default export is already a Workers module handler. (2) `wrangler.jsonc` is committed, not rendered: the Worker binds nothing, so there is nothing to wire. (3) Per-environment deploys through wrangler `env` sections (`--env stage` / `--env prod`), naming `hono-api-api-{stage,prod}`. (4) No infra root. | | Gate | HA1 is the first user-visible rung (the API serves from a Worker). | -| Shipped as | `main` after [#3](https://github.com/sourceplane/hono-api/pull/3); verified locally under `wrangler dev` and the `--env prod` dry run, deploy gated until a workspace is linked | +| Shipped as | `baseline-v1` ([#4](https://github.com/sourceplane/hono-api/pull/4)), then HA4 on `main`; proven offline (Baseline CI), deploy gated until a workspace is linked | ## Read order @@ -33,3 +33,4 @@ The upstream code stays the code. The port adds the Worker's config (`wrangler.j | HA1 — the API on Workers | `apps/api` bundled by wrangler, `tests/api`, green checks | `wrangler dev` answers `/` with the welcome text; Checks green | | HA2 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it | | HA3 — a baseline | card, build document, rename, bootstrap tooling, tests | a new API goes from nothing to live in one landing; Baseline CI green | +| HA4 — 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/hono-api/design.md b/specs/epics/hono-api/design.md index 261c425..47d2820 100644 --- a/specs/epics/hono-api/design.md +++ b/specs/epics/hono-api/design.md @@ -36,7 +36,7 @@ apps/api the template (src/index.ts) + the Worker config tests/api vitest: app.request("/") in-process — no server, no workerd tooling/* shared tsconfig / eslint / wrangler wiring renderer (unused here: nothing to wire) intent.yaml environments dev (verify) · stage · prod; `work:` points at specs/epics and tasks -.github/workflows checks.yml (merge gate) · ci.yml (Orun lanes, gated by the ORUN_CI variable) +.github/workflows checks.yml (merge gate) · ci.yml (Orun lanes; plans nothing while intent.yaml names ws_CHANGE_ME) ``` ## 4. The build diff --git a/specs/epics/hono-api/epic.yaml b/specs/epics/hono-api/epic.yaml index f83d5e9..d378b13 100644 --- a/specs/epics/hono-api/epic.yaml +++ b/specs/epics/hono-api/epic.yaml @@ -32,3 +32,10 @@ spec: - "an API built from it carries the API only, renamed throughout to its own name, repository and Worker, through one seam (apps/api/src/identity.ts), 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, the Worker served by wrangler dev and smoke-tested on /health" tasks: [HA-4] + - name: "HA4 — 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 an API" + - "every milestone's status row agrees with the tags" + tasks: [HA-5] diff --git a/specs/epics/hono-api/implementation-plan.md b/specs/epics/hono-api/implementation-plan.md index 260b8ea..3a7af3d 100644 --- a/specs/epics/hono-api/implementation-plan.md +++ b/specs/epics/hono-api/implementation-plan.md @@ -31,7 +31,7 @@ The README explains the port and how to run, test, preview and deploy it; - the README's quick start works from a fresh clone - the status file names the PRs and the welcome-line departure -## HA3 — a baseline (HA-4) +## HA3 — a baseline (HA-4) ✅ `blueprint.yaml`, `repo-blueprint.yaml`, `.baseline/` (identity, task contracts, the API's README), `tooling/rebrand`, `tooling/bootstrap`, @@ -49,6 +49,29 @@ contracts, the API's README), `tooling/rebrand`, `tooling/bootstrap`, - the status file records what is proven offline and what only a live bootstrap can prove +## HA4 — the cirrus standard (HA-5) ✅ + +Bring the baseline to cirrus-baseline's standard, with nothing about the API +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 an API ships with — this repository's + own, so no module places them. +- **Status that agrees with the tags.** HA3 is shipped and tagged. + +**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 HA3 (outside this repository) 1. Cut `baseline-v1` with `tag.yml` from the merged `main`. diff --git a/tasks/HA-5.TaskContract.yaml b/tasks/HA-5.TaskContract.yaml new file mode 100644 index 0000000..7618750 --- /dev/null +++ b/tasks/HA-5.TaskContract.yaml @@ -0,0 +1,28 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: HA-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/api/docs/** + - tests/api/docs/** + - ai/context/** + - docs/phases/** + - specs/** + - tasks/** + doneWhen: + - no file names kiox, and the leak gate and the offline bootstrap place an API 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 be4237c..6b80430 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", "api", "api-tests", "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"], "02-docs": [], diff --git a/tests/api/docs/architecture.md b/tests/api/docs/architecture.md new file mode 100644 index 0000000..5954032 --- /dev/null +++ b/tests/api/docs/architecture.md @@ -0,0 +1,7 @@ +# api-tests — architecture + +A test package at `tests/api`. Its lane runs the suite before it builds. + +## Suites (1) + +- `app.test.ts` diff --git a/tests/api/docs/overview.md b/tests/api/docs/overview.md new file mode 100644 index 0000000..2b670ed --- /dev/null +++ b/tests/api/docs/overview.md @@ -0,0 +1,18 @@ +# api-tests + +The test suite for **api**. It deploys nothing: its lane installs, builds and runs the tests. + +| | | +|---|---| +| Type | `turbo-package` | +| Source | `tests/api` | +| Package | `@app/api-tests` | +| Environments | `dev`: `quick-check` | + +## Depends on + +- (none) + +## Depended on by + +- (none) diff --git a/tests/api/docs/runbook.md b/tests/api/docs/runbook.md new file mode 100644 index 0000000..4b40103 --- /dev/null +++ b/tests/api/docs/runbook.md @@ -0,0 +1,26 @@ +# api-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/api-tests build +pnpm --filter @app/api-tests test +pnpm --filter @app/api-tests typecheck +pnpm --filter @app/api-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 9c40f39..49017bc 100755 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -176,7 +176,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 83df3191849c37e12b5efaeed8646a0498531791 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:27:40 +0000 Subject: [PATCH 2/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. - Word the kiox exit criterion as it can be true: nothing outside this milestone's own record names kiox. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- apps/api/docs/architecture.md | 12 ++--- apps/api/docs/overview.md | 10 ++-- apps/api/docs/runbook.md | 3 -- specs/epics/hono-api/epic.yaml | 2 +- specs/epics/hono-api/implementation-plan.md | 2 +- tasks/HA-5.TaskContract.yaml | 2 +- tests/api/docs/overview.md | 10 ++-- tooling/catalog/gen-component-docs.py | 53 +++++++++++++-------- 8 files changed, 53 insertions(+), 41 deletions(-) diff --git a/apps/api/docs/architecture.md b/apps/api/docs/architecture.md index 2269eeb..4cffbed 100644 --- a/apps/api/docs/architecture.md +++ b/apps/api/docs/architecture.md @@ -2,12 +2,12 @@ Built by the turbo pipeline from `apps/api` and deployed with wrangler. -| | | -|---|---| -| Worker config | `apps/api/wrangler.jsonc` | -| Entry | `src/index.ts` | -| Compatibility date | `2026-10-01` | -| Compatibility flags | `nodejs_compat` | +| | | +| ------------------- | ------------------------- | +| Worker config | `apps/api/wrangler.jsonc` | +| Entry | `src/index.ts` | +| Compatibility date | `2026-10-01` | +| Compatibility flags | `nodejs_compat` | ## Bindings diff --git a/apps/api/docs/overview.md b/apps/api/docs/overview.md index f812616..84c2203 100644 --- a/apps/api/docs/overview.md +++ b/apps/api/docs/overview.md @@ -4,11 +4,11 @@ The Hono API (a plain Cloudflare Worker, per environment) A Cloudflare Worker, deployed per environment by its CI lane. -| | | -|---|---| -| Type | `cloudflare-worker-turbo` | -| Source | `apps/api` | -| Package | `@app/api` | +| | | +| ------------ | ------------------------------------------------------------------------------------------------------------------ | +| Type | `cloudflare-worker-turbo` | +| Source | `apps/api` | +| Package | `@app/api` | | 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/api/docs/runbook.md b/apps/api/docs/runbook.md index 6970618..89d148a 100644 --- a/apps/api/docs/runbook.md +++ b/apps/api/docs/runbook.md @@ -31,9 +31,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/specs/epics/hono-api/epic.yaml b/specs/epics/hono-api/epic.yaml index d378b13..2648dbc 100644 --- a/specs/epics/hono-api/epic.yaml +++ b/specs/epics/hono-api/epic.yaml @@ -34,7 +34,7 @@ spec: tasks: [HA-4] - name: "HA4 — 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 an API" - "every milestone's status row agrees with the tags" diff --git a/specs/epics/hono-api/implementation-plan.md b/specs/epics/hono-api/implementation-plan.md index 3a7af3d..c974eba 100644 --- a/specs/epics/hono-api/implementation-plan.md +++ b/specs/epics/hono-api/implementation-plan.md @@ -67,7 +67,7 @@ itself changing. - **Status that agrees with the tags.** HA3 is shipped and tagged. **Done when** -- `git grep -i kiox` finds nothing, and the leak gate and the offline +- `git grep -i kiox` finds only this milestone's own record, 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/HA-5.TaskContract.yaml b/tasks/HA-5.TaskContract.yaml index 7618750..fd6b68f 100644 --- a/tasks/HA-5.TaskContract.yaml +++ b/tasks/HA-5.TaskContract.yaml @@ -20,7 +20,7 @@ spec: - specs/** - tasks/** doneWhen: - - no file names kiox, and the leak gate and the offline bootstrap place an API without it + - nothing outside this milestone's own record names kiox, and the leak gate and the offline bootstrap place an API 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 diff --git a/tests/api/docs/overview.md b/tests/api/docs/overview.md index 2b670ed..6cfa4ac 100644 --- a/tests/api/docs/overview.md +++ b/tests/api/docs/overview.md @@ -2,11 +2,11 @@ The test suite for **api**. It deploys nothing: its lane installs, builds and runs the tests. -| | | -|---|---| -| Type | `turbo-package` | -| Source | `tests/api` | -| Package | `@app/api-tests` | +| | | +| ------------ | -------------------- | +| Type | `turbo-package` | +| Source | `tests/api` | +| Package | `@app/api-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 b9bda16ac3afd6a248fae50c58a8b7b2a8d88f9b Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:34:52 +0000 Subject: [PATCH 3/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 --- tooling/catalog/gen-component-docs.py | 37 ++++++++++++++++++--------- 1 file changed, 25 insertions(+), 12 deletions(-) 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 6f8c9dfb60ed4a0afb38ccf4c14cbe12302ccd83 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 12:03:08 +0000 Subject: [PATCH 4/5] HA4: read the workers.dev subdomain from the Cloudflare connection - blueprint.yaml: the subdomain input is `from: connection.cloudflare.workersSubdomain`, as cirrus-baseline since baseline-v23 (#30); the console renders no field for it - testing/manifest.test.sh: cirrus's rule verbatim, accepting the source only when spec.requires.integrations lists its provider (mutation-checked) - repo-blueprint.yaml, BOOTSTRAP.md, docs/phases/README.md: only a hand-run build passes --set subdomain - records: HA-6 under HA4, status, plan, epic index, ai/context 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 +- specs/epics/hono-api/IMPLEMENTATION-STATUS.md | 37 ++++++++++++++++++- specs/epics/hono-api/README.md | 6 +-- specs/epics/hono-api/epic.yaml | 3 +- specs/epics/hono-api/implementation-plan.md | 5 +++ tasks/HA-6.TaskContract.yaml | 25 +++++++++++++ testing/manifest.test.sh | 15 +++++++- 13 files changed, 117 insertions(+), 15 deletions(-) create mode 100644 tasks/HA-6.TaskContract.yaml diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index 241eeb3..93ce216 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -55,6 +55,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 tokens +mint from. Only a hand-run build like this one passes it. + **`--run-hooks` is the difference between placing files and bootstrapping an API.** 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 82e7da8..e979dbe 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -16,8 +16,8 @@ own repository and takes it to live on stage and prod in one landing | | | |---|---| -| Latest tag | `baseline-v1` (HA3) | -| On `main` since | HA4 — the cirrus standard (no kiox, generated component docs, this context pack) | +| Latest tag | `baseline-v2` (HA4 — 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` (HA3 — the baseline) | | Proven live | No. Everything short of the platform is proven offline in Baseline CI; a live bootstrap from a tag is still to come (risk HA-F) | ## Where to read @@ -32,6 +32,5 @@ own repository and takes it to live on stage and prod in one landing ## Next -1. Bootstrap one API from the next tag against a workspace, and record its +1. Bootstrap one API from `baseline-v2` against a workspace, and record its timings (closes HA-F). -2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin HA4. diff --git a/ai/context/decisions.md b/ai/context/decisions.md index ca32294..94e64a0 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -16,3 +16,4 @@ reads in order. | 8 | stack-tectonic 0.19.0, not 0.20.0 | The family's one pin: 0.20.0's linked install breaks the Next.js baselines | risk HA-J | | 9 | 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 (HA4) | | 10 | 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` | +| 11 | `subdomain` is read from the Cloudflare connection (`from: connection.cloudflare.workersSubdomain`), never asked | It belongs to the account like its id and has one right answer; a typed one could only be wrong, and showed up after deploy in the smoke and the probes | `blueprint.yaml`, IMPLEMENTATION-STATUS (HA-6) | diff --git a/blueprint.yaml b/blueprint.yaml index bde3331..01e6b18 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -88,6 +88,18 @@ spec: pattern: "^[a-z0-9][a-z0-9-]{0,62}$" help: The workers.dev subdomain of the Cloudflare account the API 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 check, the phase probes and the + # verify URLs 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 tokens mint from, so all three + # name one account. The console renders no field for it. 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 9b4fbe2..ab7e9b4 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -64,8 +64,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 5e860ef..cc8a0d4 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -50,7 +50,12 @@ inputs: subdomain: type: string default: "your-workers-subdomain" - description: The workers.dev subdomain of the Cloudflare account the API deploys into — its URLs, the deploy's smoke, the probes. + description: >- + The workers.dev subdomain of the Cloudflare account the API 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 63bb420..2d29edf 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 | |------|---------|--------|------------| -| [`hono-api/`](./hono-api/) | **HA** | ✅ Shipped (`baseline-v1`); live bootstrap pending | Vercel's Hono boilerplate, equivalent in code and function, as a Cloudflare Worker — and an Orun baseline that instantiates it in one landing (HA3) | +| [`hono-api/`](./hono-api/) | **HA** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's Hono boilerplate, equivalent in code and function, as a Cloudflare Worker — and an Orun baseline that instantiates it in one landing (HA3) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/hono-api/IMPLEMENTATION-STATUS.md b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md index 4743c35..762fcdc 100644 --- a/specs/epics/hono-api/IMPLEMENTATION-STATUS.md +++ b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md @@ -9,7 +9,7 @@ the code departed from `design.md` or from the upstream template. | HA1 — the API on Workers | ✅ Shipped | [#2](https://github.com/sourceplane/hono-api/pull/2) | | HA2 — ready to instantiate | ✅ Shipped | [#3](https://github.com/sourceplane/hono-api/pull/3) | | HA3 — a baseline | ✅ Shipped | [#4](https://github.com/sourceplane/hono-api/pull/4) (HA-4), tagged `baseline-v1` | -| HA4 — the cirrus standard | ✅ Shipped | HA-5 — on `main` after `baseline-v1`, not yet tagged | +| HA4 — the cirrus standard | ✅ Shipped | [#5](https://github.com/sourceplane/hono-api/pull/5) (HA-5), [#6](https://github.com/sourceplane/hono-api/pull/6) (HA-6), tagged `baseline-v2` | ## Departures from the upstream template @@ -68,6 +68,41 @@ Nothing about the API changed. What changed is the baseline around it: | 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) | | status | HA3 "in review" | HA3 shipped and tagged `baseline-v1` | the tag existed; the documents had not caught up | +### The subdomain from the Cloudflare connection (HA-6) + +`subdomain` was the one input an operator typed that the platform could +answer itself: it belongs to the Cloudflare account the same way its id does, +and it has exactly one right answer. A typed one could only be wrong, and +wrong showed up after deploy — in the deploy's smoke, the phase probes and the +console's verify URLs. `blueprint.yaml` now declares +`from: connection.cloudflare.workersSubdomain`, as cirrus-baseline does since +baseline-v23: the Cloudflare integration reads the subdomain at connect and on +its hourly health check, and the bootstrap door fills the input from the +connection the build is bound to — the same one `CLOUDFLARE_ACCOUNT_ID` and the +deploy token mint from. The console renders no field for it, and an account +with no workers.dev subdomain is refused at the door with the fix named. + +- `testing/manifest.test.sh` takes cirrus-baseline's rule verbatim: the source + is accepted, and only when `spec.requires.integrations` lists its provider. +- `repo-blueprint.yaml` keeps the input and its default; it, `BOOTSTRAP.md` + and `docs/phases/README.md` say only a hand-run build passes + `--set subdomain`. +- Nothing an API carries changes: the rename, the smoke and the probes read + the value exactly as before. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green; `gen-component-docs.py --check` green (2 components). +- Mutation: with `cloudflare` dropped from `spec.requires.integrations`, + `manifest.test.sh` fails with exactly one finding, naming + `inputs[subdomain]`; restored, it passes. +- At v2.58.11 (the blueprint job's pin): `orun new --status` reads the + document (`01-product` pending, 44 files); `testing/leak.test.sh` 44 files + derived, every one read; `testing/placement.test.sh` 44 files placed, both + landings, the API's own plan deploys `api` to stage and prod. +- `orun task check HA-6` complete. + ## Verified (HA4) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` diff --git a/specs/epics/hono-api/README.md b/specs/epics/hono-api/README.md index 6a19a37..4f0ceb9 100644 --- a/specs/epics/hono-api/README.md +++ b/specs/epics/hono-api/README.md @@ -8,7 +8,7 @@ The upstream code stays the code. The port adds the Worker's config (`wrangler.j | Field | Value | |-------|-------| -| Status | ✅ HA0–HA3 shipped (#1–#4), tagged `baseline-v1`; HA4 (the cirrus standard, HA-5) on `main`, not yet tagged. Not yet proven by a live bootstrap (risk HA-F) | +| Status | ✅ HA0–HA3 shipped (#1–#4), tagged `baseline-v1`; HA4 (the cirrus standard, HA-5 #5 and HA-6 #6) tagged `baseline-v2`. Not yet proven by a live bootstrap (risk HA-F) | | Cluster | **HA** (HA0–HA4) | | Owner(s) | `apps/api` (the Worker) · `tests/api` (the in-process request tests) | | Builds on | `cirrus-baseline` conventions (intent, components, `checks.yml` gate, gated `ci.yml`) and the `cloudflare-worker-turbo` composition its workers deploy with — no bounded context of the fleet is needed | @@ -16,7 +16,7 @@ The upstream code stays the code. The port adds the Worker's config (`wrangler.j | Changes | Adds the Worker config, the monorepo wrapper, tests and the deploy contract; the template's app code is untouched but for the welcome line's link | | Decisions locked | (1) A plain Worker (`cloudflare-worker-turbo`), not Pages Functions and not an adapter: Hono's default export is already a Workers module handler. (2) `wrangler.jsonc` is committed, not rendered: the Worker binds nothing, so there is nothing to wire. (3) Per-environment deploys through wrangler `env` sections (`--env stage` / `--env prod`), naming `hono-api-api-{stage,prod}`. (4) No infra root. | | Gate | HA1 is the first user-visible rung (the API serves from a Worker). | -| Shipped as | `baseline-v1` ([#4](https://github.com/sourceplane/hono-api/pull/4)), then HA4 on `main`; proven offline (Baseline CI), deploy gated until a workspace is linked | +| Shipped as | `baseline-v1` ([#4](https://github.com/sourceplane/hono-api/pull/4)), then `baseline-v2` (HA4: [#5](https://github.com/sourceplane/hono-api/pull/5), [#6](https://github.com/sourceplane/hono-api/pull/6)); proven offline (Baseline CI), deploy gated until a workspace is linked | ## Read order @@ -33,4 +33,4 @@ The upstream code stays the code. The port adds the Worker's config (`wrangler.j | HA1 — the API on Workers | `apps/api` bundled by wrangler, `tests/api`, green checks | `wrangler dev` answers `/` with the welcome text; Checks green | | HA2 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it | | HA3 — a baseline | card, build document, rename, bootstrap tooling, tests | a new API goes from nothing to live in one landing; Baseline CI green | -| HA4 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags | Baseline CI green with the docs check | +| HA4 — 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/hono-api/epic.yaml b/specs/epics/hono-api/epic.yaml index 2648dbc..d40067a 100644 --- a/specs/epics/hono-api/epic.yaml +++ b/specs/epics/hono-api/epic.yaml @@ -38,4 +38,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 an API" - "every milestone's status row agrees with the tags" - tasks: [HA-5] + - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" + tasks: [HA-5, HA-6] diff --git a/specs/epics/hono-api/implementation-plan.md b/specs/epics/hono-api/implementation-plan.md index c974eba..4759e43 100644 --- a/specs/epics/hono-api/implementation-plan.md +++ b/specs/epics/hono-api/implementation-plan.md @@ -65,6 +65,11 @@ itself changing. `open-risks.md` beside the two pages an API ships with — this repository's own, so no module places them. - **Status that agrees with the tags.** HA3 is shipped and tagged. +- **The subdomain from the Cloudflare connection (HA-6).** The card declares + `subdomain` as `from: connection.cloudflare.workersSubdomain`, as + cirrus-baseline does since baseline-v23, so the console asks for nothing the + connection already knows; `testing/manifest.test.sh` requires the source's + provider in `spec.requires.integrations`. **Done when** - `git grep -i kiox` finds only this milestone's own record, and the leak gate and the offline diff --git a/tasks/HA-6.TaskContract.yaml b/tasks/HA-6.TaskContract.yaml new file mode 100644 index 0000000..c031d8e --- /dev/null +++ b/tasks/HA-6.TaskContract.yaml @@ -0,0 +1,25 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: HA-6 + title: "The subdomain from the Cloudflare connection" +spec: + goal: "The console card reads the workers.dev subdomain from the workspace's Cloudflare connection (`from: connection.cloudflare.workersSubdomain`) instead of asking for it, as cirrus-baseline does since baseline-v23, and the manifest gate holds that source to a connection the card requires" + 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/epics/README.md + - specs/epics/hono-api/** + - tasks/HA-6.TaskContract.yaml + doneWhen: + - "blueprint.yaml declares `from: connection.cloudflare.workersSubdomain` on `subdomain`, so the console renders no field for it" + - testing/manifest.test.sh accepts that source only when spec.requires.integrations lists its provider, and fails naming the input when it does not (mutation-checked) + - BOOTSTRAP.md, docs/phases and repo-blueprint.yaml say only a hand-run build passes `--set subdomain` + - the contract tests, the docs check, the leak gate and the offline bootstrap are green + 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 [])} From 0a7adfa13c3a7b5c9ff916324d50a729cf8c31f0 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Oct 2026 03:40:25 +0000 Subject: [PATCH 5/5] =?UTF-8?q?HA5:=20the=20console=20asks=20for=20no=20do?= =?UTF-8?q?main=20=E2=80=94=20the=20domain=20is=20set=20later?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The API goes live on workers.dev from its first deploy and nothing in the build needs a domain, so the console no longer asks for one. The logic that uses a domain stays where it is, waiting for one. - blueprint.yaml: no productdomain input - repo-blueprint.yaml: productdomain is optional, default empty - rebrand.mjs: productdomain no longer required; empty brands the reserved placeholder .example.com (RFC 2606) where the domain goes (BASE_DOMAIN in intent.yaml, every environment), so setting it later is replacing one string - the product README and ai/context/operations.md say how to set it - testing/fixtures/acme.json carries no domain; rebrand.test.sh pins the placeholder (absent, empty, and a slug whose placeholder ends in the baseline's domain); baseline.yml's blueprint read sets no domain - records: HA5 / HA-7, tagged baseline-v3 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- .baseline/product/README.md | 5 ++ .github/workflows/baseline.yml | 1 - BOOTSTRAP.md | 14 ++++-- README.md | 2 +- ai/context/current.md | 6 +-- ai/context/decisions.md | 1 + ai/context/operations.md | 2 +- blueprint.yaml | 11 +++-- docs/phases/README.md | 12 +++-- repo-blueprint.yaml | 13 +++-- specs/epics/README.md | 2 +- specs/epics/hono-api/IMPLEMENTATION-STATUS.md | 48 +++++++++++++++++++ specs/epics/hono-api/README.md | 7 +-- specs/epics/hono-api/epic.yaml | 6 +++ specs/epics/hono-api/implementation-plan.md | 9 ++++ tasks/HA-7.TaskContract.yaml | 30 ++++++++++++ testing/fixtures/acme.json | 10 ++-- testing/rebrand.test.sh | 12 +++++ tooling/rebrand/rebrand.mjs | 10 ++-- 19 files changed, 166 insertions(+), 35 deletions(-) create mode 100644 tasks/HA-7.TaskContract.yaml diff --git a/.baseline/product/README.md b/.baseline/product/README.md index 145454f..736f069 100644 --- a/.baseline/product/README.md +++ b/.baseline/product/README.md @@ -100,3 +100,8 @@ environments: env: DEPLOYED_URL: https://hono-api.example.com ``` + +The repository names the domain in one place, `BASE_DOMAIN` in `intent.yaml` +(one line per environment), which the API was born with as the reserved +placeholder `hono-api.example.com` — the example above carries it too. +Replace it with your domain in the same change that attaches it. diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index 109707d..3c81548 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -91,7 +91,6 @@ jobs: --out "$(mktemp -d)" \ --set reponame=acme-api \ --set "productname=Acme API" \ - --set productdomain=acme.dev \ --set githuborg=acme-inc - name: the leak gate — what an API carries run: bash testing/leak.test.sh diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index 93ce216..eede899 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -50,7 +50,7 @@ cd hono-api orun new --blueprint repo-blueprint.yaml \ --out ~/apis/acme-api --run-hooks --resume \ --set reponame=acme-api --set productname="Acme API" \ - --set productdomain=acme.dev --set githuborg=acme-inc \ + --set githuborg=acme-inc \ --set orunWorkspace=ws_XXXXXXXX \ --set subdomain= ``` @@ -87,9 +87,13 @@ orun new --blueprint repo-blueprint.yaml --out ~/apis/acme-api --run-hooks \ `02-docs` reads the identity back from `.rebrand/values.json` in the placed tree, but the blueprint's **required** inputs — `reponame`, `productname`, -`productdomain`, `githuborg` — are validated before anything runs, so pass -them every time (a `--values` file is easier). The full guide, one page per -phase: [docs/phases/README.md](docs/phases/README.md). +`githuborg` — are validated before anything runs, so pass them every time (a +`--values` file is easier). The domain is not one of them: the API goes live +on workers.dev, and `productdomain` defaults to empty, which brands the +reserved placeholder `.example.com` into `BASE_DOMAIN` for an owner +to replace when they attach a domain (README, "Custom domain"). Pass +`--set productdomain=` only for an API that already has its domain. +The full guide, one page per phase: [docs/phases/README.md](docs/phases/README.md). | flag | what it does | |---|---| @@ -192,7 +196,7 @@ at the tag and refuses the whole catalogue if it 404s. | Convergence failed AFTER the PR merged; re-running lands nothing | expected on its own — the files are on main. Re-run the phase (`--phase 01-product`, `--redo 01-product`, or the console's Retry): its `retouch` hook gives the landing a diff and the API redeploys | | The API's `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace; set it and re-run `01-product` | | A bootstrap stopped before `02-docs`; prod no longer waits on stage | the gate is deferred, not dropped: run `02-docs`, or `node tooling/bootstrap/promotion.mjs --restore --file /intent.yaml` | -| `✕ input "productdomain" is required` | all four required inputs must be set on every invocation, single-phase ones included | +| `✕ input "productname" is required` | all three required inputs (`reponame`, `productname`, `githuborg`) must be set on every invocation, single-phase ones included | | `unknown flag: --phase` or a parse error in the blueprint | the CLI is below the v2.58.11 floor | | the convergence reported green, then `verify` got 404 from both URLs | a second workflow ran on the push to main and the watch took its run. Only `ci.yml` runs on a push to main (`testing/coverage.test.sh` holds it); read the CI run on main for the real result | | the convergence planned no lanes at all | the merge's push had no `before` to diff against (a first push straight onto an unborn `main`). The landing merges a pull request into orun's `Initial commit`, so its push has one; re-run the phase and its retouch marker re-plans the API | diff --git a/README.md b/README.md index 8f88525..380e071 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ milestones and the as-built status. git clone --depth 1 --branch https://github.com/sourceplane/hono-api cd hono-api orun new --blueprint repo-blueprint.yaml --out ~/apis/acme-api --run-hooks --resume \ - --set reponame=acme-api --set productname="Acme API" --set productdomain=acme.dev \ + --set reponame=acme-api --set productname="Acme API" \ --set githuborg=acme-inc --set subdomain= ``` diff --git a/ai/context/current.md b/ai/context/current.md index e979dbe..4230926 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -16,8 +16,8 @@ own repository and takes it to live on stage and prod in one landing | | | |---|---| -| Latest tag | `baseline-v2` (HA4 — 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` (HA3 — the baseline) | +| Latest tag | `baseline-v3` (HA5 — the domain is set later: the console asks for no domain, and an API is born with the placeholder `.example.com` for an owner to replace) | +| Before it | `baseline-v2` (HA4 — the cirrus standard: no kiox, generated component docs, this context pack, and the workers.dev subdomain read from the Cloudflare connection instead of asked); `baseline-v1` (HA3 — the baseline) | | Proven live | No. Everything short of the platform is proven offline in Baseline CI; a live bootstrap from a tag is still to come (risk HA-F) | ## Where to read @@ -32,5 +32,5 @@ own repository and takes it to live on stage and prod in one landing ## Next -1. Bootstrap one API from `baseline-v2` against a workspace, and record its +1. Bootstrap one API from `baseline-v3` against a workspace, and record its timings (closes HA-F). diff --git a/ai/context/decisions.md b/ai/context/decisions.md index 94e64a0..74aa9d2 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -17,3 +17,4 @@ reads in order. | 9 | 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 (HA4) | | 10 | 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` | | 11 | `subdomain` is read from the Cloudflare connection (`from: connection.cloudflare.workersSubdomain`), never asked | It belongs to the account like its id and has one right answer; a typed one could only be wrong, and showed up after deploy in the smoke and the probes | `blueprint.yaml`, IMPLEMENTATION-STATUS (HA-6) | +| 12 | The console asks for no domain; an empty `productdomain` brands the placeholder `.example.com` | The API goes live on workers.dev and nothing in the build needs a domain; attaching one is an owner's step, and the placeholder keeps every place the domain goes in the repository, ready to replace | `repo-blueprint.yaml`, `tooling/rebrand/rebrand.mjs`, IMPLEMENTATION-STATUS (HA-7) | diff --git a/ai/context/operations.md b/ai/context/operations.md index 1d7c95f..94619a3 100644 --- a/ai/context/operations.md +++ b/ai/context/operations.md @@ -96,7 +96,7 @@ orun integrations list --org --json && orun cloud check --org | deploy a change | merge to `main`; watch the run; failed lanes → `gh run rerun --failed` | | redeploy without a change | edit the last line of `apps/api/component.yaml` (`# orun: redeploy `) and merge — it is a deploy trigger, nothing reads it | | rename the API | `API_NAME` in `apps/api/src/identity.ts` — what `/health` answers with | -| serve a custom domain | attach it to the Worker in Cloudflare (README, "Custom domain"); the workers.dev URL keeps answering for the smoke | +| serve a custom domain | attach it to the Worker in Cloudflare (README, "Custom domain"), then replace the placeholder `hono-api.example.com` in `intent.yaml`'s `BASE_DOMAIN` (every environment) with it; the workers.dev URL keeps answering for the smoke | | add a runtime secret | `orun secrets set --org --env `, then declare it in the component's `optionalSecretEnv` and name it in `runtimeSecrets` | | headless credentials | `ORUN_TOKEN` (workspace-scoped) + `GITHUB_TOKEN` | diff --git a/blueprint.yaml b/blueprint.yaml index 01e6b18..838ad1c 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -59,6 +59,12 @@ spec: # already holds says so with `from`. repo-blueprint.yaml declares the same # names; `repoPrivate`, `orunWorkspace` and `epicSlug` are build inputs with # defaults (or filled from the build's workspace) and are not asked. + # + # NOR IS THE DOMAIN. The API goes live on workers.dev, and a domain is an + # owner's step after the bootstrap: `productdomain` defaults to empty, the + # rebrand writes the reserved placeholder `.example.com` where + # the domain goes, and the API's README ("Custom domain") says how to set + # it. Nothing that needs a domain is removed — it waits for one. inputs: - key: reponame label: Repo name @@ -70,11 +76,6 @@ spec: pattern: "^[A-Za-z0-9][A-Za-z0-9 .,'&-]{1,48}$" help: The name the API answers with — GET /health reports it beside the environment. example: Acme API - - key: productdomain - label: API domain - pattern: "^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$" - help: The domain the API will answer on. It does not need to exist — the API goes live on workers.dev first. - example: acme.dev - key: githuborg label: GitHub organisation pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$" diff --git a/docs/phases/README.md b/docs/phases/README.md index ab7e9b4..46ece6a 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -60,9 +60,15 @@ domain", says how. `01-product` takes the API's identity once and writes it into the repo (`.rebrand/values.json`); `02-docs` reads it back from the placed tree. But the blueprint's **required** inputs — `reponame`, `productname`, -`productdomain`, `githuborg` — are validated before any phase runs, so they -must be supplied on every invocation, single-phase ones included. A -`--values` file is easier than repeating `--set`. +`githuborg` — are validated before any phase runs, so they must be supplied +on every invocation, single-phase ones included. A `--values` file is easier +than repeating `--set`. + +- `productdomain` — NOT ASKED, default empty. The API goes live on + workers.dev; empty brands the reserved placeholder `.example.com` + into `BASE_DOMAIN`, for an owner to replace when they attach a domain (the + API's README, "Custom domain"). Pass it only for an API that already has + its domain. - `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 diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index cc8a0d4..0753f75 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -33,11 +33,16 @@ inputs: description: The API's display name (e.g. "Acme API") — what GET /health answers with. productdomain: type: string - required: true + default: "" description: >- - The domain the API will answer on (e.g. acme.dev) — BASE_DOMAIN and the - custom-domain guidance. It does not need to exist: the API answers on - workers.dev from its first deploy. + The API's own domain, once it has one (e.g. acme.dev). NOT ASKED: the + API answers on workers.dev from its first deploy, and a domain is an + owner's step after it. Empty, the rebrand writes the reserved + placeholder `.example.com` where the domain goes (BASE_DOMAIN + in intent.yaml, for every environment, and the README's DEPLOYED_URL + example), so setting it later is replacing that one string — the API's + README, "Custom domain", says how. Pass it with --set only to brand a + hand-run build with a domain it already has. githuborg: type: string pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$" diff --git a/specs/epics/README.md b/specs/epics/README.md index 2d29edf..48f3dd5 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 | |------|---------|--------|------------| -| [`hono-api/`](./hono-api/) | **HA** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's Hono boilerplate, equivalent in code and function, as a Cloudflare Worker — and an Orun baseline that instantiates it in one landing (HA3) | +| [`hono-api/`](./hono-api/) | **HA** | ✅ Shipped (`baseline-v3`); live bootstrap pending | Vercel's Hono boilerplate, equivalent in code and function, as a Cloudflare Worker — and an Orun baseline that instantiates it in one landing (HA3) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/hono-api/IMPLEMENTATION-STATUS.md b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md index 762fcdc..1f9cf33 100644 --- a/specs/epics/hono-api/IMPLEMENTATION-STATUS.md +++ b/specs/epics/hono-api/IMPLEMENTATION-STATUS.md @@ -10,6 +10,7 @@ the code departed from `design.md` or from the upstream template. | HA2 — ready to instantiate | ✅ Shipped | [#3](https://github.com/sourceplane/hono-api/pull/3) | | HA3 — a baseline | ✅ Shipped | [#4](https://github.com/sourceplane/hono-api/pull/4) (HA-4), tagged `baseline-v1` | | HA4 — the cirrus standard | ✅ Shipped | [#5](https://github.com/sourceplane/hono-api/pull/5) (HA-5), [#6](https://github.com/sourceplane/hono-api/pull/6) (HA-6), tagged `baseline-v2` | +| HA5 — the domain is set later | ✅ Shipped | [#7](https://github.com/sourceplane/hono-api/pull/7) (HA-7), tagged `baseline-v3` | ## Departures from the upstream template @@ -103,6 +104,53 @@ Verified: landings, the API's own plan deploys `api` to stage and prod. - `orun task check HA-6` complete. +## The domain is set later (HA5, HA-7) + +The console asked for the API's domain, with help text that said it did not +need to exist — and nothing in the build needed one: the API answers on +workers.dev from its first deploy, the deploy's smoke and the phase probes +read the workers.dev URL, and the one place the repository names the domain +is `BASE_DOMAIN` in `intent.yaml` (one line per environment: dev, stage, +prod), plus the README's `DEPLOYED_URL` example. A domain is an owner's step +after the bootstrap (README, "Custom domain"), so the form no longer asks for +it. + +- `blueprint.yaml` declares no `productdomain` input; the console asks for + the API's name alone. +- `repo-blueprint.yaml`'s `productdomain` is optional, default empty. Nothing + else in the build reads it — no hook, probe or `when:` — so an empty value + is harmless; `.rebrand/values.json` records `""`. A hand-run build may still + pass `--set productdomain=` for an API that already has its domain. +- `rebrand.mjs` no longer requires it. Empty, it brands the reserved + placeholder `.example.com` (RFC 2606 — never someone else's + domain) where the domain goes, so setting it later is replacing one + string; the product README and `ai/context/operations.md` say so. +- `testing/fixtures/acme.json` carries no domain, so the leak gate and the + offline bootstrap exercise exactly what a console build supplies; + `testing/rebrand.test.sh` pins the placeholder for an absent and an empty + domain, and for the fixture's own slug, whose placeholder + `acme-hono-api.example.com` ends in the baseline's `hono-api.example.com` + (three passes, unchanged); `baseline.yml`'s blueprint read sets no domain. + +Nothing that needs a domain was removed — it waits for one. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green (rebrand: the three new checks among them; with the previous + `rebrand.mjs` all three fail, restored they pass); `gen-component-docs.py + --check` green (2 components). +- At v2.58.11 (the blueprint job's pin): `orun new --status` with no + `productdomain` reads the document (`01-product` pending, 44 files); + `testing/leak.test.sh` 44 files derived, 44 read; `testing/placement.test.sh` + 44 files placed, both landings, the API's own plan deploys `api` to stage + and prod. +- The offline bootstrap of the fixture leaves `.rebrand/values.json` + `productdomain` empty and `BASE_DOMAIN: acme-hono-api.example.com` in all + three environments of the API's `intent.yaml` (and the same string in its + README and `operations.md`); no line names `hono-api.example.com` on its own. +- `orun task check HA-7` complete. + ## Verified (HA4) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` diff --git a/specs/epics/hono-api/README.md b/specs/epics/hono-api/README.md index 4f0ceb9..50efacf 100644 --- a/specs/epics/hono-api/README.md +++ b/specs/epics/hono-api/README.md @@ -8,15 +8,15 @@ The upstream code stays the code. The port adds the Worker's config (`wrangler.j | Field | Value | |-------|-------| -| Status | ✅ HA0–HA3 shipped (#1–#4), tagged `baseline-v1`; HA4 (the cirrus standard, HA-5 #5 and HA-6 #6) tagged `baseline-v2`. Not yet proven by a live bootstrap (risk HA-F) | -| Cluster | **HA** (HA0–HA4) | +| Status | ✅ HA0–HA5 shipped (#1–#7): HA3 tagged `baseline-v1`; HA4 (the cirrus standard, HA-5 #5 and HA-6 #6) tagged `baseline-v2`; HA5 (the domain is set later, HA-7 #7) tagged `baseline-v3`. Not yet proven by a live bootstrap (risk HA-F) | +| Cluster | **HA** (HA0–HA5) | | Owner(s) | `apps/api` (the Worker) · `tests/api` (the in-process request tests) | | Builds on | `cirrus-baseline` conventions (intent, components, `checks.yml` gate, gated `ci.yml`) and the `cloudflare-worker-turbo` composition its workers deploy with — no bounded context of the fleet is needed | | Upstream | [vercel/examples `framework-boilerplates/hono`](https://github.com/vercel/examples/tree/main/framework-boilerplates/hono) | | Changes | Adds the Worker config, the monorepo wrapper, tests and the deploy contract; the template's app code is untouched but for the welcome line's link | | Decisions locked | (1) A plain Worker (`cloudflare-worker-turbo`), not Pages Functions and not an adapter: Hono's default export is already a Workers module handler. (2) `wrangler.jsonc` is committed, not rendered: the Worker binds nothing, so there is nothing to wire. (3) Per-environment deploys through wrangler `env` sections (`--env stage` / `--env prod`), naming `hono-api-api-{stage,prod}`. (4) No infra root. | | Gate | HA1 is the first user-visible rung (the API serves from a Worker). | -| Shipped as | `baseline-v1` ([#4](https://github.com/sourceplane/hono-api/pull/4)), then `baseline-v2` (HA4: [#5](https://github.com/sourceplane/hono-api/pull/5), [#6](https://github.com/sourceplane/hono-api/pull/6)); proven offline (Baseline CI), deploy gated until a workspace is linked | +| Shipped as | `baseline-v3` ([#7](https://github.com/sourceplane/hono-api/pull/7), HA5: no domain asked), `baseline-v2` (HA4: [#5](https://github.com/sourceplane/hono-api/pull/5), [#6](https://github.com/sourceplane/hono-api/pull/6)), `baseline-v1` ([#4](https://github.com/sourceplane/hono-api/pull/4)); proven offline (Baseline CI), deploy gated until a workspace is linked | ## Read order @@ -34,3 +34,4 @@ The upstream code stays the code. The port adds the Worker's config (`wrangler.j | HA2 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it | | HA3 — a baseline | card, build document, rename, bootstrap tooling, tests | a new API goes from nothing to live in one landing; Baseline CI green | | HA4 — 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 | +| HA5 — the domain is set later | the console asks for no domain; an empty `productdomain` brands the placeholder `.example.com` for an owner to replace | Baseline CI green on a fixture with no domain | diff --git a/specs/epics/hono-api/epic.yaml b/specs/epics/hono-api/epic.yaml index d40067a..633d300 100644 --- a/specs/epics/hono-api/epic.yaml +++ b/specs/epics/hono-api/epic.yaml @@ -40,3 +40,9 @@ spec: - "every milestone's status row agrees with the tags" - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" tasks: [HA-5, HA-6] + - name: "HA5 — the domain is set later" + exitCriteria: + - "the console card asks for no domain: an API goes live on workers.dev, and productdomain is an optional build input that defaults to empty" + - "an API built without a domain is branded with the reserved placeholder .example.com wherever the domain goes (BASE_DOMAIN), and its README says how an owner sets the real one" + - "Baseline CI places, leak-checks and plans an API built with no domain" + tasks: [HA-7] diff --git a/specs/epics/hono-api/implementation-plan.md b/specs/epics/hono-api/implementation-plan.md index 4759e43..0c6d1ee 100644 --- a/specs/epics/hono-api/implementation-plan.md +++ b/specs/epics/hono-api/implementation-plan.md @@ -77,6 +77,15 @@ itself changing. - the docs check is green in Baseline CI - this file, the status file and `epic.yaml` agree +## HA5 — the domain is set later (HA-7) ✅ + +**Done when** the console card asks for no domain; `productdomain` is an +optional build input, empty by default; an API built without one is branded +with the reserved placeholder `.example.com` where the domain goes +(`BASE_DOMAIN` in `intent.yaml`) and its README says how an owner sets the +real one; Baseline CI places, leak-checks and plans an API built with no +domain. Shipped in `baseline-v3`. + ## After HA3 (outside this repository) 1. Cut `baseline-v1` with `tag.yml` from the merged `main`. diff --git a/tasks/HA-7.TaskContract.yaml b/tasks/HA-7.TaskContract.yaml new file mode 100644 index 0000000..805c925 --- /dev/null +++ b/tasks/HA-7.TaskContract.yaml @@ -0,0 +1,30 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: HA-7 + title: "The domain is set later" +spec: + goal: "The console no longer asks for the API's domain. An API goes live on workers.dev; productdomain is an optional build input (default empty), the rebrand writes the reserved placeholder .example.com where the domain goes (BASE_DOMAIN in intent.yaml), and the API's README says how an owner replaces it once a domain is attached" + affects: + - blueprint.yaml + - repo-blueprint.yaml + - tooling/rebrand/rebrand.mjs + - testing/rebrand.test.sh + - testing/fixtures/acme.json + - .github/workflows/baseline.yml + - .baseline/product/README.md + - BOOTSTRAP.md + - README.md + - docs/phases/README.md + - ai/context/operations.md + - ai/context/current.md + - ai/context/decisions.md + - specs/** + - tasks/** + doneWhen: + - blueprint.yaml declares no productdomain input, and repo-blueprint.yaml's productdomain is optional with an empty default + - "rebrand.mjs no longer requires productdomain and brands .example.com when it is empty (testing/rebrand.test.sh)" + - testing/fixtures/acme.json carries no domain, so the leak gate and the offline bootstrap exercise what a console build supplies + - the contract tests, the docs check, the leak gate and the offline bootstrap are green + gates: + - checks diff --git a/testing/fixtures/acme.json b/testing/fixtures/acme.json index b3163b2..b5d7779 100644 --- a/testing/fixtures/acme.json +++ b/testing/fixtures/acme.json @@ -6,16 +6,16 @@ "AWKWARD rather than tidy — an API name with an apostrophe and an ampersand", "(both legal in the card's pattern, both special in TypeScript strings,", "shell words and JSON), a hyphenated repo slug that CONTAINS the word", - "`hono` and ends in `api`, an owner other than the baseline's, and a", - "multi-label domain — because a fixture that only uses values the templates", - "were written against proves the templates work on the values they were", - "written against.", + "`hono` and ends in `api`, an owner other than the baseline's, and NO", + "domain — a console build asks for none, so the placeholder", + ".example.com is what an API is born with — because a fixture", + "that only uses values the templates were written against proves the", + "templates work on the values they were written against.", "Every key here is an input repo-blueprint.yaml declares. A key it does not", "declare is a fixture that has drifted, and orun refuses it." ], "reponame": "acme-hono-api", "productname": "Sam's Tools & Things", - "productdomain": "api.acme.dev", "githuborg": "acme-inc", "subdomain": "acme", "orunWorkspace": "ws_0000000000000000000000000000000f", diff --git a/testing/rebrand.test.sh b/testing/rebrand.test.sh index a907a28..ce98bc4 100755 --- a/testing/rebrand.test.sh +++ b/testing/rebrand.test.sh @@ -84,6 +84,14 @@ check "an environment URL in the intent" \ check "the placeholder domain is the product's domain, not a renamed slug" \ "$acme" intent.yaml ' BASE_DOMAIN: hono-api.example.com' \ ' BASE_DOMAIN: acme.dev' +check "no domain given: the reserved placeholder, for an owner to replace later" \ + '{"reponame":"acme-api","productname":"Acme API","githuborg":"acme-inc","subdomain":"acme"}' \ + intent.yaml ' BASE_DOMAIN: hono-api.example.com' \ + ' BASE_DOMAIN: acme-api.example.com' +check "an empty domain is no domain" \ + '{"reponame":"acme-api","productname":"Acme API","productdomain":""}' \ + intent.yaml ' BASE_DOMAIN: hono-api.example.com' \ + ' BASE_DOMAIN: acme-api.example.com' check "the repo slug" \ "$acme" package.json ' "name": "hono-api",' \ ' "name": "acme-api",' @@ -124,6 +132,10 @@ check "a repo slug ending in the baseline's slug survives three passes" \ check "…and its Worker name in the smoke URL" \ "$suffixed" apps/api/component.yaml 'x: https://hono-api-api-${ORUN_ENVIRONMENT}.your-workers-subdomain.workers.dev' \ 'x: https://acme-hono-api-api-${ORUN_ENVIRONMENT}.acme.workers.dev' 3 +check "…and, with no domain, its placeholder (which ends in the baseline's domain)" \ + '{"reponame":"acme-hono-api","productname":"Acme","githuborg":"acme-inc","subdomain":"acme"}' \ + intent.yaml ' BASE_DOMAIN: hono-api.example.com' \ + ' BASE_DOMAIN: acme-hono-api.example.com' 3 # --verify runs in every phase. Without the product's values it cannot tell # the product's own identity from a leftover; with them it can. A real diff --git a/tooling/rebrand/rebrand.mjs b/tooling/rebrand/rebrand.mjs index 49017bc..38a5045 100755 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -24,7 +24,7 @@ // { // "reponame": "acme-api", // required — repo slug // "productname": "Acme API", // required — the API's display name -// "productdomain": "acme.dev", // required — the product domain +// "productdomain": "acme.dev", // optional — default .example.com (set later) // "githuborg": "acme-inc", // owner of the product repo (source link) // "brandSlug": "acme", // default: reponame — worker name prefix // "subdomain": "acme", // default: your-workers-subdomain @@ -65,7 +65,7 @@ if (!verifyOnly && !valuesPath) { } if (valuesPath) { values = JSON.parse(fs.readFileSync(valuesPath, "utf8")); - for (const required of ["reponame", "productname", "productdomain"]) { + for (const required of ["reponame", "productname"]) { if (typeof values[required] !== "string" || values[required].length === 0) { console.error(`rebrand: values file is missing required field "${required}"`); process.exit(2); @@ -128,7 +128,11 @@ const rx = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // All fields are unused under --verify; the fallbacks keep derivation total. const reponame = values.reponame ?? ""; const productname = values.productname ?? ""; -const productdomain = values.productdomain ?? ""; +// The domain is NOT ASKED at bootstrap: an API goes live on workers.dev and an +// owner sets a domain later. Until then the reserved placeholder +// `.example.com` (RFC 2606 — it can never be someone else's) stands +// wherever the domain goes, so setting it is replacing one string. +const productdomain = (values.productdomain ?? "").trim() || (reponame ? `${reponame}.example.com` : ""); const githuborg = (values.githuborg ?? "").trim() || baseline.githubOwner; const brandSlug = (values.brandSlug ?? "").trim() || reponame; const subdomain = (values.subdomain ?? "").trim() || "your-workers-subdomain";