diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index ef9fc24..eb73d4f 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -73,6 +73,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 0e05421..d7aacc1 100644 --- a/ai/context/current.md +++ b/ai/context/current.md @@ -21,8 +21,8 @@ vendor key. | | | |---|---| -| Latest tag | `baseline-v1` (RG5, [#6](https://github.com/sourceplane/rag-chatbot/pull/6)) | -| On `main` since | RG6 — the cirrus standard (no kiox, generated component docs, this context pack) | +| Latest tag | `baseline-v2` (RG6 — the cirrus standard, [#7](https://github.com/sourceplane/rag-chatbot/pull/7) and [#8](https://github.com/sourceplane/rag-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` (RG5, [#6](https://github.com/sourceplane/rag-chatbot/pull/6)) | | Proven live | No. Everything short of the platform is proven offline in Baseline CI, with stand-ins for Workers AI and Supabase's Management API. The real models, a deploy with the brokered token and its `AI` binding, the Terraform and db-migrate applies and a live bootstrap are still to come (risks RG-J, RG-K) | ## Where to read @@ -37,8 +37,7 @@ vendor key. ## Next -1. Bootstrap one product from the next tag against a workspace with +1. Bootstrap one product from `baseline-v2` against a workspace with Cloudflare and Supabase connected (two free project slots, RG-O): the first run of the real models and of the `AI` binding under the brokered deploy token, and the first Terraform and db-migrate applies (closes RG-J, RG-K). -2. Cut the next `baseline-vN` with `tag.yml` so the registry can pin RG6. diff --git a/ai/context/decisions.md b/ai/context/decisions.md index bfb1304..ef4f14e 100644 --- a/ai/context/decisions.md +++ b/ai/context/decisions.md @@ -18,3 +18,4 @@ reads in order. | 10 | `ci.yml` plans nothing while `intent.yaml` names `ws_CHANGE_ME` | A bootstrap cannot set a repository variable (replaced the `ORUN_CI` gate) | IMPLEMENTATION-STATUS (RG5), `.github/workflows/ci.yml` | | 11 | stack-tectonic 0.19.0, not 0.20.0 | 0.20.0's lane-scoped install links `node_modules` out of the job tree, which Next 16's Turbopack refuses | `intent.yaml`, `BOOTSTRAP.md` (Troubleshooting) | | 12 | orun is pinned only where it runs (the `orun-action` `version:` in each workflow); no kiox. Component docs are generated from the manifests and checked in CI | `kiox.yaml` pinned a version nothing ran; a hand-written copy of the dependency graph and bindings drifts silently | IMPLEMENTATION-STATUS (RG6), `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 Open Graph origin, the smoke and the probes | `blueprint.yaml`, IMPLEMENTATION-STATUS (RG-8) | diff --git a/blueprint.yaml b/blueprint.yaml index cd36344..0bf2699 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -98,6 +98,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 image link is 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 4fae6e0..b4ad373 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -59,8 +59,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 d5a5788..e631d92 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -56,7 +56,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 1458d0b..7f9f572 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 | |------|---------|--------|------------| -| [`rag-chatbot/`](./rag-chatbot/) | **RG** | ✅ Shipped (`baseline-v1`); live bootstrap pending | Vercel's AI SDK RAG chatbot, equivalent in code and function, on Cloudflare Workers with Supabase Postgres (pgvector) through Hyperdrive — and an Orun baseline that instantiates it in one landing, chatting on Workers AI (RG5) | +| [`rag-chatbot/`](./rag-chatbot/) | **RG** | ✅ Shipped (`baseline-v2`); live bootstrap pending | Vercel's AI SDK RAG chatbot, equivalent in code and function, on Cloudflare Workers with Supabase Postgres (pgvector) through Hyperdrive — and an Orun baseline that instantiates it in one landing, chatting on Workers AI (RG5) | As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`. diff --git a/specs/epics/rag-chatbot/IMPLEMENTATION-STATUS.md b/specs/epics/rag-chatbot/IMPLEMENTATION-STATUS.md index 232681a..7e93f91 100644 --- a/specs/epics/rag-chatbot/IMPLEMENTATION-STATUS.md +++ b/specs/epics/rag-chatbot/IMPLEMENTATION-STATUS.md @@ -11,7 +11,7 @@ the code departed from `design.md` or from the upstream template. | RG3 — Supabase and Hyperdrive from Terraform | ✅ Shipped (validated; apply gated on a linked workspace) | [#4](https://github.com/sourceplane/rag-chatbot/pull/4) | | RG4 — ready to instantiate | ✅ Shipped | [#5](https://github.com/sourceplane/rag-chatbot/pull/5) | | RG5 — a baseline | ✅ Shipped | [#6](https://github.com/sourceplane/rag-chatbot/pull/6) (RG-6), tagged `baseline-v1` | -| RG6 — the cirrus standard | ✅ Shipped | RG-7 — on `main` after `baseline-v1`, not yet tagged | +| RG6 — the cirrus standard | ✅ Shipped | [#7](https://github.com/sourceplane/rag-chatbot/pull/7) (RG-7), [#8](https://github.com/sourceplane/rag-chatbot/pull/8) (RG-8), tagged `baseline-v2` | ## Departures from the upstream template @@ -273,6 +273,45 @@ Nothing about the chatbot changed. What changed is the baseline around it: | context pack | `operations.md`, `deployment.md` | plus `current.md`, `decisions.md`, `open-risks.md` | cirrus-baseline's shape; the three new pages are this repository's own and no module places them (the leak gate still allows exactly two) | | status | RG5 "in review" on its branch | RG5 shipped ([#6](https://github.com/sourceplane/rag-chatbot/pull/6)) and tagged `baseline-v1` | the tag existed; the documents had not caught up | +### The subdomain from the Cloudflare connection (RG-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 image link +is built from (RG-P), 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 build line's site URL, the URLs), and + the probes read it as before. + +Verified: + +- `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` + green; `gen-component-docs.py --check` green (7 components). +- Mutation: with `cloudflare` dropped from `spec.requires.integrations`, + `manifest.test.sh` fails with exactly one finding, naming + `inputs[subdomain]`; restored, it passes. +- At v2.58.11 (the blueprint job's pin, placement included): + `orun new --status` reads the document (`01-product` pending, 145 files); + `testing/leak.test.sh` 145 files derived, 141 text files read; + `testing/placement.test.sh` 145 files placed, both landings, the product's + own plan orders supabase → cloudflare-hyperdrive → db-migrate → web on + stage and prod; exactly the five minted keys; `--resume` a no-op. +- `orun task check RG-8` complete. + ## Verified (RG6) - `testing/{manifest,phases,coverage,rebrand,retouch,bootstrap-defer}.test.sh` diff --git a/specs/epics/rag-chatbot/README.md b/specs/epics/rag-chatbot/README.md index 6a62add..00272a7 100644 --- a/specs/epics/rag-chatbot/README.md +++ b/specs/epics/rag-chatbot/README.md @@ -8,7 +8,7 @@ The upstream code stays the code: the chat page, the route and its tools, the re | Field | Value | |-------|-------| -| Status | ✅ RG0–RG5 shipped (#1–#6), tagged `baseline-v1`; RG6 (the cirrus standard, RG-7) on `main`, not yet tagged. The Supabase, Hyperdrive and migration applies, a live deploy and a live bootstrap are still to come (risks RG-J, RG-K) | +| Status | ✅ RG0–RG5 shipped (#1–#6), tagged `baseline-v1`; RG6 (the cirrus standard, RG-7 #7 and RG-8 #8) tagged `baseline-v2`. The Supabase, Hyperdrive and migration applies, a live deploy and a live bootstrap are still to come (risks RG-J, RG-K) | | Cluster | **RG** (RG0–RG6) | | Owner(s) | `apps/web` (the app) · `packages/db` + `infra/db-migrate` (the schema) · `tests/web`, `tests/db` · `infra/terraform/{supabase,cloudflare-hyperdrive}` (the database) | | Builds on | `lumen` conventions — the `supabase` and `cloudflare-hyperdrive` roots, `@saas/db` with the db-migrate composition, the per-request Hyperdrive client; `supabase-starter` for the repository and the rendered-wrangler shape | @@ -16,7 +16,7 @@ The upstream code stays the code: the chat page, the route and its tools, the re | Changes | Adds the Workers build, the monorepo wrapper, tests, the migration package, both Terraform roots and the deploy contract; in the template's code: `lib/db/index.ts` exports `getDb()` instead of `db`, its two callers await it, `DATABASE_URL` is optional in `lib/env.mjs` | | Decisions locked | (1) OpenNext on Workers + Static Assets, static-assets incremental cache. (2) Postgres through Hyperdrive, a `postgres` client per call; no module-level pool. (3) pgvector stays: the schema is the template's SQL, applied by db-migrate; not Vectorize. (4) The models are Workers AI's through an `AI` binding — Llama 4 Scout for the chat, bge-base-en-v1.5 (768) for the embeddings, the column resized by a migration; `AI_GATEWAY_API_KEY` is optional and switches only the chat to upstream's gateway model (RG5; RG1–RG4 used the gateway only). (5) `wrangler.jsonc` rendered from the template: committed as the fixture render (the composition checks it exists before the build), re-rendered per environment from the Hyperdrive wiring document by the deploy lanes (RG5; it was never committed before). (6) Row-level security, no policy, on every table in `public` (RG5). (7) Infra before app on main: supabase → cloudflare-hyperdrive → db-migrate → web, enforced; advisory on pull requests (RG5). | | Gate | RG1 is the first user-visible rung. RG2 and RG3 need a workspace with Supabase and Cloudflare connections to apply; both are verified by `plan` and `validate`. | -| Shipped as | `baseline-v1` ([#6](https://github.com/sourceplane/rag-chatbot/pull/6)), then RG6 on `main`; proven offline (Baseline CI), deploy gated until a workspace is linked | +| Shipped as | `baseline-v1` ([#6](https://github.com/sourceplane/rag-chatbot/pull/6)), then `baseline-v2` (RG6: [#7](https://github.com/sourceplane/rag-chatbot/pull/7), [#8](https://github.com/sourceplane/rag-chatbot/pull/8)); proven offline (Baseline CI), deploy gated until a workspace is linked | ## Read order @@ -35,4 +35,4 @@ The upstream code stays the code: the chat page, the route and its tools, the re | RG3 — Supabase and Hyperdrive from Terraform | both roots, the app's `dependsOn` and `secretEnv` | both roots validate; the wiring keys match the template's tokens | | RG4 — ready to instantiate | README, as-built status | a reader can run, test, preview and deploy it | | RG5 — a baseline | card, build document, rename, bootstrap tooling, Workers AI models, RLS, the product's README and context pack, tests | a new product goes from nothing to live on stage and prod in one landing, chatting on Workers AI with no AI vendor key; Baseline CI green | -| RG6 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags | Baseline CI green with the docs check | +| RG6 — the cirrus standard | no kiox, generated component docs, the context pack, status that agrees with the tags; the subdomain read from the Cloudflare connection | Baseline CI green with the docs check; the card asks for no subdomain | diff --git a/specs/epics/rag-chatbot/epic.yaml b/specs/epics/rag-chatbot/epic.yaml index a12c513..c9a7d93 100644 --- a/specs/epics/rag-chatbot/epic.yaml +++ b/specs/epics/rag-chatbot/epic.yaml @@ -52,4 +52,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: [RG-7] + - "the console card reads subdomain from the Cloudflare connection (from: connection.cloudflare.workersSubdomain), as cirrus-baseline since baseline-v23" + tasks: [RG-7, RG-8] diff --git a/specs/epics/rag-chatbot/implementation-plan.md b/specs/epics/rag-chatbot/implementation-plan.md index b9d91eb..a9987b3 100644 --- a/specs/epics/rag-chatbot/implementation-plan.md +++ b/specs/epics/rag-chatbot/implementation-plan.md @@ -112,6 +112,11 @@ chatbot itself changing. `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.** RG5 is shipped and tagged. +- **The subdomain from the Cloudflare connection (RG-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** - `git grep -i kiox` finds nothing outside this milestone's own record diff --git a/tasks/RG-8.TaskContract.yaml b/tasks/RG-8.TaskContract.yaml new file mode 100644 index 0000000..12a7110 --- /dev/null +++ b/tasks/RG-8.TaskContract.yaml @@ -0,0 +1,25 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: RG-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/rag-chatbot/** + - tasks/RG-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 [])}