diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afe071b..e827734 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,8 @@ jobs: # nothing user-facing may publish them (reports go to security@). - name: Reserved mailbox regression tests run: node --test scripts/reserved-mailboxes.test.mjs + - name: Supabase adapter clean consumer acceptance (synthetic delivery) + run: node scripts/check-supabase-consumer.mjs - name: Design and truthfulness audit run: pnpm exec tsx scripts/design-audit.ts # Cheap and fast, so it runs before the build: a placeholder link is a diff --git a/AGENTS.md b/AGENTS.md index e8a44e3..144ed4b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -64,6 +64,13 @@ the industry's founding lie, in our own product. ## Current production checkpoint (October 26, 2026) +Acceptance follow-up (27 October): the iPhone Simulator's normal sign-in request +succeeded through an authorized opt-in Xcode UI test, but default Supabase delivery +produced a link-only email while Sprout expects a code. Free-plan template editing +is locked without SMTP or Pro. This fallback is incompatible, not merely untested. +The clean consumer packaging fixture passes; independent customer setup and actual +two-client sync remain open. See `docs/supabase-rollout-acceptance-2026-10-27.md`. + API and worker run `effd2bdbe3fe5f52b2f960c3a6075817c7e2cc4a` (PR #59), released through exact-main CI/image publishing and the guarded canary path. Two labelled owner-inbox canaries have provider delivery evidence. Dashboard @@ -75,8 +82,9 @@ restoration after restart. Five of eight approved emails were used. The Supabase hook is now Disabled, the temporary QA key is revoked (HTTP 401 verified), auth admission is disabled, and the optional hook/vault runtime and temporary secrets are removed. The limited ledger login is disabled; replay tombstones remain. -No ongoing Rootmail auth sending is enabled. Supabase default fallback delivery, -actual two-device sync and an independent customer installation remain unverified. +No ongoing Rootmail auth sending is enabled. Default fallback delivery is +incompatible with native OTP. Actual two-device sync and an independent customer +installation remain unverified. See `docs/sprout-pilot-validation-2026-10-25.md` for exact scope and evidence. SES sandbox limits remain; no unrestricted sending or public auth rollout is claimed. The application host, managed database and managed queue sizes are diff --git a/CLAUDE.md b/CLAUDE.md index eb3d3b8..75a5958 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -2,6 +2,13 @@ ## Current production checkpoint (October 26, 2026) +Acceptance follow-up (27 October): the iPhone Simulator's normal sign-in request +succeeded through an authorized opt-in Xcode UI test, but default Supabase delivery +produced a link-only email while Sprout expects a code. Free-plan template editing +is locked without SMTP or Pro. This fallback is incompatible, not merely untested. +The clean consumer packaging fixture passes; independent customer setup and actual +two-client sync remain open. See `docs/supabase-rollout-acceptance-2026-10-27.md`. + API and worker run `effd2bdbe3fe5f52b2f960c3a6075817c7e2cc4a` (PR #59), released through exact-main CI/image publishing and the guarded canary path. Two labelled owner-inbox canaries have provider delivery evidence. Dashboard @@ -13,8 +20,9 @@ restoration after restart. Five of eight approved emails were used. The Supabase hook is now Disabled, the temporary QA key is revoked (HTTP 401 verified), auth admission is disabled, and the optional hook/vault runtime and temporary secrets are removed. The limited ledger login is disabled; replay tombstones remain. -No ongoing Rootmail auth sending is enabled. Supabase default fallback delivery, -actual two-device sync and an independent customer installation remain unverified. +No ongoing Rootmail auth sending is enabled. Default fallback delivery is +incompatible with native OTP. Actual two-device sync and an independent customer +installation remain unverified. See `docs/sprout-pilot-validation-2026-10-25.md` for exact scope and evidence. SES sandbox limits remain; no unrestricted sending or public auth rollout is claimed. The application host, managed database and managed queue sizes are diff --git a/docs/COLLAB.md b/docs/COLLAB.md index 630a487..807f9f5 100644 --- a/docs/COLLAB.md +++ b/docs/COLLAB.md @@ -391,3 +391,17 @@ login disabled and replay metadata preserved. No extra paid AWS resource was added. Rootmail auth sending is not left enabled; default Supabase fallback is untested. An independent customer setup and broader live acceptance remain gates. See docs/sprout-pilot-validation-2026-10-25.md for evidence and local native build fix. + +## 27 October 2026 — default email fallback is incompatible with native OTP + +The opt-in Xcode UI test requested an actual iPhone Simulator sign-in email. +Supabase's default sender delivered a link-only message, while Sprout requires a +code. Free-plan template editing is locked without SMTP or Pro. The retired +Rootmail pilot is still successful historical evidence, but its removal did not +leave a working native sign-in path for new sessions. Broader beta remains gated. + +A clean consumer fixture now verifies installation and public imports outside the +monorepo with all six action types and synthetic retry/signature checks. This is +automated packaging evidence, not an independently onboarded second customer. +Real two-client sync is still pending. See +docs/supabase-rollout-acceptance-2026-10-27.md; do not mark the broad tasks Done. diff --git a/docs/supabase-auth-integration.md b/docs/supabase-auth-integration.md index d242688..68810c8 100644 --- a/docs/supabase-auth-integration.md +++ b/docs/supabase-auth-integration.md @@ -7,9 +7,11 @@ in this increment. Task: [Rootmail / Sprout pilot](https://app.notion.com/p/4032db0e8691818496f5c235840c351c). -Latest operational evidence: [25 October production and Sprout configuration -validation](sprout-pilot-validation-2026-10-25.md). The checks are read-only; -the integration is not deployed and the native pilot has not run. +Latest operational evidence: [configuration, release and controlled pilot +validation](sprout-pilot-validation-2026-10-25.md). API/worker `effd2bd` is deployed; +native Mac sign-in and session restoration passed on 26 October. The temporary +pilot was then retired. [Broader acceptance](supabase-rollout-acceptance-2026-10-27.md) +remains open. The dated implementation increments below are historical. ## First increment — signed planner diff --git a/docs/supabase-hook-setup.md b/docs/supabase-hook-setup.md index 5ff5180..5ca058e 100644 --- a/docs/supabase-hook-setup.md +++ b/docs/supabase-hook-setup.md @@ -1,9 +1,10 @@ # Supabase → Rootmail hook setup reference -Unreleased reference, 25 October 2026. This has passed synthetic/local tests, -not an independently followed customer installation or live Sprout sign-in. -Keep the Supabase hook disabled until the production release/pilot gates below -are explicitly cleared. No SMTP fallback is invoked by this adapter. +Private reference, updated 27 October 2026. The controlled Sprout pilot passed +live code delivery, native Mac sign-in and session restoration on release +`effd2bd`; its temporary hook/key/runtime were subsequently retired. An independent +customer installation and broader live acceptance remain open. Enable only the +reviewed scope after operational checks. No SMTP fallback is invoked by this adapter. ## Prerequisites and cost @@ -173,17 +174,25 @@ pilot, not public Sprout email availability. restoring that tested configuration. A disabled hook does not prove SMTP works. Roll Rootmail back only after disabling admission and draining/expiring auth jobs. -## Pilot gates (not yet observed) +## Acceptance and remaining rollout gates -Confirm the deployed version/configuration and exact sender/inboxes; authorize -one live Sprout test; request the code, observe provider acceptance and delivery -separately, enter the code and verify the native Supabase session. Test wrong and -expired codes, resend invalidation and two-recipient change. Record IDs/timestamps -and latency, never codes or links. Then have a second customer follow this guide. +The [controlled pilot report](sprout-pilot-validation-2026-10-25.md) records the +observed sender/scope, delivery, native Mac sign-in, restart and cleanup. Wrong +codes and a code beyond the expiry window were rejected. Exact expiry boundaries, +immediate resend invalidation and live two-recipient changes remain unverified. +Record IDs/timestamps and latency, never codes or links. Have a second customer +follow this guide; the clean consumer fixture is automated packaging evidence, +not that human acceptance. + +**Fallback finding, 27 October:** disabling the hook in `sprout-dev-us` returned +to Supabase's Free-plan default link-only email. Sprout's native UI expects an +eight-digit code, so receipt did not complete sign-in. The dashboard locks template +editing without custom SMTP or Pro; a Send Email Hook is the existing chosen +integration. Do not call the default sender a working native OTP fallback or +disable a working hook without an explicitly tested replacement configuration. Sources: [Supabase email hook and recipient mapping](https://supabase.com/docs/guides/auth/auth-hooks/send-email-hook), [hook errors and five-second budget](https://supabase.com/docs/guides/auth/auth-hooks). -Configs touched: reference hook-host environment, server-only PostgreSQL schema -and pool settings; no settings were applied to a customer or production host. -Prod behaviour preserved: auth remains disabled and no live emails were sent. +Current rollout evidence and remaining gates: +[27 October acceptance](supabase-rollout-acceptance-2026-10-27.md). diff --git a/docs/supabase-rollout-acceptance-2026-10-27.md b/docs/supabase-rollout-acceptance-2026-10-27.md new file mode 100644 index 0000000..9784ce6 --- /dev/null +++ b/docs/supabase-rollout-acceptance-2026-10-27.md @@ -0,0 +1,74 @@ +# Supabase rollout and Sprout sync acceptance + +Status: **In progress. Do not close broader rollout or HT-005.** +This continues the [successful controlled pilot](sprout-pilot-validation-2026-10-25.md). +It distinguishes local fixtures, hosted observations and open acceptance gates. + +## Observed on 27 October + +| Check | Evidence and limits | +| --- | --- | +| Adapter regressions | 40/40 package tests passed; synthetic delivery. | +| Clean consumer | Public `@rootmail/supabase` imports worked after installation outside the monorepo. Six action types, two-recipient mapping, signature denial and reconstructed-handler retry passed. Transport and ledger query results are fixtures. | +| Sprout model | Four cloud-sync XCTest cases and 12 core Swift Testing cases passed in a fresh scratch directory. | +| Database invariants | Disposable PostgreSQL tests passed for ownership, anonymous denial, idempotency, conflicts, validation and rollback. This is not hosted Data API acceptance. | +| Deletion cascade | Extended disposable SQL tests passed: deleting a fixture auth user removes its account, habits, check-ins and replay receipt, preserves the other owner, and rejects recreation by a stale identity. This does not implement or prove an end-user account-deletion flow. | +| Hosted anonymous access | Using only the app's publishable key, all four table reads and `habit_snapshot` returned HTTP 401 / PostgreSQL 42501. No signed-in session was copied or user records returned. This does not prove authenticated cross-owner isolation through the Data API. | +| iPhone app | Fresh arm64 build and build-for-testing passed. Installed on the iPhone 17 Pro / iOS 26.2 simulator; UI rendered. No physical iPhone acceptance is claimed. | +| Hosted code request | Explicitly authorized Xcode UI test used the normal native form, without copying a session or resetting data. One test passed, zero skipped. | +| Default email | Supabase sent “Your sign-in link” to the owner inbox at 08:05:24 UTC (09:05 WAT). It was link-only; native Sprout expects an eight-digit code. Sign-in did not complete. | +| Default template edit | Dashboard requires custom SMTP or Pro for template customization; source editing and saving are disabled. No upgrade or provider change was made. | +| Mac data | Created the disposable habit “QA sync 27 Oct — disposable,” cue “Mac to iPhone acceptance.” Mac displayed Up to date. This alone does not prove remote persistence or a second-client read. | +| Provider access | SES reports sending enabled, HEALTHY, production access false, 200/day and one/second. Unrestricted sending remains blocked. | + +## Reproducible automated checks + +```sh +pnpm --filter @rootmail/supabase test +node scripts/check-supabase-consumer.mjs +``` + +The clean consumer uses only vendored source/metadata and a pinned package-manager +version, does not read Rootmail `.env`, forbids default runtime fetch and removes +its temporary directory. Dependency installation may use the package registry. +It is included in CI. An independent customer still needs to follow the setup +guide with their own workspace and server secrets. + +Sprout checks live in its separate repository: `swift test --package-path +apple/SproutCore --scratch-path `, `supabase/tests/run-postgres.sh`, +and the opt-in `HabitFlowTests/testOpenHostedAccountSignIn` UI test. Normal UI +test execution skips the hosted test unless explicitly enabled with an email. +The UI test never reads or supplies a code. Its first invocation skipped because +the runner lacked the opt-in environment; only the later enabled invocation is +the successful request evidence. + +## Open acceptance + +- Restore a bounded, authorized code-delivery path for the independent iPhone + sign-in; keep server credentials out of the native app. Retire temporary access + after acceptance and document whether ongoing sign-in remains available. +- Observe Mac → iPhone and iPhone → Mac habit/check-in changes through hosted + storage, then restart, retry and conflict behavior. Do not reuse the Mac session + as a shortcut to a second independent session. +- Verify immediate resend invalidation and controlled expiry behavior; do not + infer them from email arrival or an old-code rejection hours later. +- Complete account deletion/retention acceptance using disposable data/accounts, + including ownership and prevention of resurrection. Never delete the owner account. +- Have an independent customer complete installation, and obtain applicable + delivery access before unrestricted onboarding. No SES appeal is filed here. + +## Current operational boundary + +API/worker remain on `effd2bd`; the prior pilot key is revoked and its hook/runtime +are retired. Supabase's default email path now has an observed incompatibility +with the native code UI. A prepared new temporary QA key is awaiting action-time +approval; it has not been created. No additional paid resource has been created. + +Local evidence: `/tmp/rootmail-consumer-acceptance-20261027.log`, +`/tmp/rootmail-supabase-acceptance-20261027.log`, +`/tmp/sprout-core-acceptance-20261027.log`, +`/tmp/sprout-sql-acceptance-20261027.log`, +`/tmp/sprout-anonymous-acceptance-20261027.log`, +`/tmp/sprout-rollout-ios-build.log`, +`/tmp/sprout-live-signin-enabled-20261027.xcresult`. +These local artifacts are not durable CI or independent-review evidence. diff --git a/packages/supabase/README.md b/packages/supabase/README.md index dac2bf4..fe7b81e 100644 --- a/packages/supabase/README.md +++ b/packages/supabase/README.md @@ -1,17 +1,17 @@ -# Supabase email adapter — unreleased reference +# Supabase email adapter — private reference -**Unreleased and private. Do not enable this as a production Supabase hook yet.** -The package now includes both a transport-free planner and an opt-in Web Request -handler that uses the auth-only Rootmail HTTPS endpoint. No running application -installs it automatically. Local transport tests use fake delivery; no real -Supabase session has been completed. Never use ordinary `/v1/messages` for codes. +**Private and unpublished; broader rollout remains gated.** API/worker release +`effd2bd` includes the disabled-by-default auth endpoint. The controlled Sprout +pilot on 26 October passed real code delivery, native Mac sign-in and session +restoration. Its temporary hook/key/runtime were retired after acceptance; +ongoing Rootmail auth sending is not enabled by that pilot. -Update: the draft branch now includes a separate, disabled-by-default -`POST /v1/auth-messages` server contract. It has encrypted ephemeral content, -expiry enforcement and a restricted SES path with tracking checks. This planner -now has an explicit HTTP wrapper, capability preflight and PostgreSQL replay -ledger. See the [customer setup reference](../../docs/supabase-hook-setup.md) and -integration notes for rollout gates and remaining limitations. +The package includes a signed planner, bounded HTTPS handler, capability preflight +and PostgreSQL replay ledger. No application installs it automatically. Local +tests use synthetic delivery. Never use ordinary `/v1/messages` for codes. +See the [pilot evidence](../../docs/sprout-pilot-validation-2026-10-25.md), +[setup guide](../../docs/supabase-hook-setup.md) and +[broader acceptance](../../docs/supabase-rollout-acceptance-2026-10-27.md). Tracking task: [Supabase authentication emails — Sprout pilot](https://app.notion.com/p/4032db0e8691818496f5c235840c351c). Release gates and implementation sequence: [integration notes](../../docs/supabase-auth-integration.md). @@ -53,7 +53,8 @@ credentials; this package never mints a token or declares a session valid. For link actions the verification host comes from trusted `supabaseUrl`, never payload `site_url`. `redirect_to` must exactly match a server allowlist entry; an absent/empty value uses the configured default. Explicit native-app callbacks -are supported as strings, but native app session completion is not tested here. +are supported as strings, but link-based native callback completion is untested. +The controlled Sprout pilot used code-only verification instead. Plain HTTP callbacks are deliberately not supported in this first increment. ## Local development (synthetic fixtures only) @@ -61,8 +62,15 @@ Plain HTTP callbacks are deliberately not supported in this first increment. ```sh pnpm --filter @rootmail/supabase typecheck pnpm --filter @rootmail/supabase test +node scripts/check-supabase-consumer.mjs ``` +The last command installs the vendored package into a temporary consumer outside +the monorepo and exercises its public imports with synthetic transport and ledger +fixtures. It checks six action types, both secure-change recipients, invalid +signatures and retry after handler reconstruction. It does not establish a real +PostgreSQL connection, live delivery or an independent customer's installation. + Package tests use an independent HMAC signer, synthetic secrets, a fake ledger and injected fetch; they never make real network/mail calls. Separate API tests use the real local database, queue, worker and PostgreSQL ledger with fake delivery. diff --git a/scripts/check-supabase-consumer.mjs b/scripts/check-supabase-consumer.mjs new file mode 100644 index 0000000..5919bcb --- /dev/null +++ b/scripts/check-supabase-consumer.mjs @@ -0,0 +1,28 @@ +#!/usr/bin/env node +// Clean consumer install; synthetic mail only, never reads Rootmail .env. +import { mkdtemp, mkdir, cp, writeFile, readFile, rm } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { join, dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { spawnSync } from 'node:child_process'; +const root = dirname(dirname(fileURLToPath(import.meta.url))); +const directory = await mkdtemp(join(tmpdir(), 'rootmail-supabase-consumer-')); +const run = (command, args) => { + const result = spawnSync(command, args, { cwd: directory, stdio: 'inherit', + env: { PATH: process.env.PATH, HOME: process.env.HOME, CI: 'true' } }); + if (result.error || result.status !== 0) throw new Error('Consumer acceptance failed'); +}; +try { + await mkdir(join(directory, 'vendor/supabase'), { recursive: true }); + // Copy only installable source/metadata, never local credentials or build state. + for (const path of ['package.json', 'src']) { + await cp(join(root, 'packages/supabase', path), join(directory, 'vendor/supabase', path), { recursive: true }); + } + const tsx = JSON.parse(await readFile(join(root, 'node_modules/tsx/package.json'), 'utf8')).version; + const { packageManager } = JSON.parse(await readFile(join(root, 'package.json'), 'utf8')); + await writeFile(join(directory, 'package.json'), JSON.stringify({ private: true, type: 'module', + packageManager, dependencies: { '@rootmail/supabase': 'file:./vendor/supabase', tsx } })); + await cp(join(root, 'scripts/fixtures/supabase-consumer/acceptance.ts'), join(directory, 'acceptance.ts')); + run('pnpm', ['install', '--prefer-offline', '--ignore-scripts']); + run(process.execPath, ['--import', 'tsx', 'acceptance.ts']); +} finally { await rm(directory, { recursive: true, force: true }); } diff --git a/scripts/fixtures/supabase-consumer/acceptance.ts b/scripts/fixtures/supabase-consumer/acceptance.ts new file mode 100644 index 0000000..75d7ac7 --- /dev/null +++ b/scripts/fixtures/supabase-consumer/acceptance.ts @@ -0,0 +1,63 @@ +// Public imports in a separate installed consumer: no repository-relative code imports. +import assert from 'node:assert/strict'; +import { createHmac, randomBytes } from 'node:crypto'; +import { createSupabaseEmailHook, createPostgresHookLedger } from '@rootmail/supabase'; +// Fail closed if this reference accidentally bypasses its injected fake transport. +globalThis.fetch = async () => { throw Error('Network forbidden in consumer fixture'); }; +const secret = randomBytes(32); +const entries = new Map(); +const ledger = createPostgresHookLedger(async (query, values) => { + assert.match(query, /ON CONFLICT/); + const [event, fingerprint, expires] = values; + assert.match(event, /^[a-f0-9]{64}$/); + assert.match(fingerprint, /^[a-f0-9]{64}$/); + if (!entries.has(event)) entries.set(event, { fingerprint, expires_at: expires }); + return [entries.get(event)]; +}); +const config = { + hookSecrets: [`v1,whsec_${secret.toString('base64')}`], + supabaseUrl: 'https://consumer.example.test', workspaceId: 'ws_consumer', clientId: 'tnt_consumer', + rootmailUrl: 'https://api.example.test', rootmailApiKey: 'rm_live_fixture_only', + from: 'auth@consumer.example.test', replyTo: 'support@consumer.example.test', brand: 'Consumer', + emailChangeMode: 'secure' as const, deliveryMode: 'code_only' as const, + credentialLifetimeSeconds: 3600, ledgerKey: randomBytes(32).toString('base64'), ledger, +}; +const receipts = new Map(); let admitted = 0; +const transport: typeof fetch = async (url, init) => { + assert.equal(init?.redirect, 'error'); + assert.equal(init?.headers?.['x-rootmail-subtenant'], 'tnt_consumer'); + if (String(url).endsWith('/capabilities')) return Response.json({ policy: 'authentication-v1', + provider: 'ses', workspace_id: 'ws_consumer', sub_tenant_id: 'tnt_consumer' }); + assert.equal(init?.method, 'POST'); + const data = JSON.parse(String(init.body)); + assert.equal(data.policy, 'authentication-v1'); + assert.ok(!data.html.includes('fixture-hash')); + if (!receipts.has(data.idempotency_key)) receipts.set(data.idempotency_key, { + id: `msg_fixture_${++admitted}`, content_policy: data.policy, workspace_id: 'ws_consumer', + sub_tenant_id: 'tnt_consumer', expires_at: data.expires_at, to: data.to, sandbox: false, + test_recipient: null, status: 'sent', provider: 'ses', provider_message_id: `fake_${admitted}`, + }); + return Response.json(receipts.get(data.idempotency_key)); +}; +const request = (action: string, id: string, valid = true) => { + const timestamp = Math.floor(Date.now() / 1000); + const body = JSON.stringify({ user: { email: 'first@example.test', new_email: 'second@example.test' }, + email_data: { email_action_type: action, token: '12345678', token_hash: 'fixture-hash', + ...(action === 'email_change' ? { token_new: '87654321', token_hash_new: 'other-fixture-hash' } : {}) } }); + return new Request('https://hook.consumer.example.test', { method: 'POST', body, headers: { + 'content-type': 'application/json', 'webhook-id': id, 'webhook-timestamp': String(timestamp), + 'webhook-signature': `v1,${valid ? createHmac('sha256', secret).update(`${id}.${timestamp}.${body}`).digest('base64') : 'invalid'}`, + } }); +}; +const hook = createSupabaseEmailHook(config, { fetch: transport }); +assert.equal((await hook(request('signup', 'invalid', false))).status, 401); +assert.equal(entries.size, 0); assert.equal(admitted, 0); +for (const action of ['signup', 'magiclink', 'recovery', 'invite', 'reauthentication', 'email_change']) { + assert.equal((await hook(request(action, `event_${action}`))).status, 200, action); +} +assert.equal(admitted, 7); +const restarted = createSupabaseEmailHook(config, { fetch: transport }); +assert.equal((await restarted(request('email_change', 'event_email_change'))).status, 200); +assert.equal(admitted, 7, 'Restarted retry must retain the same recipient keys'); +assert.equal(entries.size, 6); +console.log('Clean consumer install passed: public imports, six action types, two-recipient mapping, signature denial and restarted retry; synthetic delivery only.');