Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

docs(ops): document QA account provisioning for the authed page sweeps

nirholas6aed25797432
diff --git a/CLAUDE.md b/CLAUDE.md
index 2638a7c80..58df6c76d 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -32,7 +32,7 @@ Agents stopping mid-task to ask a question is a failure mode the owner explicitl
| Blocker | Resolution (do this, don't ask) |
|---|---|
| Missing env var / credential | Look in `.env` and `.env.local`, then the Cloud Run service (`gcloud run services describe three-ws-api --region us-central1 --project aerial-vehicle-466722-p5 --format=yaml`), then Secret Manager (`gcloud secrets list`). Never trust `vercel env pull` (returns empty for secrets). Update single vars with `--update-env-vars` (merges); `--set-env-vars` REPLACES the whole set, so never use it for one key. If a credential truly exists nowhere, build the feature fully wired behind the env var, prove it with a mock-free dry run, and list the single missing var in your report. |
-| A QA login for authed page testing | `AUDIT_EMAIL` / `AUDIT_PASSWORD` in `.env` are a real production QA account. Unauthenticated sweep: `npm run audit:web`. Authed sweep: `npm run audit:web:login`. |
+| A QA login for authed page testing | `AUDIT_EMAIL` / `AUDIT_PASSWORD` in `.env` are a real production QA account. If they are missing from `.env` (a fresh clone has no `.env` at all), `npm run audit:web:provision` creates a new one through the real `/register` page and writes both vars back; no server-side code reads them, so the Cloud Run env does not need them. Unauthenticated sweep: `npm run audit:web`. Authed sweep: `npm run audit:web:login` to mint the session, then `npm run audit:web`, which replays it. Details: `docs/ops/page-audit.md`. |
| GCP access / project facts | Already authenticated in this workspace. Project `aerial-vehicle-466722-p5`, region `us-central1`. Fleet + quota + pre-approved scaling: `docs/ops/gcp-credits-plan.md`. Full production runbook (LB/DNS/TLS/env/rollback): `docs/ops/gcp-production.md`. Logs: `gcloud logging read 'resource.type="cloud_run_revision" resource.labels.service_name="three-ws-api" textPayload:"<term>"' --freshness=24h`. |
| The database | `DATABASE_URL` in `.env.local` (Neon); `.env` currently holds only the QA audit login, so a script that loads `.env` alone dies on `missing required env var: DATABASE_URL`. Production's authoritative copy is on the Cloud Run service env. Migrations: `npm run db:status` previews pending ones, `npm run db:check` is the deploy gate (exit 4 if pending), and **`npm run db:migrate` APPLIES immediately, with no dry run** (the npm script hardcodes `--apply`). Read `db:status` before you ever run `db:migrate`; it applies every pending migration in `api/_lib/migrations/`, not just yours. If `db:status` reports `[drift]` because an applied migration's *comments* were edited (the banned-dash rule does this), `npm run db:restamp` re-records its hash after recovering the applied bytes from git and confirming not one statement changed; a real statement change is refused and needs a NEW migration. `forge_creations` carries per-generation backend/status/error/prompt: the fastest ground truth for generation issues. |
| GCP quota hit | File the increase request immediately (`gcloud` or console link in your report), then route around it: lower minScale on an idle service, use another region, or queue behind existing capacity. Never park the task on the quota. |
diff --git a/docs/ops/page-audit.md b/docs/ops/page-audit.md
index 06560a143..21b2c84ca 100644
--- a/docs/ops/page-audit.md
+++ b/docs/ops/page-audit.md
@@ -22,8 +22,11 @@ The sweep is read-only. It never mutates the target.
## Commands
```sh
+# One-time: provision the QA account if AUDIT_EMAIL / AUDIT_PASSWORD are absent
+npm run audit:web:provision
+
# One-time: create the auth session (server-set HttpOnly cookie -> storageState)
[email protected] AUDIT_PASSWORD=secret npm run audit:web:login
+npm run audit:web:login
# Full sweep (picks up the saved session automatically)
npm run audit:web
@@ -52,6 +55,32 @@ BASE_URL=http://localhost:3000 npm run audit:web # vite dev server
Local targets get an extra noise filter for failures that only exist because
serverless functions and CDNs are absent under a bare dev server.
+## QA account
+
+The authed sweep signs in as a real member, so it needs `AUDIT_EMAIL` and
+`AUDIT_PASSWORD` in `.env`. If they are missing, `npm run audit:web:provision`
+(`scripts/provision-audit-account.mjs`) creates a fresh account by driving the
+real `/register` page in a headless Chromium: same form, same clickwrap
+checkbox, same `POST /api/auth/register` the page makes. It then proves the new
+credentials authenticate through `/api/auth/login` and writes them into `.env`
+(mode 0600), leaving every other line in the file untouched.
+
+```sh
+npm run audit:web:provision # against production
+npm run audit:web:provision -- --username qa-audit-mine # pick the username
+npm run audit:web:provision -- --print-only # don't touch .env
+BASE_URL=http://localhost:3000 npm run audit:web:provision # against dev
+```
+
+The register form takes a username, not an email address, and the server
+derives `<username>@users.three.ws.local` as the account email. That derived
+address is what lands in `AUDIT_EMAIL`, because `/api/auth/login` treats any
+value containing `@` as an email lookup. No server-side code reads these two
+vars: they are a local-harness credential, so the Cloud Run service env does
+not need them. `scripts/likeness-eval.mjs`,
+`scripts/reconstruct-load-test.mjs` and `scripts/capture-bundles-media.mjs`
+read the same pair.
+
## Session file
`--login` posts `AUDIT_EMAIL` / `AUDIT_PASSWORD` to `/api/auth/login` on the
diff --git a/tests/audit-links-surfaces.test.js b/tests/audit-links-surfaces.test.js
new file mode 100644
index 000000000..b17e25d00
--- /dev/null
+++ b/tests/audit-links-surfaces.test.js
@@ -0,0 +1,81 @@
+// Link audit: the gate itself, plus the coverage invariant behind it.
+//
+// `npm run audit:links` only proves what it walks. For a long time it walked
+// pages/, public/ and src/ and nothing else, while vercel.json routed real
+// requests into docs/, blog/ and chat/ too. Those trees served 200s in
+// production with their dead links unaudited, and the audit still reported a
+// clean zero, which is the worst possible failure for a gate: green with the
+// hole intact.
+//
+// So two things are pinned here:
+//
+// 1. The gate result. No broken internal link, no stub href, no dangling
+// route, anywhere the audit walks.
+// 2. The walk itself. Every top-level tree vercel.json can route an .html
+// request into must appear in the script's LINK_SURFACES list, so the
+// next content tree added at the repo root cannot quietly escape the
+// audit the way docs/ and blog/ did.
+
+import { describe, it, expect } from 'vitest';
+import { execFileSync } from 'node:child_process';
+import { readFileSync, existsSync } from 'node:fs';
+import { resolve, join } from 'node:path';
+
+const ROOT = resolve(import.meta.dirname, '..');
+const SCRIPT = join(ROOT, 'scripts', 'audit-links.mjs');
+
+const report = JSON.parse(
+ execFileSync('node', [SCRIPT, '--json'], { cwd: ROOT, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 }),
+);
+
+// The trees the script declares it walks, read from its source so the test
+// tracks the real list rather than a copy that can drift out of step.
+function declaredSurfaces() {
+ const src = readFileSync(SCRIPT, 'utf8');
+ const m = src.match(/const LINK_SURFACES = \[([^\]]*)\]/);
+ expect(m, 'audit-links.mjs must declare LINK_SURFACES').not.toBeNull();
+ return m[1].match(/'([^']+)'/g).map((s) => s.slice(1, -1));
+}
+
+// Top-level directories vercel.json serves .html out of, excluding the ones
+// that live under pages/ or public/ (those are covered by definition).
+function routedRootTrees() {
+ const vercel = JSON.parse(readFileSync(join(ROOT, 'vercel.json'), 'utf8'));
+ const trees = new Set();
+ for (const r of vercel.routes || []) {
+ if (!r.dest) continue;
+ const dest = r.dest.split('?')[0];
+ if (!dest.endsWith('.html') || dest.includes('$')) continue;
+ const rel = dest.replace(/^\/+/, '');
+ if (existsSync(join(ROOT, 'pages', rel)) || existsSync(join(ROOT, 'public', rel))) continue;
+ if (existsSync(join(ROOT, rel))) trees.add(rel.split('/')[0]);
+ }
+ return [...trees];
+}
+
+describe('link audit', () => {
+ it('finds no broken internal links', () => {
+ expect(report.brokenInternal).toEqual([]);
+ });
+
+ it('finds no stub hrefs', () => {
+ expect(report.stubs).toEqual([]);
+ });
+
+ it('finds no dangling routes', () => {
+ expect(report.danglingRoutes).toEqual([]);
+ });
+
+ it('walks every root tree vercel.json routes html into', () => {
+ const declared = declaredSurfaces();
+ for (const tree of routedRootTrees()) {
+ expect(declared, `vercel.json routes /${tree}/**.html but audit-links.mjs never walks it`).toContain(tree);
+ }
+ });
+
+ it('scans more than the three original surfaces', () => {
+ // A guard against the walk silently collapsing back: docs/ and blog/ alone
+ // are ~46 files, so a regression to pages+public+src shows up as a drop.
+ expect(report.scannedFiles).toBeGreaterThan(2028);
+ });
+});