diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1a50251..c66cc5b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -45,13 +45,3 @@ jobs: npx wrangler pages deploy dist --project-name pegma-dev --branch main - - name: Deploy pegma-dev-api Worker - if: > - github.ref == 'refs/heads/main' && - (github.event_name == 'push' || - github.event_name == 'schedule' || - github.event_name == 'workflow_dispatch') - env: - CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} - CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - run: npx wrangler deploy -c worker/wrangler.jsonc diff --git a/docs/PROJECT_PLAN.md b/docs/PROJECT_PLAN.md index 50f247c..c704ecd 100644 --- a/docs/PROJECT_PLAN.md +++ b/docs/PROJECT_PLAN.md @@ -6,13 +6,15 @@ serves the static site from Cloudflare Pages (project `pegma-dev`; `www` 301s to the apex); push-to-main deploys production via the SHA-pinned workflow, while PRs validate without receiving production credentials. -**Phase 3 complete -2026-07-27. Phase 4 is in progress:** its D1-backed Identity consumer now +**Phase 3 complete 2026-07-27. Phase 4 complete 2026-07-28:** its D1-backed +Identity consumer now composes the exact public Identity, Authorization adapter, Sessions, Mail, -rate-limit, and storage packages. Production deployment remains gated on -review and end-to-end account smoke tests. Email-code activation is a separate -gate: provider-domain setup, its managed secret, an audited operator workflow, -and an end-to-end delivery smoke test. +rate-limit, and storage packages. Worker version +`0a9956e6-01c6-4a9a-953f-4e71d94d0055` is live on `pegma.dev/api/*`; production +health, capabilities, unauthenticated account, and cross-origin rejection +smoke tests pass. Email-code activation is a separate gate: provider-domain +setup, its managed secret, an audited operator workflow, and an end-to-end +delivery smoke test. **Hosting decision:** Cloudflare (Pages for the static site; Workers when a dynamic slice exists). Deliberate: the reference application @@ -167,8 +169,8 @@ Actions deploy (SHA-pinned, per ecosystem standard). Exit: push-to-main publishes; the domain serves the site with an A grade on the obvious security headers. **Done:** project `pegma-dev`, deploys via plain `npx wrangler` in the SHA-pinned workflow (the CI token is scoped to -Pages:Edit and Workers:Edit — deliberately no D1 or DNS scope; the custom -domain was attached in the dashboard); security headers served from +Pages:Edit only — deliberately no Worker, D1, or DNS scope; the custom domain +was attached in the dashboard); security headers served from `public/_headers`, CSP with same-origin scripts only; `www` 301s to the apex. The initial D1 migration was operator-applied and production CI pins its exact hash; a future schema change remains fail-closed until it has a separate @@ -176,6 +178,10 @@ least-privileged D1 credential. Pull requests run the build gate but never receive the production token; branch previews remain disabled until a separately scoped preview credential exists. +The Worker is an explicit operator deployment until a second GitHub credential +has least-privileged Worker script plus `pegma.dev` route authority. The broad +local OAuth credential is never copied into GitHub. + ### Phase 3 — the compiled roadmap ✓ (2026-07-27) Build-time aggregation of component PROJECT_PLAN.md statuses into the @@ -189,7 +195,7 @@ emits file-format output so extensionless URLs serve 200 with no trailing-slash redirect. Verified live: the roadmap shows plan text the registry never contained. -### Phase 4 — the environment test +### Phase 4 — the environment test ✓ (2026-07-28) `packages/storage-cloudflare-d1` in the storage-core repo, passing the full conformance suite against real D1 (Miniflare/wrangler in CI). Then the @@ -243,7 +249,7 @@ with a source link where not. Decide in Phase 3. ## Near-term backlog 1. Complete independent review and local/remote D1 tests for the exact - Identity composition. + Identity composition. **Done 2026-07-28.** 2. Configure the Resend free-tier account, verify the `pegma.dev` sender, install its managed provider secret, and smoke-test idempotent delivery behind an authenticated, audited terminal-mail acknowledgement workflow @@ -251,3 +257,4 @@ with a source link where not. Decide in Phase 3. installed in Cloudflare's managed secret store. 3. Route same-origin `/api/*` traffic to `pegma-dev-api`, deploy, and verify the D1-backed account flow without changing the Pages-hosted static architecture. + **Done 2026-07-28; email activation remains separately gated.** diff --git a/worker/README.md b/worker/README.md index ea0413d..dbcacf1 100644 --- a/worker/README.md +++ b/worker/README.md @@ -32,9 +32,12 @@ npx wrangler secret put DATADOG_SITE -c worker/wrangler.jsonc # value: us5.datadoghq.com (or datadoghq.eu — not a full URL) ``` -CI deploys this Worker with the same `CLOUDFLARE_API_TOKEN` as Pages; that -token needs **Workers:Edit** in addition to **Pages:Edit**. It intentionally -does not receive D1 authority. +The GitHub deployment credential is Pages-only. Deploy this Worker from an +authenticated operator session with `npm run worker:deploy` until a separate, +least-privileged credential has both Worker script and `pegma.dev` route +authority. Do not substitute a broad personal OAuth token into GitHub. The +production Worker was operator-deployed on 2026-07-28 as version +`0a9956e6-01c6-4a9a-953f-4e71d94d0055`. ## Identity composition