diff --git a/.baseline/identity.json b/.baseline/identity.json
new file mode 100644
index 0000000..6c9ca2d
--- /dev/null
+++ b/.baseline/identity.json
@@ -0,0 +1,9 @@
+{
+ "_comment": "THIS TREE'S OWN IDENTITY — the FROM side of every rebrand. tooling/rebrand/rebrand.mjs reads it to know what to rename AWAY from; a product's identity is the --values file, which is the TO side. Change a value here only together with the tree: these strings must be what the tree actually contains, or the rename silently misses and the product ships carrying this baseline's name. `productName` is the SITE_NAME seam in apps/web/src/site.ts (upstream's own heading, 'SvelteKit Auth Example'); `pascal` is also the name of Auth.js's `SvelteKitAuth`, which the engine protects where the app imports and calls it (UPSTREAM in rebrand.mjs); `domain` and `subdomain` are placeholders, because this baseline has never deployed under a name of its own; `githubOwner` is the owner in the repository's source links.",
+ "slug": "sveltekit-auth",
+ "pascal": "SvelteKitAuth",
+ "productName": "SvelteKit Auth Example",
+ "domain": "sveltekit-auth.example.com",
+ "subdomain": "your-workers-subdomain",
+ "githubOwner": "sourceplane"
+}
diff --git a/.baseline/product/README.md b/.baseline/product/README.md
new file mode 100644
index 0000000..ca51f13
--- /dev/null
+++ b/.baseline/product/README.md
@@ -0,0 +1,171 @@
+# sveltekit-auth
+
+A SvelteKit site whose sign-in is [Auth.js](https://authjs.dev) — a home
+page, a sign-in page, a page only a signed-in visitor can read, and a
+sign-out — on **Cloudflare Workers + Static Assets** through SvelteKit's own
+[`@sveltejs/adapter-cloudflare`](https://svelte.dev/docs/kit/adapter-cloudflare).
+Sessions are Auth.js's encrypted JWT cookies: there is no database to run.
+
+It is Auth.js's SvelteKit example, ported to Cloudflare.
+Upstream: https://github.com/nextauthjs/sveltekit-auth-example (ISC,
+© 2022-2024 Balázs Orbán; the licence is `apps/web/LICENSE`).
+
+## Live deployment
+
+
+Not recorded yet. The bootstrap's last phase writes the live URLs, the
+workspace and the secrets the site uses into
+[ai/context/deployment.md](ai/context/deployment.md); how the site deploys
+and how to operate it is in
+[ai/context/operations.md](ai/context/operations.md).
+
+
+## What is here
+
+| Surface | Where |
+|---|---|
+| The site's name (the home page's heading, every page's `
`) | `apps/web/src/site.ts` |
+| `/` (home), `/signin`, `/protected`, `/signout` | `apps/web/src/routes` |
+| Auth.js: the configuration, built per request from the Worker's secrets | `apps/web/src/auth.ts`, `apps/web/src/hooks.server.ts` |
+| The 26 sign-in providers and the keys each needs | `apps/web/src/server/providers.ts` |
+| The header (who is signed in, sign in and out) and the footer | `apps/web/src/components` |
+| The deploy step that gives each Worker its secrets | `tooling/wire/worker-secrets.mjs` |
+| Workers build and deploy contract | `apps/web/svelte.config.js`, `apps/web/wrangler.jsonc`, `apps/web/component.yaml` |
+| Tests (the providers and their keys, the site's name, the secrets step) | `apps/web/src/**/*.test.ts` (vitest) |
+
+## Getting started
+
+```bash
+pnpm install # runs `svelte-kit sync`
+pnpm typecheck # svelte-check
+pnpm lint # prettier --check
+pnpm test # vitest
+pnpm build # vite build → apps/web/.svelte-kit/cloudflare (_worker.js + the static output)
+```
+
+```bash
+pnpm --filter @app/web secret:dev # writes a generated AUTH_SECRET into apps/web/.env (git-ignored)
+pnpm --filter @app/web dev # http://localhost:3000
+pnpm --filter @app/web preview # wrangler dev over the built Worker, http://localhost:8787
+```
+
+Both read `apps/web/.env`: copy `apps/web/.env.example`, the example's
+own, for every key the site can take. Without an
+AUTH_SECRET Auth.js refuses every request with a server-configuration
+error, so run `secret:dev` once; a second run keeps the secret it wrote.
+
+Make the site yours in `apps/web/src/routes` (the pages) and
+`apps/web/src/site.ts` (its name). A page reads the visitor's session from
+`$page.data.session` (the root layout loads it with `event.locals.auth()`),
+as `/protected` does.
+
+## Sign-in providers
+
+The site deploys with no provider connected, and `/signin` says so and
+lists what each one needs. A provider is offered once **every** key it
+takes is set; the others are never shown. For GitHub:
+
+1. Create an OAuth app (GitHub → Settings → Developer settings → OAuth
+ Apps). Its callback URL is the site's `/auth/callback/github`:
+ `https://sveltekit-auth-web-prod..workers.dev/auth/callback/github`
+ for prod (one app per environment, or one per origin you serve).
+2. Store its client id and secret as this repository's Orun secrets for
+ that environment (or on the console's Secrets page):
+
+ ```bash
+ orun secrets set AUTH_GITHUB_ID --env prod # prompts for the value
+ orun secrets set AUTH_GITHUB_SECRET --env prod
+ ```
+
+ The build never sees them; the deploy hands them to the Worker as
+ Worker secrets (`wrangler secret bulk`, over stdin), so they are in no
+ bundle, no build cache and no log.
+3. Redeploy (a merge, or **Deploy by hand** below). The deploy pushes the
+ keys to the Worker, and the GitHub button appears.
+
+The deploy pushes the keys of the providers upstream's `.env.example`
+names, when they are set:
+
+| Provider | Keys |
+|---|---|
+| GitHub | `AUTH_GITHUB_ID`, `AUTH_GITHUB_SECRET` |
+| Google | `AUTH_GOOGLE_ID`, `AUTH_GOOGLE_SECRET` |
+| Discord | `AUTH_DISCORD_ID`, `AUTH_DISCORD_SECRET` |
+| LinkedIn | `AUTH_LINKEDIN_ID`, `AUTH_LINKEDIN_SECRET` |
+| Facebook | `AUTH_FACEBOOK_ID`, `AUTH_FACEBOOK_SECRET` |
+| Twitter | `AUTH_TWITTER_ID`, `AUTH_TWITTER_SECRET` |
+| Twitch | `AUTH_TWITCH_ID`, `AUTH_TWITCH_SECRET` |
+| Pinterest | `AUTH_PINTEREST_ID`, `AUTH_PINTEREST_SECRET` |
+| Auth0 | `AUTH_AUTH0_ID`, `AUTH_AUTH0_SECRET`, `AUTH_AUTH0_ISSUER` |
+
+The other seventeen of the example's providers (Apple, Azure AD B2C, BoxyHQ
+SAML, Cognito, Coinbase, Dropbox, GitLab, HubSpot, Keycloak, Netlify, Okta,
+Passage, Reddit, Slack, Spotify, WorkOS, Zoom) work the same way; their keys
+are in `apps/web/src/server/providers.ts`. Set them in `apps/web/.env` locally.
+To deploy one, add its keys to `optionalSecretEnv` in
+`apps/web/component.yaml` and to the `--secret` list in that file's
+`buildCommand`, or set them on the Worker directly
+(`pnpm --filter @app/web exec wrangler secret put AUTH_GITLAB_ID --name sveltekit-auth-web-prod`):
+a Worker keeps its secrets from one deploy to the next.
+
+## Sessions and AUTH_SECRET
+
+A session is Auth.js's default: a JWT, encrypted with `AUTH_SECRET`, in an
+httpOnly `authjs.session-token` cookie (`__Secure-` prefixed over HTTPS).
+Nothing about a visitor is stored anywhere else. The upstream example has
+no database adapter, and none is added.
+
+Each environment's Worker gets its own AUTH_SECRET from its first deploy:
+the deploy lane's build step (`tooling/wire/worker-secrets.mjs`) lists the
+secrets the Worker carries, generates one only if it carries none, and
+pushes it with `wrangler secret bulk` over stdin. Every later deploy keeps
+it, so sessions survive deploys. It is never in the repository, a log or
+the build. To set your own, store an Orun secret named `AUTH_SECRET` for
+the environment (`orun secrets set AUTH_SECRET --env prod`); the next deploy
+pushes it. Changing it signs everyone out,
+since a session sealed with the old secret no longer opens.
+
+## How it deploys
+
+Merges to `main` converge through Orun: `.github/workflows/ci.yml` plans the
+changed components and runs each lane against the workspace in
+`intent.yaml`. The site deploys to `stage`, then to `prod` once stage has
+converged on the same commit; `dev` only verifies. The Worker is
+`sveltekit-auth-web-` on your account's workers.dev subdomain. Each
+deploy builds the site, gives the Worker its secrets, deploys it, and is
+smoke-tested over HTTP: the home page must render and Auth.js's
+`/auth/session` must answer `null`, which it does only once the Worker has
+its AUTH_SECRET. A pull request runs the same pipeline's verify lanes: the
+site built and dry-deployed for each environment, with nothing deployed and
+no secret pushed. They do not lint or run the tests, so run
+`pnpm typecheck`, `pnpm lint` and `pnpm test` before you push.
+
+The pipeline holds one credential, GitHub's own `GITHUB_TOKEN`. The
+Cloudflare token and account id are brokered per run from the workspace's
+Cloudflare connection; the providers' keys are the site's own secrets in
+the workspace. Nothing provider-shaped is stored in the repository or in
+GitHub.
+
+**Deploy by hand.** Orunbase's **Deploy** button on a component, or **Run
+workflow** on the CI workflow in GitHub's Actions tab (on `main`), runs
+`ci.yml` for the environment and components you pick, and each one deploys
+exactly as a merge would deploy it. Leave the component blank to redeploy
+every component in that environment, with nothing changed: after storing a
+provider's keys, say. A component with nothing to run in that environment
+(a test suite in `prod`) is left out with a notice.
+
+## Custom domain
+
+The site answers on workers.dev from its first deploy. To serve it on your
+own domain, add the domain to the Cloudflare account the site deploys into
+and attach it to the Worker (dashboard → Workers & Pages →
+`sveltekit-auth-web-prod` → Settings → Domains & Routes → Add → Custom
+domain). Do the same for stage with a subdomain if you want one.
+
+Auth.js trusts the host a request arrives on (`trustHost: true`), so
+sign-in works on the new origin with no change to the code: add the new
+origin's `/auth/callback/` to each OAuth app. The repository
+names the domain in one place, `BASE_DOMAIN` in `intent.yaml` (dev, stage
+and prod), which the site was born with as the reserved placeholder
+`sveltekit-auth.example.com`. Replace it with your domain in the same
+change that records it.
diff --git a/.baseline/tasks/01-product.TaskContract.yaml b/.baseline/tasks/01-product.TaskContract.yaml
new file mode 100644
index 0000000..a6c0b87
--- /dev/null
+++ b/.baseline/tasks/01-product.TaskContract.yaml
@@ -0,0 +1,25 @@
+# Task contract template for the 01-product landing.
+# Unbound to a key on purpose: `orun.task/ensure@v1` seals and attaches it to
+# the key the allocator issues. It lives under `.baseline/`, not `tasks/`,
+# because `tasks/` is this repository's own work tree (`intent.yaml` `work:`),
+# where an unkeyed contract is an error. gates: [] is a DECLARATION — merge
+# alone finishes this task; the main convergence is the gate the bootstrap
+# watches, not one the plane observes as a PR check.
+#
+# The whole site in one landing. `affects` names COMPONENTS, by
+# metadata.name: the phase's retouch hook reads this list to decide which
+# component.yaml files get the redeploy marker, so the deploy set and the task
+# plane's statement of the work are one list. The site is one component — its
+# test runs inside it (vitest in apps/web), so there is no separate test
+# package to redeploy.
+apiVersion: orun.io/v1
+kind: TaskContract
+spec:
+ goal: The site's repository is born and linked, the whole site lands in one pull request, and one convergence builds it with @sveltejs/adapter-cloudflare, gives each environment's Worker its AUTH_SECRET and deploys it to stage and prod, its tests green
+ affects:
+ - web
+ doneWhen:
+ - repo pushed, main pinned as default, workspace linked (orun cloud link)
+ - main convergence green (build, deploy and smoke on stage and prod)
+ - the home page answers on both workers.dev URLs, and Auth.js's /auth/session answers there
+ gates: []
diff --git a/.baseline/tasks/03-docs.TaskContract.yaml b/.baseline/tasks/03-docs.TaskContract.yaml
new file mode 100644
index 0000000..c8f2ba1
--- /dev/null
+++ b/.baseline/tasks/03-docs.TaskContract.yaml
@@ -0,0 +1,13 @@
+# Task contract template for the 03-docs landing. See 01-product's header.
+apiVersion: orun.io/v1
+kind: TaskContract
+spec:
+ goal: The live deployment is recorded from verified facts as agent-readable state in the site's repo
+ affects:
+ - ai/context/deployment.md
+ - ai/context/operations.md
+ - README.md
+ doneWhen:
+ - committed deployment manifest matches probed reality
+ - prod waits on stage again, and dev verifies every merge to main again
+ gates: []
diff --git a/.github/workflows/baseline.yml b/.github/workflows/baseline.yml
new file mode 100644
index 0000000..420017c
--- /dev/null
+++ b/.github/workflows/baseline.yml
@@ -0,0 +1,136 @@
+name: Baseline CI
+
+# THE FACTORY'S OWN LANES — this repository tested as a BASELINE: that its
+# build document parses with the orun a bootstrap actually runs, that its card
+# agrees with it, that every component is placed by exactly one phase, that a
+# placed tree comes up branded and carrying nothing of the factory, and that
+# the site it produces installs, builds, deploys (dry) and serves.
+#
+# ─── WHY THIS IS NOT IN ci.yml ────────────────────────────────────────────
+#
+# `repo-blueprint.yaml`'s `github-workflows` module copies the WHOLE `.github`
+# directory into every site built from this repository. These jobs run
+# `testing/*.sh`, and `testing/` is deliberately not placed — so in a site they
+# would be steps that cannot pass, red on its very first pull request. This
+# file is in the blueprint's `ignore` list, and `testing/coverage.test.sh`
+# fails on any workflow that reads `testing/` and is not.
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+
+concurrency:
+ group: baseline-ci-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+permissions:
+ contents: read
+
+jobs:
+ # Tier 0. bash, python3 and git; node for the tools. No workspace install,
+ # no network, no credential — the job that most certainly fails a PR.
+ baseline-contract:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 22
+ # setup-node v5 turns on the pnpm cache by itself when package.json
+ # names a packageManager, and then fails on a runner with no pnpm.
+ # This job installs nothing.
+ package-manager-cache: false
+ - name: Contract tests (manifest, phases, coverage, rebrand, retouch, bootstrap-defer)
+ run: |
+ set -euo pipefail
+ python3 -c 'import yaml' 2>/dev/null || pip install --quiet pyyaml
+ for t in manifest phases coverage rebrand retouch bootstrap-defer; do
+ echo "── $t"
+ bash "testing/$t.test.sh"
+ done
+ # Every component's docs/{overview,architecture,runbook}.md is generated
+ # from what the component declares (its manifest, Worker config,
+ # Terraform, migrations, package scripts). A pull request that changes
+ # one of those facts without regenerating the pages fails here.
+ - name: Component docs match their manifests
+ run: python3 tooling/catalog/gen-component-docs.py --check
+
+ # Tier 1. THE BLUEPRINT, READ AND PLACED BY THE BINARY A BOOTSTRAP RUNS.
+ #
+ # Pinned at the bootstrap floor (BOOTSTRAP.md), not the site's lane pin:
+ # every test here reads YAML with PyYAML, which parses anything well-formed;
+ # only the pinned orun can say whether the document is one a bootstrap can
+ # run. `--status` parses it, validates every hook against the action
+ # registry, compiles every `when` and narration template, and writes
+ # nothing. Then the leak gate (what a site would carry) and the placement
+ # tier (the offline bootstrap: every phase placed and finished by the
+ # blueprint's own hooks, then the site's own `orun plan` for the 01-product
+ # merge).
+ blueprint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+ - uses: sourceplane/orun-action@v1.2.0
+ with:
+ version: v2.88.0
+ - uses: pnpm/action-setup@v4
+ with:
+ version: 10.12.1
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 22
+ # This job installs nothing either: with no lockfile hook the offline
+ # bootstrap never runs pnpm, so there is no store, and the pnpm cache
+ # setup-node v5 turns on by itself (package.json names a packageManager)
+ # fails the job saving a path that does not exist whenever no earlier
+ # cache exists for the lockfile.
+ package-manager-cache: false
+ - name: repo-blueprint.yaml, read by the pinned CLI
+ run: |
+ set -euo pipefail
+ orun --version
+ python3 -c 'import yaml' 2>/dev/null || pip install --quiet pyyaml
+ # Required inputs must be supplied for the document to resolve; the
+ # values are arbitrary and nothing is written.
+ orun new --blueprint repo-blueprint.yaml --status \
+ --out "$(mktemp -d)" \
+ --set reponame=acme-notes \
+ --set "productname=Acme Notes" \
+ --set githuborg=acme-inc
+ - name: the leak gate — what a site carries
+ run: bash testing/leak.test.sh
+ - name: placement — the offline bootstrap, and the site's own plan
+ run: |
+ git config --global user.email ci@example.invalid
+ git config --global user.name "baseline ci"
+ bash testing/placement.test.sh
+
+ # Tier 2. THE SITE IT PRODUCES WORKS: the finished site installed, its
+ # fixtures rendered, type-checked, linted, tested and built, the stage
+ # lane's own build, output check and dry deploy, and the built Worker served
+ # and smoke-tested with the component's own smoke command. Pinned at the
+ # bootstrap floor (v2.88.0): the offline bootstrap reads the blueprint (its
+ # one `secrets` reconcile, its background task set-up, its landings checked
+ # in the box), and the floor is newer than the site's lane pin (v2.78.4),
+ # which is all the lane steps need.
+ site:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v6
+ - uses: sourceplane/orun-action@v1.2.0
+ with:
+ version: v2.88.0
+ - uses: pnpm/action-setup@v4
+ with:
+ version: 10.12.1
+ - uses: actions/setup-node@v5
+ with:
+ node-version: 22
+ cache: pnpm
+ - name: e2e — the bootstrapped site builds, deploys (dry) and serves
+ run: |
+ python3 -c 'import yaml' 2>/dev/null || pip install --quiet pyyaml
+ git config --global user.email ci@example.invalid
+ git config --global user.name "baseline ci"
+ bash testing/e2e.test.sh
diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml
new file mode 100644
index 0000000..c0383e3
--- /dev/null
+++ b/.github/workflows/tag.yml
@@ -0,0 +1,97 @@
+name: Baseline tag
+
+# CUTS A `baseline-vN` TAG FOR THIS REPOSITORY.
+#
+# A baseline tag is what the platform's registry resolves and what every
+# product bootstrapped from this repository is built out of, so it is cut by a
+# workflow rather than by hand: the version must look like a baseline tag, an
+# existing tag is never moved, and the commit is resolved here, once.
+#
+# Whether a commit is fit to release is decided outside this repository, by
+# whoever cuts the tag; nothing here asks for proof beyond a green `main`.
+
+on:
+ workflow_dispatch:
+ inputs:
+ version:
+ description: "The tag to cut, e.g. baseline-v2."
+ required: true
+ type: string
+ ref:
+ description: "Branch, tag or sha to cut it from. Defaults to main."
+ required: false
+ default: main
+ type: string
+
+concurrency:
+ group: baseline-tag
+ cancel-in-progress: false
+
+permissions:
+ contents: read
+
+jobs:
+ cut:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/checkout@v6
+ with:
+ # Full history: the ref being cut from may be any commit, and a
+ # shallow clone cannot resolve one it did not fetch.
+ fetch-depth: 0
+ ref: ${{ inputs.ref }}
+
+ - name: the version must look like a baseline tag
+ run: |
+ set -euo pipefail
+ # Refused here rather than by the API, because the API's error for a
+ # malformed ref says nothing about the convention it broke.
+ case "${{ inputs.version }}" in
+ baseline-v[0-9]*) ;;
+ *) echo "✕ '${{ inputs.version }}' is not a baseline-vN tag" >&2; exit 1 ;;
+ esac
+
+ - name: resolve the commit
+ id: commit
+ run: |
+ set -euo pipefail
+ sha="$(git rev-parse HEAD)"
+ echo "sha=$sha" >> "$GITHUB_OUTPUT"
+ echo "Cutting ${{ inputs.version }} from ${{ inputs.ref }} = $sha"
+
+ - name: the tag must not already exist
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ code="$(curl -sS -o /dev/null -w '%{http_code}' \
+ -H "Authorization: Bearer $GH_TOKEN" \
+ -H "Accept: application/vnd.github+json" \
+ "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/git/ref/tags/${{ inputs.version }}")"
+ if [ "$code" = "200" ]; then
+ echo "✕ ${{ inputs.version }} already exists. A baseline tag is never moved:" >&2
+ echo " products resolve it, and repointing one changes what a build that" >&2
+ echo " already shipped was made of. Cut the next number." >&2
+ exit 1
+ fi
+ # Anything other than 200 or 404 means the question was not answered,
+ # and "it probably does not exist" is not a thing to guess about a
+ # tag that is about to be created.
+ [ "$code" = "404" ] || { echo "✕ could not check for the tag (HTTP $code)" >&2; exit 1; }
+
+ - name: cut the tag
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ run: |
+ set -euo pipefail
+ curl -sS -X POST --fail-with-body \
+ -H "Authorization: Bearer $GH_TOKEN" \
+ -H "Accept: application/vnd.github+json" \
+ "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/git/refs" \
+ -d "$(printf '{"ref":"refs/tags/%s","sha":"%s"}' \
+ "${{ inputs.version }}" "${{ steps.commit.outputs.sha }}")"
+ echo ""
+ echo "✓ ${{ inputs.version }} → ${{ steps.commit.outputs.sha }}"
+ echo " Next: move the registry row in orun-cloud's infra/baselines-registry/baselines.yaml."
diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md
new file mode 100644
index 0000000..129801e
--- /dev/null
+++ b/BOOTSTRAP.md
@@ -0,0 +1,227 @@
+# BOOTSTRAP — a new site from this baseline, in phases
+
+How to go from **nothing** to a **SvelteKit site with Auth.js sign-in, live
+on stage and prod, documented**, with ONE provider consent and nothing typed.
+
+There is one artifact: **`repo-blueprint.yaml`**. It declares what to place,
+in what order, what each phase needs first, and what to say while it runs.
+`orun new` is the whole runtime — the phases below are its `--phase` names,
+not separate workflows. The console card the platform renders is
+**`blueprint.yaml`**; it names the build document and states the inputs, the
+brokered secrets and the programme, and `testing/manifest.test.sh` holds it
+to what the build document does.
+
+Target wall-clock: **about five minutes** — an estimate summed from the
+phases (4 + 1) until a bootstrap measures it. The shape is
+sveltekit-boilerplate's: 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 SvelteKit build per environment (seconds, not
+minutes — the long poles are the installs, the runners and a first deploy's
+workers.dev route), stage and prod deployed side by side, then a short docs
+landing, checked the same way, that restores the promotion gate. This site
+adds one step to each deploy lane — `wrangler secret list`, then one
+`wrangler secret bulk` that gives the Worker its generated AUTH_SECRET (and
+creates it, on the first deploy) — and a minute is budgeted for it.
+sveltekit-boilerplate's estimate of the same shape (3 + 1) is unmeasured
+too: the sibling site baselines measured 7m07s–8m43s from the console's
+Build over three landings, and `01-product` dropped one landing and the
+Checks waits (cirrus-baseline baseline-v22's shape).
+
+## 0. What you need
+
+- GitHub org access (repository creation) and a machine with `git`, `node`
+ (≥ 22), `pnpm` (10.12.1), `python3` with PyYAML, `curl`, and the `orun`
+ CLI **≥ v2.88.0** — the floor for RUNNING the bootstrap (the phase overlay,
+ landings that commit per phase, `githubOwner` on the doctor probe, a probe
+ deferred for a project not yet created, `from: workspace`, the deploy
+ credentials minted in one `secrets` reconcile, the task set-up run in the
+ background (`background: true`), and landings checked in the box before
+ they merge (`checks: local`)). The site's own `ci.yml` pins its lanes
+ separately (v2.78.4).
+- A Cloudflare account (the free plan is enough for one Worker with static
+ assets) and its **Account API token** with Workers Scripts Write (the
+ console's Connect recipe lists the exact permission groups). It is the ONLY
+ provider credential this baseline needs.
+- An Orun Cloud workspace for the site — `orunWorkspace`, or the workspace
+ the build runs in (ORUN_WORKSPACE) when that is unset — with an
+ **admin-role API key** for headless runs (secret writes below admin are
+ masked as `not_found`).
+- **The repository allow-listed in the workspace** (console → Settings → Git
+ repos), unless the credential can write links. `01-product`'s `link` step
+ stops and names the fix if it is not.
+
+## 1. One command: `--resume`
+
+The whole bootstrap, unattended. `--resume` places every phase not already
+derived as done, in order, honouring each phase's barrier:
+
+```bash
+git clone --depth 1 --branch https://github.com/sourceplane/sveltekit-auth
+cd sveltekit-auth
+
+orun new --blueprint repo-blueprint.yaml \
+ --out ~/sites/acme-notes --run-hooks --resume \
+ --set reponame=acme-notes --set productname="Acme Notes" \
+ --set githuborg=acme-inc \
+ --set orunWorkspace=ws_XXXXXXXX \
+ --set subdomain=
+```
+
+`subdomain` is the workers.dev subdomain of the Cloudflare account you deploy
+into (Workers & Pages → your subdomain). A build started from the console, or
+with `orun baseline new --from bst_…`, never asks for it: the platform reads
+it from the workspace's Cloudflare connection, the same one the deploy token
+is minted from. Only a hand-run build like this one passes it.
+
+**`--run-hooks` is the difference between placing files and bootstrapping a
+site.** Without it `orun new` writes the tree and stops: no repository, no
+landing, no convergence watch, no probe. That is deliberate — it is what
+makes the offline bootstrap in `testing/` possible with no workspace and no
+provider.
+
+`--resume` is safe to re-run from anywhere, a fresh container with a fresh
+`--out` included: **phase state is derived from the tree, never stored.** A
+phase whose files are present but branded derives as `drifted`, and
+`--resume` leaves it placed rather than reverting the site's identity.
+
+## 1b. Or phase by phase
+
+| phase | what it lands | verified by |
+|---|---|---|
+| `01-product` | the repository, created and linked; the brokered Cloudflare secrets; then the whole site in one PR — intent, CI, tooling, identity, `apps/web` (the site and its tests) | its commit validated and planned in the box (as the PR and as the merge), then merged; the convergence green (build, deploy, smoke) and both workers.dev URLs answering |
+| `03-docs` | `ai/context/deployment.md` from probed facts; prod's promotion gate and dev's push lanes restored | the render's own probes, recorded; the commit checked in the box and merged |
+
+```bash
+orun new --blueprint repo-blueprint.yaml --out ~/sites/acme-notes --run-hooks \
+ --phase 01-product --values ~/acme-notes.values.yaml
+# … then 03-docs
+```
+
+Every later phase reads the identity back from `.rebrand/values.json` in the
+placed tree, but the blueprint's **required** inputs — `reponame`,
+`productname`, `githuborg` — are validated before anything runs, so pass them
+every time (a `--values` file is easier). The domain is not one of them: the
+site goes live on workers.dev, and `productdomain` defaults to empty, which
+brands the reserved placeholder `.example.com` into `BASE_DOMAIN`
+for an owner to replace when they attach a domain (README, "Custom domain").
+Pass `--set productdomain=` only for a site that already has its domain.
+The full guide, one page per phase: [docs/phases/README.md](docs/phases/README.md).
+
+| flag | what it does |
+|---|---|
+| `--status` | derives and prints every phase's state and writes nothing. It parses the document, validates each hook against the action registry and compiles every template; it needs no credential and no network |
+| `--phase ` | places exactly that phase; its `requires.phases` still gates |
+| `--until ` | places every phase through that one and stops |
+
+What lands in the site is PRODUCT-ONLY: the app (its tests inside it), its
+CI, its tooling, its README and its two context pages. None of this
+repository's machinery (`.baseline/`, the blueprints, `tooling/rebrand`,
+`tooling/bootstrap`, `hooks/`, `testing/`, `docs/phases/`, `specs/`,
+`tasks/`, this file) ships, nor does `tooling/migrations` (the D1 manifest
+check for a database the site does not have). That promise is a test:
+`testing/leak.test.sh` derives what every phase would place and gates the
+set, and `testing/placement.test.sh` gates the same rules over a placed,
+branded tree.
+
+## 2. Headless / container mode
+
+The blueprint's source is this repository (`sources: [{kind: dir, path: .}]`),
+so the container contract is a shallow clone at a pinned tag plus two
+tokens:
+
+```bash
+export ORUN_TOKEN=… # orun auth, headless
+export GITHUB_TOKEN=… # fine-grained PAT (below)
+
+git clone --depth 1 --branch https://github.com/sourceplane/sveltekit-auth
+cd sveltekit-auth
+orun new --blueprint repo-blueprint.yaml \
+ --out /work/acme-notes --run-hooks --resume --progress json \
+ --values /work/acme-notes.values.yaml
+```
+
+| requirement | detail |
+|---|---|
+| `GITHUB_TOKEN` | fine-grained PAT: **read** on this repository; on the SITE's repository **contents write**, **pull-requests write**, **actions read+write** (`orun.run/watch@v1` resumes runs with `gh run rerun`), **checks read**; **repository create** on the owner if `01-product` creates it (or pre-create it — supported) |
+| classic token caveat | a classic PAT or gh OAuth token also needs the `workflow` scope to push `.github/workflows/` |
+| pinning | the clone's `--branch ` pins everything: the blueprint, its modules and its hooks' scripts all come from that one commit |
+
+## 3. After the site is live
+
+- **Write**: the pages are `apps/web/src/routes/`; the site's name is
+ `apps/web/src/site.ts`. Every merge to `main` redeploys.
+- **Connect a sign-in provider**: the site deploys with none, and `/signin`
+ says so. Create an OAuth app (GitHub: callback
+ `https://-web-..workers.dev/auth/callback/github`),
+ store its two keys as the site's secrets for that environment
+ (`orun secrets set AUTH_GITHUB_ID --env `, then `AUTH_GITHUB_SECRET`,
+ or the console's Secrets page), and redeploy (a merge, or `ci.yml`'s Run workflow):
+ the deploy pushes them to the Worker and the button appears. The site's
+ README, "Sign-in providers", lists every provider's keys.
+- **AUTH_SECRET** is generated on each environment's Worker by its first
+ deploy and kept by every later one; nobody types or sees it. Storing an
+ Orun secret named `AUTH_SECRET` replaces it on the next deploy, which
+ signs every visitor out (sessions sealed with the old one no longer
+ open).
+- **Custom domain**: attach it to the Worker in Cloudflare, and replace the
+ placeholder `.example.com` in `intent.yaml`'s `BASE_DOMAIN` with
+ it (the site's README, "Custom domain"); nothing else changes, because the
+ site builds no absolute links. There is no domain phase: attaching a domain
+ needs zone permissions the brokered `workers-deploy` token does not carry.
+- **Refresh the record**: re-run `--phase 03-docs`; it is idempotent.
+
+## 4. Testing this baseline
+
+`.github/workflows/baseline.yml` runs three tiers on every pull request, and
+each runs locally the same way:
+
+```bash
+for t in manifest phases coverage rebrand retouch bootstrap-defer; do bash testing/$t.test.sh; done
+bash testing/leak.test.sh # needs orun
+bash testing/placement.test.sh # needs orun, node, pnpm: the offline bootstrap
+bash testing/e2e.test.sh # + network for pnpm: the site built, dry-deployed and served
+```
+
+The offline bootstrap (`testing/lib/bootstrap.sh`) places every phase in
+order and finishes each with the blueprint's OWN `run:` hooks — read out of
+`repo-blueprint.yaml`, not transcribed — so the rebrand, the re-tenant, the
+deferrals and their restore, the retouch marker and the deployment record
+all run exactly as a real bootstrap runs them. Only the
+platform's typed actions (task, repo, link, land, watch, probe, reconcile)
+are stood in for, a landing becoming a commit.
+
+## 5. Cutting a baseline tag (maintainers)
+
+Every site built from this repository resolves a `baseline-vN` tag, so the
+tag is cut by a workflow rather than by hand:
+
+```bash
+gh workflow run tag.yml -f version=baseline-v1 # from main
+gh workflow run tag.yml -f version=baseline-v1 -f ref=
+```
+
+It refuses a version that is not `baseline-v` and a tag that already
+exists: a baseline tag is never moved. Then move the registry row in
+orun-cloud's `infra/baselines-registry/baselines.yaml` by pull request —
+after the tag exists, because the registry's sync fetches `blueprint.yaml`
+at the tag and refuses the whole catalogue if it 404s.
+
+## Troubleshooting
+
+| Symptom | Cause → fix |
+|---|---|
+| `01-product` parks: `waiting for github for ` | the workspace's GitHub connection is to another account. Connect the App installation on `` (console → Integrations → GitHub), then `--resume` |
+| `01-product` stops at `link` | the repository is not linked to the workspace and the credential cannot link it. Allow-list it (console → Settings → Git repos) and re-run the phase |
+| `01-product` waits on the `providers` probe, then stops | Cloudflare is not connected. Connect it (console → Integrations), then re-run the phase — the probe is a wait, not a failure |
+| Secret WRITE fails `not_found` while listings work | the API key's role is below admin; re-mint it with the admin role |
+| Deploy lane: Authentication error (10000) | the connection's token lacks Workers Scripts Write; re-issue it, re-connect, re-run `01-product` |
+| `land` stops: `the landing's own check failed — orun plan for …` | the site's tree does not plan — the line after it is orun's own error (an unknown component type, a composition that does not resolve). Nothing was pushed. Fix the tree (or the baseline) and re-run the phase |
+| `land` waits on CI after all | the site's repository requires a status check on `main` (branch protection or a ruleset), so GitHub refused the early merge; the landing waits for the check as a `checks: ci` landing would, then merges |
+| Convergence failed AFTER the PR merged; re-running lands nothing | expected on its own — the files are on main. Re-run the phase (`--phase 01-product`, `--redo 01-product`, or the console's Retry): its `retouch` hook gives the landing a diff and the site redeploys |
+| The site's `intent.yaml` says `workspace: ws_SET_ME` | `orunWorkspace` was empty and the build ran outside a workspace; set it and re-run `01-product` |
+| A bootstrap stopped before `03-docs`; prod no longer waits on stage | the gate is deferred, not dropped: run `03-docs`, or `node tooling/bootstrap/promotion.mjs --restore --file /intent.yaml` |
+| `✕ input "productname" is required` | all three required inputs (`reponame`, `productname`, `githuborg`) must be set on every invocation, single-phase ones included |
+| `unknown flag: --phase`, `has no parameter "checks"`, `has no parameter "secrets"` or another parse error in the blueprint | the CLI is below the v2.88.0 floor |
+| `01-product` lanes fail in `build-app` resolving a dependency | the site's intent no longer pins stack-tectonic 0.19.0. 0.20.0's lane-scoped install links each job's node_modules out of its staged tree; this site's Vite build was tried there and builds, but a Next.js sibling's did not, and the pin keeps the install the e2e tier proves. `intent.yaml` says why |
+| A deploy lane's smoke fails on `/auth/session` (500, `MissingSecret` in the Worker's log) | the Worker has no AUTH_SECRET because its `build-app` step did not push one; resume the convergence. If `build-app` says `refusing to mint a replacement`, `wrangler secret list` failed for another reason than a missing Worker (the token, the API): nothing was pushed, and no session was lost |
+| `01-product`'s convergence reported green, then `verify` got 404 from both URLs | a second workflow ran on the push to main and the watch took its run. Only `ci.yml` may run on a push to main, and a site carries no other workflow (`testing/coverage.test.sh` holds the rule); read the CI run on main for the real result |
diff --git a/README.md b/README.md
index d7736f7..82e86a0 100644
--- a/README.md
+++ b/README.md
@@ -5,8 +5,8 @@ Auth.js's [SvelteKit example](https://github.com/nextauthjs/sveltekit-auth-examp
sign-out, over [`@auth/sveltekit`](https://authjs.dev/reference/sveltekit)
with the example's 26 OAuth providers — running on **Cloudflare Workers +
Static Assets** through SvelteKit's own
-[`@sveltejs/adapter-cloudflare`](https://svelte.dev/docs/kit/adapter-cloudflare).
-It is being packaged as an **Orun baseline** that takes a new site from
+[`@sveltejs/adapter-cloudflare`](https://svelte.dev/docs/kit/adapter-cloudflare),
+and packaged as an **Orun baseline**: one command takes a new site from
nothing to live on stage and prod, in its own repository, under its own
name, in ONE landing.
@@ -14,12 +14,52 @@ Sessions are the example's: Auth.js's encrypted JWT cookie, so there is no
database. Each provider is offered once its keys are stored as the site's
secrets, so the site goes live with none connected and its sign-in page
says what to connect; the AUTH_SECRET that seals the sessions is generated
-on each environment's Worker by its first deploy, so nothing is typed. The
-design, the milestones and the as-built status are in
+on each environment's Worker by its first deploy, so nothing is typed. What
+the baseline adds is everything needed to make a copy of it somebody
+else's, built the way [cirrus-baseline](https://github.com/sourceplane/cirrus-baseline)
+is. The design, the milestones and the as-built status are in
[`specs/epics/sveltekit-auth`](specs/epics/sveltekit-auth/README.md).
ISC, © 2022-2024 Balázs Orbán (`apps/web/LICENSE`).
-## What is here
+## Instantiating a site
+
+```bash
+git clone --depth 1 --branch https://github.com/sourceplane/sveltekit-auth
+cd sveltekit-auth
+orun new --blueprint repo-blueprint.yaml --out ~/sites/acme-accounts --run-hooks --resume \
+ --set reponame=acme-accounts --set productname="Acme Accounts" \
+ --set githuborg=acme-inc --set subdomain=
+```
+
+Or, once the platform's registry lists it, from the Orun console (Baselines →
+`sveltekit-auth` → Build). Two phases: **`01-product`** creates the
+repository and lands the whole site as ONE pull request — intent, CI,
+tooling, the site and its tests — and one convergence builds it, gives each
+environment's Worker its AUTH_SECRET and deploys it to stage and prod;
+**`03-docs`** records the live deployment from probed facts.
+**[BOOTSTRAP.md](BOOTSTRAP.md)** is the operator guide;
+[docs/phases/](docs/phases/README.md) has a page per phase.
+
+The new repository receives the **site only** — the app and its tests, its
+CI, its tooling, a README of its own and its operating contract — renamed
+throughout to the site's name, repository and Cloudflare Worker, with
+Auth.js's own names (`SvelteKitAuth`, `sveltekit-auth-example`) and the
+example's licence left as they are. None of this repository's machinery
+ships.
+
+| What makes it a baseline | Where |
+|---|---|
+| The console card (inputs, secrets, programme) | `blueprint.yaml` |
+| The build document (modules, phases, hooks) | `repo-blueprint.yaml` |
+| This tree's identity, and the bootstrap's task contracts | `.baseline/` |
+| The rename engine | `tooling/rebrand/rebrand.mjs` |
+| The bootstrap's helpers (deferrals, redeploy marker, work-tree strip) | `tooling/bootstrap/` |
+| The deployment-record renderer | `hooks/render-deployment-docs.sh` |
+| The site's README and context pack | `.baseline/product/README.md`, `ai/context/` |
+| The baseline's tests: contract, leak, offline bootstrap, end to end | `testing/`, `.github/workflows/baseline.yml` |
+| Cutting a `baseline-vN` tag | `.github/workflows/tag.yml` |
+
+## What is here (the site)
| Surface | Where |
|---|---|
@@ -76,7 +116,7 @@ optional Orun secrets per environment (`orun secrets set AUTH_GITHUB_ID
--env stage`), pushed to the Worker by its next deploy; the OAuth app's
callback URL is `/auth/callback/`. The component carries
secret refs for the nine providers upstream's `.env.example` names; the
-keys of every other provider are in `apps/web/src/server/providers.ts`.
+site's README ("Sign-in providers") says how to deploy the others.
## How it maps to Vercel
@@ -89,9 +129,12 @@ keys of every other provider are in `apps/web/src/server/providers.ts`.
| `$env/dynamic/private` from the platform's env | the Worker's bindings (`platform.env`), read per request; `.env` locally, as upstream, for `vite dev` and `wrangler dev` alike |
| sessions: Auth.js's JWT cookie | the same; no database |
| Deploy on push | Orun deploys `-web-{stage,prod}` on merge to `main` (`apps/web/component.yaml`), smoke-tested |
+| "Deploy with Vercel" (clone the example) | `orun new --blueprint repo-blueprint.yaml` — a new repository, branded, deployed |
## CI
| Workflow | What it runs | Ships to a site |
|---|---|---|
| `ci.yml` | the Orun pipeline, and the only workflow a site carries: `orun plan --changed`, then one job per lane. A pull request runs the verify lanes (the site built and dry-deployed per environment, no secret pushed; they do not typecheck, lint or run the tests), except the bootstrap's own landings (`orun/BASE-*`), where `plan` alone is the check; a merge deploys stage → prod. It plans nothing while `intent.yaml` names the placeholder workspace `ws_CHANGE_ME`, as this repository does. A manual run (Orunbase's Deploy button, or Run workflow on `main`) plans the environment and components it names under the push-to-main trigger, so they deploy as a merge deploys them | yes |
+| `baseline.yml` | the baseline's own tiers: contract tests, the blueprint read by the pinned orun, the leak gate, the offline bootstrap with the site's own plan, the site installed, type-checked, linted, tested, built and dry-deployed in the lane's tree and served — with no secret (the smoke refuses it), with one (every page), and with GitHub's keys (the authorize URL, a session, sign-out) (`testing/e2e.test.sh`, before every tag) | no |
+| `tag.yml` | cuts a `baseline-vN` tag (manual) | no |
diff --git a/ai/context/current.md b/ai/context/current.md
new file mode 100644
index 0000000..c957ae3
--- /dev/null
+++ b/ai/context/current.md
@@ -0,0 +1,43 @@
+# sveltekit-auth — where this repository stands
+
+The entry page for anyone (or any agent) picking this repository up. It is
+this repository's own state and does not ship to a site built from it; the
+two pages that do are [operations.md](operations.md) and
+[deployment.md](deployment.md).
+
+## What it is
+
+Auth.js's SvelteKit example (nextauthjs/sveltekit-auth-example, ISC) — a
+home page, a sign-in page, a protected page and a sign-out over
+`@auth/sveltekit`, with the example's 26 OAuth providers, each offered once
+its keys are stored — on SvelteKit 2 and Svelte 5, deployed as one
+Cloudflare Worker + Static Assets through SvelteKit's own Cloudflare
+adapter. Sessions are Auth.js's encrypted JWT cookies; there is no database.
+The AUTH_SECRET is generated on each environment's Worker by its first
+deploy. Packaged as an Orun baseline: `orun new --blueprint
+repo-blueprint.yaml` builds a new site in its own repository and takes it to
+live on stage and prod in one landing (`01-product`), then records what went
+live (`03-docs`).
+
+## Release
+
+| | |
+|---|---|
+| Latest tag | `baseline-v1` (SU0, SU1, SU3, SU4: the auth app on Workers, its secret generated by the deploy, providers optional, the one-landing baseline) |
+| Proven live | No. Everything short of the platform is proven offline in Baseline CI: the stage lane's build and dry deploy in the lane's own tree, then the built Worker under `wrangler dev` with no secret (the smoke refuses it), with one (every page), and with GitHub's keys (the authorize URL, a session sealed with the Worker's secret, sign-out). A live bootstrap from a tag is still to come (risk SU-A). The card's 5 minutes is an estimate |
+
+## Where to read
+
+| Question | Page |
+|---|---|
+| What shipped, and every departure from upstream | `specs/epics/sveltekit-auth/IMPLEMENTATION-STATUS.md` |
+| Why it is built this way | [decisions.md](decisions.md), then `specs/epics/sveltekit-auth/design.md` |
+| What could still go wrong | [open-risks.md](open-risks.md), then `specs/epics/sveltekit-auth/risks-and-open-questions.md` |
+| How to instantiate it | `BOOTSTRAP.md`, `docs/phases/` |
+| What the component is | `apps/web/docs/` (generated; `python3 tooling/catalog/gen-component-docs.py`) |
+
+## Next
+
+1. Bootstrap one site from `baseline-v1` against a workspace, connect a
+ GitHub OAuth app, sign in on stage, and record the timings in place of
+ the estimate (closes SU-A).
diff --git a/ai/context/decisions.md b/ai/context/decisions.md
new file mode 100644
index 0000000..0c4b8b5
--- /dev/null
+++ b/ai/context/decisions.md
@@ -0,0 +1,20 @@
+# sveltekit-auth — decisions
+
+The choices that shape this repository, one line each, with where the full
+reasoning lives. Superseded decisions stay listed, marked, so the history
+reads in order.
+
+| # | Decision | Why | Source |
+|---|---|---|---|
+| 1 | The app is nextauthjs/sveltekit-auth-example, kept close: its pages, header, footer, actions, `trustHost: true` and its 26 providers with their options | The example is what Auth.js maintains; the closer it stays, the cheaper an upgrade | design.md, "How it maps" |
+| 2 | `@sveltejs/adapter-cloudflare` (one Worker + Static Assets), `nodejs_compat` | SvelteKit's own adapter, as sveltekit-boilerplate; no OpenNext | risk SU-G |
+| 3 | `@auth/sveltekit` 1.11.3, SvelteKit 2.60.1, Svelte 5.55.7, Vite 6.4.2, exact; `cookie@0 → 0.7.0` carried from upstream's overrides | An unpinned `latest` would change the site under it; Auth.js peers SvelteKit `^2` | risk SU-C |
+| 4 | No database: sessions are Auth.js's JWT cookies, so no D1, no db-migrate, no data rung (SU2) | The example has no adapter and persists nothing server-side | design.md, "Out of scope" |
+| 5 | Each provider is registered only when every key it takes is set; with none, `/signin` says what to connect | A fresh site goes live with no provider; a button that fails is worse than none | IMPLEMENTATION-STATUS 3, 5 |
+| 6 | The configuration is built per request from the Worker's bindings first, then SvelteKit's dynamic env | A provider's keys take effect with the deploy that pushes them; `wrangler dev` and `vite dev` read the same local `.env` | IMPLEMENTATION-STATUS 4 |
+| 7 | AUTH_SECRET is generated once per environment on the Worker by the deploy lane (`tooling/wire/worker-secrets.mjs`: list, mint only if absent, push with `secret bulk` over stdin); a stored Orun secret wins; a failed list stops the deploy | Nothing is typed or committed, stage and prod differ, sessions survive deploys, and a live secret is never replaced by accident | design.md, "The secret flow"; risk SU-B |
+| 8 | The provider keys are optional Orun secrets, kept out of the build (`env -u`) and pushed to the Worker as Worker secrets — for the nine providers upstream's `.env.example` names | They are read at request time; no bundle, build cache or log holds them; nine refs keep the component readable | risk SU-E |
+| 9 | The smoke requires `