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.

Complete avatar-animation-hardening Task 4: regression corpus + fallen-pose guard

nirholasc8fcd1d729f8
diff --git a/prompts/avatar-animation-hardening/04-regression-corpus-and-runtime-guard.md b/prompts/avatar-animation-hardening/04-regression-corpus-and-runtime-guard.md
deleted file mode 100644
index b5a0c0c19..000000000
--- a/prompts/avatar-animation-hardening/04-regression-corpus-and-runtime-guard.md
+++ /dev/null
@@ -1,68 +0,0 @@
-# Task 4 — Cross-rig regression corpus + runtime "fallen pose" guard
-
-> Read [00-README.md](./00-README.md) first. **Depends on Task 1** (benefits from Task 2). Follow
-> [CLAUDE.md](../../CLAUDE.md).
-
-This is the "zero error, stays shipped" guarantee. The lying-down bug shipped because nothing
-asserted that an animated avatar stays upright. This task locks that invariant in tests across a
-corpus of rig conventions **and** adds a runtime guard that catches any future regression in
-production and degrades gracefully instead of showing a body on its back.
-
-## What to build
-
-### 1. A deterministic cross-rig regression corpus
-- New test suite (e.g. `tests/animation-upright-invariant.test.js`) that, for a corpus of rig
- conventions × the `FEATURED` clips ([src/animation-presets.js](../../src/animation-presets.js)),
- retargets and asserts the **upright invariant**: the Hips world up-axis stays within a small
- tolerance of vertical at **every keyframe** (not just frame 0). Use the world-matrix
- reconstruction technique from the diagnosis (raw GLB parse → Bone graph → compose) so it runs in
- Node with no browser.
-- Corpus must include the two committed real GLBs — **cz.glb** (Avaturn, identity convention) and
- **michelle.glb** (Mixamo, `−90°X` Hips) — plus synthetic rigs covering: a non-`±90` armature
- rotation, `DEF-`/snake_case bone names, and a missing-bones rig (coverage below
- `MIN_COVERAGE`). The michelle + celebrate case is the **named regression lock** for this bug.
-- Assert the no-regression invariant too: cz.glb retarget output is byte-for-byte equal to the
- verbatim path.
-
-### 2. Runtime "fallen pose" guard
-- In [src/animation-manager.js](../../src/animation-manager.js) (or the viewer), after a clip is
- bound/first played, sample the rig's root/Hips world up-axis. If it tilts beyond a threshold at
- rest (a sign the retarget produced a fallen pose), treat it as a failure: skip/disable that
- action and fall back to the authored bind pose (the viewer already prefers the authored pose
- over a broken retarget — reuse that path), and report once via the existing client-error channel
- (`/api/client-errors`, logged `[client-error]`) with enough context (avatar id/url, clip,
- measured tilt) to diagnose. **No console spam, no per-frame checks** — sample once per
- attach/clip, debounced.
-- The guard must never fire for healthy rigs (cz, michelle-post-fix). Make the threshold generous
- (e.g. > 45°) so it only catches genuine catastrophes, and prove it stays silent on the corpus.
-
-### 3. Make it a gate
-- Ensure the new suite runs under `npm test` and therefore gates the Vercel build (the only
- automated gate per repo memory). Keep it fast (raw parse, no GLTFLoader).
-
-## Definition of done
-- Cross-rig upright-invariant suite covering ≥4 conventions × featured clips, with michelle +
- celebrate as an explicit named regression test; all green.
-- cz.glb byte-for-byte no-regression assertion present and green.
-- Runtime fallen-pose guard wired: detects, falls back to bind pose, reports once via
- `/api/client-errors`; proven silent on healthy rigs.
-- `npm test` + `npm run typecheck` green; suite is part of the gate.
-- Changelog entry if user-visible (reliability/self-healing). `completionist` run; findings fixed.
-- Handoff note for Task 6 (which surfaces to spot-check live).
-
-Do not push unless the user approves (then both remotes).
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-The moment every item above is **built, wired, verified, and committed**, remove it in the same
-change:
-
-```bash
-git rm "prompts/avatar-animation-hardening/04-regression-corpus-and-runtime-guard.md"
-```
-
-Stage the deletion in the completion commit. A file that still exists is unfinished work.
diff --git a/prompts/avatar-animation-hardening/06-final-qa-and-promote.md b/prompts/avatar-animation-hardening/06-final-qa-and-promote.md
index bb7c8a0ce..b6eee1283 100644
--- a/prompts/avatar-animation-hardening/06-final-qa-and-promote.md
+++ b/prompts/avatar-animation-hardening/06-final-qa-and-promote.md
@@ -7,6 +7,39 @@ Tasks 1–5 fix the math, the ingest path, the regression guard, and the embed U
the whole thing is production-ready end to end: every surface that renders an animated avatar is
correct, polished, and free of console errors, on a representative matrix of avatars and clips.
+## Handoff from Task 4 (regression corpus + runtime fallen-pose guard)
+
+Shipped and committed; build on it, don't redo it:
+
+- **Regression corpus** — [tests/animation-upright-invariant.test.js](../../tests/animation-upright-invariant.test.js)
+ asserts the Hips world up-axis stays within **40°** of vertical at *every* keyframe across 4
+ rig conventions (cz Avaturn, michelle Mixamo `−90°X`, a synthetic `+90°Z`/`−90°Z`,
+ DEF-/snake_case names) × the `FEATURED` clips, plus a below-`MIN_COVERAGE` missing-bones rig.
+ **michelle + celebrate is the named regression lock** for the lying-down bug, with explicit
+ "has teeth" cases proving the verbatim (no-correction) path still falls flat (>80°). cz.glb is
+ asserted **byte-for-byte equal** to the verbatim path (the `1.7°→1.7°` no-regression invariant).
+ Runs in plain Node via a raw GLB JSON-chunk → Bone-graph reconstruction
+ ([tests/_helpers/glb-bone-graph.js](../../tests/_helpers/glb-bone-graph.js)) — no GLTFLoader,
+ no network — so it gates the Vercel build. 49 cases, all green.
+- **Runtime guard** — [src/animation-manager.js](../../src/animation-manager.js): `measureHipsTiltDeg`
+ + `_guardAgainstFallenPose` sample the at-rest Hips tilt **once per (avatar, clip)** before an
+ action plays (never per frame). Past `CATASTROPHE_TILT_DEG` (**45°**) it disables the action,
+ falls back to the authored bind pose, and reports **once** (Set-debounced) via
+ `window.reportClientError` → `/api/client-errors` with `{avatarId, avatarUrl, clip, tiltDeg}`.
+ The viewer wires avatar context at [src/viewer.js:1008](../../src/viewer.js#L1008)
+ (`attach(content, { avatarUrl })`).
+- **For your QA:** the guard must stay **silent** on every healthy avatar/clip you exercise — a
+ `[client-error] fallen-pose retarget` log line during the matrix run is a real regression, not
+ noise. To confirm the guard *fires* correctly, you don't need a broken avatar in the browser;
+ the corpus already proves the fire path (`michelle + celebrate` without the fix measures >45°).
+- **Note on the full suite:** Task 4's animation suites are green (106/106) and `typecheck` is
+ 0 errors. If you see failures in `tests/api/marketplace-platform-fee.test.js` (vitest can't
+ resolve a `?cb=` dynamic import), `tests/branding.test.js` (Avaturn/Character Studio strings in
+ docs), `tests/src/usdz-pipeline.test.js` (meshopt decoder absent in Node), or `all-modules-load`
+ (unbuilt local workspace SDKs), those are **environment/build artifacts** — run the postinstall
+ ESM fixups and build the `agent-payments-sdk`/`solana-agent-sdk` workspaces, they are unrelated
+ to animation.
+
## What to do
### 1. Build the verification matrix