Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .baseline/product/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment and whose schema is applied by migrations before every deploy.

<!-- 02-docs:begin -->
Not recorded yet. The bootstrap's last phase writes the live URLs, the
workspace and the secrets inventory into
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).
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- uses: actions/checkout@v6
- uses: sourceplane/orun-action@v1.2.0
with:
version: v2.87.0
version: v2.88.0
- uses: pnpm/action-setup@v4
with:
version: 10.12.1
Expand Down Expand Up @@ -104,11 +104,12 @@ jobs:
# dependsOn edge's `modeRules` (advisory on a PR, enforced on main). The
# test refuses an orun older than the pin rather than assert the wrong
# CLI's plan. The offline bootstrap before it reads the blueprint, which
# takes the bootstrap floor (v2.87.0, the one `secrets` reconcile), so
# takes the bootstrap floor (v2.88.0: the task set-up in the background,
# the landings checked in the box), so
# this tier runs the floor, which is newer than the lane pin.
- uses: sourceplane/orun-action@v1.2.0
with:
version: v2.87.0
version: v2.88.0
- name: placement — the offline bootstrap, and the product's own plan
run: |
git config --global user.email ci@example.invalid
Expand All @@ -120,7 +121,7 @@ jobs:
# (the live wiring render included), output check and dry deploy in the tree
# orun stages, the migration lane's plan and apply (against a stand-in D1
# API), and the built Worker served and smoke-tested with the component's
# own smoke command. Pinned at the bootstrap floor (v2.87.0): the offline
# own smoke command. Pinned at the bootstrap floor (v2.88.0): the offline
# bootstrap reads the blueprint, and the floor is newer than the product's
# lane pin (v2.78.4), which is all the lane steps need.
site:
Expand All @@ -129,7 +130,7 @@ jobs:
- uses: actions/checkout@v6
- uses: sourceplane/orun-action@v1.2.0
with:
version: v2.87.0
version: v2.88.0
- uses: pnpm/action-setup@v4
with:
version: 10.12.1
Expand Down
41 changes: 23 additions & 18 deletions BOOTSTRAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@ not separate workflows. The console card the platform renders is
brokered secrets and the programme, and `testing/manifest.test.sh` holds it
to what the build document does.

Target wall-clock: **about sixteen minutes** — an estimate summed from the
phases until a bootstrap measures it: ONE landing whose pull request waits on
`plan`, then one convergence — per environment the D1
database applied, then its migrations, then the site built with its id and
deployed, stage and prod side by side — then a short docs landing that
restores the promotion gate.
Target wall-clock: **about five minutes** from the build box's boot, summed
from the phases (4 + 1). A v6 build measured 5:14; v8 takes about a minute
out of 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), then one convergence — per environment the D1 database
applied, then its migrations, then the site built with its id and deployed,
stage and prod side by side — then a short docs landing that restores the
promotion gate.

## 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.87.0** — the floor for RUNNING the bootstrap (the phase overlay,
landings that commit per phase and wait on the PR's whole CI run,
`githubOwner` on the doctor probe, `environments` on the secrets probe, a
probe deferred for a project not yet created, `from: workspace`, and the
deploy credentials minted in one `secrets` reconcile). The product's own
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 product'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 a D1 database per environment) and its **Account API token**
Expand Down Expand Up @@ -81,8 +84,8 @@ phase whose files are present but branded derives as `drifted`, and

