Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

Harness end-of-feature smoke + isolated parallel e2e (audit D5, D7)

Jeromecc3f8f1eb801
diff --git a/.claude/agents/orchestrator.md b/.claude/agents/orchestrator.md
index 745f565d..98a3a9c6 100644
--- a/.claude/agents/orchestrator.md
+++ b/.claude/agents/orchestrator.md
@@ -465,6 +465,14 @@ Agent({
- `APPROVED` → forward any non-blocking notes (nits, ponytail `net: -N`) to the final report; proceed to promotion.
- `BLOCKED:` <imperative findings> → dispatch ONE `developer` to fix ONLY those findings on a fix worktree off `session/<SESSION_SHORT_ID>` (`BRANCH_NAME: <SESSION_SHORT_ID>/featurefix`, `CHANGE_REQUEST` = the findings verbatim), then merge it into the session branch (merger, Stage A), then re-run feature-review. **Bound to 2 rounds**: if still `BLOCKED` after 2, report the remaining findings in the handoff and proceed anyway (never wedge the pipeline on review). `#technical-harness` runs feature-review before its stop (no promotion after).
+#### Feature-smoke (does it actually run? audit D5)
+
+After feature-review passes, confirm the integrated feature RUNS before promotion / handoff. Two parts, both reported in the handoff:
+- **Demo smoke** (when the diff changes UI under `src/components/`): dispatch the quality-reviewer with `MODE: feature-smoke` (foreground, `run_in_background: false`) to drive the feature's key user flows in demo mode via the Playwright MCP and report PASS/FAIL. Runs for any UI change; needs no Supabase.
+- **Supabase e2e** (conditional): if the diff changed `e2e/**` OR touches behavior the specs assert (`src/components/**` / `supabase/**`), run `Bash("bash $CLAUDE_PROJECT_DIR/.claude/scripts/e2e-smoke.sh")`. It runs the Playwright suite against an ISOLATED, slot-leased Supabase instance and tears it down (guaranteed via `trap`). Exit 0 = passed OR gracefully skipped (it prints `SKIP: ...` when there is no free slot / too little RAM / the stack cannot start); exit 1 = the suite FAILED.
+
+A smoke FAIL is surfaced (like a feature-review finding; it may drive a bounded fix), never silently swallowed. A skip is fine (deferred to a human `make test-e2e`). `#technical-harness` runs feature-smoke before its stop and reports the result; it does not promote.
+
**`PERSONA: technical` → stop here.** Every reconciled ticket is already on `session/<SESSION_SHORT_ID>`. Do NOT promote and do NOT run POST-DEV: emit the raw per-ticket report (statuses, branches, SHAs, verdicts, ADR paths), run the `pending-deploys.mjs` detection for information only (add "schema changes detected — migration needed on merge" when non-empty), name the session branch for `/harness-diff`, and enter STATE DONE. The rest of this Promotion block is skipped.
Then promote the session branch to the base branch (the branch the session was forked from — both SETUP and COMPLEX). Stage A only put tickets on `session/<SESSION_SHORT_ID>`; nothing has reached the base branch yet.
diff --git a/.claude/agents/quality-reviewer.md b/.claude/agents/quality-reviewer.md
index 8cf863a2..e70e33e4 100644
--- a/.claude/agents/quality-reviewer.md
+++ b/.claude/agents/quality-reviewer.md
@@ -86,6 +86,23 @@ OUTPUT CONTRACT (text, no `SendMessage`), last line exactly one of:
`file:line - failure scenario - what to change`. The orchestrator dispatches a fix for these,
then re-runs you.
+## Feature-smoke mode (single-shot, no team)
+
+When your spawn prompt contains `MODE: feature-smoke`, drive the WHOLE integrated feature in
+demo mode to confirm it actually RUNS before handoff. This is Part C.3 (below) promoted from a
+single ticket's criteria to the feature's 2-3 key user flows. Start a `dev:demo` server (FakeRest,
+no Supabase, auto-authenticated) inside your worktree on a port unique to this session, walk the
+key flows via the Playwright MCP (`browser_navigate` -> `browser_snapshot`; `browser_take_screenshot`
+only for visual criteria; `browser_console_messages` for runtime errors), then ALWAYS tear down
+(`browser_close` + kill the server).
+
+Scope (state it in the report): demo mode covers rendering, routing, forms, filters and visual
+correctness; it does NOT cover auth, RLS, triggers, views, edge functions or real backend behavior
+(those are the Supabase e2e suite's job, run separately by `e2e-smoke.sh`).
+
+OUTPUT CONTRACT (text, last line): `APPROVED` (all key flows run) or `BLOCKED:` + the broken flows
+(one per line: flow, what failed).
+
## Migration mode (single-shot, no team)
When your spawn prompt contains `MODE: migration-review`, you are dispatched
diff --git a/.claude/scripts/e2e-smoke.sh b/.claude/scripts/e2e-smoke.sh
new file mode 100755
index 00000000..6b179aba
--- /dev/null
+++ b/.claude/scripts/e2e-smoke.sh
@@ -0,0 +1,118 @@
+#!/usr/bin/env bash
+# e2e-smoke.sh - run the Playwright e2e suite against an ISOLATED, disposable Supabase
+# instance so multiple harness sessions can run it in parallel without colliding.
+# Guaranteed teardown via `trap ... EXIT`. Audit D5/D7.
+#
+# Isolation per run: a leased SLOT (0..K-1) gives offset = slot*20, applied to the
+# project_id, every Supabase port, and the app port + auth URLs, in a throwaway workdir.
+# The flock lease also CAPS concurrency (K stacks max) so we never OOM the host.
+#
+# Exit codes: 0 = suite passed OR gracefully skipped (no slot / low RAM / cannot start);
+# 1 = the e2e suite ran and FAILED. Skips are exit 0 by design (the caller
+# treats a skip as "not run here, run it later", not as a failure).
+#
+# Env: E2E_SMOKE_SLOTS (default 5), E2E_SMOKE_MIN_MB (default 2500), E2E_SMOKE_DRY=1
+# (resolve slot/ports/config and print them, then exit WITHOUT Docker - for tests).
+set -uo pipefail
+
+REPO="${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
+SLOTS="${E2E_SMOKE_SLOTS:-5}"
+MIN_MB="${E2E_SMOKE_MIN_MB:-2500}"
+DRY="${E2E_SMOKE_DRY:-0}"
+SLOT_LOCK_DIR="/tmp/atomic-crm-e2e-slots"
+CONFIG_SRC="$REPO/supabase/config.e2e.toml"
+mkdir -p "$SLOT_LOCK_DIR"
+
+skip() { echo "SKIP: $*"; exit 0; } # graceful: not run here, not a failure
+
+# --- memory preflight -------------------------------------------------------
+# Each Supabase stack is ~2-3 GB. Don't attempt a boot the host can't hold; skip
+# gracefully so the caller defers to a human `make test-e2e` instead of OOM-ing.
+avail_mb="$(free -m 2>/dev/null | awk '/^Mem:/{print $7}')"
+if [ "$DRY" != "1" ] && [ -n "$avail_mb" ] && [ "$avail_mb" -lt "$MIN_MB" ]; then
+ skip "only ${avail_mb}MB free, need ~${MIN_MB}MB for a Supabase e2e stack; run 'make test-e2e' locally."
+fi
+
+# --- lease a slot (flock; also the concurrency cap) -------------------------
+slot=""; SLOT_FD=""
+for i in $(seq 0 $((SLOTS - 1))); do
+ exec {fd}>"$SLOT_LOCK_DIR/slot-$i.lock"
+ if flock -n "$fd"; then slot="$i"; SLOT_FD="$fd"; break; fi
+ exec {fd}>&-
+done
+[ -z "$slot" ] && skip "all $SLOTS e2e slots busy; try again later."
+
+offset=$((slot * 20))
+project="atomic-crm-e2e-$slot"
+api_port=$((54341 + offset))
+app_port=$((5175 + slot))
+workroot="$(mktemp -d)"
+workdir="$workroot/e2e" # supabase --workdir
+mkdir -p "$workdir/supabase"
+
+# --- guaranteed teardown ----------------------------------------------------
+APP_PID=""
+cleanup() {
+ local code=$?
+ [ -n "$APP_PID" ] && kill "$APP_PID" 2>/dev/null || true
+ [ "$DRY" != "1" ] && npx supabase stop --workdir "$workdir" --no-backup >/dev/null 2>&1 || true
+ [ -n "$SLOT_FD" ] && flock -u "$SLOT_FD" 2>/dev/null || true
+ rm -rf "$workroot" 2>/dev/null || true
+ return $code
+}
+trap cleanup EXIT INT TERM
+
+# --- render the per-slot config ---------------------------------------------
+# Offset every Supabase port (`port =`, `shadow_port =`, `vector_port =`) by `offset`,
+# set a unique project_id (distinct Docker containers), and point the auth URLs at the
+# per-slot app port. perl `/e` evaluates the numeric replacement.
+[ -f "$CONFIG_SRC" ] || skip "no $CONFIG_SRC"
+perl -pe "s/^(project_id\s*=\s*).*/\$1\"$project\"/;
+ s/((?:^|_)port\s*=\s*)(\d+)/\$1.(\$2+$offset)/e;
+ s/5175/$app_port/g" "$CONFIG_SRC" > "$workdir/supabase/config.toml"
+
+# Supabase needs the schema/migrations/seed to build the DB on first start.
+for d in migrations schemas functions templates; do
+ [ -d "$REPO/supabase/$d" ] && cp -r "$REPO/supabase/$d" "$workdir/supabase/$d"
+done
+for f in seed.sql signing_keys.json; do
+ [ -f "$REPO/supabase/$f" ] && cp "$REPO/supabase/$f" "$workdir/supabase/$f"
+done
+
+if [ "$DRY" = "1" ]; then
+ echo "DRY-RUN slot=$slot offset=$offset project=$project api_port=$api_port app_port=$app_port workdir=$workdir"
+ echo "config.project_id=$(grep -E '^project_id' "$workdir/supabase/config.toml")"
+ echo "config.api_port=$(awk '/^\[api\]/{a=1} a&&/^port =/{print $3; exit}' "$workdir/supabase/config.toml")"
+ echo "config.site_url=$(grep -E '^site_url' "$workdir/supabase/config.toml" | head -1)"
+ exit 0
+fi
+
+# --- reap a previously killed run of this slot -----------------------------
+# The trap cleans up normal exits (EXIT/INT/TERM); a SIGKILL would orphan this slot's
+# containers. Before starting fresh, remove any lingering ones for this project_id.
+docker ps -aq --filter "name=${project}" 2>/dev/null | xargs -r docker rm -f >/dev/null 2>&1 || true
+
+# --- start the isolated stack ----------------------------------------------
+echo "e2e-smoke: starting isolated Supabase (slot $slot, api :$api_port, project $project)..."
+if ! npx supabase start --workdir "$workdir" >/"$workroot/supabase.log" 2>&1; then
+ cat "$workroot/supabase.log" >&2 || true
+ skip "isolated Supabase failed to start (see log); deferring e2e to a human run."
+fi
+SERVICE_ROLE_KEY="$(npx supabase status --workdir "$workdir" -o env 2>/dev/null | sed -nE 's/^SERVICE_ROLE_KEY="?([^"]+)"?/\1/p')"
+ANON_KEY="$(npx supabase status --workdir "$workdir" -o env 2>/dev/null | sed -nE 's/^ANON_KEY="?([^"]+)"?/\1/p')"
+export VITE_SUPABASE_URL="http://127.0.0.1:$api_port"
+export VITE_SUPABASE_ANON_KEY="$ANON_KEY"
+export SERVICE_ROLE_KEY
+
+# --- serve the app (dev server reads env at start, so no per-slot build) ----
+( cd "$REPO" && VITE_SUPABASE_URL="$VITE_SUPABASE_URL" npx vite --port "$app_port" --strictPort --mode e2e >"$workroot/app.log" 2>&1 ) &
+APP_PID=$!
+npx wait-on -t 120000 "http-get://127.0.0.1:$api_port/auth/v1/health" "http-get://127.0.0.1:$app_port" >/dev/null 2>&1 \
+ || skip "isolated stack did not become ready in time."
+
+# --- run the suite ----------------------------------------------------------
+echo "e2e-smoke: running Playwright against the isolated stack..."
+( cd "$REPO" && CI=true PLAYWRIGHT_BASE_URL="http://127.0.0.1:$app_port" npx playwright test )
+result=$?
+echo "e2e-smoke: suite exit=$result (slot $slot)"
+exit $result
diff --git a/e2e/bulkContactTags.spec.ts b/e2e/bulkContactTags.spec.ts
index 7545858c..02c5c934 100644
--- a/e2e/bulkContactTags.spec.ts
+++ b/e2e/bulkContactTags.spec.ts
@@ -30,7 +30,7 @@ test("user adds a tag to several contacts", async ({
title: "Rear Admiral",
});
- await page.goto("http://localhost:5175/");
+ await page.goto("/");
await page.getByLabel("Email").fill("[email protected]");
await page.getByLabel("Password").fill("password");
diff --git a/e2e/onboarding.spec.ts b/e2e/onboarding.spec.ts
index d3206f82..7786268e 100644
--- a/e2e/onboarding.spec.ts
+++ b/e2e/onboarding.spec.ts
@@ -1,7 +1,7 @@
import { test, expect } from "./fixtures";
test("user onboarding", async ({ page, isMobile, menu, dismissToast }) => {
- await page.goto("http://localhost:5175/");
+ await page.goto("/");
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Atomic CRM/);
diff --git a/e2e/userAddingATask.spec.ts b/e2e/userAddingATask.spec.ts
index 42d34284..70a9ff86 100644
--- a/e2e/userAddingATask.spec.ts
+++ b/e2e/userAddingATask.spec.ts
@@ -40,7 +40,7 @@ test.describe("user adding a task", () => {
});
});
test("user adding a task", async ({ page, isMobile, menu, dismissToast }) => {
- await page.goto("http://localhost:5175/");
+ await page.goto("/");
await page.getByLabel("Email").fill("[email protected]");
await page.getByLabel("Password").fill("password");
await page.getByRole("button", { name: "Sign in" }).click();
diff --git a/playwright.config.ts b/playwright.config.ts
index d1b4fb91..99ebeb55 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -27,8 +27,10 @@ export default defineConfig({
reporter: "list",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
- /* Base URL to use in actions like `await page.goto('')`. */
- // baseURL: 'http://localhost:3000',
+ /* Base URL for `page.goto('/')`. Overridable so an isolated e2e-smoke run can
+ point the specs at its own per-slot app port (audit D7). Default matches the
+ makefile's `start-app-e2e` port. */
+ baseURL: process.env.PLAYWRIGHT_BASE_URL || "http://localhost:5175",
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: "on-first-retry",