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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 |
Expand Down
39 changes: 29 additions & 10 deletions ai/context/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`** —
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -148,7 +159,9 @@ that re-verifies.

Payload CMS 3.89 on Workers (OpenNext), deployed as `lumen-payload-cms-<env>`
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-<env>`) 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
Expand Down Expand Up @@ -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
Expand All @@ -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.<subdomain>.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.
Expand Down
65 changes: 59 additions & 6 deletions specs/epics/lumen-payload-console/IMPLEMENTATION-STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<slug>/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

Expand Down Expand Up @@ -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.
4 changes: 2 additions & 2 deletions specs/epics/lumen-payload-console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 20 additions & 0 deletions tasks/PX-6.TaskContract.yaml
Original file line number Diff line number Diff line change
@@ -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: []
Loading