From 31686a87910776612e948a03a6ae10832ff1efb6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 28 Oct 2026 21:30:01 +0000 Subject: [PATCH] docs: the lumen-payload-console record (PX5) The repository now describes the product as it runs after PX1-PX4: the Payload admin is the console, signed in with a Lumen account and holding the account, organization, notifications, security-activity and billing pages; the old console URL is a redirect Worker into it. - AGENTS.md, README.md and ai/context/operations.md name the CMS as the console and web-console-next as the redirect; the operations guide's secrets model lists CLOUDFLARE_API_TOKEN and CLOUDFLARE_HYPERDRIVE_TOKEN as rotated (30 days) at the project rung, and where each environment's first admin stands - the epic's IMPLEMENTATION-STATUS: PX0-PX5 shipped with their PRs, the live verification on stage (PX1 35/35, PX2 26/26, PX3 11/11, PX4's redirects) and prod, the rotated-token and Orun Cloud departures, and the sandbox-browser note on the admin's route chunk - the epic README: shipped Orun-Task: PX-6 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013JuHbkZCjDrGgHdzCrCRqG --- AGENTS.md | 20 ++++-- README.md | 8 ++- ai/context/operations.md | 39 ++++++++--- .../IMPLEMENTATION-STATUS.md | 65 +++++++++++++++++-- specs/epics/lumen-payload-console/README.md | 4 +- tasks/PX-6.TaskContract.yaml | 20 ++++++ 6 files changed, 128 insertions(+), 28 deletions(-) create mode 100644 tasks/PX-6.TaskContract.yaml diff --git a/AGENTS.md b/AGENTS.md index 9bd1476..3eec4e0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,19 +18,25 @@ is what deploys it. 4. `apps/api-edge/docs/` — the one public entry point and how it routes to the workers. Every app has the same three pages: overview, architecture, runbook. -5. `apps/web-console-next/docs/` — the console. -6. `apps/cms/docs/` — the CMS: how it deploys, how the owner opens its - admin, and how to change a collection (a migration, never a push). +5. `apps/cms/docs/` — the CMS, which is the console: the Payload admin + with Lumen sign-in and the account and billing pages, how it deploys, + how the owner opens its admin, and how to change a collection (a + migration, never a push). +6. `apps/web-console-next/docs/` — the old console URL, now a redirect + Worker into the CMS. ## Layout - `apps/api-edge` is public; the twelve `apps/*-worker` are reached only through it, over service bindings. -- `apps/web-console-next` — Next.js on Workers + Static Assets. -- `apps/cms` — Payload CMS on Workers (OpenNext), public on its own - hostname, beside the fleet: no worker calls it and the edge does not - route to it. Its schema is `cms`, changed only by migrations in +- `apps/cms` — the product: Payload CMS on Workers (OpenNext), public on + its own hostname. Its admin is the console: a Lumen account signs in + (no Payload passwords), and the account, organization, notifications, + security activity and billing pages call `api-edge` server to server + over the `LUMEN_API` service binding. No worker calls the CMS. Its schema is `cms`, changed only by migrations in `packages/db`. +- `apps/web-console-next` — a small redirect Worker: every old console + path answers 308 to its place in the same environment's CMS. - `packages/*` — contracts, SDK, CLI, database harness, policy engine. - `infra/terraform/*` — Supabase, Hyperdrive, KV, and the CMS's own Hyperdrive (`cloudflare-hyperdrive-cms`); `infra/db-migrate` — the schema diff --git a/README.md b/README.md index 2ea2b9b..7d0f749 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,9 @@ and Supabase Postgres, run as an [Orun](https://github.com/sourceplane/orun) component-native desired-state repo. Identity, organizations, projects, RBAC, audit, metering, billing, webhooks and notifications are separate -bounded-context Workers behind one public edge API, with a Next.js console on -Workers + Static Assets. +bounded-context Workers behind one public edge API. The product opens in its +Payload CMS admin, which is the console: a Lumen account signs in, and the +account, organization, notifications and billing pages live inside it. ## Live deployment @@ -29,7 +30,8 @@ what not to touch. |---|---| | `apps/api-edge` | The one public HTTP entry point; reaches the workers over service bindings | | `apps/*-worker` | Twelve bounded-context Workers — identity, membership, projects, policy, events, config, metering, billing, notifications, webhooks, integrations, admin. Never public | -| `apps/web-console-next` | The console: Next.js on Workers + Static Assets, configured against the edge | +| `apps/cms` | The product and its console: Payload CMS on Workers (OpenNext), signed in with a Lumen account; content, media on R2, and the account and billing pages, calling the edge server to server | +| `apps/web-console-next` | The old console URL, now a redirect Worker: every path answers 308 to its place in the CMS | | `packages/*` | Shared libraries: contracts, SDK, CLI, the database harness, the policy engine, the notifications client, the webhook verifier | | `infra/terraform/*` | The data plane: Supabase projects, Hyperdrive, the edge's idempotency KV, and the custom-domain component (parked until a domain is set) | | `infra/db-migrate` | Database migrations — planned on pull requests, applied on merge | diff --git a/ai/context/operations.md b/ai/context/operations.md index aa93b09..90460b1 100644 --- a/ai/context/operations.md +++ b/ai/context/operations.md @@ -20,11 +20,14 @@ component-native desired-state repo: - **`apps/*-worker`** — bounded-context Workers (identity, membership, projects, policy, config, events, webhooks, metering, billing, notifications, …). Never public; reached only through the edge. -- **`apps/web-console-next`** — the console UI, Next.js on Workers + - Static Assets, configured against the edge. -- **`apps/cms`** — Payload CMS on Workers (OpenNext), its own public - Worker beside the fleet: `/admin` for staff, `/api/*` for content. See +- **`apps/cms`** — the product and its console: Payload CMS on Workers + (OpenNext), its own public Worker. `/admin` for staff, signed in with a + Lumen account, holding the account, organization, notifications, + security-activity and billing pages; `/api/*` for content. See [The CMS](#the-cms-appscms). +- **`apps/web-console-next`** — the old console URL, now a redirect + Worker: every path answers 308 to its place in the same environment's + CMS (`/auth/callback` to `/auth/lumen/callback`). - **`infra/terraform/*`** — data plane: Supabase projects (stage/prod), Cloudflare Hyperdrive, idempotency KV, and the CMS's own cache-disabled Hyperdrive (`cloudflare-hyperdrive-cms`). **`infra/db-migrate`** — @@ -78,11 +81,19 @@ Caveats that matter: ## Secrets model -- **Brokered provider secrets** (project rung): `CLOUDFLARE_API_TOKEN`, - `CLOUDFLARE_HYPERDRIVE_TOKEN`, `CLOUDFLARE_ACCOUNT_ID`, - `SUPABASE_ACCESS_TOKEN`, `SUPABASE_ORG_ID` — pointers minted per-run - from the workspace's integration connections. No long-lived values at - rest; nothing to rotate by hand. +- **Rotated Cloudflare tokens** (project rung): `CLOUDFLARE_API_TOKEN` + (`workers-deploy`) and `CLOUDFLARE_HYPERDRIVE_TOKEN` (`hyperdrive-edit`), + plus `CLOUDFLARE_R2_TOKEN` (`r2-data`, the CMS media bucket). Each is + minted once from the workspace's Cloudflare connection and re-minted by + the platform every 30 days, so a CI run no longer mints a fresh token per + job (`orun secrets list --env stage --chain` shows them SERVES FROM + project). The first two shadow the workspace's brokered bindings of the + same name. +- **Brokered provider secrets** (workspace rung): `CLOUDFLARE_ACCOUNT_ID` + and `SUPABASE_ORG_ID` (connection facts, which mint nothing and do not + count toward the daily credential-mint limit) and `SUPABASE_ACCESS_TOKEN` + (minted per run; Supabase supports only brokered mode). Nothing to rotate + by hand. - **Job-output secrets** (environment rungs): `WIRING_*`, `SUPABASE_PROJECT_REF`, `SUPABASE_DB_URL`, `SUPABASE_DB_PASSWORD`, `CMS_PAYLOAD_SECRET` — published by the infrastructure terraform; deploy @@ -148,7 +159,9 @@ that re-verifies. Payload CMS 3.89 on Workers (OpenNext), deployed as `lumen-payload-cms-` on stage and prod, beside the fleet rather than inside it: nothing routes to -it through `api-edge`, and no worker calls it. +it through `api-edge`, and no worker calls it. It is the product: `intent.yaml`'s +product URLs point at it, `/` redirects to `/admin`, and the old console URL +(`lumen-payload-web-console-next-`) answers 308 into it. - **Database path:** its own Hyperdrive config, `stg-lumen-payload-cms-stage` and `prod-lumen-payload-cms-prod` (`infra/terraform/cloudflare-hyperdrive-cms`), over the same Supabase origin @@ -194,6 +207,10 @@ The visit sets a 15-minute cookie and opens the Lumen sign-in. While no admin exists, whoever signs in with that cookie becomes the admin; afterwards admins make everyone else an `editor` or `admin`, and the token can be deleted. +**Where each environment stands (2026-10-28):** stage's first admin is open +(the setup token was used once and revoked, and the owner's own account is +invited as admin); prod waits for the owner to open it. + ### Verify it ```bash @@ -203,6 +220,8 @@ curl -s -o /dev/null -w '%{http_code}\n' $B/admin # 200, the Lumen sign-in curl -s -o /dev/null -w '%{http_code}\n' -X POST $B/api/users/login \ -H content-type:application/json -d '{"email":"x@example.com","password":"x"}' # 403: no CMS passwords curl -fsS "$B/api/media?limit=1" # the media collection answers +C=https://lumen-payload-web-console-next-stage..workers.dev +curl -s -o /dev/null -w '%{http_code} %{redirect_url}\n' $C/login # 308 into $B ``` The CMS lane's smoke check asserts the first two after every deploy. diff --git a/specs/epics/lumen-payload-console/IMPLEMENTATION-STATUS.md b/specs/epics/lumen-payload-console/IMPLEMENTATION-STATUS.md index f759d9f..548c165 100644 --- a/specs/epics/lumen-payload-console/IMPLEMENTATION-STATUS.md +++ b/specs/epics/lumen-payload-console/IMPLEMENTATION-STATUS.md @@ -5,12 +5,55 @@ the code departed from `design.md`. | Milestone | State | PR | |---|---|---| -| PX0 — the spec | Merged | sourceplane/lumen-payload#21 | -| PX1 — Lumen sign-in | Merged; stage partly deployed, the rest waits on the credential-mint quota | sourceplane/lumen-payload#22 | -| PX2 — your account and organization | In review | — | -| PX3 — billing and plan | In review | — | -| PX4 — the front door | In review | — | -| PX5 — the record | Not started | — | +| PX0 — the spec | Shipped | sourceplane/lumen-payload#21 | +| PX1 — Lumen sign-in | Shipped; live on stage and prod | sourceplane/lumen-payload#22 | +| PX2 — your account and organization | Shipped; live on stage and prod | sourceplane/lumen-payload#23 | +| PX3 — billing and plan | Shipped; live on stage and prod | sourceplane/lumen-payload#24 | +| PX4 — the front door | Shipped; live on stage and prod | sourceplane/lumen-payload#25 | +| PX5 — the record | Shipped | this change | + +## Live verification (2026-10-28) + +Each milestone was checked against the deployed Workers after its merge, +with a Playwright run against stage's CMS and its real api-edge (stage shows +the sign-in code, so a test account can sign in): + +- **PX1, stage: 35/35.** A newcomer signs in and waits as pending; sign-out + revokes the Lumen session; the owner's setup token opens the first admin, + who promotes the newcomer; the OAuth return path; the session hand-in + refuses another origin, no origin and bogus tokens; a sibling Worker on the + same site cannot write with the admin cookie; first-register and password + login answer 403. The setup token was then revoked, and the owner's own + account was invited as admin. +- **PX2, stage: 26/26.** The Account nav group; the display name saved and + read back from Lumen and the `users` row; security activity listing this + sign-in (after the identity-worker fix); the organization; a notification + category off and back on, read back from Lumen; cross-origin and pending + posts refused; 15 own-session reads in a row all answer 200 (the `account` + rate family). +- **PX3, stage: 11/11.** Plan, plans, entitlements and invoices render; Upgrade + comes back with stage's explanation (no payment provider there); the + checkout return posts one reconcile; opening the return link alone writes + nothing. +- **PX4, stage and prod.** The console URL's `/`, `/login`, `/account`, + `/orgs//billing` and `/auth/callback?…` answer 308 to `/admin`, + `/admin/login`, `/admin/account`, `/admin/organization/billing` and + `/auth/lumen/callback?…` (query kept) on the same environment's CMS; + following the console URL lands on the CMS sign-in, titled *Login — Lumen + Payload*; the CMS root redirects to `/admin`. +- **Prod, read-only:** `/health` ok, `/admin` shows the Lumen sign-in, + password login and `/setup` without the owner's token answer 403. Prod's + first admin waits for the owner. + +**A note on the browser runs.** In the sandbox that ran these checks, +Chromium's requests for the admin's route chunk +(`/_next/static/chunks/app/(payload)/admin/%5B%5B...segments%5D%5D/page-*.js`) +came back as a 307 to the same URL, looping, while byte-identical requests +from curl, Python and Node got 200 from the same edge (and the +multi-tenant-saas-2 CMS, without these changes, behaved the same). The runs +therefore fetched `/_next/static/**` through Playwright's own network stack. +If a person's browser ever shows `ERR_TOO_MANY_REDIRECTS` on `/admin`, this is +where to look. ## Departures from the design @@ -71,6 +114,16 @@ the code departed from `design.md`. - **PX4, the billing fallback return.** `POLAR_SUCCESS_URL` is the CMS billing page on workers.dev, no longer a custom-domain placeholder, so it left the "Setting the domain later" list. +- **Operations: rotated Cloudflare tokens.** PX1's deploy ran out of the + workspace's 200 credential mints per rolling 24 hours: every CI job minted + fresh Cloudflare tokens, and the account-id fact counted as a mint too. + `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_HYPERDRIVE_TOKEN` now live at the + project rung as rotated secrets (minted once, re-minted every 30 days), + shadowing the workspace's brokered bindings. In Orun Cloud, fact templates + no longer count toward the limit and the orphan sweep now deletes expired + minted tokens hourly (sourceplane/orun-cloud#2106, with its follow-up + sourceplane/orun-cloud#2112), and the identity-worker fix from PX2 landed in + the baseline too (sourceplane/orun-cloud#2114). - **PX4, branding.** The admin's title suffix is *Lumen Payload*, and the logo and icon are a glyph with the product name, drawn in the admin's text colour. `.rebrand/values.json` carries a name, not a logo file. diff --git a/specs/epics/lumen-payload-console/README.md b/specs/epics/lumen-payload-console/README.md index 2b5344f..068e18f 100644 --- a/specs/epics/lumen-payload-console/README.md +++ b/specs/epics/lumen-payload-console/README.md @@ -23,14 +23,14 @@ the CMS, its schema and its media stay exactly as that epic built them. | Field | Value | |-------|-------| -| Status | Proposed | +| Status | Shipped (2026-10-28) | | Cluster | **PX** (PX0–PX5) | | Owner(s) | `apps/cms` (the console now) · `apps/identity-worker` (its OAuth return allowlist) · `apps/web-console-next` (retired to a redirect) · `packages/db` (one migration) | | Builds on | `lumen-payload-cms` (PC0–PC5) and Solo mode (`specs/profiles/solo-m0.md`) | | Changes | The CMS gains Lumen sign-in and the account pages; the Lumen console's URL redirects to the CMS. api-edge and every bounded-context worker are unchanged. | | Decisions locked | (1) The **Payload admin is the console**; the Lumen console UI is retired to a redirect. (2) **Lumen identity is the only sign-in**: Payload's local strategy is off. (3) The CMS calls `api-edge` **server to server**; the Lumen session lives only in an httpOnly cookie on the CMS host. (4) **Roles stay Payload's**: a new account is *pending* until an admin grants editor or admin, and the first admin still needs the owner's setup token. (5) Only the **Solo-mode surface** moves; what Solo mode hides at the edge stays hidden. | | Gate | PX1 is the first visible change: `/admin` asks for a Lumen sign-in on stage and prod. PX4 is the one users notice: the product URL opens Payload. | -| Shipped as | — | +| Shipped as | sourceplane/lumen-payload#21 (PX0), #22 (PX1), #23 (PX2), #24 (PX3), #25 (PX4) and the PX5 record; see `IMPLEMENTATION-STATUS.md` | ## Read order diff --git a/tasks/PX-6.TaskContract.yaml b/tasks/PX-6.TaskContract.yaml new file mode 100644 index 0000000..3251aa6 --- /dev/null +++ b/tasks/PX-6.TaskContract.yaml @@ -0,0 +1,20 @@ +apiVersion: orun.io/v1 +kind: TaskContract +metadata: + name: PX-6 + title: "PX5: the record — lumen-payload-console shipped" +spec: + goal: "The repository describes the product as it now runs: the Payload admin is the console, the old console URL redirects into it, and the epic's status reads shipped with each milestone's PR, its live verification and every departure from the design." + affects: + - "AGENTS.md" + - "README.md" + - "ai/context/operations.md" + - "apps/cms/docs/**" + - "apps/web-console-next/docs/**" + - "specs/epics/lumen-payload-console/**" + - "tasks/PX-6.TaskContract.yaml" + doneWhen: + - "AGENTS.md and ai/context/operations.md name the CMS as the console and the console Worker as a redirect" + - "the operations guide's secrets model lists the rotated Cloudflare tokens at the project rung" + - "IMPLEMENTATION-STATUS.md lists PX0 to PX5 as shipped, with their PRs and the stage and prod verification" + gates: []