From c9979898ed3e5e6f4a1680d69daed1dad11891e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 25 Oct 2026 09:42:20 +0000 Subject: [PATCH] =?UTF-8?q?CM7:=20the=20turso=20v8=20shape=20=E2=80=94=20o?= =?UTF-8?q?ne=20secrets=20hook,=20no=20Checks,=20docs=20in=20the=20catalog?= =?UTF-8?q?,=20tasks=20in=20the=20background,=20landings=20checked=20here?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit What sourceplane/turso-starter became across baseline-v6, v7 and v8, made here for the storefront. Floor: orun v2.88.0. A. One secrets hook. secret-workers-deploy, secret-r2-data and secret-account-id (same provider, no other parameters) are one `secrets` reconcile, the keys and templates in the card's order: CLOUDFLARE_API_TOKEN (workers-deploy), CLOUDFLARE_R2_TOKEN (r2-data), CLOUDFLARE_ACCOUNT_ID (account-id). The two scopes stay two: each key keeps its own template, so the deploy token still carries no R2. manifest.test.sh reads the `secrets: [{key, template}]` form beside `keys`. B. No Checks workflow. checks.yml is gone; the landing is checked by `plan` (now in the box), and the baseline's Tier 2 runs install, the fixture render, typecheck, lint, test and build on the landing from its own LANDING_CHECKS list (the steps checks.yml ran). Every component attaches its generated overview, architecture and runbook in spec.docs (the pages already shipped), web-tests has a description (its overview regenerated with tooling/catalog/gen-component-docs.py), and apps/web's domain is `app`, not `web`, which was also the component's name. coverage.test.sh holds both rules, reading spec.domain and labels.domain. web-tests' quick-check lane only installs and checks the package, so a product's pull requests run neither vitest nor eslint; the docs say so and tell the product's developers to run them before they push. C. The fast shape. Every preInstantiate hook is `background: true`; each phase's `task` moves from `pre` to `post`, just before its landing; both landings are `checks: local`; the convergence watch reads every 5 s; the `pnpm-lockfile` hook is gone (the lockfile is installed frozen by the lanes and by Tier 2). The `wiring` await is gone: its one key, WIRING_CLOUDFLARE_R2, is resolved on stage and prod by the storefront's deploy job (apps/web secretEnv, a required ref, enforced on main) before its first step, fail-closed, so a green convergence already proves it; no key stays awaited. 02-docs loses its final probe and its narrate.await. The render hook asks the platform nothing (it made five CLI calls: the workspace slug, three secret listings, the integrations) and lists the secrets the store uses and where they live. expectedMinutes 14 + 2 becomes 13 + 1 (card 14, "about fourteen minutes"). These are estimates, not measurements. phases.test.sh holds the fast shape and checks that every published wiring document is resolved on stage and prod by a component, which is the reason the await could go; narrate.await only where a phase awaits. baseline.yml pins v2.88.0 on the blueprint, placement and site tiers, and the blueprint job's setup-node asks for no pnpm cache; ci.yml's lane pin (v2.78.4) is unchanged. specs/, tasks/ and ai/context/decisions.md are left as they were. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CJuLwDKfEaQGAEuBpJvN5Q --- .baseline/product/README.md | 16 +- .github/workflows/baseline.yml | 45 +++-- .github/workflows/checks.yml | 51 ----- BOOTSTRAP.md | 58 +++--- README.md | 10 +- ai/context/deployment.md | 4 +- ai/context/operations.md | 15 +- apps/web/component.yaml | 12 +- blueprint.yaml | 26 +-- docs/phases/01-product.md | 36 ++-- docs/phases/02-docs.md | 7 +- docs/phases/README.md | 33 +-- hooks/render-deployment-docs.sh | 65 +++--- infra/terraform/cloudflare-r2/component.yaml | 8 + repo-blueprint.yaml | 199 ++++++++++--------- testing/coverage.test.sh | 46 ++++- testing/e2e.test.sh | 43 ++-- testing/leak.test.sh | 2 +- testing/lib/bootstrap.sh | 4 +- testing/manifest.test.sh | 9 +- testing/phases.test.sh | 118 ++++++++--- testing/placement.test.sh | 14 +- tests/web/component.yaml | 9 + tests/web/docs/overview.md | 2 + tooling/catalog/gen-component-docs.py | 7 +- 25 files changed, 478 insertions(+), 361 deletions(-) delete mode 100644 .github/workflows/checks.yml diff --git a/.baseline/product/README.md b/.baseline/product/README.md index c68a541..c353e35 100644 --- a/.baseline/product/README.md +++ b/.baseline/product/README.md @@ -17,7 +17,7 @@ says plainly that a payment provider must be connected first. Not recorded yet. The bootstrap's last phase writes the live URLs, the -workspace and the secrets inventory into +workspace and the secrets the store uses into [ai/context/deployment.md](ai/context/deployment.md); how the store deploys and how to operate it is in [ai/context/operations.md](ai/context/operations.md). @@ -122,9 +122,9 @@ revalidation of stale routes, through the Worker's own local work and verification, and on every deploy from the document the `cloudflare-r2` Terraform root publishes after its apply (`WIRING_CLOUDFLARE_R2`, per environment). Edit the template, then -`pnpm run wire:fixture`; Checks fails if the committed `wrangler.jsonc` is not -the fixture render. The Durable Objects need no root: the migration in the -config creates them on the first deploy. +`pnpm run wire:fixture` and commit the render with the template. The Durable +Objects need no root: the migration in the config creates them on the first +deploy. ## How it deploys @@ -136,9 +136,11 @@ storefront builds with that environment's bucket name and deploys — to only verifies. The Worker is `commerce-web-` on your account's workers.dev subdomain, and every deploy is smoke-tested over HTTP: the home page must answer, and `robots.txt` must name the origin it was asked on, which -only the Worker renders. `checks.yml` runs install, the fixture render, -typecheck, lint, test and build on every pull request. (A push to `main` runs -`ci.yml` alone, which applies, builds and deploys.) +only the Worker renders. A pull request runs the same pipeline's verify lanes, +with nothing applied or deployed: the R2 bucket planned for stage and prod, +and the storefront built and dry-deployed for each environment. They do not +run the tests or the linter — run those before you push (Getting started, +above). (A push to `main` applies, builds and deploys.) The pipeline holds one credential, GitHub's own `GITHUB_TOKEN`. The Cloudflare tokens and account id are brokered per run from the workspace's Cloudflare diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index dcf0435..08354df 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -8,7 +8,7 @@ name: Baseline CI # bucket before the Worker on a merge — and that the product it produces # installs, builds, deploys (dry), serves, and takes a cart. # -# ─── WHY THIS IS NOT IN ci.yml OR checks.yml ────────────────────────────── +# ─── 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 @@ -69,20 +69,26 @@ jobs: # floor too), and the placement tier (the offline bootstrap: both phases # placed and finished by the blueprint's own hooks, then the product's own # `orun plan` for the 01-product merge — the R2 apply before the Worker's - # deploy — under the product's lane pin, below). + # deploy — by an orun at or above the product's lane pin, below). blueprint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: sourceplane/orun-action@v1.2.0 with: - version: v2.58.11 + 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 @@ -98,34 +104,39 @@ jobs: - name: the leak gate — what a product carries run: bash testing/leak.test.sh # The placement tier ENDS with the product's own `orun plan` — what the - # product's ci.yml runs — so it runs under the product's lane pin, not - # the bootstrap floor. v2.58.11 plans a pull request with apps/web - # waiting on the R2 plan: it does not apply a dependsOn edge's - # `modeRules`. The lane pin does (advisory on a PR, enforced on main), - # and the test refuses an orun older than the pin rather than assert - # the wrong CLI's plan. Its placements are valid under either. + # product's ci.yml runs — so it needs an orun at the product's lane pin + # or newer: one older than v2.78.4 plans a pull request with apps/web + # waiting on the R2 plan, because it does not apply a 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.88.0: the one `secrets` reconcile, 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.78.4 + version: v2.88.0 - name: placement — the offline bootstrap, and the product'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 PRODUCT IT PRODUCES WORKS: its one landing under the checks - # its pull request waits on, the stage lane's own structure check, build - # (the live wiring render included), output check and dry deploy in the tree - # orun stages, and the built Worker served and smoke-tested with the - # component's own smoke command. Pinned at the product's lane version, - # because that is the orun the product's CI runs. + # Tier 2. THE PRODUCT IT PRODUCES WORKS: its one landing installed, its + # fixture rendered, type-checked, linted, tested and built, the stage lane's + # own structure check, build (the live wiring render included), output check + # and dry deploy in the tree orun stages, 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, and + # the floor is newer than the product'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.78.4 + version: v2.88.0 - uses: pnpm/action-setup@v4 with: version: 10.12.1 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml deleted file mode 100644 index 1426539..0000000 --- a/.github/workflows/checks.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Checks - -# Credential-free verification: install, render the offline wrangler fixtures, -# typecheck, lint, test and build, on every pull request, linked or not. -# `ci.yml` is the Orun pipeline beside it (plan/run with brokered Cloudflare -# credentials, deploys on merge); it plans nothing until intent.yaml names a -# workspace. -# -# PULL REQUESTS ONLY — not pushes to main. A push to main must start exactly -# one workflow, `ci.yml`, because the bootstrap's convergence watch -# (`orun.run/watch@v1` with `sha:`) takes the newest run for the merge commit -# from ANY workflow. With this one on push too, the first live bootstrap -# watched this run go green while ci.yml's deploy lanes had failed, and called -# the site converged. On main the convergence builds and tests the site -# anyway. The baseline's coverage gate holds the rule. -on: - pull_request: - workflow_dispatch: - -concurrency: - group: checks-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -permissions: - contents: read - -jobs: - checks: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: pnpm/action-setup@v4 - with: - version: 10.12.1 - - uses: actions/setup-node@v5 - with: - node-version: 22 - cache: pnpm - - run: pnpm install --frozen-lockfile - # Templated deployables render their wrangler config from the committed - # fixture; an unresolved wiring token fails here, not at deploy time. - - run: pnpm run wire:fixture - # …and the render is what is committed. The deploy lane checks that the - # config exists before it builds, so wrangler.jsonc is in the tree as the - # fixture render; a template edited without re-rendering fails here. - - name: the committed wrangler config is the fixture render - run: git diff --exit-code - - run: pnpm typecheck - - run: pnpm lint - - run: pnpm test - - run: pnpm build diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index a695838..e37eb90 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -12,23 +12,26 @@ 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 -Checks (a full Next.js build), then one convergence — the R2 bucket applied -on stage and prod, then the storefront built with its name and deployed, -stage and prod side by side — then a short docs landing that restores the -promotion gate. +Target wall-clock: **about fourteen minutes** — an estimate summed from the +phases (13 + 1) until a bootstrap measures it; no build of this baseline has +been timed. 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 — the R2 bucket applied on stage +and prod, then the storefront built with its name 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.58.11** — 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, and `from: workspace`). The - product's own `ci.yml` pins its lanes separately (v2.78.4), and its plans - need that pin: the floor does not apply a `dependsOn` edge's `modeRules`. + 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 with **R2 enabled** (R2 must be activated once in the dashboard, even on the free plan; Durable Objects with SQLite storage are on the free plan too) and its **Account API token** with Workers Scripts @@ -87,8 +90,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 R2 root, the storefront and its tests; the brokered Cloudflare secrets (deploy, R2, account id) | its PR's checks green and merged; the convergence green (R2 applied, then the storefront built, deployed, smoke-tested); `WIRING_CLOUDFLARE_R2` 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 R2 root, the storefront and its tests; the brokered Cloudflare secrets (deploy, R2, account id) | its commit validated and planned in the box (as the PR and as the merge), then merged; the convergence green (R2 applied, then the storefront — which resolves `WIRING_CLOUDFLARE_R2` — 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-shop --run-hooks \ @@ -135,8 +138,9 @@ need landings of its own. It does not, because the product's plan holds it: environment's apply; on a pull request nothing deploys, so nothing waits. - A job resolves its secrets when it STARTS, so `WIRING_CLOUDFLARE_R2_` is there when the deploy begins. -- The landing's `await` then asks the platform that the wiring exists on - stage and prod (`orun.secrets/exists@v1`) — every later deploy reads it. +- The deploy resolves the document from the place every later run looks + (its `component.yaml` secret refs), so a green convergence already says it + is there: a missing one fails its 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; `testing/placement.test.sh` plans @@ -147,8 +151,10 @@ the product's own merge and asserts the R2 lanes run first. `workers-deploy` grants Workers Scripts and KV write — and no R2. The R2 root's Terraform has to list the account's buckets (`adopt.tf`) and create one, so it authenticates with its own key, `CLOUDFLARE_R2_TOKEN`, minted from -the `r2-data` template by a second `orun.integrations/reconcile@v1` hook and -bound in `infra/terraform/cloudflare-r2/component.yaml` as the provider's +the `r2-data` template — its own entry in the one +`orun.integrations/reconcile@v1` hook (`secrets`), beside the deploy token's +`workers-deploy` — and bound in +`infra/terraform/cloudflare-r2/component.yaml` as the provider's `CLOUDFLARE_API_TOKEN` (the way a D1 root binds a `d1-edit` token). The card (`blueprint.yaml` `spec.secrets`) mirrors the hook, and `testing/manifest.test.sh` holds the two together. @@ -217,9 +223,9 @@ bash testing/e2e.test.sh # + network for pnpm: the product built in the The offline bootstrap (`testing/lib/bootstrap.sh`) places both phases in order and finishes each with the blueprint's OWN `run:` hooks — read out of `repo-blueprint.yaml`, not transcribed — so the retouch marker, the rebrand, -the re-tenant, the deferrals and their restore, the lockfile and the -deployment record all run exactly as a real bootstrap runs them. Only the -platform's typed actions (task, repo, link, reconcile, land, watch, secrets, +the re-tenant, the deferrals and their restore, and the deployment record +all run exactly as a real bootstrap runs them. Only the platform's typed +actions (task, repo, link, reconcile, land, watch, secrets, probe) are stood in for, a landing becoming a commit. What no offline test can do is the platform's half: the bucket applied for real (the R2 root is held to `terraform validate`), the tokens minted, the deploy, the probes — @@ -249,18 +255,20 @@ at the tag and refuses the whole catalogue if it 404s. | `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 | | `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 | | Secret WRITE fails `not_found` while listings work | the API key's role is below admin; re-mint it with the admin role | -| `secret-r2-data` fails `parent_grant_insufficient` | the connection's token lacks Workers R2 Storage Write; add it, re-connect, re-run `01-product` | +| `secrets` fails `parent_grant_insufficient` on `CLOUDFLARE_R2_TOKEN` | the connection's token lacks Workers R2 Storage Write; add it, re-connect, re-run `01-product` | | R2 lane: Authentication error (10000) | the R2 root is not authenticating with `CLOUDFLARE_R2_TOKEN` (its component.yaml), or the account has not activated R2 | | deploy lane: Authentication error (10000) | the connection's token lacks Workers Scripts write; re-issue it, re-connect, re-run `01-product` | | R2 lane: bucket already exists (10004) | `adopt.tf` imports a bucket of the same name; restore it if removed. Two products with one `reponame` in one account share bucket names — pick another `reponame` | | web lane fails resolving `WIRING_CLOUDFLARE_R2_` | that environment's R2 apply failed — read its lane; the web lane waits on it | -| `wiring` await stops: `WIRING_CLOUDFLARE_R2` missing on stage or prod | the convergence was green but the apply published nothing: the R2 component lost its `secretOutputs`, or its lane was not in the plan. Re-run the phase; its retouch marker re-plans the R2 root | +| web lane: `WIRING_CLOUDFLARE_R2` not found | that environment's R2 apply published nothing: the R2 component lost its `secretOutputs`, or its lane was not in the plan. Re-run the phase; its retouch marker re-plans the R2 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 R2 root and the storefront re-plan | | The live store shows the demo banner | no Shopify store is connected — expected after a bootstrap. The product's README, "Connecting Shopify" | | 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 /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` or a parse error in the blueprint | the CLI is below the v2.58.11 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 (`checks.yml` is pull-request only) | +| 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 | diff --git a/README.md b/README.md index d044ccc..5d9ccdc 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,8 @@ route at request time. ``` infra/terraform/cloudflare-r2 ──apply (r2-data token)──► orun secret WIRING_CLOUDFLARE_R2 (stage, prod) - │ (the landing's await checks it exists) + │ (each deploy resolves it as it starts; + │ a missing one fails the lane) ▼ apps/web dependsOn cloudflare-r2 (enforced on main) · secretEnv WIRING_CLOUDFLARE_R2_ build: tooling/wire/live.mjs → wrangler.jsonc with the environment's bucket name @@ -125,14 +126,13 @@ apps/web dependsOn cloudflare-r2 (enforced on main) · secretEnv WIRING_CLOUDFL `wrangler.jsonc` is committed as the fixture render of `wrangler.template.jsonc`, because the deploy lane's `verify-app-structure` -step checks the config exists before it builds; Checks fails if the two -disagree. +step checks the config exists before it builds; `testing/e2e.test.sh` fails +if the two disagree. ## CI | Workflow | What it runs | Ships to a product | |---|---|---| -| `checks.yml` | install, wire fixtures (and the committed config is their render), typecheck, lint, test, build — every PR (not pushes: on main, `ci.yml` must be the only run a commit has, because the bootstrap's convergence watch takes the newest one) | yes | -| `ci.yml` | the Orun pipeline: `orun plan --changed`, then one job per lane; applies the R2 bucket, then deploys stage → prod on merge. It plans nothing while `intent.yaml` names the placeholder workspace `ws_CHANGE_ME`, as this repository does | yes | +| `ci.yml` | the Orun pipeline, and the only workflow a product carries: `orun plan --changed`, then one job per lane. A pull request runs the verify lanes (the R2 root planned for stage and prod, the storefront built and dry-deployed per environment; they neither lint nor run the tests, which `baseline.yml`'s e2e tier runs before every tag), except the bootstrap's own landings (`orun/BASE-*`), where `plan` alone runs and nothing waits for it (the landing checked its commit in the box); a merge applies the R2 bucket, then deploys stage → prod. It plans nothing while `intent.yaml` names the placeholder workspace `ws_CHANGE_ME`, as this repository does | yes | | `baseline.yml` | the baseline's own tiers: contract tests, the wiring path, the blueprint read by the pinned orun, the leak gate, the offline bootstrap with the product's own plan, the product built in the job tree, dry-deployed, served, browsed and added to the cart | no | | `tag.yml` | cuts a `baseline-vN` tag (manual) | no | diff --git a/ai/context/deployment.md b/ai/context/deployment.md index 7b60298..39f4e66 100644 --- a/ai/context/deployment.md +++ b/ai/context/deployment.md @@ -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, which store backend answered, and the secrets inventory by -> name. Until then, nothing here claims the store is live. The operating +> their status, which store backend answered, and the secrets the store uses, +> by name. Until then, nothing here claims the store is live. The operating > contract is [operations.md](operations.md). diff --git a/ai/context/operations.md b/ai/context/operations.md index b11b6e2..f6d05e6 100644 --- a/ai/context/operations.md +++ b/ai/context/operations.md @@ -1,7 +1,7 @@ # commerce — operating contract (for humans and agents) This is the standing guide to how this store 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 @@ -25,14 +25,16 @@ component-native desired-state repo. Worker binds the bucket (`NEXT_INC_CACHE_R2_BUCKET`) and exports two Durable Objects: the tag cache and the revalidation queue. - **`tests/web`** — the Shopify client, the demo catalogue and cart, the - webhook and the URL helpers (vitest), verified on the `dev` rung. + webhook and the URL helpers (vitest). Its `dev` lane installs the package + and checks its structure; it does not run the suite or the linter, so run + `pnpm typecheck`, `pnpm lint` and `pnpm test` before you push. - **`tooling/*`** — shared TypeScript and ESLint configuration, and the wrangler renderer that turns `wrangler.template.jsonc` plus a wiring document into `wrangler.jsonc`. Environments: **`stage`** and **`prod`** are deployed; **`dev` is -verify-only by design** — lanes build and test, nothing deploys, and no -bucket exists for it (its build renders the committed fixture). +verify-only by design** — lanes build and dry-deploy, nothing deploys, and +no bucket exists for it (its build renders the committed fixture). ## Identity and tenancy @@ -76,8 +78,9 @@ Caveats that matter: 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`. -- `wrangler.jsonc` is generated. Edit `wrangler.template.jsonc` and run - `pnpm run wire:fixture`; Checks fails when the two disagree. +- `wrangler.jsonc` is generated. Edit `wrangler.template.jsonc`, run + `pnpm run wire:fixture` and commit both; the deploy renders its own + config from the template, so a stale committed render misleads local work. ## The store backend diff --git a/apps/web/component.yaml b/apps/web/component.yaml index 0ed407d..ea99071 100644 --- a/apps/web/component.yaml +++ b/apps/web/component.yaml @@ -7,7 +7,17 @@ spec: type: cloudflare-workers-assets-turbo lifecycle: production owner: platform - domain: web + # Its pages, attached to it in the workspace's catalog: what the Docs + # library shows for it, and what the catalog's docs and runbook checks read. + # Generated from what this manifest and its sources declare. + docs: + overview: docs/overview.md + pages: + - { path: docs/architecture.md, role: architecture, title: Architecture } + - { path: docs/runbook.md, role: runbook, title: Runbook } + # `app`, not `web`: a domain and a component share one name space in the + # catalog, and a domain called `web` hid this component from it. + domain: app path: apps/web # Its own lane per environment: the Next.js build is the longest job in the # plan, and a shared lane would wait on it. diff --git a/blueprint.yaml b/blueprint.yaml index fe5c62a..69b49cf 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -26,7 +26,7 @@ metadata: bucket and deploys the storefront to stage and prod on merge. It serves a bundled demo catalogue and a cookie cart until the owner connects a Shopify store; checkout asks for a payment provider until then. One - provider, one consent. Live in about sixteen minutes, in one landing. + provider, one consent. Live in about fourteen minutes, in one landing. tags: [storefront, shopify, r2, cloudflare, nextjs, terraform] spec: source: @@ -112,15 +112,15 @@ spec: # anything is created. from: connection.cloudflare.workersSubdomain - # ── PREVIEW ONLY. repo-blueprint.yaml's `orun.integrations/reconcile@v1` - # hooks mint these, brokered, during 01-product. ───────────────────────── - # Transcribed from those hooks' own `keys:` and `template:` values, 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. The bucket names are - # not here: they are not credentials, and the bucket's own apply publishes - # them. Nor are Shopify's: the platform does not broker them, and the - # storefront needs none to go live. + # ── PREVIEW ONLY. repo-blueprint.yaml's one `orun.integrations/reconcile@v1` + # hook (`secrets`) mints these, brokered, during 01-product. ────────────── + # Transcribed from that hook's own `secrets:` entries (each key and its + # template), in its order, 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. The bucket names are not here: they are not credentials, and the + # bucket's own apply publishes them. Nor are Shopify's: the platform does + # not broker them, and the storefront needs none to go live. secrets: - key: CLOUDFLARE_API_TOKEN provider: cloudflare @@ -154,9 +154,9 @@ 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 (13 + 1). An estimate until a + # bootstrap measures it: no build of this baseline has been timed. + expectedMinutes: 14 tokenChannel: ORUN_TOKEN_FILE # how a runner hands over its refreshed token verify: urls: diff --git a/docs/phases/01-product.md b/docs/phases/01-product.md index 10eda10..5cb6a5c 100644 --- a/docs/phases/01-product.md +++ b/docs/phases/01-product.md @@ -16,24 +16,24 @@ catalogue, and the owner connects a store afterwards. ## 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-r2`, `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 `/` (or finds it) | | `link` | the repository becomes the workspace's; `orun cloud check` is the gate | -| `secret-workers-deploy` | `orun.integrations/reconcile@v1` — `CLOUDFLARE_API_TOKEN` from the `workers-deploy` template: Workers Scripts and KV write, for the storefront's deploy. It carries no R2 | -| `secret-r2-data` | `CLOUDFLARE_R2_TOKEN` from the `r2-data` template: R2 Storage write, which the R2 root's Terraform binds as its provider token | -| `secret-account-id` | `CLOUDFLARE_ACCOUNT_ID`, the connection fact both bind | -| `land` | one PR bound to the task, merged once its checks (Checks, and `plan`) are 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_R2` exists on stage and prod | +| `secrets` | `orun.integrations/reconcile@v1`, the three keys in one hook, created side by side, each under its own template: `CLOUDFLARE_API_TOKEN` from `workers-deploy` (Workers Scripts and KV write, for the storefront's deploy — it carries no R2); `CLOUDFLARE_R2_TOKEN` from `r2-data` (R2 Storage write, which the R2 root's Terraform binds as its provider token); `CLOUDFLARE_ACCOUNT_ID`, the connection fact both bind | +| `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 @@ -46,15 +46,20 @@ promotion gate deferred: | `cloudflare-r2 · stage` / `· prod` | nothing | `terraform apply` of `stg--stage` / `prod--prod` with the `r2-data` token, adopting a bucket of that name if one exists (`adopt.tf`), then lease-publishes `WIRING_CLOUDFLARE_R2` = `{r2_bucket_name}` on that environment | | `stage · web` / `prod · web` | that environment's R2 apply (`dependsOn: cloudflare-r2`, `mode: enforced` on main) | resolves `WIRING_CLOUDFLARE_R2_` as it starts, renders `wrangler.jsonc` with the real bucket name, builds with OpenNext, deploys `-web-` (the Durable Objects' migration runs on this first deploy), and smoke-tests it: `/` must answer and `/robots.txt` must name the origin it was asked on, which only the Worker renders | -Stage and prod run side by side. `web-tests` verifies on dev only, so on the -merge its gate is the pull request's Checks run, which the landing waited -for. +Stage and prod run side by side. `web-tests` verifies on dev only, on a pull +request. The 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 +installed, type-checked, linted, tested and built this exact tree before the +tag was cut. A later pull request's `web-tests` lane installs and checks the +package; it does not run the suite, so the product's developers run +`pnpm test` and `pnpm lint` before they push. ## Verified -The convergence run for the merge commit is green; `WIRING_CLOUDFLARE_R2` -exists on stage and prod; `https://-web-{stage,prod}..workers.dev` -answer — with the demo catalogue, until the owner connects Shopify. +The convergence run for the merge commit is green — the storefront resolved +`WIRING_CLOUDFLARE_R2` from stage and prod, where every later deploy reads +it; `https://-web-{stage,prod}..workers.dev` answer — +with the demo catalogue, until the owner connects Shopify. ## Troubleshooting @@ -62,7 +67,8 @@ answer — with the demo catalogue, until the owner connects Shopify. |---|---| | 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 | -| `secret-r2-data` fails `parent_grant_insufficient` | the connection's Account API token lacks Workers R2 Storage Write; add it (the console's Connect recipe lists it under "R2 data access"), re-connect, 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 | +| `secrets` fails `parent_grant_insufficient` on `CLOUDFLARE_R2_TOKEN` | the connection's Account API token lacks Workers R2 Storage Write; add it (the console's Connect recipe lists it under "R2 data access"), re-connect, re-run the phase | | R2 lane: Authentication error (10000) on the bucket list or create | the R2 root is not using the `r2-data` token — `infra/terraform/cloudflare-r2/component.yaml` must bind `CLOUDFLARE_API_TOKEN` to `CLOUDFLARE_R2_TOKEN`; the deploy token carries no R2 | | R2 lane: `The bucket you tried to create already exists` (10004) | `adopt.tf` imports a bucket of the same name; if it was removed, restore it. Two products with the same `reponame` in one account share bucket names — use a distinct `reponame` | | 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, re-connect, re-run the phase | diff --git a/docs/phases/02-docs.md b/docs/phases/02-docs.md index a13b788..23e937e 100644 --- a/docs/phases/02-docs.md +++ b/docs/phases/02-docs.md @@ -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 `/` and `/robots.txt` on both environments (whether the Worker rendered the request's origin, and whether the demo catalogue or a connected store answered), 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 `/` and `/robots.txt` on both environments (whether the Worker rendered the request's origin, and whether the demo catalogue or a connected store answered) 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 diff --git a/docs/phases/README.md b/docs/phases/README.md index 2e5dba0..6981e99 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -9,9 +9,13 @@ container the same operation as running them all. The product phase follows the contract every deploying phase does: -> **place its modules → brand them → land them as one pull request → watch -> the convergence that merge triggers (auto-resumed) → check what the -> convergence published → verify the outcome over HTTP.** +> **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. @@ -20,7 +24,7 @@ site's repository is wherever `--out` points. | phase | lands | verified by | |---|---|---| -| [`01-product`](01-product.md) | **the GitHub repo created** and the whole product in ONE pull request: intent, CI, tooling, identity, the R2 root, the storefront and its tests | the convergence green (R2 applied, then the storefront built, deployed and smoke-tested), `WIRING_CLOUDFLARE_R2` on stage and prod, both URLs answering | +| [`01-product`](01-product.md) | **the GitHub repo created** and the whole product in ONE pull request: intent, CI, tooling, identity, the R2 root, the storefront and its tests | the convergence green (R2 applied, then the storefront built, deployed and smoke-tested), both URLs answering | | [`02-docs`](02-docs.md) | the live-deployment record; the promotion gate and dev's lanes put back | committed manifest matches probed reality | **One landing, not three.** Before the one-landing shape a site like this @@ -35,12 +39,16 @@ published is there. On a pull request the edge is advisory: nothing deploys. the product's own plan honours it. Every landing is a pull request on a branch named for its task -(`orun/BASE--`). On those branches `ci.yml` runs `plan` only — the -intent, every component and every composition resolve — and skips the lanes, +(`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. `checks.yml` (install, the fixture -render, typecheck, lint, test, build) runs on every pull request regardless, -and the product's landing waits for it. +convergence is what the phase watches. The product carries no other +workflow: the baseline's own CI (Tier 2) installs, renders the fixture, +type-checks, lints, tests and builds this landing before a tag is cut, and +every later pull request in the product runs `ci.yml`'s verify lanes (which +build and dry-deploy, but neither lint nor run the tests). 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 @@ -100,9 +108,10 @@ lands, its `post` hooks make them the site's: the two bootstrap deferrals (prod's promotion gate, dev's push lanes), restage, `rebrand --verify` — the identity rename over the whole tree, then a sweep that fails on any of this baseline's identity left behind. -3. `pnpm install --lockfile-only` — confirms the baseline's complete - lockfile against the placed tree, so `--frozen-lockfile` installs pass. -4. `repo`, `link`, the brokered Cloudflare credentials, `land`. +3. `repo`, `link`, the brokered Cloudflare credentials (the deploy token, + the R2 token and the account id, one `secrets` hook), `task`, `land`. The + baseline's lockfile is placed as it is and installed `--frozen-lockfile` + by the lanes; nothing re-resolves it. ## When a phase fails diff --git a/hooks/render-deployment-docs.sh b/hooks/render-deployment-docs.sh index b417448..a8735e8 100755 --- a/hooks/render-deployment-docs.sh +++ b/hooks/render-deployment-docs.sh @@ -11,15 +11,22 @@ # ai/context/deployment.md — REGENERATED: URLs with live probe results (and # whether the Worker rendered the request's # origin, and which store backend answered), -# identity, the R2 wiring, secrets inventory BY -# NAME, integrations +# identity, the R2 wiring, 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 — inventories are names only. +# 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 }" @@ -37,10 +44,6 @@ 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="?" -# Workspace slug via the direct backend read; tolerate failure. -slug="$( { orun workspace "$ws" 2>/dev/null || true; } | sed -n 's/^ *slug: *//p' | head -1)" -[ -n "$slug" ] || slug="?" - # 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="?" @@ -83,17 +86,6 @@ for pair in "stage|$stage_url" "prod|$prod_url"; do rows+="| storefront (${env}) | ${url} | $(badge "$(probe "$url")") |"$'\n' done -secrets_list() { { orun secrets list --org "$ws" "$@" 2>/dev/null || true; } | awk 'NR>1 && NF {print " - "$1}'; } -secrets_proj="$(secrets_list --project)"; [ -n "$secrets_proj" ] || secrets_proj=" - (listing unavailable to this credential)" -secrets_stage="$(secrets_list --env stage)"; [ -n "$secrets_stage" ] || secrets_stage=" - (listing unavailable to this credential)" -secrets_prod="$(secrets_list --env prod)"; [ -n "$secrets_prod" ] || secrets_prod=" - (listing unavailable to this credential)" -integrations="$( { orun integrations list --org "$ws" --json 2>/dev/null || true; } | python3 -c " -import json,sys -try: rows=json.load(sys.stdin) -except Exception: rows=[] -out=[f\" - {r.get('provider','?')}: {r.get('status','?')}\" for r in rows] -print('\n'.join(out) if out else ' - (listing unavailable to this credential)')" )" - now="$(date -u +%Y-%m-%dT%H:%M:%SZ)" # Heal the static operating contract when the site predates it. @@ -110,15 +102,14 @@ cat > ai/context/deployment.md < GENERATED by the \`02-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 — inventories are names -> only. +> overwritten. No secret values appear in this file — secrets are named only. ## Identity | | | |---|---| | repository / project slug | \`${repo}\` | -| Orun workspace | \`${ws}\` (slug \`${slug}\`) | +| Orun workspace | \`${ws}\` | | declared in | \`intent.yaml\` → \`execution.state.workspace\` | | Workers | \`${brand}-web-stage\`, \`${brand}-web-prod\` on \`${sub}.workers.dev\` | | R2 buckets (the Next.js data cache) | \`stg-${repo}-stage\`, \`prod-${repo}-prod\` (\`infra/terraform/cloudflare-r2\`); their names reach the Workers as \`WIRING_CLOUDFLARE_R2\` on each environment | @@ -134,26 +125,20 @@ bucket. Until a Shopify store is connected (the README's "Connecting Shopify"), each storefront serves its bundled demo catalogue and \`/checkout\` asks for a payment provider. -## Secrets inventory (names only) - -Project rung: -${secrets_proj} +## Secrets (names only) -Environment \`stage\`: -${secrets_stage} - -Environment \`prod\`: -${secrets_prod} - -Provider secrets are BROKERED (minted per run from the workspace's Cloudflare -connection; no long-lived values at rest). \`WIRING_CLOUDFLARE_R2\` is written -by the R2 root's apply and holds the bucket name, not a credential. Shopify's -facts, once connected, are Worker secrets on the Workers above, not Orun -secrets, and are not listed here. - -## Workspace integrations +| 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_R2_TOKEN\` | the workspace | BROKERED (\`r2-data\`): applies the R2 bucket — the deploy token carries no R2 | +| \`CLOUDFLARE_ACCOUNT_ID\` | the workspace | the connection's account id — a fact, not a credential | +| \`WIRING_CLOUDFLARE_R2\` | \`${repo}\` on stage and on prod | written by the R2 root's apply: the bucket's name, not a credential | -${integrations} +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}\`. Shopify's facts, once connected, are Worker secrets on the +Workers above, not Orun secrets, and are not listed here. ## How this deployment changes @@ -168,7 +153,7 @@ python3 - <<'PY' import re begin, end = "", "" body = f"""{begin} -This store is **live**. Verified URLs, identity and the secrets inventory are +This store 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 `02-docs` phase); how it deploys and how to operate it: [ai/context/operations.md](ai/context/operations.md). diff --git a/infra/terraform/cloudflare-r2/component.yaml b/infra/terraform/cloudflare-r2/component.yaml index c37dc17..3582471 100644 --- a/infra/terraform/cloudflare-r2/component.yaml +++ b/infra/terraform/cloudflare-r2/component.yaml @@ -12,6 +12,14 @@ spec: type: terraform lifecycle: production owner: platform + # Its pages, attached to it in the workspace's catalog: what the Docs + # library shows for it, and what the catalog's docs and runbook checks read. + # Generated from what this manifest and its sources declare. + docs: + overview: docs/overview.md + pages: + - { path: docs/architecture.md, role: architecture, title: Architecture } + - { path: docs/runbook.md, role: runbook, title: Runbook } domain: infra parameters: diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index 89f6666..10063d5 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -184,8 +184,10 @@ modules: source: baseline from: pnpm-workspace.yaml to: pnpm-workspace.yaml - # The baseline's complete lockfile: the whole tree lands at once, so the - # `pnpm-lockfile` hook only confirms it. + # 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 @@ -305,16 +307,25 @@ modules: # new milestone after the last, and a task naming a milestone the epic does # not have yet would create it out of order. # -# Each phase's own `pre` hook runs `orun.task/ensure@v1` on its task again. -# Same identity, so it finds rather than creates, and it is how the phase gets -# the task's KEY for its landing. 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. +# 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 }}" @@ -329,6 +340,7 @@ hooks: owner: me - id: m01 uses: orun.task/ensure@v1 + background: true with: kind: milestone epic: "{{ .inputs.epicSlug }}" @@ -339,6 +351,7 @@ hooks: - the storefront built, deployed and answering on stage and prod - id: m02 uses: orun.task/ensure@v1 + background: true with: kind: milestone epic: "{{ .inputs.epicSlug }}" @@ -348,6 +361,7 @@ hooks: - prod waits on stage again - id: t01 uses: orun.task/ensure@v1 + background: true with: kind: task epic: "{{ .inputs.epicSlug }}" @@ -363,6 +377,7 @@ hooks: contract: .baseline/tasks/01-product.TaskContract.yaml - id: t02 uses: orun.task/ensure@v1 + background: true with: kind: task epic: "{{ .inputs.epicSlug }}" @@ -397,11 +412,14 @@ phases: - name: 01-product title: The product, built in one landing description: The whole tree — manifests, CI, tooling, the R2 root, the storefront and its tests — branded, landed as one pull request, and deployed by one convergence. - # An estimate until a bootstrap measures it: the pull request's Checks (a - # full Next.js build of a larger app than a starter's), the merge, the R2 - # apply, then the storefront's build, deploy and smoke on stage and prod - # side by side. - expectedMinutes: 14 + # An estimate, not a measurement — no bootstrap of this baseline has been + # timed on this shape: the landing checked here (no runner's Checks or + # `plan` waited for) and merged, then the merge's convergence — the R2 + # apply, then the storefront's build (a larger Next.js app than a + # starter's), deploy and smoke, stage and prod side by side. A minute + # under the last estimate, for the task set-up in the background, the + # landing checked in the box and the watch reading every 5 s. + expectedMinutes: 13 narrate: start: "Creating the repository and landing the whole product in one pull request — intent, CI, tooling, the R2 cache bucket and the storefront with its tests. Then one convergence applies the bucket and deploys the storefront on stage and prod. Usually about {{ .meta.expectedMinutes }} minutes." await: "One convergence is deploying the product: the R2 bucket first, then the storefront built with its name, on stage and prod side by side. The Next.js build is the long pole; nothing is stuck." @@ -426,19 +444,6 @@ phases: waitSeconds: 600 pollSeconds: 20 hooks: - pre: - # The epic, the milestones and the tasks already exist (the run-level - # list above). This finds the task and yields its key, which the - # landing binds the pull request to. - - id: task - uses: orun.task/ensure@v1 - with: - kind: task - epic: "{{ .inputs.epicSlug }}" - milestone: "{{ .phase.name }}" - name: "Build the product in one landing" - prefix: BASE - contract: .baseline/tasks/01-product.TaskContract.yaml # The whole tree is placed when these run. rebrand.mjs enumerates it # 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 @@ -511,11 +516,6 @@ phases: run: ["git", "add", "-A"] - id: rebrand-verify run: ["node", "{{ .baseline.dir }}/tooling/rebrand/rebrand.mjs", "--verify", "--values", ".rebrand/values.json"] - # root-pnpm-lock places the baseline's complete lockfile and the whole - # tree is here, so this only confirms it; the lanes and Checks install - # with --frozen-lockfile. The lockfile carries no identity. - - id: pnpm-lockfile - run: ["pnpm", "install", "--lockfile-only"] # The repo has to exist before there is anywhere to land. - id: repo uses: orun.repo/ensure@v1 @@ -544,42 +544,50 @@ phases: - link - "{{ .inputs.orunWorkspace }}" - "{{ .inputs.githuborg }}/{{ .inputs.reponame }}" - # The deploy credentials, brokered, one hook per template: - # `integrations/reconcile` mints from ONE connection with ONE scope - # template, and this product needs two scopes on purpose. - # `workers-deploy` (Workers Scripts and KV write) deploys the - # storefront's Worker; it carries NO R2, so the R2 root cannot create - # or list a bucket with it. `r2-data` (Workers R2 Storage Write) is the - # R2 root's own token, CLOUDFLARE_R2_TOKEN, which its component binds as - # the provider's CLOUDFLARE_API_TOKEN — the way a D1 root binds a - # d1-edit token. Collapsing the two hooks would be collapsing the - # scopes. The account id is a connection fact both bind. Keys that - # already exist are kept. After the link, before the landing whose - # convergence uses them. - - id: secret-workers-deploy - uses: orun.integrations/reconcile@v1 - with: - provider: cloudflare - keys: [CLOUDFLARE_API_TOKEN] - template: workers-deploy - - id: secret-r2-data + # 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. + # This product needs two scopes on purpose, and still gets them: each + # key keeps its own template. `workers-deploy` (Workers Scripts and KV + # write) deploys the storefront's Worker; it carries NO R2, so the R2 + # root cannot create or list a bucket with it. `r2-data` (Workers R2 + # Storage Write) is the R2 root's own token, CLOUDFLARE_R2_TOKEN, which + # its component binds as the provider's CLOUDFLARE_API_TOKEN — the way + # a D1 root binds a d1-edit token. The account id is a connection fact + # both bind. 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 - keys: [CLOUDFLARE_R2_TOKEN] - template: r2-data - - id: secret-account-id - uses: orun.integrations/reconcile@v1 + secrets: + - { key: CLOUDFLARE_API_TOKEN, template: workers-deploy } + - { key: CLOUDFLARE_R2_TOKEN, template: r2-data } + - { 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: - provider: cloudflare - keys: [CLOUDFLARE_ACCOUNT_ID] - template: account-id - # THE PRODUCT IS A PULL REQUEST THAT IS CHECKED, THEN MERGED. This - # landing waits for its PR's whole CI run (orun >= v2.58.6): Checks - # (install, the fixture render, typecheck, lint, test, build) and - # `plan` — on a bootstrap branch (`orun/BASE-…`) the lanes are skipped - # (ci.yml), because the merge runs every one of them on main a minute - # later, for real, and that convergence is what `await` watches. + kind: task + epic: "{{ .inputs.epicSlug }}" + milestone: "{{ .phase.name }}" + name: "Build the product in one landing" + prefix: BASE + contract: .baseline/tasks/01-product.TaskContract.yaml + # THE PRODUCT 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. 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 every lane on main a minute later, for + # real, and that convergence is what `await` watches. - id: land uses: orun.pr/land@v1 narrate: "The product is merged into main." @@ -588,6 +596,7 @@ phases: epic: "{{ .inputs.epicSlug }}" branchSlug: "{{ .phase.name }}" title: "feat: {{ .inputs.productname }}, the whole product from the commerce baseline" + checks: local await: - id: converge uses: orun.run/watch@v1 @@ -600,18 +609,18 @@ phases: repo: "{{ .inputs.githuborg }}/{{ .inputs.reponame }}" resumeBudget: 3 waitSeconds: 1800 - # The R2 root's apply lease-publishes its wiring document to the - # project's ENVIRONMENT rungs (stage and prod), not to the workspace; - # every later deploy of the storefront reads it back. Asked of the platform - # directly, because a green convergence says the lanes passed, not - # that the document a FUTURE deploy needs is where it will look. - - id: wiring - uses: orun.secrets/exists@v1 - narrate: "The R2 wiring the storefront's deploys read is published on stage and prod." - with: - keys: [WIRING_CLOUDFLARE_R2] - project: "{{ .inputs.reponame }}" - environments: [stage, prod] + # 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 + # NO SEPARATE WIRING CHECK. The R2 root's apply lease-publishes its + # wiring document to the project's stage and prod rungs, and its one + # reader resolves it in this convergence from the place every later + # run looks: the storefront's deploy job, on stage and on prod, + # resolves WIRING_CLOUDFLARE_R2_STAGE and _PROD (apps/web/component.yaml's + # secretEnv, waiting on the apply — enforced on main) before its first + # step, fail-closed. A missing document fails that lane, so a green run + # already says it is there. WIRING_CLOUDFLARE_R2 was the await's only + # key, so the await goes with it. - id: verify uses: orun.http/probe@v1 narrate: "The storefront answered on stage and prod." @@ -621,31 +630,23 @@ phases: - "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 and why - # its verify is the probe 01-product ends on. + # 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: 02-docs title: The deployment, recorded description: The live-deployment manifest, rendered from probed reality, and the promotion gate and dev's lanes put back. - expectedMinutes: 2 + # An estimate, not a measurement: the render's two probes, the task, and + # one landing checked here and merged, with nothing after it to wait for. + expectedMinutes: 1 narrate: start: "Now recording what was actually built — probing every URL and writing the deployment manifest into the repository." - await: "Probing the live endpoints one last time." 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: - pre: - - 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/02-docs.TaskContract.yaml post: # THE SITE GOES LIVE WITH ITS PROMOTION GATE. 01-product deferred # `prod.promotion.dependsOn: [stage]`; this, the last landing, puts it @@ -660,6 +661,17 @@ phases: 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/02-docs.TaskContract.yaml + # Checked here and merged, as 01-product's landing is + # (`checks: local`). - id: land uses: orun.pr/land@v1 narrate: "The deployment record is merged into main." @@ -668,11 +680,4 @@ phases: epic: "{{ .inputs.epicSlug }}" branchSlug: "{{ .phase.name }}" title: "docs(deployment): record the live deployment state" - await: - - id: verify - uses: orun.http/probe@v1 - narrate: "Every live URL answered on the final probe." - with: - urls: - - "https://{{ .inputs.reponame }}-web-stage.{{ .inputs.subdomain }}.workers.dev" - - "https://{{ .inputs.reponame }}-web-prod.{{ .inputs.subdomain }}.workers.dev" + checks: local diff --git a/testing/coverage.test.sh b/testing/coverage.test.sh index 1ee1577..67027c5 100755 --- a/testing/coverage.test.sh +++ b/testing/coverage.test.sh @@ -95,6 +95,46 @@ 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 product's Docs library showed nothing for any +# component and the catalog failed every one of them on docs and on runbook. +# A component also needs a description: it is the catalog's one-line answer to +# "what is this", and the test suite had none. +# +# And a domain may not share a component's name. The catalog keys entities by +# name, so the `web` domain (`spec.domain: web`) took the `web` component's +# place, and the product's one deployable was missing from its own catalog. +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 + for domain in (spec.get("domain"), (meta.get("labels") or {}).get("domain")): + if domain: + domains.setdefault(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: @@ -136,9 +176,9 @@ for wf in workflows: # 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. +# second one on push (the Checks workflow this baseline once shipped 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: diff --git a/testing/e2e.test.sh b/testing/e2e.test.sh index 284dac7..f40d281 100755 --- a/testing/e2e.test.sh +++ b/testing/e2e.test.sh @@ -5,11 +5,11 @@ # This proves it WORKS, by doing to it what its own pipelines will: # # 1. at the 01-product landing (the commit its one pull request merges), -# run what `checks.yml` runs on that PR — install with the lockfile the -# phase confirmed, render the wrangler fixture and check the committed -# config IS that render, typecheck, lint, test, build. The landing WAITS -# on those checks, so a product they refuse is a bootstrap that never -# merges; +# install with the lockfile the product ships, render the wrangler +# fixture and check the committed config IS that render, typecheck, +# lint, test, build. The landing's own PR runs `plan` alone (an +# `orun/BASE-*` branch), so THIS is where a product 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 product for # a pull request (the verify profile: the deploy profile has no dry run) # — `verify-app-structure` (which checks the wrangler config exists @@ -72,24 +72,29 @@ 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 NEXT_TELEMETRY_DISABLED=1 TURBO_TELEMETRY_DISABLED=1 -# What checks.yml runs, step for step, read out of the workflow the product -# carries so the two cannot drift: every `run:` of its one job, in order. +# The landing's own checks, step for step — the ones the product's retired +# Checks workflow ran, run here at once on the whole tree. A product's pull +# requests verify through ci.yml's lanes (the storefront built — Next's build +# type-checks it — and dry-deployed per environment, the R2 root planned), +# which neither lint nor run the tests, so before a tag THIS is where those +# are held. +LANDING_CHECKS=( + "pnpm install --frozen-lockfile" + "pnpm run wire:fixture" + "git diff --exit-code" + "pnpm typecheck" + "pnpm lint" + "pnpm test" + "pnpm build" +) checks() { # DIR LOG local dir="$1" log="$2" cmd - while IFS= read -r cmd; do + 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 < <(python3 - "$dir/.github/workflows/checks.yml" <<'PY' -import sys, yaml -wf = yaml.safe_load(open(sys.argv[1])) -for job in wf["jobs"].values(): - for step in job["steps"]: - if "run" in step: - print(step["run"].strip()) -PY -) + done } echo "── the offline bootstrap (testing/lib/bootstrap.sh)" @@ -100,10 +105,10 @@ echo " 2 phases placed and landed" s01="$(git -C "$tree" rev-parse HEAD~1)" # ── 1. the product's one pull request ────────────────────────────────────── -echo "── 01-product's landing, under the checks its PR waits on" +echo "── 01-product's landing: install, the fixture render, typecheck, lint, test, build" git -C "$tree" worktree add -q "$scratch/at-01" "$s01" checks "$scratch/at-01" "$scratch/checks-01.log" -# The first Checks build is done; its tree is not needed again, and the disk is shared. +# The landing's build is done; its tree is not needed again, and the disk is shared. git -C "$tree" worktree remove --force "$scratch/at-01" # ── 2. the stage lane's steps, in the job's own tree ────────────────────── diff --git a/testing/leak.test.sh b/testing/leak.test.sh index 3516e82..79c4698 100755 --- a/testing/leak.test.sh +++ b/testing/leak.test.sh @@ -88,7 +88,7 @@ for p in placed: # ── the site's README, not this repository's ────────────────────────────── if "README.md" not in placed: bad("README.md would not ship") -for must in (".github/workflows/ci.yml", ".github/workflows/checks.yml", +for must in (".github/workflows/ci.yml", "apps/web/component.yaml", "apps/web/app/site.ts", "tests/web/component.yaml", ".rebrand/values.json", "apps/web/.env.example", "packages/.gitkeep", # the wiring path: the template, its fixture, the committed render diff --git a/testing/lib/bootstrap.sh b/testing/lib/bootstrap.sh index 43bfd4e..44466cb 100644 --- a/testing/lib/bootstrap.sh +++ b/testing/lib/bootstrap.sh @@ -14,8 +14,8 @@ # workspace; # - `{{ .inputs.* }}` render from the fixture. # Everything else — the rebrand, the re-tenant, the work-tree strip, the -# deferrals and their restore, the retouch marker, the lockfile seed and -# prune, the deployment-docs render — runs exactly as declared. +# deferrals and their restore, the retouch marker, the deployment-docs +# render — runs exactly as declared. # # Needs: orun, node, pnpm, python3 (+PyYAML), git. diff --git a/testing/manifest.test.sh b/testing/manifest.test.sh index 5374cb5..64f04c8 100755 --- a/testing/manifest.test.sh +++ b/testing/manifest.test.sh @@ -83,13 +83,16 @@ def uses(phase, action): yield hook # THE SECRETS THE BOOTSTRAP MINTS. `orun.integrations/reconcile@v1` is what -# `create-secrets.sh` was written out longhand as: one connection, one scope -# template, the keys it ensures. Read per key so a hook minting two keys under -# one template is three facts rather than one. +# `create-secrets.sh` was written out longhand as: one connection, and per key +# the scope template it is minted under — `secrets: [{key, template}]`, or +# `keys` sharing one `template`. Read per key so a hook minting three keys is +# three facts rather than one. blueprint_secrets = {} for phase in bp_phases: for hook in uses(phase, "orun.integrations/reconcile@v1"): w = hook.get("with") or {} + for item in (w.get("secrets") or []): + blueprint_secrets[item.get("key")] = (w.get("provider"), item.get("template")) for key in (w.get("keys") or []): blueprint_secrets[key] = (w.get("provider"), w.get("template")) diff --git a/testing/phases.test.sh b/testing/phases.test.sh index 0f86720..5779e6e 100755 --- a/testing/phases.test.sh +++ b/testing/phases.test.sh @@ -10,9 +10,16 @@ # before the Worker that binds it — is carried by the plan instead, and this # file checks the edges that carry it: every component that reads a wiring # document waits, on a merge to main, for the infra component that publishes -# it, and the landing's await checks that document exists afterwards. A -# module that drifts into another phase, or an edge that goes missing, fails -# at landing time, live, with nothing in this repository having looked wrong. +# it. Each reader resolves its document in the convergence from the place +# every later run looks, so a green convergence says the document is there — +# no separate check. A module that drifts into another phase, or an edge that +# goes missing, fails at landing time, live, with nothing in this repository +# having looked wrong. +# +# And the shape that keeps a bootstrap fast (orun >= v2.88.0): the run-level +# task set-up runs in the background, each phase finds its task just before +# its landing, each landing checks its commit here (`checks: local`), and the +# convergence watch reads every few seconds. # # Adapted from sourceplane/cirrus-baseline's testing/phases.test.sh: the # narration rules and the hook-only rule are Cirrus's, unchanged. @@ -51,16 +58,19 @@ PARTITION = { HOOK_ONLY = {"02-docs"} # The phases that DEPLOY, and so must give a re-run something to land. DEPLOYS = {"01-product"} -# Each phase's post and await hooks, in order — the one-landing recipe. The -# `secret-*` reconciles are matched as a group (one per brokered key) and the -# `wiring` await only when infra publishes wiring; both are checked below. +# Each phase's pre, post and await hooks, in order — the one-landing recipe. +# The brokered keys are one `secrets` reconcile. No phase has a `pre` hook: +# the task is found in `post`, just before the landing, so that everything +# before it runs beside the background task set-up. No phase awaits the +# wiring: the storefront's deploy resolves it in the convergence (checked below). +PRE = {"01-product": [], "02-docs": []} POST = { "01-product": ["retouch", "git-init", "stage", "rebrand", "orun-workspace", "work-tree", - "promotion", "dev-lanes", "restage", "rebrand-verify", "pnpm-lockfile", - "repo", "link", "secret-*", "land"], - "02-docs": ["promotion", "dev-lanes", "render", "land"], + "promotion", "dev-lanes", "restage", "rebrand-verify", + "repo", "link", "secrets", "task", "land"], + "02-docs": ["promotion", "dev-lanes", "render", "task", "land"], } -AWAIT = {"01-product": ["converge", "wiring", "verify"], "02-docs": ["verify"]} +AWAIT = {"01-product": ["converge", "verify"], "02-docs": []} by_name = {p["name"]: p for p in phases} names = [p["name"] for p in phases] @@ -140,15 +150,13 @@ for p in phases: f"commit it merged (orun.run/watch@v1 with sha: mergeSha)") # ── the hooks run in the one-landing order ──────────────────────────────── -def collapse(ids): - out = [] - for i in ids: - i = "secret-*" if i.startswith("secret-") else i - if not out or out[-1] != i or i != "secret-*": - out.append(i) - return out +for name, want in PRE.items(): + got = [h.get("id") for h in ((by_name.get(name, {}).get("hooks") or {}).get("pre") or [])] + if got != want: + bad(f"phase {name}'s pre hooks are {got}; want {want} — a task found in `pre` waits " + f"for the background task set-up before the phase has done anything") for name, want in POST.items(): - got = collapse([h.get("id") for h in ((by_name.get(name, {}).get("hooks") or {}).get("post") or [])]) + got = [h.get("id") for h in ((by_name.get(name, {}).get("hooks") or {}).get("post") or [])] if got != want: bad(f"phase {name}'s post hooks are {got}; the one-landing order is {want}") for name, want in AWAIT.items(): @@ -206,18 +214,63 @@ for name, (rel, spec) in comps.items(): if (m.get("from") or "").rstrip("/") == comps[pub][0].rsplit("/", 1)[0]), None) if mod and pub_mod and pub_mod not in (mod.get("dependsOn") or []): bad(f"module {mod['name']} reads {key} and is not placed after {pub_mod} (module dependsOn)") -# …and the landing's await asks the platform that every one of them exists. +# …and every document published is one a component in the convergence +# resolves, on stage AND prod, from the place every later run looks (its +# secretEnv: `secret://///WIRING_X`). That read is what +# replaced the `wiring` await: a job resolves its secrets when it starts, +# fail-closed, so a green convergence says every one of them is there. A +# document nothing reads in the convergence would need the await back. +read_from = {} +for name, (rel, spec) in comps.items(): + for env_key, ref in (spec.get("secretEnv") or {}).items(): + m = re.match(r"^secret://[^/]+/[^/]+/(stage|prod)/(WIRING_[A-Z0-9_]+)$", str(ref)) + if m: + read_from.setdefault(m.group(2), set()).add(m.group(1)) +for key in sorted(publishes): + if read_from.get(key, set()) != {"stage", "prod"}: + bad(f"{key} is published and no component resolves it on both stage and prod " + f"(it is read on {sorted(read_from.get(key, set())) or 'none'}) — nothing in the " + f"convergence proves it is there; read it, or await it with orun.secrets/exists@v1") for p in phases: - if p["name"] not in DEPLOYS: - continue - exists = [h for h in ((p.get("hooks") or {}).get("await") or []) - if (h.get("uses") or "").startswith("orun.secrets/exists@")] - keys = {k for h in exists for k in ((h.get("with") or {}).get("keys") or [])} - envs = {e for h in exists for e in ((h.get("with") or {}).get("environments") or [])} - if set(publishes) - keys: - bad(f"phase {p['name']} does not await the wiring {sorted(set(publishes) - keys)} with orun.secrets/exists@v1") - if publishes and envs != {"stage", "prod"}: - bad(f"phase {p['name']} awaits the wiring on {sorted(envs)}, not stage and prod") + for h in hooks_of(p): + if (h.get("uses") or "").startswith("orun.secrets/exists@"): + keys = set((h.get("with") or {}).get("keys") or []) + proven = {k for k in keys if read_from.get(k, set()) >= {"stage", "prod"}} + if proven: + bad(f"phase {p['name']} awaits {sorted(proven)} with orun.secrets/exists@v1, which " + f"the convergence's own lanes already resolve on stage and prod — a second check") + +# ── THE FAST SHAPE (orun >= v2.88.0) ────────────────────────────────────── +# The run-level list is the task set-up, all of it in the background: the +# first phase's provider check, placement, rebrand, repository and secrets +# run while it opens the epic, the milestones and the tasks. +for h in run_hooks: + if not h.get("background"): + bad(f"hooks.preInstantiate {h.get('id')} is not `background: true` — the first phase " + f"waits for it before doing anything, though nothing before its landing reads it") +# No phase keeps a `pre` hook on the task plane: one there waits for the +# whole background list before the phase has done anything. +PLANE = ("orun.task/", "orun.pr/land@") +for p in phases: + for h in ((p.get("hooks") or {}).get("pre") or []): + if (h.get("uses") or "").startswith(PLANE): + bad(f"phase {p['name']} pre hook {h.get('id')} uses the task plane ({h['uses']}) — " + f"move it to `post`, just before the landing") +# Every landing checks its commit here and merges, instead of waiting for a +# runner to plan the tree this box just wrote. +for p in phases: + for h in hooks_of(p): + if (h.get("uses") or "").startswith("orun.pr/land@") and (h.get("with") or {}).get("checks") != "local": + bad(f"phase {p['name']} lands with checks {(h.get('with') or {}).get('checks', 'ci')!r}, " + f"not 'local' — it waits for a runner to plan a tree that is here") +# The convergence watch reads every few seconds, not the action's default 40. +for p in phases: + for h in ((p.get("hooks") or {}).get("await") or []): + if (h.get("uses") or "").startswith("orun.run/watch@"): + every = (h.get("with") or {}).get("pollSeconds") + if not isinstance(every, int) or every > 10: + bad(f"phase {p['name']} watches its convergence every {every or 40} s; at most 10 — " + f"the build goes on that much after the run is green") # ── every phase's task is one the run-level list opens, in the same order ─ def task_names(hooks): @@ -312,8 +365,15 @@ def check_line(where, line, slot, hook_ids): for p in phases: n = p.get("narrate") or {} ids = {h.get("id") for h in hooks_of(p)} + awaits = bool((p.get("hooks") or {}).get("await")) for slot in ("start", "await", "done", "failed"): line = n.get(slot) + if slot == "await" and not awaits: + # A phase that waits on nothing never says its await line. + if line: + bad(f"phase {p['name']} declares narrate.await and has no await hooks — " + f"nobody would ever read it") + continue if not line: bad(f"phase {p['name']} declares no narrate.{slot}") continue diff --git a/testing/placement.test.sh b/testing/placement.test.sh index ced293d..e0d5e39 100755 --- a/testing/placement.test.sh +++ b/testing/placement.test.sh @@ -12,7 +12,7 @@ # 2. THE OFFLINE BOOTSTRAP (testing/lib/bootstrap.sh) — both phases placed in # order onto what the previous one landed, finished by the blueprint's OWN # `run:` hooks (retouch, rebrand, re-tenant, work-tree strip, the -# deferrals and their restore, the lockfile, the deployment record), each +# deferrals and their restore, the deployment record), each # landing a commit; # 3. the product it ends with: branded with no residue — the store's name # and source link, the Worker and its self-reference binding, the R2 @@ -33,9 +33,8 @@ # testing/e2e.test.sh goes on from here: it installs, builds and serves the # product and runs its smoke against it. # -# Needs: orun, node, pnpm, python3 (+PyYAML), git. No credential. The pnpm -# lockfile check and the deployment-record probes reach the network if they -# can, and pass without it. +# Needs: orun, node, pnpm, python3 (+PyYAML), git. No credential. The +# deployment-record probes reach the network if they can, and pass without it. set -euo pipefail here="$(cd "$(dirname "$0")" && pwd)" root="$(cd "$here/.." && pwd)" @@ -46,9 +45,10 @@ for bin in orun node pnpm python3 git; do command -v "$bin" >/dev/null || { echo "placement.test.sh needs $bin on PATH" >&2; exit 1; } done # Step 4 is the PRODUCT's own plan, so it must be planned by the orun the -# product's CI runs (ci.yml's pin) or newer: v2.58.11, the bootstrap floor, -# does not apply a dependsOn edge's `modeRules`, and would plan a pull request -# with the storefront waiting on the R2 plan. +# product's CI runs (ci.yml's pin) or newer: an older orun (v2.58.11, the +# bootstrap's floor before v2.88.0) does not apply a dependsOn edge's +# `modeRules`, and would plan a pull request with the storefront waiting on +# the R2 plan. pin="$(sed -n 's/^ *version: *v\([0-9.]*\) *$/\1/p' "$root/.github/workflows/ci.yml" | head -1)" have="$(orun --version | sed -n 's/.*version \([0-9.]*\).*/\1/p')" python3 -c "import sys; v=lambda s: tuple(map(int, s.split('.'))); sys.exit(0 if v(sys.argv[1]) >= v(sys.argv[2]) else 1)" "$have" "$pin" \ diff --git a/tests/web/component.yaml b/tests/web/component.yaml index 352f7ad..5bb5543 100644 --- a/tests/web/component.yaml +++ b/tests/web/component.yaml @@ -2,10 +2,19 @@ apiVersion: sourceplane.io/v1 kind: Component metadata: name: web-tests + description: The storefront's vitest suite — the demo catalogue and the cookie cart, the Shopify client against a stubbed Storefront API, revalidation, the site identity and the request origin spec: type: turbo-package lifecycle: production owner: platform + # Its pages, attached to it in the workspace's catalog: what the Docs + # library shows for it, and what the catalog's docs and runbook checks read. + # Generated from what this manifest and its sources declare. + docs: + overview: docs/overview.md + pages: + - { path: docs/architecture.md, role: architecture, title: Architecture } + - { path: docs/runbook.md, role: runbook, title: Runbook } domain: tests subscribe: environments: diff --git a/tests/web/docs/overview.md b/tests/web/docs/overview.md index 3534e6b..89a140d 100644 --- a/tests/web/docs/overview.md +++ b/tests/web/docs/overview.md @@ -1,5 +1,7 @@ # web-tests +The storefront's vitest suite — the demo catalogue and the cookie cart, the Shopify client against a stubbed Storefront API, revalidation, the site identity and the request origin + The test suite for **web**. It deploys nothing: its lane installs, builds and runs the tests. | | | diff --git a/tooling/catalog/gen-component-docs.py b/tooling/catalog/gen-component-docs.py index 9a39931..743782b 100644 --- a/tooling/catalog/gen-component-docs.py +++ b/tooling/catalog/gen-component-docs.py @@ -4,8 +4,11 @@ python3 tooling/catalog/gen-component-docs.py # write python3 tooling/catalog/gen-component-docs.py --check # fail on drift (CI) -The Orun workspace's Docs library renders the `docs/` folder next to every -`component.yaml`. These pages are generated, not hand-written, because almost +Every `component.yaml` attaches its `docs/` folder in `spec.docs` (overview, +architecture, runbook), which is what the Orun workspace's Docs library shows +and what the catalog's docs and runbook checks read; a folder nothing declares +is never attached (testing/coverage.test.sh holds the rule). These pages are +generated, not hand-written, because almost everything in them is already declared somewhere CI validates: the component's manifest (type, description, dependencies, environments, the secrets a lane resolves, the smoke), its Worker config (bindings, triggers, the wiring the