From 3150f24284d44bafa4c0fb1f16cc98100e84316e Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 25 Oct 2026 09:18:55 +0000 Subject: [PATCH] =?UTF-8?q?ND7:=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, brought to the Nextra docs site (web and its tests, one Cloudflare provider, no infra and no wiring). A. One secrets hook. The two single-template reconciles (secret-workers-deploy, secret-account-id) are one `secrets` reconcile (orun >= v2.87.0): one connections read, one secrets read, the missing keys created side by side. Same provider and no other parameters, so they merge; keys, templates and order are the card's. manifest.test.sh reads the `secrets` form beside `keys`; docs/phases/01-product.md and the card's comment name the one hook. B. No Checks workflow; docs in the catalog; web found. - checks.yml is gone. A site's pull requests verify through ci.yml's lanes, a bootstrap's landings through `plan`; the e2e tier runs the steps checks.yml ran (install, the fixture render, typecheck, lint, test, build) from its own LANDING_CHECKS list, and the leak gate no longer requires it. tests/web's lane is `quick-check`, so a site's pull request does not lint or run the tests: the site's README says to run them before a push, and the baseline's e2e tier runs them before a tag. - apps/web and tests/web attach overview, architecture and runbook in spec.docs; web-tests gets a description (its overview regenerated by tooling/catalog/gen-component-docs.py). - apps/web's domain is `app`, not `web`: the catalog keys a domain and a component by name, so the `web` domain hid the `web` component. - coverage.test.sh holds both rules (the three pages attached and present, a description, no domain named like a component). C. The fast shape on orun v2.88.0. - The run-level task set-up runs in the background (`background: true` on all five hooks); each phase's `task` moves from `pre` to `post`, just before `land`, so neither phase has a `pre` hook. - Both landings are `checks: local` (orun validate, then orun plan as the PR and as the merge, in the box) and merge without waiting for CI. - The convergence watch reads every 5 s. - No `pnpm-lockfile` hook: the shipped lockfile is installed frozen by the lanes and by the e2e tier. - 03-docs: no final probe (its render probes as it writes, and the landing redeploys nothing) and no narrate.await. The render asks the platform nothing: no `orun workspace`, `orun secrets list` or `orun integrations list`; the record names CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID (workspace scope) and points to the console's Secrets and Integrations pages. The "secrets inventory" wording in ai/context and the site's README follows. - No orun.secrets/exists await existed (no wiring here), so none is removed or kept. - expectedMinutes 5 + 1 -> 4 + 1, the card 6 -> 5, "about five minutes"; estimates, not measured on this shape. - Floor v2.88.0: BOOTSTRAP.md (with the `has no parameter "checks"` row) and baseline.yml's blueprint tier (placement included) and its site tier, whose offline bootstrap reads the blueprint. ci.yml's lane pin (v2.78.4) is unchanged. - phases.test.sh: PRE/POST/AWAIT lists and the fast-shape rules (every preInstantiate hook background, no task-plane `pre` hook, every landing checks: local, the watch at most 10 s). narrate.await is required where a phase waits (an await hook or a requires probe) and refused where it waits on nothing. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CJuLwDKfEaQGAEuBpJvN5Q --- .baseline/product/README.md | 10 +- .github/workflows/baseline.yml | 19 ++-- .github/workflows/checks.yml | 57 ---------- BOOTSTRAP.md | 45 +++++--- README.md | 3 +- ai/context/deployment.md | 2 +- ai/context/operations.md | 2 +- apps/web/component.yaml | 12 +- blueprint.yaml | 19 ++-- docs/phases/01-product.md | 19 ++-- docs/phases/03-docs.md | 7 +- docs/phases/README.md | 38 ++++--- hooks/render-deployment-docs.sh | 59 ++++------ repo-blueprint.yaml | 157 +++++++++++++++----------- testing/coverage.test.sh | 39 +++++++ testing/e2e.test.sh | 46 ++++---- testing/leak.test.sh | 2 +- testing/lib/bootstrap.sh | 4 +- testing/manifest.test.sh | 9 +- testing/phases.test.sh | 80 +++++++++++++ testing/placement.test.sh | 8 +- tests/web/component.yaml | 9 ++ tests/web/docs/overview.md | 2 + tooling/catalog/gen-component-docs.py | 7 +- 24 files changed, 386 insertions(+), 269 deletions(-) delete mode 100644 .github/workflows/checks.yml diff --git a/.baseline/product/README.md b/.baseline/product/README.md index d303be2..e612a4c 100644 --- a/.baseline/product/README.md +++ b/.baseline/product/README.md @@ -12,7 +12,7 @@ from the [Nextra Docs Template](https://github.com/shuding/nextra-docs-template) 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). @@ -61,9 +61,11 @@ against the workspace in `intent.yaml`. The site deploys to `stage`, then to `prod` once stage has converged on the same commit; `dev` only verifies. The Worker is `nextra-docs-web-` on your account's workers.dev subdomain, and every deploy is smoke-tested over HTTP: the home page must render and the -search index must be served. `checks.yml` runs install, typecheck, lint, -test and build on every pull request. (A push to `main` runs `ci.yml` alone, -which builds, tests and deploys.) +search index must be served. A pull request runs the same pipeline's verify +lanes: the site built and dry-deployed for each environment, with nothing +deployed. They do not lint or run the tests, so run `pnpm typecheck`, +`pnpm lint` and `pnpm test` before you push. (A push to `main` builds, +deploys and smoke-tests.) The pipeline holds one credential, GitHub's own `GITHUB_TOKEN`. The Cloudflare token and account id are brokered per run from the workspace's diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml index 9a142c7..6a07788 100644 --- a/.github/workflows/baseline.yml +++ b/.github/workflows/baseline.yml @@ -6,7 +6,7 @@ name: Baseline CI # placed tree comes up branded and carrying nothing of the factory, and that # the site it produces installs, builds, deploys (dry) and serves. # -# ─── WHY THIS IS NOT IN ci.yml 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 @@ -73,7 +73,7 @@ jobs: - 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 @@ -100,18 +100,21 @@ jobs: git config --global user.name "baseline ci" bash testing/placement.test.sh - # Tier 2. THE SITE IT PRODUCES WORKS: the finished site under the checks - # every later pull request of it runs, the stage lane's own build, output - # check and dry deploy, and the built Worker served and smoke-tested with - # the component's own smoke command. Pinned at the site's lane version, - # because that is the orun the site's CI runs. + # Tier 2. THE SITE IT PRODUCES WORKS: the finished site installed, its + # fixtures rendered, type-checked, linted, tested and built, the stage + # lane's own build, output check and dry deploy, and the built Worker served + # and smoke-tested with the component's own smoke command. Pinned at the + # bootstrap floor (v2.88.0): the offline bootstrap reads the blueprint (its + # one `secrets` reconcile, its background task set-up, its landings checked + # in the box), and the floor is newer than the site's lane pin (v2.78.4), + # which is all the lane steps need. site: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: sourceplane/orun-action@v1.2.0 with: - version: v2.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 5e3f2c4..0000000 --- a/.github/workflows/checks.yml +++ /dev/null @@ -1,57 +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: - # A BOOTSTRAP LANDING IS CHECKED BY `plan` ALONE. The baseline bootstrap - # lands on branches named for its tasks (`orun/BASE-…`) and merges each - # one as soon as its pull request's CI is green; the convergence that the - # merge starts on main installs, builds, deploys and smoke-tests the site - # for real, and the bootstrap watches it to green. Running this job there - # too was the same build twice, and most of each landing's wait — the - # same reason ci.yml skips its lanes on those branches. Its typecheck, - # lint and unit tests are not lost: the baseline's own CI runs them over a - # bootstrapped tree of the very commit being built (its e2e tier), and - # every other pull request of the site runs this job. - if: ${{ !(github.event_name == 'pull_request' && startsWith(github.head_ref, 'orun/BASE-')) }} - 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 - - run: pnpm typecheck - - run: pnpm lint - - run: pnpm test - - run: pnpm build diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index e5beaac..d640764 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -11,23 +11,30 @@ 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 six minutes** — an estimate summed from the -phases until a bootstrap measures it: two landings, each checked by `plan` -alone, one Next.js build (and its Pagefind index) per environment, stage and -prod deployed side by side until `03-docs` restores the promotion gate. -baseline-v1 measured 8m15s from the console's Build (2026-10-15) over three -landings, about 1m41s of it the build sandbox starting; `01-product` drops -one landing and the Checks waits, cirrus-baseline baseline-v22's shape. +Target wall-clock: **about five minutes** — an estimate summed from the +phases (4 + 1) until a bootstrap of this shape measures it. The shape: the +task set-up in the background while ONE landing is placed, branded and +checked in the box (`orun validate` and `orun plan`, no runner waited for), +one Next.js build (and its Pagefind index) per environment, stage and prod +deployed side by side, then a short docs landing, checked the same way, that +restores the promotion gate. baseline-v1 measured 8m15s from the console's +Build (2026-10-15) over three landings, about 1m41s of it the build sandbox +starting; `01-product` dropped one landing and the Checks waits +(cirrus-baseline baseline-v22's shape), and orun v2.88.0's fast shape took +about a minute out of turso-starter's measured build — the same minute is +assumed here. ## 0. What you need - GitHub org access (repository creation) and a machine with `git`, `node` (≥ 22), `pnpm` (10.12.1), `python3` with PyYAML, `curl`, and the `orun` - CLI **≥ v2.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 - site's own `ci.yml` pins its lanes separately (v2.78.4). + CLI **≥ v2.88.0** — the floor for RUNNING the bootstrap (the phase overlay, + landings that commit per phase, `githubOwner` on the doctor probe, a probe + deferred for a project not yet created, `from: workspace`, the deploy + credentials minted in one `secrets` reconcile, the task set-up run in the + background (`background: true`), and landings checked in the box before + they merge (`checks: local`)). The site's own `ci.yml` pins its lanes + separately (v2.78.4). - A Cloudflare account (the free plan is enough for one Worker with static assets) and its **Account API token** with Workers Scripts Write (the console's Connect recipe lists the exact permission groups). It is the ONLY @@ -78,8 +85,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 brokered Cloudflare secrets; then the whole site in one PR — intent, CI, tooling, identity, `apps/web` + `tests/web` | its PR's `plan` green, merged; the convergence green (build, deploy, smoke) and both workers.dev URLs answering | -| `03-docs` | `ai/context/deployment.md` from probed facts; prod's promotion gate and dev's push lanes restored | the final probe | +| `01-product` | the repository, created and linked; the brokered Cloudflare secrets; then the whole site in one PR — intent, CI, tooling, identity, `apps/web` + `tests/web` | its commit validated and planned in the box (as the PR and as the merge), then merged; the convergence green (build, deploy, smoke) and both workers.dev URLs answering | +| `03-docs` | `ai/context/deployment.md` from probed facts; prod's promotion gate and dev's push lanes restored | the render's own probes, recorded; the commit checked in the box and merged | ```bash orun new --blueprint repo-blueprint.yaml --out ~/sites/acme-docs --run-hooks \ @@ -163,8 +170,8 @@ bash testing/e2e.test.sh # + network for pnpm: the site built, dry-deplo The offline bootstrap (`testing/lib/bootstrap.sh`) places every phase in order and finishes each with the blueprint's OWN `run:` hooks — read out of `repo-blueprint.yaml`, not transcribed — so the rebrand, the re-tenant, the -deferrals and their restore, the retouch marker, the lockfile and the -deployment record all run exactly as a real bootstrap runs them. Only the +deferrals and their restore, the retouch marker and the deployment record +all run exactly as a real bootstrap runs them. Only the platform's typed actions (task, repo, link, land, watch, probe, reconcile) are stood in for, a landing becoming a commit. @@ -193,10 +200,12 @@ 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 | | Secret WRITE fails `not_found` while listings work | the API key's role is below admin; re-mint it with the admin role | | Deploy lane: Authentication error (10000) | the connection's token lacks Workers Scripts Write; re-issue it, re-connect, re-run `01-product` | +| `land` stops: `the landing's own check failed — orun plan for …` | the site's tree does not plan — the line after it is orun's own error (an unknown component type, a composition that does not resolve). Nothing was pushed. Fix the tree (or the baseline) and re-run the phase | +| `land` waits on CI after all | the site's repository requires a status check on `main` (branch protection or a ruleset), so GitHub refused the early merge; the landing waits for the check as a `checks: ci` landing would, then merges | | Convergence failed AFTER the PR merged; re-running lands nothing | expected on its own — the files are on main. Re-run the phase (`--phase 01-product`, `--redo 01-product`, or the console's Retry): its `retouch` hook gives the landing a diff and the site redeploys | | The site's `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace; set it and re-run `01-product` | | A bootstrap stopped before `03-docs`; prod no longer waits on stage | the gate is deferred, not dropped: run `03-docs`, or `node tooling/bootstrap/promotion.mjs --restore --file /intent.yaml` | | `✕ input "productname" is required` | all three required inputs (`reponame`, `productname`, `githuborg`) must be set on every invocation, single-phase ones included | -| `unknown flag: --phase` 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 | | `01-product` lanes fail in `build-app`: `Symlink apps/web/node_modules/next is invalid, it points out of the filesystem root` | the site'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 (this baseline does; `intent.yaml` says why) | -| `01-product`'s convergence reported green, then `verify` got 404 from both URLs | a second workflow ran on the push to main and the watch took its run (a `checks.yml` that also runs on push). This baseline runs `checks.yml` on pull requests only, and its coverage gate holds the rule; read the CI run on main for the real result | +| `01-product`'s convergence reported green, then `verify` got 404 from both URLs | a second workflow ran on the push to main and the watch took its run (an early `checks.yml` that also ran on push did this). Only `ci.yml` may run on a push to main, a site carries no other workflow, and the coverage gate holds the rule; read the CI run on main for the real result | diff --git a/README.md b/README.md index f4447a3..6263ea9 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,6 @@ ones); it is pre-rendered and indexed at build time. | Workflow | What it runs | Ships to a site | |---|---|---| -| `checks.yml` | install, wire fixtures, 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; 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 site carries: `orun plan --changed`, then one job per lane. A pull request runs the verify lanes (the site built and dry-deployed per environment; the tests' `quick-check` lane installs and checks the package, it does not run them), except the bootstrap's own landings (`orun/BASE-*`), where `plan` alone is the check; a merge deploys stage → prod. It plans nothing while `intent.yaml` names the placeholder workspace `ws_CHANGE_ME`, as this repository does | yes | | `baseline.yml` | the baseline's own tiers: contract tests, the blueprint read by the pinned orun, the leak gate, the offline bootstrap, the site built in a staged job tree, dry-deployed and served | no | | `tag.yml` | cuts a `baseline-vN` tag (manual) | no | diff --git a/ai/context/deployment.md b/ai/context/deployment.md index d79fa8f..2b51481 100644 --- a/ai/context/deployment.md +++ b/ai/context/deployment.md @@ -2,6 +2,6 @@ > Not rendered yet. The bootstrap's `03-docs` phase probes every live URL and > regenerates this file from what answered — the workspace, the URLs and -> their status, and the secrets 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). diff --git a/ai/context/operations.md b/ai/context/operations.md index 41c3434..4641d44 100644 --- a/ai/context/operations.md +++ b/ai/context/operations.md @@ -1,7 +1,7 @@ # nextra-docs — 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 `03-docs` phase; this file is the contract that stays true between deployments. It is written to give an agent with repository read diff --git a/apps/web/component.yaml b/apps/web/component.yaml index 7314959..d02473f 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 09031cf..5be0782 100644 --- a/blueprint.yaml +++ b/blueprint.yaml @@ -23,7 +23,7 @@ metadata: dark mode and full-text search through a Pagefind index, on Nextra 4 and Next.js, built by OpenNext into one Cloudflare Worker with Static Assets, and CI that deploys it to stage and prod on merge. One provider, one - consent, one token, one landing. Live in about six minutes. + consent, one token, one landing. Live in about five minutes. tags: [docs, nextra, mdx, cloudflare, nextjs] spec: source: @@ -104,11 +104,12 @@ spec: 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. + # hook mints these, brokered, during 01-product. ────────────────────────── + # Transcribed from that hook's own `secrets:` list (each key and its + # `template:`), so testing/manifest.test.sh compares this list to the + # document that mints them. The console renders them read-only: no + # credential is ever typed, shown or stored. Keys that already exist are + # kept. secrets: - key: CLOUDFLARE_API_TOKEN provider: cloudflare @@ -135,9 +136,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: 6 + # Summed from the phases' expectedMinutes (4 + 1). An estimate until a + # bootstrap of this shape measures it. + expectedMinutes: 5 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 261bf70..3e67d9a 100644 --- a/docs/phases/01-product.md +++ b/docs/phases/01-product.md @@ -2,8 +2,8 @@ **Places** the whole tree: the root manifests (`intent.yaml`, `package.json`, the pnpm workspace and lockfile, `turbo.json`), -`.github/workflows` (`ci.yml` and `checks.yml` — the baseline's own -`baseline.yml` and `tag.yml` are ignored), the shared TypeScript/ESLint +`.github/workflows` (`ci.yml` — the baseline's own `baseline.yml` and +`tag.yml` are ignored), the shared TypeScript/ESLint config and the wrangler renderer, the site's README and its two context pages, the identity file `.rebrand/values.json`, `.gitkeep` files for the four discovery roots, `apps/web` (the Nextra site — its content, its theme, @@ -18,9 +18,12 @@ probe runs before anything is created. ## What runs +The run's task set-up — the epic, both milestones, both tasks — runs in the +background from the start (`background: true`), so every hook up to `task` +runs beside it; `task` is the first that waits for it. + | hook | what it does | |---|---| -| `task` (pre) | finds the phase's task (opened by the run-level list) and yields its key | | `retouch` | the redeploy marker on `apps/web/component.yaml` and `tests/web/component.yaml` (`.baseline/tasks/01-product.TaskContract.yaml`'s `affects`) | | `git-init`, `git-stage` | the rebrand enumerates with `git ls-files`, so the tree is a staged repo first | | `rebrand` | renames the baseline's identity to the site's over the whole tree (`tooling/rebrand/rebrand.mjs`) | @@ -29,13 +32,12 @@ probe runs before anything is created. | `promotion` | defers prod's wait on stage until `03-docs` (both environments deploy side by side) | | `dev-lanes` | keeps dev's verify lanes off main's convergences until `03-docs` | | `git-restage`, `rebrand-verify` | refuses the landing if any baseline identity is left | -| `pnpm-lockfile` | confirms the baseline's complete lockfile against the placed tree (a no-op) | | `repo` | `orun.repo/ensure@v1` — creates `githuborg/reponame` (private unless `repoPrivate=false`) | | `link` | `orun cloud link` (best effort) then `orun cloud check` — an unlinked repo stops here | -| `secret-workers-deploy` | `orun.integrations/reconcile@v1` — ensures `CLOUDFLARE_API_TOKEN`, brokered from the Cloudflare connection with the `workers-deploy` scope | -| `secret-account-id` | ensures `CLOUDFLARE_ACCOUNT_ID`, the connection fact | -| `land` | one PR, checked by `plan` alone (a bootstrap branch skips the lanes and Checks) and merged on green | -| `converge` (await) | `orun.run/watch@v1` on the merge commit's run; resumes it up to three times | +| `secrets` | `orun.integrations/reconcile@v1`, both keys in one hook, created side by side: `CLOUDFLARE_API_TOKEN` from the `workers-deploy` template (Workers Scripts, the site's deploy); `CLOUDFLARE_ACCOUNT_ID`, the connection fact | +| `task` | finds the phase's task (opened by the run-level list) and yields its key — waiting, if it must, for the background set-up | +| `land` | one PR bound to the task, its commit checked in the box first (`checks: local`: `orun validate`, then `orun plan` as the PR and as the merge would plan it, under a second); merged without waiting for the PR's CI | +| `converge` (await) | `orun.run/watch@v1` on the merge commit's run, read every 5 s; resumes it up to three times | | `verify` (await) | `orun.http/probe@v1` on both workers.dev URLs | ## What the convergence does @@ -63,6 +65,7 @@ the merge commit is green, and | parks on `waiting for github for ` | the workspace's GitHub connection is to another account. Connect the App installation on `` (console → Integrations → GitHub), then `--resume` | | parks on the `providers` probe for cloudflare | Cloudflare is not connected to the workspace. Connect it (console → Integrations → Cloudflare, paste the Account API token) | | `link` fails: `… is not linked to workspace` | the credential cannot write links and the platform has not linked the repo. Allow-list it (console → Settings → Git repos) and re-run the phase | +| `land`: `the landing's own check failed — orun plan for …` | the placed tree does not plan; the next line is orun's error. Nothing was pushed. Fix it and re-run the phase | | `rebrand-verify` lists leftovers | a file carries an identity form no rule renames. Add a rule to `tooling/rebrand/rebrand.mjs` (and a case to `testing/rebrand.test.sh`) | | `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace. Set it and re-run | | deploy lane: `secret resolution failed … CLOUDFLARE_API_TOKEN` | the reconcile did not run or minted against a revoked connection. Re-connect and re-run the phase; the reconcile re-mints only what is missing | diff --git a/docs/phases/03-docs.md b/docs/phases/03-docs.md index cc0d105..59fd42c 100644 --- a/docs/phases/03-docs.md +++ b/docs/phases/03-docs.md @@ -11,12 +11,11 @@ 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 the search index (`/_pagefind/pagefind-entry.json`) on both environments, 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, checked by `plan` alone and merged on green. 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 the search index (`/_pagefind/pagefind-entry.json`) on both environments and regenerates `ai/context/deployment.md` — the identity, the probed URLs, the secrets the deployment uses by name — and the README's live-deployment section. It asks the platform nothing: what the workspace holds right now is on the console's Secrets and Integrations pages, which the record points to | +| `task` | finds the phase's task and yields its key | +| `land` | one PR, its commit checked in the box (`checks: local`) and merged. It touches no component, so it deploys nothing — and there is nothing after it to wait for: the render's probes are the phase's check | ## Re-running it diff --git a/docs/phases/README.md b/docs/phases/README.md index 9e0ac30..c087366 100644 --- a/docs/phases/README.md +++ b/docs/phases/README.md @@ -8,11 +8,15 @@ no umbrella workflow and no per-phase document: a phase is a selection on one artifact, which is what makes running one alone, months later, from a fresh container the same operation as running them all. -Each phase follows the same contract: +The site 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) → 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. @@ -24,15 +28,15 @@ states it in the document: the engine refuses a phase whose predecessor is not placed, and names it. Every landing is a pull request on a branch named for its task -(`orun/BASE--`). 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, typecheck, lint, -test, build) skips its job on those branches for the same reason — the -convergence builds, deploys and smoke-tests the site, and the baseline's own -CI ran these checks over a bootstrapped tree at the tag being built — and runs -on every other pull request. -So each landing waits for `plan` alone, a few seconds, and merges. +convergence is what the phase watches. The site carries no other workflow: +the baseline's own CI (Tier 2) installs, renders the fixtures, type-checks, +lints, tests and builds this tree before a tag is cut, and every later pull +request in the site runs `ci.yml`'s verify lanes. | phase | lands | verified by | |---|---|---| @@ -95,14 +99,16 @@ lands, its `post` hooks make them the site's: those components. 2. `rebrand` → `rebrand --verify` — the identity rename over the whole tree, then a sweep that fails on any of this baseline's identity left behind. -3. `pnpm install --lockfile-only` over the baseline's complete lockfile — - the whole tree is placed, so it only confirms it and `--frozen-lockfile` - installs pass. + +The baseline's complete lockfile ships as it is: it carries no identity, and +the lanes install it with `--frozen-lockfile`, as the baseline's own CI does +on this exact tree before a tag. ## When a phase fails - **Before it lands** (a probe that timed out, a rebrand residue, a refused - link): nothing was merged. Fix what the message names and re-run the phase. + link, a tree the landing's own `orun plan` refuses): nothing was merged. + Fix what the message names and re-run the phase. - **After it lands** (the convergence went red): the files are on main. `orun.run/watch@v1` has already resumed the run up to three times. Re-run the phase (`--phase 01-product`, `--redo 01-product` under `--resume`, or the diff --git a/hooks/render-deployment-docs.sh b/hooks/render-deployment-docs.sh index 47e7abc..b39e873 100644 --- a/hooks/render-deployment-docs.sh +++ b/hooks/render-deployment-docs.sh @@ -9,15 +9,22 @@ # # What it writes (in ): # ai/context/deployment.md — REGENERATED: URLs with live probe results, -# identity, secrets inventory BY NAME, -# integrations +# identity, and the secrets the deployment +# uses BY NAME # ai/context/operations.md — healed from the baseline's copy if absent # (the static operating contract; never rewritten) # README.md — the section between # is replaced (appended after the title if the # README predates the markers) # -# No secret VALUE is ever read or written here — 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 }" @@ -35,10 +42,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="?" @@ -63,17 +66,6 @@ for pair in "stage|$stage_dev" "prod|$prod_dev"; do rows+="| search index (${env}) | ${url}/_pagefind/pagefind-entry.json | $(badge "$(probe "$url/_pagefind/pagefind-entry.json")") |"$'\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. @@ -90,15 +82,14 @@ cat > ai/context/deployment.md < GENERATED by the \`03-docs\` phase on ${now}; re-run it to refresh > (idempotent; see [operations.md](operations.md)). Hand-edits here are -> overwritten. No secret values appear in this file — 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\` | | CI lane CLI pin | orun \`${lanepin}\` (\`.github/workflows/ci.yml\`) | @@ -110,23 +101,17 @@ cat > ai/context/deployment.md <" body = f"""{begin} -This site is **live**. Verified URLs, identity and the secrets inventory are +This site is **live**. Verified URLs, identity and the secrets it uses are recorded in [ai/context/deployment.md](ai/context/deployment.md) (re-rendered by the `03-docs` phase); how it deploys and how to operate it: [ai/context/operations.md](ai/context/operations.md). diff --git a/repo-blueprint.yaml b/repo-blueprint.yaml index f210897..f30f974 100644 --- a/repo-blueprint.yaml +++ b/repo-blueprint.yaml @@ -179,6 +179,10 @@ modules: source: baseline from: pnpm-workspace.yaml to: pnpm-workspace.yaml + # The baseline's complete lockfile, as it is: the whole tree lands at once + # and the lockfile carries no identity, so there is nothing to re-resolve — + # the lanes install it with --frozen-lockfile, and the baseline's own CI + # (testing/e2e.test.sh) does the same on this exact tree before a tag. - name: root-pnpm-lock mode: copy source: baseline @@ -287,16 +291,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 }}" @@ -311,6 +324,7 @@ hooks: owner: me - id: m01 uses: orun.task/ensure@v1 + background: true with: kind: milestone epic: "{{ .inputs.epicSlug }}" @@ -321,6 +335,7 @@ hooks: - the home page answers on both workers.dev URLs - id: m03 uses: orun.task/ensure@v1 + background: true with: kind: milestone epic: "{{ .inputs.epicSlug }}" @@ -330,6 +345,7 @@ hooks: - prod waits on stage again - id: t01 uses: orun.task/ensure@v1 + background: true with: kind: task epic: "{{ .inputs.epicSlug }}" @@ -345,6 +361,7 @@ hooks: contract: .baseline/tasks/01-product.TaskContract.yaml - id: t03 uses: orun.task/ensure@v1 + background: true with: kind: task epic: "{{ .inputs.epicSlug }}" @@ -386,7 +403,14 @@ phases: - name: 01-product title: The site, built in one landing description: The whole tree — manifests, tooling, CI, the identity and the Nextra site — branded, landed as one pull request, built by OpenNext with its Pagefind index and deployed to stage and prod by one convergence. - expectedMinutes: 5 + # An estimate, not a measurement of this shape: a minute under the 5 it + # was, for what v2.88.0 takes out of the wait — the task set-up in the + # background, the landing checked here instead of by a runner's `plan`, + # the watch reading every 5 s instead of 40 (about a minute on + # turso-starter's measured build). The rest is the merge's convergence: + # the site's Next.js build with its Pagefind index, deploy and smoke, + # stage and prod side by side. + expectedMinutes: 4 narrate: start: "Creating the repository and landing the whole site in one pull request — intent, CI, tooling, the pages, the sidebar and the search index. Then one convergence builds it with OpenNext and deploys it to stage and prod side by side. Usually about {{ .meta.expectedMinutes }} minutes." await: "The site is building and deploying on both environments. The Next.js build is the long pole; nothing is stuck." @@ -412,19 +436,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 site in one landing" - prefix: BASE - contract: .baseline/tasks/01-product.TaskContract.yaml post: # A RE-RUN PHASE MUST HAVE SOMETHING TO LAND. A convergence can fail # AFTER its PR merged, and the merge has already put every file this @@ -497,12 +508,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 — a no-op in well under a - # second, where the old per-phase prune of the Next.js tree was a - # resolve. The lanes and Checks install with --frozen-lockfile. - - 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 @@ -531,30 +536,46 @@ 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. The deploy lane binds both keys (the workers-assets - # composition's `secretBindings`). Keys that already exist are kept. - # After the link, before the landing whose convergence uses them. - - id: secret-workers-deploy + # The deploy credentials, brokered, in ONE hook (orun >= v2.87.0): + # `secrets` mints each key under its own scope template from the one + # connection the build is bound to, reading the connections and the + # existing secrets once and creating the missing keys side by side. + # `workers-deploy` is the site's deploy (Workers Scripts); the account + # id is a connection fact. The deploy lane binds both keys (the + # workers-assets composition's `secretBindings`). Keys that already + # exist are kept. After the link, before the landing whose convergence + # uses them. + - id: secrets uses: orun.integrations/reconcile@v1 with: provider: cloudflare - keys: [CLOUDFLARE_API_TOKEN] - template: workers-deploy - - id: secret-account-id - uses: orun.integrations/reconcile@v1 + secrets: + - { key: CLOUDFLARE_API_TOKEN, template: workers-deploy } + - { key: CLOUDFLARE_ACCOUNT_ID, template: account-id } + # The task this landing closes, and its key. The run-level list above + # opens it in the background; this is the first hook that needs it, + # so it is the one that waits for that list (orun >= v2.88.0) — every + # hook before it ran while the task plane was still being set up. + - id: task + uses: orun.task/ensure@v1 with: - provider: cloudflare - keys: [CLOUDFLARE_ACCOUNT_ID] - template: account-id - # THE SITE IS A PULL REQUEST THAT IS CHECKED, THEN MERGED. This - # landing waits for its PR's own CI (orun >= v2.58.6) and merges only - # on green — and on a bootstrap branch (`orun/BASE-…`) that CI is - # `plan` alone: ci.yml skips the lanes and checks.yml skips its job, - # because the merge runs the site's build, deploy and smoke on - # main moments later, for real, and the convergence after the merge - # is what `await` watches to green. + kind: task + epic: "{{ .inputs.epicSlug }}" + milestone: "{{ .phase.name }}" + name: "Build the site in one landing" + prefix: BASE + contract: .baseline/tasks/01-product.TaskContract.yaml + # THE SITE IS A PULL REQUEST THAT IS CHECKED, THEN MERGED — checked + # HERE (`checks: local`, orun >= v2.88.0): `orun validate`, then + # `orun plan` as the pull request and as the merge to main plan it, + # on the commit, before it is pushed. That is what the PR's `plan` + # job checks (the intent, every component and every composition + # resolve), plus the merge's own plan, in under a second instead of a + # runner's ~25 s. A tree that fails is never pushed. The PR's CI still + # runs (`plan` alone on a bootstrap branch, `orun/BASE-…`, ci.yml); + # nothing waits for it. The merge runs the site's build, deploy and + # smoke on main moments later, for real, and that convergence is what + # `await` watches to green. - id: land uses: orun.pr/land@v1 narrate: "The site is merged into main." @@ -563,6 +584,7 @@ phases: epic: "{{ .inputs.epicSlug }}" branchSlug: "{{ .phase.name }}" title: "feat: {{ .inputs.productname }}, the whole site from the Nextra docs baseline" + checks: local await: - id: converge uses: orun.run/watch@v1 @@ -574,6 +596,9 @@ phases: repo: "{{ .inputs.githuborg }}/{{ .inputs.reponame }}" resumeBudget: 3 waitSeconds: 1800 + # Read every 5 s, not the action's 40: the build goes on the + # moment the run is green instead of up to 40 s after it. + pollSeconds: 5 - id: verify uses: orun.http/probe@v1 narrate: "The site answered on stage and prod." @@ -583,31 +608,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. + # rather than from what the blueprint intended — which is why it runs last. + # Its render probes every URL as it writes the record, and this landing + # redeploys nothing, so there is no probe after it to wait for. - name: 03-docs title: The deployment, recorded description: The live-deployment manifest, rendered from probed reality, and the promotion gate put back. + # An estimate, not a measurement: the render's probes, the task found, + # the commit checked here and merged — nothing built, nothing waited on. expectedMinutes: 1 narrate: start: "Now recording what was actually built — probing every URL and writing the deployment manifest into the repository." - 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/03-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 @@ -622,8 +639,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 }}"] - # Checked by `plan` alone, like 01-product's: a bootstrap branch skips - # the lanes and checks.yml's job, and nothing here builds. + - id: task + uses: orun.task/ensure@v1 + with: + kind: task + epic: "{{ .inputs.epicSlug }}" + milestone: "{{ .phase.name }}" + name: "Record the live deployment" + prefix: BASE + contract: .baseline/tasks/03-docs.TaskContract.yaml + # Checked here and merged, as 01-product's landing is; nothing here + # builds. - id: land uses: orun.pr/land@v1 narrate: "The deployment record is merged into main." @@ -632,11 +658,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 25e71e0..4bc66dd 100755 --- a/testing/coverage.test.sh +++ b/testing/coverage.test.sh @@ -95,6 +95,45 @@ for comp in BASELINE_ONLY: if not (root / comp).exists(): bad(f"{comp} is declared baseline-only and does not exist — drop the entry") +# ── WHAT THE CATALOG SEES OF EACH COMPONENT ─────────────────────────────── +# +# Every component ships its generated pages (overview, architecture, runbook) +# and must ATTACH them in `spec.docs`: a `docs/` folder no manifest declares is +# never attached, so a fresh site's Docs library showed nothing for 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 site'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 + if spec.get("domain"): + domains.setdefault(spec["domain"], comp) + if not (meta.get("description") or "").strip(): + bad(f"{comp}/component.yaml has no metadata.description — the catalog shows the component with nothing to say") + docs = spec.get("docs") or {} + got = {"overview": docs.get("overview")} + for page in docs.get("pages") or []: + got[page.get("role")] = page.get("path") + for role, path in WANT_DOCS.items(): + if got.get(role) != path: + bad(f"{comp}/component.yaml does not attach {path} as its {role} " + f"(spec.docs) — the page ships and the catalog never sees it") + elif not (root / comp / path).is_file(): + bad(f"{comp}/component.yaml attaches {path}, which does not exist") +for domain, comp in sorted(domains.items()): + if domain in names: + bad(f"{comp} declares domain `{domain}`, which is also the name of the " + f"component in {names[domain]} — the catalog keeps one of the two") + # ── WHAT `ignore` ACTUALLY EXCLUDES (BE6) ────────────────────────────────── # # orun matches an ignore entry two ways, and WHICH ONE depends on the entry: diff --git a/testing/e2e.test.sh b/testing/e2e.test.sh index acb79c3..158b5ad 100644 --- a/testing/e2e.test.sh +++ b/testing/e2e.test.sh @@ -4,13 +4,15 @@ # placement.test.sh proves the tree a bootstrap ends with is the right tree. # This proves it WORKS, by doing to it what its own pipelines will: # -# 1. at the finished site, what `checks.yml` runs on a pull request — -# install with the committed lockfile, render fixtures, typecheck, lint, -# test, build. The bootstrap's own landings do not wait on it (on a -# `orun/BASE-…` branch the job is skipped and `plan` is the check; the -# convergence on main builds, deploys and smoke-tests the site), so this -# tier is where they run over a bootstrapped tree, and the gate -# every LATER pull request of the site meets; +# 1. at the finished site, the landing's own checks — install with the +# lockfile the site ships, render fixtures, typecheck, lint, test, +# build. The bootstrap's own landings are checked in the box with +# `orun validate` and `orun plan` alone (`checks: local`; their PR's CI +# on an `orun/BASE-…` branch is `plan` alone, and the convergence on +# main builds, deploys and smoke-tests the site), so THIS is where a +# site those steps refuse is caught: before the tag, not after a build +# has merged it. Every later pull request of the site runs ci.yml's +# verify lanes; # 2. the stage lane's own steps, rendered by `orun plan` in the site: on a # pull request (the verify profile) `build-app` — the component's # buildCommand (`next build` with Turbopack, Pagefind over @@ -40,7 +42,8 @@ # # Needs: orun, node, pnpm, python3 (+PyYAML), git, curl, and the network for # `pnpm install` (or a warm store). A few minutes: two installs and builds -# (the Checks over the site, and the stage lane's own in its staged tree). +# (the landing's checks over the site, and the stage lane's own in its staged +# tree). set -euo pipefail here="$(cd "$(dirname "$0")" && pwd)" root="$(cd "$here/.." && pwd)" @@ -69,24 +72,25 @@ 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 site -# carries so the two cannot drift: every `run:` of its one job, in order. +# The landing's own checks, step for step, run here at once on the whole +# tree. A pull request in the site builds and dry-deploys it through ci.yml's +# lanes; the lint and the tests run here, and by hand before a push. +LANDING_CHECKS=( + "pnpm install --frozen-lockfile" + "pnpm run wire:fixture" + "pnpm typecheck" + "pnpm lint" + "pnpm test" + "pnpm build" +) checks() { # DIR LOG local dir="$1" log="$2" cmd - 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)" @@ -96,7 +100,7 @@ bootstrap_offline "$root" "$tree" "$values" "$scratch/logs" > "$scratch/bootstra echo " 2 phases placed and landed" # ── 1. the finished site ─────────────────────────────────────────────────── -echo "── the finished site, under the checks a pull request of it runs" +echo "── the finished site: install, the fixture render, typecheck, lint, test, build" checks "$tree" "$scratch/checks-site.log" # ── 2. the deploy lane's steps, for stage ────────────────────────────────── diff --git a/testing/leak.test.sh b/testing/leak.test.sh index dbe0def..5b4688d 100644 --- a/testing/leak.test.sh +++ b/testing/leak.test.sh @@ -78,7 +78,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", "apps/web/app/layout.tsx", "apps/web/content/_meta.ts", "tests/web/component.yaml", "tests/web/src/site.test.ts", ".rebrand/values.json"): diff --git a/testing/lib/bootstrap.sh b/testing/lib/bootstrap.sh index 0cb819e..4289b20 100644 --- a/testing/lib/bootstrap.sh +++ b/testing/lib/bootstrap.sh @@ -18,8 +18,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 check, 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..a834d4d 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 two keys is +# two 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 458e694..e0e856a 100644 --- a/testing/phases.test.sh +++ b/testing/phases.test.sh @@ -12,6 +12,12 @@ # ONE LANDING BUILDS THE SITE (PK-6, cirrus-baseline baseline-v22's shape): # 01-product places every module, and 03-docs only records. # +# And the shape that keeps a bootstrap fast (orun >= v2.88.0, turso-starter +# baseline-v8's): 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. # @@ -49,6 +55,19 @@ PARTITION = { HOOK_ONLY = {"03-docs"} # The phases that DEPLOY, and so must give a re-run something to land. DEPLOYS = {"01-product"} +# 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. 03-docs awaits nothing: +# its render probes as it writes, and its landing redeploys nothing. +PRE = {"01-product": [], "03-docs": []} +POST = { + "01-product": ["retouch", "git-init", "git-stage", "rebrand", "orun-workspace", "work-tree", + "promotion", "dev-lanes", "git-restage", "rebrand-verify", + "repo", "link", "secrets", "task", "land"], + "03-docs": ["promotion", "dev-lanes", "render", "task", "land"], +} +AWAIT = {"01-product": ["converge", "verify"], "03-docs": []} by_name = {p["name"]: p for p in phases} names = [p["name"] for p in phases] @@ -127,6 +146,58 @@ for p in phases: bad(f"phase {p['name']} deploys and does not watch the convergence of the " f"commit it merged (orun.run/watch@v1 with sha: mergeSha)") +# ── the hooks run in the one-landing order ──────────────────────────────── +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 = [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(): + got = [h.get("id") for h in ((by_name.get(name, {}).get("hooks") or {}).get("await") or [])] + if got != want: + bad(f"phase {name}'s await hooks are {got}; want {want}") +for p in phases: + if p["name"] not in DEPLOYS: + for h in hooks_of(p): + if (h.get("uses") or "").startswith(("orun.integrations/reconcile@", "orun.run/watch@")): + bad(f"phase {p['name']} deploys nothing and runs {h['uses']} ({h.get('id')})") + +# ── 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") +# A `pre` hook on the task plane would wait for that background at once, +# before the phase had placed a file — the old order, whatever its id. +TASK_PLANE = ("orun.task/", "orun.pr/") +for p in phases: + for h in ((p.get("hooks") or {}).get("pre") or []): + if (h.get("uses") or "").startswith(TASK_PLANE): + bad(f"phase {p['name']}'s pre hook {h.get('id')} uses {h['uses']}, which waits for the " + f"background task set-up — find the task in `post`, just before the landing") +# Every landing checks its commit here and merges, instead of waiting ~25 s +# 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): return [(h.get("with") or {}).get("name") for h in hooks @@ -220,8 +291,17 @@ 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)} + # The await line is said while the phase waits: on an await hook, or on a + # deferred `requires.probe`. A phase that waits on nothing never says it, + # so it may not author one; one that waits must. + waits = bool((p.get("hooks") or {}).get("await")) or bool((p.get("requires") or {}).get("probe")) for slot in ("start", "await", "done", "failed"): line = n.get(slot) + if slot == "await" and not waits: + if line: + bad(f"phase {p['name']} declares narrate.await and waits on nothing — " + 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 a8f289e..adc7404 100644 --- a/testing/placement.test.sh +++ b/testing/placement.test.sh @@ -12,8 +12,7 @@ # 2. THE OFFLINE BOOTSTRAP (testing/lib/bootstrap.sh) — every phase placed in # order onto what the previous one landed, finished by the blueprint's OWN # `run:` hooks (rebrand, re-tenant, work-tree strip, the deferrals, the -# retouch marker, the lockfile, the deployment record), each landing a -# commit; +# retouch marker, the deployment record), each landing a commit; # 3. the product it ends with: branded with no residue, carrying nothing of # the factory, re-tenanted, its gates restored, its record rendered; # 4. what the product's own CI would do with the 01-product merge: `orun @@ -26,9 +25,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)" diff --git a/tests/web/component.yaml b/tests/web/component.yaml index 352f7ad..2632804 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 site's vitest suite (the content pages, the `_meta` sidebar and navbar, and the site's identity), run with pnpm test 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..f0b90d9 100644 --- a/tests/web/docs/overview.md +++ b/tests/web/docs/overview.md @@ -1,5 +1,7 @@ # web-tests +The site's vitest suite (the content pages, the `_meta` sidebar and navbar, and the site's identity), run with pnpm test + 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