| phase | what it lands | verified by |
|---|---|---|
| `01-product` | the repository, created and linked; the WHOLE product in one PR — intent, CI, tooling, identity, the D1 root, the migrations, the site and its tests; the brokered Cloudflare secrets (the deploy token, the D1 token, the account id) | its PR's checks green and merged; the convergence green (D1 applied, then migrated, then the site built, deployed, smoke-tested); `WIRING_CLOUDFLARE_D1` on stage and prod; both workers.dev URLs answering |
| `02-docs` | `ai/context/deployment.md` from probed facts; prod's promotion gate and dev's push lanes restored | the final probe |
| `01-product` | the repository, created and linked; the WHOLE product in one PR — intent, CI, tooling, identity, the D1 root, the migrations, the site and its tests; the brokered Cloudflare secrets (the deploy token, the D1 token, the account id) | its commit validated and planned in the box (as the PR and as the merge), then merged; the convergence green (D1 applied, then migrated — which resolves `WIRING_CLOUDFLARE_D1` — then the site built, deployed, smoke-tested); both workers.dev URLs answering |
| `02-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-todos --run-hooks \
Expand Down Expand Up @@ -134,9 +137,9 @@ per environment:
- A job resolves its secrets when it STARTS, so `WIRING_CLOUDFLARE_D1` is
there when the migrations begin, and `WIRING_CLOUDFLARE_D1_<ENV>` when the
deploy does.
- The landing's `await` then asks the platform that the wiring exists on
stage and prod (`orun.secrets/exists@v1`) — every later migration and
deploy reads it.
- Both readers resolve the document from the place every later run looks
(their `component.yaml` secret refs), so a green convergence already says
it is there: a missing one fails their lane. There is no separate check.

`testing/phases.test.sh` fails if a component that reads a wiring document
does not wait for its publisher this way, or if a deployable that binds the
Expand Down Expand Up @@ -241,12 +244,14 @@ at the tag and refuses the whole catalogue if it 404s.
| db-migrate lane: `Checksum mismatch for already-applied migrations` | an applied migration's file was edited; restore it and put the change in a new migration |
| web lane fails resolving `WIRING_CLOUDFLARE_D1_<ENV>` | that environment's D1 apply failed — read its lane; the web lane waits on it |
| the smoke fails on a "no `todos` table" notice | the migrations did not reach the database the Worker binds — read the db-migrate lane for that environment |
| `wiring` await stops: `WIRING_CLOUDFLARE_D1` missing on stage or prod | the convergence was green but the apply published nothing: the D1 component lost its `secretOutputs`, or its lane was not in the plan. Re-run the phase; its retouch marker re-plans the D1 root |
| db-migrate or web lane: `WIRING_CLOUDFLARE_D1` not found | that environment's D1 apply published nothing: the D1 component lost its `secretOutputs`, or its lane was not in the plan. Re-run the phase; its retouch marker re-plans the D1 root |
| `land` stops: `the landing's own check failed — orun plan for …` | the product'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 product'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 D1 root, the migrations and the site re-plan; applied migrations are skipped |
| The product's `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace; set it and re-run `01-product` |
| A bootstrap stopped before `02-docs`; prod no longer waits on stage | the gate is deferred, not dropped: run `02-docs`, or `node tooling/bootstrap/promotion.mjs --restore --file <product>/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 "secrets"` or another parse error in the blueprint | the CLI is below the v2.87.0 floor |
| `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 |
| web lane `verify-app-structure` fails on `wrangler.jsonc` | the config is not committed. It is the fixture render of `wrangler.template.jsonc`: `pnpm run wire:fixture` and commit it |
| web lane `build-app`: `Symlink apps/web/node_modules/next is invalid, it points out of the filesystem root` | the product's intent pins stack-tectonic ≥ 0.20.0, whose lane-scoped install links each job's node_modules out of its tree, which Next 16's Turbopack refuses. Pin 0.19.0 (`intent.yaml` says why) |
| the convergence reported green, then `verify` got 404 | 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 |
2 changes: 1 addition & 1 deletion ai/context/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

> Not rendered yet. The bootstrap's `02-docs` phase probes every live URL and
> regenerates this file from what answered — the workspace, the URLs and
> their status, and the secrets inventory by name. Until then, nothing here
> 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).
2 changes: 1 addition & 1 deletion ai/context/operations.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# turso-starter — operating contract (for humans and agents)

This is the standing guide to how this site is deployed and operated.
Instance facts (live URLs, workspace, secrets inventory) live in
Instance facts (live URLs, workspace, the secrets it uses) live in
[deployment.md](deployment.md), rendered from probed reality by the
bootstrap's `02-docs` phase; this file is the contract that stays true
between deployments. It is written to give an agent with repository read
Expand Down
9 changes: 5 additions & 4 deletions blueprint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ metadata:
D1 database Terraform provisions per environment, its schema applied by
db-migrate, and CI that applies the database, migrates it and deploys the
site to stage and prod on merge. One provider, one consent. Live in about
fifteen minutes, in one landing.
five minutes, in one landing.
tags: [todos, d1, sqlite, cloudflare, nextjs]
spec:
source:
Expand Down Expand Up @@ -147,9 +147,10 @@ spec:
# 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. An estimate until a bootstrap
# measures it.
expectedMinutes: 16
# Summed from the phases' expectedMinutes (4 + 1), which come from a
# measured build: 5:14 from the box's boot on v6, less the minute v8 takes
# out of it.
expectedMinutes: 5
tokenChannel: ORUN_TOKEN_FILE # how a runner hands over its refreshed token
verify:
urls:
Expand Down
25 changes: 15 additions & 10 deletions docs/phases/01-product.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,24 @@ waits.

## 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 |
|---|---|
| `task` (pre) | finds the phase's task and yields its key |
| `retouch` | the redeploy marker on the components `.baseline/tasks/01-product.TaskContract.yaml` names: `cloudflare-d1`, `db`, `db-migrate`, `db-tests`, `web`, `web-tests` |
| `git-init`, `stage`, `rebrand` | the tree becomes a repository, then the product's |
| `orun-workspace` | intent.yaml's `workspace:` becomes the product's (or `ws_SET_ME`, which fails loudly) |
| `work-tree` | intent.yaml's `work:` block — this repository's epics and tasks — is removed |
| `promotion`, `dev-lanes` | prod's promotion gate and dev's push-to-main activation deferred until `02-docs` |
| `restage`, `rebrand-verify` | the sweep: no identity of this baseline left anywhere |
| `pnpm-lockfile` | confirms the baseline's complete lockfile against the placed tree |
| `repo` | `orun.repo/ensure@v1` creates `<githuborg>/<reponame>` (or finds it) |
| `link` | the repository becomes the workspace's; `orun cloud check` is the gate |
| `secrets` | `orun.integrations/reconcile@v1`, the three keys in one hook, created side by side: `CLOUDFLARE_API_TOKEN` from the `workers-deploy` template (Workers Scripts, the site's deploy); `CLOUDFLARE_D1_TOKEN` from `d1-edit` (D1, for the database's apply and the migrations — the deploy token cannot touch D1); `CLOUDFLARE_ACCOUNT_ID`, the connection fact all three bind |
| `land` | one PR bound to the task, merged once its check (`plan`) is green |
| `converge` (await) | `orun.run/watch@v1` on the merge commit's run; resumes it up to three times |
| `wiring` (await) | `orun.secrets/exists@v1` — `WIRING_CLOUDFLARE_D1` exists on stage and prod |
| `task` | finds the phase's task 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
Expand All @@ -47,14 +49,16 @@ by side:
| `stage · web` / `prod · web` | that environment's D1 apply and its migrations (`dependsOn` both, `mode: enforced` on main) | resolves `WIRING_CLOUDFLARE_D1_<ENV>`, renders `wrangler.jsonc` with the real database id, builds with OpenNext, deploys `<reponame>-web-<env>`, and smoke-tests it: `/` must render the list's row count (`data-todos="N"`), which only the Worker querying its migrated database can |

`web-tests`, `db-tests` and `db` verify on dev only, on a pull request. The
landing's own pull request runs `plan` alone: the baseline's own CI ran their
checks on this exact tree before the tag was cut, and every later pull
request in the product runs them.
landing's own pull request runs `plan` alone, and nothing waits for it — the
same plan ran in the box before the push: the baseline's own CI ran the
lanes' checks on this exact tree before the tag was cut, and every later
pull request in the product runs them.

## Verified

The convergence run for the merge commit is green; `WIRING_CLOUDFLARE_D1`
exists on stage and prod; `https://<reponame>-web-{stage,prod}.<subdomain>.workers.dev`
The convergence run for the merge commit is green — its migrations and the
site resolved `WIRING_CLOUDFLARE_D1` from stage and prod, where every later
run reads it; `https://<reponame>-web-{stage,prod}.<subdomain>.workers.dev`
answer.

