From b77c67324b0ada6f908fd13013d78840f2681141 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:29:03 +0000 Subject: [PATCH 1/2] =?UTF-8?q?TU6:=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 all six components from what they declare (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 TU5 (shipped, tagged baseline-v2; baseline-v1 is TU4), label the TU1–TU3 Verified section, and record TU6 (TU-7). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D8AmgTwmnp4M8mgmnS9aha --- .github/workflows/baseline.yml | 6 + ai/context/current.md | 40 ++ ai/context/decisions.md | 20 + ai/context/open-risks.md | 16 + apps/web/docs/architecture.md | 27 + apps/web/docs/overview.md | 21 + apps/web/docs/runbook.md | 40 ++ infra/db-migrate/docs/architecture.md | 16 + infra/db-migrate/docs/overview.md | 20 + infra/db-migrate/docs/runbook.md | 19 + .../cloudflare-d1/docs/architecture.md | 29 + .../terraform/cloudflare-d1/docs/overview.md | 20 + infra/terraform/cloudflare-d1/docs/runbook.md | 20 + kiox.lock | 11 - kiox.yaml | 6 - packages/db/docs/architecture.md | 11 + packages/db/docs/overview.md | 20 + packages/db/docs/runbook.md | 25 + repo-blueprint.yaml | 12 +- specs/epics/README.md | 2 +- .../turso-starter/IMPLEMENTATION-STATUS.md | 49 +- specs/epics/turso-starter/README.md | 7 +- specs/epics/turso-starter/epic.yaml | 7 + .../turso-starter/implementation-plan.md | 30 +- tasks/TU-7.TaskContract.yaml | 31 + testing/phases.test.sh | 2 +- tests/db/docs/architecture.md | 7 + tests/db/docs/overview.md | 18 + tests/db/docs/runbook.md | 26 + tests/web/docs/architecture.md | 8 + tests/web/docs/overview.md | 18 + tests/web/docs/runbook.md | 26 + tooling/catalog/gen-component-docs.py | 534 ++++++++++++++++++ tooling/rebrand/rebrand.mjs | 1 - 34 files changed, 1106 insertions(+), 39 deletions(-) create mode 100644 ai/context/current.md create mode 100644 ai/context/decisions.md create mode 100644 ai/context/open-risks.md create mode 100644 apps/web/docs/architecture.md create mode 100644 apps/web/docs/overview.md create mode 100644 apps/web/docs/runbook.md create mode 100644 infra/db-migrate/docs/architecture.md create mode 100644 infra/db-migrate/docs/overview.md create mode 100644 infra/db-migrate/docs/runbook.md create mode 100644 infra/terraform/cloudflare-d1/docs/architecture.md create mode 100644 infra/terraform/cloudflare-d1/docs/overview.md create mode 100644 infra/terraform/cloudflare-d1/docs/runbook.md delete mode 100644 kiox.lock delete mode 100644 kiox.yaml create mode 100644 packages/db/docs/architecture.md create mode 100644 packages/db/docs/overview.md create mode 100644 packages/db/docs/runbook.md create mode 100644 tasks/TU-7.TaskContract.yaml create mode 100644 tests/db/docs/architecture.md create mode 100644 tests/db/docs/overview.md create mode 100644 tests/db/docs/runbook.md create mode 100644 tests/web/docs/architecture.md create mode 100644 tests/web/docs/overview.md create mode 100644 tests/web/docs/runbook.md create mode 100644 tooling/catalog/gen-component-docs.py diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index ab15ef7..e235fe9 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -51,6 +51,12 @@ jobs: echo "── $t" bash "testing/$t.test.sh" done + # Every component's docs/{overview,architecture,runbook}.md is generated + # from what the component declares (its manifest, Worker config, + # Terraform, migrations, package scripts). A pull request that changes + # one of those facts without regenerating the pages fails here. + - name: Component docs match their manifests + run: python3 tooling/catalog/gen-component-docs.py --check # Tier 1. THE BLUEPRINT, READ AND PLACED BY THE BINARY A BOOTSTRAP RUNS. # diff --git a/ai/context/current.md b/ai/context/current.md new file mode 100644 index 0000000..baa2c35 --- /dev/null +++ b/ai/context/current.md @@ -0,0 +1,40 @@ +# turso-starter — where this repository stands + +The entry page for anyone (or any agent) picking this repository up. It is +this repository's own state and does not ship to a product built from it; +the two pages that do are [operations.md](operations.md) and +[deployment.md](deployment.md). + +## What it is + +Vercel's Next.js + Turso starter — a todo list — on Cloudflare Workers + +Static Assets, with the todos in a D1 database Terraform provisions and a +migration creates, packaged as an Orun baseline: `orun new --blueprint +repo-blueprint.yaml` builds a new product in its own repository and takes it +to live on stage and prod in one landing (`01-product`: cloudflare-d1 → +db-migrate → web per environment), then records what went live (`02-docs`). + +## Release + +| | | +|---|---| +| Latest tag | `baseline-v2` (TU5, one landing); `baseline-v1` is TU4's four-phase build | +| On `main` since | TU6 — 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, the migration lane against a stand-in D1 API and a todo round-tripped through the built Worker included; a live bootstrap from a tag is still to come (risk TU-E) | + +## Where to read + +| Question | Page | +|---|---| +| What shipped, and every departure from upstream | `specs/epics/turso-starter/IMPLEMENTATION-STATUS.md` | +| Why it is built this way | [decisions.md](decisions.md), then `specs/epics/turso-starter/design.md` | +| What could still go wrong | [open-risks.md](open-risks.md), then `specs/epics/turso-starter/risks-and-open-questions.md` | +| How to instantiate it | `BOOTSTRAP.md`, `docs/phases/` | +| What each component is | `/docs/` beside each `component.yaml` — `apps/web`, `packages/db`, `infra/db-migrate`, `infra/terraform/cloudflare-d1`, `tests/{web,db}` (generated; `python3 tooling/catalog/gen-component-docs.py`) | + +## Next + +1. Bootstrap one product from a tag against a workspace whose Cloudflare + token can mint D1 Edit as well as Workers Scripts (TU-F), and record its + timings (closes TU-E). +2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin TU6. diff --git a/ai/context/decisions.md b/ai/context/decisions.md new file mode 100644 index 0000000..89f07da --- /dev/null +++ b/ai/context/decisions.md @@ -0,0 +1,20 @@ +# turso-starter — 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 | `lib/turso.ts` keeps the libSQL client's `execute()` shape over the `DB` D1 binding; the template's SQL runs as written | D1 is SQLite, and so are the template's statements: one file changes | `specs/epics/turso-starter/README.md`, design.md | +| 2 | ~~The table is created on first use, as upstream does~~ — superseded by #3 in TU5 | — | risk TU-A | +| 3 | The schema is a migration (`packages/db`'s `010_todos`), applied by `infra/db-migrate` between the D1 apply and the Worker's deploy; the page never writes DDL | The template said to remove create-on-first-use in production; the convergence's order then includes the schema | risk TU-A, design.md §6 | +| 4 | `app/page.tsx` is `force-dynamic` | The Worker serves pre-rendered pages from a read-only cache, so ISR would never show a new todo | risk TU-D | +| 5 | `wrangler.jsonc` is rendered from the D1 root's wiring document per environment, and the fixture render is committed; dev renders the fixture | The deploy lane checks the config exists before the build; no root applies in dev | risks TU-G, TU-H | +| 6 | One landing (`01-product`) then the record (`02-docs`), replacing TU4's four phases; edges `mode: enforced` on main, advisory on a pull request | The plan, not a landing boundary, orders the database, its schema and the Worker (cirrus-baseline since baseline-v22) | design.md §6 | +| 7 | The D1 apply and the migrations use their own `d1-edit` key (`CLOUDFLARE_D1_TOKEN`) | The `workers-deploy` token cannot touch D1 | design.md §6, risk TU-F | +| 8 | The migrations package is named `@saas/db` | stack-tectonic's db-migrate composition builds `--filter=@saas/db` | risk TU-J | +| 9 | The smoke requires `data-todos="N"` on `/` | Only a Worker that read the migrated table renders it; read-only, so no deploy writes a todo | IMPLEMENTATION-STATUS (TU5) | +| 10 | stack-tectonic 0.19.0, not 0.20.0 | 0.20.0 links the install out of the job's tree, which Next 16's Turbopack refuses | `intent.yaml` (the pin's comment) | +| 11 | orun is pinned only where it runs (the `orun-action` `version:` in each workflow); no kiox | `kiox.yaml` pinned a version (v2.15.0) nothing ran | IMPLEMENTATION-STATUS (TU6) | +| 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph, bindings and migrations 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..1b79737 --- /dev/null +++ b/ai/context/open-risks.md @@ -0,0 +1,16 @@ +# turso-starter — 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/turso-starter/risks-and-open-questions.md`; this page lists only +what is still live, so it should be short. + +| ID | Risk | State | What closes it | +|---|---|---|---| +| TU-E | Not yet proven live: the `d1-edit` mint, the Terraform apply and its wiring publish, the migrations against the real D1 API, the deploy and the workers.dev probes | OPEN | One bootstrap from a tag against a workspace whose Cloudflare token can mint D1 Edit | + +Accepted, and worth knowing before you change them: TU-B (D1's limits), +TU-F (a Cloudflare token without D1 Write stops the bootstrap before the +landing), TU-I (the bootstrap floor plans every edge enforced), TU-J (the +migrations package is named `@saas/db`), TU-K (a custom domain is the +owner's step). diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md new file mode 100644 index 0000000..ec34677 --- /dev/null +++ b/apps/web/docs/architecture.md @@ -0,0 +1,27 @@ +# web — architecture + +Built by the turbo pipeline from `apps/web` and deployed with wrangler. + +| | | +| ------------------- | ----------------------------------------------- | +| Worker config | `apps/web/wrangler.template.jsonc` | +| Entry | `.open-next/worker.js` | +| Compatibility date | `2026-10-01` | +| Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` | + +## Bindings + +| Binding | Kind | Source | +| -------- | ------------- | ------------------------------------- | +| `DB` | D1 database | `d1_database_id` from `cloudflare-d1` | +| `ASSETS` | Static assets | `.open-next/assets` | + +Identifiers marked _from_ a component are filled in at deploy time from +that component's published outputs for the environment being deployed. + +## Wiring + +Resolved at deploy time from secrets the infrastructure lanes publish (names only): + +- `WIRING_CLOUDFLARE_D1_PROD` +- `WIRING_CLOUDFLARE_D1_STAGE` diff --git a/apps/web/docs/overview.md b/apps/web/docs/overview.md new file mode 100644 index 0000000..998ad7b --- /dev/null +++ b/apps/web/docs/overview.md @@ -0,0 +1,21 @@ +# web + +The todo list (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) + +A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane. + +| | | +| ------------ | ------------------------------------------------------------------------------------------------------------------ | +| Type | `cloudflare-workers-assets-turbo` | +| Source | `apps/web` | +| Package | `@app/web` | +| Environments | `dev`: `verify` · `stage`: `verify`, `deploy` on a push to `main` · `prod`: `verify`, `deploy` on a push to `main` | + +## Depends on + +- **cloudflare-d1** — Provisions the Cloudflare D1 todos database for stage and prod +- **db-migrate** — Applies the todos schema (packages/db's migrations) to the stage and prod Cloudflare D1 databases + +## Depended on by + +- (none) diff --git a/apps/web/docs/runbook.md b/apps/web/docs/runbook.md new file mode 100644 index 0000000..ae236d9 --- /dev/null +++ b/apps/web/docs/runbook.md @@ -0,0 +1,40 @@ +# web — runbook + +## How it runs + +Pull requests verify it; a merge to `main` deploys it to `stage`, `prod`. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @app/web dev +pnpm --filter @app/web build +pnpm --filter @app/web typecheck +pnpm --filter @app/web lint +pnpm --filter @app/web preview +``` + +## Verify + +After a deploy the lane runs this smoke against the environment it +deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL: + +```bash +html=$(curl -sfL "${DEPLOYED_URL}/") && echo "${html}" | grep -Eq 'data-todos="[0-9]+"' +``` + +## 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/infra/db-migrate/docs/architecture.md b/infra/db-migrate/docs/architecture.md new file mode 100644 index 0000000..2a80c0f --- /dev/null +++ b/infra/db-migrate/docs/architecture.md @@ -0,0 +1,16 @@ +# db-migrate — architecture + +Applies the migrations under `packages/db/src/migrations` 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. + +## Migrations + +- `000_control` +- `010_todos` + +## Resolved at run time (names only) + +- `CLOUDFLARE_ACCOUNT_ID` +- `CLOUDFLARE_API_TOKEN` +- `WIRING_CLOUDFLARE_D1` diff --git a/infra/db-migrate/docs/overview.md b/infra/db-migrate/docs/overview.md new file mode 100644 index 0000000..e7cc80d --- /dev/null +++ b/infra/db-migrate/docs/overview.md @@ -0,0 +1,20 @@ +# db-migrate + +Applies the todos schema (packages/db's migrations) to the stage and prod Cloudflare D1 databases + +Applies this repository's ordered database migrations per environment: plan on pull requests, apply on merge to `main`. + +| | | +| ------------ | ------------------------------------------------------------------------------------------ | +| Type | `db-migrate` | +| Source | `infra/db-migrate` | +| Environments | `stage`: `plan`, `apply` on a push to `main` · `prod`: `plan`, `apply` on a push to `main` | + +## Depends on + +- **db** — The todos schema as migrations, and the runner that applies them to D1 (built by the db-migrate component before it plans or applies) +- **cloudflare-d1** — Provisions the Cloudflare D1 todos database for stage and prod + +## Depended on by + +- **web** — The todo list (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) diff --git a/infra/db-migrate/docs/runbook.md b/infra/db-migrate/docs/runbook.md new file mode 100644 index 0000000..04a50d1 --- /dev/null +++ b/infra/db-migrate/docs/runbook.md @@ -0,0 +1,19 @@ +# db-migrate — runbook + +## How it runs + +Pull requests plan it; a merge to `main` applies 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. + +## 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 + +- **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. diff --git a/infra/terraform/cloudflare-d1/docs/architecture.md b/infra/terraform/cloudflare-d1/docs/architecture.md new file mode 100644 index 0000000..230a46d --- /dev/null +++ b/infra/terraform/cloudflare-d1/docs/architecture.md @@ -0,0 +1,29 @@ +# cloudflare-d1 — architecture + +A `terraform` root at `infra/terraform/cloudflare-d1/terraform`. + +- **State** lives in the Orun Cloud HTTP state backend — no local state and + no state bucket to manage. +- **Credentials are brokered per run** from the workspace's provider + connections and resolved by name; none is stored in this repository. +- **Adoption** (`adopt.tf`): when state is empty but the resource already + exists, plan-time import adopts it instead of failing. + +## Resources + +- `cloudflare_d1_database.platform` + +## Published outputs + +Written as job-output secrets on each environment after an apply; deploy +lanes downstream resolve them by name. + +| Secret | Terraform output | +| ---------------------- | ---------------- | +| `WIRING_CLOUDFLARE_D1` | `wiring` | + +## Resolved at run time (names only) + +- `CLOUDFLARE_ACCOUNT_ID` +- `CLOUDFLARE_API_TOKEN` +- `TF_VAR_cloudflare_account_id` diff --git a/infra/terraform/cloudflare-d1/docs/overview.md b/infra/terraform/cloudflare-d1/docs/overview.md new file mode 100644 index 0000000..f95158f --- /dev/null +++ b/infra/terraform/cloudflare-d1/docs/overview.md @@ -0,0 +1,20 @@ +# cloudflare-d1 + +Provisions the Cloudflare D1 todos database for stage and prod + +Terraform-managed infrastructure, planned and applied per environment by its CI lane. + +| | | +| ------------ | ---------------------------------------------------------------------------------------------------- | +| Type | `terraform` | +| Source | `infra/terraform/cloudflare-d1` | +| Environments | `stage`: `plan-only`, `apply` on a push to `main` · `prod`: `plan-only`, `apply` on a push to `main` | + +## Depends on + +- (none) + +## Depended on by + +- **db-migrate** — Applies the todos schema (packages/db's migrations) to the stage and prod Cloudflare D1 databases +- **web** — The todo list (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) diff --git a/infra/terraform/cloudflare-d1/docs/runbook.md b/infra/terraform/cloudflare-d1/docs/runbook.md new file mode 100644 index 0000000..6ce343b --- /dev/null +++ b/infra/terraform/cloudflare-d1/docs/runbook.md @@ -0,0 +1,20 @@ +# cloudflare-d1 — runbook + +## How it runs + +Pull requests plan it; a merge to `main` applies 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. + +## 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 + +- **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. 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/packages/db/docs/architecture.md b/packages/db/docs/architecture.md new file mode 100644 index 0000000..3f9b079 --- /dev/null +++ b/packages/db/docs/architecture.md @@ -0,0 +1,11 @@ +# db — architecture + +A workspace package at `packages/db`, consumed by the components that depend +on it. It has no deployed surface of its own. + +## Exports + +- `.` +- `./manifest` +- `./runner` +- `./types` diff --git a/packages/db/docs/overview.md b/packages/db/docs/overview.md new file mode 100644 index 0000000..f521f34 --- /dev/null +++ b/packages/db/docs/overview.md @@ -0,0 +1,20 @@ +# db + +The todos schema as migrations, and the runner that applies them to D1 (built by the db-migrate component before it plans or applies) + +A workspace package built by the turbo pipeline. It deploys nothing itself: its lane type-checks, lints, tests and builds it. + +| | | +| ------------ | -------------------- | +| Type | `turbo-package` | +| Source | `packages/db` | +| Package | `@saas/db` | +| Environments | `dev`: `quick-check` | + +## Depends on + +- (none) + +## Depended on by + +- **db-migrate** — Applies the todos schema (packages/db's migrations) to the stage and prod Cloudflare D1 databases diff --git a/packages/db/docs/runbook.md b/packages/db/docs/runbook.md new file mode 100644 index 0000000..3fa7445 --- /dev/null +++ b/packages/db/docs/runbook.md @@ -0,0 +1,25 @@ +# db — 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 @saas/db build +pnpm --filter @saas/db typecheck +pnpm --filter @saas/db 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/repo-blueprint.yaml b/repo-blueprint.yaml index 546b125..5c7076c 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -185,16 +185,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 @@ -441,7 +431,7 @@ phases: await: "One convergence is deploying the product, per environment: the D1 database first, then its migrations, then the site built with its id — stage and prod side by side. The Next.js build is the long pole; nothing is stuck." done: "{{ .inputs.reponame }} is live on stage and prod — {{ .meta.files }} files on main, branded as {{ .inputs.productname }}, the list reading its database. That took {{ .meta.elapsed }}." failed: "The product did not come up. The failing lane above names the component — the D1 apply, the migrations, or the site's build, deploy or smoke — and a provider error is in its log; whatever deployed is still there." - modules: [ai-deployment, ai-operations, cloudflare-d1, db, db-migrate, db-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-migrations, tooling-tsconfig, tooling-wire, vscode, web, web-tests] + modules: [ai-deployment, ai-operations, cloudflare-d1, db, db-migrate, db-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-migrations, tooling-tsconfig, tooling-wire, vscode, web, web-tests] # THE PLATFORM MUST BE ABLE TO SEE THE REPOSITORY BEFORE IT EXISTS. Every # phase lands a pull request that files under its task, and the platform # learns of a PR only through the GitHub App installation on the account diff --git a/specs/epics/README.md b/specs/epics/README.md index 32086af..a31e74b 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 | |------|---------|--------|------------| -| [`turso-starter/`](./turso-starter/) | **TU** | 🟡 TU5 in review | Vercel's Next.js + Turso starter, equivalent in code and function, on Cloudflare Workers with the todos in D1 — and an Orun baseline that instantiates it in one landing, its database applied and migrated before the Worker deploys (TU4, rebuilt in TU5) | +| [`turso-starter/`](./turso-starter/) | **TU** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's Next.js + Turso starter, equivalent in code and function, on Cloudflare Workers with the todos in D1 — and an Orun baseline that instantiates it in one landing, its database applied and migrated before the Worker deploys (TU4, rebuilt in TU5) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/turso-starter/IMPLEMENTATION-STATUS.md b/specs/epics/turso-starter/IMPLEMENTATION-STATUS.md index 0ba8bb5..318c11a 100644 --- a/specs/epics/turso-starter/IMPLEMENTATION-STATUS.md +++ b/specs/epics/turso-starter/IMPLEMENTATION-STATUS.md @@ -9,8 +9,9 @@ the code departed from `design.md` or from the upstream template. | TU1 — the todos on D1 | ✅ Shipped | [#2](https://github.com/sourceplane/turso-starter/pull/2) | | TU2 — the D1 database from Terraform | ✅ Shipped (validated; apply gated on a linked workspace) | [#3](https://github.com/sourceplane/turso-starter/pull/3) | | TU3 — ready to instantiate | ✅ Shipped | [#4](https://github.com/sourceplane/turso-starter/pull/4) | -| TU4 — a baseline | ✅ Shipped (four phases; rebuilt by TU5) | [#5](https://github.com/sourceplane/turso-starter/pull/5) | -| TU5 — a baseline, in one landing | 🟡 In review (offline-proven; no live bootstrap yet, risk TU-E) | this PR (TU-6), to be tagged `baseline-v1` | +| TU4 — a baseline | ✅ Shipped (four phases; rebuilt by TU5) | [#5](https://github.com/sourceplane/turso-starter/pull/5) (TU-5), tagged `baseline-v1` | +| TU5 — a baseline, in one landing | ✅ Shipped (offline-proven; no live bootstrap yet, risk TU-E) | [#6](https://github.com/sourceplane/turso-starter/pull/6) (TU-6), tagged `baseline-v2` | +| TU6 — the cirrus standard | ✅ Shipped | TU-7 — on `main` after `baseline-v2`, not yet tagged | ## Departures from the upstream template @@ -75,7 +76,7 @@ The template floated `next: latest` with React 18 and `eslint-config-next 14`. | `tooling/wire/render.mjs` | copied the template's header comment | writes a GENERATED banner | the committed render must say it is one | | e2e | built and dry-deployed the stage lane (no `verify-app-structure`) | + `verify-app-structure`; + the db-migrate lane's install, build, offline plan and apply against a stand-in D1 REST API over real SQLite; + the smoke refusing a page with no schema | the tier must run what the lanes run | -## Verified +## Verified (TU1–TU3) - Local: `pnpm run wire:fixture`, `pnpm typecheck`, `pnpm lint`, `pnpm test` (3 tests), `pnpm build` green; `wrangler dev` with a local D1: `/` 200 @@ -141,6 +142,48 @@ See the pull request for the run log. In short, under orun 2.79.0, v2.78.4 — build) green; `terraform validate` green on `infra/terraform/cloudflare-d1`. - Not verified: a live bootstrap against a workspace (risk TU-E). +## The cirrus standard (TU6) + +Nothing about the product changed. What changed is the baseline around it: + +| What | Before | After | Why | +|---|---|---|---| +| orun pin | `kiox.yaml` (v2.15.0) + `kiox.lock`, shipped to every product | 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` and the rebrand's skip list follow) | a product is placed with 106 files: 90 − 2 kiox + 18 docs pages | +| component docs | none | `docs/overview.md`, `architecture.md`, `runbook.md` beside each of the six `component.yaml` (`apps/web`, `packages/db`, `infra/db-migrate`, `infra/terraform/cloudflare-d1`, `tests/{web,db}`) | 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, the 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 | TU5 "in review … to be tagged `baseline-v1`"; an unlabeled Verified section ("the table created on first render", 3 tests) | TU4 `baseline-v1`, TU5 `baseline-v2`; the section is labeled TU1–TU3 | the tags existed; the documents had not caught up | + +## Verified (TU6) + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer,wire}.test.sh` + green; `gen-component-docs.py --check` green (6 components, 18 pages). +- `orun new --status` (v2.58.11, the bootstrap floor): `01-product` 106 + files, `02-docs` hook-only. +- `testing/leak.test.sh` (v2.58.11): 106 files derived (90 − 2 kiox + 18 + docs pages); ai/context still exactly the two declared pages; 100 shipped + sources name no factory path. +- `testing/placement.test.sh` (v2.78.4, as Baseline CI runs it): 106 files + placed, both landings, branded, re-tenanted, record rendered; the + product's own plan for the 01-product merge: `cloudflare-d1` (level 0) → + `db-migrate` (level 1) → `web` (level 2) on stage and prod side by side; + on a pull request nothing waits; the 02-docs merge plans 0 jobs; + `--resume` changes nothing. +- `pnpm install --frozen-lockfile`, `wire:fixture` + `git diff + --exit-code`, `typecheck`, `lint`, `test` (21 tests: 7 in `tests/web`, 14 + in `tests/db`), `build` green. +- `testing/e2e.test.sh` (v2.78.4): the 01-product landing passes the Checks + sequence; the stage web lane's `verify-app-structure`, `build-app` (the + stage document's database id), `verify-build-output` and + `deploy-dry-run` pass in the staged job tree; the stage db-migrate lane + plans offline, applies both migrations to the stand-in D1 API and applies + nothing the second time; under `wrangler dev` the page without a schema + is refused by the smoke, and after `db:migrate:local` the smoke passes and + a todo is added, listed and removed through the page's own server + actions. +- `orun task check TU-7` complete. + ## Versions | Package | Version | Why | diff --git a/specs/epics/turso-starter/README.md b/specs/epics/turso-starter/README.md index 3e2463e..6f8b86b 100644 --- a/specs/epics/turso-starter/README.md +++ b/specs/epics/turso-starter/README.md @@ -8,15 +8,15 @@ The port keeps the page, the form, the server actions and the todo list. It adds | Field | Value | |-------|-------| -| Status | 🟡 TU0–TU4 shipped (#1–#5); TU5 — a baseline, in one landing — in review; D1 apply, migrations and live deploy proven only by a live bootstrap | -| Cluster | **TU** (TU0–TU5) | +| Status | ✅ TU0–TU5 shipped (#1–#6): TU4 tagged `baseline-v1`, TU5 tagged `baseline-v2`; TU6 (the cirrus standard, TU-7) on `main`, not yet tagged. D1 apply, migrations and live deploy proven only by a live bootstrap (risk TU-E) | +| Cluster | **TU** (TU0–TU6) | | Owner(s) | `apps/web` (the page, the actions, `lib/turso.ts`) · `tests/web` · `infra/terraform/cloudflare-d1` · `packages/db` + `infra/db-migrate` (the schema, TU5) · `tests/db` | | Builds on | `cirrus-baseline`: its `cloudflare-d1` root and the `@@wiring(...)@@` deploy-time render; the `kv-redis-starter` port's binding shape | | Upstream | [vercel/next.js `examples/with-turso`](https://github.com/vercel/next.js/tree/canary/examples/with-turso) | | Changes | The client (libSQL → D1 binding, same `execute` shape), the Workers build, tests, the D1 root, the deploy contract; page copy says D1 | | Decisions locked | (1) ~~The table is created on first use, as upstream does~~ — since TU5 the table is a migration (`packages/db`), applied by Cirrus's `db-migrate` shape between the D1 apply and the Worker's deploy (risk TU-A). (2) `wrangler.jsonc` rendered per environment — and, since TU5, committed as the fixture render, because the deploy lane checks it exists before the build (risk TU-G). (3) No local `dev.db` file: `wrangler dev` and `next dev` get a local D1 (`db:migrate:local` creates the table). (4) TU5: one landing — the plan, not a landing boundary, orders the database, its schema and the Worker. | | Gate | TU1 is the first user-visible rung. TU2 applies only with a linked workspace; verified by `terraform validate`. | -| Shipped as | `main` after [#4](https://github.com/sourceplane/turso-starter/pull/4); verified locally under `wrangler dev` with a local D1 | +| Shipped as | `baseline-v2` ([#6](https://github.com/sourceplane/turso-starter/pull/6), one landing), then TU6 on `main`; `baseline-v1` is TU4's four-phase build ([#5](https://github.com/sourceplane/turso-starter/pull/5)). Proven offline (Baseline CI: a todo round-tripped through a local D1 under `wrangler dev`), deploy gated until a workspace is linked | ## Read order @@ -35,3 +35,4 @@ The port keeps the page, the form, the server actions and the todo list. It adds | TU3 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it | | TU4 — a baseline | card, build document (four phases, the database its own), rename, bootstrap tooling, tests | a new todo list goes from nothing to live, its D1 database included; Baseline CI green | | TU5 — a baseline, in one landing | the build document rebuilt as `01-product` + `02-docs` (cirrus-baseline v22), the schema as migrations (`packages/db`, `infra/db-migrate`), the deploy-lane fixes | a new todo list goes from nothing to live in one landing, D1 applied, then migrated, then the Worker deployed; Baseline CI green | +| TU6 — 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/turso-starter/epic.yaml b/specs/epics/turso-starter/epic.yaml index 7d26801..ac2b60a 100644 --- a/specs/epics/turso-starter/epic.yaml +++ b/specs/epics/turso-starter/epic.yaml @@ -44,3 +44,10 @@ spec: - "the product's own push-to-main plan applies cloudflare-d1, then db-migrate, then deploys web, per environment, and the landing's await finds WIRING_CLOUDFLARE_D1 on stage and prod" - "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 migration lane applied against a stand-in D1 API, a todo round-tripped through a local D1)" tasks: [TU-6] + - name: "TU6 — the cirrus standard" + exitCriteria: + - "nothing outside this milestone's own record names kiox: orun is pinned where CI runs it (the orun-action `version:` in each workflow)" + - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" + - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a product" + - "every milestone's status row agrees with the tags" + tasks: [TU-7] diff --git a/specs/epics/turso-starter/implementation-plan.md b/specs/epics/turso-starter/implementation-plan.md index 1d9a101..24f3baf 100644 --- a/specs/epics/turso-starter/implementation-plan.md +++ b/specs/epics/turso-starter/implementation-plan.md @@ -45,7 +45,7 @@ recipe (PK3 and PK-5), with a `02-data` phase from virga's - the status file records what is proven offline and what only a live bootstrap can prove -## TU5 — a baseline, in one landing +## TU5 — a baseline, in one landing ✅ (#6) The build document rebuilt the cirrus-baseline v22 way (`01-product`, `02-docs`), from `kv-redis-starter`'s KR4; the schema as migrations @@ -66,9 +66,35 @@ The build document rebuilt the cirrus-baseline v22 way (`01-product`, - the status file records what is proven offline and what only a live bootstrap can prove +## TU6 — the cirrus standard (TU-7) ✅ + +Bring the baseline to cirrus-baseline's standard, with nothing about the +product itself changing. + +- **No kiox.** `kiox.yaml`/`kiox.lock` pinned an orun (v2.15.0) that nothing + ran: every workflow installs orun itself through `orun-action` with its own + `version:`. The files, their two modules and the rebrand's skip entry go. +- **Component docs.** `tooling/catalog/gen-component-docs.py` writes each + component's `docs/overview.md`, `docs/architecture.md` and `docs/runbook.md` + from what the component declares, as cirrus-baseline's do; the pages ship + with the component. Baseline CI runs it with `--check`. +- **The context pack.** `ai/context/current.md`, `decisions.md` and + `open-risks.md` beside the two pages a product ships with — this + repository's own, so no module places them. +- **Status that agrees with the tags.** TU4 is `baseline-v1`, TU5 + `baseline-v2`. + +**Done when** +- nothing outside this milestone's own record (its specs, task and context + pages) names kiox, and the leak gate and the offline bootstrap pass + without the two modules +- the docs check is green in Baseline CI +- this file, the status file and `epic.yaml` agree + ## After TU5 (outside this repository) -1. Cut `baseline-v1` with `tag.yml` from the merged `main`. +1. Cut the tag with `tag.yml` from the merged `main` — done: TU5 is + `baseline-v2` (`baseline-v1` is TU4's four-phase build). 2. Register the row in orun-cloud's `infra/baselines-registry/baselines.yaml` (unlisted, `manifestPath: blueprint.yaml`, `requires: [cloudflare]`) — its catalogue preflight refuses a tag that does not exist yet. diff --git a/tasks/TU-7.TaskContract.yaml b/tasks/TU-7.TaskContract.yaml new file mode 100644 index 0000000..3e16e7f --- /dev/null +++ b/tasks/TU-7.TaskContract.yaml @@ -0,0 +1,31 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: TU-7 + title: "The cirrus standard" +spec: + goal: The baseline meets cirrus-baseline's standard — no kiox pin (orun is pinned where CI runs it), every component documented by generated overview/architecture/runbook pages that CI keeps in step with the manifests, the agent context pack, and status documents that agree with the tags + affects: + - kiox.yaml + - kiox.lock + - repo-blueprint.yaml + - testing/phases.test.sh + - tooling/rebrand/** + - tooling/catalog/** + - .github/workflows/baseline.yml + - apps/web/docs/** + - packages/db/docs/** + - infra/db-migrate/docs/** + - infra/terraform/cloudflare-d1/docs/** + - tests/web/docs/** + - tests/db/docs/** + - ai/context/** + - specs/** + - tasks/** + doneWhen: + - nothing outside this milestone's own record names kiox, and the leak gate and the offline bootstrap place a product 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 78575f9..652445d 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", "cloudflare-d1", "db", "db-migrate", "db-tests", "discovery-roots", "github-workflows", "rebrand-values", - "root-gitignore", "root-intent", "root-kiox", "root-kiox-lock", + "root-gitignore", "root-intent", "root-package-json", "root-pnpm-lock", "root-pnpm-workspace", "root-readme", "root-turbo", "tooling-eslint", "tooling-migrations", "tooling-tsconfig", "tooling-wire", "vscode", "web", "web-tests"], diff --git a/tests/db/docs/architecture.md b/tests/db/docs/architecture.md new file mode 100644 index 0000000..448c54d --- /dev/null +++ b/tests/db/docs/architecture.md @@ -0,0 +1,7 @@ +# db-tests — architecture + +A test package at `tests/db`. Its lane runs the suite before it builds. + +## Suites (1) + +- `migrations.test.ts` diff --git a/tests/db/docs/overview.md b/tests/db/docs/overview.md new file mode 100644 index 0000000..ea4ef3f --- /dev/null +++ b/tests/db/docs/overview.md @@ -0,0 +1,18 @@ +# db-tests + +The test suite for **db**. It deploys nothing: its lane installs, builds and runs the tests. + +| | | +| ------------ | -------------------- | +| Type | `turbo-package` | +| Source | `tests/db` | +| Package | `@app/db-tests` | +| Environments | `dev`: `quick-check` | + +## Depends on + +- (none) + +## Depended on by + +- (none) diff --git a/tests/db/docs/runbook.md b/tests/db/docs/runbook.md new file mode 100644 index 0000000..aa64499 --- /dev/null +++ b/tests/db/docs/runbook.md @@ -0,0 +1,26 @@ +# db-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/db-tests build +pnpm --filter @app/db-tests test +pnpm --filter @app/db-tests typecheck +pnpm --filter @app/db-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/tests/web/docs/architecture.md b/tests/web/docs/architecture.md new file mode 100644 index 0000000..9621e3a --- /dev/null +++ b/tests/web/docs/architecture.md @@ -0,0 +1,8 @@ +# web-tests — architecture + +A test package at `tests/web`. Its lane runs the suite before it builds. + +## Suites (2) + +- `site.test.ts` +- `turso.test.ts` diff --git a/tests/web/docs/overview.md b/tests/web/docs/overview.md new file mode 100644 index 0000000..3534e6b --- /dev/null +++ b/tests/web/docs/overview.md @@ -0,0 +1,18 @@ +# web-tests + +The test suite for **web**. It deploys nothing: its lane installs, builds and runs the tests. + +| | | +| ------------ | -------------------- | +| Type | `turbo-package` | +| Source | `tests/web` | +| Package | `@app/web-tests` | +| Environments | `dev`: `quick-check` | + +## Depends on + +- (none) + +## Depended on by + +- (none) diff --git a/tests/web/docs/runbook.md b/tests/web/docs/runbook.md new file mode 100644 index 0000000..c687de2 --- /dev/null +++ b/tests/web/docs/runbook.md @@ -0,0 +1,26 @@ +# web-tests — runbook + +## How it runs + +Its lane runs on every pull request that changes it; it has no deployed surface. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @app/web-tests build +pnpm --filter @app/web-tests test +pnpm --filter @app/web-tests typecheck +pnpm --filter @app/web-tests lint +``` + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **A dependent fails to build after a change here**: run `pnpm typecheck` + across the workspace before merging. diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py new file mode 100644 index 0000000..cda768f --- /dev/null +++ b/tooling/catalog/gen-component-docs.py @@ -0,0 +1,534 @@ +#!/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") + + +# ── 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 = { + "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"], ""] + facts = [["Type", f"`{c['type']}`"], ["Source", f"`{c['path']}`"]] + if pkg and pkg.get("name"): + facts.append(["Package", f"`{pkg['name']}`"]) + if 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) + + +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.", "", + *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"]], ""] + 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: + facts = [["Worker config", f"`{c['path']}/{cfg_name}`"]] + if cfg.get("main"): + facts.append(["Entry", f"`{cfg['main']}`"]) + if cfg.get("compatibility_date"): + facts.append(["Compatibility date", f"`{cfg['compatibility_date']}`"]) + if cfg.get("compatibility_flags"): + 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 += [*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", + "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 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 ["."] + 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-"): + _, 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: + 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 b80f2da..8cf80b7 100644 --- a/tooling/rebrand/rebrand.mjs +++ b/tooling/rebrand/rebrand.mjs @@ -181,7 +181,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 0e56cd723475e34659e5a03c0344cff6287bebf7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 18 Oct 2026 14:35:14 +0000 Subject: [PATCH 2/2] 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",