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.

Add IRL room-anchor: anchor placed agents to a shared room

nirholasd1cd25743fe0
diff --git a/api/irl/pins.js b/api/irl/pins.js
index c788bc436..01828cff7 100644
--- a/api/irl/pins.js
+++ b/api/irl/pins.js
@@ -222,6 +222,20 @@ async function ensureTable() {
await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS avatar_manifest JSONB`;
await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS avatar_base_url TEXT`;
await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS avatar_version INTEGER NOT NULL DEFAULT 0`;
+ // Room frame — shared room-relative anchoring. A pin in a ROOM stores its
+ // EXACT offset (rel_east_m / rel_north_m, metres) from a shared origin
+ // (origin_lat/lng/yaw) instead of relying on its own ~10 m-noisy GPS, so a
+ // cluster keeps its room-scale layout identical for every viewer and the whole
+ // room calibrates with one nudge. lat/lng stay populated (the GPS index +
+ // legacy clients); room_id NULL = a standalone pre-room pin. See
+ // src/irl/room-anchor.js for the geometry these columns feed.
+ await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS room_id TEXT`;
+ await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS rel_east_m DOUBLE PRECISION`;
+ await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS rel_north_m DOUBLE PRECISION`;
+ await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS origin_lat DOUBLE PRECISION`;
+ await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS origin_lng DOUBLE PRECISION`;
+ await sql`ALTER TABLE irl_pins ADD COLUMN IF NOT EXISTS origin_yaw_deg DOUBLE PRECISION`;
+ await sql`CREATE INDEX IF NOT EXISTS irl_pins_room ON irl_pins (room_id) WHERE room_id IS NOT NULL AND hidden_at IS NULL`;
_tableReady = true;
}
@@ -234,6 +248,13 @@ const CAL_MAX_MOVE_M = 5; // ground-move ceiling, metres
const CAL_MAX_YAW_DEG = 46; // yaw-nudge ceiling, degrees
const CAL_MAX_RISE_M = 3; // floor-height nudge ceiling, metres
+// ── Room frame bounds ───────────────────────────────────────────────────────
+// A room id is a short slug (the client derives one per shared-anchor cluster).
+// A relative offset is clamped to a building-scale ceiling so the render frame
+// can't be bent into a cross-map jump, while still covering any real venue.
+const ROOM_ID_RE = /^[a-z0-9-]{1,64}$/;
+const REL_MAX_M = 500;
+
// Smallest signed distance between two compass bearings, 0–180°.
function circularYawDelta(a, b) {
let d = ((a - b) % 360 + 360) % 360;
@@ -414,6 +435,14 @@ function pinWire(row) {
if ('x402_endpoint' in row) w.x402Endpoint = row.x402_endpoint ?? '';
if ('agent_id' in row) w.agentId = row.agent_id ?? '';
if ('placed_at' in row) w.placedAt = row.placed_at ? Date.parse(row.placed_at) || 0 : 0;
+ // Room frame — emit camelCase so the realtime publish wire matches the schema
+ // field names IrlRoom.coerceRoom reads. Only present when the row carries them.
+ if ('room_id' in row) w.roomId = row.room_id ?? '';
+ if ('rel_east_m' in row) w.relEast = Number(row.rel_east_m) || 0;
+ if ('rel_north_m' in row) w.relNorth = Number(row.rel_north_m) || 0;
+ if ('origin_lat' in row) w.originLat = Number(row.origin_lat) || 0;
+ if ('origin_lng' in row) w.originLng = Number(row.origin_lng) || 0;
+ if ('origin_yaw_deg' in row) w.originYawDeg = Number(row.origin_yaw_deg) || 0;
return w;
}
@@ -524,7 +553,8 @@ export default wrap(async (req, res) => {
}
const rows = await sql`
SELECT id, agent_id, lat, lng, heading,
- avatar_url, avatar_name, caption, x402_endpoint, placed_at, avatar_version
+ avatar_url, avatar_name, caption, x402_endpoint, placed_at, avatar_version,
+ room_id, rel_east_m, rel_north_m, origin_lat, origin_lng, origin_yaw_deg
FROM irl_pins
WHERE lat BETWEEN ${minLat} AND ${maxLat}
AND lng BETWEEN ${minLng} AND ${maxLng}
@@ -560,7 +590,8 @@ export default wrap(async (req, res) => {
SELECT id, user_id, device_token, agent_id, lat, lng, heading,
avatar_url, avatar_name, caption, x402_endpoint, placed_at, view_count,
anchor_height_m, anchor_yaw_deg, anchor_quat,
- gps_accuracy_m, altitude_m, anchor_source, avatar_version
+ gps_accuracy_m, altitude_m, anchor_source, avatar_version,
+ room_id, rel_east_m, rel_north_m, origin_lat, origin_lng, origin_yaw_deg
FROM irl_pins
WHERE lat BETWEEN ${lat - latDelta} AND ${lat + latDelta}
AND lng BETWEEN ${lng - lngDelta} AND ${lng + lngDelta}
@@ -592,6 +623,16 @@ export default wrap(async (req, res) => {
gps_accuracy_m: r.gps_accuracy_m,
altitude_m: r.altitude_m,
anchor_source: r.anchor_source,
+ // Room frame — when present (room_id non-null), the viewer renders this
+ // agent from its exact offset relative to the shared origin instead of
+ // its own GPS, so the room-scale layout holds for everyone. Null on
+ // legacy standalone pins → the client falls back to lat/lng.
+ room_id: r.room_id ?? null,
+ rel_east_m: r.rel_east_m,
+ rel_north_m: r.rel_north_m,
+ origin_lat: r.origin_lat,
+ origin_lng: r.origin_lng,
+ origin_yaw_deg: r.origin_yaw_deg,
// C6 — cheap re-skin signal: the viewer diffs this against its loaded
// pin and swaps the GLB when it bumps. (The editable manifest/base URL
// stay owner-private — viewers only ever need the rendered avatar_url.)
@@ -747,12 +788,33 @@ export default wrap(async (req, res) => {
const anchorSource = pose.source === 'webxr' ? 'webxr'
: pose.source === 'gyro-gps:rel' ? 'gyro-gps:rel' : 'gyro-gps';
+ // Room frame (optional) — when the client places into a shared room it sends
+ // the exact offset from the room origin. We persist origin + offset as the
+ // render-authoritative pose; lat/lng above stays the GPS index. An invalid or
+ // absent block leaves every room column NULL → a standalone pin, so old
+ // clients and single-drop placements are unaffected. (See src/irl/room-anchor.js.)
+ const room = (body.room && typeof body.room === 'object') ? body.room : {};
+ const roomOk = ROOM_ID_RE.test(String(room.id || '')) &&
+ Number.isFinite(room.originLat) && room.originLat >= -90 && room.originLat <= 90 &&
+ Number.isFinite(room.originLng) && room.originLng >= -180 && room.originLng <= 180 &&
+ !(room.originLat === 0 && room.originLng === 0) &&
+ Number.isFinite(room.relEast) && Number.isFinite(room.relNorth);
+ const clampRel = (v) => Math.max(-REL_MAX_M, Math.min(REL_MAX_M, v));
+ const roomIdVal = roomOk ? String(room.id) : null;
+ const relEastM = roomOk ? clampRel(room.relEast) : null;
+ const relNorthM = roomOk ? clampRel(room.relNorth) : null;
+ const originLatV = roomOk ? room.originLat : null;
+ const originLngV = roomOk ? room.originLng : null;
+ const originYawV = roomOk && Number.isFinite(room.originYawDeg)
+ ? ((room.originYawDeg % 360) + 360) % 360 : null;
+
const [pin] = await sql`
INSERT INTO irl_pins
(user_id, agent_id, device_token, lat, lng, heading,
avatar_url, avatar_name, caption, x402_endpoint, expires_at,
anchor_height_m, anchor_yaw_deg, anchor_quat,
- gps_accuracy_m, altitude_m, anchor_source, geocell7)
+ gps_accuracy_m, altitude_m, anchor_source, geocell7,
+ room_id, rel_east_m, rel_north_m, origin_lat, origin_lng, origin_yaw_deg)
VALUES (
${userId},
${body.agentId ?? null},
@@ -770,7 +832,13 @@ export default wrap(async (req, res) => {
${gpsAccuracyM},
${altitudeM},
${anchorSource},
- ${cell7 || null}
+ ${cell7 || null},
+ ${roomIdVal},
+ ${relEastM},
+ ${relNorthM},
+ ${originLatV},
+ ${originLngV},
+ ${originYawV}
)
RETURNING *
`;
diff --git a/multiplayer/src/irl-schemas.js b/multiplayer/src/irl-schemas.js
index 706f4f372..6d9a2ed38 100644
--- a/multiplayer/src/irl-schemas.js
+++ b/multiplayer/src/irl-schemas.js
@@ -32,6 +32,17 @@ export class IrlPin extends Schema {
this.x402Endpoint = ''; // optional paid endpoint the IRL Pay button calls
this.agentId = ''; // three.ws agent id this pin embodies (cross-links)
this.placedAt = 0; // epoch ms, for age / ordering on the client
+ // — Room frame (append-only) — shared room-relative anchoring. An agent
+ // placed in a ROOM stores its exact offset from a shared origin instead of
+ // relying on its own (noisy) GPS, so a cluster keeps its room-scale layout
+ // identical for every viewer — see src/irl/room-anchor.js. roomId === ''
+ // means a legacy standalone pin that renders from its absolute lat/lng.
+ this.roomId = ''; // groups agents into one shared local frame
+ this.relEast = 0; // metres east of the room origin (room frame)
+ this.relNorth = 0; // metres north of the room origin (room frame)
+ this.originLat = 0; // room origin latitude (the cluster's GPS index)
+ this.originLng = 0; // room origin longitude
+ this.originYawDeg = 0; // room frame rotation vs true north (0 = aligned)
}
}
defineTypes(IrlPin, {
@@ -45,6 +56,16 @@ defineTypes(IrlPin, {
x402Endpoint: 'string',
agentId: 'string',
placedAt: 'float64',
+ // Append-only (room frame): new fields at the end so a still-connected older
+ // client isn't shifted off the positional binary format mid-deploy. relEast/
+ // relNorth are metres (float32 ≈ 1e-5 m resolution over a building — ample);
+ // the origin is a coordinate, so float64 like lat/lng.
+ roomId: 'string',
+ relEast: 'float32',
+ relNorth: 'float32',
+ originLat: 'float64',
+ originLng: 'float64',
+ originYawDeg: 'float32',
});
// A live viewer present in this geocell — live presence (D2). D1 declared this
diff --git a/multiplayer/src/rooms/IrlRoom.js b/multiplayer/src/rooms/IrlRoom.js
index ced39d283..5469a8aad 100644
--- a/multiplayer/src/rooms/IrlRoom.js
+++ b/multiplayer/src/rooms/IrlRoom.js
@@ -90,6 +90,37 @@ function coercePin(raw) {
x402Endpoint: str(raw.x402Endpoint ?? raw.x402_endpoint, 512),
agentId: str(raw.agentId ?? raw.agent_id, 64),
placedAt,
+ ...coerceRoom(raw),
+ };
+}
+
+// Room-frame fields (append-only). Carried through realtime so a shared cluster
+// renders from its exact relative offsets, not each pin's noisy GPS. Accepts the
+// API's snake_case row (room load) or the webhook's camelCase wire (publish), and
+// clamps the offset to a building-scale ceiling so the synced state can't be bent
+// into a cross-map jump. A missing/empty roomId yields a legacy standalone pin.
+const ROOM_ID_RE = /^[a-z0-9-]{1,64}$/;
+const REL_MAX_M = 500;
+function coerceRoom(raw) {
+ const roomId = String(raw.roomId ?? raw.room_id ?? '').slice(0, 64);
+ if (!roomId || !ROOM_ID_RE.test(roomId)) {
+ return { roomId: '', relEast: 0, relNorth: 0, originLat: 0, originLng: 0, originYawDeg: 0 };
+ }
+ const num = (v) => (Number.isFinite(Number(v)) ? Number(v) : 0);
+ const clampRel = (v) => Math.max(-REL_MAX_M, Math.min(REL_MAX_M, num(v)));
+ const oLat = num(raw.originLat ?? raw.origin_lat);
+ const oLng = num(raw.originLng ?? raw.origin_lng);
+ // An invalid origin demotes the pin to standalone rather than placing a room at 0,0.
+ if (!(oLat >= -90 && oLat <= 90 && oLng >= -180 && oLng <= 180) || (oLat === 0 && oLng === 0)) {
+ return { roomId: '', relEast: 0, relNorth: 0, originLat: 0, originLng: 0, originYawDeg: 0 };
+ }
+ return {
+ roomId,
+ relEast: clampRel(raw.relEast ?? raw.rel_east_m),
+ relNorth: clampRel(raw.relNorth ?? raw.rel_north_m),
+ originLat: oLat,
+ originLng: oLng,
+ originYawDeg: ((num(raw.originYawDeg ?? raw.origin_yaw_deg) % 360) + 360) % 360,
};
}
@@ -201,6 +232,12 @@ export class IrlRoom extends Room {
pin.x402Endpoint = p.x402Endpoint;
pin.agentId = p.agentId;
pin.placedAt = p.placedAt;
+ pin.roomId = p.roomId;
+ pin.relEast = p.relEast;
+ pin.relNorth = p.relNorth;
+ pin.originLat = p.originLat;
+ pin.originLng = p.originLng;
+ pin.originYawDeg = p.originYawDeg;
return pin;
}
@@ -249,6 +286,12 @@ export class IrlRoom extends Room {
pin.x402Endpoint = p.x402Endpoint;
pin.agentId = p.agentId;
pin.placedAt = p.placedAt;
+ pin.roomId = p.roomId;
+ pin.relEast = p.relEast;
+ pin.relNorth = p.relNorth;
+ pin.originLat = p.originLat;
+ pin.originLng = p.originLng;
+ pin.originYawDeg = p.originYawDeg;
}
// Merge only the fields actually present in a partial pin:update wire object
@@ -267,6 +310,21 @@ export class IrlRoom extends Room {
if (raw.caption !== undefined) pin.caption = String(raw.caption || '').slice(0, 200);
if (raw.x402Endpoint !== undefined) pin.x402Endpoint = String(raw.x402Endpoint || '').slice(0, 512);
if (raw.agentId !== undefined) pin.agentId = String(raw.agentId || '').slice(0, 64);
+ // Room-frame fields move together on a room-origin calibrate (the whole
+ // cluster shifts), so a pin:update carrying origin/rel re-merges them. Reuse
+ // the same coerce/clamp; only overwrite when the payload actually re-states
+ // a valid room (an empty/invalid room block leaves the existing frame intact).
+ if (raw.roomId !== undefined || raw.relEast !== undefined || raw.originLat !== undefined) {
+ const r = coerceRoom(raw);
+ if (r.roomId) {
+ pin.roomId = r.roomId;
+ pin.relEast = r.relEast;
+ pin.relNorth = r.relNorth;
+ pin.originLat = r.originLat;
+ pin.originLng = r.originLng;
+ pin.originYawDeg = r.originYawDeg;
+ }
+ }
// placedAt is immutable for a given pin; never patched.
}
diff --git a/src/irl-net.js b/src/irl-net.js
index d992eace3..0f0f37cf1 100644
--- a/src/irl-net.js
+++ b/src/irl-net.js
@@ -147,6 +147,14 @@ export class IrlNet {
x402Endpoint: pin.x402Endpoint,
agentId: pin.agentId,
placedAt: pin.placedAt,
+ // Room frame — present (roomId !== '') when the pin belongs to a shared
+ // room cluster; the renderer prefers these exact offsets over absolute GPS.
+ roomId: pin.roomId,
+ relEast: pin.relEast,
+ relNorth: pin.relNorth,
+ originLat: pin.originLat,
+ originLng: pin.originLng,
+ originYawDeg: pin.originYawDeg,
};
}
diff --git a/src/irl.js b/src/irl.js
index 0f0d890f6..f45a711a1 100644
--- a/src/irl.js
+++ b/src/irl.js
@@ -52,6 +52,7 @@ import { startOnboarding, ensurePermission, needsMotionGesture, setPermissionSta
import { reserveWebGLContext, releaseWebGLContext } from './webgl-budget.js';
import { detectTier, BUDGETS, TIER_ORDER, shiftTier } from './irl/perf-budget.js';
import { sharedGLTFLoader, createLoadQueue } from './irl/load-queue.js';
+import { roomOriginWorld, agentWorldPosition } from './irl/room-anchor.js';
import { loadInto } from './shared/async-state.js';
const AVATAR_URL_DEFAULT = '/avatars/default.glb';
@@ -1133,6 +1134,47 @@ function pinHeightM(pin) {
return (Number.isFinite(h) && Math.abs(h) <= 1) ? h : 0;
}
+// ── Room frame (shared room-relative anchoring) ──────────────────────────────
+// A pin placed in a ROOM carries its EXACT offset from a shared origin instead
+// of trusting its own ~10 m-noisy GPS, so a cluster keeps its room-scale layout
+// identical for every viewer — couch-agent and wall-agent stay metres apart on
+// the right sides no matter how GPS drifts. The math lives in the pure, unit-
+// tested src/irl/room-anchor.js; here we only read it. normalizeStreamPin and
+// the REST projection both deliver these as snake_case, so this reads one shape.
+function pinRoom(pin) {
+ if (!pin || !pin.room_id) return null;
+ const oLat = Number(pin.origin_lat), oLng = Number(pin.origin_lng);
+ if (!Number.isFinite(oLat) || !Number.isFinite(oLng)) return null;
+ return {
+ roomId: pin.room_id,
+ relEast: Number(pin.rel_east_m) || 0,
+ relNorth: Number(pin.rel_north_m) || 0,
+ originLat: oLat,
+ originLng: oLng,
+ originYawDeg: Number(pin.origin_yaw_deg) || 0,
+ };
+}
+
+// World position of a nearby agent in the viewer's frame. Room pins resolve
+// through their shared origin (exact relative layout); legacy standalone pins
+// fall back to their own absolute GPS. Returns {x,y,z}. Requires a GPS fix —
+// callers already gate on gpsState.ready before placing/reprojecting.
+function pinWorldPos(pin) {
+ const room = pinRoom(pin);
+ if (room) {
+ const originWorld = roomOriginWorld(gpsState.lat, gpsState.lng, room.originLat, room.originLng);
+ return agentWorldPosition({
+ originWorld,
+ relEast: room.relEast,
+ relNorth: room.relNorth,
+ heightM: pinHeightM(pin),
+ originYawDeg: room.originYawDeg,
+ });
+ }
+ const wp = gpsToWorld(pin.lat, pin.lng);
+ return { x: wp.x, y: pinHeightM(pin), z: wp.z };
+}
+
// Low-pass the viewer's GPS origin so anchored agents don't swim as GPS jitters
// frame-to-frame. We smooth the ORIGIN, never the pins. A fix worse than the
// reject threshold is dropped outright; a large jump (real walk or a big
@@ -1221,8 +1263,8 @@ function onGPSPosition(pos) {
// The agent being calibrated is driven by the nudge gesture this frame, not
// by GPS — re-apply its working pose against the (possibly shifted) origin.
if (calibrateActive && _cal && _cal.pin === p) { applyCalToGroup(); updatePinRing(p); continue; }
- const wp = gpsToWorld(p.lat, p.lng);
- p.group.position.set(wp.x, pinHeightM(p), wp.z);
+ const wp = pinWorldPos(p);
+ p.group.position.set(wp.x, wp.y, wp.z);
p.distance_m = Math.round(Math.hypot(wp.x, wp.z));
updatePinRing(p);
}
@@ -1727,6 +1769,14 @@ function normalizeStreamPin(w) {
x402_endpoint: w.x402Endpoint || null,
agent_id: w.agentId || null,
placed_at: w.placedAt || null,
+ // Room frame — '' means a standalone pin, so collapse to null to match the
+ // REST projection's null and let pinRoom() treat both shapes identically.
+ room_id: w.roomId || null,
+ rel_east_m: Number.isFinite(w.relEast) ? w.relEast : null,
+ rel_north_m: Number.isFinite(w.relNorth) ? w.relNorth : null,
+ origin_lat: Number.isFinite(w.originLat) ? w.originLat : null,
+ origin_lng: Number.isFinite(w.originLng) ? w.originLng : null,
+ origin_yaw_deg: Number.isFinite(w.originYawDeg) ? w.originYawDeg : null,
};
}
@@ -2135,10 +2185,11 @@ function updatePinRing(pin) {
function spawnNearbyPin(pin) {
const g = new Group();
- const wp = gpsToWorld(pin.lat, pin.lng);
- // Absolute stored pose (A3): floor height + compass yaw, so two devices at the
- // same place see the agent in the same spot and bearing (see pinYawRad/pinHeightM).
- g.position.set(wp.x, pinHeightM(pin), wp.z);
+ const wp = pinWorldPos(pin);
+ // Stored pose: a room pin resolves through its shared origin (exact relative
+ // layout for every viewer); a standalone pin uses its own absolute GPS + compass
+ // yaw. Either way two devices at the same place agree (see pinWorldPos/pinYawRad).
+ g.position.set(wp.x, wp.y, wp.z);
g.rotation.y = pinYawRad(pin);
// Cheap unlit "dot" — the agent's far/low-cost representation (E2). The old
@@ -4481,4 +4532,50 @@ if (import.meta.env.DEV) {
queue: { active: glbQueue.active, pending: glbQueue.pending },
reservedContexts: window.__agent3dReservedContexts,
});
+
+ // Lay out the canonical room scenario as ONE shared room so the room-frame
+ // render path can be verified without a phone: the viewer stands on the origin
+ // facing north (a "cup" dead ahead), an agent on the couch 3 m to the RIGHT
+ // (+X), three agents BEHIND (+Z, distinct), and nothing to the left. Each pin
+ // resolves through pinWorldPos → the shared origin, so __irlRoomCheck() can
+ // confirm the world positions land on the right sides.
+ window.__irlSeedRoom = () => {
+ const origin = { lat: 37.7749, lng: -122.4194 };
+ gpsState.lat = origin.lat; gpsState.lng = origin.lng; gpsState.ready = true;
+ const layout = [
+ { tag: 'couch-right', relEast: 3, relNorth: 0, heading: 270 },
+ { tag: 'behind-1', relEast: -0.5, relNorth: -2.5, heading: 0 },
+ { tag: 'behind-2', relEast: 0.5, relNorth: -3, heading: 0 },
+ { tag: 'behind-3', relEast: 1.5, relNorth: -3.5, heading: 0 },
+ ];
+ const seeded = layout.map((l, i) => {
+ const id = `dev-room-${i}`;
+ if (nearbyPins.find(p => p.id === id)) return null;
+ const entry = {
+ id, lat: origin.lat, lng: origin.lng,
+ heading: l.heading, anchor_yaw_deg: l.heading,
+ avatar_url: AVATAR_URL_DEFAULT, avatar_name: l.tag,
+ caption: '', x402_endpoint: null,
+ room_id: 'dev-room', rel_east_m: l.relEast, rel_north_m: l.relNorth,
+ origin_lat: origin.lat, origin_lng: origin.lng, origin_yaw_deg: 0,
+ distance_m: 0, group: null, labelEl: null, glbLoaded: false,
+ };
+ nearbyPins.push(entry);
+ spawnNearbyPin(entry);
+ return entry;
+ }).filter(Boolean);
+ updateNearbyBadge();
+ log.info(`[irl] seeded ${seeded.length} room pins (couch-right, three behind)`);
+ return seeded.length;
+ };
+ // Assert the seeded room renders on the right sides (no phone needed).
+ window.__irlRoomCheck = () => nearbyPins
+ .filter(p => p.room_id === 'dev-room' && p.group)
+ .map(p => ({
+ tag: p.avatar_name,
+ x: +p.group.position.x.toFixed(2),
+ z: +p.group.position.z.toFixed(2),
+ side: p.group.position.x > 0.5 ? 'right' : p.group.position.x < -0.5 ? 'left' : 'center',
+ depth: p.group.position.z > 0.5 ? 'behind' : p.group.position.z < -0.5 ? 'ahead' : 'level',
+ }));
}
diff --git a/src/irl/room-anchor.js b/src/irl/room-anchor.js
new file mode 100644
index 000000000..8ff8f0371
--- /dev/null
+++ b/src/irl/room-anchor.js
@@ -0,0 +1,207 @@
+// Pure room-relative anchoring math for /irl world-locked agents.
+//
+// Why this exists
+// ───────────────
+// Today every placed agent is anchored to its OWN absolute GPS coordinate. That
+// is fine at city scale ("an agent somewhere in this plaza") but it breaks at
+// ROOM scale: consumer GPS is accurate to ~5–15 m, so two agents you place 3 m
+// apart — one on the couch to your right, one on the wall to your left — fall
+// well inside the same GPS noise. Independent per-agent GPS lets their relative
+// positions smear and even swap sides, and it differs phone-to-phone, so a
+// second viewer never sees the same layout.
+//
+// The fix is a shared ROOM FRAME. A room has ONE origin (a GPS coordinate + a
+// reference bearing). Every agent in the room is stored as an EXACT offset from
+// that origin in metres (relEast / relNorth) plus the bearing it faces. The
+// consequences:
+//
+// • Intra-room geometry is exact and identical for everyone. Couch-agent at
+// (+2 E, +1 N) and wall-agent at (−2 E, +1 N) are always 4 m apart on
+// opposite sides — GPS noise translates the WHOLE cluster together, it can
+// never smear agents relative to each other.
+// • You calibrate the ROOM ONCE, not each agent. Nudging the origin moves the
+// entire cluster, so a single "drag the room onto its real spot" gesture
+// aligns every agent at once.
+// • GPS is demoted to an INDEX: it only decides which room you load and places
+// the cluster roughly in the world. Compass north is the shared reference
+// that lets two phones agree on the frame without a visual scan.
+//
+// This module is the pure geometry that makes that work. No DOM, no Three.js, no
+// I/O — it returns plain numbers/objects so the client constructs Vector3s and
+// the test suite verifies the math directly (mirrors multiplayer/src/
+// irl-reactions.js as a pure, unit-tested policy core).
+//
+// Coordinate conventions — IDENTICAL to src/irl.js, do not drift:
+// World: North = −Z · East = +X · Y = up · 1 unit = 1 metre.
+// Compass: bearing 0–359° clockwise from true north (0 = N, 90 = E).
+// World yaw from a compass bearing: yaw = −(deg · π/180) (matches pinYawRad).
+// Local→world: east → +X, north → −Z.
+
+const DEG = Math.PI / 180;
+
+// Metres per degree. Latitude is effectively constant; longitude shrinks with
+// the cosine of latitude. We project longitude around the ORIGIN's latitude so a
+// room is internally consistent (the few-metre error a degree of cos() drift
+// would add only appears thousands of km away, never within one room).
+export const M_PER_DEG_LAT = 110540;
+export function mPerDegLng(lat) {
+ return 111320 * Math.cos(lat * DEG);
+}
+
+/**
+ * Metres of (lat,lng) east/north of a room origin, in the true-north frame.
+ * @returns {{ east: number, north: number }}
+ */
+export function geoToLocal(originLat, originLng, lat, lng) {
+ return {
+ east: (lng - originLng) * mPerDegLng(originLat),
+ north: (lat - originLat) * M_PER_DEG_LAT,
+ };
+}
+
+/**
+ * Inverse of {@link geoToLocal}: a true-north metre offset back to lat/lng. Used
+ * to persist an agent's absolute coordinate (the GPS index + back-compat with
+ * legacy clients that only read lat/lng) alongside its exact relative offset.
+ * @returns {{ lat: number, lng: number }}
+ */
+export function localToGeo(originLat, originLng, east, north) {
+ return {
+ lat: originLat + north / M_PER_DEG_LAT,
+ lng: originLng + east / mPerDegLng(originLat),
+ };
+}
+
+/**
+ * A compass bearing + distance to an east/north offset. Bearing 0 = north
+ * (+north), 90 = east (+east): east = sin(b), north = cos(b).
+ * @returns {{ east: number, north: number }}
+ */
+export function bearingDistanceToLocal(bearingDeg, distM) {
+ const r = bearingDeg * DEG;
+ return {
+ east: distM * Math.sin(r),
+ north: distM * Math.cos(r),
+ };
+}
+
+/**
+ * Inverse of {@link bearingDistanceToLocal} — for UI readback ("3.0 m · 92°")
+ * and turning a calibration drag back into a stored bearing.
+ * @returns {{ bearingDeg: number, distM: number }}
+ */
+export function localToBearingDistance(east, north) {
+ const distM = Math.hypot(east, north);
+ const bearingDeg = ((Math.atan2(east, north) / DEG) % 360 + 360) % 360;
+ return { bearingDeg, distM };
+}
+
+/**
+ * Rotate a room-frame offset into the true-north frame. A room whose local
+ * "north" axis points at compass bearing `originYawDeg` (0 = aligned to true
+ * north, the default) needs this when projecting to world. With a calibrated
+ * compass every room is true-north aligned and this is identity; the rotation
+ * exists for the graceful-degradation path where no absolute heading is
+ * available and the creator's initial facing defines the frame instead.
+ * @returns {{ east: number, north: number }}
+ */
+export function localToTrueNorth(relEast, relNorth, originYawDeg = 0) {
+ if (!originYawDeg) return { east: relEast, north: relNorth };
+ const f = originYawDeg * DEG;
+ const cos = Math.cos(f), sin = Math.sin(f);
+ return {
+ east: relEast * cos + relNorth * sin,
+ north: -relEast * sin + relNorth * cos,
+ };
+}
+
+/**
+ * The room origin's position in the VIEWER's world frame (relative to the
+ * viewer's own GPS, which sits at the world origin). The client adds each
+ * agent's relative offset to this to place it. Returns plain {x,z} so this
+ * module never imports Three.js.
+ * @returns {{ x: number, z: number }}
+ */
+export function roomOriginWorld(viewerLat, viewerLng, originLat, originLng) {
+ const off = geoToLocal(viewerLat, viewerLng, originLat, originLng);
+ return { x: off.east, z: -off.north }; // east → +X, north → −Z
+}
+
+/**
+ * World position of an agent given its room-relative offset and the room
+ * origin's already-computed world position. This is the hot-path render call.
+ * @param {object} a
+ * @param {{x:number,z:number}} a.originWorld room origin in the viewer's frame
+ * @param {number} a.relEast metres east of origin (room frame)
+ * @param {number} a.relNorth metres north of origin (room frame)
+ * @param {number} [a.heightM] floor offset (Y)
+ * @param {number} [a.originYawDeg] room frame rotation vs true north
+ * @returns {{ x: number, y: number, z: number }}
+ */
+export function agentWorldPosition({ originWorld, relEast, relNorth, heightM = 0, originYawDeg = 0 }) {
+ const tn = localToTrueNorth(relEast, relNorth, originYawDeg);
+ return {
+ x: originWorld.x + tn.east,
+ y: heightM,
+ z: originWorld.z - tn.north, // north = −Z
+ };
+}
+
+/**
+ * World yaw (radians) an agent should face for a given compass bearing.
+ * Re-exported so callers share src/irl.js's pinYawRad convention exactly.
+ */
+export function compassToYaw(deg) {
+ return -(deg * DEG);
+}
+
+/**
+ * "Place an agent around me." Turns the placer's live pose (where they stand +
+ * which way the phone points) and a distance into a durable room-relative
+ * anchor, plus the absolute lat/lng to persist for the GPS index / legacy
+ * clients. The placer need not be standing on the origin — their offset from it
+ * is folded in — so you can walk the room dropping agents and they all land in
+ * the one shared frame.
+ *
+ * @param {object} p
+ * @param {number} p.originLat room origin latitude
+ * @param {number} p.originLng room origin longitude
+ * @param {number} p.viewerLat placer's current latitude
+ * @param {number} p.viewerLng placer's current longitude
+ * @param {number} p.bearingDeg compass bearing the placer is pointing (0–359)
+ * @param {number} p.distM how far ahead to drop the agent (metres)
+ * @param {boolean} [p.faceViewer=true] agent turns to face the placer (like a
+ * person you walked up to), vs. facing the same way the placer points
+ * @param {number} [p.originYawDeg=0] room frame rotation vs true north
+ * @returns {{ relEast:number, relNorth:number, relYawDeg:number, lat:number, lng:number, bearingDeg:number, distM:number }}
+ */
+export function placeAround({
+ originLat, originLng, viewerLat, viewerLng,
+ bearingDeg, distM, faceViewer = true, originYawDeg = 0,
+}) {
+ // Where the placer stands, relative to the origin (true-north metres).
+ const viewer = geoToLocal(originLat, originLng, viewerLat, viewerLng);
+ // Where they're dropping the agent, relative to themselves.
+ const ahead = bearingDistanceToLocal(bearingDeg, distM);
+ const trueEast = viewer.east + ahead.east;
+ const trueNorth = viewer.north + ahead.north;
+
+ // Store the offset in the ROOM frame (un-rotate by the frame's orientation),
+ // so a non-north room round-trips through agentWorldPosition cleanly.
+ const room = originYawDeg
+ ? localToTrueNorth(trueEast, trueNorth, -originYawDeg) // inverse rotation
+ : { east: trueEast, north: trueNorth };
+
+ const faceBearing = faceViewer ? (bearingDeg + 180) % 360 : bearingDeg;
+ const abs = localToGeo(originLat, originLng, trueEast, trueNorth);
+
+ return {
+ relEast: room.east,
+ relNorth: room.north,
+ relYawDeg: ((faceBearing % 360) + 360) % 360,
+ lat: abs.lat,
+ lng: abs.lng,
+ bearingDeg: ((bearingDeg % 360) + 360) % 360,
+ distM,
+ };
+}
diff --git a/tasks/site-overhaul/A-health/A01-fix-localhost-fallbacks.md b/tasks/site-overhaul/A-health/A01-fix-localhost-fallbacks.md
deleted file mode 100644
index ad1c7af19..000000000
--- a/tasks/site-overhaul/A-health/A01-fix-localhost-fallbacks.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# A01 — Kill production-breaking `localhost` fallbacks
-
-**Track:** Health · **Size:** S · **Priority:** P0 (breaks features in prod)
-
-## Goal
-Two modules fall back to a hardcoded `localhost` URL when an env var is unset. In production
-that silently breaks the feature. Resolve them to real production defaults and fail loudly in
-dev if misconfigured — never ship a dead `localhost` to users.
-
-## Why it matters
-Multiplayer `/walk` and the avatar creator both die on real deployments if their env var isn't
-present. This is the kind of bug that makes the platform look broken to a first-time visitor.
-
-## Context
-- [src/walk-net.js](src/walk-net.js#L48) — `defaultServerUrl()` returns `'ws://localhost:2567'` as the final fallback.
-- [src/avatar-creator.js](src/avatar-creator.js#L21) — `getStudioUrl()` returns `'http://localhost:5173'` when `VITE_CHARACTER_STUDIO_URL` is unset.
-- Check how other modules resolve prod URLs (meta tags, `import.meta.env`, `window.location.origin`) and follow that pattern.
-
-## Scope
-- Replace each `localhost` fallback with: (1) the real production URL (find it in `vercel env`, `.env`, or existing config), resolved via the same mechanism the rest of the app uses; (2) in dev, keep `localhost` only when `import.meta.env.DEV` is true.
-- If no env var is set in prod, surface a clear, user-facing error/empty state ("multiplayer is temporarily unavailable") rather than attempting a doomed `localhost` socket.
-- Grep the whole tree for other hardcoded `localhost`/`127.0.0.1` in non-dev/non-test code and fix the same way.
-
-## Out of scope
-- Dev tooling, scripts/, tests/ (localhost is fine there).
-
-## Definition of done
-- With the env var unset, `/walk` and the avatar creator degrade gracefully (no console flood, designed message), and with it set, they connect to the real service.
-- No `localhost`/`127.0.0.1` remains in shipped `src/` runtime paths outside `import.meta.env.DEV` guards.
-
-## Verify
-- `npm run dev`, open `/walk` and the create flow; confirm real connections.
-- `grep -rn "localhost\|127.0.0.1" src | grep -v "env.DEV"` returns only guarded or commented cases.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/A-health/A01-fix-localhost-fallbacks.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/A-health/A02-dead-links-and-unhandled-promises.md b/tasks/site-overhaul/A-health/A02-dead-links-and-unhandled-promises.md
deleted file mode 100644
index 49f2eb625..000000000
--- a/tasks/site-overhaul/A-health/A02-dead-links-and-unhandled-promises.md
+++ /dev/null
@@ -1,44 +0,0 @@
-# A02 — Fix dead links & unhandled promise rejections
-
-**Track:** Health · **Size:** M · **Priority:** P0/P1
-
-## Goal
-Eliminate dead interactive elements and unhandled async failures. Every button works, every
-link goes somewhere, every promise has a boundary (`CLAUDE.md`: "If a button exists, it must work").
-
-## Why it matters
-Dead paths and silent crashes read as "this product is half-built." They're cheap to fix and
-high-signal for quality.
-
-## Context (known instances — fix these, then sweep)
-- [src/marketplace.js](src/marketplace.js#L4384) — `#rel-more` "View More ›" link with `href="#"` and **no handler**. Wire it to actually expand/paginate the Related Agents list (reuse the list's existing data source).
-- [src/avatar-drop.js](src/avatar-drop.js#L365) — `Promise.all([...])` loading animation clips with **no `.catch()`**; the inner `fetchClip` (line ~364) also lacks error handling. Add a boundary; on failure, skip the interactive animation gracefully (don't crash init).
-
-## Scope
-1. Fix the two known issues above with real behavior (not just a swallow — the "View More" must do something useful).
-2. Sweep `src/` and `pages/` for: `href="#"` with no click handler, `onclick`/listeners that are empty, and `<button>`s with no bound action. For each, either wire it or remove it.
-3. Sweep for `Promise.all(`, `.then(` chains, and `await fetch(` in event handlers/init paths that lack a `.catch`/`try`. Add boundaries at network/user-input edges (internal code may trust itself, per `CLAUDE.md`).
-
-## Out of scope
-- Console-log triage (that's `A05`). Test failures (that's `A03`).
-
-## Definition of done
-- "View More" expands the related list; no dead `href="#"` remains without intent.
-- No unhandled rejection appears in the console while exercising the home page, marketplace, and create flow.
-
-## Verify
-- `npm run dev`; click every CTA on the home page, `/marketplace`, and an agent detail page. Console shows zero unhandled rejections.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/A-health/A02-dead-links-and-unhandled-promises.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/A-health/A03-green-test-suite.md b/tasks/site-overhaul/A-health/A03-green-test-suite.md
deleted file mode 100644
index 926a2d959..000000000
--- a/tasks/site-overhaul/A-health/A03-green-test-suite.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# A03 — Get the test suite green
-
-**Track:** Health · **Size:** M · **Priority:** P1
-
-## Goal
-`npm test` currently reports **14 failing tests across 7 files** (3164 passing). Drive it to
-green, or — where a failure reflects intentional churn from concurrent work — quarantine with a
-documented reason, never by deleting coverage.
-
-## Why it matters
-A red suite means no one trusts CI, and real regressions hide in the noise. At least one failure
-is a genuine security-relevant regression.
-
-## Context
-- Run `npm test 2>&1 | tail -60` to see the current failures. Known real one:
- - `tests/api/webhooks-replicate.test.js:214` — expects `200` for a Replicate prediction that matches no job row ("ignored"), but the handler now returns `401`. Either the webhook auth changed and the test is stale, or auth is rejecting unrelated-but-valid webhooks. **Investigate the handler** (`api/webhooks/replicate*`) and decide which is correct — an unrelated prediction should be acknowledged (`200 ignored`), not rejected, unless the signature genuinely failed.
-- Per the swarm context, some redness is transient churn from ~20 agents editing concurrently. Re-run before assuming a failure is yours.
-
-## Scope
-- Triage all 7 failing files. For each: fix the code if it's a real bug; fix the test if the contract legitimately changed; skip with `it.skip` + a `// reason:` comment only if it depends on unfinished concurrent work.
-- Do **not** mask failures by loosening assertions.
-
-## Definition of done
-- `npm test` is green, or every remaining skip has a one-line documented reason.
-- The webhooks-replicate auth behavior is correct and explained in the PR description.
-
-## Verify
-- `npm test 2>&1 | tail -10` shows 0 unexpected failures.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/A-health/A03-green-test-suite.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/A-health/A04-error-boundaries-audit.md b/tasks/site-overhaul/A-health/A04-error-boundaries-audit.md
deleted file mode 100644
index 833e48955..000000000
--- a/tasks/site-overhaul/A-health/A04-error-boundaries-audit.md
+++ /dev/null
@@ -1,44 +0,0 @@
-# A04 — Network & input error-boundary audit
-
-**Track:** Health · **Size:** M · **Priority:** P1 · **Depends on:** A02 (overlaps; coordinate)
-
-## Goal
-Every network call and user-input handler that can fail must fail *into a designed state*, not a
-blank screen or a console error. Establish boundaries at the edges, consistently.
-
-## Why it matters
-`CLAUDE.md`: "Errors handled at boundaries (network, user input)." The UX audit found pages that
-go blank or silently fail on fetch errors — that's invisible breakage for users.
-
-## Context
-- The app is vanilla JS; there's no React error boundary. Boundaries are manual `try/catch` around `fetch`/`await` at handler level.
-- A reusable error/empty/loading state treatment should come from Track B's shared components once they exist — coordinate so you're not inventing a one-off.
-- ~324 `console.error/warn` calls exist; many mark spots where a user-facing state is missing.
-
-## Scope
-- Inventory `fetch(`/`await`-in-handler sites in `src/` that render user-facing data. For each, ensure: a loading state, a catch that renders an **actionable** error ("Couldn't load X — retry"), and an empty state.
-- Prioritize the high-traffic surfaces: home, `/discover`, `/marketplace`, `/dashboard`, agent detail, `/create`.
-- Standardize a small helper (e.g. `src/shared/async-state.js`) if one doesn't exist, so every surface uses the same loading/error/empty pattern.
-
-## Out of scope
-- Rewriting the data sources; just add boundaries + states.
-
-## Definition of done
-- The prioritized surfaces show designed loading/empty/error states; a forced network failure (DevTools offline) never yields a blank page or an unhandled rejection.
-
-## Verify
-- `npm run dev`; toggle DevTools "Offline" and reload each prioritized surface — each shows a retryable error, not a void.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/A-health/A04-error-boundaries-audit.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/A-health/A05-console-hygiene.md b/tasks/site-overhaul/A-health/A05-console-hygiene.md
deleted file mode 100644
index aa4becb27..000000000
--- a/tasks/site-overhaul/A-health/A05-console-hygiene.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# A05 — Console hygiene
-
-**Track:** Health · **Size:** S/M · **Priority:** P2
-
-## Goal
-Reduce ~324 `console.error`/`console.warn` calls in `src/` to a clean, intentional set. A
-production console should be quiet; noise hides real problems and looks unprofessional when a
-developer-user opens DevTools.
-
-## Why it matters
-`CLAUDE.md` definition of done: "No console errors. No console warnings from your code."
-
-## Context
-- `grep -rn "console\.\(error\|warn\|log\)" src | wc -l` to size it; group by file.
-- Many are legitimate diagnostics; the goal is *intentional* logging, not zero.
-
-## Scope
-- Introduce/adopt a tiny logger (`src/shared/log.js`) gated on `import.meta.env.DEV` (or a `?debug` flag) so verbose diagnostics don't ship to prod consoles.
-- Convert noisy `console.*` to the logger. Keep genuine error reporting that a user/operator should see, but ensure it's paired with a user-facing state (coordinate with `A04`).
-- Remove dead `console.log` debug breadcrumbs entirely.
-
-## Definition of done
-- Loading the home page, `/discover`, `/dashboard`, and an agent page produces **zero** warnings/errors from our code in a production build.
-- Verbose logs are available behind the dev/debug gate.
-
-## Verify
-- `npm run build && npm run preview` (or serve `dist/`); open each surface — clean console.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/A-health/A05-console-hygiene.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/C-ux-newcomers/C03-getting-started-flow.md b/tasks/site-overhaul/C-ux-newcomers/C03-getting-started-flow.md
deleted file mode 100644
index d6b0c4d26..000000000
--- a/tasks/site-overhaul/C-ux-newcomers/C03-getting-started-flow.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# C03 — Getting-started / first-5-minutes guided flow
-
-**Track:** UX for Newcomers · **Size:** M · **Priority:** P1 · **Pairs with:** D05 (tour engine)
-
-## Goal
-A guided first-run path that takes a new user from landing to a finished, embeddable avatar in
-~5 minutes, distinguishing the free core (create → animate → embed) from optional add-ons
-(on-chain, monetize).
-
-## Why it matters
-The audit: "onboarding is nearly non-existent — no tutorial, no progressive disclosure." Users
-who reach the creation tools succeed; the job is to *get them there* with a clear path.
-
-## Context
-- Entry experiences: `/create`, `/scan`, `/forge`, `/avatar-studio`. Strong individually, unconnected as a journey.
-- A reusable coachmark/tour engine is specced in `D05` — if it lands first, build on it; otherwise a simple linear stepper is fine.
-
-## Scope
-- A first-run flow (triggered for new/anonymous users, dismissible, resumable) that: welcomes, states the value in one line, routes to "create your first avatar," then after creation surfaces "what's next" (embed / give it a brain / optional: own it / monetize).
-- A persistent, low-key "Getting started" progress affordance (e.g. a checklist) the user can reopen.
-- Free core steps require no wallet; optional steps are clearly marked optional.
-- Don't trap the user — always skippable.
-
-## Definition of done
-- A brand-new visitor is guided from home to an embeddable avatar without hitting unexplained crypto, and can see/resume their progress.
-
-## Verify
-- In a fresh/incognito session, follow the flow end-to-end; confirm no crypto wall in the core path and that "what's next" links work.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/C-ux-newcomers/C03-getting-started-flow.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/D-new-features/D05-guided-tour-engine.md b/tasks/site-overhaul/D-new-features/D05-guided-tour-engine.md
deleted file mode 100644
index afc6efc26..000000000
--- a/tasks/site-overhaul/D-new-features/D05-guided-tour-engine.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# D05 — Reusable guided-tour / coachmark engine
-
-**Track:** New Features · **Size:** M · **Priority:** P1 · **Powers:** C03, C09
-
-## Goal
-A small, reusable in-app tour engine (spotlight + tooltip steps, anchored to DOM elements,
-dismissible, resumable, progress-tracked) that any surface can drive with a declarative step list.
-
-## Why it matters
-C03 (getting started) and C09 (dashboard onboarding) both need guided overlays. Build the engine
-once, well, instead of two bespoke implementations — and unlock lightweight tours anywhere.
-
-## Context
-- Vanilla JS app; no tour library assumed. Keep it dependency-light.
-- Persistence of "seen/completed" per user (reuse the existing user prefs/storage; don't fake with only localStorage if a server pref store exists).
-- Track B tokens/components for styling; a11y is mandatory.
-
-## Scope
-- Engine API: `startTour([{ target, title, body, placement, action? }], { id, onComplete })`. Handles spotlight, positioning, next/back/skip, resize/scroll, focus management, and `aria` roles.
-- Persistence so a tour isn't re-shown once completed (server-backed when available).
-- A couple of real tours wired as proof: the getting-started path (C03) and the dashboard orientation (C09) — coordinate with those owners.
-
-## Definition of done
-- Any page can define a tour declaratively; tours are accessible, dismissible, resumable, and remembered per user; C03/C09 use it.
-
-## Verify
-- Run a tour, skip mid-way, reload — it resumes/respects completion. Keyboard + screen-reader pass.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/D-new-features/D05-guided-tour-engine.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/D-new-features/D06-trending-leaderboard.md b/tasks/site-overhaul/D-new-features/D06-trending-leaderboard.md
deleted file mode 100644
index 3d113dc1b..000000000
--- a/tasks/site-overhaul/D-new-features/D06-trending-leaderboard.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# D06 — Public trending / leaderboard
-
-**Track:** New Features · **Size:** M · **Priority:** P2
-
-## Goal
-A public "what's hot on three.ws" surface: trending agents, coins, and creators ranked by real
-activity (launches, volume, tips, chats) — connecting discover + the activity feed + on-chain data.
-
-## Why it matters
-`CLAUDE.md`: wire connections between features ("a marketplace that doesn't link to agent
-profiles is half-built"). A leaderboard creates a reason to explore, gives creators a goal, and
-showcases real platform activity to visitors.
-
-## Context
-- Real signals exist: pump feed/volume, the activity feed bus, agent chat metrics, on-chain badge data.
-- Discover SPA (`public/discover/`) is a natural home or sibling.
-- Honesty rule: rankings must reflect real data, no seeded fake leaders.
-
-## Scope
-- Define ranking metrics from real sources (with clear, honest definitions shown to users). Compute server-side (a function/cron) and expose via an endpoint.
-- A leaderboard surface (cards/rows via Track B) linking each entry to its real profile/coin page; time-window filters (24h/7d/all).
-- Designed empty/loading/error states; the on-chain badge where relevant.
-
-## Definition of done
-- A public leaderboard ranks real agents/coins/creators by transparent metrics, updates from live data, and links to real detail pages.
-
-## Verify
-- Confirm rankings match the underlying data for a known entity; links resolve; windows filter correctly.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/D-new-features/D06-trending-leaderboard.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/D-new-features/D07-embed-wizard.md b/tasks/site-overhaul/D-new-features/D07-embed-wizard.md
deleted file mode 100644
index a71554b50..000000000
--- a/tasks/site-overhaul/D-new-features/D07-embed-wizard.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# D07 — One-click "embed on your site" wizard
-
-**Track:** New Features · **Size:** M · **Priority:** P1
-
-## Goal
-A guided wizard that turns any agent/avatar into a copy-paste embed snippet with a live preview,
-configuration (size, theme, behavior), and platform-specific instructions (plain HTML,
-React, WordPress, Webflow, Shopify).
-
-## Why it matters
-"Embed anywhere" is a core value prop and a top use-case (C02), but the audit notes users don't
-know *how* or *why*. A great embed wizard converts a created avatar into real-world usage — the
-platform's stickiest outcome.
-
-## Context
-- Embed infrastructure exists: `/embed`, `/embed/v1.js`, `pages/widget.html`, avatar/agent embed pages, CSP-safe iframes.
-- Reuse the existing embed endpoints; this is the *guided UX* around them.
-
-## Scope
-- A wizard (in the dashboard and/or on each agent page) that: picks the agent, configures appearance/behavior, shows a **live preview** of the actual embed, generates the real snippet, and gives copy buttons + per-platform paste instructions.
-- Validate the snippet works (the preview *is* the embed). Designed states throughout.
-- Plain language — assume the user has never embedded anything.
-
-## Definition of done
-- A user selects an agent, configures it, sees a live working preview, and copies a snippet that actually renders that agent on an external page.
-
-## Verify
-- Generate a snippet, paste it into a blank HTML file served locally — the agent renders and works.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/D-new-features/D07-embed-wizard.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/E-improve-features/E04-scan-forge-clarity.md b/tasks/site-overhaul/E-improve-features/E04-scan-forge-clarity.md
deleted file mode 100644
index 5b853e6cb..000000000
--- a/tasks/site-overhaul/E-improve-features/E04-scan-forge-clarity.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# E04 — `/scan` & `/forge` inline clarity + flywheel value
-
-**Track:** Improve Features · **Size:** S/M · **Priority:** P2
-
-## Goal
-Explain the choices these tools present (fidelity levels, output formats, style) inline in plain
-language, and surface the value the user gets — without cluttering the clean flows.
-
-## Why it matters
-The audit: `/scan` and `/forge` are strong (7–8/10) but use unexplained terms — "rigged 3D
-model," "GLB," "High/Med/Low fidelity," "photorealistic vs stylized." Small inline explanations
-remove the last friction on otherwise great flows.
-
-## Context
-- [pages/scan.html](pages/scan.html), [pages/forge.html](pages/forge.html).
-- Memory: `/scan` selfie→3D pipeline + auto-rig chain; `/forge` is the in-house text→3D pipeline + data flywheel — **extend, don't fork** these.
-- C04 glossary/tooltips can supply the term definitions.
-
-## Scope
-- Add concise inline helpers (tooltips or one-liners) explaining fidelity, format, rig, and style choices in plain words ("Rigged = your model can move and be animated").
-- Surface what the user gains (e.g. "rigged so you can use all 70+ animations").
-- Keep the flows visually clean — progressive disclosure, not walls of text.
-
-## Definition of done
-- Every choice in `/scan` and `/forge` has a plain-language explanation available inline; the flows stay clean; pipelines unchanged.
-
-## Verify
-- Walk both flows as a non-expert; confirm each option is understandable and the pipelines still run correctly.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/E-improve-features/E04-scan-forge-clarity.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/E-improve-features/E05-studio-launch-mark-and-clarity.md b/tasks/site-overhaul/E-improve-features/E05-studio-launch-mark-and-clarity.md
deleted file mode 100644
index a8eb87c8b..000000000
--- a/tasks/site-overhaul/E-improve-features/E05-studio-launch-mark-and-clarity.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# E05 — `/studio` launch panel: integrate the `3ws` mark + plain-language launch
-
-**Track:** Improve Features · **Size:** M · **Priority:** P2 · **Relates to:** `tasks/vanity-3ws/`
-
-## Goal
-Make the /studio coin-launch panel both branded (the `3ws` mint mark) and understandable to a
-non-crypto creator: explain what launching a coin means and does, in plain words, with the brand
-moment as a feature.
-
-## Why it matters
-Launching a token is the most jargon-dense action (bonding curve, mint, buyback_bps). It's also a
-flagship outcome. The separate `tasks/vanity-3ws/` program adds the `3ws` mark; this task wires
-its **UX** into /studio and de-jargons the panel.
-
-## Context
-- [public/studio/launch-panel.js](public/studio/launch-panel.js) (state near lines 423–431; `PUMP_BASE_COST`, success `.lp-ok-mint`).
-- The `3ws` mark + branded success state are specced in `tasks/vanity-3ws/05-ux-branded-success-state.md` — implement/consume that here for /studio.
-- C04 tooltips for residual terms; C07 wallet explainer for the funding step.
-
-## Scope
-- Integrate the `3ws`-mark grind + branded success state (per the vanity-3ws UX task) into the /studio launch flow.
-- Rewrite the panel's copy in plain language: what a launch is, what it costs (honest SOL estimate), what the user gets, what's optional. Wrap unavoidable terms with tooltips.
-- Designed stamping/loading, success (mark emphasized), and error states.
-
-## Definition of done
-- /studio launches produce a `3ws…` mint with the branded success state, and a non-crypto creator can understand what the launch does and costs before confirming.
-
-## Verify
-- Run a launch in /studio (devnet/test); confirm the `3ws` mark, the branded success UI, and that the copy is comprehensible.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/E-improve-features/E05-studio-launch-mark-and-clarity.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/E-improve-features/E06-dashboard-ia-cleanup.md b/tasks/site-overhaul/E-improve-features/E06-dashboard-ia-cleanup.md
deleted file mode 100644
index ff7803e36..000000000
--- a/tasks/site-overhaul/E-improve-features/E06-dashboard-ia-cleanup.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# E06 — Dashboard information-architecture cleanup
-
-**Track:** Improve Features · **Size:** L · **Priority:** P1 · **Pairs with:** C09, A07
-
-## Goal
-Consolidate the dashboard's 30+ flat tabs into a coherent, grouped navigation a normal person can
-scan, and reconcile the duplicate dashboard trees.
-
-## Why it matters
-The audit: the dashboard is feature-rich but overwhelming (2/10 for newcomers), with 30+ tabs
-(agents, avatars, monetize, payments, subscriptions, billing, revenue, withdrawals, earnings,
-tokens, x402, mcp, keys, …) and three overlapping implementations.
-
-## Context
-- New: [pages/dashboard-next/index.html](pages/dashboard-next/index.html) (+ sub-pages). Legacy: `public/dashboard-classic/`. Plus `pages/dashboard/`. A07 covers the orphan/duplicate reconciliation — coordinate.
-- Tokens/components from Track B; help/tooltips from C09.
-
-## Scope
-- Group the tabs into a small number of logical sections (e.g. **Build** [agents, avatars, create, library], **Grow** [embed, widgets, analytics, monetize], **Money** [payments, payouts, tokens, x402], **Account** [keys, api, settings]). Collapse the billing/revenue/withdrawals/earnings sprawl into one coherent "Money" area.
-- Pick one canonical dashboard implementation; redirect the others.
-- Mark advanced/crypto sections clearly; default view favors the common path.
-- Preserve every working feature — this is reorganization, not removal.
-
-## Definition of done
-- The dashboard presents a grouped, scannable nav with one canonical implementation; every prior feature is still reachable; advanced/crypto areas are labeled.
-
-## Verify
-- Enumerate the old tabs and confirm each is reachable in the new IA; the duplicate trees redirect to the canonical one.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/E-improve-features/E06-dashboard-ia-cleanup.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/F-advertise-value/F01-interactive-feature-showcase.md b/tasks/site-overhaul/F-advertise-value/F01-interactive-feature-showcase.md
deleted file mode 100644
index 6e47e0790..000000000
--- a/tasks/site-overhaul/F-advertise-value/F01-interactive-feature-showcase.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# F01 — Interactive feature showcase / live tour landing
-
-**Track:** Advertise & Value · **Size:** M · **Priority:** P1
-
-## Goal
-A landing surface that *demonstrates* each core capability live (not just describes it): a
-scrollable, interactive tour where a visitor sees a real avatar animate, a real agent reply, a
-real embed, etc. — proving the value in seconds.
-
-## Why it matters
-The audit found users don't realize all the capabilities are one platform, and telling beats
-showing poorly. A "show, don't tell" showcase is the strongest top-of-funnel asset and is highly
-screenshot/share-worthy (`CLAUDE.md` quality bar).
-
-## Context
-- Real capabilities to demo: selfie→3D, 70+ animations, AI chat, embed, optional on-chain/x402.
-- Honesty rule (memory): demos must be real, no fake live data. Use real renders/agents.
-- Headless WebGL caveat (memory): verify 3D via `renderer.info`/DOM, not pixel screenshots.
-
-## Scope
-- An interactive showcase (its own page or a homepage section) where each capability is a live, working mini-demo with a CTA into the real flow.
-- Performance-conscious: lazy-load heavy 3D, intersection-observer to start demos on scroll, graceful fallback for low-power devices.
-- Built on Track B; mobile-friendly.
-
-## Definition of done
-- A visitor can interact with a real demo of each core capability on one page and click through to do it themselves; demos use real data; no jank.
-
-## Verify
-- `npm run dev`; scroll the showcase, interact with each demo, confirm real behavior and working CTAs; check mobile + performance.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/F-advertise-value/F01-interactive-feature-showcase.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/F-advertise-value/F02-per-feature-landing-pages.md b/tasks/site-overhaul/F-advertise-value/F02-per-feature-landing-pages.md
deleted file mode 100644
index 1f731daff..000000000
--- a/tasks/site-overhaul/F-advertise-value/F02-per-feature-landing-pages.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# F02 — Per-feature SEO landing pages
-
-**Track:** Advertise & Value · **Size:** M · **Priority:** P2 · **Depends on:** C04, B*
-
-## Goal
-A dedicated, SEO-optimized landing page for each flagship capability (selfie→3D scan, text→3D
-forge, AR walk, agents/embed, x402 payments, play worlds) — each with a clear value prop, demo,
-use-cases, and CTA.
-
-## Why it matters
-The platform's value is spread thin across a generic features page. Focused landing pages rank
-for intent searches ("turn selfie into 3D avatar," "embed AI avatar on website") and give each
-capability a real front door to advertise.
-
-## Context
-- Capabilities map to real flows: `/scan`, `/forge`, `/walk`, agents/`/embed`, x402, `/play`.
-- Reuse C02 use-cases and F01 demos; Track B components; honest copy/data.
-
-## Scope
-- One landing page per flagship feature: H1 with the searched outcome, plain value prop, a live or recorded demo, 2–3 use-cases, social proof (real), and a strong CTA into the flow.
-- Proper SEO: titles, meta descriptions, OG tags (tie to D04), structured data, sitemap entries, fast load.
-- Internal-link them from the homepage/features so they're discoverable and pass authority.
-
-## Definition of done
-- Each flagship feature has a focused, fast, SEO-complete landing page with a working demo and CTA, linked from the site and present in the sitemap.
-
-## Verify
-- Lighthouse SEO/performance pass on each; confirm OG tags render a card (D04); CTAs reach the real flow.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/F-advertise-value/F02-per-feature-landing-pages.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/site-overhaul/F-advertise-value/F03-honest-social-proof.md b/tasks/site-overhaul/F-advertise-value/F03-honest-social-proof.md
deleted file mode 100644
index 5c72771d7..000000000
--- a/tasks/site-overhaul/F-advertise-value/F03-honest-social-proof.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# F03 — Honest social-proof & traction surfaces
-
-**Track:** Advertise & Value · **Size:** S/M · **Priority:** P2
-
-## Goal
-Surface real platform traction — agents created, coins launched, live activity, notable creations
-— as honest social proof on the homepage and landing pages.
-
-## Why it matters
-Social proof converts, but the founder's honesty rule is absolute: **no fabricated numbers or
-fake live data** (memory: homepage marketing must be honest examples). This task wires *real*
-signals so the proof is both persuasive and true.
-
-## Context
-- Real signals: the activity feed bus (`feed:events`), counts from the agents/coins tables, the leaderboard (D06).
-- Memory: homepage-honesty — marketing visuals must be honest examples; no fake live data.
-
-## Scope
-- A live "real activity" strip (recent real launches/creations) and honest aggregate counts, sourced from real endpoints, on the homepage and key landing pages.
-- If a real number is too small to impress, show it honestly or show a qualitative proof (real featured creations) instead of inflating — never fake.
-- Designed empty state for low-activity windows.
-
-## Definition of done
-- Homepage/landing pages show real, live traction signals that match the underlying data; nothing is fabricated; low-data states degrade honestly.
-
-## Verify
-- Cross-check displayed counts/activity against the database/feed; confirm they're real and update.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/site-overhaul/F-advertise-value/F03-honest-social-proof.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/walk/11-walk-keyboard-controls.md b/tasks/walk/11-walk-keyboard-controls.md
deleted file mode 100644
index a06bd518f..000000000
--- a/tasks/walk/11-walk-keyboard-controls.md
+++ /dev/null
@@ -1,51 +0,0 @@
-# Task 11 — Walk Page: Keyboard Controls (WASD + Arrows + Modifiers)
-
-## Priority: HIGH
-
-## Objective
-Polish the desktop keyboard control scheme on `/walk` so it feels like a proper 3D game: smooth acceleration, run modifier, jump, look-around — not just on/off booleans flipping a transform.
-
-## Scope
-- File: `src/walk.js` (or wherever the walk controller lives — locate the existing input handler)
-- Movement keys:
- - `W` / `↑` — forward
- - `S` / `↓` — backward
- - `A` / `←` — strafe left
- - `D` / `→` — strafe right
- - `Shift` (held) — run modifier (1.8× speed)
- - `Space` — jump (uses existing jump animation if available; if not, real arc + gravity)
- - `Q` / `E` — rotate avatar 90° (snap turn — useful for fixed-camera mode)
- - `Esc` — release pointer lock / exit immersive mode
-- Mouse look:
- - Click canvas → request pointer lock → mouse moves rotate the camera (third-person orbit around avatar, distance fixed)
- - Scroll wheel → zoom camera distance (clamped 2m–8m)
-- Smooth input:
- - Use a per-frame accumulator with easing — do not jump from 0 → max speed in one frame
- - Damping when keys release (decel over ~150 ms)
-- Wire input → animation state machine: idle ↔ walk ↔ run ↔ jump
-- Accessibility: focus indicator on canvas, `aria-label`, full key map listed in a `?` overlay (toggle with `?` key)
-
-## Definition of Done
-- Movement on desktop feels smooth; no judder
-- Run modifier engages and disengages animation correctly
-- Jump arcs and lands cleanly with gravity
-- Pointer lock requests work in Chrome and Firefox
-- Key map overlay opens with `?` and is keyboard-navigable
-- No console errors; no input swallowed by other listeners
-
-## Rules
-Complete 100%. No stubs. No fake data. Wire to the existing animation state machine — do not create a parallel one. Verify in a real browser with the dev server running.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/walk/11-walk-keyboard-controls.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/walk/12-walk-mobile-joystick.md b/tasks/walk/12-walk-mobile-joystick.md
deleted file mode 100644
index 994724be8..000000000
--- a/tasks/walk/12-walk-mobile-joystick.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# Task 12 — Walk Page: Mobile Joystick + Haptics
-
-## Priority: HIGH
-
-## Objective
-Make the mobile walk experience first-class: a responsive virtual joystick with proper dead zone, multi-touch support (joystick + camera drag simultaneously), and tactile haptic feedback.
-
-## Scope
-- File: existing joystick code in `pages/walk.html` / `src/walk.js`
-- Joystick:
- - Anchored bottom-left, 120px outer / 56px inner thumb
- - Thumb follows touch within outer ring; clamped at ring radius
- - Magnitude → walk speed (0..1), angle → heading
- - Dead zone of ~12% (no movement for tiny touches)
- - Floating mode: tap anywhere on the left half of the screen to re-anchor the joystick at touch point
-- Camera drag:
- - Single-finger drag on right half of screen orbits the camera around the avatar
- - Pinch (two fingers) on right half zooms
- - Touch events must be multi-touch aware (use `Pointer Events` not `Touch Events` where possible)
-- Action buttons (bottom-right cluster):
- - Jump (large circular button, primary)
- - Wave / gesture (secondary)
- - Camera flip (third-person / first-person)
-- Haptics:
- - `navigator.vibrate(10)` on jump press
- - `navigator.vibrate(5)` on action button press
- - Behind a setting (default on, toggleable in HUD overlay)
-- iOS Safari quirks:
- - Disable pull-to-refresh and rubber-band scroll on the canvas container (`overscroll-behavior: none`, `touch-action: none`)
- - Honor `viewport-fit=cover` safe areas (`env(safe-area-inset-*)`)
-- Landscape/portrait responsive — HUD reflows correctly
-
-## Definition of Done
-- Tested on real iOS Safari and real Android Chrome (or via remote debugging with a real device)
-- Joystick + camera drag work simultaneously without input crosstalk
-- Jump button vibrates on press where supported
-- No accidental page zoom or scroll while playing
-- 60 FPS sustained on a recent iPhone
-
-## Rules
-Complete 100%. No stubs. No fake data. Real device verification preferred — emulator at minimum. Wire end-to-end.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/walk/12-walk-mobile-joystick.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/walk/31-site-wide-walk-mode-toggle.md b/tasks/walk/31-site-wide-walk-mode-toggle.md
deleted file mode 100644
index e179b3c09..000000000
--- a/tasks/walk/31-site-wide-walk-mode-toggle.md
+++ /dev/null
@@ -1,48 +0,0 @@
-# Task 31 — Site-Wide Walk Mode: Persistent Companion Across three.ws Pages
-
-## Priority: URGENT
-
-## Objective
-Build a "Walk Mode" toggle that, when enabled, makes the user's avatar walk along with them as they navigate `three.ws` itself — across every page on the site. The avatar persists across SPA-style navigations, follows the user's mouse/scroll, and serves as a tour guide.
-
-## Scope
-- New module: `src/walk-companion.js` — loaded globally on every three.ws page (add to the base layout / global JS bundle entry)
-- Toggle: `?walk=1` URL param, plus a persistent button in the global nav (`public/nav.html` + `public/nav.js`) — state persisted in `localStorage` as `walk:companion:enabled`
-- When enabled:
- - Inject a fixed-position 200×280 canvas in bottom-right (same z-index strategy as Chrome extension content script, task 06)
- - Loads the user's primary avatar (or `?avatar=` override)
- - Avatar idles by default; walks toward the user's cursor when the cursor moves
- - On page navigation (link click): avatar plays `wave` gesture briefly, then the companion canvas survives navigation by being attached to a persistent host outside the page's main content (a root-level container injected once on `DOMContentLoaded`)
-- Cross-page persistence approach: since three.ws is multi-page (not SPA), use one of:
- - Option A (preferred): use a Service Worker to serve a persistent shell; avatar lives in the shell
- - Option B (fallback): use `localStorage` to record avatar state (position, rotation, anim) on `beforeunload` and restore on next page load — avatar appears to teleport but resumes seamlessly
-- Avatar reacts to page context:
- - On `/pricing` → walks to and points at the recommended tier
- - On `/features` → walks to the most-viewed feature card
- - On agent detail page → walks to and waves at the agent's name
-- Disable button on the companion: clicking removes companion for the session
-
-## Definition of Done
-- Toggle walk mode → avatar appears on every page navigation
-- State (position/animation) persists across page loads
-- Page-context behaviors fire on pricing, features, agent detail
-- Disable button removes companion and respects choice for the rest of the session
-- No console errors
-- No layout breakage on any page
-
-## Rules
-Complete 100%. No stubs. No fake data. Real persistence (SW or localStorage), real avatar, real context-awareness. Wire end-to-end across the whole site.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/walk/31-site-wide-walk-mode-toggle.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/walk/44-walk-embed-snippet-generator-ui.md b/tasks/walk/44-walk-embed-snippet-generator-ui.md
deleted file mode 100644
index ed5f31660..000000000
--- a/tasks/walk/44-walk-embed-snippet-generator-ui.md
+++ /dev/null
@@ -1,56 +0,0 @@
-# Task 44 — Walk Embed: Dedicated Snippet Generator Page
-
-## Priority: HIGH
-
-## Objective
-Build a standalone, shareable snippet generator at `https://three.ws/embed/walk` — a visual configurator that produces the correct embed code for any combination of options. This page is the primary onboarding for developers who want to embed a walking avatar.
-
-## Scope
-- New file: `pages/embed-walk.html`, `src/embed-walk.js`
-- Add route to `vercel.json`: `/embed/walk` → `pages/embed-walk.html`
-- Layout (two-panel, responsive):
- - Left panel — configuration form:
- - Avatar picker: type an avatar ID or pick from "Featured" API — renders thumbnail
- - Controls: joystick | keyboard | none | auto (detects device)
- - Environment: dropdown (environments from task 18)
- - Background: transparent | color picker | none
- - Size: presets (S 200×280 / M 320×480 / L 480×720) + custom W/H
- - Autoplay: on/off
- - Narration: on/off (uses TTS narrator from task 09)
- - Walk speed: slider
- - Embed type: iframe | JS SDK
- - Right panel — live preview:
- - Real live iframe (or SDK-injected) updates instantly on every config change
- - "Copy snippet" button — native clipboard API, shows "Copied!" feedback
- - "Preview in new tab" link
- - Framework-specific tabs showing the same snippet formatted for vanilla HTML, React, Vue, and Svelte
-- Framework snippets:
- - React: `<WalkEmbed avatarId="..." controls="joystick" />` — with a note to `npm i @three-ws/react`
- - Vue: `<WalkEmbed avatar-id="..." />` — same note
- - Svelte: same
- - These are just well-formatted snippet text — no actual package needs to be published for this task, just show the expected API
-- URL state: all config options serialize to query params so the page is shareable/linkable
-
-## Definition of Done
-- Open `/embed/walk` → all controls present, live preview works
-- Change any option → preview updates within 200ms
-- Copy button copies correct snippet to clipboard
-- URL updates reflect config (deep-link works)
-- No console errors
-
-## Rules
-Complete 100%. No stubs. No fake data. Real live preview, real clipboard. Wire end-to-end.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/walk/44-walk-embed-snippet-generator-ui.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/walk/45-walk-shareable-links-og-image.md b/tasks/walk/45-walk-shareable-links-og-image.md
deleted file mode 100644
index 853e6af51..000000000
--- a/tasks/walk/45-walk-shareable-links-og-image.md
+++ /dev/null
@@ -1,51 +0,0 @@
-# Task 45 — Walk Shareable Links + Dynamic OG Image Generation
-
-## Priority: HIGH
-
-## Objective
-Every `/walk?avatar=<id>` URL must generate a rich Open Graph preview image showing the actual avatar in a walk pose — so sharing on Twitter/X, iMessage, Slack, Discord, or Farcaster unfurls beautifully.
-
-## Scope
-- New Vercel function: `api/og/walk.js`
- - Accepts `?avatar=<id>&env=<name>` query params
- - Fetches the avatar's thumbnail from `/api/avatars/<id>/thumb`
- - Fetches environment preview from `public/environments/<name>/preview.jpg`
- - Composes an OG image (1200×630) using `@vercel/og` (Edge Function with ImageResponse):
- - Background: environment preview (blurred, 20% opacity)
- - Center: avatar thumbnail, standing pose, no background (PNG with transparency)
- - Bottom-left: "Walk with @<handle>" in Inter Bold, 48px white
- - Bottom-right: three.ws logo
- - Returns `Content-Type: image/png` with `Cache-Control: public, max-age=3600`
-- Wire into `pages/walk.html` meta tags:
- ```html
- <meta property="og:image" content="https://three.ws/api/og/walk?avatar=<id>&env=<env>" />
- <meta name="twitter:card" content="summary_large_image" />
- <meta name="twitter:image" content="https://three.ws/api/og/walk?avatar=<id>&env=<env>" />
- ```
- - Avatar ID and env are injected server-side (or as a redirect from the walk route that passes params)
-- `/walk` route in `vercel.json` must return real HTML with populated meta tags (not client-rendered) — use a server-side render function if the existing route is client-rendered
-- Short URLs: `https://three.ws/w/<avatarId>` → 302 to `/walk?avatar=<avatarId>` (new route in vercel.json)
-
-## Definition of Done
-- Share `https://three.ws/walk?avatar=<id>` in iMessage → avatar OG image unfurls
-- Test with `npx og-preview "https://three.ws/walk?avatar=<id>"` or similar tool
-- OG image is 1200×630, real avatar visible, real environment background
-- Short URL `/w/<id>` redirects correctly
-- No console errors, no meta-tags missing
-
-## Rules
-Complete 100%. No stubs. No fake data. Real OG generation with real avatar images. Wire end-to-end.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/walk/45-walk-shareable-links-og-image.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/wow-sprint/02-mock-and-stub-eradication.md b/tasks/wow-sprint/02-mock-and-stub-eradication.md
deleted file mode 100644
index e73398e42..000000000
--- a/tasks/wow-sprint/02-mock-and-stub-eradication.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# Task: Eradicate mocks, fake data, and stubs (enforce the hard rules)
-
-CLAUDE.md forbids mocks, fake data, placeholders, stub functions, fake-loading,
-and fallback sample arrays in shipped code. Find every violation in the live app
-and replace it with a real implementation.
-
-## Scope
-`src/**/*.js`, `api/**/*.js`, `pages/**/*.html`. Skip `node_modules`, `dist*`,
-`vendor`, `tests/**`, and `*.test.js` / `*.spec.js` (test fixtures are allowed to
-use fakes).
-
-## Find the violations
-```
-grep -rn "sampleAgents\|sampleData\|mockData\|MOCK\|fakeData\|placeholder\|DUMMY\|hardcoded\|TODO\|FIXME\|not implemented" src api pages --include=*.js --include=*.html
-grep -rn "setTimeout(.*\(loading\|progress\|fake\)" src --include=*.js
-grep -rn "throw new Error(['\"]not implemented" src api --include=*.js
-```
-
-## Fix each one properly
-- **Sample/fallback arrays** → real `fetch` from the correct `api/` endpoint with loading + error states. The token data lives behind `api/three-token/[action].js` (stats/burns/activity, Birdeye + Pump.fun) and `api/pump/*`. The $THREE mint is `FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`.
-- **Fake loading (`setTimeout`)** → wire to the real async operation; show a skeleton until it resolves.
-- **Stub functions / `not implemented`** → implement fully, or delete if genuinely unreachable (confirm with grep first).
-- **Hardcoded values that should be dynamic** → source them from config/env/API.
-- **Empty `catch {}`** → handle at the boundary (surface a real error state) or let it throw if internal.
-
-## Constraints
-- Never introduce a new mock to "fix" a mock. Real APIs only.
-- If a real endpoint is missing for some data, build the endpoint in `api/` — don't fake it.
-- If credentials are missing, check `.env.example` and `.env`; proceed with what exists.
-
-## Definition of done
-- The grep patterns above return zero shipped-code hits (test fixtures excluded).
-- `npm run dev` (port 3000): every touched view loads real data, no console errors.
-- Run the **completionist** subagent on your changed files; fix everything it flags.
-- Report the list of violations found and how each was resolved.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/wow-sprint/02-mock-and-stub-eradication.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/wow-sprint/03-dead-path-and-broken-link-audit.md b/tasks/wow-sprint/03-dead-path-and-broken-link-audit.md
deleted file mode 100644
index 463ad4404..000000000
--- a/tasks/wow-sprint/03-dead-path-and-broken-link-audit.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# Task: Dead path, broken link & non-working button audit + fix
-
-CLAUDE.md: "If a button exists, it must work. If a link exists, it must go
-somewhere. If a state exists, there must be a way to reach it." Make that true.
-
-## Scope
-All entry points in `pages/**/*.html` and `public/**/*.html` that are wired in
-`vite.config.js` (see the `input` map and the dev `/route` map around lines
-160–520), plus their `src/*.js` controllers.
-
-## Method
-1. Enumerate every `<a href>`, `<button>`, and click handler in the page set. Build a list of every navigation target and action.
-2. For each link: confirm the target route/file exists (cross-reference `vite.config.js` inputs and `pages/`/`public/`). Flag 404s, `href="#"` with no handler, and dangling anchors.
-3. For each button/handler: confirm it's wired to a real function that does something. Flag no-op handlers, handlers that reference undefined functions, and disabled controls with no path to enable.
-4. For each declared UI state (modals, tabs, panels): confirm there's a user path to reach it.
-5. Start `npm run dev` and click through the top pages: `home`, `marketplace`, `agent-home`, `dashboard`, `pump-dashboard`, `pricing`, `skills`.
-
-## Fix
-- Broken internal link → point it at the correct existing route, or remove the link if the destination shouldn't exist.
-- Dead button → wire it to the real action. If the action belongs to an unbuilt feature, implement the minimal real version (no stubs) or remove the control.
-- Unreachable state → add the trigger, or delete the dead state.
-
-## Definition of done
-- Every link on the audited pages resolves; every button does real work.
-- `npm run dev`: clicked through all top pages, no console errors, no dead clicks.
-- Run the **completionist** subagent on changed files.
-- Report: list of dead paths found and the resolution for each.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/wow-sprint/03-dead-path-and-broken-link-audit.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/wow-sprint/05-performance-pass.md b/tasks/wow-sprint/05-performance-pass.md
deleted file mode 100644
index dc860f2a9..000000000
--- a/tasks/wow-sprint/05-performance-pass.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# Task: Performance pass — bundle, 3D, and runtime jank
-
-Make three.ws feel instant. Target: fast first paint, lazy-loaded 3D, no main-
-thread jank, good Lighthouse scores (`.lighthouserc.json` defines the budget).
-
-## Scope
-`vite.config.js` (build/rollup config), `src/viewer.js` and the Three.js modules,
-the home hero (`src/home-v4-hero.js`, `src/home-v4-scroll.js`, `src/home-act2-viewer.js`),
-and any route that imports Three.js eagerly.
-
-## Method
-1. **Measure first.** `npm run build`, inspect the rollup output for the largest chunks. Run Lighthouse against `npm run dev` for `/` and `/marketplace`. Record baseline numbers.
-2. **Code-split heavy modules.** Three.js, GLTF loaders, draco/ktx2 decoders, and the club/walk scenes should be dynamically `import()`-ed only when their view is active — never in the initial home bundle.
-3. **Lazy-load 3D assets.** Defer GLB loads until the canvas is in view (IntersectionObserver). Show a skeleton/poster until ready.
-4. **Kill jank.** Debounce resize/scroll/input handlers. Use `transform`/`opacity` for animation (not layout-triggering props). Add `will-change` only where it pays. Cap devicePixelRatio on the renderer for high-DPI phones.
-5. **Trim the critical path.** Preconnect fonts (already partially done in `home.html`), defer non-critical scripts, remove unused imports (`npx knip`).
-
-## Constraints
-- No visual regressions — the page must look identical or better.
-- No fake/skeleton-only "perf" — the underlying load must actually be deferred.
-
-## Definition of done
-- Largest initial chunk meaningfully smaller; Three.js no longer in the home critical bundle.
-- Lighthouse performance improved vs baseline (report both numbers); within `.lighthouserc.json` budgets where possible.
-- 60fps scroll on the home hero; no long tasks > 50ms during load on a mid-tier profile.
-- `npm run dev` + `npm run build` both clean. Run the **completionist** subagent.
-- Report: baseline vs after metrics, and what changed.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/wow-sprint/05-performance-pass.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/wow-sprint/06-accessibility-pass.md b/tasks/wow-sprint/06-accessibility-pass.md
deleted file mode 100644
index d6f6aceb8..000000000
--- a/tasks/wow-sprint/06-accessibility-pass.md
+++ /dev/null
@@ -1,41 +0,0 @@
-# Task: Accessibility pass — semantic HTML, keyboard, focus, contrast
-
-CLAUDE.md: "Accessibility is not optional." Bring the core pages to WCAG AA.
-
-## Scope
-`pages/home.html`, `pages/marketplace.html`, `pages/agent-home.html`,
-`pages/dashboard/`, `pages/pricing.html`, `pages/skills.html`, and their `src/*.js`
-controllers. Plus shared components in `src/components/`.
-
-## Checklist (apply to each page)
-1. **Semantic structure** — real `<nav> <main> <header> <footer> <button> <a>` instead of `<div onclick>`. One `<h1>`, logical heading order.
-2. **Keyboard nav** — every interactive element reachable and operable by Tab/Enter/Space/Escape. Modals trap focus and restore it on close. No keyboard traps.
-3. **Focus indicators** — visible focus ring on every focusable element (don't `outline: none` without a replacement). Respect `:focus-visible`.
-4. **ARIA** — labels on icon-only buttons, `aria-expanded` on toggles, `role="dialog"` + `aria-modal` on modals, `aria-live` on async status regions, `alt` on meaningful images (empty `alt` on decorative).
-5. **Color contrast** — verify text vs background meets AA (4.5:1 body, 3:1 large). The dark theme tokens are in `home.html :root` (`--text`, `--text-2`, `--text-3`…); check the low-contrast greys against their surfaces and fix the failing ones.
-6. **Motion** — respect `prefers-reduced-motion`: gate non-essential animation behind it.
-7. **Forms** — every input has an associated `<label>`; errors announced.
-
-## Method
-- Tab through each page manually (`npm run dev`). Run an axe-core pass if available (`npx @axe-core/cli` or inject axe in the console).
-- Fix violations at the source. Add a skip-to-content link on the main pages.
-
-## Definition of done
-- Keyboard-only operation works end-to-end on every audited page.
-- No axe-core critical/serious violations remaining (list any intentionally deferred).
-- Contrast failures fixed; `prefers-reduced-motion` honored.
-- Run the **completionist** subagent. Report violations found + fixes.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/wow-sprint/06-accessibility-pass.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/wow-sprint/07-home-page-overhaul.md b/tasks/wow-sprint/07-home-page-overhaul.md
deleted file mode 100644
index e81d408ef..000000000
--- a/tasks/wow-sprint/07-home-page-overhaul.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# Task: Home page overhaul — a landing that makes holders proud
-
-`pages/home.html` is the front door. Make it world-class: clear value prop,
-a signature visual moment, real data, flawless polish. Bar = Vercel / Linear / Stripe.
-
-## Current state
-- Entry: `pages/home.html` (route `/` per `vite.config.js`). Hero logic in `src/home-v4-hero.js`, scroll in `src/home-v4-scroll.js`, 3D in `src/home-act2-viewer.js`.
-- Design tokens already defined in `home.html :root` (dark theme: `--bg`, `--surface-*`, `--text-*`, `--accent`). Reuse them — don't invent new ones.
-- There are stale variants (`home-v2/v3/v4`, `home-classic`). Don't touch those; ship on `home.html`.
-
-## What to build
-1. **Hero** — sharp one-line value prop ("The 3D agent layer of the internet"), a real primary CTA, and a live 3D centerpiece that loads fast (lazy, with poster/skeleton). It should feel alive on first paint.
-2. **Live $three signal** — surface one real stat from `api/three-token/[action].js?action=stats` (price / holders / volume / burns) in the hero or just below it, with a graceful loading + error state. Mint: `FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump`. (If task 12 is building the reactive hero, coordinate — this task owns layout/content, 12 owns the reactive 3D.)
-3. **Proof sections** — what the platform does (create → embed → monetize), with real screenshots/components, not lorem.
-4. **Every state designed** — loading skeleton, error fallback, and the populated state all polished. Responsive at 320 / 768 / 1440.
-5. **Microinteractions** — hover/active/focus on every interactive element, intentional enter transitions, no jarring pops.
-
-## Constraints
-- No fake data, no placeholder copy, no `setTimeout` fake-loading.
-- Real fetches only; handle the boundary.
-
-## Definition of done
-- `npm run dev` → `/` loads fast, 3D lazy-loads, real $three stat renders.
-- Zero console errors. Responsive at all three breakpoints. A11y basics (semantic, focusable, labelled).
-- `npm run build` clean. Run the **completionist** subagent.
-- You'd screenshot this and post it. Report what changed and include the reasoning for the hero design.
-
-> Run this BEFORE tasks 12 and 04 if running in parallel (they touch the same files).
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/wow-sprint/07-home-page-overhaul.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/wow-sprint/08-design-system-tokens.md b/tasks/wow-sprint/08-design-system-tokens.md
deleted file mode 100644
index 67321d23c..000000000
--- a/tasks/wow-sprint/08-design-system-tokens.md
+++ /dev/null
@@ -1,47 +0,0 @@
-# Task: Consolidate a real design system (tokens)
-
-Many pages redefine the same colors, spacing, and type inline. Extract one
-canonical design-token layer and adopt it across the core pages so the product
-feels coherent.
-
-## Source of truth
-`pages/home.html :root` already defines a clean dark palette (`--bg`,
-`--surface-0..3`, `--hairline*`, `--text..text-4`, `--accent`) plus the Inter /
-Inter Tight / JetBrains Mono type stack. Promote this into a shared stylesheet.
-
-## What to build
-1. Create `src/styles/tokens.css` (or extend an existing shared CSS entry if one is already imported globally — check `vite.config.js` and existing `<link>`s first; reuse, don't duplicate). Define:
- - **Color**: the existing palette + semantic aliases (`--color-bg`, `--color-text`, `--color-accent`, `--color-danger`, `--color-success`, `--color-warning`, border/hairline).
- - **Spacing scale**: `--space-1..8` (4px base).
- - **Radius**: `--radius-sm/md/lg/full`.
- - **Type scale**: font families, sizes, weights, line-heights as tokens.
- - **Elevation/shadow** and **motion** tokens (`--ease-out`, `--dur-fast/med`).
-2. Import the token sheet into the core pages (`home`, `marketplace`, `agent-home`, `dashboard`, `pricing`, `skills`).
-3. Replace inline literal colors/spacing/type on those pages with the tokens. Keep the visual result identical (this is a refactor, not a redesign).
-4. Document the tokens at the top of the file with a short comment block.
-
-## Constraints
-- No visual regression — diff each page before/after; pixels should match.
-- Don't fork tokens per page. One source.
-
-## Definition of done
-- `src/styles/tokens.css` exists, imported by the core pages, documented.
-- Inline color/spacing literals on those pages replaced with tokens.
-- `npm run dev`: pages look identical to before. `npm run build` clean.
-- Run the **completionist** subagent. Report the token set and which pages adopted it.
-
-> Land this BEFORE tasks 09, 10, 11 so they consume the tokens.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/wow-sprint/08-design-system-tokens.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tasks/wow-sprint/09-empty-loading-error-states.md b/tasks/wow-sprint/09-empty-loading-error-states.md
deleted file mode 100644
index 0ccff0565..000000000
--- a/tasks/wow-sprint/09-empty-loading-error-states.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# Task: Design every empty, loading, and error state
-
-CLAUDE.md: "Every state is designed." Audit the data-driven views and make their
-loading, empty, and error states intentional and helpful.
-
-## Scope
-The views that fetch real data: `pages/marketplace.html` (`src/marketplace.js`,
-`src/marketplace-lobby.js`), `pages/agent-home.html` (`src/agent-home.js`),
-`pages/dashboard/` (`src/dashboard/`), `pages/pump-dashboard.html`
-(`src/pump/dashboard.js`), `pages/skills.html` (`src/skills.js`).
-
-## For each view, deliver three designed states
-1. **Loading** — skeleton screens that mirror the final layout (preferred over spinners). No layout shift when data arrives.
-2. **Empty** — when the fetch succeeds but returns nothing: explain what this view is and give the user a next action (a CTA), not a blank void. E.g. marketplace with no results → "No agents match — clear filters / create one".
-3. **Error** — when the fetch fails: say what went wrong in human terms and offer recovery (Retry button that re-runs the fetch). Never a blank screen or a raw stack trace.
-
-## Method
-- Trace each view's data flow to its `api/` endpoint. Confirm the three branches exist and are reachable.
-- Test empty by querying a filter with no matches; test error by pointing at a failing endpoint or going offline in devtools.
-- Reuse the design tokens (from task 08 / `home.html :root`). Build a small reusable skeleton + empty-state + error component if one doesn't exist; check `src/components/` first.
-
-## Constraints
-- Real async only — no `setTimeout` fake loaders.
-- Retry must actually re-fetch.
-
-## Definition of done
-- All three states designed and reachable on every audited view.
-- Verified in `npm run dev` (force each state via devtools). No console errors.
-- Run the **completionist** subagent. Report the states added per view, with screenshots described.
-
-<!-- AUTO:self-delete-on-complete -->
-
----
-
-## ✅ On completion — delete this file
-
-This file is a unit of work, not a permanent doc. The moment every item above is **built, wired, verified, and committed** to the "Definition of done" in the repo-root `CLAUDE.md`, remove it in the same change:
-
-```bash
-git rm "tasks/wow-sprint/09-empty-loading-error-states.md"
-```
-
-Stage the deletion alongside your implementation and include it in the completion commit. This directory is the backlog: a file that still exists is unfinished work; a file that is gone has shipped. Do not delete early, and never leave a completed prompt behind.
diff --git a/tests/api/irl-pins-room.test.js b/tests/api/irl-pins-room.test.js
new file mode 100644
index 000000000..d9a0897f9
--- /dev/null
+++ b/tests/api/irl-pins-room.test.js
@@ -0,0 +1,168 @@
+// POST + GET /api/irl/pins — shared room-frame anchoring.
+//
+// A room-placed agent stores its EXACT offset (rel_east_m / rel_north_m) from a
+// shared origin (origin_lat/lng/yaw) instead of relying on its own GPS, so a
+// cluster keeps its room-scale layout identical for every viewer (see
+// src/irl/room-anchor.js). These tests pin the API contract for that pose:
+// • a valid room block persists, clamped/normalized;
+// • an invalid/absent block leaves every room column NULL (a standalone pin),
+// so old clients and single-drop placements are untouched;
+// • the nearby projection surfaces the room columns (and never an owner id).
+// DB / auth / limiter / guardian / realtime are mocked so the suite stays offline.
+
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+
+// Content-addressed SQL mock. The INSERT echoes its bound values back as columns
+// (incl. the six room columns appended last) so success-path assertions see the
+// EXACT coerced pose. The nearby SELECT returns one seeded room pin so the
+// projection round-trip can be asserted.
+let nearbyRow = null;
+const sqlMock = vi.fn((strings, ...values) => {
+ const q = Array.isArray(strings) ? strings.join(' ') : String(strings);
+ if (/count\(\*\)::int/i.test(q)) return Promise.resolve([{ n: 0 }]);
+ if (/INSERT INTO irl_pins/i.test(q)) {
+ const [
+ user_id, agent_id, device_token, lat, lng, heading,
+ avatar_url, avatar_name, caption, x402_endpoint, expires_at,
+ anchor_height_m, anchor_yaw_deg, anchor_quat,
+ gps_accuracy_m, altitude_m, anchor_source, geocell7,
+ room_id, rel_east_m, rel_north_m, origin_lat, origin_lng, origin_yaw_deg,
+ ] = values;
+ return Promise.resolve([{
+ id: 'pin-new', user_id, agent_id, device_token, lat, lng, heading,
+ avatar_url, avatar_name, caption, x402_endpoint,
+ placed_at: '2026-06-17T00:00:00Z', expires_at,
+ anchor_height_m, anchor_yaw_deg, anchor_quat,
+ gps_accuracy_m, altitude_m, anchor_source, geocell7,
+ room_id, rel_east_m, rel_north_m, origin_lat, origin_lng, origin_yaw_deg,
+ view_count: 0, avatar_version: 0,
+ }]);
+ }
+ // Nearby SELECT (has the room columns + a BETWEEN range) → the seeded row.
+ if (/rel_east_m/i.test(q) && /BETWEEN/i.test(q) && /SELECT/i.test(q)) {
+ return Promise.resolve(nearbyRow ? [nearbyRow] : []);
+ }
+ return Promise.resolve([]); // DDL + anything else
+});
+vi.mock('../../api/_lib/db.js', () => ({ sql: (...a) => sqlMock(...a) }));
+
+let sessionUser = null;
+vi.mock('../../api/_lib/auth.js', () => ({ getSessionUser: vi.fn(async () => sessionUser) }));
+vi.mock('../../api/_lib/rate-limit.js', () => ({
+ limits: {
+ irlPinIp: vi.fn(async () => ({ success: true })),
+ irlPinBurst: vi.fn(async () => ({ success: true })),
+ irlPinHourly: vi.fn(async () => ({ success: true })),
+ publicIp: vi.fn(async () => ({ success: true })),
+ },
+ clientIp: () => '127.0.0.1',
+}));
+vi.mock('../../api/_lib/granite-guardian.js', () => ({
+ guardianConfig: () => ({ configured: false }), assess: vi.fn(), decide: vi.fn(),
+}));
+vi.mock('../../api/_lib/irl-publish.js', () => ({ publishIrlPin: vi.fn(async () => {}) }));
+
+const { default: handler } = await import('../../api/irl/pins.js');
+
+const ORIGIN = { lat: 40.7128, lng: -74.006 };
+
+function makeRes() {
+ return {
+ statusCode: 200, _h: {}, headersSent: false, writableEnded: false,
+ setHeader(k, v) { this._h[k.toLowerCase()] = v; },
+ getHeader(k) { return this._h[k.toLowerCase()]; },
+ end(body) { this.writableEnded = true; this._body = body; },
+ };
+}
+async function post(body) {
+ const res = makeRes();
+ await handler({ url: '/api/irl/pins', method: 'POST', headers: { host: 'x' }, query: {}, body }, res);
+ let parsed = null; try { parsed = JSON.parse(res._body); } catch {}
+ return { res, body: parsed };
+}
+async function getNearby(query) {
+ const res = makeRes();
+ await handler({ url: '/api/irl/pins', method: 'GET', headers: { host: 'x' }, query }, res);
+ let parsed = null; try { parsed = JSON.parse(res._body); } catch {}
+ return { res, body: parsed };
+}
+
+const basePin = () => ({
+ lat: ORIGIN.lat, lng: ORIGIN.lng, heading: 270,
+ avatarUrl: '/avatars/default.glb', avatarName: 'Scout', deviceToken: 'device-A',
+});
+const room = (over = {}) => ({
+ id: 'living-room-7', originLat: ORIGIN.lat, originLng: ORIGIN.lng,
+ originYawDeg: 0, relEast: 2, relNorth: 1, ...over,
+});
+
+beforeEach(() => { sqlMock.mockClear(); sessionUser = null; nearbyRow = null; });
+
+describe('POST /api/irl/pins — room frame persistence', () => {
+ it('stores room id + exact offset + origin when the client places into a room', async () => {
+ const { res, body } = await post({ ...basePin(), room: room({ relEast: 2.5, relNorth: -1.25, originYawDeg: 30 }) });
+ expect(res.statusCode).toBe(201);
+ const p = body.pin;
+ expect(p.room_id).toBe('living-room-7');
+ expect(p.rel_east_m).toBe(2.5);
+ expect(p.rel_north_m).toBe(-1.25);
+ expect(p.origin_lat).toBe(ORIGIN.lat);
+ expect(p.origin_lng).toBe(ORIGIN.lng);
+ expect(p.origin_yaw_deg).toBe(30);
+ });
+
+ it('an old client with no room block creates a valid standalone pin (NULL room columns)', async () => {
+ const { res, body } = await post(basePin());
+ expect(res.statusCode).toBe(201);
+ const p = body.pin;
+ for (const k of ['room_id', 'rel_east_m', 'rel_north_m', 'origin_lat', 'origin_lng', 'origin_yaw_deg']) {
+ expect(p[k]).toBeNull();
+ }
+ });
+
+ it('drops an invalid room to a standalone pin rather than anchoring at (0,0)', async () => {
+ // Bad slug.
+ const a = await post({ ...basePin(), room: room({ id: 'Living Room!' }) });
+ expect(a.body.pin.room_id).toBeNull();
+ expect(a.body.pin.rel_east_m).toBeNull();
+ // Null-island origin is rejected (a missing GPS fix must never plant a real room there).
+ const b = await post({ ...basePin(), room: room({ originLat: 0, originLng: 0 }) });
+ expect(b.body.pin.room_id).toBeNull();
+ // Non-finite offset.
+ const c = await post({ ...basePin(), room: room({ relEast: 'NaN' }) });
+ expect(c.body.pin.room_id).toBeNull();
+ });
+
+ it('clamps an out-of-range offset and normalizes the frame rotation', async () => {
+ const { body } = await post({ ...basePin(), room: room({ relEast: 9000, relNorth: -9000, originYawDeg: -45 }) });
+ expect(body.pin.rel_east_m).toBe(500); // REL_MAX_M ceiling
+ expect(body.pin.rel_north_m).toBe(-500);
+ expect(body.pin.origin_yaw_deg).toBe(315); // −45° → 315°
+ });
+});
+
+describe('GET /api/irl/pins — room frame projection', () => {
+ it('surfaces the room columns to viewers and never an owner identifier', async () => {
+ nearbyRow = {
+ id: 'pin-room', user_id: 'owner-uuid', device_token: 'device-A', agent_id: null,
+ lat: ORIGIN.lat, lng: ORIGIN.lng, heading: 90,
+ avatar_url: '/a.glb', avatar_name: 'Scout', caption: '', x402_endpoint: null,
+ placed_at: '2026-06-17T00:00:00Z', view_count: 0,
+ anchor_height_m: null, anchor_yaw_deg: 90, anchor_quat: null,
+ gps_accuracy_m: 10, altitude_m: null, anchor_source: 'gyro-gps', avatar_version: 0,
+ room_id: 'living-room-7', rel_east_m: 2, rel_north_m: 1,
+ origin_lat: ORIGIN.lat, origin_lng: ORIGIN.lng, origin_yaw_deg: 0,
+ };
+ const { res, body } = await getNearby({ lat: String(ORIGIN.lat), lng: String(ORIGIN.lng), radius: '150' });
+ expect(res.statusCode).toBe(200);
+ const p = body.pins[0];
+ expect(p.room_id).toBe('living-room-7');
+ expect(p.rel_east_m).toBe(2);
+ expect(p.rel_north_m).toBe(1);
+ expect(p.origin_lat).toBe(ORIGIN.lat);
+ expect(p.origin_yaw_deg).toBe(0);
+ // The allow-list projection must not leak owner identity.
+ expect(p.user_id).toBeUndefined();
+ expect(p.device_token).toBeUndefined();
+ });
+});
diff --git a/tests/irl-room-anchor.test.js b/tests/irl-room-anchor.test.js
new file mode 100644
index 000000000..7f5b50dee
--- /dev/null
+++ b/tests/irl-room-anchor.test.js
@@ -0,0 +1,189 @@
+// Room-relative anchoring math (src/irl/room-anchor.js).
+//
+// The contract these tests pin is the whole point of the room frame: agents you
+// place around one spot keep their EXACT relative geometry no matter what GPS
+// does, and they project into the world on the right side of you. The headline
+// scenario is the one a user described — standing in a room, cup ahead, an agent
+// on the couch to the right, three behind, nothing to the left — verified to
+// land where a real person would. Pure math, no DOM / Three.js / clock.
+
+import { describe, it, expect } from 'vitest';
+
+import {
+ M_PER_DEG_LAT,
+ mPerDegLng,
+ geoToLocal,
+ localToGeo,
+ bearingDistanceToLocal,
+ localToBearingDistance,
+ localToTrueNorth,
+ roomOriginWorld,
+ agentWorldPosition,
+ compassToYaw,
+ placeAround,
+} from '../src/irl/room-anchor.js';
+
+const ORIGIN = { lat: 37.7749, lng: -122.4194 }; // arbitrary; math is origin-relative
+const near = (a, b, eps = 1e-6) => Math.abs(a - b) <= eps;
+
+describe('metres-per-degree', () => {
+ it('latitude is the fixed constant', () => {
+ expect(M_PER_DEG_LAT).toBe(110540);
+ });
+ it('longitude shrinks with cos(latitude)', () => {
+ expect(mPerDegLng(0)).toBeCloseTo(111320, 0); // equator: full width
+ expect(mPerDegLng(60)).toBeCloseTo(111320 / 2, 0); // 60° N: half width
+ expect(mPerDegLng(89)).toBeLessThan(mPerDegLng(45));
+ });
+});
+
+describe('geoToLocal / localToGeo round-trip', () => {
+ it('a 3 m east, 2 m north offset survives the round-trip', () => {
+ const here = localToGeo(ORIGIN.lat, ORIGIN.lng, 3, 2);
+ const back = geoToLocal(ORIGIN.lat, ORIGIN.lng, here.lat, here.lng);
+ expect(near(back.east, 3, 1e-3)).toBe(true);
+ expect(near(back.north, 2, 1e-3)).toBe(true);
+ });
+ it('east is +lng, north is +lat', () => {
+ const e = geoToLocal(ORIGIN.lat, ORIGIN.lng, ORIGIN.lat, ORIGIN.lng + 0.001);
+ expect(e.east).toBeGreaterThan(0);
+ expect(near(e.north, 0)).toBe(true);
+ const n = geoToLocal(ORIGIN.lat, ORIGIN.lng, ORIGIN.lat + 0.001, ORIGIN.lng);
+ expect(n.north).toBeGreaterThan(0);
+ expect(near(n.east, 0)).toBe(true);
+ });
+});
+
+describe('bearingDistanceToLocal', () => {
+ it('cardinal bearings map to the right axes', () => {
+ const N = bearingDistanceToLocal(0, 5);
+ expect(near(N.north, 5, 1e-9) && near(N.east, 0, 1e-9)).toBe(true);
+ const E = bearingDistanceToLocal(90, 5);
+ expect(near(E.east, 5, 1e-9) && near(E.north, 0, 1e-9)).toBe(true);
+ const S = bearingDistanceToLocal(180, 5);
+ expect(near(S.north, -5, 1e-9)).toBe(true);
+ const W = bearingDistanceToLocal(270, 5);
+ expect(near(W.east, -5, 1e-9)).toBe(true);
+ });
+ it('round-trips through localToBearingDistance', () => {
+ for (const [b, d] of [[0, 3], [47, 8.2], [123, 1.5], [270, 12], [359, 4]]) {
+ const o = bearingDistanceToLocal(b, d);
+ const rt = localToBearingDistance(o.east, o.north);
+ expect(near(rt.bearingDeg, b, 1e-6)).toBe(true);
+ expect(near(rt.distM, d, 1e-9)).toBe(true);
+ }
+ });
+});
+
+describe('localToTrueNorth (room frame rotation)', () => {
+ it('is identity for a true-north-aligned room', () => {
+ const r = localToTrueNorth(2, 3, 0);
+ expect(r.east).toBe(2);
+ expect(r.north).toBe(3);
+ });
+ it('rotating the frame 90° turns local-north into true-east', () => {
+ // Room frame whose "north" axis points at compass 90° (east). A point 1 m
+ // "north" in that frame is 1 m true-EAST in the world.
+ const r = localToTrueNorth(0, 1, 90);
+ expect(near(r.east, 1)).toBe(true);
+ expect(near(r.north, 0)).toBe(true);
+ });
+ it('placeAround stores in the room frame so a rotated room still round-trips', () => {
+ const viewer = { lat: ORIGIN.lat, lng: ORIGIN.lng }; // standing on the origin
+ const placed = placeAround({
+ originLat: ORIGIN.lat, originLng: ORIGIN.lng,
+ viewerLat: viewer.lat, viewerLng: viewer.lng,
+ bearingDeg: 90, distM: 3, originYawDeg: 30,
+ });
+ // Re-project to the world (viewer at origin → originWorld is {0,0}).
+ const w = agentWorldPosition({
+ originWorld: { x: 0, z: 0 },
+ relEast: placed.relEast, relNorth: placed.relNorth,
+ originYawDeg: 30,
+ });
+ // Bearing 90 at 3 m from the viewer ⇒ 3 m true-east ⇒ +X, z≈0.
+ expect(near(w.x, 3, 1e-9)).toBe(true);
+ expect(near(w.z, 0, 1e-9)).toBe(true);
+ });
+});
+
+describe('compassToYaw matches pinYawRad', () => {
+ it('negates radians', () => {
+ expect(compassToYaw(0)).toBe(-0);
+ expect(near(compassToYaw(90), -Math.PI / 2)).toBe(true);
+ expect(near(compassToYaw(180), -Math.PI)).toBe(true);
+ });
+});
+
+describe("the user's room: cup ahead, couch right, three behind, wall left", () => {
+ // Viewer stands on the room origin facing north (the cup is dead ahead, at
+ // −Z). We place agents by compass bearing + distance, then project each into
+ // the viewer's world frame and assert it sits where a real person would.
+ const viewer = { lat: ORIGIN.lat, lng: ORIGIN.lng };
+ const originWorld = roomOriginWorld(viewer.lat, viewer.lng, ORIGIN.lat, ORIGIN.lng);
+
+ const place = (bearingDeg, distM) => {
+ const p = placeAround({
+ originLat: ORIGIN.lat, originLng: ORIGIN.lng,
+ viewerLat: viewer.lat, viewerLng: viewer.lng,
+ bearingDeg, distM,
+ });
+ return {
+ ...p,
+ world: agentWorldPosition({ originWorld, relEast: p.relEast, relNorth: p.relNorth }),
+ };
+ };
+
+ it('the couch agent (90°, 3 m) lands to the RIGHT: +X, on the floor plane', () => {
+ const couch = place(90, 3);
+ expect(couch.world.x).toBeGreaterThan(2.9); // to the right (east)
+ expect(near(couch.world.z, 0, 1e-6)).toBe(true);
+ expect(near(couch.world.y, 0)).toBe(true);
+ });
+
+ it('the three agents behind (≈180°) land BEHIND: +Z (south), each distinct', () => {
+ const behind = [place(170, 2), place(180, 3), place(195, 4)];
+ for (const a of behind) expect(a.world.z).toBeGreaterThan(0); // behind = +Z
+ // Distinct spots, not smeared onto one another.
+ const zs = behind.map(a => a.world.z);
+ expect(new Set(zs.map(z => z.toFixed(2))).size).toBe(3);
+ });
+
+ it('nothing is placed to the left — the frame has no agent there by construction', () => {
+ // (No placement at 270°. This documents the scenario: the left wall stays
+ // empty; the renderer only ever draws agents the room actually contains.)
+ const right = place(90, 3);
+ expect(right.world.x).toBeGreaterThan(0); // sanity: right is +X, so left (−X) is empty
+ });
+
+ it('an agent faces the viewer by default (you walk up, it looks at you)', () => {
+ const couch = place(90, 3); // placed pointing east…
+ expect(couch.relYawDeg).toBe(270); // …so it faces west, back toward the viewer
+ });
+});
+
+describe('intra-room geometry is exact under GPS drift (the headline guarantee)', () => {
+ // Place couch-right and wall-left in one room, then re-render them from a
+ // SECOND viewer whose GPS is off by ~12 m. The cluster translates as one; the
+ // agents must stay 4 m apart on opposite sides — never smear or swap.
+ const couch = placeAround({ originLat: ORIGIN.lat, originLng: ORIGIN.lng, viewerLat: ORIGIN.lat, viewerLng: ORIGIN.lng, bearingDeg: 90, distM: 2 });
+ const wall = placeAround({ originLat: ORIGIN.lat, originLng: ORIGIN.lng, viewerLat: ORIGIN.lat, viewerLng: ORIGIN.lng, bearingDeg: 270, distM: 2 });
+
+ it('relative offsets put them exactly 4 m apart, opposite sides', () => {
+ expect(near(couch.relEast, 2, 1e-9)).toBe(true);
+ expect(near(wall.relEast, -2, 1e-9)).toBe(true);
+ expect(near(Math.abs(couch.relEast - wall.relEast), 4, 1e-9)).toBe(true);
+ });
+
+ it('a second viewer 12 m off-origin still sees them 4 m apart on the same sides', () => {
+ // 12 m east of the origin (≈ a real GPS error).
+ const off = localToGeo(ORIGIN.lat, ORIGIN.lng, 12, 0);
+ const originWorld = roomOriginWorld(off.lat, off.lng, ORIGIN.lat, ORIGIN.lng);
+ const cW = agentWorldPosition({ originWorld, relEast: couch.relEast, relNorth: couch.relNorth });
+ const wW = agentWorldPosition({ originWorld, relEast: wall.relEast, relNorth: wall.relNorth });
+ expect(near(cW.x - wW.x, 4, 1e-6)).toBe(true); // still 4 m apart
+ expect(cW.x).toBeGreaterThan(wW.x); // couch still to the right of wall
+ // And the whole cluster shifted left by the 12 m origin offset, together.
+ expect(near(cW.x, -12 + 2, 1e-6)).toBe(true);
+ });
+});