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.

feat(guards): publish the guard registry to /guards and document writing one

nirholascbb4acfde365
diff --git a/docs/tutorials/write-a-guard.md b/docs/tutorials/write-a-guard.md
new file mode 100644
index 000000000..ab520ded1
--- /dev/null
+++ b/docs/tutorials/write-a-guard.md
@@ -0,0 +1,255 @@
+# Write a repository guard
+
+**Level:** intermediate. You should be comfortable with Node and `git`.
+**Time:** about 20 minutes.
+**You will build:** a real guard that fails the build when an API handler forgets its error boundary, wired into the gate, covered by tests, and registered so it shows up on [/guards](/guards).
+
+This repository has no CI, so a guard is not a nice-to-have that runs somewhere in the cloud. It is the only thing standing between a mistake and production. [Repository guards](/docs/guards) explains the system; this page walks you through adding one.
+
+---
+
+## The example
+
+We will build `check-fetch-timeouts`: a guard that refuses to build when server code calls `fetch()` without a timeout.
+
+This is a real class of bug. A `fetch` with no timeout hangs until the platform's own limit kills it, so one slow upstream turns into stacked requests, then a cold pool, then a 502 on an endpoint that has nothing to do with the slow service. It is invisible in review because the line looks completely normal.
+
+---
+
+## Step 1: write the checker
+
+Guards live in `scripts/`. Create `scripts/check-fetch-timeouts.mjs`:
+
+```js
+#!/usr/bin/env node
+// Refuse to build when server code calls fetch() without a timeout.
+//
+// A fetch with no timeout hangs until the platform kills the request, so a
+// single slow upstream becomes stacked requests, an exhausted pool, and 502s on
+// unrelated endpoints. It reads as ordinary code in review, which is why this
+// has to be mechanical.
+
+import { readFileSync, readdirSync, statSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+
+/** Every .js file under a directory, skipping node_modules. */
+function walk(dir, out = []) {
+ for (const entry of readdirSync(dir)) {
+ if (entry === 'node_modules') continue;
+ const full = path.join(dir, entry);
+ if (statSync(full).isDirectory()) walk(full, out);
+ else if (entry.endsWith('.js')) out.push(full);
+ }
+ return out;
+}
+
+const failures = [];
+
+for (const file of walk(path.join(root, 'api'))) {
+ const body = readFileSync(file, 'utf8');
+ body.split('\n').forEach((line, i) => {
+ if (!/\bfetch\s*\(/.test(line)) return;
+ // Conservative on purpose: only flag a fetch whose own line carries no
+ // signal of a timeout. A multi-line call that sets `signal` below is left
+ // alone, because a false positive here gets the whole guard switched off.
+ if (/signal|timeout|AbortController|withTimeout/i.test(line)) return;
+ if (/^\s*(\/\/|\*)/.test(line)) return;
+ failures.push(`${path.relative(root, file)}:${i + 1}`);
+ });
+}
+
+if (failures.length) {
+ console.error(`[check-fetch-timeouts] ${failures.length} fetch call(s) with no timeout:`);
+ for (const f of failures) console.error(`[check-fetch-timeouts] ${f}`);
+ console.error('[check-fetch-timeouts] Pass an AbortSignal, or use the shared withTimeout helper.');
+ process.exit(1);
+}
+
+console.log('[check-fetch-timeouts] OK: every server fetch sets a timeout');
+```
+
+Three things to copy from this, because they are what keep a guard alive:
+
+- **The header is a post-mortem.** State the failure that motivated the guard. Without it, a future maintainer reads a check that has never fired and deletes it.
+- **It is conservative.** It skips any line that even mentions a timeout. Missing a real violation is recoverable; a false positive means somebody removes the guard entirely.
+- **The failure message says what to do.** "Pass an AbortSignal, or use the shared `withTimeout` helper" is actionable. "Invalid fetch" is not.
+
+---
+
+## Step 2: give it an npm script
+
+A guard nobody can run is a guard nobody runs. In `package.json`:
+
+```json
+"check:fetch-timeouts": "node scripts/check-fetch-timeouts.mjs"
+```
+
+Verify it:
+
+```bash
+npm run check:fetch-timeouts
+```
+
+---
+
+## Step 3: register it
+
+Add an entry to `data/guards.json`. This is what [/guards](/guards) renders and what [Repository guards](/docs/guards) documents, so the registry is the single source of truth rather than a copy of one:
+
+```json
+{
+ "id": "check-fetch-timeouts",
+ "script": "scripts/check-fetch-timeouts.mjs",
+ "npm": "check:fetch-timeouts",
+ "title": "Server fetch timeouts",
+ "protects": "No server-side fetch can hang without a timeout.",
+ "why": "A fetch with no timeout turns one slow upstream into stacked requests and 502s on unrelated endpoints. It reads as ordinary code in review.",
+ "stages": ["gate"],
+ "needs": "none"
+}
+```
+
+Every field is required, and `audit-guards` enforces that, because a guard with no `why` is one nobody dares delete and nobody understands.
+
+---
+
+## Step 4: wire it into a stage
+
+Registering is a claim; wiring makes it true. Add it to the `gate` chain in `package.json`:
+
+```json
+"gate": "npm run check:conflicts && npm run check:claude && ... && npm run check:fetch-timeouts"
+```
+
+Now run the registry auditor:
+
+```bash
+npm run audit:guards
+```
+
+If you skip this step, it fails with exactly the mismatch:
+
+```
+[audit-guards] guard `check-fetch-timeouts` claims it runs in `gate` but it is
+not in the gate chain. Wire it there, or correct the stage in data/guards.json.
+```
+
+That message is the point of the whole registry. Documentation drifts from reality silently; this turns the drift into a failed command.
+
+### Which stage?
+
+| Stage | Use it when | Cost budget |
+|---|---|---|
+| `prebuild` | The guard checks something the build itself generates. | Under a second. |
+| `gate` | Offline, deterministic, no credentials. Most guards belong here. | A few seconds. |
+| `build:gcp` | It can only judge a finished artifact, like `dist/`. | Seconds. |
+| `pre-push` | It judges commit content and must not be skippable. | Under a second. |
+| `manual` | It needs a browser, live credentials, or the network. | Any. |
+
+Anything needing the network or credentials goes in `manual`. A flaky guard on an automatic path gets bypassed, and once people are in the habit of bypassing, every other guard on that path is weaker too.
+
+---
+
+## Step 5: test it
+
+A guard with no test rots into a no-op, and you find out when the thing it was supposed to catch ships anyway. Create `tests/check-fetch-timeouts.test.js`:
+
+```js
+import { describe, it, expect, beforeAll, afterAll } from 'vitest';
+import { execFileSync } from 'node:child_process';
+import { mkdtempSync, rmSync, writeFileSync, mkdirSync, copyFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve, dirname } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
+const script = join(repoRoot, 'scripts', 'check-fetch-timeouts.mjs');
+
+let sandbox;
+
+/** A miniature repo with one api/ file, so the real script can run against it. */
+function makeRepo(name, contents) {
+ const dir = join(sandbox, name);
+ mkdirSync(join(dir, 'api'), { recursive: true });
+ mkdirSync(join(dir, 'scripts'), { recursive: true });
+ copyFileSync(script, join(dir, 'scripts', 'check-fetch-timeouts.mjs'));
+ writeFileSync(join(dir, 'api', 'handler.js'), contents);
+ return dir;
+}
+
+function run(dir) {
+ try {
+ return { code: 0, out: execFileSync('node', [join(dir, 'scripts', 'check-fetch-timeouts.mjs')], { encoding: 'utf8' }) };
+ } catch (err) {
+ return { code: err.status, out: `${err.stdout || ''}${err.stderr || ''}` };
+ }
+}
+
+beforeAll(() => {
+ sandbox = mkdtempSync(join(tmpdir(), 'fetch-timeouts-'));
+});
+afterAll(() => {
+ rmSync(sandbox, { recursive: true, force: true });
+});
+
+describe('check-fetch-timeouts', () => {
+ it('passes when the fetch carries a signal', () => {
+ const dir = makeRepo('ok', 'await fetch(url, { signal: AbortSignal.timeout(5000) });\n');
+ expect(run(dir).code).toBe(0);
+ });
+
+ it('fails on a bare fetch and names the line', () => {
+ const dir = makeRepo('bad', 'const a = 1;\nawait fetch(url);\n');
+ const { code, out } = run(dir);
+ expect(code).toBe(1);
+ expect(out).toContain('api/handler.js:2');
+ });
+
+ it('ignores a fetch mentioned in a comment', () => {
+ // The false positive that would get this guard deleted.
+ const dir = makeRepo('comment', '// call fetch(url) here later\nexport const ok = 1;\n');
+ expect(run(dir).code).toBe(0);
+ });
+});
+```
+
+Run it:
+
+```bash
+npx vitest run tests/check-fetch-timeouts.test.js
+```
+
+Note the third test. It is not padding. It encodes the false positive that would get the guard switched off, so nobody can "simplify" the check later and reintroduce it.
+
+Build the sandbox rather than pointing the test at the real repository. A test that asserts on real files fails the moment somebody adds an unrelated `fetch`, and a test that edits real files races every other agent working in the tree.
+
+---
+
+## Step 6: document it
+
+Add a row to the relevant table in [`docs/guards.md`](/docs/guards), and add a `data/changelog.json` entry if the guard changes what contributors have to do.
+
+---
+
+## Checklist
+
+Your guard is done when all of these are true:
+
+- [ ] `scripts/check-<thing>.mjs` exists, exits non-zero with an actionable message, and opens with the incident that motivated it.
+- [ ] An npm script runs it.
+- [ ] `data/guards.json` has an entry with `title`, `protects`, `why`, and `stages`.
+- [ ] It is wired into the chain for every stage it claims.
+- [ ] `npm run audit:guards` passes.
+- [ ] A test covers the pass case, the fail case, and at least one false positive it must not report.
+- [ ] `npm run gate` still passes.
+
+---
+
+## Related
+
+- [Repository guards](/docs/guards): every existing guard, its stage, and the design principles.
+- [/guards](/guards): the registry as a browsable page.
+- [Start here](/docs/start-here): what three.ws is, if you landed here first.
diff --git a/public/guards.json b/public/guards.json
new file mode 100644
index 000000000..27713dc55
--- /dev/null
+++ b/public/guards.json
@@ -0,0 +1,400 @@
+{
+ "updated": "2026-07-30",
+ "summary": "Every mechanical guard that protects this repository, and the stage each one runs in. This file is the single source of truth: scripts/audit-guards.mjs proves every entry is real and every stage claim is true, docs/guards.md explains them, and /guards renders them.",
+ "stages": [
+ {
+ "id": "prebuild",
+ "title": "Prebuild",
+ "when": "Every `npm run build`, automatically.",
+ "description": "Runs before any bundle is produced. These guards regenerate the page index and then immediately re-audit it, so a page can never be advertised and unreachable in the same build."
+ },
+ {
+ "id": "gate",
+ "title": "Gate",
+ "when": "`npm run gate`, before you call a feature done.",
+ "description": "The composite correctness sweep: the CLAUDE.md truth check, the critical-path tests, and every offline audit. Ordered cheapest first, so a merge-conflict marker fails in seconds instead of after the test stage."
+ },
+ {
+ "id": "build:gcp",
+ "title": "Deploy build",
+ "when": "`npm run build:gcp`, before an image is submitted to Cloud Build.",
+ "description": "Guards that can only judge a finished artifact: the browser bundle, the contents of dist/, and whether every declared page actually resolves against the route table."
+ },
+ {
+ "id": "pre-push",
+ "title": "Pre-push",
+ "when": "Automatically, on `git push`.",
+ "description": "Installed into .git/hooks by scripts/setup-git-hooks.mjs on every npm install. Judges exactly the commits leaving the machine and never the shared working tree, so a concurrent agent's in-flight edit can never block your push. Bypass once with SKIP_PUSH_CHECKS=1."
+ },
+ {
+ "id": "manual",
+ "title": "On demand",
+ "when": "Run it yourself when you touch the area it covers.",
+ "description": "Guards that need a browser, live credentials, or a network round trip, so they cannot sit on an automatic path without making it flaky. Each one has an npm script so it is discoverable rather than buried in scripts/."
+ }
+ ],
+ "guards": [
+ {
+ "id": "check-merge-conflicts",
+ "script": "scripts/check-merge-conflicts.mjs",
+ "npm": "check:conflicts",
+ "title": "Merge-conflict markers",
+ "protects": "No unresolved conflict marker can be built or deployed.",
+ "why": "A stash-pop conflict was once committed wholesale and reached production source. A conflict marker is a syntax error rather than a lint violation, so neither eslint nor vitest caught it. It runs first in both chains because it costs seconds and the build costs minutes.",
+ "stages": [
+ "gate",
+ "build:gcp"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "check-claude-md",
+ "script": "scripts/check-claude-md.mjs",
+ "npm": "check:claude",
+ "title": "CLAUDE.md truth check",
+ "protects": "Every script, path, count, and runbook step named in CLAUDE.md matches the repo.",
+ "why": "Agents execute CLAUDE.md verbatim, so a stale line does not read as stale, it reads as an instruction. Each claim is re-derived from its source of truth on every run: the cron count from vercel.json, the deploy chain order from the real npm script, the documented git remotes from git itself.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "check-rules",
+ "script": "scripts/check-rules.mjs",
+ "npm": "check:rules",
+ "title": "Hard rules, diff scoped",
+ "protects": "The CLAUDE.md hard rules on the lines you actually changed.",
+ "why": "A repo-wide sweep is impossible because thousands of tracked files predate the rules. Reading added lines only stops the bleeding without rewriting history: your change is held to the bar, the legacy around it is left alone. It also synthesizes hunks for untracked files, which a bare git diff cannot see.",
+ "stages": [
+ "pre-push"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "check-cron-drift",
+ "script": "scripts/check-cron-drift.mjs",
+ "npm": "check:cron-drift",
+ "npmAliases": [
+ "check:cron-syntax"
+ ],
+ "title": "Cron schedule drift",
+ "protects": "Every cron declared in vercel.json is a valid expression, and matches what Cloud Scheduler is actually running.",
+ "why": "vercel.json is a live config file: the scheduler sync seeds Cloud Scheduler from its crons array. A schedule edited without a re-sync, or a job paused by hand during an incident and never resumed, fails silently because the declared config still looks right. The offline half validates expressions and runs in the gate; the live half compares against the running jobs.",
+ "stages": [
+ "gate",
+ "manual"
+ ],
+ "needs": "gcloud"
+ },
+ {
+ "id": "audit-page-index",
+ "script": "scripts/audit-page-index.mjs",
+ "npm": "audit:pages",
+ "title": "Route documentation",
+ "protects": "Every human-facing route in vercel.json is documented in data/pages.json.",
+ "why": "data/pages.json feeds the sitemap, llms.txt, features.json, and the changelog. A page missing from it is invisible to crawlers and to the changelog, so it ships without ever being announced.",
+ "stages": [
+ "prebuild",
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "check-pages",
+ "script": "scripts/check-pages.mjs",
+ "npm": "check:pages",
+ "title": "Declared pages resolve",
+ "protects": "Every page declared in data/pages.json is actually reachable.",
+ "why": "Anything listed in pages.json is advertised to crawlers the moment it lands. Two pages shipped as hard 404s in three days, each with a built dist file and no route rewrite. The local mode gates the deploy build; the base-url mode sweeps a live deployment after it.",
+ "stages": [
+ "build:gcp"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "verify-routes",
+ "script": "scripts/verify-routes.mjs",
+ "npm": "audit:routes",
+ "title": "Routing and 404 model",
+ "protects": "Every catalog page is reachable, unknown paths reach the designed 404, and no page route is shadowed by an earlier rule.",
+ "why": "The route table is evaluated in order and split at the filesystem marker, so an earlier catch-all can swallow a later literal route. A handler can be routed and still never run, which is invisible until someone reports the endpoint dead.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-empty-handlers",
+ "script": "scripts/audit-empty-handlers.mjs",
+ "npm": "audit:handlers",
+ "title": "API handlers export a body",
+ "protects": "No API handler ships as an empty file or without an export.",
+ "why": "The api tree uses a dispatcher-shim pattern where a real endpoint can be a one-line re-export, which makes an accidentally empty handler look normal in review and return nothing in production.",
+ "stages": [
+ "prebuild",
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-hidden-guard",
+ "script": "scripts/audit-hidden-guard.mjs",
+ "npm": "audit:hidden-guard",
+ "title": "The [hidden] guard",
+ "protects": "Every page resolves the CSS that makes the hidden attribute actually hide.",
+ "why": "The hidden HTML attribute only hides an element while some stylesheet maps it. A page that misses that rule renders its hidden scaffolding to real users. This is the verifier half of an inject-and-audit pair.",
+ "stages": [
+ "prebuild",
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-docs",
+ "script": "scripts/audit-docs.mjs",
+ "npm": "audit:docs",
+ "title": "Documentation integrity",
+ "protects": "No dead relative link, no site link that matches no route, no command naming a script that no longer exists, and no packages or workers directory without a README.",
+ "why": "Docs rot silently: a page gets renamed, a script gets dropped, a directory moves, and the doc that pointed at it keeps looking correct. Renaming or deleting a file is exactly when this earns its keep.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-x402-catalog",
+ "script": "scripts/audit-x402-catalog.mjs",
+ "npm": "audit:x402-catalog",
+ "title": "x402 endpoint catalog",
+ "protects": "Every paid endpoint under api/x402 is documented in the public catalog.",
+ "why": "Each paid endpoint is a sellable product an agent can discover and call. One that exists but is undocumented earns nothing, because no buyer can find it.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-mcp-manifests",
+ "script": "scripts/audit-mcp-manifests.mjs",
+ "npm": "audit:mcp",
+ "title": "MCP manifests",
+ "protects": "Every MCP registry manifest satisfies the official registry's rules, offline.",
+ "why": "The official registry enforces these rules at publish time, so a manifest that drifts past them blocks the next publish instead of failing here, where it is cheap to fix.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-mcp-golden",
+ "script": "scripts/audit-mcp-golden.mjs",
+ "npm": "audit:mcp-golden",
+ "title": "MCP golden contracts",
+ "protects": "Tool names, descriptions, annotations, and input schemas of every hosted MCP server, against a committed snapshot.",
+ "why": "That contract is what external agents integrate against, so a well-meaning description edit silently changes how other people's agents route. It parses the sources statically rather than importing them, because importing would pull in database and RPC clients.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-mcp-safety",
+ "script": "scripts/audit-mcp-safety.mjs",
+ "npm": "audit:mcp-safety",
+ "title": "MCP safety annotations",
+ "protects": "Every MCP tool's declared safety annotations match what its handler actually does.",
+ "why": "Annotations are not decoration: clients read readOnlyHint and destructiveHint to decide what may run without asking a human. A tool that writes while claiming to be read-only removes a confirmation the user was relying on.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-token-drift",
+ "script": "scripts/audit-token-drift.mjs",
+ "npm": "audit:tokens",
+ "title": "Design-token ratchet",
+ "protects": "Hardcoded colour hexes cannot creep back past a committed baseline.",
+ "why": "public/tokens.css is the single source of truth for colour primitives, but a big-bang cleanup of every legacy hex is not possible. Counting violations against a baseline and failing only when the count rises makes the debt strictly decreasing.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "check-browser-graph",
+ "script": "scripts/check-browser-graph.mjs",
+ "npm": "check:browser-graph",
+ "title": "Browser bundle purity",
+ "protects": "No Node-only module leaks into the browser bundle.",
+ "why": "A Node builtin pulled into browser code does not fail the build, it fails at runtime in the user's tab, usually on a page nobody tested after the import was added.",
+ "stages": [
+ "build:gcp"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "check-dist",
+ "script": "scripts/check-dist.mjs",
+ "npm": "check:dist",
+ "title": "Build output shape",
+ "protects": "dist/ contains every artifact the deploy expects, including the UMD library bundle.",
+ "why": "The frontend build empties dist/, so anything written before it is destroyed. This fails the build when the order was wrong instead of shipping an image missing its pages or its library.",
+ "stages": [
+ "build:gcp"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-deploy-artifacts",
+ "script": "scripts/audit-deploy-artifacts.mjs",
+ "npm": "audit:deploy",
+ "title": "Deploy artifact preflight",
+ "protects": "The two artifact failure classes that have taken production down.",
+ "why": "Both are invisible in a diff and obvious in seconds if something looks. Running it before a submit costs nothing next to a failed Cloud Build.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "check-gcloudignore",
+ "script": "scripts/check-gcloudignore.mjs",
+ "npm": "check:gcloudignore",
+ "title": "Cloud Build upload contents",
+ "protects": "What `gcloud builds submit` would actually upload.",
+ "why": "An over-broad ignore file silently drops a file the build needs; an under-broad one uploads gigabytes of node_modules and times out. Neither is visible until the build runs.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "gcloud"
+ },
+ {
+ "id": "audit-links",
+ "script": "scripts/audit-links.mjs",
+ "npm": "audit:links",
+ "title": "Site link integrity",
+ "protects": "Every navigable target across pages, public, and src resolves to a real route or file.",
+ "why": "It resolves each link against the real routing model rather than assuming the catch-all rules count as proof, so a dead internal path cannot hide behind a wildcard that would serve a 404 page.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-console",
+ "script": "scripts/audit-console.mjs",
+ "npm": "audit:console",
+ "title": "Console sweep",
+ "protects": "A clean browser console on every canonical route, at desktop and mobile widths.",
+ "why": "A clean console is part of the definition of done, and the only way to prove it is to drive the real pages in a real browser. Environment noise is filtered so the output is signal.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "browser"
+ },
+ {
+ "id": "audit-image-loading",
+ "script": "scripts/audit-image-loading.mjs",
+ "npm": "check:images",
+ "title": "Image loading attributes",
+ "protects": "Every JS-rendered image sets its loading and decoding attributes.",
+ "why": "These images pull remote thumbnails and avatars. Without the attributes the browser blocks rendering on images far below the fold, which shows up as a slow page rather than as an error.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "audit-garments",
+ "script": "scripts/audit-garments.mjs",
+ "npm": "audit:garments",
+ "title": "Wardrobe catalog integrity",
+ "protects": "Every garment in the live catalog validates, and its GLB hash matches its manifest.",
+ "why": "It runs the same validation the closet runs at consume time, against the real fetched asset, so a re-uploaded or corrupted GLB is caught before a user wears it.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "network"
+ },
+ {
+ "id": "audit-rig-coverage",
+ "script": "scripts/audit-rig-coverage.mjs",
+ "npm": "audit:rig-coverage",
+ "title": "Rig coverage",
+ "protects": "How well the canonicalizer maps the skeletons actually stored in production.",
+ "why": "The bone-name tables grew by anticipating rig conventions, and anticipation is not evidence. This walks real avatars and ranks the unmapped bone names by frequency, so the next mapping to add is a measurement rather than a guess.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "credentials"
+ },
+ {
+ "id": "audit-service-wallets",
+ "script": "scripts/audit-service-wallets.mjs",
+ "npm": "audit:service-wallets",
+ "title": "Service wallet configuration",
+ "protects": "Every platform wallet's on-chain balance, its floor, and whether the advertised x402 fee payer matches the secret we actually co-sign with.",
+ "why": "An advertised fee-payer that does not match the configured secret silently 502s paid endpoints, and a wallet under its floor pauses its engine. Both look identical from outside and have different fixes.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "credentials"
+ },
+ {
+ "id": "audit-wallet-flows",
+ "script": "scripts/audit-wallet-flows.mjs",
+ "npm": "audit:wallet-flows",
+ "title": "Fleet wallet flows",
+ "protects": "Where the platform's SOL is, where it has been going, and whether any of it is leaking.",
+ "why": "Every time the paid rail goes dry the first theory is a leak. This separates the three real answers by measurement: capital dispersed into agent wallets, a starved fee floor, and an actual unexplained debit.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "credentials"
+ },
+ {
+ "id": "check-relayer-balances",
+ "script": "scripts/check-relayer-balances.mjs",
+ "npm": "check:relayer-balances",
+ "title": "Relayer balances",
+ "protects": "Every configured Solana signer is above its documented minimum.",
+ "why": "The operator companion to the balance watchdog cron, run on demand from a machine that holds the signer secrets. Unconfigured signers are listed explicitly so the real deployment's holdings are visible at a glance.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "credentials"
+ },
+ {
+ "id": "audit-guards",
+ "script": "scripts/audit-guards.mjs",
+ "npm": "audit:guards",
+ "title": "The guard registry itself",
+ "protects": "Every entry in this file names a real script and a real npm script, every guard on disk is registered, and every stage claim matches the npm chain that would actually run it.",
+ "why": "This registry is rendered by docs/guards.md and by /guards, so a stale stage column does not read as stale, it reads as coverage a reader then stops looking for. Listing itself is not circular: it verifies its own script, npm binding, and gate membership exactly like every other entry.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none"
+ },
+ {
+ "id": "check-erc7710-addresses",
+ "script": "scripts/check-erc7710-addresses.js",
+ "npm": "check:erc7710",
+ "title": "Delegation contract addresses",
+ "protects": "Every address in the delegation-manager deployment table is a deployed contract on its chain.",
+ "why": "A wrong or undeployed address fails only at the moment a user signs, which is the worst possible time to discover a typo in a constant.",
+ "stages": [
+ "manual"
+ ],
+ "needs": "network"
+ }
+ ],
+ "exempt": [
+ {
+ "pattern": "scripts/verify-*.mjs",
+ "reason": "One-off integration verifiers for a specific vendor surface or world build, not repository guards. They prove an external service works, so they belong with that feature rather than in a guard stage."
+ }
+ ]
+}
diff --git a/scripts/audit-guards.mjs b/scripts/audit-guards.mjs
index c8cae1e84..ec75dfe7a 100644
--- a/scripts/audit-guards.mjs
+++ b/scripts/audit-guards.mjs
@@ -143,6 +143,21 @@ for (const rel of onDisk) {
);
}
+// The published copy the /guards page fetches. data/ is never served, so the
+// page reads public/guards.json; if the two drift, the page and docs/guards.md
+// show different answers and neither looks wrong on its own.
+{
+ const publicPath = 'public/guards.json';
+ if (!existsSync(path.join(root, publicPath))) {
+ note(`${publicPath} is missing, so /guards has nothing to render. Run \`npm run build:guards\`.`);
+ } else {
+ const expected = `${JSON.stringify(registry, null, '\t')}\n`;
+ if (read(publicPath) !== expected) {
+ note(`${publicPath} is out of date with data/guards.json, so /guards would render stale content. Run \`npm run build:guards\`.`);
+ }
+ }
+}
+
if (failures.length) {
console.error(`[audit-guards] ${failures.length} problem(s) between data/guards.json and the repo:`);
for (const f of failures) console.error(`[audit-guards] ${f}`);
diff --git a/scripts/build-guards.mjs b/scripts/build-guards.mjs
new file mode 100644
index 000000000..fd4b71819
--- /dev/null
+++ b/scripts/build-guards.mjs
@@ -0,0 +1,44 @@
+#!/usr/bin/env node
+// Publish data/guards.json to public/guards.json, which the /guards page fetches.
+//
+// data/ is source and is never served, so a page cannot read the registry
+// directly. Every other registry here follows the same shape (pages.json feeds
+// features.json, the changelog feeds changelog.json), and the generated copy is
+// committed so the page works from a clean checkout without a build step.
+//
+// Staleness is the obvious failure: someone edits the registry, never rebuilds,
+// and /guards shows last week's answer while docs/guards.md shows this week's.
+// scripts/audit-guards.mjs fails the gate when the two disagree, so this is a
+// closed loop rather than a convention.
+//
+// Run: node scripts/build-guards.mjs (wired as `npm run build:guards`)
+
+import { readFileSync, writeFileSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+
+/** The exact bytes public/guards.json must contain for a given registry. */
+export function renderPublicGuards(registry) {
+ return `${JSON.stringify(registry, null, '\t')}\n`;
+}
+
+const src = path.join(root, 'data/guards.json');
+const out = path.join(root, 'public/guards.json');
+const registry = JSON.parse(readFileSync(src, 'utf8'));
+const body = renderPublicGuards(registry);
+
+let previous = null;
+try {
+ previous = readFileSync(out, 'utf8');
+} catch {
+ previous = null;
+}
+
+if (previous === body) {
+ console.log(`[build-guards] public/guards.json already current (${registry.guards.length} guards)`);
+} else {
+ writeFileSync(out, body);
+ console.log(`[build-guards] wrote public/guards.json (${registry.guards.length} guards, ${registry.stages.length} stages)`);
+}