diff --git a/.baseline/identity.json b/.baseline/identity.json
new file mode 100644
index 0000000..f3b24f8
--- /dev/null
+++ b/.baseline/identity.json
@@ -0,0 +1,9 @@
+{
+ "_comment": "THIS TREE'S OWN IDENTITY — the FROM side of every rebrand. tooling/rebrand/rebrand.mjs reads it to know what to rename AWAY from; a product's identity is the --values file, which is the TO side. Change a value here only together with the tree: these strings must be what the tree actually contains, or the rename silently misses and the product ships carrying this baseline's name. `productName` is the SITE_NAME seam in apps/web/src/lib/site.ts (the upstream template's own name for the app, from its
); `domain` and `subdomain` are placeholders, because this baseline has never deployed under a name of its own; `githubOwner` is the owner in the repository's source links.",
+ "slug": "tanstack-start",
+ "pascal": "TanStackStart",
+ "productName": "TanStack Start Starter",
+ "domain": "tanstack-start.example.com",
+ "subdomain": "your-workers-subdomain",
+ "githubOwner": "sourceplane"
+}
diff --git a/.baseline/product/README.md b/.baseline/product/README.md
new file mode 100644
index 0000000..4cb3fd4
--- /dev/null
+++ b/.baseline/product/README.md
@@ -0,0 +1,98 @@
+# tanstack-start
+
+A TanStack Start site — the welcome page, a todo list kept by server
+functions in the visitor's own cookie, an API route, and the three SSR modes
+(full, data-only and SPA) — on **Cloudflare Workers + Static Assets**, built
+by [Cloudflare's Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/),
+TanStack Start's own Cloudflare target.
+
+## Live deployment
+
+
+Not recorded yet. The bootstrap's last phase writes the live URLs, the
+workspace and the secrets the site uses into
+[ai/context/deployment.md](ai/context/deployment.md); how the site deploys
+and how to operate it is in
+[ai/context/operations.md](ai/context/operations.md).
+
+
+## What is here
+
+| Surface | Where |
+|---|---|
+| The site's name (every page's ``) | `apps/web/src/lib/site.ts` |
+| `/` (the welcome page), `/demo/start/server-funcs` (todos through a GET and a POST server function), `/demo/start/api-request` (a page that fetches the API route), `/demo/start/ssr/*` (full SSR, data-only, SPA mode) | `apps/web/src/routes` |
+| The API route: `GET /demo/api/names` | `apps/web/src/routes/demo/api.names.ts` |
+| The todo store: the visitor's list in one httpOnly cookie | `apps/web/src/data/todos.ts` |
+| The header and its navigation | `apps/web/src/components/Header.tsx` |
+| Workers build and deploy contract | `apps/web/vite.config.ts`, `apps/web/wrangler.jsonc`, `apps/web/component.yaml` |
+| Tests (the site's name, the todo store) | `apps/web/src/**/*.test.ts` (vitest) |
+
+## Getting started
+
+```bash
+pnpm install
+pnpm typecheck # tsc
+pnpm lint # biome lint
+pnpm test # vitest
+pnpm build # vite build → apps/web/dist/server (the Worker) + dist/client (the browser's files)
+```
+
+```bash
+pnpm --filter @app/web dev # http://localhost:3000, the server in workerd
+pnpm --filter @app/web preview # wrangler dev over the built Worker
+```
+
+Make the site yours in `apps/web/src/routes` (the pages; TanStack Router
+writes `src/routeTree.gen.ts` from them) and `apps/web/src/lib/site.ts` (its
+name). The site needs no environment variable and no secret.
+
+The server-functions demo keeps each visitor's list in their own browser:
+one httpOnly cookie holding the list as JSON — no database and no third
+party. A cookie holds about 4 KB, so the list is capped (50 todos of up to
+100 characters, and a todo that would not fit is refused with a message). To
+share a list across devices, swap `readTodos` and the `setCookie` call in
+`apps/web/src/routes/demo/start.server-funcs.tsx` for a KV namespace bound in
+`apps/web/wrangler.jsonc`.
+
+## How it deploys
+
+Merges to `main` converge through Orun: `.github/workflows/ci.yml` plans the
+changed components and runs each lane against the workspace in
+`intent.yaml`. The site deploys to `stage`, then to `prod` once stage has
+converged on the same commit; `dev` only verifies. The Worker is
+`tanstack-start-web-` on your account's workers.dev subdomain, and
+every deploy is smoke-tested over HTTP. A pull request runs the same
+pipeline's verify lanes: the site built and dry-deployed for each
+environment, with nothing deployed. They do not lint or run the tests, so
+run `pnpm typecheck`, `pnpm lint` and `pnpm test` before you push. (A push
+to `main` builds, deploys and smoke-tests.)
+
+The pipeline holds one credential, GitHub's own `GITHUB_TOKEN`. The
+Cloudflare token and account id are brokered per run from the workspace's
+Cloudflare connection; nothing provider-shaped is stored in the repository
+or in GitHub.
+
+**Deploy by hand.** Orunbase's **Deploy** button on a component, or **Run
+workflow** on the CI workflow in GitHub's Actions tab (on `main`), runs
+`ci.yml` for the environment and components you pick, and each one deploys
+exactly as a merge would deploy it. Leave the component blank to redeploy
+every component in that environment, with nothing changed: after rotating a
+secret, say. A component with nothing to run in that environment (a test
+suite in `prod`) is left out with a notice.
+
+## Custom domain
+
+The site answers on workers.dev from its first deploy. To serve it on your
+own domain, add the domain to the Cloudflare account the site deploys into
+and attach it to the Worker (dashboard → Workers & Pages →
+`tanstack-start-web-prod` → Settings → Domains & Routes → Add → Custom
+domain). Do the same for stage with a subdomain if you want one.
+
+Nothing else has to change: the site builds no absolute links, so it answers
+on whatever origin serves it, and TanStack Start's server functions check a
+request's `Origin` against the host it arrived on. The repository names the domain in
+one place, `BASE_DOMAIN` in `intent.yaml` (dev, stage and prod), which the
+site was born with as the reserved placeholder
+`tanstack-start.example.com`. Replace it with your domain in the same
+change that records it.
diff --git a/.baseline/tasks/01-product.TaskContract.yaml b/.baseline/tasks/01-product.TaskContract.yaml
new file mode 100644
index 0000000..bc965e9
--- /dev/null
+++ b/.baseline/tasks/01-product.TaskContract.yaml
@@ -0,0 +1,25 @@
+# Task contract template for the 01-product landing.
+# Unbound to a key on purpose: `orun.task/ensure@v1` seals and attaches it to
+# the key the allocator issues. It lives under `.baseline/`, not `tasks/`,
+# because `tasks/` is this repository's own work tree (`intent.yaml` `work:`),
+# where an unkeyed contract is an error. gates: [] is a DECLARATION — merge
+# alone finishes this task; the main convergence is the gate the bootstrap
+# watches, not one the plane observes as a PR check.
+#
+# The whole site in one landing. `affects` names COMPONENTS, by
+# metadata.name: the phase's retouch hook reads this list to decide which
+# component.yaml files get the redeploy marker, so the deploy set and the task
+# plane's statement of the work are one list. The site is one component — its
+# test runs inside it (vitest in apps/web), so there is no separate test
+# package to redeploy.
+apiVersion: orun.io/v1
+kind: TaskContract
+spec:
+ goal: The site's repository is born and linked, the whole site lands in one pull request, and one convergence builds it with Cloudflare's Vite plugin and deploys it to stage and prod, its tests green
+ affects:
+ - web
+ doneWhen:
+ - repo pushed, main pinned as default, workspace linked (orun cloud link)
+ - main convergence green (build, deploy and smoke on stage and prod)
+ - the home page answers on both workers.dev URLs
+ gates: []
diff --git a/.baseline/tasks/03-docs.TaskContract.yaml b/.baseline/tasks/03-docs.TaskContract.yaml
new file mode 100644
index 0000000..c8f2ba1
--- /dev/null
+++ b/.baseline/tasks/03-docs.TaskContract.yaml
@@ -0,0 +1,13 @@
+# Task contract template for the 03-docs landing. See 01-product's header.
+apiVersion: orun.io/v1
+kind: TaskContract
+spec:
+ goal: The live deployment is recorded from verified facts as agent-readable state in the site's repo
+ affects:
+ - ai/context/deployment.md
+ - ai/context/operations.md
+ - README.md
+ doneWhen:
+ - committed deployment manifest matches probed reality
+ - prod waits on stage again, and dev verifies every merge to main again
+ gates: []
diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml
new file mode 100644
index 0000000..420017c
--- /dev/null
+++ b/.github/workflows/baseline.yml
@@ -0,0 +1,136 @@
+name: Baseline CI
+
+# THE FACTORY'S OWN LANES — this repository tested as a BASELINE: that its
+# build document parses with the orun a bootstrap actually runs, that its card
+# agrees with it, that every component is placed by exactly one phase, that a
+# placed tree comes up branded and carrying nothing of the factory, and that
+# the site it produces installs, builds, deploys (dry) and serves.
+#
+# ─── WHY THIS IS NOT IN ci.yml ────────────────────────────────────────────
+#
+# `repo-blueprint.yaml`'s `github-workflows` module copies the WHOLE `.github`
+# directory into every site built from this repository. These jobs run
+# `testing/*.sh`, and `testing/` is deliberately not placed — so in a site they
+# would be steps that cannot pass, red on its very first pull request. This
+# file is in the blueprint's `ignore` list, and `testing/coverage.test.sh`
+# fails on any workflow that reads `testing/` and is not.
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+
+concurrency:
+ group: baseline-ci-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+permissions:
+ contents: read
+
+jobs:
+ # Tier 0. bash, python3 and git; node for the tools. No workspace install,
+ # no network, no credential — the job that most certainly fails a PR.
+ baseline-contract:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 22
+ # setup-node v5 turns on the pnpm cache by itself when package.json
+ # names a packageManager, and then fails on a runner with no pnpm.
+ # This job installs nothing.
+ package-manager-cache: false
+ - name: Contract tests (manifest, phases, coverage, rebrand, retouch, bootstrap-defer)
+ run: |
+ set -euo pipefail
+ python3 -c 'import yaml' 2>/dev/null || pip install --quiet pyyaml
+ for t in manifest phases coverage rebrand retouch bootstrap-defer; do
+ 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.
+ #
+ # Pinned at the bootstrap floor (BOOTSTRAP.md), not the site's lane pin:
+ # every test here reads YAML with PyYAML, which parses anything well-formed;
+ # only the pinned orun can say whether the document is one a bootstrap can
+ # run. `--status` parses it, validates every hook against the action
+ # registry, compiles every `when` and narration template, and writes
+ # nothing. Then the leak gate (what a site would carry) and the placement
+ # tier (the offline bootstrap: every phase placed and finished by the
+ # blueprint's own hooks, then the site's own `orun plan` for the 01-product
+ # merge).
+ blueprint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+ - uses: sourceplane/orun-action@v1.2.0
+ with:
+ version: v2.88.0
+ - uses: pnpm/action-setup@v4
+ with:
+ version: 10.12.1
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 22
+ # This job installs nothing either: with no lockfile hook the offline
+ # bootstrap never runs pnpm, so there is no store, and the pnpm cache
+ # setup-node v5 turns on by itself (package.json names a packageManager)
+ # fails the job saving a path that does not exist whenever no earlier
+ # cache exists for the lockfile.
+ package-manager-cache: false
+ - name: repo-blueprint.yaml, read by the pinned CLI
+ run: |
+ set -euo pipefail
+ orun --version
+ python3 -c 'import yaml' 2>/dev/null || pip install --quiet pyyaml
+ # Required inputs must be supplied for the document to resolve; the
+ # values are arbitrary and nothing is written.
+ orun new --blueprint repo-blueprint.yaml --status \
+ --out "$(mktemp -d)" \
+ --set reponame=acme-notes \
+ --set "productname=Acme Notes" \
+ --set githuborg=acme-inc
+ - name: the leak gate — what a site carries
+ run: bash testing/leak.test.sh
+ - name: placement — the offline bootstrap, and the site's own plan
+ run: |
+ git config --global user.email ci@example.invalid
+ git config --global user.name "baseline ci"
+ bash testing/placement.test.sh
+
+ # Tier 2. THE SITE IT PRODUCES WORKS: the finished site installed, its
+ # fixtures rendered, type-checked, linted, tested and built, the stage
+ # lane's own build, output check and dry deploy, and the built Worker served
+ # and smoke-tested with the component's own smoke command. Pinned at the
+ # bootstrap floor (v2.88.0): the offline bootstrap reads the blueprint (its
+ # one `secrets` reconcile, its background task set-up, its landings checked
+ # in the box), and the floor is newer than the site's lane pin (v2.78.4),
+ # which is all the lane steps need.
+ site:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+ - uses: sourceplane/orun-action@v1.2.0
+ with:
+ version: v2.88.0
+ - uses: pnpm/action-setup@v4
+ with:
+ version: 10.12.1
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 22
+ cache: pnpm
+ - name: e2e — the bootstrapped site builds, deploys (dry) and serves
+ run: |
+ python3 -c 'import yaml' 2>/dev/null || pip install --quiet pyyaml
+ git config --global user.email ci@example.invalid
+ git config --global user.name "baseline ci"
+ bash testing/e2e.test.sh
diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml
new file mode 100644
index 0000000..c0383e3
--- /dev/null
+++ b/.github/workflows/tag.yml
@@ -0,0 +1,97 @@
+name: Baseline tag
+
+# CUTS A `baseline-vN` TAG FOR THIS REPOSITORY.
+#
+# A baseline tag is what the platform's registry resolves and what every
+# product bootstrapped from this repository is built out of, so it is cut by a
+# workflow rather than by hand: the version must look like a baseline tag, an
+# existing tag is never moved, and the commit is resolved here, once.
+#
+# Whether a commit is fit to release is decided outside this repository, by
+# whoever cuts the tag; nothing here asks for proof beyond a green `main`.
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: "The tag to cut, e.g. baseline-v2."
+ required: true
+ type: string
+ ref:
+ description: "Branch, tag or sha to cut it from. Defaults to main."
+ required: false
+ default: main
+ type: string
+
+concurrency:
+ group: baseline-tag
+ cancel-in-progress: false
+
+permissions:
+ contents: read
+
+jobs:
+ cut:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/checkout@v6
+ with:
+ # Full history: the ref being cut from may be any commit, and a
+ # shallow clone cannot resolve one it did not fetch.
+ fetch-depth: 0
+ ref: ${{ inputs.ref }}
+
+ - name: the version must look like a baseline tag
+ run: |
+ set -euo pipefail
+ # Refused here rather than by the API, because the API's error for a
+ # malformed ref says nothing about the convention it broke.
+ case "${{ inputs.version }}" in
+ baseline-v[0-9]*) ;;
+ *) echo "✕ '${{ inputs.version }}' is not a baseline-vN tag" >&2; exit 1 ;;
+ esac
+
+ - name: resolve the commit
+ id: commit
+ run: |
+ set -euo pipefail
+ sha="$(git rev-parse HEAD)"
+ echo "sha=$sha" >> "$GITHUB_OUTPUT"
+ echo "Cutting ${{ inputs.version }} from ${{ inputs.ref }} = $sha"
+
+ - name: the tag must not already exist
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ code="$(curl -sS -o /dev/null -w '%{http_code}' \
+ -H "Authorization: Bearer $GH_TOKEN" \
+ -H "Accept: application/vnd.github+json" \
+ "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/git/ref/tags/${{ inputs.version }}")"
+ if [ "$code" = "200" ]; then
+ echo "✕ ${{ inputs.version }} already exists. A baseline tag is never moved:" >&2
+ echo " products resolve it, and repointing one changes what a build that" >&2
+ echo " already shipped was made of. Cut the next number." >&2
+ exit 1
+ fi
+ # Anything other than 200 or 404 means the question was not answered,
+ # and "it probably does not exist" is not a thing to guess about a
+ # tag that is about to be created.
+ [ "$code" = "404" ] || { echo "✕ could not check for the tag (HTTP $code)" >&2; exit 1; }
+
+ - name: cut the tag
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ curl -sS -X POST --fail-with-body \
+ -H "Authorization: Bearer $GH_TOKEN" \
+ -H "Accept: application/vnd.github+json" \
+ "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/git/refs" \
+ -d "$(printf '{"ref":"refs/tags/%s","sha":"%s"}' \
+ "${{ inputs.version }}" "${{ steps.commit.outputs.sha }}")"
+ echo ""
+ echo "✓ ${{ inputs.version }} → ${{ steps.commit.outputs.sha }}"
+ echo " Next: move the registry row in orun-cloud's infra/baselines-registry/baselines.yaml."
diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md
new file mode 100644
index 0000000..d41117c
--- /dev/null
+++ b/BOOTSTRAP.md
@@ -0,0 +1,215 @@
+# BOOTSTRAP — a new site from this baseline, in phases
+
+How to go from **nothing** to a **TanStack Start site live on stage and prod,
+documented**, with ONE provider consent.
+
+There is one artifact: **`repo-blueprint.yaml`**. It declares what to place,
+in what order, what each phase needs first, and what to say while it runs.
+`orun new` is the whole runtime — the phases below are its `--phase` names,
+not separate workflows. The console card the platform renders is
+**`blueprint.yaml`**; it names the build document and states the inputs, the
+brokered secrets and the programme, and `testing/manifest.test.sh` holds it
+to what the build document does.
+
+Target wall-clock: **about four minutes** — an estimate summed from the
+phases (3 + 1) until a bootstrap measures it. The shape: the task set-up in
+the background while ONE landing is placed, branded and checked in the box
+(`orun validate` and `orun plan`, no runner waited for), one TanStack Start
+build per environment (seconds, not minutes — the long poles are the
+installs, the runners and a first deploy's workers.dev route), stage and prod
+deployed side by side, then a short docs landing, checked the same way, that
+restores the promotion gate. It is unmeasured: no live bootstrap of this
+baseline has run yet. The sibling site baselines measured 7m07s–8m43s from
+the console's Build over three landings; `01-product` dropped one landing and
+the Checks waits (cirrus-baseline baseline-v22's shape), and orun v2.88.0's
+fast shape took about a minute out of turso-starter's measured build — the
+same minute is assumed here.
+
+## 0. What you need
+
+- GitHub org access (repository creation) and a machine with `git`, `node`
+ (≥ 22), `pnpm` (10.12.1), `python3` with PyYAML, `curl`, and the `orun`
+ CLI **≥ v2.88.0** — the floor for RUNNING the bootstrap (the phase overlay,
+ landings that commit per phase, `githubOwner` on the doctor probe, a probe
+ deferred for a project not yet created, `from: workspace`, the deploy
+ credentials minted in one `secrets` reconcile, the task set-up run in the
+ background (`background: true`), and landings checked in the box before
+ they merge (`checks: local`)). The site's own `ci.yml` pins its lanes
+ separately (v2.78.4).
+- A Cloudflare account (the free plan is enough for one Worker with static
+ assets) and its **Account API token** with Workers Scripts Write (the
+ console's Connect recipe lists the exact permission groups). It is the ONLY
+ provider credential this baseline needs.
+- An Orun Cloud workspace for the site — `orunWorkspace`, or the workspace
+ the build runs in (ORUN_WORKSPACE) when that is unset — with an
+ **admin-role API key** for headless runs (secret writes below admin are
+ masked as `not_found`).
+- **The repository allow-listed in the workspace** (console → Settings → Git
+ repos), unless the credential can write links. `01-product`'s `link` step
+ stops and names the fix if it is not.
+
+## 1. One command: `--resume`
+
+The whole bootstrap, unattended. `--resume` places every phase not already
+derived as done, in order, honouring each phase's barrier:
+
+```bash
+git clone --depth 1 --branch https://github.com/sourceplane/tanstack-start
+cd tanstack-start
+
+orun new --blueprint repo-blueprint.yaml \
+ --out ~/sites/acme-notes --run-hooks --resume \
+ --set reponame=acme-notes --set productname="Acme Notes" \
+ --set githuborg=acme-inc \
+ --set orunWorkspace=ws_XXXXXXXX \
+ --set subdomain=
+```
+
+`subdomain` is the workers.dev subdomain of the Cloudflare account you deploy
+into (Workers & Pages → your subdomain). A build started from the console, or
+with `orun baseline new --from bst_…`, never asks for it: the platform reads
+it from the workspace's Cloudflare connection, the same one the deploy token
+is minted from. Only a hand-run build like this one passes it.
+
+**`--run-hooks` is the difference between placing files and bootstrapping a
+site.** Without it `orun new` writes the tree and stops: no repository, no
+landing, no convergence watch, no probe. That is deliberate — it is what
+makes the offline bootstrap in `testing/` possible with no workspace and no
+provider.
+
+`--resume` is safe to re-run from anywhere, a fresh container with a fresh
+`--out` included: **phase state is derived from the tree, never stored.** A
+phase whose files are present but branded derives as `drifted`, and
+`--resume` leaves it placed rather than reverting the site's identity.
+
+## 1b. Or phase by phase
+
+| phase | what it lands | verified by |
+|---|---|---|
+| `01-product` | the repository, created and linked; the brokered Cloudflare secrets; then the whole site in one PR — intent, CI, tooling, identity, `apps/web` (the site and its tests) | its commit validated and planned in the box (as the PR and as the merge), then merged; the convergence green (build, deploy, smoke) and both workers.dev URLs answering |
+| `03-docs` | `ai/context/deployment.md` from probed facts; prod's promotion gate and dev's push lanes restored | the render's own probes, recorded; the commit checked in the box and merged |
+
+```bash
+orun new --blueprint repo-blueprint.yaml --out ~/sites/acme-notes --run-hooks \
+ --phase 01-product --values ~/acme-notes.values.yaml
+# … then 03-docs
+```
+
+Every later phase reads the identity back from `.rebrand/values.json` in the
+placed tree, but the blueprint's **required** inputs — `reponame`,
+`productname`, `githuborg` — are validated before anything runs, so pass them
+every time (a `--values` file is easier). The domain is not one of them: the
+site goes live on workers.dev, and `productdomain` defaults to empty, which
+brands the reserved placeholder `.example.com` into `BASE_DOMAIN`
+for an owner to replace when they attach a domain (README, "Custom domain").
+Pass `--set productdomain=` only for a site that already has its domain.
+The full guide, one page per phase: [docs/phases/README.md](docs/phases/README.md).
+
+| flag | what it does |
+|---|---|
+| `--status` | derives and prints every phase's state and writes nothing. It parses the document, validates each hook against the action registry and compiles every template; it needs no credential and no network |
+| `--phase ` | places exactly that phase; its `requires.phases` still gates |
+| `--until ` | places every phase through that one and stops |
+
+What lands in the site is PRODUCT-ONLY: the app (its tests inside it), its
+CI, its tooling, its README and its two context pages. None of this
+repository's machinery (`.baseline/`, the blueprints, `tooling/rebrand`,
+`tooling/bootstrap`, `hooks/`, `testing/`, `docs/phases/`, `specs/`,
+`tasks/`, this file) ships, nor does `tooling/migrations` (the D1 manifest
+check for a database the site does not have). That promise is a test:
+`testing/leak.test.sh` derives what every phase would place and gates the
+set, and `testing/placement.test.sh` gates the same rules over a placed,
+branded tree.
+
+## 2. Headless / container mode
+
+The blueprint's source is this repository (`sources: [{kind: dir, path: .}]`),
+so the container contract is a shallow clone at a pinned tag plus two
+tokens:
+
+```bash
+export ORUN_TOKEN=… # orun auth, headless
+export GITHUB_TOKEN=… # fine-grained PAT (below)
+
+git clone --depth 1 --branch https://github.com/sourceplane/tanstack-start
+cd tanstack-start
+orun new --blueprint repo-blueprint.yaml \
+ --out /work/acme-notes --run-hooks --resume --progress json \
+ --values /work/acme-notes.values.yaml
+```
+
+| requirement | detail |
+|---|---|
+| `GITHUB_TOKEN` | fine-grained PAT: **read** on this repository; on the SITE's repository **contents write**, **pull-requests write**, **actions read+write** (`orun.run/watch@v1` resumes runs with `gh run rerun`), **checks read**; **repository create** on the owner if `01-product` creates it (or pre-create it — supported) |
+| classic token caveat | a classic PAT or gh OAuth token also needs the `workflow` scope to push `.github/workflows/` |
+| pinning | the clone's `--branch ` pins everything: the blueprint, its modules and its hooks' scripts all come from that one commit |
+
+## 3. After the site is live
+
+- **Write**: the pages are `apps/web/src/routes/` (TanStack Router writes
+ `src/routeTree.gen.ts` from them); the site's name is
+ `apps/web/src/lib/site.ts`. Every merge to `main` redeploys.
+- **The todos**: each visitor's list lives in their own httpOnly cookie
+ (`apps/web/src/data/todos.ts`), so the site depends on no third party. To
+ share a list across devices, swap the cookie for a KV namespace.
+- **Custom domain**: attach it to the Worker in Cloudflare, and replace the
+ placeholder `.example.com` in `intent.yaml`'s `BASE_DOMAIN` with
+ it (the site's README, "Custom domain"); nothing else changes, because the
+ site builds no absolute links. There is no domain phase: attaching a domain
+ needs zone permissions the brokered `workers-deploy` token does not carry.
+- **Refresh the record**: re-run `--phase 03-docs`; it is idempotent.
+
+## 4. Testing this baseline
+
+`.github/workflows/baseline.yml` runs three tiers on every pull request, and
+each runs locally the same way:
+
+```bash
+for t in manifest phases coverage rebrand retouch bootstrap-defer; do bash testing/$t.test.sh; done
+bash testing/leak.test.sh # needs orun
+bash testing/placement.test.sh # needs orun, node, pnpm: the offline bootstrap
+bash testing/e2e.test.sh # + network for pnpm: the site built, dry-deployed and served
+```
+
+The offline bootstrap (`testing/lib/bootstrap.sh`) places every phase in
+order and finishes each with the blueprint's OWN `run:` hooks — read out of
+`repo-blueprint.yaml`, not transcribed — so the rebrand, the re-tenant, the
+deferrals and their restore, the retouch marker and the deployment record
+all run exactly as a real bootstrap runs them. Only the
+platform's typed actions (task, repo, link, land, watch, probe, reconcile)
+are stood in for, a landing becoming a commit.
+
+## 5. Cutting a baseline tag (maintainers)
+
+Every site built from this repository resolves a `baseline-vN` tag, so the
+tag is cut by a workflow rather than by hand:
+
+```bash
+gh workflow run tag.yml -f version=baseline-v1 # from main
+gh workflow run tag.yml -f version=baseline-v1 -f ref=
+```
+
+It refuses a version that is not `baseline-v` and a tag that already
+exists: a baseline tag is never moved. Then move the registry row in
+orun-cloud's `infra/baselines-registry/baselines.yaml` by pull request —
+after the tag exists, because the registry's sync fetches `blueprint.yaml`
+at the tag and refuses the whole catalogue if it 404s.
+
+## Troubleshooting
+
+| Symptom | Cause → fix |
+|---|---|
+| `01-product` parks: `waiting for github for ` | the workspace's GitHub connection is to another account. Connect the App installation on `` (console → Integrations → GitHub), then `--resume` |
+| `01-product` stops at `link` | the repository is not linked to the workspace and the credential cannot link it. Allow-list it (console → Settings → Git repos) and re-run the phase |
+| `01-product` waits on the `providers` probe, then stops | Cloudflare is not connected. Connect it (console → Integrations), then re-run the phase — the probe is a wait, not a failure |
+| Secret WRITE fails `not_found` while listings work | the API key's role is below admin; re-mint it with the admin role |
+| Deploy lane: Authentication error (10000) | the connection's token lacks Workers Scripts Write; re-issue it, re-connect, re-run `01-product` |
+| `land` stops: `the landing's own check failed — orun plan for …` | the site's tree does not plan — the line after it is orun's own error (an unknown component type, a composition that does not resolve). Nothing was pushed. Fix the tree (or the baseline) and re-run the phase |
+| `land` waits on CI after all | the site's repository requires a status check on `main` (branch protection or a ruleset), so GitHub refused the early merge; the landing waits for the check as a `checks: ci` landing would, then merges |
+| Convergence failed AFTER the PR merged; re-running lands nothing | expected on its own — the files are on main. Re-run the phase (`--phase 01-product`, `--redo 01-product`, or the console's Retry): its `retouch` hook gives the landing a diff and the site redeploys |
+| The site's `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace; set it and re-run `01-product` |
+| A bootstrap stopped before `03-docs`; prod no longer waits on stage | the gate is deferred, not dropped: run `03-docs`, or `node tooling/bootstrap/promotion.mjs --restore --file /intent.yaml` |
+| `✕ input "productname" is required` | all three required inputs (`reponame`, `productname`, `githuborg`) must be set on every invocation, single-phase ones included |
+| `unknown flag: --phase`, `has no parameter "checks"`, `has no parameter "secrets"` or another parse error in the blueprint | the CLI is below the v2.88.0 floor |
+| `01-product` lanes fail in `build-app` resolving a dependency | the site's intent no longer pins stack-tectonic 0.19.0. 0.20.0's lane-scoped install links each job's node_modules out of its staged tree; this site's Vite build has not been tried there, a Next.js sibling's did not build there, and the pin keeps the install the e2e tier proves. `intent.yaml` says why |
+| `01-product`'s convergence reported green, then `verify` got 404 from both URLs | a second workflow ran on the push to main and the watch took its run. Only `ci.yml` may run on a push to main, and a site carries no other workflow (`testing/coverage.test.sh` holds the rule); read the CI run on main for the real result |
diff --git a/README.md b/README.md
index 0480dc2..ff0b9af 100644
--- a/README.md
+++ b/README.md
@@ -5,17 +5,54 @@ Vercel's [TanStack Start template](https://github.com/vercel/vercel/tree/main/ex
the three SSR modes (full, data-only and SPA) — running on **Cloudflare
Workers + Static Assets** through
[Cloudflare's Vite plugin](https://developers.cloudflare.com/workers/vite-plugin/),
-TanStack Start's own Cloudflare target, deployed by
-[Orun](https://github.com/sourceplane/orun) to stage and prod on every merge.
-Packaging it as an Orun baseline is the next milestone (TS2).
+TanStack Start's own Cloudflare target, and packaged as an **Orun baseline**:
+one command takes a new site from nothing to live on stage and prod, in its
+own repository, under its own name.
Swapping Vercel's Nitro build for Cloudflare's Vite plugin is the port; the
todo list moving from a `todos.json` on the server's disk into the visitor's
own cookie, and TanStack Start's move from 1.133 to 1.169, are the rest of
-the diff, and every move is recorded. See
+the diff, and every move is recorded. What the baseline adds is everything
+needed to make a copy of it somebody else's — built the way
+[cirrus-baseline](https://github.com/sourceplane/cirrus-baseline) is. See
[`specs/epics/tanstack-start`](specs/epics/tanstack-start/README.md)
for the design, the milestones and the as-built status.
+## Instantiating a site
+
+```bash
+git clone --depth 1 --branch https://github.com/sourceplane/tanstack-start
+cd tanstack-start
+orun new --blueprint repo-blueprint.yaml --out ~/sites/acme-notes --run-hooks --resume \
+ --set reponame=acme-notes --set productname="Acme Notes" \
+ --set githuborg=acme-inc --set subdomain=
+```
+
+Or, once the platform's registry lists it, from the Orun console (Baselines →
+`tanstack-start` → Build). Two phases — `01-product` (the repository
+created, then the whole site in one pull request, deployed to stage and prod
+and smoke-tested) and `03-docs` (the live deployment recorded) — each landing
+one pull request in the new repository. **[BOOTSTRAP.md](BOOTSTRAP.md)** is
+the operator guide; [docs/phases/](docs/phases/README.md) has a page per
+phase.
+
+The new repository receives the **site only** — the app and its tests, its
+CI, its tooling, a README of its own and its operating contract — renamed
+throughout to the site's name, repository and Cloudflare Worker. None of this
+repository's machinery ships.
+
+| What makes it a baseline | Where |
+|---|---|
+| The console card (inputs, secrets, programme) | `blueprint.yaml` |
+| The build document (modules, phases, hooks) | `repo-blueprint.yaml` |
+| This tree's identity, and the bootstrap's task contracts | `.baseline/` |
+| The rename engine | `tooling/rebrand/rebrand.mjs` |
+| The bootstrap's helpers (deferrals, redeploy marker, work-tree strip) | `tooling/bootstrap/` |
+| The deployment-record renderer | `hooks/render-deployment-docs.sh` |
+| The site's README and context pack | `.baseline/product/README.md`, `ai/context/` |
+| The baseline's tests: contract, leak, offline bootstrap, end to end | `testing/`, `.github/workflows/baseline.yml` |
+| Cutting a `baseline-vN` tag | `.github/workflows/tag.yml` |
+
## What is here (the site)
| Surface | Where |
@@ -79,3 +116,5 @@ dry-run deploys of both upload the same modules.
| Workflow | What it runs | Ships to a site |
|---|---|---|
| `ci.yml` | the Orun pipeline, and the only workflow a site carries: `orun plan --changed`, then one job per lane. A pull request runs the verify lanes (the site built and dry-deployed per environment; they do not typecheck, lint or run the tests), except the bootstrap's own landings (`orun/BASE-*`), where `plan` alone is the check; a merge deploys stage → prod. It plans nothing while `intent.yaml` names the placeholder workspace `ws_CHANGE_ME`, as this repository does. A manual run (Orunbase's Deploy button, or Run workflow on `main`) plans the environment and components it names under the push-to-main trigger, so they deploy as a merge deploys them | yes |
+| `baseline.yml` | the baseline's own tiers: contract tests, the blueprint read by the pinned orun, the leak gate, the offline bootstrap, the site installed, type-checked, linted, tested, built, dry-deployed and served (`testing/e2e.test.sh`, before every tag) | no |
+| `tag.yml` | cuts a `baseline-vN` tag (manual) | no |
diff --git a/ai/context/current.md b/ai/context/current.md
new file mode 100644
index 0000000..194f693
--- /dev/null
+++ b/ai/context/current.md
@@ -0,0 +1,39 @@
+# tanstack-start — 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 site built from it; the
+two pages that do are [operations.md](operations.md) and
+[deployment.md](deployment.md).
+
+## What it is
+
+Vercel's TanStack Start template (the welcome page, a todo list read and
+changed by server functions, an API route, the three SSR modes) on TanStack
+Start 1.169, deployed as one Cloudflare Worker + Static Assets through
+Cloudflare's Vite plugin — TanStack Start's own Cloudflare target. The todos
+live in each visitor's own httpOnly cookie. Packaged as an Orun baseline:
+`orun new --blueprint repo-blueprint.yaml` builds a new site in its own
+repository and takes it to live on stage and prod in one landing
+(`01-product`), then records what went live (`03-docs`).
+
+## Release
+
+| | |
+|---|---|
+| Latest tag | `baseline-v1` (TS-3) |
+| Proven live | No. Everything short of the platform is proven offline in Baseline CI (risk TS-A). The card's 4 minutes is an estimate |
+
+## Where to read
+
+| Question | Page |
+|---|---|
+| What shipped, and every departure from upstream | `specs/epics/tanstack-start/IMPLEMENTATION-STATUS.md` |
+| Why it is built this way | [decisions.md](decisions.md), then `specs/epics/tanstack-start/design.md` |
+| What could still go wrong | [open-risks.md](open-risks.md), then `specs/epics/tanstack-start/risks-and-open-questions.md` |
+| How to instantiate it | `BOOTSTRAP.md`, `docs/phases/` |
+| What the component is | `apps/web/docs/` (generated; `python3 tooling/catalog/gen-component-docs.py`) |
+
+## Next
+
+1. Bootstrap one site from `baseline-v1` against a workspace and record its
+ timings in place of the estimate (closes TS-A).
diff --git a/ai/context/decisions.md b/ai/context/decisions.md
new file mode 100644
index 0000000..88e4a4f
--- /dev/null
+++ b/ai/context/decisions.md
@@ -0,0 +1,19 @@
+# tanstack-start — 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 | Cloudflare's Vite plugin (`@cloudflare/vite-plugin`), TanStack Start's documented Cloudflare target, replaces Nitro; the component deploys the Worker and assets it builds | The framework's own target; `vite dev` runs the server in workerd too | `specs/epics/tanstack-start/design.md` §2 |
+| 2 | TanStack Start 1.133 → 1.169 with Vite 8, `@vitejs/plugin-react` 6, vitest 5 | The current plugin and Start are what TanStack documents for Cloudflare; Start 1.169 requires Vite 8 | design.md §2 |
+| 3 | One `wrangler.jsonc`, describing the BUILT Worker for `wrangler deploy --config wrangler.jsonc`; `vite.config.ts` names the source entry | The deploy's explicit `--config` never reads the build's redirect, and `verify-structure` checks the config before the build; one file and a test beat two files | design.md §3, risks TS-B, TS-C |
+| 4 | The todos live in the visitor's own httpOnly cookie (50 × 100 characters, 3,800 encoded bytes), not `todos.json` | A Worker has no disk that outlives a request; no database is part of the template | design.md §2, risk TS-F |
+| 5 | Tests live in `apps/web` (vitest over the site's name and the todo store) | One component; nothing to place separately | `repo-blueprint.yaml` |
+| 6 | The site's name is one seam, `src/lib/site.ts`, read by the root route's `` | The rename rewrites one line, written so that any name stays a valid string | IMPLEMENTATION-STATUS |
+| 7 | The template's own `biome.json`, run as `biome lint`, and the code made to pass it (button types, keys, hook dependencies) | Upstream ships the config but never ran it; formatting stays upstream's | IMPLEMENTATION-STATUS |
+| 8 | The devtools stay in production, as upstream | The template's behaviour; removing them is one line for an owner | risk TS-E |
+| 9 | One landing (`01-product`) then the record (`03-docs`); every bootstrap landing is checked in the box (`checks: local`) | A landing has a fixed cost; the convergence on `main` builds and smoke-tests the site anyway | `repo-blueprint.yaml` |
+| 10 | stack-tectonic 0.19.0 | The layout the end-to-end tier proves; one job per lane gains nothing from a shared install | risk TS-H |
+| 11 | The workers.dev subdomain is read from the Cloudflare connection, and the console asks for no domain | It has one right answer; a domain is an owner's step after the site is live | `blueprint.yaml` |
diff --git a/ai/context/deployment.md b/ai/context/deployment.md
new file mode 100644
index 0000000..b6c61ac
--- /dev/null
+++ b/ai/context/deployment.md
@@ -0,0 +1,7 @@
+# tanstack-start — live deployment manifest
+
+> Not rendered yet. The bootstrap's `03-docs` phase probes every live URL and
+> regenerates this file from what answered — the workspace, the URLs and
+> their status, and the secrets the site uses, by name. Until then, nothing here
+> claims the site is live. The operating contract is
+> [operations.md](operations.md).
diff --git a/ai/context/open-risks.md b/ai/context/open-risks.md
new file mode 100644
index 0000000..0755300
--- /dev/null
+++ b/ai/context/open-risks.md
@@ -0,0 +1,16 @@
+# tanstack-start — open risks
+
+What is not yet proven or not yet decided. The full write-up of every risk,
+including the accepted ones, is
+`specs/epics/tanstack-start/risks-and-open-questions.md`; this page lists
+only what is still live, so it should be short.
+
+| ID | Risk | State | What closes it |
+|---|---|---|---|
+| TS-A | No live bootstrap yet: the repository created and linked, the Cloudflare token minted, a real `wrangler deploy` and the probes are unproven | OPEN | One bootstrap from `baseline-v1` against a workspace |
+
+Accepted, and worth knowing before you change them: TS-B (`wrangler.jsonc`
+is the built Worker, held to the Vite plugin's output by the end-to-end
+tier), TS-D (the end-to-end tier speaks the server-function protocol),
+TS-E (the devtools render in production, as upstream), TS-F (the todos are
+per visitor).
diff --git a/ai/context/operations.md b/ai/context/operations.md
new file mode 100644
index 0000000..ababc51
--- /dev/null
+++ b/ai/context/operations.md
@@ -0,0 +1,117 @@
+# tanstack-start — operating contract (for humans and agents)
+
+This is the standing guide to how this site is deployed and operated.
+Instance facts (live URLs, workspace, the secrets it uses) live in
+[deployment.md](deployment.md), rendered from probed reality by the
+bootstrap's `03-docs` phase; this file is the contract that stays true
+between deployments. It is written to give an agent with repository read
+access enough context to reason about and operate the site without any
+other source.
+
+## What this system is
+
+A TanStack Start site on Cloudflare alone, expressed as an Orun
+component-native desired-state repo.
+
+- **`apps/web`** — the site: TanStack Start built by Cloudflare's Vite plugin
+ (`@cloudflare/vite-plugin`) into one Worker (`dist/server/index.js` and its
+ chunks) plus Static Assets (`dist/client`: the hashed JS and CSS, and
+ `public/`). The Worker renders every page, runs the server functions
+ (`/_serverFn/…`, which refuse a request from another origin) and the API
+ route (`/demo/api/names`), and answers an unknown path with TanStack
+ Router's not-found page and a 404. The server-functions demo keeps each
+ visitor's todos in their own httpOnly cookie (`src/data/todos.ts`: JSON,
+ capped at 50 todos of 100 characters and refused past ~3.8 KB). There is
+ no database, no third-party service and no runtime secret. The site's
+ tests (vitest) live in `apps/web` and run with `pnpm test` — by hand,
+ before a push: `ci.yml`'s lanes do not lint or run them.
+- **`tooling/*`** — shared TypeScript and ESLint configuration, and the
+ deploy-time wrangler renderer for workers that take wiring.
+
+Environments: **`stage`** and **`prod`** are deployed; **`dev` is
+verify-only by design** — lanes build and dry-deploy, nothing deploys.
+
+## Identity and tenancy
+
+Every remote operation runs against ONE Orun workspace, declared in
+`intent.yaml` under `execution.state.workspace` — committed, enforced, and
+what CI uses. Do not remove it; headless credentials depend on it. If it
+reads `ws_SET_ME`, the bootstrap had no workspace to write: set the real one
+before anything else.
+
+## How deployment works
+
+1. Merge (or push) to `main`.
+2. CI (`.github/workflows/ci.yml`) runs `orun plan --changed` — only
+ components whose files changed are planned — then runs each planned lane
+ with `orun run --remote-state`, authenticated by GitHub OIDC (the
+ exchange resolves this repository's linked workspace server-side).
+3. `apps/web` builds once per environment (`vite build`; the Vite plugin
+ writes the Worker and the assets where `wrangler.jsonc`'s `main` and
+ `assets.directory` say), then `wrangler deploy --config wrangler.jsonc`
+ ships `tanstack-start-web-` and a smoke test fetches `/` (the nav
+ must be there), the API route (its JSON) and an unknown path (the
+ not-found page, with a 404).
+4. `prod` deploys after `stage` has converged on the same commit
+ (`environments.prod.promotion` in intent.yaml).
+5. **The convergence run is the deployment.** A green run means every
+ planned lane applied. Failed lanes are retried with
+ `gh run rerun --failed`, which resumes the same execution.
+
+Caveats that matter:
+
+- A push that touches no component files plans zero lanes — that run is
+ green and deployed nothing. Never treat "latest run green" as "site
+ converged"; probe the URLs instead.
+- A change to `intent.yaml`'s `environments` maps to no component and
+ redeploys nothing on its own. Land it with a change under `apps/web`.
+- A visitor's todos are theirs alone and live in their browser: clearing
+ cookies clears the list, and nothing server-side can read or restore it.
+
+## Secrets model
+
+- **Brokered provider secrets**: `CLOUDFLARE_API_TOKEN` (Workers deploy
+ scope) and `CLOUDFLARE_ACCOUNT_ID` — pointers minted per run from the
+ workspace's Cloudflare connection. No long-lived values at rest; nothing
+ to rotate by hand.
+- Inspect by NAME only: `orun secrets list --org --project` and
+ `--env stage|prod`. No tooling in this repository prints a secret value,
+ and no document in `ai/context/` may contain one.
+- The site needs no runtime secret and no build-time variable.
+
+## Verifying the system
+
+```bash
+# the site on each environment (also recorded, probed, in deployment.md)
+curl -s -o /dev/null -w '%{http_code}\n' https://tanstack-start-web-stage.your-workers-subdomain.workers.dev/
+curl -s https://tanstack-start-web-prod.your-workers-subdomain.workers.dev/demo/api/names
+
+# workspace readiness (integrations + repository link)
+orun integrations list --org --json && orun cloud check --org
+```
+
+## Common operations
+
+| task | how |
+|---|---|
+| change a page | edit `apps/web/src/routes/…`, merge |
+| rename the site | edit `SITE_NAME` in `apps/web/src/lib/site.ts`, merge |
+| deploy a change | merge to `main`; watch the run; failed lanes → `gh run rerun --failed` |
+| deploy by hand | Orunbase's Deploy button, or `gh workflow run ci.yml --ref main -f environment= [-f component=]` — the named components (blank: every one) run in that environment as a merge runs them; started off `main` it is refused |
+| redeploy without a change | edit the last line of `apps/web/component.yaml` (`# orun: redeploy `) and merge — it is a deploy trigger, nothing reads it |
+| serve a custom domain | attach it to the Worker in Cloudflare (README, "Custom domain"), then replace the placeholder `tanstack-start.example.com` in `intent.yaml`'s `BASE_DOMAIN` (dev, stage and prod) with it; nothing else changes |
+| share todos across devices | swap the cookie in `apps/web/src/routes/demo/start.server-funcs.tsx` (`readTodos`, `setCookie`) for a KV namespace bound in `wrangler.jsonc` |
+| add a runtime secret | `orun secrets set --org --env ` |
+| headless credentials | `ORUN_TOKEN` (workspace-scoped) + `GITHUB_TOKEN` |
+
+The deployment record is the bootstrap's `03-docs` phase. Re-running it (the
+Orun console's Retry on that phase, or `orun new … --phase 03-docs`)
+re-probes the URLs and re-renders [deployment.md](deployment.md); it is
+idempotent.
+
+## Evolution
+
+Structural changes (a second Worker, an API, a data store) follow the same
+contract that deployed the site: add a component under `apps/`, `infra/` or
+`packages/` with a `component.yaml`, land it as a pull request, and the
+convergence run applies it.
diff --git a/blueprint.yaml b/blueprint.yaml
new file mode 100644
index 0000000..358b5e0
--- /dev/null
+++ b/blueprint.yaml
@@ -0,0 +1,149 @@
+# The tanstack-start card: what the console's Blueprints page renders
+# and the platform's bootstrap door consumes.
+#
+# THIS FILE IS NOT THE BUILD. `spec.bootstrap.blueprint` names the build
+# document — `repo-blueprint.yaml`, whose phases a runner places. This card is
+# what an operator reads and fills in before pressing Build, and
+# `testing/manifest.test.sh` compares every list below to the document that
+# actually does the thing, not to a copy of itself.
+#
+# The division of labour with the registry is strict: the registry (orun-cloud
+# `infra/baselines-registry/baselines.yaml`) owns identity and commerce — id,
+# visibility, tier, the pinned tag. This file owns the build contract. Neither
+# restates the other, which is why there is no `tag` here: this file is
+# fetched AT the tag the registry pins.
+apiVersion: orun.io/v1
+kind: Blueprint
+metadata:
+ name: tanstack-start
+ displayName: TanStack Start — a TanStack Start site on Cloudflare Workers
+ description: >
+ Vercel's TanStack Start template as a product of its own: the welcome page,
+ a todo list kept by server functions in each visitor's own cookie, an API
+ route, and the three SSR modes (full, data-only and SPA), built by
+ Cloudflare's Vite plugin — TanStack Start's own Cloudflare target — into
+ one Worker with Static Assets, and CI that deploys it to stage and prod on
+ merge. One provider, one consent, one token, one landing. Live in about
+ four minutes.
+ tags: [tanstack, tanstack-start, react, vite, cloudflare, starter]
+spec:
+ source:
+ repo: sourceplane/tanstack-start
+ # No `tag`. The registry pins it; this file is fetched at it.
+
+ # ── What the operator reads first ────────────────────────────────────────
+ overview:
+ lede: >
+ A TanStack Start site on Cloudflare alone: every page rendered in the
+ Worker, server functions and API routes beside it, the browser's files
+ from Static Assets. Edit a route, merge, and the site is rebuilt and
+ deployed.
+ architecture:
+ - layer: Edge
+ items: [web]
+ - layer: Pages
+ items: [server-rendered routes, server functions and an API route]
+ - layer: Delivery
+ items: [GitHub Actions, "@cloudflare/vite-plugin"]
+ outcome:
+ - Live on stage and prod
+ - Every merge redeploys, smoke-tested
+ - Its own CI from the first phase
+
+ requires:
+ # Cloudflare is the only provider connection a bootstrap needs. GitHub
+ # arrives as the App installation plus the repo link, not as a
+ # connection row.
+ integrations: [github, cloudflare]
+ apiKeyRole: admin # secret writes need the admin floor
+
+ # Every input is collected by the console: keys are lowercase (the
+ # platform's reader refuses anything else), every one carries the `pattern`
+ # its value is checked against before Continue, and a value the console
+ # already holds says so with `from`. repo-blueprint.yaml declares the same
+ # names; `repoPrivate`, `orunWorkspace` and `epicSlug` are build inputs with
+ # defaults (or filled from the build's workspace) and are not asked.
+ #
+ # NOR IS THE DOMAIN. The site goes live on workers.dev, and a domain is an
+ # owner's step after the bootstrap: `productdomain` defaults to empty, the
+ # rebrand writes the reserved placeholder `.example.com` where
+ # the domain goes, and the site's README ("Custom domain") says how to set
+ # it. Nothing that needs a domain is removed — it waits for one.
+ inputs:
+ - key: reponame
+ label: Repo name
+ pattern: "^[a-z][a-z0-9-]{1,38}$"
+ # The operator picked the repository; its name IS this value.
+ from: repo.name
+ - key: productname
+ label: Site name
+ pattern: "^[A-Za-z0-9][A-Za-z0-9 .,'&-]{1,48}$"
+ help: The name visitors see — every page's title.
+ example: Acme Notes
+ - key: githuborg
+ label: GitHub organisation
+ pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$"
+ help: The GitHub org or user the site's repository is created under.
+ # DERIVED FROM THE CHOSEN REPOSITORY: its owner IS this value. Declared
+ # because repo-blueprint.yaml requires it — a build may declare more
+ # inputs than this card, but not require one nobody supplies.
+ from: repo.owner
+ - key: subdomain
+ label: workers.dev subdomain
+ pattern: "^[a-z0-9][a-z0-9-]{0,62}$"
+ help: The workers.dev subdomain of the Cloudflare account the site deploys into.
+ example: acme
+ # READ FROM THE CLOUDFLARE CONNECTION, not asked. The subdomain belongs
+ # to the account the same way its id does, and there is exactly one
+ # right answer — a typed one could only be wrong, and wrong showed up
+ # after deploy, in the deploy's smoke, 01-product's probes and the
+ # verify URL below. The integration reads it from Cloudflare at connect
+ # and on its hourly health check; the bootstrap door fills this input
+ # from the connection the build is BOUND to, the same one
+ # CLOUDFLARE_ACCOUNT_ID and the deploy token mint from, so all three
+ # name one account. The console renders no field for it, and an account
+ # with no workers.dev subdomain refuses the build at the door, naming
+ # the fix, before anything is created.
+ from: connection.cloudflare.workersSubdomain
+
+ # ── PREVIEW ONLY. repo-blueprint.yaml's `orun.integrations/reconcile@v1`
+ # hook mints these, brokered, during 01-product. ──────────────────────────
+ # Transcribed from that hook's own `secrets:` list (each key and its
+ # `template:`), so testing/manifest.test.sh compares this list to the
+ # document that mints them. The console renders them read-only: no
+ # credential is ever typed, shown or stored. Keys that already exist are
+ # kept.
+ secrets:
+ - key: CLOUDFLARE_API_TOKEN
+ provider: cloudflare
+ template: workers-deploy
+ why: Deploys the site's Worker and its static assets
+ - key: CLOUDFLARE_ACCOUNT_ID
+ provider: cloudflare
+ template: account-id
+ why: Connection fact, not a secret
+ fact: true
+
+ # ── PREVIEW ONLY. repo-blueprint.yaml's run-level `hooks.preInstantiate`
+ # opens these — the epic, every milestone in this order, every task — before
+ # the first phase places. Idempotent by identity, so a re-run finds what it
+ # made before.
+ programme:
+ epicSlug: tanstack-start-baselining # = repo-blueprint.yaml's `epicSlug` default
+ epicName: "TanStack Start baselining — {productname}"
+ milestones:
+ - name: 01-product
+ - name: 03-docs
+
+ bootstrap:
+ # THE BUILD DOCUMENT. There is no umbrella workflow and no agent brief:
+ # every phase is declared in it and orun runs it.
+ blueprint: repo-blueprint.yaml
+ # Summed from the phases' expectedMinutes (3 + 1). An estimate until a
+ # bootstrap of this shape measures it.
+ expectedMinutes: 4
+ tokenChannel: ORUN_TOKEN_FILE # how a runner hands over its refreshed token
+ verify:
+ urls:
+ - "https://{reponame}-web-{env}.{subdomain}.workers.dev"
+ envs: [stage, prod]
diff --git a/docs/phases/01-product.md b/docs/phases/01-product.md
new file mode 100644
index 0000000..3bd47b9
--- /dev/null
+++ b/docs/phases/01-product.md
@@ -0,0 +1,78 @@
+# 01-product — the site, built in one landing
+
+**Places** the whole tree: the root manifests (`intent.yaml`, `package.json`,
+the pnpm workspace and lockfile, `turbo.json`),
+`.github/workflows` (`ci.yml` — the baseline's own `baseline.yml` and
+`tag.yml` are ignored), the shared TypeScript/ESLint
+config and the wrangler renderer, the site's README and its two context
+pages, the identity file `.rebrand/values.json`, `.gitkeep` files for the
+four discovery roots, and `apps/web` — the TanStack Start site, its
+Cloudflare Vite plugin build, its deploy contract and its tests (vitest, run
+inside the app).
+
+**Requires** both connections live — GitHub (the App installation on
+`githuborg`) and Cloudflare — probed, waited for up to ten minutes each, so a
+consent can be clicked while it waits. The platform sees a pull request only
+through the installation on the account that owns the repository, so the
+probe runs before anything is created.
+
+## What runs
+
+The run's task set-up — the epic, both milestones, both tasks — runs in the
+background from the start (`background: true`), so every hook up to `task`
+runs beside it; `task` is the first that waits for it.
+
+| hook | what it does |
+|---|---|
+| `retouch` | the redeploy marker on `apps/web/component.yaml` (`.baseline/tasks/01-product.TaskContract.yaml`'s `affects`) |
+| `git-init`, `git-stage` | the rebrand enumerates with `git ls-files`, so the tree is a staged repo first |
+| `rebrand` | renames the baseline's identity to the site's over the whole tree (`tooling/rebrand/rebrand.mjs`) |
+| `orun-workspace` | writes the site's workspace into `intent.yaml` (`ws_SET_ME` if there is none — loud, not silent) |
+| `work-tree` | removes the baseline's own `work:` block from `intent.yaml` — `specs/` and `tasks/` do not ship |
+| `promotion` | defers prod's wait on stage until `03-docs` (both environments deploy side by side) |
+| `dev-lanes` | keeps dev's verify lanes off main's convergences until `03-docs` |
+| `git-restage`, `rebrand-verify` | refuses the landing if any baseline identity is left |
+| `repo` | `orun.repo/ensure@v1` — creates `githuborg/reponame` (private unless `repoPrivate=false`) |
+| `link` | `orun cloud link` (best effort) then `orun cloud check` — an unlinked repo stops here |
+| `secrets` | `orun.integrations/reconcile@v1`, both keys in one hook, created side by side: `CLOUDFLARE_API_TOKEN` from the `workers-deploy` template (Workers Scripts, the site's deploy); `CLOUDFLARE_ACCOUNT_ID`, the connection fact |
+| `task` | finds the phase's task (opened by the run-level list) and yields its key — waiting, if it must, for the background set-up |
+| `land` | one PR bound to the task, its commit checked in the box first (`checks: local`: `orun validate`, then `orun plan` as the PR and as the merge would plan it, under a second); merged without waiting for the PR's CI |
+| `converge` (await) | `orun.run/watch@v1` on the merge commit's run, read every 5 s; resumes it up to three times |
+| `verify` (await) | `orun.http/probe@v1` on both workers.dev URLs |
+
+## What the convergence does
+
+`orun plan --changed` plans `web` on stage and prod (deploy) and — dev's push
+activation being deferred — nothing on dev. Each deploy lane installs the
+workspace inside its own job tree, builds with `vite build` (Cloudflare's
+Vite plugin writes `dist/server/index.js` and its chunks, and the browser's
+files in `dist/client`, where `wrangler.jsonc`'s `main` and
+`assets.directory` say), checks the build output, deploys
+`-web-` with `wrangler deploy --config wrangler.jsonc`, and
+smoke-tests it: the home page must carry the nav's server-functions link,
+the API route must answer its JSON, and an unknown path must be TanStack
+Router's not-found page with a 404, rendered by the Worker. Stage and prod
+deploy side by side (this phase deferred the promotion gate).
+
+## Verified
+
+The repository exists and is linked to the workspace, the convergence run for
+the merge commit is green, and
+`https://-web-{stage,prod}..workers.dev` answer.
+
+## Troubleshooting
+
+| symptom | cause → fix |
+|---|---|
+| parks on `waiting for github for ` | the workspace's GitHub connection is to another account. Connect the App installation on `` (console → Integrations → GitHub), then `--resume` |
+| parks on the `providers` probe for cloudflare | Cloudflare is not connected to the workspace. Connect it (console → Integrations → Cloudflare, paste the Account API token) |
+| `link` fails: `… is not linked to workspace` | the credential cannot write links and the platform has not linked the repo. Allow-list it (console → Settings → Git repos) and re-run the phase |
+| `land`: `the landing's own check failed — orun plan for …` | the placed tree does not plan; the next line is orun's error. Nothing was pushed. Fix it and re-run the phase |
+| `rebrand-verify` lists leftovers | a file carries an identity form no rule renames. Add a rule to `tooling/rebrand/rebrand.mjs` (and a case to `testing/rebrand.test.sh`) |
+| `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace. Set it and re-run |
+| deploy lane: `secret resolution failed … CLOUDFLARE_API_TOKEN` | the reconcile did not run or minted against a revoked connection. Re-connect and re-run the phase; the reconcile re-mints only what is missing |
+| deploy lane: Authentication error (10000) | the connection's token lacks Workers Scripts Write. Re-issue it with the permission groups the console's Connect recipe lists |
+| smoke fails right after the FIRST deploy | workers.dev route propagation; the composition retries the first deploy and the smoke with backoff (stack-tectonic ≥ 0.19.0). A convergence resume clears what is left |
+| `build-app` fails resolving a dependency, or `wrangler` is not found | the job's install did not run inside its tree. The site's `intent.yaml` pins stack-tectonic 0.19.0, where it does; a bump changes the install's layout — `intent.yaml`'s comment says why it is pinned |
+| the watch says green, the probe says 404 | another workflow ran on the push and the watch took its run. Only `ci.yml` may run on a push to main |
+| re-run lands nothing | the hooks did not run (`--run-hooks`), or the contract names no component — `node tooling/bootstrap/retouch.mjs --check --affects .baseline/tasks/01-product.TaskContract.yaml` in the site's tree says which |
diff --git a/docs/phases/03-docs.md b/docs/phases/03-docs.md
new file mode 100644
index 0000000..cabe694
--- /dev/null
+++ b/docs/phases/03-docs.md
@@ -0,0 +1,39 @@
+# 03-docs — the deployment, recorded
+
+**Places** nothing. Its work is hooks: it records what `01-product` built, from
+probed facts rather than from what the blueprint intended, and it puts back
+the two things `01-product` deferred for the bootstrap's sake.
+
+**Requires** `01-product` placed. (A hook-only phase derives as `unknown`, so no
+phase may require this one.)
+
+## What runs
+
+| hook | what it does |
+|---|---|
+| `promotion` | restores `environments.prod.promotion` — from now on prod deploys only after stage |
+| `dev-lanes` | restores dev's activation on pushes to main |
+| `render` | `hooks/render-deployment-docs.sh`: probes `/`, `/demo/start/server-funcs` and `/demo/api/names` on both environments and regenerates `ai/context/deployment.md` — the identity, the probed URLs, the secrets the deployment uses by name — and the README's live-deployment section. It asks the platform nothing: what the workspace holds right now is on the console's Secrets and Integrations pages, which the record points to |
+| `task` | finds the phase's task and yields its key |
+| `land` | one PR, its commit checked in the box (`checks: local`) and merged. It touches no component, so it deploys nothing — and there is nothing after it to wait for: the render's probes are the phase's check |
+
+## Re-running it
+
+Idempotent, and the way to refresh the record after a redeploy: every
+generated section is re-rendered from scratch.
+
+```bash
+orun new --blueprint repo-blueprint.yaml --out \
+ --run-hooks --phase 03-docs --values
+```
+
+## If a bootstrap stops before this phase
+
+The promotion gate and dev's push activation stay deferred: `intent.yaml`
+carries a `# @promotion-deferred:…` and a `# @dev-lanes-deferred:…` marker.
+Running this phase restores both, or by hand from the baseline checkout:
+
+```bash
+node tooling/bootstrap/promotion.mjs --restore --file /intent.yaml
+node tooling/bootstrap/dev-lanes.mjs --restore --file /intent.yaml
+```
diff --git a/docs/phases/README.md b/docs/phases/README.md
new file mode 100644
index 0000000..e7a0c1b
--- /dev/null
+++ b/docs/phases/README.md
@@ -0,0 +1,118 @@
+# The phases — one blueprint, two selections
+
+`repo-blueprint.yaml` declares two phases that take a site from **nothing**
+to **live on stage and prod, documented**: one landing builds the whole site,
+one records it. Run them one at a time with
+`--phase `, or the whole sequence unattended with `--resume`. There is
+no umbrella workflow and no per-phase document: a phase is a selection on one
+artifact, which is what makes running one alone, months later, from a fresh
+container the same operation as running them all.
+
+The site phase follows the contract every deploying phase does:
+
+> **place its modules → brand them → check them in the box and land them as
+> one pull request → watch the convergence that merge triggers
+> (auto-resumed) → verify the outcome over HTTP.**
+
+The run's task set-up — the epic, a milestone per phase, a task per landing
+— runs in the background from the start; the first hook that needs it, the
+phase's `task`, waits for it.
+
+Run from the baseline checkout (the blueprint's source is `path: .`); the
+site's repository is wherever `--out` points.
+
+## Execution order
+
+The phase number is the EXECUTION order, and each phase's `requires.phases`
+states it in the document: the engine refuses a phase whose predecessor is not
+placed, and names it.
+
+Every landing is a pull request on a branch named for its task
+(`orun/BASE--`), checked before it is pushed: `orun validate`, then
+`orun plan` as the pull request and as the merge would plan it, in the box,
+in under a second (`checks: local`). Then it merges; nothing waits for the
+PR's CI. On those branches `ci.yml` runs `plan` only and skips the lanes,
+because the merge runs them on main a minute later, for real, and that
+convergence is what the phase watches. The site carries no other workflow:
+the baseline's own CI (Tier 2) installs, renders the fixtures, type-checks,
+lints, tests and builds this tree before a tag is cut, and every later pull
+request in the site runs `ci.yml`'s verify lanes (built and dry-deployed per
+environment; they do not lint or run the tests).
+
+| phase | lands | verified by |
+|---|---|---|
+| [`01-product`](01-product.md) | **the GitHub repo created**, then the WHOLE site in one PR: intent, CI, tooling, identity, `apps/web` (the site and its tests) — one convergence deploys it to stage and prod side by side | repo workspace-linked, convergence green (build, deploy, smoke) + both URLs answer |
+| [`03-docs`](03-docs.md) | the live-deployment record; the promotion gate and dev lanes put back | committed manifest matches probed reality |
+
+There is no custom-domain phase. Attaching a domain to a Worker needs zone
+permissions the platform's brokered `workers-deploy` token does not carry, so
+it is an owner's step after the bootstrap — the site's README, "Custom
+domain", says how. Nothing else in the repository changes with it — the site
+builds no absolute links — beyond `BASE_DOMAIN` in `intent.yaml`, which holds
+the placeholder until then.
+
+## Inputs
+
+`01-product` takes the site's identity once and writes it into the repo
+(`.rebrand/values.json`); every later phase reads it back from the placed
+tree. But the blueprint's **required** inputs — `reponame`, `productname`,
+`githuborg` — are validated before any phase runs, so they must be supplied
+on every invocation, single-phase ones included. A `--values` file is easier
+than repeating `--set`.
+
+- `productdomain` — NOT ASKED, default empty. The site goes live on
+ workers.dev; empty brands the reserved placeholder `.example.com`
+ into `BASE_DOMAIN`, for an owner to replace when they attach a domain (the
+ site's README, "Custom domain"). Pass it only for a site that already has
+ its domain.
+
+- `subdomain` — the workers.dev subdomain of the Cloudflare account you
+ deploy into. It is in every URL the phases probe and the deploy's smoke
+ fetches. 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.
+- `epicSlug` (default `tanstack-start-baselining`) — the epic every phase clubs
+ its task under. Found by slug, so a fresh run and a resumed run find the
+ same work.
+- `repoPrivate` (default `true`) — the repository's visibility at creation.
+
+```bash
+orun new --blueprint repo-blueprint.yaml \
+ --out $HOME/sites/acme-notes --run-hooks --phase 01-product \
+ --values ~/acme-notes.values.yaml
+```
+
+Drop `--run-hooks` (or add `--status`) to preview. Without it a phase places
+files and stops: no repo, no landing, no convergence watch, and no probe —
+which is exactly what makes a dry instantiation of this baseline possible in
+CI with no workspace and no provider (`testing/placement.test.sh`,
+`testing/e2e.test.sh`).
+
+## What 01-product does after it places
+
+Placement writes the baseline's files as they are here. Before the phase
+lands, its `post` hooks make them the site's:
+
+1. `retouch` — one `# orun: redeploy ` line
+ at the end of each component.yaml its task contract names, so a re-run
+ after a failed convergence still has a diff to land and redeploys exactly
+ those components.
+2. `rebrand` → `rebrand --verify` — the identity rename over the whole tree,
+ then a sweep that fails on any of this baseline's identity left behind.
+
+The baseline's complete lockfile ships as it is: it carries no identity, and
+the lanes install it with `--frozen-lockfile`, as the baseline's own CI does
+on this exact tree before a tag.
+
+## When a phase fails
+
+- **Before it lands** (a probe that timed out, a rebrand residue, a refused
+ link, a tree the landing's own `orun plan` refuses): nothing was merged.
+ Fix what the message names and re-run the phase.
+- **After it lands** (the convergence went red): the files are on main.
+ `orun.run/watch@v1` has already resumed the run up to three times. Re-run
+ the phase (`--phase 01-product`, `--redo 01-product` under `--resume`, or the
+ console's Retry): its `retouch` hook gives the landing a diff and the
+ component redeploys.
diff --git a/hooks/render-deployment-docs.sh b/hooks/render-deployment-docs.sh
new file mode 100755
index 0000000..2ae55de
--- /dev/null
+++ b/hooks/render-deployment-docs.sh
@@ -0,0 +1,150 @@
+#!/usr/bin/env bash
+# Render the site's LIVE-DEPLOYMENT documentation from verified state.
+# Called by phase 03-docs as a `run:` hook (and safe to run by hand, from the
+# site's checkout). Idempotent: the generated file and the README section are
+# fully re-rendered on every run, so re-running after a redeploy or a custom
+# domain refreshes them.
+#
+# hooks/render-deployment-docs.sh
+#
+# What it writes (in ):
+# ai/context/deployment.md — REGENERATED: URLs with live probe results,
+# identity, and the secrets the deployment
+# uses BY NAME
+# ai/context/operations.md — healed from the baseline's copy if absent
+# (the static operating contract; never rewritten)
+# README.md — the section between
+# is replaced (appended after the title if the
+# README predates the markers)
+#
+# No secret VALUE is ever read or written here — secrets are named, not read.
+#
+# IT ASKS THE PLATFORM NOTHING. The record used to carry the workspace's slug,
+# its secrets listed per rung and its integrations — five CLI calls, one after
+# another, from the build box — and all of it is what the console shows live
+# and this file could only show as it was the day it was written. The record
+# keeps what the repository is the right place for: the identity the code
+# names, what answered at the URLs, and where to look for the rest.
+set -euo pipefail
+
+out="${1:?usage: render-deployment-docs.sh }"
+ws="${2:-}"
+L="${3:?usage: render-deployment-docs.sh }"
+
+cd "$out"
+vals=".rebrand/values.json"
+[ -f "$vals" ] || { echo "render-docs: $vals missing — is this a scaffolded site?" >&2; exit 1; }
+val() { python3 -c "import json,sys;print(json.load(open('$vals')).get(sys.argv[1],'') or '')" "$1"; }
+
+repo="$(val reponame)"
+brand="$(val brandSlug)"; [ -n "$brand" ] || brand="$repo"
+sub="$(val subdomain)"; [ -n "$sub" ] || sub="your-workers-subdomain"
+[ -n "$ws" ] || ws="$(sed -n 's/^[[:space:]]*workspace:[[:space:]]*\([^[:space:]#]*\).*/\1/p' intent.yaml | head -1)"
+[ -n "$ws" ] || ws="?"
+
+# CI lane pin (what version the deploy lanes run).
+lanepin="$(sed -n 's/^ *version: *\(v[0-9.]*\) *$/\1/p' .github/workflows/ci.yml 2>/dev/null | head -1)"
+[ -n "$lanepin" ] || lanepin="?"
+
+# curl emits the -w format even on connection failure (000) — capture, don't
+# append, or a failed probe reads "000000".
+probe() { local c; c="$(curl -s -o /dev/null -w '%{http_code}' --max-time 20 "$1" 2>/dev/null)" || true; printf '%s' "${c:-000}"; }
+badge() { case "$1" in 2*|3*) echo "LIVE ($1)" ;; 000) echo "unreachable" ;; *) echo "answering $1" ;; esac; }
+
+# The Worker's workers.dev URL per environment. The site builds no absolute
+# links, so a custom domain attached in Cloudflare serves the same Worker with
+# nothing in the repository naming it; the record probes what the repository
+# can name.
+stage_dev="https://${brand}-web-stage.${sub}.workers.dev"
+prod_dev="https://${brand}-web-prod.${sub}.workers.dev"
+
+# Every page is rendered by the Worker: the home page, the server-functions
+# demo (its loader, the visitor's cookie) and the API route beside them.
+rows=""
+for pair in "stage|$stage_dev" "prod|$prod_dev"; do
+ env="${pair%%|*}"; url="${pair#*|}"
+ rows+="| site (${env}) | ${url} | $(badge "$(probe "$url/")") |"$'\n'
+ rows+="| server functions (${env}) | ${url}/demo/start/server-funcs | $(badge "$(probe "$url/demo/start/server-funcs")") |"$'\n'
+ rows+="| API route (${env}) | ${url}/demo/api/names | $(badge "$(probe "$url/demo/api/names")") |"$'\n'
+done
+
+now="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
+
+# Heal the static operating contract when the site predates it.
+mkdir -p ai/context
+if [ ! -f ai/context/operations.md ] && [ -f "$L/ai/context/operations.md" ]; then
+ cp "$L/ai/context/operations.md" ai/context/operations.md
+ git add ai/context/operations.md 2>/dev/null || true
+ node "$L/tooling/rebrand/rebrand.mjs" --values "$vals" --allow-dirty >/dev/null 2>&1 || true
+ echo "render-docs: healed ai/context/operations.md"
+fi
+
+cat > ai/context/deployment.md < GENERATED by the \`03-docs\` phase on ${now}; re-run it to refresh
+> (idempotent; see [operations.md](operations.md)). Hand-edits here are
+> overwritten. No secret values appear in this file — secrets are named only.
+
+## Identity
+
+| | |
+|---|---|
+| repository / project slug | \`${repo}\` |
+| Orun workspace | \`${ws}\` |
+| declared in | \`intent.yaml\` → \`execution.state.workspace\` |
+| Workers | \`${brand}-web-stage\`, \`${brand}-web-prod\` on \`${sub}.workers.dev\` |
+| CI lane CLI pin | orun \`${lanepin}\` (\`.github/workflows/ci.yml\`) |
+
+## Public URLs (probed ${now})
+
+| surface | URL | status |
+|---|---|---|
+${rows}
+The \`dev\` environment is verify-only by design — no deployed URL. A custom
+domain attached to a Worker in Cloudflare serves the same site (README,
+"Custom domain").
+
+## Secrets (names only)
+
+| secret | where | what it is |
+|---|---|---|
+| \`CLOUDFLARE_API_TOKEN\` | the workspace | BROKERED from its Cloudflare connection (\`workers-deploy\`): deploys the Worker and its static assets |
+| \`CLOUDFLARE_ACCOUNT_ID\` | the workspace | the connection's account id — a fact, not a credential |
+
+The site needs no runtime secret. Brokered secrets are minted per run, so no
+long-lived value is at rest. What the workspace holds right now (every
+secret by name, and its integrations and their health) is on the console's
+Secrets and Integrations pages for \`${ws}\`.
+
+## How this deployment changes
+
+Merges to \`main\` converge automatically: CI plans the changed components and
+runs each lane with \`orun run --remote-state\` against the workspace above.
+See [operations.md](operations.md) for the full operating contract.
+EOF
+echo "render-docs: wrote ai/context/deployment.md"
+
+python3 - <<'PY'
+import re
+begin, end = "", ""
+body = f"""{begin}
+This site is **live**. Verified URLs, identity and the secrets it uses are
+recorded in [ai/context/deployment.md](ai/context/deployment.md) (re-rendered
+by the `03-docs` phase); how it deploys and how to operate it:
+[ai/context/operations.md](ai/context/operations.md).
+{end}"""
+s = open("README.md").read()
+if begin in s and end in s:
+ s = re.sub(re.escape(begin) + r".*?" + re.escape(end), lambda _m: body, s, count=1, flags=re.S)
+else:
+ lines = s.splitlines(keepends=True)
+ at = 1
+ while at < len(lines) and lines[at].strip() == "":
+ at += 1
+ lines.insert(at, f"\n## Live deployment\n\n{body}\n")
+ s = "".join(lines)
+open("README.md", "w").write(s)
+print("render-docs: README live-deployment section rendered")
+PY
+echo "render-docs: done"
diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml
new file mode 100644
index 0000000..6894ff3
--- /dev/null
+++ b/repo-blueprint.yaml
@@ -0,0 +1,657 @@
+apiVersion: orun.dev/v1
+kind: Blueprint
+metadata:
+ name: tanstack-start
+ description: >-
+ The TanStack Start template as a Blueprint of itself — instantiate a new
+ TanStack Start site repository (the welcome page, a todo list kept by
+ server functions in each visitor's cookie, an API route and the three SSR
+ modes, built by Cloudflare's Vite plugin onto Cloudflare Workers + Static
+ Assets) and
+ take it from nothing to live on stage and prod in one landing, then record
+ it. Run one at a time with `--phase ` or the whole sequence with
+ `--resume`; see docs/phases/README.md for the contract every phase
+ follows, and BOOTSTRAP.md for the operator checklist no script can
+ perform.
+
+# ── INPUTS ────────────────────────────────────────────────────────────────
+# The instance-identity contract, consumed by tooling/rebrand/rebrand.mjs via
+# the `.rebrand/values.json` the `rebrand-values` module templates. Every
+# input a later phase needs is in that file, because it is committed and so
+# survives a fresh container; `.orun/provenance.lock` does not.
+#
+# The card (blueprint.yaml) declares a subset of these with the patterns the
+# console validates; testing/manifest.test.sh fails if a card input is not
+# one of these, or if one of these is required and nothing supplies it.
+inputs:
+ reponame:
+ type: string
+ pattern: "^[a-z][a-z0-9-]*$"
+ required: true
+ description: Repo slug (e.g. acme-notes) — intent metadata.name, the Worker name prefix, the secret project.
+ productname:
+ type: string
+ required: true
+ description: The site's display name (e.g. "Acme Notes") — every page's title.
+ productdomain:
+ type: string
+ default: ""
+ description: >-
+ The site's own domain, once it has one (e.g. acme.dev). NOT ASKED: the
+ site answers on workers.dev from its first deploy, and a domain is an
+ owner's step after it. Empty, the rebrand writes the reserved
+ placeholder `.example.com` where the domain goes (BASE_DOMAIN
+ in intent.yaml, for dev, stage and prod), so setting it later is
+ replacing that one string — the site's README, "Custom domain", says
+ how. Pass it with --set only to brand a hand-run build with a domain it
+ already has.
+ githuborg:
+ type: string
+ pattern: "^[A-Za-z0-9][A-Za-z0-9-]*$"
+ required: true
+ description: >-
+ GitHub owner the site's repository is created under — and the owner in
+ the source link the site's nav carries. 01-product waits for the App
+ installation on THIS owner before it creates anything: the platform
+ learns of a pull request only through the installation on the account
+ that owns the repository.
+ subdomain:
+ type: string
+ default: "your-workers-subdomain"
+ description: >-
+ The workers.dev subdomain of the Cloudflare account the site deploys
+ into — its URLs, the smoke, the probes. A console or `--from bst_…`
+ build gets it from the workspace's Cloudflare connection
+ (blueprint.yaml declares `from: connection.cloudflare.workersSubdomain`);
+ pass it with --set only for a hand-run build.
+ repoPrivate:
+ type: boolean
+ default: true
+ description: >-
+ Whether the repository is created private. Private is the safe default;
+ `orun.repo/ensure@v1` only sets it at creation — an existing repository
+ keeps the visibility it has.
+ orunWorkspace:
+ type: string
+ default: ""
+ # Unset, it is the workspace the build runs in (ORUN_WORKSPACE — which a
+ # console build's sandbox always sets, and which the console form cannot
+ # send). A value set on the command line or recorded by the tree wins.
+ from: workspace
+ description: >-
+ Orun Cloud workspace (ws_…) for the site's remote state. Unset, it is
+ the workspace the build runs in; with none anywhere, 01-product writes
+ a placeholder that fails loudly rather than silently claiming another
+ tenant's workspace.
+ epicSlug:
+ type: string
+ pattern: "^[a-z][a-z0-9-]*$"
+ default: tanstack-start-baselining
+ description: >-
+ The epic this bootstrap tracks itself under. Found by slug, so a run
+ that starts fresh and a run that resumes find the same work.
+
+# ── SOURCES ───────────────────────────────────────────────────────────────
+# The baseline is this repository itself. Run `orun new` from its root so
+# `path: .` resolves to it; orun pins it by digest into its object store
+# before any module reads it, so an instance is reproducible and provenanced.
+sources:
+ - name: baseline
+ kind: dir
+ path: .
+
+# Derived build output, local secrets, and the factory's own lanes — never
+# carried into an instance.
+#
+# WHAT `ignore` ACTUALLY EXCLUDES: orun matches an entry two ways, and which
+# one depends on the entry. A pattern with no glob metacharacter is compared
+# against each path SEGMENT; only a pattern containing one is compared against
+# the whole relative path. So `apps/web/.env.local` on its own would match
+# nothing — it needs the `**/`. testing/coverage.test.sh refuses an entry that
+# names a path without a glob.
+ignore:
+ - dist
+ - coverage
+ - .turbo
+ - .tanstack
+ - .wrangler
+ - node_modules
+ - .orun
+ - plan.json
+ - "**/*.tsbuildinfo"
+ # `orun new` snapshots the WORKING TREE, not the git index: an operator's
+ # local environment files would otherwise be copied into somebody else's
+ # repository. `.env.example` is not among them, and ships.
+ - "**/.env"
+ - "**/.env.local"
+ - "**/.env.*.local"
+ - "**/.dev.vars"
+ - "**/.dev.vars.*"
+ # THE FACTORY'S OWN LANES. `github-workflows` copies the whole of `.github`,
+ # so without these two entries every site built from this baseline would
+ # carry them — `baseline.yml` runs `testing/*.sh`, which no module places,
+ # and `tag.yml` cuts baseline tags a site does not have.
+ # testing/coverage.test.sh fails if a lane reading `testing/` is not here.
+ - "**/.github/workflows/baseline.yml"
+ - "**/.github/workflows/tag.yml"
+
+# ── MODULES ───────────────────────────────────────────────────────────────
+# One module per component or root file. Root files are single-file modules
+# rather than one module with an include list: a file shipping to a product
+# is a line in a diff, and nothing of the factory (specs/, tasks/, testing/,
+# hooks/, docs/phases/, tooling/rebrand/, tooling/bootstrap/, the blueprints,
+# BOOTSTRAP.md) can ship by accident. testing/leak.test.sh holds that line.
+modules:
+ # ── the identity file every later phase reads back ───────────────────────
+ # The only place blueprint inputs touch the tree; everything else is a
+ # verbatim copy the `rebrand` hook rewrites. Committed, so a phase run months
+ # later from a fresh container recovers what the operator answered.
+ - name: rebrand-values
+ mode: template
+ files:
+ ".rebrand/values.json": |
+ {
+ "reponame": "{{ .reponame }}",
+ "productname": "{{ .productname }}",
+ "productdomain": "{{ .productdomain }}",
+ "subdomain": "{{ .subdomain }}",
+ "orunWorkspace": "{{ .orunWorkspace }}",
+ "githuborg": "{{ .githuborg }}",
+ "epicSlug": "{{ .epicSlug }}"
+ }
+
+ # ── root files ───────────────────────────────────────────────────────────
+ - name: root-intent
+ mode: copy
+ source: baseline
+ from: intent.yaml
+ to: intent.yaml
+ - name: root-package-json
+ mode: copy
+ source: baseline
+ from: package.json
+ to: package.json
+ - name: root-pnpm-workspace
+ mode: copy
+ source: baseline
+ from: pnpm-workspace.yaml
+ to: pnpm-workspace.yaml
+ # The baseline's complete lockfile, as it is: the whole tree lands at once
+ # and the lockfile carries no identity, so there is nothing to re-resolve —
+ # the lanes install it with --frozen-lockfile, and the baseline's own CI
+ # (testing/e2e.test.sh) does the same on this exact tree before a tag.
+ - name: root-pnpm-lock
+ mode: copy
+ source: baseline
+ from: pnpm-lock.yaml
+ to: pnpm-lock.yaml
+ - name: root-turbo
+ mode: copy
+ source: baseline
+ from: turbo.json
+ to: turbo.json
+ - name: root-gitignore
+ mode: copy
+ source: baseline
+ from: .gitignore
+ to: .gitignore
+ # The SITE's README, not this repository's: this one is about the baseline
+ # (how to instantiate it, how it is tested), and a site's owner has no use
+ # for any of that.
+ - name: root-readme
+ mode: copy
+ source: baseline
+ from: .baseline/product/README.md
+ to: README.md
+ - name: github-workflows
+ mode: copy
+ source: baseline
+ from: .github
+ to: .github
+ - name: vscode
+ mode: copy
+ source: baseline
+ from: .vscode
+ to: .vscode
+
+ # The two context pages a site genuinely owns: its operating contract, and
+ # the deployment manifest 03-docs renders. One module per file, so a new
+ # file in ai/context/ cannot ship without somebody writing a module for it.
+ - name: ai-operations
+ mode: copy
+ source: baseline
+ from: ai/context/operations.md
+ to: ai/context/operations.md
+ - name: ai-deployment
+ mode: copy
+ source: baseline
+ from: ai/context/deployment.md
+ to: ai/context/deployment.md
+
+ # ── the empty discovery roots, declared ──────────────────────────────────
+ # orun's repo-scale gate — and later `orun plan` in the site's own CI —
+ # discovers apps/, infra/, packages/ and tests/, and a missing root is a
+ # hard failure. The site fills apps/ in the same landing; the other three
+ # stay empty (the site's test runs inside apps/web). A file the tree needs
+ # in order to be valid is what a module is for.
+ - name: discovery-roots
+ mode: template
+ files:
+ "apps/.gitkeep": ""
+ "infra/.gitkeep": ""
+ "packages/.gitkeep": ""
+ "tests/.gitkeep": ""
+
+ # ── shared tooling ───────────────────────────────────────────────────────
+ # The workspace's shared packages: the TypeScript and ESLint configuration
+ # (both pnpm workspace projects, so the lockfile names them) and the
+ # deploy-time wrangler renderer. The factory's tooling (rebrand, bootstrap)
+ # stays here, and so does `tooling/migrations`: it checks the D1 migration
+ # manifest of a `packages/db` this site does not have, and nothing a site
+ # runs reads it.
+ - name: tooling-tsconfig
+ mode: copy
+ source: baseline
+ from: tooling/tsconfig
+ to: tooling/tsconfig
+ - name: tooling-eslint
+ mode: copy
+ source: baseline
+ from: tooling/eslint
+ to: tooling/eslint
+ - name: tooling-wire
+ mode: copy
+ source: baseline
+ from: tooling/wire
+ to: tooling/wire
+
+ # ── the site ─────────────────────────────────────────────────────────────
+ # One component: the app carries its own tests (vitest over the site's
+ # modules, beside the code they test, in apps/web), and there is no
+ # separate test package to place.
+ - name: web
+ mode: copy
+ source: baseline
+ from: apps/web
+ to: apps/web
+
+# ── THE WORK, UP FRONT ────────────────────────────────────────────────────
+# The bootstrap is work, so it lives where work lives — and all of it is on
+# the plane before the first phase places a file: one epic, one milestone per
+# phase in the order the phases run, one task per landing.
+#
+# `hooks.preInstantiate` (orun >= v2.60) runs under no phase, once per run, on
+# a resume too. Everything here is find-or-create BY IDENTITY — the epic by
+# slug, a milestone by name within its epic, a task by title within its epic —
+# so a second run, a resume and a redo all find what the first run made. The
+# milestones are created IN ORDER and BEFORE the tasks: the plane appends each
+# new milestone after the last, and a task naming a milestone the epic does
+# not have yet would create it out of order.
+#
+# IN THE BACKGROUND (orun >= v2.88.0, `background: true` on every hook here).
+# Nothing a phase does before its landing reads the task plane — the provider
+# check, the placement, the rebrand, the repository, the secrets — so the
+# whole list runs beside 01-product instead of before it, in order. A hook
+# that works on the plane (`orun.task/ensure@v1`, `orun.pr/land@v1`) waits
+# for it to finish; a failure here stops the build at the next hook.
+#
+# Each phase's own `task` hook runs `orun.task/ensure@v1` on its task again,
+# just before its landing. Same identity, so it finds rather than creates,
+# and it is how the phase gets the task's KEY for its landing; it sits in
+# `post` rather than `pre` so that everything before it overlaps with this
+# list. The MILESTONE keeps the phase's name: it is the identity the engine's
+# phase events, the plane's evidence and the console's rows all meet on, and
+# the card's `programme.milestones` names the same list.
+hooks:
+ preInstantiate:
+ - id: epic
+ uses: orun.task/ensure@v1
+ background: true
+ with:
+ kind: epic
+ slug: "{{ .inputs.epicSlug }}"
+ name: "TanStack Start baselining — {{ .inputs.productname }}"
+ description: >-
+ Everything the TanStack Start template builds for
+ {{ .inputs.productname }} in {{ .inputs.githuborg }}/{{ .inputs.reponame }}:
+ the repository, its CI and the site live on stage and prod in one
+ landing, then the record of what went live. One milestone per phase,
+ in the order the phases run; one task per landing, each bound to the
+ pull request that lands it.
+ owner: me
+ - id: m01
+ uses: orun.task/ensure@v1
+ background: true
+ with:
+ kind: milestone
+ epic: "{{ .inputs.epicSlug }}"
+ name: 01-product
+ exitCriteria:
+ - repository created under {{ .inputs.githuborg }} and linked to the workspace
+ - the site built and deployed on stage and prod, its smoke green
+ - the home page answers on both workers.dev URLs
+ - id: m03
+ uses: orun.task/ensure@v1
+ background: true
+ with:
+ kind: milestone
+ epic: "{{ .inputs.epicSlug }}"
+ name: 03-docs
+ exitCriteria:
+ - ai/context/deployment.md on main matches the probed live URLs
+ - prod waits on stage again
+ - id: t01
+ uses: orun.task/ensure@v1
+ background: true
+ with:
+ kind: task
+ epic: "{{ .inputs.epicSlug }}"
+ milestone: 01-product
+ name: "Build the site in one landing"
+ brief: >-
+ Create {{ .inputs.githuborg }}/{{ .inputs.reponame }} and land the
+ whole site as one pull request — intent, CI, tooling, the identity,
+ the site and its tests, branded as {{ .inputs.productname }} — then
+ see the convergence build it with Cloudflare's Vite plugin and
+ deploy it to stage and prod, smoke-tested over HTTP.
+ prefix: BASE
+ contract: .baseline/tasks/01-product.TaskContract.yaml
+ - id: t03
+ uses: orun.task/ensure@v1
+ background: true
+ with:
+ kind: task
+ epic: "{{ .inputs.epicSlug }}"
+ milestone: 03-docs
+ name: "Record the live deployment"
+ brief: >-
+ Probe every live URL one last time and write the deployment record
+ into the repository from what actually answered, not from what the
+ blueprint intended.
+ prefix: BASE
+ contract: .baseline/tasks/03-docs.TaskContract.yaml
+
+# ── PHASES ────────────────────────────────────────────────────────────────
+# A phase is orun's own barrier over the module DAG and the whole of what a
+# phase DOES: what it is for a person (`title`), what to budget
+# (`expectedMinutes`), what must already be true (`requires`), and the hooks
+# that do its work around placement — `pre` before, `post` after, `await` for
+# what is still converging when the hooks are done.
+#
+# THE ORDER HERE IS THE EXECUTION ORDER, and the numbered names are the names
+# the task plane's milestones carry. A dependency may never point forward
+# across a phase boundary; orun refuses the blueprint if one does.
+#
+# ONE LANDING BUILDS THE SITE (cirrus-baseline baseline-v22's shape). A landing
+# has a fixed cost however small it is — place, open a PR, wait for its
+# checks, merge, wait for the convergence to start — and the bootstrap used to
+# pay it three times: the scaffold, the site, the record. Nothing in the
+# scaffold/site split was order the plan could not carry itself: the site's
+# build reads the tooling from the same tree, and the convergence on main is
+# what deploys it either way. So 01-product places the whole tree, brands it
+# and lands it as one pull request, and its convergence deploys the site to
+# stage and prod. 03-docs stays a landing of its own because it records what
+# went live and puts back the two bootstrap deferrals. The numbering keeps its
+# gap so the names stay the identities the task plane and `--phase` use.
+#
+# One phase places NO modules: `03-docs` is hooks only. It is a phase because
+# it is a separately landable unit with its own task and its own PR.
+phases:
+ - name: 01-product
+ title: The site, built in one landing
+ description: The whole tree — manifests, tooling, CI, the identity and the site — branded, landed as one pull request, and deployed to stage and prod by one convergence.
+ # An estimate, not a measurement of this shape: a minute under the 4 it
+ # was, for what v2.88.0 takes out of the wait — the task set-up in the
+ # background, the landing checked here instead of by a runner's `plan`,
+ # the watch reading every 5 s instead of 40 (about a minute on
+ # turso-starter's measured build). The rest is the merge's convergence:
+ # the site's Vite build, deploy and smoke, stage and prod side by side.
+ expectedMinutes: 3
+ narrate:
+ start: "Creating the repository and landing the whole site in one pull request — intent, CI, tooling, the welcome page, the server-function todos, the API route and the SSR demos. Then one convergence builds it with Cloudflare's Vite plugin and deploys it to stage and prod side by side. Usually about {{ .meta.expectedMinutes }} minutes."
+ await: "The site is building and deploying on both environments. A first deploy waits on its workers.dev route; nothing is stuck."
+ done: "{{ .inputs.reponame }} is live on stage and prod — {{ .meta.files }} files on main, branded as {{ .inputs.productname }}. That took {{ .meta.elapsed }}."
+ failed: "The site did not come up. The failing lane above names the step — the build, the deploy or the smoke — and a provider error is in its log."
+ modules: [ai-deployment, ai-operations, discovery-roots, github-workflows, rebrand-values, root-gitignore, root-intent, root-package-json, root-pnpm-lock, root-pnpm-workspace, root-readme, root-turbo, tooling-eslint, tooling-tsconfig, tooling-wire, vscode, web]
+ # 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
+ # that OWNS the repository. So the owner's connection is asked for here,
+ # before a repository is created, and waited for like any other consent.
+ # And the Cloudflare connection, which the deploy credentials below are
+ # minted from — asked for here too, since this phase is the one that
+ # deploys. `requires.probe` asks reality what a lock file cannot: are both
+ # connections live right now?
+ requires:
+ probe:
+ - id: providers
+ uses: orun.doctor/check@v1
+ with:
+ providers: [github, cloudflare]
+ githubOwner: "{{ .inputs.githuborg }}"
+ waitSeconds: 600
+ pollSeconds: 20
+ hooks:
+ post:
+ # A RE-RUN PHASE MUST HAVE SOMETHING TO LAND. A convergence can fail
+ # AFTER its PR merged, and the merge has already put every file this
+ # phase places on main; orun derives phase state from the tree, so a
+ # forced re-run lands an EMPTY diff while the site's CI plans
+ # `--changed`. So the phase rewrites ONE trailing marker line in each
+ # component.yaml its contract names — `# orun: redeploy
+ # ` — and the landing has a diff. The marker is a deploy
+ # trigger, not state: nothing reads it back.
+ - id: retouch
+ run: ["node", "{{ .baseline.dir }}/tooling/bootstrap/retouch.mjs", "--phase", "{{ .phase.name }}", "--affects", "{{ .baseline.dir }}/.baseline/tasks/01-product.TaskContract.yaml"]
+ # The identity chain. rebrand.mjs enumerates the tree with
+ # `git ls-files`, so the output has to be a git repository with a
+ # populated index BEFORE it runs. `git add -A` only stages; the landing
+ # commits. The whole tree is here, so the one rebrand brands all of it.
+ - id: git-init
+ run: ["git", "init", "-q"]
+ - id: git-stage
+ run: ["git", "add", "-A"]
+ - id: rebrand
+ run: ["node", "{{ .baseline.dir }}/tooling/rebrand/rebrand.mjs", "--values", ".rebrand/values.json", "--allow-dirty"]
+ # Re-tenant the site. rebrand.mjs treats the orun state backend as
+ # org-owned and leaves it alone, so intent.yaml would keep THIS
+ # repository's `workspace:` — the site's CI would then claim another
+ # tenant's workspace on every remote op. Hook argv is not templated,
+ # so the value travels through .rebrand/values.json, which IS.
+ - id: orun-workspace
+ run:
+ - node
+ - -e
+ - |
+ const fs = require("fs");
+ const values = JSON.parse(fs.readFileSync(".rebrand/values.json", "utf8"));
+ const ws = String(values.orunWorkspace || "").trim() || "ws_SET_ME";
+ const before = fs.readFileSync("intent.yaml", "utf8");
+ // Look for the line rather than for a change: a site built into
+ // a workspace already named there rewrites the line to the value
+ // it already has, and "unchanged" is not "missing".
+ const line = /^(\s*workspace:\s*).*$/m;
+ if (!line.test(before)) {
+ console.error("orun-workspace: no `workspace:` line in intent.yaml — refusing to guess");
+ process.exit(1);
+ }
+ fs.writeFileSync("intent.yaml", before.replace(line, "$1" + ws));
+ console.log(
+ ws === "ws_SET_ME"
+ ? "orun-workspace: wrote placeholder ws_SET_ME — set your Orun Cloud workspace before enabling remote state"
+ : "orun-workspace: intent.yaml workspace -> " + ws,
+ );
+ # The site carries no work tree of this repository's: `specs/` and
+ # `tasks/` never ship, so intent.yaml's `work:` block would point its
+ # every plan at two directories that do not exist.
+ - id: work-tree
+ run: ["node", "{{ .baseline.dir }}/tooling/bootstrap/work-tree.mjs", "--strip"]
+ # STAGE AND PROD DEPLOY SIDE BY SIDE UNTIL THE BOOTSTRAP IS DONE. The
+ # promotion gate makes prod wait out stage's deploy; during a
+ # bootstrap both are empty and the landing is watched to green, so it
+ # protects nothing and doubles the convergence. Deferred here,
+ # restored by 03-docs. tooling/bootstrap/promotion.mjs.
+ - id: promotion
+ run: ["node", "{{ .baseline.dir }}/tooling/bootstrap/promotion.mjs", "--defer"]
+ # DEV'S VERIFY LANES STAY OFF MAIN UNTIL THE BOOTSTRAP IS DONE, by the
+ # same mechanism: a third TanStack Start build on every merge proves nothing
+ # the baseline's own CI did not. Pull requests keep their dev lanes.
+ # tooling/bootstrap/dev-lanes.mjs.
+ - id: dev-lanes
+ run: ["node", "{{ .baseline.dir }}/tooling/bootstrap/dev-lanes.mjs", "--defer"]
+ # Re-stage so `git ls-files` and `rebrand --verify` see the rewritten tree.
+ - id: git-restage
+ run: ["git", "add", "-A"]
+ - id: rebrand-verify
+ run: ["node", "{{ .baseline.dir }}/tooling/rebrand/rebrand.mjs", "--verify", "--values", ".rebrand/values.json"]
+ # The repo has to exist before there is anywhere to land.
+ - id: repo
+ uses: orun.repo/ensure@v1
+ narrate: "The repository exists at {{ .inputs.githuborg }}/{{ .inputs.reponame }}."
+ with:
+ owner: "{{ .inputs.githuborg }}"
+ name: "{{ .inputs.reponame }}"
+ private: "{{ .inputs.repoPrivate }}"
+ # THE REPOSITORY MUST BE THE WORKSPACE'S before anything lands in it,
+ # or the site's own CI cannot reach the platform: every convergence
+ # lane authenticates over GitHub OIDC, resolved through the repo link.
+ # `link` may be refused where the credential cannot write links (a
+ # workspace key) and the platform has linked the repository already,
+ # so it is best effort and `check` is the gate — an unlinked
+ # repository stops here, naming the fix, instead of in every lane.
+ - id: link
+ run:
+ - bash
+ - -c
+ - |
+ orun cloud link --org "$1" || true
+ orun cloud check --org "$1" || {
+ echo "$2 is not linked to workspace $1 — its CI cannot authenticate. Link it (orun cloud link --org $1, or the console's Git Repos) and re-run this phase." >&2
+ exit 1
+ }
+ - link
+ - "{{ .inputs.orunWorkspace }}"
+ - "{{ .inputs.githuborg }}/{{ .inputs.reponame }}"
+ # The deploy credentials, brokered, in ONE hook (orun >= v2.87.0):
+ # `secrets` mints each key under its own scope template from the one
+ # connection the build is bound to, reading the connections and the
+ # existing secrets once and creating the missing keys side by side.
+ # `workers-deploy` is the site's deploy (Workers Scripts); the account
+ # id is a connection fact. The deploy lane binds both keys (the
+ # workers-assets composition's `secretBindings`). Keys that already
+ # exist are kept. After the link, before the landing whose convergence
+ # uses them.
+ - id: secrets
+ uses: orun.integrations/reconcile@v1
+ with:
+ provider: cloudflare
+ secrets:
+ - { key: CLOUDFLARE_API_TOKEN, template: workers-deploy }
+ - { key: CLOUDFLARE_ACCOUNT_ID, template: account-id }
+ # The task this landing closes, and its key. The run-level list above
+ # opens it in the background; this is the first hook that needs it,
+ # so it is the one that waits for that list (orun >= v2.88.0) — every
+ # hook before it ran while the task plane was still being set up.
+ - id: task
+ uses: orun.task/ensure@v1
+ with:
+ kind: task
+ epic: "{{ .inputs.epicSlug }}"
+ milestone: "{{ .phase.name }}"
+ name: "Build the site in one landing"
+ prefix: BASE
+ contract: .baseline/tasks/01-product.TaskContract.yaml
+ # THE SITE IS A PULL REQUEST THAT IS CHECKED, THEN MERGED — checked
+ # HERE (`checks: local`, orun >= v2.88.0): `orun validate`, then
+ # `orun plan` as the pull request and as the merge to main plan it,
+ # on the commit, before it is pushed. That is what the PR's `plan`
+ # job checks (the intent, every component and every composition
+ # resolve), plus the merge's own plan, in under a second instead of a
+ # runner's ~25 s. A tree that fails is never pushed. The PR's CI still
+ # runs (`plan` alone on a bootstrap branch, `orun/BASE-…`, ci.yml);
+ # nothing waits for it. The merge runs the site's build, deploy and
+ # smoke on main moments later, for real, and that convergence is what
+ # `await` watches to green.
+ - id: land
+ uses: orun.pr/land@v1
+ narrate: "The site is merged into main."
+ with:
+ task: "{{ .phase.hooks.task.outputs.key }}"
+ epic: "{{ .inputs.epicSlug }}"
+ branchSlug: "{{ .phase.name }}"
+ title: "feat: {{ .inputs.productname }}, the whole site from the TanStack Start template"
+ checks: local
+ await:
+ - id: converge
+ uses: orun.run/watch@v1
+ narrate: "The site built, deployed and passed its smoke, and the convergence run came back green."
+ with:
+ # The run for the commit THIS landing merged — the branch's newest
+ # run, read the moment the merge returns, may be another push's.
+ sha: "{{ .phase.hooks.land.outputs.mergeSha }}"
+ repo: "{{ .inputs.githuborg }}/{{ .inputs.reponame }}"
+ resumeBudget: 3
+ waitSeconds: 1800
+ # Read every 5 s, not the action's 40: the build goes on the
+ # moment the run is green instead of up to 40 s after it.
+ pollSeconds: 5
+ - id: verify
+ uses: orun.http/probe@v1
+ narrate: "The site answered on stage and prod."
+ with:
+ urls:
+ - "https://{{ .inputs.reponame }}-web-stage.{{ .inputs.subdomain }}.workers.dev"
+ - "https://{{ .inputs.reponame }}-web-prod.{{ .inputs.subdomain }}.workers.dev"
+
+ # Places nothing. It records what 01-product built, from PROBED facts
+ # rather than from what the blueprint intended — which is why it runs last.
+ # Its render probes every URL as it writes the record, and this landing
+ # redeploys nothing, so there is no probe after it to wait for.
+ - name: 03-docs
+ title: The deployment, recorded
+ description: The live-deployment manifest, rendered from probed reality, and the promotion gate put back.
+ # An estimate, not a measurement: the render's probes, the task found,
+ # the commit checked here and merged — nothing built, nothing waited on.
+ expectedMinutes: 1
+ narrate:
+ start: "Now recording what was actually built — probing every URL and writing the deployment manifest into the repository."
+ done: "ai/context/deployment.md now records the live deployment, written from probed facts, and prod waits on stage again. {{ .meta.elapsed }}."
+ failed: "The deployment record did not land. The site is still live; only the write-up is missing."
+ modules: []
+ requires:
+ phases: [01-product]
+ hooks:
+ post:
+ # THE SITE GOES LIVE WITH ITS PROMOTION GATE. 01-product deferred
+ # `prod.promotion.dependsOn: [stage]`; this, the last landing, puts it
+ # back, and from here on a change reaches prod only after stage.
+ # Restoring touches only intent.yaml's `environments` section, which
+ # `orun plan --changed` maps to no component, so this landing
+ # redeploys nothing.
+ - id: promotion
+ run: ["node", "{{ .baseline.dir }}/tooling/bootstrap/promotion.mjs", "--restore"]
+ # And dev verifies every merge to main again (01-product deferred it).
+ - id: dev-lanes
+ run: ["node", "{{ .baseline.dir }}/tooling/bootstrap/dev-lanes.mjs", "--restore"]
+ - id: render
+ run: ["bash", "{{ .baseline.dir }}/hooks/render-deployment-docs.sh", ".", "{{ .inputs.orunWorkspace }}", "{{ .baseline.dir }}"]
+ - id: task
+ uses: orun.task/ensure@v1
+ with:
+ kind: task
+ epic: "{{ .inputs.epicSlug }}"
+ milestone: "{{ .phase.name }}"
+ name: "Record the live deployment"
+ prefix: BASE
+ contract: .baseline/tasks/03-docs.TaskContract.yaml
+ # Checked here and merged, as 01-product's landing is; nothing here
+ # builds.
+ - id: land
+ uses: orun.pr/land@v1
+ narrate: "The deployment record is merged into main."
+ with:
+ task: "{{ .phase.hooks.task.outputs.key }}"
+ epic: "{{ .inputs.epicSlug }}"
+ branchSlug: "{{ .phase.name }}"
+ title: "docs(deployment): record the live deployment state"
+ checks: local
diff --git a/specs/epics/README.md b/specs/epics/README.md
index 1fd1302..4058bd8 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 |
|------|---------|--------|------------|
-| [`tanstack-start/`](./tanstack-start/) | **TS** | In progress (TS1: the site on Workers) | Vercel's TanStack Start template — the welcome page, server-function todos kept in the visitor's cookie, an API route and the three SSR modes — on Cloudflare Workers + Static Assets via Cloudflare's Vite plugin, and an Orun baseline that instantiates it in one landing (TS2) |
+| [`tanstack-start/`](./tanstack-start/) | **TS** | ✅ Shipped (`baseline-v1`); not yet live | Vercel's TanStack Start template — the welcome page, server-function todos kept in the visitor's cookie, an API route and the three SSR modes — on Cloudflare Workers + Static Assets via Cloudflare's Vite plugin, and an Orun baseline that instantiates it in one landing (TS2) |
As-built ≠ intent: what shipped lives in each epic's `IMPLEMENTATION-STATUS.md`.
diff --git a/specs/epics/tanstack-start/IMPLEMENTATION-STATUS.md b/specs/epics/tanstack-start/IMPLEMENTATION-STATUS.md
index 67097b8..819cab7 100644
--- a/specs/epics/tanstack-start/IMPLEMENTATION-STATUS.md
+++ b/specs/epics/tanstack-start/IMPLEMENTATION-STATUS.md
@@ -4,7 +4,7 @@
|---|---|---|
| TS0 — the spec | ✅ | TS-1 |
| TS1 — TanStack Start on Workers | ✅ | TS-2 |
-| TS2 — a baseline | planned | TS-3 |
+| TS2 — a baseline | ✅ | TS-3, tagged `baseline-v1` |
## Departures from the upstream template
diff --git a/specs/epics/tanstack-start/README.md b/specs/epics/tanstack-start/README.md
index 54d0fa5..9c33cfa 100644
--- a/specs/epics/tanstack-start/README.md
+++ b/specs/epics/tanstack-start/README.md
@@ -11,7 +11,7 @@ somebody else's site in one landing.**
| | |
|---|---|
-| Status | In progress — TS1 on main: the site runs on Workers |
+| Status | ✅ Shipped (`baseline-v1`) — proven offline in Baseline CI; not yet live (risk TS-A) |
| Upstream | [vercel/vercel › examples/tanstack-start](https://github.com/vercel/vercel/tree/main/examples/tanstack-start), at `84878e5` — Apache-2.0 |
| Reference | [sveltekit-boilerplate](https://github.com/sourceplane/sveltekit-boilerplate) (the Vite-built Worker + Static Assets scaffolding, and the cookie-kept todos) |
| Key | `TS` |
diff --git a/specs/epics/tanstack-start/epic.yaml b/specs/epics/tanstack-start/epic.yaml
index 8ad7d7b..5fb9308 100644
--- a/specs/epics/tanstack-start/epic.yaml
+++ b/specs/epics/tanstack-start/epic.yaml
@@ -9,7 +9,7 @@ metadata:
spec:
title: "Vercel's TanStack Start template on Cloudflare Workers"
summary: "Vercel's TanStack Start template — the welcome page, a todo list read and changed by server functions, an API route and the three SSR modes — runs on Cloudflare Workers + Static Assets through Cloudflare's Vite plugin, TanStack Start's own Cloudflare target, the todos kept in each visitor's own cookie, inside the Cirrus baseline's repository conventions, and becomes an Orun baseline that takes a new TanStack Start site from nothing to live on stage and prod in one landing."
- state: started
+ state: completed
milestones:
- name: "TS0 — the spec"
exitCriteria:
diff --git a/testing/bootstrap-defer.test.sh b/testing/bootstrap-defer.test.sh
new file mode 100755
index 0000000..526e2b4
--- /dev/null
+++ b/testing/bootstrap-defer.test.sh
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+# The two things a bootstrap turns off in intent.yaml and puts back —
+# `prod.promotion` (tooling/bootstrap/promotion.mjs) and dev's push-to-main
+# activation (tooling/bootstrap/dev-lanes.mjs) — must each defer, be
+# idempotent both ways, leave a parseable intent while deferred, and restore
+# the file BYTE-FOR-BYTE: a restore that reproduced the block by hand would
+# be a second place the intent is authored.
+set -euo pipefail
+here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+root="$(cd "$here/.." && pwd)"
+fail=0
+ok() { echo " ok $1"; }
+bad() { echo " ✕ $1" >&2; fail=1; }
+
+tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
+cp "$root/intent.yaml" "$tmp/intent.yaml"
+
+for tool in promotion dev-lanes; do
+ f="$tmp/intent.yaml"; cp "$root/intent.yaml" "$f"
+ echo "── $tool.mjs"
+ node "$root/tooling/bootstrap/$tool.mjs" --check --file "$f" | grep -q -E 'enforced|active' && ok "starts enforced/active" || bad "starts enforced/active"
+ node "$root/tooling/bootstrap/$tool.mjs" --defer --file "$f" >/dev/null
+ node "$root/tooling/bootstrap/$tool.mjs" --check --file "$f" | grep -q deferred && ok "--defer defers" || bad "--defer defers"
+ python3 -c "import yaml,sys; yaml.safe_load(open(sys.argv[1]))" "$f" && ok "deferred intent still parses" || bad "deferred intent still parses"
+ cp "$f" "$tmp/once.yaml"; node "$root/tooling/bootstrap/$tool.mjs" --defer --file "$f" >/dev/null
+ cmp -s "$f" "$tmp/once.yaml" && ok "a second --defer changes nothing" || bad "a second --defer changes nothing"
+ node "$root/tooling/bootstrap/$tool.mjs" --restore --file "$f" >/dev/null
+ cmp -s "$f" "$root/intent.yaml" && ok "--restore is byte-exact" || bad "--restore is byte-exact"
+ node "$root/tooling/bootstrap/$tool.mjs" --restore --file "$f" >/dev/null
+ cmp -s "$f" "$root/intent.yaml" && ok "a second --restore changes nothing" || bad "a second --restore changes nothing"
+done
+
+echo "── what each deferral means to a push-to-main plan"
+f="$tmp/intent.yaml"; cp "$root/intent.yaml" "$f"
+node "$root/tooling/bootstrap/dev-lanes.mjs" --defer --file "$f" >/dev/null
+python3 - "$f" <<'PY' && ok "dev is no longer activated by github-push-main while deferred" || bad "dev is no longer activated by github-push-main while deferred"
+import sys, yaml
+d = yaml.safe_load(open(sys.argv[1]))
+refs = d["environments"]["dev"]["activation"]["triggerRefs"]
+assert "github-push-main" not in refs and "github-pull-request" in refs, refs
+PY
+f="$tmp/intent.yaml"; cp "$root/intent.yaml" "$f"
+node "$root/tooling/bootstrap/promotion.mjs" --defer --file "$f" >/dev/null
+python3 - "$f" <<'PY' && ok "prod has no promotion gate while deferred" || bad "prod has no promotion gate while deferred"
+import sys, yaml
+d = yaml.safe_load(open(sys.argv[1]))
+assert "promotion" not in d["environments"]["prod"], d["environments"]["prod"].keys()
+PY
+
+echo "── work-tree.mjs — the baseline's work tree does not ship"
+f="$tmp/intent.yaml"; cp "$root/intent.yaml" "$f"
+node "$root/tooling/bootstrap/work-tree.mjs" --check --file "$f" | grep -q declared && ok "this repository declares a work tree" || bad "this repository declares a work tree"
+node "$root/tooling/bootstrap/work-tree.mjs" --strip --file "$f" >/dev/null
+node "$root/tooling/bootstrap/work-tree.mjs" --check --file "$f" | grep -q absent && ok "--strip removes it" || bad "--strip removes it"
+python3 - "$f" "$root/intent.yaml" <<'PY' && ok "everything else in the intent is untouched" || bad "everything else in the intent is untouched"
+import sys, yaml
+after, before = (yaml.safe_load(open(p)) for p in sys.argv[1:3])
+assert "work" not in after, list(after)
+before.pop("work")
+assert after == before, "a key other than work: changed"
+PY
+grep -q 'Where the work lives' "$f" && bad "the block's own comment is left behind" || ok "the block's own comment goes with it"
+cp "$f" "$tmp/once.yaml"; node "$root/tooling/bootstrap/work-tree.mjs" --strip --file "$f" >/dev/null
+cmp -s "$f" "$tmp/once.yaml" && ok "a second --strip changes nothing" || bad "a second --strip changes nothing"
+
+if [ "$fail" -ne 0 ]; then echo "bootstrap-defer.test.sh: failure(s)" >&2; exit 1; fi
+echo "bootstrap-defer.test.sh: ok"
diff --git a/testing/coverage.test.sh b/testing/coverage.test.sh
new file mode 100755
index 0000000..be53ff9
--- /dev/null
+++ b/testing/coverage.test.sh
@@ -0,0 +1,264 @@
+#!/usr/bin/env bash
+# EVERY COMPONENT THIS REPO SHIPS IS PLACED BY EXACTLY ONE PHASE
+# (saas-bootstrap-engine BE5, Tier 0).
+#
+# `repo-blueprint.yaml` decides what a product is made of. A component that no
+# module names is not a component a product gets — and nothing would say so.
+# The failure is quiet and late: the fork builds, its CI goes green, and the
+# missing piece surfaces when somebody looks for a worker that was never
+# copied.
+#
+# orun already enforces the other half — every MODULE belongs to exactly one
+# phase, and a module naming an unknown module is a parse error. What it cannot
+# know is what this repository contains, because a blueprint declares what to
+# place and not what exists. That is this file's job.
+#
+# bash + python3 + PyYAML. No network, no orun, no credential.
+set -euo pipefail
+here="$(cd "$(dirname "$0")" && pwd)"
+root="$(cd "$here/.." && pwd)"
+
+echo "── every component against the blueprint that places it"
+python3 - "$root" <<'PY'
+import pathlib, sys
+
+try:
+ import yaml
+except ImportError:
+ sys.exit("PyYAML is required for the coverage gate (pip install pyyaml)")
+
+root = pathlib.Path(sys.argv[1])
+problems = []
+def bad(m): problems.append(m)
+
+# A component directory this repository deliberately keeps to itself. Declared
+# with its reason rather than skipped by a pattern: "tests/*" would also hide
+# the test suite a product genuinely needs, and the next
+# baseline-only directory should have to be argued for in a diff.
+# EMPTY: every component here is a site's. The baseline's own suites live in
+# `testing/`, which is not a component at all and so is not one this gate can
+# miss. The map stays so that the next baseline-only directory has to be
+# argued for in a diff; the check below refuses an exemption whose directory is
+# absent, so a stale entry cannot linger.
+BASELINE_ONLY: dict[str, str] = {}
+
+bp = yaml.safe_load((root / "repo-blueprint.yaml").read_text())
+
+# Where each module takes its content from, and which phase places it.
+placed_by = {}
+for m in bp.get("modules") or []:
+ src = (m.get("from") or "").rstrip("/")
+ if src:
+ placed_by.setdefault(src, []).append(m["name"])
+phase_of = {n: ph["name"] for ph in (bp.get("phases") or []) for n in ph["modules"]}
+
+components = sorted(
+ p.parent.relative_to(root).as_posix()
+ for p in root.rglob("component.yaml")
+ if "node_modules" not in p.parts and ".git" not in p.parts
+)
+if not components:
+ sys.exit("no component.yaml anywhere — this check has gone blind")
+
+for comp in components:
+ modules = placed_by.get(comp, [])
+ reason = BASELINE_ONLY.get(comp)
+
+ if reason and modules:
+ bad(f"{comp} is declared baseline-only ({reason}) and yet {modules[0]} "
+ f"places it — one of the two is wrong")
+ continue
+ if reason:
+ continue
+ if not modules:
+ bad(f"{comp} is a component and no module places it. Either add one, or "
+ f"declare it baseline-only in this file with the reason.")
+ continue
+ if len(modules) > 1:
+ bad(f"{comp} is placed by {len(modules)} modules ({', '.join(modules)}) "
+ f"— a component comes from one place")
+ continue
+ if modules[0] not in phase_of:
+ bad(f"{comp} is placed by {modules[0]}, which is in no phase")
+
+# The other direction: a module naming a path this repo does not have places
+# nothing, silently. orun resolves `from` against the source tree and an absent
+# path is an empty module, not an error.
+for src, modules in sorted(placed_by.items()):
+ if not (root / src).exists():
+ bad(f"module {modules[0]} takes its content from {src}, which does not "
+ f"exist — it would place nothing, and say nothing")
+
+# A directory named baseline-only must actually BE one, or the exemption is
+# protecting nothing and will outlive the thing it was written for.
+for comp in BASELINE_ONLY:
+ if not (root / comp).exists():
+ bad(f"{comp} is declared baseline-only and does not exist — drop the entry")
+
+# ── WHAT THE CATALOG SEES OF EACH COMPONENT ───────────────────────────────
+#
+# Every component ships its generated pages (overview, architecture, runbook)
+# and must ATTACH them in `spec.docs`: a `docs/` folder no manifest declares is
+# never attached, so a fresh site's Docs library showed nothing for its
+# component and the catalog failed it on docs and on runbook. A component
+# also needs a description: it is the catalog's one-line answer to "what is
+# this".
+#
+# And a domain may not share a component's name. The catalog keys entities by
+# name, so a `web` domain (`spec.domain: web`) takes the `web` component's
+# place, and the site's one deployable goes missing from its own catalog (as
+# turso-starter's and the portfolio starter kit's live builds showed).
+WANT_DOCS = {"overview": "docs/overview.md", "architecture": "docs/architecture.md", "runbook": "docs/runbook.md"}
+names, domains = {}, {}
+for comp in components:
+ if comp in BASELINE_ONLY:
+ continue
+ doc = yaml.safe_load((root / comp / "component.yaml").read_text()) or {}
+ meta, spec = doc.get("metadata") or {}, doc.get("spec") or {}
+ names[meta.get("name")] = comp
+ if spec.get("domain"):
+ domains.setdefault(spec["domain"], comp)
+ if not (meta.get("description") or "").strip():
+ bad(f"{comp}/component.yaml has no metadata.description — the catalog shows the component with nothing to say")
+ docs = spec.get("docs") or {}
+ got = {"overview": docs.get("overview")}
+ for page in docs.get("pages") or []:
+ got[page.get("role")] = page.get("path")
+ for role, path in WANT_DOCS.items():
+ if got.get(role) != path:
+ bad(f"{comp}/component.yaml does not attach {path} as its {role} "
+ f"(spec.docs) — the page ships and the catalog never sees it")
+ elif not (root / comp / path).is_file():
+ bad(f"{comp}/component.yaml attaches {path}, which does not exist")
+for domain, comp in sorted(domains.items()):
+ if domain in names:
+ bad(f"{comp} declares domain `{domain}`, which is also the name of the "
+ f"component in {names[domain]} — the catalog keeps one of the two")
+
+# ── WHAT `ignore` ACTUALLY EXCLUDES (BE6) ──────────────────────────────────
+#
+# orun matches an ignore entry two ways, and WHICH ONE depends on the entry:
+# a pattern containing no glob metacharacter is compared against each path
+# SEGMENT, and only a pattern containing one is compared against the whole
+# relative path. So `apps/admin-worker/wrangler.jsonc` matches nothing at all —
+# no segment is ever equal to it — and the entry is INERT while reading exactly
+# like a rule.
+#
+# That was not hypothetical. Twelve such entries were inert in this file's own
+# blueprint, and a canary written to `apps/admin-worker/wrangler.jsonc` was
+# placed straight into a product — which is the leak their comment says they
+# exist to prevent. An `ignore` list that silently does nothing is worse than
+# no list, because the comment above it reads as a defence.
+for entry in bp.get("ignore") or []:
+ if "/" in entry and not any(c in entry for c in "*?["):
+ bad(f'ignore entry "{entry}" names a path and has no glob character, so orun '
+ f'matches it against path SEGMENTS and it excludes nothing. Write it as '
+ f'"**/{entry}".')
+
+# A workflow that runs the FACTORY must not ship to the factory's products.
+# `github-workflows` copies the whole `.github` directory, so a lane added for
+# this repository travels to every product built from it — and one that reads a
+# path under `testing/` cannot work there, because `testing/` is not placed.
+# A nightly lane did exactly this once: shipped, on a cron, reading an intent
+# file no product has.
+ignored = set(bp.get("ignore") or [])
+workflows = sorted((root / ".github" / "workflows").glob("*.y*ml"))
+for wf in workflows:
+ text = wf.read_text(encoding="utf-8")
+ if "testing/" not in text:
+ continue
+ rel = f".github/workflows/{wf.name}"
+ if f"**/{rel}" not in ignored and rel not in ignored:
+ bad(f"{rel} reads a path under testing/, which no product is placed with, "
+ f"and is not in the blueprint's ignore list — so it ships into every "
+ f'product and fails there. Add "**/{rel}" to ignore.')
+
+# ONE WORKFLOW ON A PUSH TO MAIN, in what a product carries. The bootstrap
+# watches each phase's convergence with `orun.run/watch@v1` and `sha:`, which
+# takes the newest workflow run for the merge commit — from any workflow. A
+# second one on push (checks.yml did this) can be the run it finds: the first
+# live bootstrap watched Checks go green while ci.yml's deploy lanes had
+# failed. So every shipped workflow but ci.yml stays off pushes to main.
+import yaml as _yaml
+on_push = []
+for wf in workflows:
+ rel = f".github/workflows/{wf.name}"
+ if f"**/{rel}" in ignored or rel in ignored:
+ continue # the factory's own; never in a product
+ doc = _yaml.safe_load(wf.read_text(encoding="utf-8")) or {}
+ on = doc.get("on", doc.get(True)) # PyYAML reads a bare `on:` key as True
+ if isinstance(on, str):
+ on = {on: None}
+ elif isinstance(on, list):
+ on = {k: None for k in on}
+ push = (on or {}).get("push", "absent")
+ if push == "absent":
+ continue
+ branches = (push or {}).get("branches") if isinstance(push, dict) else None
+ if branches is None or "main" in branches:
+ on_push.append(wf.name)
+if on_push != ["ci.yml"]:
+ bad(f"the workflows a product runs on a push to main are {on_push or 'none'}; "
+ f"it must be exactly ci.yml — orun.run/watch@v1 watches the newest run "
+ f"for a commit from ANY workflow, so a second one hides the convergence")
+
+# A MANUAL RUN (the deploys contract, packages/contracts DEPLOY_WORKFLOW in
+# orun-cloud). Orunbase's Run and Deploy buttons dispatch ci.yml on main with
+# inputs component, environment and deploy_id, then find the run by the deploy
+# id in its name; GitHub refuses a dispatch whose inputs the workflow does not
+# declare (422), so a product without them has dead buttons. The plan step
+# must plan a dispatch under the push-to-main binding (what a merge deploys),
+# on main only, and read the inputs from env, never interpolate them.
+import yaml as _ydisp
+_ci_path = root / ".github" / "workflows" / "ci.yml"
+_ci = _ydisp.safe_load(_ci_path.read_text(encoding="utf-8")) or {}
+_on = _ci.get("on", _ci.get(True)) or {}
+_wd = _on.get("workflow_dispatch") if isinstance(_on, dict) else None
+_inputs = (_wd or {}).get("inputs") or {}
+if set(_inputs) != {"component", "environment", "deploy_id"}:
+ bad(f"ci.yml's workflow_dispatch declares inputs {sorted(_inputs) or 'none'}; Orunbase "
+ f"dispatches component, environment and deploy_id, and GitHub refuses unknown inputs")
+else:
+ _intent = _ydisp.safe_load((root / "intent.yaml").read_text(encoding="utf-8")) or {}
+ _envs = set((_intent.get("environments") or {}).keys())
+ _opts = set(_inputs["environment"].get("options") or [])
+ if _inputs["environment"].get("type") != "choice" or _opts != _envs:
+ bad(f"ci.yml's environment input offers {sorted(_opts)}; intent.yaml declares {sorted(_envs)}")
+ if "github-push-main" not in ((_intent.get("automation") or {}).get("triggerBindings") or {}):
+ bad("a manual run plans under intent.yaml's github-push-main binding, which is missing")
+if "inputs.deploy_id" not in str(_ci.get("run-name", "")):
+ bad("ci.yml's run-name must carry inputs.deploy_id: Orunbase finds a deploy's run by that id")
+_steps = (_ci.get("jobs") or {}).get("plan", {}).get("steps") or []
+_plan_step = next((s for s in _steps if "plan_args" in str(s.get("run", ""))), None)
+if _plan_step is None:
+ bad("ci.yml's plan job has no step that builds plan_args")
+else:
+ _run = _plan_step["run"]
+ for _needle, _why in (
+ ('"$GITHUB_EVENT_NAME" = "workflow_dispatch"', "plans a dispatch on its own branch"),
+ ("--trigger github-push-main", "plans a dispatch as a merge to main"),
+ ('"$GITHUB_REF" != "refs/heads/main"', "refuses a dispatch started off main"),
+ ('--env "$DISPATCH_ENVIRONMENT"', "filters a dispatch to its environment"),
+ ):
+ if _needle not in _run:
+ bad(f"ci.yml's plan step no longer {_why} ({_needle!r} is gone)")
+ if "${{" in _run and "inputs." in _run:
+ bad("ci.yml's plan step interpolates inputs.* into its script; read them from env")
+ _env = _plan_step.get("env") or {}
+ if "inputs.component" not in str(_env.get("DISPATCH_COMPONENT", "")) \
+ or "inputs.environment" not in str(_env.get("DISPATCH_ENVIRONMENT", "")):
+ bad("ci.yml's plan step must take DISPATCH_COMPONENT / DISPATCH_ENVIRONMENT from inputs in env")
+
+if problems:
+ print("FAIL: the blueprint and this repository disagree about what a product is:",
+ file=sys.stderr)
+ for p in problems:
+ print(f" - {p}", file=sys.stderr)
+ sys.exit(1)
+
+shipped = len(components) - len(BASELINE_ONLY)
+print(f" {shipped} of {len(components)} components placed, "
+ f"{len(BASELINE_ONLY)} baseline-only by declaration")
+PY
+
+echo "coverage.test.sh: ok"
diff --git a/testing/e2e.test.sh b/testing/e2e.test.sh
new file mode 100755
index 0000000..652f54b
--- /dev/null
+++ b/testing/e2e.test.sh
@@ -0,0 +1,430 @@
+#!/usr/bin/env bash
+# TIER 2 — the site a bootstrap produces builds, deploys (dry) and serves.
+#
+# placement.test.sh proves the tree a bootstrap ends with is the right tree.
+# This proves it WORKS, by doing to it what its own pipelines will:
+#
+# 1. at the finished site, the landing's own checks — install with the
+# lockfile the site ships, render fixtures, typecheck, lint, test,
+# build. The bootstrap's own landings are checked in the box with
+# `orun validate` and `orun plan` alone (`checks: local`; their PR's CI
+# on an `orun/BASE-…` branch is `plan` alone, and the convergence on
+# main builds, deploys and smoke-tests the site), and a later pull
+# request of the site runs ci.yml's verify lanes, which build and
+# dry-deploy it but do not lint or run the tests — so THIS is where a
+# site those steps refuse is caught: before the tag, not after a build
+# has merged it;
+# 2. the stage lane's own steps, rendered by `orun plan` in the site: on a
+# pull request (the verify profile) `build-app` — the component's
+# buildCommand, the same step the deploy profile runs; `vite build`,
+# where Cloudflare's Vite plugin writes the Worker to dist/server and the
+# browser's files to dist/client, where wrangler.jsonc's `main` and
+# `assets.directory` point — `verify-build-output` (the component's
+# `workerEntrypoint` and `assetsDir`) and `deploy-dry-run` (`wrangler
+# deploy --dry-run --config wrangler.jsonc --name -web-stage`).
+# They run IN THE TREE THE RUNNER STAGES for the job
+# (testing/lib/stage-job.py), with the dependency layout the pinned
+# composition produces: if its install step is `scope: lane`, the
+# top-level node_modules is a symlink to the source checkout's; if not,
+# the job's own install step runs inside the staged tree;
+# 3. THE ONE WORKER CONFIG, held to the build: the deploy names
+# wrangler.jsonc, which describes the BUILT Worker, while the plugin
+# writes its own config beside the build (dist/server/wrangler.json).
+# The two must name the same Worker — compatibility date and flags, the
+# entry, the module rule, the assets — and a dry-run deploy of each
+# must upload the same modules. A plugin release that moves its output
+# fails here, before a tag;
+# 4. serve the built Worker with `wrangler dev` FROM THAT STAGED TREE and run
+# the component's OWN `smokeCommand` against it, verbatim — the check the
+# real deploy ends with — and then read every route the site promises:
+# the welcome page with the site's name as its `` (escaped, not
+# broken, by an `&` and an `'`), the hashed client build and the static
+# files, the API route and the page that reads it, the three SSR modes
+# (the songs in the markup, only in the loader's data, and in neither —
+# fetched by the browser through the GET server function), the todos
+# through their server functions called as the browser calls them
+# (testing/lib/serverfn-payload.mjs) — the visitor's starter list, a
+# todo added by the POST one and read back by the page and by the GET
+# one with the cookie it set, an empty todo refused, a cross-origin post
+# refused — and an unknown path's 404.
+#
+# What it cannot do is the platform's half: create the repository, mint the
+# brokered Cloudflare token, deploy for real and probe workers.dev. That is a
+# bootstrap against a workspace (BOOTSTRAP.md); everything short of it is here.
+#
+# Needs: orun, node, pnpm, python3 (+PyYAML), git, curl, and the network for
+# `pnpm install` (or a warm store). A few minutes: two installs and builds
+# (the landing's checks over the site, and the stage lane's own in its staged
+# tree).
+set -euo pipefail
+here="$(cd "$(dirname "$0")" && pwd)"
+root="$(cd "$here/.." && pwd)"
+# shellcheck source=lib/bootstrap.sh
+source "$here/lib/bootstrap.sh"
+
+for bin in orun node pnpm python3 git curl; do
+ command -v "$bin" >/dev/null || { echo "e2e.test.sh needs $bin on PATH" >&2; exit 1; }
+done
+
+scratch="$(mktemp -d)"
+dev_pid=""
+# wrangler dev runs under pnpm, node and two workerd processes; a TERM to the
+# first does not reach the rest, and waiting on it then never returns. So it is
+# started as its own process group (setsid) and the whole group is stopped.
+cleanup() {
+ if [ -n "$dev_pid" ]; then
+ kill -TERM -- "-$dev_pid" 2>/dev/null || true
+ for _ in 1 2 3 4 5 6 7 8 9 10; do kill -0 -- "-$dev_pid" 2>/dev/null || break; sleep 0.5; done
+ kill -KILL -- "-$dev_pid" 2>/dev/null || true
+ fi
+ rm -rf "$scratch"
+}
+trap cleanup EXIT
+values="$here/fixtures/acme.json"
+repo="$(python3 -c "import json,sys;print(json.load(open(sys.argv[1]))['reponame'])" "$values")"
+export CI=1 WRANGLER_SEND_METRICS=false TURBO_TELEMETRY_DISABLED=1
+
+# The landing's own checks, step for step, run here at once on the whole
+# tree. A pull request in the site builds and dry-deploys it through ci.yml's
+# lanes; the lint and the tests run here, and by hand before a push.
+LANDING_CHECKS=(
+ "pnpm install --frozen-lockfile"
+ "pnpm run wire:fixture"
+ "pnpm typecheck"
+ "pnpm lint"
+ "pnpm test"
+ "pnpm build"
+)
+checks() { # DIR LOG
+ local dir="$1" log="$2" cmd
+ for cmd in "${LANDING_CHECKS[@]}"; do
+ echo " \$ $cmd" | tee -a "$log"
+ if ! (cd "$dir" && bash -c "$cmd") >> "$log" 2>&1; then
+ echo "FAIL: \`$cmd\` failed in $dir" >&2; tail -40 "$log" >&2; return 1
+ fi
+ done
+}
+
+echo "── the offline bootstrap (testing/lib/bootstrap.sh)"
+tree="$scratch/$repo"
+bootstrap_offline "$root" "$tree" "$values" "$scratch/logs" > "$scratch/bootstrap.log" 2>&1 || {
+ echo "FAIL: the offline bootstrap stopped" >&2; tail -40 "$scratch/bootstrap.log" >&2; exit 1; }
+echo " 2 phases placed and landed"
+
+# ── 1. the finished site ───────────────────────────────────────────────────
+echo "── the finished site: install, the fixture render, typecheck, lint, test, build"
+checks "$tree" "$scratch/checks-site.log"
+
+# ── 2. the deploy lane's steps, for stage ──────────────────────────────────
+echo "── the stage lane: build-app, verify-build-output, deploy-dry-run"
+# The 01-product landing over the repository's empty first commit: every file
+# of the site changed, as on its pull request.
+s00="$(git -C "$tree" rev-parse HEAD~2)"; s01="$(git -C "$tree" rev-parse HEAD~1)"
+(cd "$tree" && orun plan --intent intent.yaml --trigger github-pull-request --changed \
+ --base "$s00" --head "$s01" --env stage --output "$scratch/plan.json") > "$scratch/plan.log" 2>&1 \
+ || { echo "FAIL: orun plan" >&2; tail -15 "$scratch/plan.log" >&2; exit 1; }
+python3 - "$scratch/plan.json" "$scratch/steps" <<'PY'
+import json, pathlib, sys
+plan = json.load(open(sys.argv[1]))
+out = pathlib.Path(sys.argv[2]); out.mkdir()
+job = next(j for j in plan["jobs"] if j["component"] == "web" and j["environment"] == "stage")
+for s in job["steps"]:
+ if s["id"] in ("build-app", "verify-build-output", "deploy-dry-run"):
+ (out / f"{s['id']}.sh").write_text(s.get("run") or "")
+ if s["id"] == "install-workspace-dependencies":
+ (out / "install.sh").write_text(s.get("run") or "")
+ (out / "install.wd").write_text(s.get("working-directory") or ".")
+ (out / "install.scope").write_text(s.get("scope") or "job")
+(out / "path").write_text(job.get("path") or "apps/web")
+for k, v in (job.get("env") or {}).items():
+ (out / "env").open("a").write(f"export {k}={json.dumps(v)}\n")
+PY
+# The job's private tree, staged as orun stages it. The source checkout
+# carries no build output (a CI checkout has none, so the plain-tree build's is
+# removed rather than copied in), and its dependencies are what the pinned
+# composition says: a lane-scoped install ran once in the source tree (step 1
+# ran the same command) and is linked in, or the job installs its own.
+rm -rf "$tree/apps/web/dist" "$tree/apps/web/.tanstack" "$tree/apps/web/.wrangler"
+work="$tree/.orun/runs/e2e/web.stage.verify-deploy/work"
+[ -f "$scratch/steps/install.sh" ] || { echo "FAIL: the stage lane has no install step" >&2; exit 1; }
+if [ "$(cat "$scratch/steps/install.scope")" = lane ]; then
+ python3 "$here/lib/stage-job.py" "$tree" "$work" --shared-deps
+ [ -L "$work/node_modules" ] || { echo "FAIL: the staged tree's node_modules is not the lane's symlink" >&2; exit 1; }
+ echo " staged: $(realpath --relative-to="$tree" "$work"); install scope: lane — node_modules → the source tree's"
+else
+ python3 "$here/lib/stage-job.py" "$tree" "$work"
+ echo " staged: $(realpath --relative-to="$tree" "$work"); install scope: job — installing inside it"
+ echo " ▸ install-workspace-dependencies"
+ (cd "$work/$(cat "$scratch/steps/path")/$(cat "$scratch/steps/install.wd")" && bash -e "$scratch/steps/install.sh") \
+ > "$scratch/install.log" 2>&1 || { echo "FAIL: the lane's install step" >&2; tail -30 "$scratch/install.log" >&2; exit 1; }
+ [ -d "$work/node_modules" ] && [ ! -L "$work/node_modules" ] \
+ || { echo "FAIL: the job's install did not land inside its own tree" >&2; exit 1; }
+fi
+for step in build-app verify-build-output deploy-dry-run; do
+ [ -f "$scratch/steps/$step.sh" ] || { echo "FAIL: the stage verify lane has no $step step" >&2; exit 1; }
+ echo " ▸ $step"
+ # The runner's per-job environment: the job's env (intent environment
+ # `env:`) and ORUN_ENVIRONMENT; the step runs in the component's directory.
+ if ! (cd "$work/$(cat "$scratch/steps/path")" && \
+ { [ -f "$scratch/steps/env" ] && source "$scratch/steps/env"; true; } && \
+ export ORUN_ENVIRONMENT=stage && bash -e "$scratch/steps/$step.sh") > "$scratch/$step.log" 2>&1; then
+ echo "FAIL: the deploy lane's $step step" >&2; tail -40 "$scratch/$step.log" >&2; exit 1
+ fi
+done
+
+# ── 3. the one Worker config, held to the build ───────────────────────────
+echo "── wrangler.jsonc against the config the Vite plugin wrote"
+app="$work/apps/web"
+python3 - "$app" <<'PY'
+import json, os, re, sys
+app = sys.argv[1]
+def jsonc(path):
+ return json.loads(re.sub(r"^\s*//.*$", "", open(path).read(), flags=re.M))
+ours = jsonc(os.path.join(app, "wrangler.jsonc"))
+built_path = os.path.join(app, "dist/server/wrangler.json")
+if not os.path.exists(built_path):
+ sys.exit("FAIL: the build wrote no dist/server/wrangler.json")
+built = json.load(open(built_path))
+problems = []
+def same(label, a, b):
+ if a != b:
+ problems.append(f"{label}: wrangler.jsonc has {a!r}, the plugin's config {b!r}")
+for key in ("name", "compatibility_date", "compatibility_flags", "no_bundle", "rules"):
+ same(key, ours.get(key), built.get(key))
+here = lambda rel: os.path.realpath(os.path.join(app, rel))
+there = lambda rel: os.path.realpath(os.path.join(app, "dist/server", rel))
+same("the entry", here(ours["main"]), there(built["main"]))
+same("the assets directory", here(ours["assets"]["directory"]), there(built["assets"]["directory"]))
+if problems:
+ print("FAIL: the committed Worker config is not the Worker the build made:", file=sys.stderr)
+ for p in problems:
+ print(f" - {p}", file=sys.stderr)
+ sys.exit(1)
+print(f" the same Worker: {ours['name']}, {ours['main']}, assets {ours['assets']['directory']}, "
+ f"{ours['compatibility_date']} {ours['compatibility_flags']}")
+PY
+for which in wrangler.jsonc dist/server/wrangler.json; do
+ out="$scratch/dry-$(basename "$which")"
+ (cd "$app" && pnpm exec wrangler deploy --dry-run --config "$which" --name "$repo-web-stage" --outdir "$out") \
+ > "$out.log" 2>&1 || { echo "FAIL: the dry-run deploy of $which" >&2; tail -20 "$out.log" >&2; exit 1; }
+ (cd "$out" && find . -type f | LC_ALL=C sort) > "$out.files"
+ grep -E '^Total Upload: ' "$out.log" > "$out.total" || { echo "FAIL: no upload size from $which" >&2; exit 1; }
+done
+cmp -s "$scratch/dry-wrangler.jsonc.files" "$scratch/dry-wrangler.json.files" \
+ || { echo "FAIL: the two configs upload different modules:" >&2
+ diff "$scratch/dry-wrangler.jsonc.files" "$scratch/dry-wrangler.json.files" >&2; exit 1; }
+cmp -s "$scratch/dry-wrangler.jsonc.total" "$scratch/dry-wrangler.json.total" \
+ || { echo "FAIL: the two configs upload different sizes" >&2; cat "$scratch"/dry-*.total >&2; exit 1; }
+echo " both upload the same $(wc -l < "$scratch/dry-wrangler.jsonc.files" | tr -d ' ') files — $(cat "$scratch/dry-wrangler.jsonc.total")"
+
+# ── 4. serve it, and smoke it as the deploy does ───────────────────────────
+echo "── wrangler dev over the built Worker"
+port=$(python3 -c "import socket;s=socket.socket();s.bind(('127.0.0.1',0));print(s.getsockname()[1]);s.close()")
+(cd "$work/apps/web" && exec setsid pnpm exec wrangler dev --config wrangler.jsonc --ip 127.0.0.1 --port "$port" \
+ --name "$repo-web-stage" --show-interactive-dev-session=false) > "$scratch/dev.log" 2>&1 < /dev/null &
+dev_pid=$!
+url="http://127.0.0.1:$port"
+for _ in $(seq 1 90); do
+ curl -s -o /dev/null "$url/" && break
+ kill -0 "$dev_pid" 2>/dev/null || { echo "FAIL: wrangler dev exited" >&2; tail -30 "$scratch/dev.log" >&2; exit 1; }
+ sleep 1
+done
+curl -s -o /dev/null "$url/" || { echo "FAIL: wrangler dev never answered" >&2; tail -30 "$scratch/dev.log" >&2; exit 1; }
+
+echo " ▸ the component's own smokeCommand, DEPLOYED_URL=$url"
+smoke="$(python3 -c "import yaml,sys;print(yaml.safe_load(open(sys.argv[1]))['spec']['parameters']['smokeCommand'])" "$tree/apps/web/component.yaml")"
+DEPLOYED_URL="$url" bash -c "$smoke" || { echo "FAIL: the deploy's smoke refused the site" >&2; exit 1; }
+
+echo " ▸ every route the site promises"
+python3 - "$url" "$values" "$work/apps/web" "$here/lib/serverfn-payload.mjs" <<'PY'
+import glob, html, json, re, subprocess, sys, urllib.error, urllib.request
+base, values, app, payload_js = sys.argv[1], json.load(open(sys.argv[2])), sys.argv[3], sys.argv[4]
+name = values["productname"]
+problems = []
+def bad(m): problems.append(m)
+def get(path, data=None, headers=None, method=None):
+ req = urllib.request.Request(base + path, data=data, headers=headers or {}, method=method)
+ try:
+ with urllib.request.urlopen(req, timeout=60) as r:
+ return r.status, r.headers, r.read()
+ except urllib.error.HTTPError as e:
+ return e.code, e.headers, e.read()
+def markup(page): # the rendered HTML, without the scripts that carry the loaders' data
+ return re.sub(r"