## Troubleshooting
Expand All @@ -64,6 +68,7 @@ answer.
| parks on the `providers` probe | GitHub (on the repository's owner) or Cloudflare is not connected to the workspace. Connect it (console → Integrations), then re-run the phase — the probe is a wait, not a failure |
| 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 |
| D1 lane: a database with this name already exists | `adopt.tf` imports a database of the same name; if it was removed, restore it. Two products with the same `reponame` in one account share a name — use a distinct `reponame` |
| `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 |
| D1 or db-migrate lane: Authentication error (10000) | the connection's token cannot mint D1 Edit (`d1-edit`). Re-issue it with the permission groups the console's Connect recipe lists, re-connect, re-run the phase |
| deploy lane: Authentication error (10000) | the connection's token lacks Workers Scripts write (`workers-deploy`); same fix |
| db-migrate lane: `No D1 database id` | the job started without `WIRING_CLOUDFLARE_D1` — that environment's D1 apply failed or never ran, or the `dependsOn` edge is gone from `infra/db-migrate/component.yaml` |
Expand Down
7 changes: 3 additions & 4 deletions docs/phases/02-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ no phase may require this one.)

| hook | what it does |
|---|---|
| `task` (pre) | finds the phase's task and yields its key |
| `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 `/` on both environments (and whether each page rendered its D1-backed list), lists the secrets by name and the workspace's integrations, and regenerates `ai/context/deployment.md` and the README's live-deployment section |
| `land` | one PR, waited for and merged. It touches no component, so it deploys nothing |
| `verify` (await) | the same probe `01-product` ended on |
| `render` | `hooks/render-deployment-docs.sh`: probes `/` on both environments (and whether each page rendered its D1-backed list) 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

Expand Down
Loading
Loading