diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index 6b92eed..0c4f30c 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -74,6 +74,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 a product.** 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 af3797a..6f0080c 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -20,8 +20,8 @@ went live (`02-docs`). | | | |---|---| -| Latest tag | `baseline-v1` (AC5, [#6](https://github.com/sourceplane/ai-chatbot/pull/6)) | -| On `main` since | AC6 — the cirrus standard (no kiox, generated component docs, this context pack) | +| Latest tag | `baseline-v2` (AC6 — the cirrus standard, [#7](https://github.com/sourceplane/ai-chatbot/pull/7) and [#8](https://github.com/sourceplane/ai-chatbot/pull/8): 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` (AC5, [#6](https://github.com/sourceplane/ai-chatbot/pull/6)) | | Proven live | No. Everything short of the platform is proven offline in Baseline CI: the e2e tier builds the product in orun's staged job tree, migrates a local Postgres with its own runner and serves the Worker over local R2 with a stand-in AI binding. No bootstrap from a tag has run against a workspace yet: the three applies, db-migrate against a real project, a real deploy, Workers AI itself (AC-K) and the `BLOB` binding under the deploy token (AC-L) are unproven | ## Where to read @@ -36,8 +36,7 @@ went live (`02-docs`). ## Next -1. Bootstrap one chatbot from a tag against a workspace with Cloudflare and - Supabase connected, and record its timings: the first proof of the - applies, the deploy, Workers AI's models and tools (AC-K) and the R2 - binding under the deploy token (AC-L). -2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin AC6. +1. Bootstrap one chatbot from `baseline-v2` against a workspace with + Cloudflare and Supabase connected, and record its timings: the first + proof of the applies, the deploy, Workers AI's models and tools (AC-K) + and the R2 binding under the deploy token (AC-L). diff --git a/ai/context/decisions.md b/ai/context/decisions.md index f13e187..e84871a 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -18,3 +18,4 @@ reads in order. | 10 | stack-tectonic 0.19.0, not 0.20.0 | 0.20.0 links each job's `node_modules` out of its tree, which Next 16's Turbopack refuses | `intent.yaml`, BOOTSTRAP.md | | 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 (AC6) | | 12 | Component docs are generated from the manifests and checked in CI | A hand-written copy of the dependency graph and bindings drifts silently | `tooling/catalog/gen-component-docs.py` | +| 13 | `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 public origin, the smoke and the probes | `blueprint.yaml`, IMPLEMENTATION-STATUS (AC-8) | diff --git a/blueprint.yaml b/blueprint.yaml index 5b74cb0..5f4ac5e 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -101,6 +101,19 @@ spec: pattern: "^[a-z0-9][a-z0-9-]{0,62}$" help: The workers.dev subdomain of the Cloudflare account the app 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 public origin the Open Graph links are built + # from, the deploy's smoke, 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 ce492d7..3d1a7b4 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -60,8 +60,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. +- `subdomain` — the workers.dev subdomain of the Cloudflare account you + deploy into. It is in every URL the phases probe. 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 651b859..e52f8c7 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -57,7 +57,10 @@ inputs: default: "your-workers-subdomain" description: >- The workers.dev subdomain of the Cloudflare account the app deploys - into — its URLs and the probes. + into — its URLs and 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 6b886c5..855c47a 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 | |------|---------|--------|------------| -| [`ai-chatbot/`](./ai-chatbot/) | **AC** | ✅ Shipped (`baseline-v1`); live bootstrap pending | Vercel's Next.js AI Chatbot, equivalent in code and function, on Cloudflare Workers with Supabase Postgres, Hyperdrive and R2 — and an Orun baseline that instantiates it in one landing, chatting on Workers AI (AC5) | +| [`ai-chatbot/`](./ai-chatbot/) | **AC** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's Next.js AI Chatbot, equivalent in code and function, on Cloudflare Workers with Supabase Postgres, Hyperdrive and R2 — and an Orun baseline that instantiates it in one landing, chatting on Workers AI (AC5) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/ai-chatbot/IMPLEMENTATION-STATUS.md b/specs/epics/ai-chatbot/IMPLEMENTATION-STATUS.md index 46c5165..05c47ac 100644 --- a/specs/epics/ai-chatbot/IMPLEMENTATION-STATUS.md +++ b/specs/epics/ai-chatbot/IMPLEMENTATION-STATUS.md @@ -16,7 +16,7 @@ the code departed from `design.md` or from the upstream template. | AC3 — Supabase, Hyperdrive and R2 from Terraform | ✅ Shipped (validated; apply gated on a linked workspace) | [#4](https://github.com/sourceplane/ai-chatbot/pull/4) | | AC4 — ready to instantiate | ✅ Shipped | [#5](https://github.com/sourceplane/ai-chatbot/pull/5) | | AC5 — a baseline | ✅ Shipped | [#6](https://github.com/sourceplane/ai-chatbot/pull/6) (AC-6), tagged `baseline-v1` | -| AC6 — the cirrus standard | ✅ Shipped | AC-7 — on `main` after `baseline-v1`, not yet tagged | +| AC6 — the cirrus standard | ✅ Shipped | [#7](https://github.com/sourceplane/ai-chatbot/pull/7) (AC-7), [#8](https://github.com/sourceplane/ai-chatbot/pull/8) (AC-8), tagged `baseline-v2` | ## Departures from the upstream template (AC1–AC4) @@ -150,6 +150,44 @@ Nothing about the chatbot changed. What changed is the baseline around it: | status | AC5 "in review" | AC5 shipped and tagged `baseline-v1` | the tag existed; the documents had not caught up | | `design.md` | §2–§7 and §9 still described AC1–AC4: the gateway "unchanged", Workers AI a rejected alternative, `wrangler.jsonc` git-ignored, `AUTH_SECRET` and the gateway key set by hand, seven Supabase outputs | each superseded passage marked and the as-built fact beside it | the design contradicted the code AC5 shipped | +### The subdomain from the Cloudflare connection (AC-8) + +`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 public origin the Open Graph links are +built from, 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 tokens 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 a product carries changes: the rename writes the value where it + always did (`workersDevSubdomain`, the URLs), and the probes read it as + before. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer,wire}.test.sh` + green; `gen-component-docs.py --check` green (8 components). +- Mutation: with `cloudflare` dropped from `spec.requires.integrations`, + `manifest.test.sh` fails with exactly one finding, naming + `inputs[subdomain]`; restored, it passes. +- `orun new --status` at v2.58.11: `01-product` pending, 294 files. + `testing/leak.test.sh` at v2.58.11: 294 files derived, 287 text files read. + `testing/placement.test.sh` at v2.78.4: 294 files placed, both landings; the + product's own plan orders supabase → cloudflare-hyperdrive → db-migrate → + web and cloudflare-r2 → web; `--resume` changes nothing. +- `orun task check AC-8` complete. + ## Verified (AC6) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer,wire}.test.sh` diff --git a/specs/epics/ai-chatbot/README.md b/specs/epics/ai-chatbot/README.md index 3977051..9ea2baa 100644 --- a/specs/epics/ai-chatbot/README.md +++ b/specs/epics/ai-chatbot/README.md @@ -8,7 +8,7 @@ The upstream code stays the code: `app/(chat)/api/chat/route.ts` with `streamTex | Field | Value | |-------|-------| -| Status | ✅ AC0–AC5 shipped (#1–#6), tagged `baseline-v1`: AC5 made the repository an Orun baseline (one landing), Workers AI the default model provider, the session key the database's own and row-level security universal. AC6 (the cirrus standard, AC-7) on `main`, not yet tagged. The Supabase, Hyperdrive and R2 applies, db-migrate and a live deploy are not yet proven by a live bootstrap (risks AC-K, AC-L) | +| Status | ✅ AC0–AC5 shipped (#1–#6), tagged `baseline-v1`: AC5 made the repository an Orun baseline (one landing), Workers AI the default model provider, the session key the database's own and row-level security universal. AC6 (the cirrus standard, AC-7 #7 and AC-8 #8) tagged `baseline-v2`. The Supabase, Hyperdrive and R2 applies, db-migrate and a live deploy are not yet proven by a live bootstrap (risks AC-K, AC-L) | | Cluster | **AC** (AC0–AC6) | | Owner(s) | `apps/web` (the app) · `tests/web` (vitest) · `packages/db` + `tests/db` (the schema) · `infra/terraform/{supabase,cloudflare-hyperdrive,cloudflare-r2}` + `infra/db-migrate` | | Builds on | `lumen` conventions — the `supabase`, `cloudflare-hyperdrive` and `db-migrate` components, `@saas/db`, the orun-secrets wiring, the per-request `postgres` client; `cirrus-baseline` for the R2 root and the repository shape | @@ -16,7 +16,7 @@ The upstream code stays the code: `app/(chat)/api/chat/route.ts` with `streamTex | Changes | Adds the Workers build, the monorepo wrapper, tests, the migrations package, the infra roots and the deploy contract; in the template's code: the per-call Postgres client, the R2 attachment routes, and shims for the Vercel-only modules (`lib/bot.ts`, `lib/geo.ts`, an empty `instrumentation.ts`) | | Decisions locked | (1) OpenNext on Workers + Static Assets, `next` pinned to 16.3.8. (2) Postgres through Hyperdrive, one `postgres` client per `getDb()` call, never at module scope. (3) Attachments in R2 behind `/api/files/`, public by unguessable URL exactly as Vercel Blob's `access: "public"` was. (4) The schema ships in `packages/db` and is applied by db-migrate; drizzle-kit stays for local development. (5) Static-assets incremental cache: the app has no `use cache` and nothing revalidates. (6) No Redis: resumable streams and the IP rate limit stay off, as upstream does without `REDIS_URL`. (7) `AUTH_SECRET` and `AI_GATEWAY_API_KEY` are Worker secrets set once per environment — **superseded by AC5**: both are optional; Workers AI through the `AI` binding is the default model provider, and the session key defaults to one the database generates. | | Gate | AC1 is the first user-visible rung and is verified without a database (the Worker boots, the routes answer). AC2 and AC3 need a workspace with Supabase and Cloudflare connections to apply; they are verified by `plan`, `terraform validate` and the offline migration tests. | -| Shipped as | `baseline-v1` ([#6](https://github.com/sourceplane/ai-chatbot/pull/6)), then AC6 on `main`; proven offline (Baseline CI: contract, leak, placement and the e2e tier), deploy gated until a workspace is linked | +| Shipped as | `baseline-v1` ([#6](https://github.com/sourceplane/ai-chatbot/pull/6)), then `baseline-v2` (AC6: [#7](https://github.com/sourceplane/ai-chatbot/pull/7), [#8](https://github.com/sourceplane/ai-chatbot/pull/8)); proven offline (Baseline CI: contract, leak, placement and the e2e tier), deploy gated until a workspace is linked | ## Read order @@ -35,4 +35,4 @@ The upstream code stays the code: `app/(chat)/api/chat/route.ts` with `streamTex | AC3 — Supabase, Hyperdrive and R2 from Terraform | the three roots and the app's wiring from them | the roots validate; the wiring keys match the template's tokens | | AC4 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it | | AC5 — a baseline | the card, the build document, `.baseline/`, the rebrand engine, the bootstrap helpers, `testing/`; Workers AI by default, the database's session key, RLS, the committed wrangler config, `/api/health`, the R2 root on its own `r2-data` key | Baseline CI green: contract, leak, placement (infra before app) and the e2e tier | -| AC6 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags and the code | Baseline CI green with the docs check | +| AC6 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags and the code; 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/ai-chatbot/epic.yaml b/specs/epics/ai-chatbot/epic.yaml index c9e2c2c..26d8353 100644 --- a/specs/epics/ai-chatbot/epic.yaml +++ b/specs/epics/ai-chatbot/epic.yaml @@ -51,4 +51,5 @@ spec: - "every component carries generated docs/{overview,architecture,runbook}.md, and Baseline CI fails a pull request whose manifests and pages disagree" - "ai/context carries this repository's current.md, decisions.md and open-risks.md, and none of them ships to a product" - "every milestone's status row agrees with the tags" - tasks: [AC-7] + - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" + tasks: [AC-7, AC-8] diff --git a/specs/epics/ai-chatbot/implementation-plan.md b/specs/epics/ai-chatbot/implementation-plan.md index 792a0fa..52bb5d7 100644 --- a/specs/epics/ai-chatbot/implementation-plan.md +++ b/specs/epics/ai-chatbot/implementation-plan.md @@ -114,6 +114,11 @@ chatbot itself changing. - **Status that agrees with the tags and the code.** AC5 is shipped and tagged; `design.md` marks what AC5 superseded (Workers AI by default, the optional `AUTH_SECRET`, the committed `wrangler.jsonc`). +- **The subdomain from the Cloudflare connection (AC-8).** 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** - nothing outside this milestone's own record names kiox (`git grep -i diff --git a/tasks/AC-8.TaskContract.yaml b/tasks/AC-8.TaskContract.yaml new file mode 100644 index 0000000..ead0a5c --- /dev/null +++ b/tasks/AC-8.TaskContract.yaml @@ -0,0 +1,25 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: AC-8 + 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/ai-chatbot/** + - tasks/AC-8.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 [])}