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.

test: repair 15 failing repo, registry and animation suites, and gate the pay registry check

nirholasa7cb189f639f
diff --git a/data/guards.json b/data/guards.json
index 15b48367d..0c945bf8b 100644
--- a/data/guards.json
+++ b/data/guards.json
@@ -463,6 +463,27 @@
"expect": "MCP resource/prompt listings are stale"
}
},
+ {
+ "id": "check-pay-skills",
+ "script": "scripts/build-pay-skills.mjs",
+ "npm": "check:pay-skills",
+ "title": "pay registry provider listings",
+ "protects": "The committed provider files under distributions/pay-skills/ are exactly what api/_lib/service-catalog/pay-skills.js generates from the service catalog today, with no stale or orphaned file.",
+ "why": "Publishing to the pay registry is a copy of this directory, and its paths, schemas and prices are projected from the same catalog and price functions the live 402 challenges use. A catalog change that nobody regenerated would publish listings that quote a price or a route production no longer serves, and an agent paying from that listing would be charged against the wrong contract.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none",
+ "proof": {
+ "summary": "A committed provider listing edited by hand, so it no longer matches what the catalog generates.",
+ "violation": {
+ "write": {
+ "distributions/pay-skills/providers/three-ws/3d/PAY.md": "Hand-edited listing that no catalog generated.\n"
+ }
+ },
+ "expect": "stale: distributions/pay-skills/providers/three-ws/3d/PAY.md"
+ }
+ },
{
"id": "audit-mcp-manifests",
"script": "scripts/audit-mcp-manifests.mjs",
diff --git a/docs/guards.md b/docs/guards.md
index a2b25054f..5361391f9 100644
--- a/docs/guards.md
+++ b/docs/guards.md
@@ -161,6 +161,7 @@ Run `npm run audit:guards` to print the current count and per-stage breakdown. T
| MCP tool catalog freshness | `npm run audit:mcp-catalog` | `public/mcp-catalog.json` matches what the MCP servers actually expose. |
| MCP directory listing source | `npm run audit:mcp-listing` | The one file every third-party MCP directory listing is written from still matches the manifests, and no new server lands without listing copy. |
| MCP resource and prompt listings | `npm run audit:mcp-surfaces` | Every hosted MCP server's registry manifest and `public/.well-known/mcp.json` list exactly the resources, templates and guided prompts the code serves. |
+| pay registry provider listings | `npm run check:pay-skills` | The provider files in `distributions/pay-skills/` are exactly what the service catalog generates, so a published listing never quotes a route or price production no longer serves. |
| 3D Studio OpenAPI sync | `npm run check:studio-openapi` | The Actions file in the OpenAI submission kit is byte-identical to the OpenAPI schema the site serves. |
| Live event window | `npm run check:event` | `public/event.json` describes an event that will actually happen, on every surface that reads it. |
| Cron schedule drift | `npm run check:cron-syntax`, `npm run check:cron-drift` | Valid expressions, and agreement with the running Cloud Scheduler jobs. |
diff --git a/docs/ops/guard-wiring.md b/docs/ops/guard-wiring.md
index d1746f4c9..ccd87daa5 100644
--- a/docs/ops/guard-wiring.md
+++ b/docs/ops/guard-wiring.md
@@ -59,12 +59,15 @@ belongs on the deploy path, in `npm test`, or in an operator's hands.
| `check:images` | Every JS-rendered `<img>` in `src/` declares a `loading` attribute | 0 | 10.6s | `gate` |
| `audit:route-shadowing` | No `api/**` handler is unreachable behind a broader route rule | 0 | 9.3s | `gate` |
| `check:docs-freshness` | Whether each doc's prose still matches the code it names, against the budget in `data/docs-freshness-budget.json` | 0 | 11s | `gate` |
-| `audit:deploy` | Committed symlinks, unsatisfied peers, undeclared api imports, and the Draco/KTX2 decoder assets in `dist/` | 0 | 5.2s | `deploy:gcp:submit` |
+| `check:pay-skills` | The committed `distributions/pay-skills/` provider files against a fresh projection of the service catalog, including orphaned files | 0 | 1.2s | `gate` |
+| `audit:deploy` | Committed symlinks, unsatisfied peers, undeclared api imports, an installed `node_modules` that matches `package-lock.json`, and the Draco/KTX2 decoder assets in `dist/` | 0 | 5.2s | `deploy:gcp:submit` |
`audit:deploy` is the one that is not a `gate` guard despite being green, repo-only and fast.
-Three of its four checks are already covered by
+Four of its five checks are already covered by
[tests/deploy-artifacts.test.js](../../tests/deploy-artifacts.test.js), which imports the same
-functions, so `npm test` runs them. The fourth, `findMissingDistAssets()`, returns
+functions, so `npm test` runs them. The lockfile check, `findLockDrift()`, joined them on
+2026-09-18 after a dependency bump nobody reinstalled shipped untested and every paid x402 route
+answered 500 on import. The fifth, `findMissingDistAssets()`, returns
`{ skipped: true }` whenever `dist/` is absent, which is always true in vitest and always true
in `gate`. It only means anything after a build, so it is wired into `deploy:gcp:submit` ahead
of the upload, where a missing decoder asset (the /scene Draco outage) is still cheap to fix.
@@ -98,7 +101,6 @@ in both the registry and the runbook.
| `audit:route-shadowing` | `GET /api/agents/vitals`, documented in `docs/agent-vitals.md` and announced in the changelog, resolved to `api/agents/[id].js` instead of its own handler | Explicit `vercel.json` rule above the `/api/agents/([^/]+)` catch-all |
| `check:doc-media` | 30 problems: `scene-studio` never captured, and 29 `usedBy` claims naming docs that embedded no figure at all | Captured `scene-studio`; embedded all 20 figures with their alt text and captions in the 27 docs that claimed them |
| `check:runnable-docs` | 8 documented curl samples no longer answered as documented | 7 declared their real contract (`<!-- runnable: 401 ... -->` for the two session-gated calls, `404`/`400` for the five illustrative ids and placeholders). The eighth is a deploy lag, below. |
-| `check:windows-widget:live` | The same Windows widget contract against what three.ws is really serving: the deployed manifest, the worker bytes, the picker assets, and whether the deployed Adaptive Card expands in the board's engine | 1 | 4.1s | **manual (post-deploy).** Its 5 findings are one defect: production serves a card whose expressions the board's own engine refuses (`Invalid expression format`), so every pinned slot draws empty. The card in this tree expands cleanly, so the fix ships with the next deploy; re-run after it. |
## Still unwired, with the reason
@@ -113,6 +115,7 @@ They belong to an operator, or to a post-deploy check.
| Guard | What it checks | Exit | Runtime | Verdict |
|---|---|---|---|---|
| `check:runnable-docs` | Executes every runnable sample in `docs/` against the live API | 1 | 15s | **manual (post-deploy).** One finding left: `/api/v1/hood-portfolios/universe` 404s because `api/v1/hood-portfolios/universe.js` landed 2026-09-07 and production runs the 2026-09-05 image. Declaring `404` would be wrong the moment it deploys. Re-run after the next deploy. |
+| `check:windows-widget:live` | The same Windows widget contract against what three.ws is really serving: the deployed manifest, the worker bytes, the picker assets, and whether the deployed Adaptive Card expands in the board's engine | 1 | 4.1s | **manual (post-deploy).** Its 5 findings are one defect: production serves a card whose expressions the board's own engine refuses (`Invalid expression format`), so every pinned slot draws empty. The card in this tree expands cleanly, so the fix ships with the next deploy; re-run after it. |
| `audit:seo` | Titles, descriptions, canonicals and sitemap agreement, fetched as Googlebot | 0 | 17.2s | **manual (post-deploy).** Fetches `https://three.ws`. |
| `check:asset-encoding` | The largest compressible files under `public/`, fetched from the live site with a browser's exact `Accept-Encoding`, checking the bytes received against what the response promised | 0 | 8.4s | **manual (post-deploy).** Requests `https://three.ws`, so it measures the CDN rather than the diff: it exists because a brotli body served under an uncompressed `content-length` hung `/create/selfie` for every Chrome and Edge on 2026-09-11, and a page check never reads the largest binary on the site. Re-run after a deploy that changes a large asset. |
| `audit:ibm-hosted` | The IBM-hosted page against a local publisher plus live three.ws | 1 | 15.7s | **manual.** Its 6 findings are all CORS refusals of `https://three.ws/*.js` from a `127.0.0.1` publisher origin, which is the harness's origin, not a page defect. Needs the real IBM origin to mean anything. |
@@ -123,6 +126,7 @@ They belong to an operator, or to a post-deploy check.
| `audit:llm-metering` | Whether any lane that spends money reports exactly $0 | 0 | 1.7s | **manual (ops).** Reads `usage_events` from the live database; its answer is about production spend, not about the diff. |
| `check:erc7710` | Every `DELEGATION_MANAGER_DEPLOYMENTS` address is a deployed contract | 0 | 3.0s | **manual.** `eth_getCode` against public RPCs; a third-party RPC outage would read as a red gate. |
| `check:evm-rpc` | Every EVM RPC endpoint answers a keyless server-side POST, in priority order | 0 | 8.6s | **manual (ops).** Network by definition. |
+| `check:xai-models` | The Grok model catalog (`GROK_MODELS` in `api/_lib/chat-models.js`) against the ids, context sizes and prices xAI actually serves | 0 | 0.5s | **manual (ops).** Reads `api.x.ai` with `GROK_API_KEY` or `XAI_API_KEY`, else xAI's public model docs, so its answer moves whenever xAI ships or retires a model, not when the diff changes. Exit 2 means the source could not be read. Run it when the Grok rung of a failover chain starts erroring. |
| `audit:deps` | The Python workers' pinned deps against the OSV vulnerability database | 1 | 16.6s | **manual (security sweep).** 285 advisories across 17 pinned versions, mostly `transformers` (two are RCE, fixed in 5.0.0 and 5.3.0). Each fix is a pin bump plus a worker image rebuild, which is its own piece of work, not a gate. |
| `audit:upstreams:map` | Not a guard: `--map` regenerates `docs/resilience.md` | 0 | 38.6s | **manual (generator).** The guard half, `audit:upstreams`, is already in `gate`. |
@@ -155,7 +159,7 @@ viewports. They are pre-event, pre-release and incident tools.
| `audit:csp` | Every CSP violation in a real browser | 2 | 6.0s | **manual (post-build).** Defaults to `127.0.0.1:8099`; it reported "25 of 25 pages never loaded, so this run proves nothing", which is the honest answer with nothing serving a built `dist/` there. Run it as `npm run audit:csp -- --base https://three.ws`. |
| `check:home-voice` | The hands-free voice loop: wake word, barge-in, self-trigger, confirmation guards | 2 | 11.2s | **manual.** Starts its own server and drives real speech lanes. |
| `audit:garments` | Every wardrobe garment: manifest validation, GLB hash, attach, walk-gait deviation | 1 | 133s | **manual.** Real finding: 1 hard failure and 4 review flags out of 59. Owned by [fix-queue](../../prompts/finish/_context/fix-queue-00-INDEX.md). |
-| `check:glb:payload` | The mobile payload budget for a high-resolution GLB, loaded under WebKit and Android Chrome | 1 | 17.4s | **manual.** Its script is currently untracked working-tree work belonging to another session; the run dies on `ENOENT` writing `public/_payload-check/`, which that session owns. |
+| `check:glb:payload` | The mobile payload budget for a high-resolution GLB, loaded under WebKit and Android Chrome | 1 | 17.4s | **manual.** Needs `npm run dev` serving `/avatar-embed`, one or more GLB paths as arguments, and Playwright's WebKit and Chromium. It stages derived files under the gitignored `public/_payload-check/` and exits 1 when either engine fails to render the finished GLB. The measured run predates the script being committed and died on `ENOENT` writing that directory. |
### Deterministic problems, deliberately not gated
@@ -169,12 +173,14 @@ viewports. They are pre-event, pre-release and incident tools.
|---|---|
| `check:rules` | The pre-push hook, as `--base <remote sha> --head <local sha>` per pushed ref (`scripts/setup-git-hooks.mjs:66`). Push-scoped is the point: it judges the commits leaving the machine, never the shared working tree, and it also lints each pushed commit subject. The bare npm script (17.5s) scans the whole worktree and would fail on other agents' in-flight work. |
| `check:secrets` | The same hook, the same push-scoped mode, one line later, so no credential material leaves the machine. |
+| `check:community-skills` | `prebuild`, as `node scripts/build-community-registry.mjs --check` directly, so every build fails on a malformed community skill or a stale `community-skills/registry.json`. The npm script is the same check by hand (0.4s, green). |
+| `check:sri-pins` | `check:dist` runs the same `checkPins()` on every `build:gcp`, and [tests/agent-3d-releases.test.js](../../tests/agent-3d-releases.test.js) runs it under `npm test`. The npm script (0.4s, green) exists for `-- --fix`, which rewrites stale documented pins from `data/agent-3d-releases.json`. |
## Nothing was deleted
Every guard measured here does something no other check does. `audit:deploy` was the one
-candidate for deletion, since `npm test` already imports three of its four functions, but its
-fourth check only fires after a build, so it moved to the deploy path instead of going away.
+candidate for deletion, since `npm test` already imports four of its five functions, but its
+decoder-asset check only fires after a build, so it moved to the deploy path instead of going away.
`check:docs-search` looked like a decoy (its message told you to commit a gitignored file) and
would have been a delete, except three open work orders under `prompts/finish/` invoke it as a
local check; its message was corrected instead.
diff --git a/package.json b/package.json
index fff716d40..d627b46a9 100644
--- a/package.json
+++ b/package.json
@@ -252,7 +252,7 @@
"audit:route-shadowing": "node scripts/audit-route-shadowing.mjs",
"audit:handlers": "node scripts/audit-empty-handlers.mjs",
"audit:x402-catalog": "node scripts/audit-x402-catalog.mjs",
- "gate": "npm run check:conflicts && npm run check:claude && npm run check:vendored && npm run check:model-viewer && npm run check:gcloudignore && npm run check:fetch-timeouts && npm run check:tdz-bootstrap && npm run check:event && npm run check:cron-syntax && npm run check:home-matrix && npm run check:studio-openapi && npm run test:gate && npm run test:gate-3d && npm run audit:mcp && npm run audit:mcp-golden && npm run audit:mcp-safety && npm run audit:mcp-catalog && npm run check:mcp-catalog && npm run audit:mcp-listing && npm run audit:mcp-surfaces && npm run audit:routes && npm run audit:handlers && npm run audit:pages && npm run audit:links && npm run check:awesome && npm run check:prompt-library && npm run audit:docs && npm run check:docs-freshness && npm run audit:upstreams && npm run check:tutorials && npm run audit:hidden-guard && npm run audit:inline-handlers && npm run audit:x402-catalog && npm run audit:tokens && npm run audit:states && npm run audit:motion-tokens && npm run audit:guards && npm run audit:tour-atlas && npm run check:ios-icons && npm run check:macos-icon && npm run check:apple-widget && npm run check:ios-app && npm run check:windows-widget && npm run check:announce && npm run i18n:home && npm run check:skills-seed && npm run check:openai-skills && npm run check:skills-pack && npm run check:skill-repos && npm run check:openai-fields && npm run audit:motion && npm run audit:tour-global && npm run check:doc-media && npm run check:images && npm run audit:route-shadowing",
+ "gate": "npm run check:conflicts && npm run check:claude && npm run check:vendored && npm run check:model-viewer && npm run check:gcloudignore && npm run check:fetch-timeouts && npm run check:tdz-bootstrap && npm run check:event && npm run check:cron-syntax && npm run check:home-matrix && npm run check:studio-openapi && npm run test:gate && npm run test:gate-3d && npm run audit:mcp && npm run audit:mcp-golden && npm run audit:mcp-safety && npm run audit:mcp-catalog && npm run check:mcp-catalog && npm run audit:mcp-listing && npm run audit:mcp-surfaces && npm run check:pay-skills && npm run audit:routes && npm run audit:handlers && npm run audit:pages && npm run audit:links && npm run check:awesome && npm run check:prompt-library && npm run audit:docs && npm run check:docs-freshness && npm run audit:upstreams && npm run check:tutorials && npm run audit:hidden-guard && npm run audit:inline-handlers && npm run audit:x402-catalog && npm run audit:tokens && npm run audit:states && npm run audit:motion-tokens && npm run audit:guards && npm run audit:tour-atlas && npm run check:ios-icons && npm run check:macos-icon && npm run check:apple-widget && npm run check:ios-app && npm run check:windows-widget && npm run check:announce && npm run i18n:home && npm run check:skills-seed && npm run check:openai-skills && npm run check:skills-pack && npm run check:skill-repos && npm run check:openai-fields && npm run audit:motion && npm run audit:tour-global && npm run check:doc-media && npm run check:images && npm run audit:route-shadowing",
"test:gate-3d": "vitest run tests/glb-canonicalize.test.js tests/animation-retarget.test.js tests/animation-retarget-rest-pollution.test.js tests/viewer-framing.test.js",
"audit:mcp-golden": "node scripts/audit-mcp-golden.mjs",
"audit:mcp-safety": "node scripts/audit-mcp-safety.mjs",
@@ -344,6 +344,7 @@
"build:walk-environments": "node scripts/build-walk-environments.mjs",
"build:trench-car": "node scripts/build-trench-car.mjs",
"build:artifact-viewer": "node scripts/build-artifact-viewer.mjs",
+ "build:agent-hints": "node scripts/build-agent-hints.mjs",
"build:lib": "TARGET=lib vite build",
"build:lib:full": "TARGET=lib LIB_FORMATS=es,umd vite build",
"build:avatar-sdk": "node avatar-sdk/build.mjs",
diff --git a/public/agent-hints.json b/public/agent-hints.json
index b9963617a..aea5e561c 100644
--- a/public/agent-hints.json
+++ b/public/agent-hints.json
@@ -52,6 +52,21 @@
"validate-model"
]
},
+ {
+ "hint": "celebrate",
+ "slot": "celebrate",
+ "clip": "celebrate",
+ "skills": [
+ "jupiter-swap",
+ "paired-launch",
+ "pons-launch",
+ "pumpfun-claim-fees",
+ "pumpfun-create",
+ "pumpfun-launch-from-agent",
+ "pumpfun-self-launch",
+ "pumpfun-self-launch-from-identity"
+ ]
+ },
{
"hint": "curiosity",
"slot": "curiosity",
@@ -66,19 +81,6 @@
"pumpfun.watchWhales"
]
},
- {
- "hint": "celebrate",
- "slot": "celebrate",
- "clip": "celebrate",
- "skills": [
- "jupiter-swap",
- "pumpfun-claim-fees",
- "pumpfun-create",
- "pumpfun-launch-from-agent",
- "pumpfun-self-launch",
- "pumpfun-self-launch-from-identity"
- ]
- },
{
"hint": "think",
"slot": "think",
@@ -159,5 +161,5 @@
]
}
],
- "total_skills": 67
+ "total_skills": 69
}
diff --git a/public/guards.json b/public/guards.json
index 15b48367d..0c945bf8b 100644
--- a/public/guards.json
+++ b/public/guards.json
@@ -463,6 +463,27 @@
"expect": "MCP resource/prompt listings are stale"
}
},
+ {
+ "id": "check-pay-skills",
+ "script": "scripts/build-pay-skills.mjs",
+ "npm": "check:pay-skills",
+ "title": "pay registry provider listings",
+ "protects": "The committed provider files under distributions/pay-skills/ are exactly what api/_lib/service-catalog/pay-skills.js generates from the service catalog today, with no stale or orphaned file.",
+ "why": "Publishing to the pay registry is a copy of this directory, and its paths, schemas and prices are projected from the same catalog and price functions the live 402 challenges use. A catalog change that nobody regenerated would publish listings that quote a price or a route production no longer serves, and an agent paying from that listing would be charged against the wrong contract.",
+ "stages": [
+ "gate"
+ ],
+ "needs": "none",
+ "proof": {
+ "summary": "A committed provider listing edited by hand, so it no longer matches what the catalog generates.",
+ "violation": {
+ "write": {
+ "distributions/pay-skills/providers/three-ws/3d/PAY.md": "Hand-edited listing that no catalog generated.\n"
+ }
+ },
+ "expect": "stale: distributions/pay-skills/providers/three-ws/3d/PAY.md"
+ }
+ },
{
"id": "audit-mcp-manifests",
"script": "scripts/audit-mcp-manifests.mjs",
diff --git a/scripts/prepare-deploy-worktree.mjs b/scripts/prepare-deploy-worktree.mjs
index 106388940..2f295141c 100644
--- a/scripts/prepare-deploy-worktree.mjs
+++ b/scripts/prepare-deploy-worktree.mjs
@@ -18,8 +18,8 @@
// avatar-studio vite build, which gets OOM-killed (exit 144) on a box
// already hosting concurrent agent builds. Both land several minutes in.
// 3. `cp -al` across a filesystem boundary. Hardlinks cannot span devices, so
-// a worktree staged outside /workspaces silently falls back to nothing at
-// all: cp exits non-zero and the tree is left half-staged.
+// a worktree staged on another filesystem than the repo silently falls
+// back to nothing at all: cp exits non-zero and the tree is left half-staged.
//
// This script closes all three: it BUILDS a missing artifact instead of failing
// on it, stages every one of them, and verifies the hardlink target shares a
@@ -27,9 +27,10 @@
//
// node scripts/prepare-deploy-worktree.mjs plan only, writes nothing
// node scripts/prepare-deploy-worktree.mjs --apply stage the worktree
-// node scripts/prepare-deploy-worktree.mjs --apply --path /workspaces/.deploy-wt-2
+// node scripts/prepare-deploy-worktree.mjs --apply --path ../.deploy-wt-2
//
-// --path (default /workspaces/.deploy-wt) lets concurrent agents stage their own
+// --path (default .deploy-wt beside the repo, so /workspaces/.deploy-wt in the
+// codespace) lets concurrent agents stage their own
// tree instead of colliding on the shared default. --force replaces an existing
// tree at that path, but only when clean-deploy-worktrees.mjs would have judged
// it reclaimable, so a tree holding uncommitted work is never destroyed.
@@ -47,7 +48,7 @@ const APPLY = process.argv.includes('--apply');
const FORCE = process.argv.includes('--force');
const TARGET = (() => {
const i = process.argv.indexOf('--path');
- const raw = i === -1 ? '/workspaces/.deploy-wt' : process.argv[i + 1];
+ const raw = i === -1 ? path.join(path.dirname(ROOT), '.deploy-wt') : process.argv[i + 1];
if (!raw || raw.startsWith('--')) fail('--path needs a directory argument');
return path.resolve(raw);
})();
diff --git a/tests/combat-system.test.js b/tests/combat-system.test.js
new file mode 100644
index 000000000..72d825833
--- /dev/null
+++ b/tests/combat-system.test.js
@@ -0,0 +1,13 @@
+// The /play combat client (src/game/combat-system.js) pulls in the shared
+// server world data (multiplayer/src/world-features.js, items.js), the HUD and
+// its own stylesheet at module load. A broken import anywhere in that graph
+// takes the whole Play world down on first paint, so this pins that the module
+// loads and still exports the class coincommunities.js constructs.
+import { describe, it, expect } from 'vitest';
+
+describe('combat-system module', () => {
+ it('loads its import graph and exports CombatSystem', async () => {
+ const m = await import('../src/game/combat-system.js');
+ expect(typeof m.CombatSystem).toBe('function');
+ });
+});
diff --git a/tests/eidon-imu-clip.test.js b/tests/eidon-imu-clip.test.js
index c0449aba4..1ccd23fab 100644
--- a/tests/eidon-imu-clip.test.js
+++ b/tests/eidon-imu-clip.test.js
@@ -50,6 +50,15 @@ function mounting(distalPrior, secondaryPrior, tiltDeg) {
return columns(distal, secondary, new Vector3().crossVectors(distal, secondary)).invert();
}
+/**
+ * The synthetic recording's clock starts 42 ms in, like a real one that never
+ * begins on a round timestamp, so truth index i was stamped at i / SAMPLE_HZ + 42 ms.
+ */
+const CLOCK_OFFSET_S = 0.042;
+
+/** Mean body heading of the synthetic wearer, degrees about world up. */
+const MEAN_HEADING_DEG = 35;
+
/** Scripted routine: returns shoulder flexion, elbow flexion and wrist wobble (degrees) at time t. */
function routine(t) {
if (t < 6) return { shoulder: 0, elbow: 0, wrist: 0 };
@@ -78,11 +87,11 @@ function simulate(seconds = 40) {
const frames = Math.round(seconds * SAMPLE_HZ);
for (let i = 0; i < frames; i++) {
const t = i / SAMPLE_HZ;
- const timeMs = Math.round(t * 1000) + 42;
+ const timeMs = Math.round((t + CLOCK_OFFSET_S) * 1000);
const { shoulder, elbow, wrist } = routine(t);
// Body: a constant heading plus a lean about the left axis and a small yaw wobble.
const lean = 6 * Math.sin(t * 0.5);
- const body = axisAngle(up, 35 + 4 * Math.sin(t * 0.3)).multiply(axisAngle(v(0, 1, 0), lean));
+ const body = axisAngle(up, MEAN_HEADING_DEG + 4 * Math.sin(t * 0.3)).multiply(axisAngle(v(0, 1, 0), lean));
const forward = v(1, 0, 0).applyQuaternion(body);
const left = v(0, 1, 0).applyQuaternion(body);
const bodyUp = v(0, 0, 1).applyQuaternion(body);
@@ -113,9 +122,25 @@ function simulate(seconds = 40) {
push(slots.hand, handWorld);
perSide[side] = { armDistal, foreDistal };
}
- truth.push({ t, shoulder, elbow, wrist, lean, forward, left, bodyUp, ...perSide });
+ // Per-arm truth lives under `arms`: spreading it would let its `left` key
+ // overwrite the body's left axis.
+ truth.push({ t, shoulder, elbow, wrist, lean, forward, left, bodyUp, arms: perSide });
}
- return { rows, truth };
+ return { rows, truth, mounts };
+}
+
+/** A segment axis (x = distal, y = anterior or dorsal) in its sensor's frame, from the true mounting. */
+const mountedAxis = (mount, axis) => axis.clone().applyQuaternion(mount.clone().invert());
+
+/**
+ * A world direction in the character frame the converter targets (+x left,
+ * +y up, +z forward), taking the wearer's mean upright heading as the frame.
+ */
+function inCharacterFrame(world) {
+ const heading = axisAngle(v(0, 0, 1), MEAN_HEADING_DEG);
+ const left = v(0, 1, 0).applyQuaternion(heading);
+ const forward = v(1, 0, 0).applyQuaternion(heading);
+ return v(world.dot(left), world.z, world.dot(forward));
}
/** World rotation of every bone in a clip frame, composed from the clip's own local tracks. */
@@ -142,7 +167,7 @@ function boneDirection(world, bone, child) {
}
describe('eidon imu clip: calibration from a synthetic wearer', () => {
- const { rows, truth } = simulate();
+ const { rows, truth, mounts } = simulate();
const frames = alignFrames(rows);
const cal = calibrate(frames);
@@ -168,8 +193,21 @@ describe('eidon imu clip: calibration from a synthetic wearer', () => {
expect(q.anteriorFromPrior).not.toBeNull();
expect(q.dorsalFromPrior).not.toBeNull();
for (const value of Object.values(q.distalFromPrior)) expect(value).not.toBeNull();
- // The mountings were tilted 9-18 degrees off the prior, and the estimate should follow the tilt, not the prior.
- expect(q.anteriorFromPrior).toBeGreaterThan(4);
+ // The mountings were tilted 9-18 degrees off the prior, so every estimate
+ // must land closer to the true mounting than the prior does. (How far the
+ // tilt moves one axis depends on the axis, so a fixed distance from the
+ // prior would not prove the estimate followed the data.)
+ const s = cal.sides[side];
+ const arm = side === 'left' ? SLOT.leftArm : SLOT.rightArm;
+ const foreArm = side === 'left' ? SLOT.leftForeArm : SLOT.rightForeArm;
+ for (const slot of [arm, foreArm]) {
+ const trueDistal = mountedAxis(mounts[slot], v(1, 0, 0));
+ expect(angle(s.distal[slot], trueDistal)).toBeLessThan(angle(v(...HARNESS_PRIOR.distal[slot]), trueDistal));
+ }
+ const trueAnterior = mountedAxis(mounts[arm], v(0, 1, 0));
+ expect(angle(s.anterior, trueAnterior)).toBeLessThan(angle(perp(v(...HARNESS_PRIOR.anterior[arm]), s.distal[arm]), trueAnterior));
+ const trueDorsal = mountedAxis(mounts[foreArm], v(0, 1, 0));
+ expect(angle(s.dorsal, trueDorsal)).toBeLessThan(angle(perp(v(...HARNESS_PRIOR.dorsal[foreArm]), s.distal[foreArm]), trueDorsal));
}
});
@@ -187,7 +225,7 @@ describe('eidon imu clip: baked motion on the canonical rig', () => {
const cal = calibrate(frames);
const clip = bakeClip(frames, cal, { name: 'synthetic', idle, start: 2, end: 36, loop: false });
const fps = 30;
- const truthAt = (clipTime) => truth[Math.round((2 + clipTime) * SAMPLE_HZ)];
+ const truthAt = (clipTime) => truth[Math.round((2 + clipTime - CLOCK_OFFSET_S) * SAMPLE_HZ)];
it('has every idle track, at 30 fps, over the requested window', () => {
expect(clip.tracks.map((t) => t.name)).toEqual(idle.tracks.map((t) => t.name));
@@ -212,14 +250,22 @@ describe('eidon imu clip: baked motion on the canonical rig', () => {
it('hangs the arms straight down and raises them forward when the wearer reaches', () => {
const at = (clipTime) => worldRotations(clip, Math.round(clipTime * fps));
- const hanging = at(1);
- expect(angle(boneDirection(hanging, 'LeftArm', 'LeftForeArm'), v(0, -1, 0))).toBeLessThan(4);
- expect(angle(boneDirection(hanging, 'RightArm', 'RightForeArm'), v(0, -1, 0))).toBeLessThan(4);
+ // The upper arm hangs along the torso, which the wearer leans up to 6
+ // degrees, so the expected direction is the wearer's own arm in the
+ // character frame rather than a fixed straight down.
+ const expectArm = (pose, clipTime, tolerance) => {
+ for (const [side, bone] of [['left', 'Left'], ['right', 'Right']]) {
+ const expected = inCharacterFrame(truthAt(clipTime).arms[side].armDistal);
+ expect(angle(boneDirection(pose, `${bone}Arm`, `${bone}ForeArm`), expected)).toBeLessThan(tolerance);
+ }
+ };
+ // t = 3 s in the routine (1 s into the clip): both arms hang.
+ expect(truthAt(1).shoulder).toBe(0);
+ expectArm(at(1), 1, 4);
// t = 23 s in the routine (21 s into the clip): shoulder 60 degrees forward, elbow about 90.
const reaching = at(21);
- const expectedArm = v(0, -Math.cos(60 / DEG), Math.sin(60 / DEG));
- expect(angle(boneDirection(reaching, 'LeftArm', 'LeftForeArm'), expectedArm)).toBeLessThan(5);
- expect(angle(boneDirection(reaching, 'RightArm', 'RightForeArm'), expectedArm)).toBeLessThan(5);
+ expect(truthAt(21).shoulder).toBe(60);
+ expectArm(reaching, 21, 5);
// The flexed forearm points up and forward (elbow flexes toward the anterior side), never backward.
const fore = boneDirection(reaching, 'LeftForeArm', 'LeftHand');
expect(fore.z).toBeGreaterThan(0.3);
@@ -227,8 +273,12 @@ describe('eidon imu clip: baked motion on the canonical rig', () => {
});
it('keeps the level forearm palm-down: its dorsal side faces up', () => {
- // t = 14.8 s: elbow near 100 degrees with the upper arm hanging, so the forearm is roughly level.
- const frame = Math.round((14.8 - 2) * fps);
+ // t = 13.25 s: (t - 6) * 1.3 = 3 pi puts the elbow at its 100 degree peak
+ // while the shoulder is back at rest, so the upper arm hangs and the forearm
+ // is roughly level.
+ expect(truthAt(11.25).shoulder).toBeLessThan(1);
+ expect(truthAt(11.25).elbow).toBeGreaterThan(99);
+ const frame = Math.round((13.25 - 2) * fps);
const world = worldRotations(clip, frame);
const restDorsal = v(0, 1, 0).applyQuaternion(new Quaternion().fromArray(CANONICAL_REST_WORLD.LeftForeArm).invert());
const dorsal = restDorsal.applyQuaternion(world.LeftForeArm);
@@ -237,10 +287,12 @@ describe('eidon imu clip: baked motion on the canonical rig', () => {
it('leans the torso with the chest sensor and leaves the legs on the idle clip', () => {
const spine2 = (clipTime) => worldRotations(clip, Math.round(clipTime * fps)).Spine2;
+ // The unmeasured bones play the idle time-warped to whole cycles inside the
+ // window (see bakeClip), so the reference must read the idle at that time.
+ const idleCycles = Math.max(1, Math.round(clip.duration / idle.duration));
const idleSpine2 = (clipTime) => {
- const idleClip = { ...idle, tracks: idle.tracks };
- const frame = Math.round(clipTime * fps) % idle.tracks[0].times.length;
- return worldRotations(idleClip, frame).Spine2;
+ const idleTime = ((clipTime / clip.duration) * idleCycles * idle.duration) % idle.duration;
+ return worldRotations(idle, Math.round(idleTime * fps) % idle.tracks[0].times.length).Spine2;
};
// The lean is 6 degrees at its peak around t = 3.14 s (1.14 s into the clip) and reverses at t = 9.4 s.
const forwardLean = spine2(1.14).angleTo(idleSpine2(1.14)) * DEG;
diff --git a/tests/prepare-deploy-worktree.test.js b/tests/prepare-deploy-worktree.test.js
index 214bc4972..d554a82fb 100644
--- a/tests/prepare-deploy-worktree.test.js
+++ b/tests/prepare-deploy-worktree.test.js
@@ -124,7 +124,9 @@ describe('guards (plan mode, writes nothing)', () => {
});
it('plans without applying by default, and says so', () => {
- const r = plan(['--path', '/workspaces/.deploy-wt-vitest-unused']);
+ // A sibling of the repo shares its filesystem on any machine, which is the
+ // only place a hardlinked deploy tree can live.
+ const r = plan(['--path', path.join(path.dirname(ROOT), '.deploy-wt-vitest-unused')]);
expect(r.code).toBe(0);
expect(r.out).toMatch(/Plan only\. Re-run with --apply/);
for (const a of ARTIFACTS.filter((x) => !x.optional)) expect(r.out).toContain(a.rel);
diff --git a/tests/route-build-inputs.test.js b/tests/route-build-inputs.test.js
index 75d75811e..8b1710446 100644
--- a/tests/route-build-inputs.test.js
+++ b/tests/route-build-inputs.test.js
@@ -20,8 +20,11 @@ const INPUTS = new Set([...vite.matchAll(/resolve\(__dirname,\s*'([^']+\.html)'\
const INPUT_DIRS = [...vite.matchAll(/resolve\(__dirname,\s*'(pages\/[a-z0-9-]+)'\)/g)].map((m) => `${m[1]}/`);
// Destinations produced by a build step rather than a source page: the docs site,
// the blog, news, events and demo pages are generated into dist/ by their own
-// builders, and a capture-group destination ($1) names no single file.
-const GENERATED = /^(docs|blog|news|events|demos)\/|\$\d/;
+// builders, and a capture-group destination ($1) names no single file. The chat
+// sub-app is one of those: `npm run build:chat` writes chat/ into public/chat/
+// (gitignored) and copies it to dist/chat/, and check:dist fails the build when
+// /chat is missing, so a fresh clone that never built it is not a dead route.
+const GENERATED = /^(docs|blog|news|events|demos|chat)\/|\$\d/;
function unbuiltDestinations() {
const missing = new Set();
diff --git a/tests/src/animation-canonical-support.test.js b/tests/src/animation-canonical-support.test.js
index 44f252cfa..a8f9a69d6 100644
--- a/tests/src/animation-canonical-support.test.js
+++ b/tests/src/animation-canonical-support.test.js
@@ -1,24 +1,27 @@
import { describe, it, expect } from 'vitest';
+import { Group, Object3D, SkinnedMesh } from 'three';
import { AnimationManager } from '../../src/animation-manager.js';
import { CANONICAL_BONES } from '../../src/glb-canonicalize.js';
-// AnimationManager.attach() builds a three AnimationMixer over the model but
-// only ever reads `.traverse`, `.isSkinnedMesh`, and `.name` for the canonical
-// support check — so a lightweight fake tree exercises the logic without
-// loading real GLB assets.
+// AnimationManager.attach() reads the model's rest pose (world matrices, rest
+// directions) as well as `.name` and `.isSkinnedMesh`, so the model must be a
+// real three.js scene graph. Plain named Object3D nodes under a Group exercise
+// the canonical support check without loading real GLB assets.
function fakeModel(nodes) {
- const all = [{ name: 'root' }, ...nodes];
- return {
- name: 'root',
- traverse(cb) {
- for (const n of all) cb(n);
- },
- };
+ const root = new Group();
+ root.name = 'root';
+ for (const node of nodes) root.add(node);
+ return root;
+}
+
+function named(node, name) {
+ node.name = name;
+ return node;
}
function boneNodes(names, { skinned = true } = {}) {
- const nodes = names.map((name) => ({ name }));
- if (skinned) nodes.push({ name: 'Body', isSkinnedMesh: true });
+ const nodes = names.map((name) => named(new Object3D(), name));
+ if (skinned) nodes.push(named(new SkinnedMesh(), 'Body'));
return nodes;
}
diff --git a/tests/src/usdz-pipeline.test.js b/tests/src/usdz-pipeline.test.js
index 4d622a8b0..979a0aa73 100644
--- a/tests/src/usdz-pipeline.test.js
+++ b/tests/src/usdz-pipeline.test.js
@@ -130,7 +130,9 @@ if (typeof HTMLCanvasElement !== 'undefined') {
};
}
-const GLB_PATH = path.resolve('/workspaces/three.ws/public/avatars/cz.glb');
+// Repo-relative: this file runs under jsdom, where import.meta.url is not a
+// file: URL, so resolve from the test's own directory instead.
+const GLB_PATH = path.resolve(__dirname, '../../public/avatars/cz.glb');
let glbBlobToUsdzBlob;
let glbBlobToHalfBodyBlob;
diff --git a/tests/zz-probe.test.js b/tests/zz-probe.test.js
deleted file mode 100644
index 60f8a08af..000000000
--- a/tests/zz-probe.test.js
+++ /dev/null
@@ -1,7 +0,0 @@
-import { describe, it, expect } from 'vitest';
-describe('import probe', () => {
- it('imports combat-system', async () => {
- const m = await import('/workspaces/three.ws/src/game/combat-system.js');
- expect(typeof m.CombatSystem).toBe('function');
- });
-});