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 launch-readiness and custody specs to IRL/wallet/IBM backlogs

nirholasccadad5fc409
diff --git a/tasks/agent-wallet-trading/09-custody-withdraw-limits.md b/tasks/agent-wallet-trading/09-custody-withdraw-limits.md
new file mode 100644
index 000000000..b34eb1893
--- /dev/null
+++ b/tasks/agent-wallet-trading/09-custody-withdraw-limits.md
@@ -0,0 +1,109 @@
+# Task: Custody safety — withdraw/sweep funds out, spend limits, key & audit hardening
+
+## Context
+
+Agent wallets are **custodial**: the platform generates the Solana keypair, encrypts
+it with AES-256-GCM keyed off `JWT_SECRET` (`api/_lib/agent-wallet.js:18,325`), and
+can recover it to sign (`:419`). Users will deposit real SOL (task 02) and the
+agent will trade (03/04), snipe (05/06), and pay (08) from it. Today there is **no
+way for a user to get funds back out**, no per-agent spend ceiling outside the
+sniper's internal caps, and custody/audit controls are not surfaced. Taking
+custodial deposits with no withdraw path and no spend governance is not
+production-acceptable — this task makes custody safe and trustworthy.
+
+## Goal
+
+The owner can withdraw all SOL and any SPL tokens from the agent wallet to an
+address they choose; per-agent spend limits govern every outbound path (trade/
+snipe/x402); and key handling + a custody audit trail meet a bar you'd defend to a
+security reviewer.
+
+## Files to Read First
+
+- `api/_lib/agent-wallet.js:18` (`deriveKey`/`JWT_SECRET`), `:325`
+ (`generateSolanaAgentWallet`), `:419` (`recoverSolanaAgentKeypair` + its audit
+ logging) — the canonical custody module
+- `api/agents/solana-wallet.js:251` — balance + `…/activity`
+- `api/_lib/agent-pumpfun.js:26` + `api/_lib/solana/connection.js` — RPC failover
+- Task 03's shared guardrail module (`api/_lib/agent-trade-guards.js`) — where
+ per-agent spend caps live; this task extends them to cover withdraw + x402
+- SPL transfer helpers already used in the repo (e.g. agent-payments-sdk / x402
+ Solana payload `api/x402-pay.js:320`) — reuse for token transfers, don't hand-roll
+- Audit-log + observability conventions (memory `observability-stack`,
+ `recoverSolanaAgentKeypair` audit pattern)
+
+## What to Build / Do
+
+1. **Withdraw / sweep endpoint** — `POST /api/agents/:id/wallet/withdraw`
+ (owner-authenticated): transfer a specified amount (or "max") of SOL and/or a
+ given SPL mint to a destination address the owner supplies. Build, sign
+ (server-side via `recoverSolanaAgentKeypair`), submit, confirm; reserve rent +
+ fee headroom on SOL "max"; return the signature + new balances. Idempotent.
+2. **Withdraw UI** — the wallet hub's **Withdraw** tab (shell from task 01): pick
+ asset (SOL or a held SPL token, from real holdings), enter/scan destination
+ (address validation + paste/QR-scan), amount or Max, confirm with a clear
+ summary, success (explorer link) + balance refresh. Designed empty (nothing to
+ withdraw), error (invalid address, insufficient balance for rent/fees), and
+ in-flight states.
+3. **Per-agent spend limits** — extend the shared guardrail module so each agent has
+ configurable ceilings (daily spend cap, per-transaction max, optional allowlist
+ of withdraw destinations) that apply uniformly to trade (03/04), snipe (05/06),
+ x402 (08), and withdraw. One policy, enforced everywhere. Surface + edit these in
+ the hub (a "limits / safety" section).
+4. **Key & secret hardening** — confirm the secret never appears in any API
+ response, log, or error (audit `git grep`); decryption only after auth +
+ ownership; every recover call audit-logged with reason (extend the existing
+ pattern). Document the `JWT_SECRET`-derived custody model and its rotation
+ consideration in a `docs/` note (key-rotation requires re-encryption — document
+ the procedure even if rotation isn't executed now).
+5. **Custody audit trail** — a per-agent, owner-viewable log of sensitive events
+ (key recovered + reason, withdraw, limit change, trade/x402 spend) so a user can
+ see exactly what their custodial wallet has done. Back it with the existing audit
+ logging; surface a readable view in the hub.
+
+## Constraints
+
+- This is the security-critical task — treat every line accordingly. Secrets never
+ leave the server, never logged, never in errors. Decrypt only via
+ `recoverSolanaAgentKeypair`, only after auth + ownership, always audit-logged.
+- Withdraw is owner-only and must validate the destination (valid base58 / on-curve
+ Solana address) before signing. Reserve rent + fees so a "max" withdraw can't brick
+ the account or fail on fees.
+- Real transfers only; honor a simulate flag for tests but default to live submit. No
+ fabricated confirmations.
+- Spend limits are enforced server-side in the shared module — a client cannot
+ bypass them. A limit breach is a structured 4xx with the reason, never a 500.
+- Idempotent withdraw (idempotency key) so a retry never double-sends.
+- Errors handled at the boundary; never let a withdraw fail silently or leave the
+ user unsure whether funds moved — always resolve to a confirmed signature or a
+ clear, recoverable error.
+
+## Success Criteria
+
+- `POST /api/agents/:id/wallet/withdraw` moves SOL and an SPL token out to a chosen
+ address on devnet, confirmed, with rent/fees reserved on Max; retry with the same
+ idempotency key does not double-send.
+- The Withdraw tab completes a withdrawal end-to-end with address validation and all
+ states designed.
+- Per-agent spend limits are enforced across trade/snipe/x402/withdraw from one
+ shared policy; breaches return clear 4xx; limits are editable in the hub.
+- No secret leaks (`git grep` audit clean); every key recovery is audit-logged with a
+ reason; the custody audit trail is viewable by the owner.
+- A `docs/` note documents the custody model + rotation procedure.
+- `npm run typecheck` + `npm test` clean (new tests cover withdraw, limit
+ enforcement, address validation, idempotency). Changelog entry (tag: security).
+ Run the **completionist** subagent on changed 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/agent-wallet-trading/09-custody-withdraw-limits.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/ibm-x402-demo/09-deploy-preview-route-and-handoff.md b/tasks/ibm-x402-demo/09-deploy-preview-route-and-handoff.md
new file mode 100644
index 000000000..9cc1aaa55
--- /dev/null
+++ b/tasks/ibm-x402-demo/09-deploy-preview-route-and-handoff.md
@@ -0,0 +1,67 @@
+# Task 09 — Deploy: three.ws preview route + telemetry + IBM handoff
+
+## Context
+
+three.ws workspace at `/workspaces/three.ws`. Deliverable + verified facts:
+[00-PLAN.md](00-PLAN.md). The page is [`pages/ibm/x402-demo.html`](../../pages/ibm/x402-demo.html).
+
+Everything before this made the page excellent. This task ships it: a live preview on three.ws,
+optional observability, the changelog entry, and a clean handoff package IBM can drop onto
+`live.ibm.com`. Run **after** tasks 01–08.
+
+## Do this
+
+1. **Serve it on three.ws as a preview.** Wire the page into the build so it's reachable at a
+ stable URL (e.g. `https://three.ws/pages/ibm/x402-demo.html`, or a clean `/ibm/x402-demo`
+ route).
+ - Add it as a Vite input in [`vite.config.js`](../../vite.config.js) following the existing
+ `pages/**` input pattern.
+ - Register it in [`data/pages.json`](../../data/pages.json) (the SoT for the dynamic sitemap
+ and SEO pipeline) and run `npm run build:pages`. Respect the existing SEO injectors
+ (`inject-seo-meta` / `inject-blog-seo`) — don't fight their ordering.
+ - Confirm it builds (`npm run build`) and serves locally (`npm run dev`) at the chosen URL,
+ identical to the standalone file.
+2. **Optional, privacy-respecting telemetry.** The page will run on a foreign origin. If useful,
+ POST client errors to `https://three.ws/api/client-errors` (the existing reporter) — first
+ confirm that endpoint sends permissive CORS for a cross-origin `live.ibm.com` POST; if it
+ doesn't, either add it or skip telemetry rather than ship a console-erroring beacon. Keep it
+ to errors + a single "demo_payment_settled" event at most. No PII, no wallet addresses.
+3. **Changelog.** Because this becomes a live three.ws page, append an entry to
+ [`data/changelog.json`](../../data/changelog.json): holder-readable title + summary, tags
+ `feature` (and `sdk` if you frame the embed snippet as a developer feature). Then
+ `npm run build:pages` (it validates the entry and regenerates the changelog artifacts). After
+ deploy, `npm run changelog:push` posts it (skip silently if Telegram creds are absent locally).
+4. **IBM handoff package.** Produce what IBM needs to host it, in `pages/ibm/`:
+ - The final standalone `x402-demo.html` (self-contained; absolute `three.ws` URLs; self-hosted
+ fonts from task 02 travel alongside it).
+ - Expand `pages/ibm/HOSTING.md` (started in task 02) into a short, complete guide: how to
+ host (copy the file + `fonts/`), the **two recommended CSP tiers** (strict Base-only / full
+ Base+Solana), the wallet requirements for visitors, the iframe-vs-top-level recommendation,
+ and a one-paragraph "what this demonstrates" for the IBM team.
+ - A copy-paste **8-line embed snippet** (already in the page) IBM can also use elsewhere.
+5. **Self-review the diff.** `git diff` every changed line. Watch the known traps: don't commit
+ an `npx vercel build` esbuild bundle into `api/`/`public/`; stage explicit paths only.
+
+## Definition of done
+
+- The page is reachable on three.ws at a stable URL, byte-for-byte equivalent to the standalone
+ file. `npm run build` clean.
+- `pages.json` + sitemap + SEO meta updated; changelog entry added and validated.
+- Telemetry is either wired with confirmed cross-origin CORS or deliberately omitted (no
+ console-erroring beacon).
+- `pages/ibm/HOSTING.md` is a complete handoff doc with CSP tiers and hosting steps.
+- Diff reviewed; only intended paths staged. Run the **completionist** subagent. Push to BOTH
+ remotes only after the user approves.
+
+<!-- AUTO:self-delete-on-complete -->
+
+---
+
+## ✅ On completion — delete this file
+
+```bash
+git rm "tasks/ibm-x402-demo/09-deploy-preview-route-and-handoff.md"
+```
+
+Stage the deletion in the same commit as the implementation. A file that still exists is
+unfinished work; a file that is gone has shipped. Do not delete early.
diff --git a/tasks/ibm-x402-demo/10-definition-of-done-sweep.md b/tasks/ibm-x402-demo/10-definition-of-done-sweep.md
new file mode 100644
index 000000000..24a6eeee9
--- /dev/null
+++ b/tasks/ibm-x402-demo/10-definition-of-done-sweep.md
@@ -0,0 +1,63 @@
+# Task 10 — Definition-of-done sweep (capstone sign-off)
+
+## Context
+
+three.ws workspace at `/workspaces/three.ws`. Deliverable + verified facts:
+[00-PLAN.md](00-PLAN.md). The page is [`pages/ibm/x402-demo.html`](../../pages/ibm/x402-demo.html).
+
+This is the final gate. Tasks 01–09 are done (their files are gone). This task proves the whole
+thing is **100% production-ready, zero-error** before it represents IBM × three.ws publicly. It
+edits nothing except to fix a blocker it uncovers — and it removes the last task files.
+
+## The sweep — verify every item against evidence (not assumption)
+
+1. **Real-money flow works.** Re-confirm task 01's result file shows `PASS` on both Base and
+ Solana with explorer-verifiable transactions (or a clearly-owned `BLOCKED` with a funding
+ note, surfaced to the user). The payment leg is real — never faked.
+2. **Zero console errors/warnings** on load and through a full happy-path run, in at least two
+ engines (Chromium + WebKit), light and dark.
+3. **Foreign-origin + CSP.** Served from a non-three.ws origin under the strict (Base-only) CSP,
+ the Base flow works with no resource outside `'self'` + `three.ws`; Solana degrades
+ gracefully. No CSP violations. (Evidence: task 02 + `pages/ibm/HOSTING.md`.)
+4. **Every state designed.** idle / preview-loading (skeleton) / success (animated) / and each
+ error from task 03 — all on-brand and actionable. No stuck spinners, no `undefined`, no raw
+ stacks.
+5. **Responsive** at 320 / 768 / 1440, no overflow; mobile-without-wallet guidance present
+ (task 05).
+6. **Accessibility:** zero serious/critical axe violations, full keyboard operability, focus
+ returns to the trigger on modal close, AA contrast in both themes (task 06).
+7. **Cross-browser matrix** report exists; desktop all `PASS`, mobile `PASS`/`UNTESTED` honestly
+ (task 07).
+8. **Copy & compliance:** accurate, honest about real spend, IBM brand correct (or flagged),
+ and **`$THREE` is the only coin** referenced anywhere on the page (task 08).
+9. **Shipped:** reachable on three.ws preview URL, `pages.json`/sitemap/SEO updated, changelog
+ entry validated, `pages/ibm/HOSTING.md` complete (task 09).
+10. **Build + hygiene:** `npm run build` clean; `npm test` green (or unrelated-failure status
+ noted); no esbuild bundle committed to `api/`/`public/`; repo root clean; only intended
+ paths staged.
+
+## Method
+
+- Run the **completionist** subagent over the changed files (`pages/ibm/x402-demo.html`,
+ `pages/ibm/HOSTING.md`, `pages/ibm/fonts/*`, `vite.config.js`, `data/pages.json`,
+ `data/changelog.json`) and resolve everything it raises.
+- Do a final human-style read of `git diff` — every changed line justified.
+- Produce a one-page **sign-off report** to the user: each DoD item with PASS + its evidence
+ (tx hashes, screenshots/paths, axe summary, matrix link), and any item the user must close
+ (e.g. IBM brand sign-off, a `BLOCKED` funding leg).
+
+## Definition of done
+
+- Every item 1–10 above is `PASS` with cited evidence, or has a named owner/blocker surfaced to
+ the user — nothing assumed.
+- Sign-off report delivered. completionist clean. Build clean.
+- Remove the last task files (this one and the now-empty plan) in the final commit:
+
+```bash
+git rm "tasks/ibm-x402-demo/10-definition-of-done-sweep.md" "tasks/ibm-x402-demo/00-PLAN.md"
+```
+
+(If any earlier `NN-*.md` still remains, that task is unfinished — do **not** delete it or the
+plan; report it as outstanding instead.) Push to BOTH remotes only after the user approves.
+
+<!-- AUTO:self-delete-on-complete -->
diff --git a/tasks/irl-hardening/H9-launch-readiness-audit.md b/tasks/irl-hardening/H9-launch-readiness-audit.md
new file mode 100644
index 000000000..432da2fed
--- /dev/null
+++ b/tasks/irl-hardening/H9-launch-readiness-audit.md
@@ -0,0 +1,97 @@
+# H9 — Launch-readiness audit & sign-off
+
+> Epic IRL-Hardening · Size **M** · Cross-cutting. Produces a sign-off report;
+> the gate for flipping `/irl` to a public launch. Run **LAST**.
+
+## Goal
+
+A single, repeatable audit that proves `/irl` is 100% production-ready —
+zero-error, privacy-safe, accessible, and polished — on **real devices**, and
+produces a written sign-off. This is the "would I demo this to a room of senior
+engineers and stake my name on it?" gate, made concrete and checkable.
+
+## Why it matters
+
+Everything before this hardens a piece. This task proves the whole is ready and
+catches the integration gaps no single task owns: a state that regressed, a header
+missing in prod, a console error only on iOS, a slow first paint on a real phone
+on cellular. A launch gate that's a checklist someone actually runs is the
+difference between "we think it's ready" and "it's ready."
+
+## Current state (verified)
+
+- The hardening pass already shipped: `redactUrl()` log scrubbing
+ (`api/_lib/http.js`), coordinate coarsening (`api/irl/pins.js` `roundCoord`), and
+ the privacy invariant suite (**H1**). H2–H8 layer credential transport,
+ proof-of-presence, consent, the privacy center, retention, anti-scrape, and the
+ states/a11y pass.
+- Tooling exists: `scripts/page-audit.mjs` (BASE_URL + reports/), the
+ `console-audit-baseline` (known non-bug noise to filter), `npm run typecheck`,
+ `npm test`, and `npm run build:pages` (changelog validation).
+
+## What to build / run
+
+### 1. Privacy sign-off (the spine)
+
+- Run the full H1 suite green; confirm every H2–H7 invariant has an assertion.
+- Manually attempt each leak the epic closes and confirm it's blocked: a 5xx
+ doesn't log coordinates/tokens (force one, inspect the log); the nearby feed
+ returns no `user_id`/`device_token` and coarse coords; a forged/foreign fix token
+ is rejected (H3); a device token never appears in any URL (H2, Network tab); a
+ "forget device" leaves zero rows (H5); orphaned interactions are reaped (H6).
+- Confirm `THREAT-MODEL.md` (H7) exists and matches shipped behavior.
+
+### 2. Zero-error sweep
+
+- `npm test` + `npm run typecheck` green.
+- `scripts/page-audit.mjs` against a real dev/preview build for `/irl` and the
+ dashboard IRL pages — **zero console errors/warnings from our code** (filter the
+ documented `console-audit-baseline` noise only; investigate anything new).
+- Network tab on every IRL flow: real API calls, real data, expected status codes,
+ correct security headers (`no-store`, `referrer-policy`, `x-irl-device` /
+ `x-irl-fix` where applicable), no coordinate/token in any URL.
+
+### 3. Real-device matrix
+
+Exercise the full flow (onboard → place exact + approximate → discover nearby →
+tap card → pay → privacy center → forget device) on:
+- **iOS Safari** (motion gesture, no WebXR path),
+- **Android Chrome** (WebXR path),
+- a desktop browser (graceful no-AR fallback).
+Record pass/fail per surface; file any defect, don't hand-wave it.
+
+### 4. Performance & polish
+
+- First-meaningful paint + interaction latency on a throttled mobile profile within
+ the IRL perf budget (per the `irl-perf-e2` system); no jank panning the camera.
+- Every state designed (H8); a11y spot-check (keyboard, contrast over camera,
+ reduced-motion).
+- Responsive at 320 / 768 / 1440.
+
+### 5. The report
+
+Write `tasks/irl-hardening/LAUNCH-SIGNOFF.md`: each section above with
+pass/fail/notes, the commit audited, the device matrix table, any accepted
+residual risk (with rationale), and a final **GO / NO-GO**. Add the changelog entry
+for the launch if it's user-visible. Honest by construction: a failed check is
+written as failed with the evidence, never glossed.
+
+## Acceptance checklist
+
+- [ ] H1 suite green; every H2–H7 invariant asserted; manual leak attempts all blocked.
+- [ ] `npm test` + `npm run typecheck` green; page-audit shows zero new console noise.
+- [ ] Security headers + transport verified in the Network tab; no coord/token in URLs.
+- [ ] Real-device matrix (iOS Safari / Android Chrome / desktop) exercised and recorded.
+- [ ] Perf within budget; states + a11y verified; responsive at 3 widths.
+- [ ] `LAUNCH-SIGNOFF.md` written with evidence and a clear GO / NO-GO.
+
+## Out of scope
+
+Building features — H9 only audits and signs off what H1–H8 shipped. A NO-GO
+returns specific defects to the owning task; it does not fix them here.
+
+## Verify
+
+The deliverable *is* the verification: a complete `LAUNCH-SIGNOFF.md` whose every
+checkbox is backed by evidence (log excerpt, Network screenshot path, device note),
+ending in a defensible GO/NO-GO an engineer could stake their name on.
diff --git a/tasks/irl-location-control/L5-my-pins-management-upgrade.md b/tasks/irl-location-control/L5-my-pins-management-upgrade.md
new file mode 100644
index 000000000..27bc05664
--- /dev/null
+++ b/tasks/irl-location-control/L5-my-pins-management-upgrade.md
@@ -0,0 +1,119 @@
+# L5 — My-pins management upgrade
+
+> Epic · Size **S** · Touches `src/irl.js` (My-pins sheet) · reuses the Leaflet
+> loader from `src/dashboard-next/pages/irl-placements.js`. Builds on the existing sheet.
+
+## Goal
+
+Make the existing **My-pins** sheet a real management surface so a tester (or any
+user) can see and purge what they've placed in seconds:
+
+1. **Map overview** — a small Leaflet map at the top of the sheet plotting every
+ pin this device/account owns, so "where did I drop things?" is answered visually.
+2. **Expiry countdown** — each row shows `expires in 6d` (anonymous) or `permanent`
+ (signed-in), so a tester knows exactly when a forgotten test pin self-destructs.
+3. **Remove all from this device** — a guarded bulk purge (confirm step) that deletes
+ every pin tied to the local device token in one action, for fast cleanup after testing.
+
+## Why it matters
+
+The whole anxiety in "I'm worried my location will leak" is really "and I won't be
+able to take it back." The sheet today lists pins and deletes them one at a time
+(`deleteMyPin`), with no map and no expiry visibility. After a testing session you
+might have a dozen pins at (or near) a real spot and no fast way to confirm they're
+gone. A map + countdown + one-tap purge turns cleanup from a chore into a reflex —
+which is exactly what makes people comfortable experimenting in the first place.
+
+## Current state (real lines)
+
+- `src/irl.js:2476` `loadMyPins()` → `GET /api/irl/pins/mine?deviceToken=` returns
+ `id, lat, lng, avatar_name, caption, placed_at, expires_at, view_count`
+ (`api/irl/pins.js:428`) — **expiry + coords already come back**, nothing new to fetch.
+- `src/irl.js:2501` `renderMyPins(pins, listEl)` paints rows; `:2531` `deleteMyPin(id, btn)`
+ does the per-row DELETE; `:2466` `MYPINS_EMPTY` is the shared empty state;
+ `:2442` `relativeTime()` already formats `placed_at` (mirror it for `expires_at`).
+- `src/irl.js:2514` `openMyPinsSheet()` uses `loadInto` (skeleton/empty/error/retry).
+- `api/irl/pins.js:847` DELETE removes one pin by `id` + owner (`device_token`/`user_id`);
+ there is **no** bulk-delete endpoint yet.
+- Leaflet loader to reuse: `src/dashboard-next/pages/irl-placements.js:1083`.
+
+## What to build
+
+### 1. Map overview in the sheet
+
+Above the list, render a Leaflet map (lazy-loaded via the dashboard's
+`loadLeaflet()`/`ensureLeafletCss()`, dark theme) with a marker per owned pin,
+auto-`fitBounds` to them. Empty → hide the map and show `MYPINS_EMPTY`. Map CDN
+failure → degrade gracefully to the list alone (the list is the source of truth;
+the map is an enhancement, never a hard dependency — Rule 9). Tapping a marker
+highlights/scrolls to its row.
+
+### 2. Expiry countdown per row
+
+Extend `renderMyPins` so each row's meta line shows expiry. Add a small
+`relativeExpiry(expires_at)` next to `relativeTime`:
+
+- `expires_at` null → `permanent` (signed-in pins).
+- future → `expires in 6d` / `expires in 5h` / `expires in 12m`.
+- past (shouldn't surface — the feed filters expired) → `expired`.
+
+Use the existing `.irl-pin-meta` styling; keep `_pinMetaLine` (`:2454`) as the
+composer so distance + age + expiry read as one line.
+
+### 3. "Remove all from this device" bulk purge
+
+A footer button in the sheet (only shown when ≥1 pin and a `_deviceToken` exists).
+On tap → a **confirm** step (designed, not `window.confirm`): "Remove all N agents
+you placed from this device? This can't be undone." On confirm, delete them all and
+re-render to the empty state.
+
+Implement the delete with a new bulk branch on the existing endpoint to avoid N
+round-trips:
+
+```
+DELETE /api/irl/pins?all=1&deviceToken=<token>
+```
+
+In `api/irl/pins.js` DELETE (`:847`): when `req.query.all` is truthy and a
+`deviceToken` is present, delete **every** row matching that exact device token
+(`device_token = ${deviceToken}` — same strict, null-guarded ownership as the
+single delete; never a NULL/empty-token match), returning the deleted count. Keep
+the single-`id` path unchanged. Auth users without a device token are out of scope
+here (they manage permanent pins from the dashboard) — gate the button on
+`_deviceToken`.
+
+### 4. Designed states + a11y
+
+Loading (skeleton rows + map skeleton), empty (`MYPINS_EMPTY`), error (retry),
+purge confirm (focus-trapped, `Esc` cancels), and disabled/spinner states on the
+buttons during deletion. 320 / 768 / 1440px clean. Buttons have ARIA labels;
+destructive purge is clearly styled.
+
+## Data / API changes
+
+- New DELETE branch: `DELETE /api/irl/pins?all=1&deviceToken=` → `{ ok: true, deleted: N }`.
+ Strict device-token ownership, null-guarded exactly like `api/irl/pins.js:869`.
+- No schema change. `loadMyPins` already returns `lat/lng/expires_at` — no new read.
+
+## Acceptance checklist
+
+- [ ] My-pins sheet shows a Leaflet map of owned pins (fitBounds); CDN failure degrades to the list, never a blank/broken sheet.
+- [ ] Each row shows expiry: `permanent` / `expires in 6d` etc., composed into the existing meta line.
+- [ ] Marker tap highlights/scrolls to the matching row.
+- [ ] "Remove all from this device" appears only with ≥1 pin + a device token, runs a designed confirm, deletes all in one request, lands on the empty state.
+- [ ] Bulk DELETE matches **only** the caller's device token (a NULL/empty token deletes nothing); single-`id` delete unchanged.
+- [ ] Skeleton/empty/error/confirm states designed; keyboard + ARIA pass; no console errors.
+- [ ] `data/changelog.json` entry added (`improvement`); `npm run build:pages` passes.
+
+## Out of scope
+
+Editing a pin's location/caption from the sheet (dashboard remote management owns
+relocation). Bulk delete for signed-in/permanent pins (dashboard scope). Map
+placement of *new* pins (L2).
+
+## Verify
+
+`npm run dev` → `/irl` (use L1 mock to place a few test pins safely) → open My
+pins: map plots them, rows show countdowns, "Remove all" → confirm → Network tab
+shows one `DELETE …?all=1` returning the count, sheet shows the empty state, and a
+reload confirms they're gone from the nearby feed.
diff --git a/tasks/irl-privacy/08-trust-surface-docs-changelog.md b/tasks/irl-privacy/08-trust-surface-docs-changelog.md
new file mode 100644
index 000000000..537fd9aeb
--- /dev/null
+++ b/tasks/irl-privacy/08-trust-surface-docs-changelog.md
@@ -0,0 +1,77 @@
+# 08 — User-facing "how location works" trust surface + docs + changelog
+
+> Size **S–M** · A small in-app explainer + a help/docs page, doc cleanup of any
+> stale "realtime pin sync" references, and finalizing the changelog. Closes the epic.
+
+## Goal
+
+Tell users — plainly and proudly — how location works on /irl: agents are private by
+location, discovered only in person, never listed. For a safety feature, the
+*explanation* is part of the product: it's what converts "creepy AR thing that wants
+my camera and GPS" into "oh, this is actually thoughtful about privacy." Then scrub
+the docs of the old model and finalize the changelog.
+
+## Why it matters
+
+Trust is UX. The single biggest objection to a location-based AR app is "who can see
+where I put this / where I am?" A clear, honest answer — surfaced at the right moment
+and on a linkable page — is a feature, not boilerplate. And any doc still describing
+the removed realtime pin-sync ("agents update live across the neighborhood") is now a
+lie that erodes that trust.
+
+## Current state
+
+- The first-run explainer (task 02) carries a one-line privacy reassurance; this task
+ gives it a "Learn more" → a real page.
+- `data/changelog.json` has the entry "IRL world: placed agents are private by
+ location — discovered only in person" (already rewritten to the final model).
+ `public/changelog.{json,xml}` + `CHANGELOG.md` regenerate via `npm run build:pages`.
+- Search the repo/docs for stale language: any mention that IRL pins sync "live" /
+ "in realtime" across viewers, a "nearby list/feed," a "map of agents," or the old
+ bbox/window/`/internal/irl-publish` flow — in `docs/`, `pages/`, blog posts, SDK
+ docs, and code comments. Public copy must stay literal + professional
+ ([memory: public-copy-tone]).
+
+## What to build
+
+1. **In-app "How location works"** — reachable from the first-run explainer's "?" and
+ from a small link in the /irl onboarding/settings. Short, plain, honest:
+ - Agents are placed at real spots; you find them only by being near them in person.
+ - There is **no list or map** of where agents are — not for other users, and not a
+ public directory. (Your own placements are visible only to you, in your dashboard.)
+ - What others *can* see when you're around: an anonymous "someone is viewing
+ nearby" presence count and, if you opt in, a coarse ghost — never your exact GPS.
+ - Camera/motion/location are used on-device to render the scene; link the privacy
+ policy.
+2. **Docs cleanup** — update or remove every stale reference found above so docs
+ describe the proximity-only model. If a docs page described D1 realtime pin sync,
+ rewrite it to "presence + reactions are realtime; pins are discovered by proximity."
+3. **Changelog finalize** — confirm the existing entry reads cleanly for holders, run
+ `npm run build:pages` (it validates + regenerates), and after deploy run
+ `npm run changelog:push --dry-run` to preview the holder Telegram post (skip the
+ real push unless asked; creds may be absent locally).
+4. Remove the now-obsolete `smoke:irl-d1` script + `scripts/irl-d1-smoke.mjs` if still
+ present (the D1 realtime pin-sync it smoke-tested no longer exists).
+
+## Acceptance checklist
+
+- [ ] "How location works" surface exists, reachable in-app, plain + accurate, links
+ the privacy policy; copy is literal/professional (no sci-fi metaphors).
+- [ ] Zero stale references to realtime pin sync / nearby list / map / bbox / publish
+ webhook remain in `docs/`, `pages/`, blog, SDK docs, or code comments.
+- [ ] `data/changelog.json` entry final; `npm run build:pages` passes + regenerates
+ `CHANGELOG.md` + `public/changelog.{json,xml}`.
+- [ ] `changelog:push --dry-run` previews cleanly (no real push without ask).
+- [ ] Obsolete `smoke:irl-d1` script + file removed.
+- [ ] Clean at 320/768/1440; no console errors.
+
+## Out of scope
+
+The first-run explainer component itself (task 02 builds it; this adds its linked
+"Learn more" page + the privacy copy).
+
+## Verify
+
+`npm run dev` → open the "How location works" page from /irl; `grep -ri` the repo for
+the stale terms and confirm none remain in user-facing docs; `npm run build:pages`
+green.
diff --git a/tasks/irl-production/01-sensor-robustness.md b/tasks/irl-production/01-sensor-robustness.md
new file mode 100644
index 000000000..972b15b03
--- /dev/null
+++ b/tasks/irl-production/01-sensor-robustness.md
@@ -0,0 +1,64 @@
+# Task 01 — Sensor robustness: never let a bad reading break the lock
+
+**Phase:** 1 (AR correctness) · **Effort:** M · **Files:** `src/irl.js`
+
+## Why
+The world-lock camera is driven by `deviceorientation` (alpha/beta) and, on iOS,
+`webkitCompassHeading`. Real devices deliver `null`, `NaN`, uncalibrated, and
+discontinuous readings constantly. A single bad value currently propagates into
+`cameraYaw`/`cameraPitch`, which can make the avatar snap, spin, freeze, or vanish.
+This is the single most important reliability surface for the AR experience.
+
+## Read first (verify each finding against the live code before fixing)
+- `onDeviceOrientation()` — `src/irl.js:858-894`
+- `readCompassHeading()` — `src/irl.js:843-849`
+- `compassToYaw()` — `src/irl.js:851-856`
+- `lerpAngle()` (already defined, reuse it) — search `function lerpAngle`
+- The lock baseline capture — `src/irl.js:967-991` (setLocked)
+
+## Scope — confirm, then fix
+
+1. **Compass-loss goes undetected (stale heading).** `onDeviceOrientation` only
+ updates `lastCompassHeading` when `compass !== null` (≈line 864). If the
+ magnetometer becomes uncalibrated mid-session, `lastCompassHeading` keeps a
+ stale value and the absolute branch keeps trusting it. Track validity explicitly
+ (e.g. timestamp the last good reading) and fall back to the relative gyro path
+ when the compass goes stale, rather than steering by a dead bearing.
+
+2. **`NaN`/non-finite alpha & beta.** `const a = e.alpha ?? 0; const b = e.beta ?? 90;`
+ (≈line 859-860) only guards `null`/`undefined`, not `NaN`. A `NaN` flows through
+ the delta math into an invalid quaternion. Guard with `Number.isFinite()` and,
+ on a bad reading, **hold the last valid value** instead of substituting 0/90
+ (substituting 90 for beta yanks the pitch).
+
+3. **0° ↔ 360° yaw discontinuity.** The absolute branch assigns
+ `cameraYaw = compassToYaw(lastCompassHeading)` directly. Crossing the
+ 359°→1° boundary is a ~6.2 rad jump that reads as a violent spin. Smooth the
+ approach with the existing `lerpAngle()` (shortest-path) rather than a hard
+ assignment — fast enough to feel locked, smooth enough to never snap.
+
+4. **Pitch clamp sanity.** Confirm `cameraPitch` stays within `PITCH_MIN/PITCH_MAX`
+ on every path (it already clamps in some) and can never become `NaN`.
+
+## Implementation guidance
+- Extract the pure decision logic into a small testable helper, e.g.
+ `resolveLockYaw({ compassHeading, compassFresh, baseAlpha, alpha, baseYaw })`
+ returning the target yaw, and `isFiniteReading(a, b)`. Keep it side-effect free so
+ it can be unit-tested without the DOM/sensors.
+- Do not change the GPS-vs-local gating already in place
+ (`lastCompassHeading !== null && gpsModeActive`); build the robustness *inside*
+ each branch.
+
+## Out of scope
+Orientation/landscape handling (task 02), GPS lifecycle (task 03).
+
+## Definition of done
+- [ ] Every finding above either fixed or documented as already-correct with the line ref.
+- [ ] Pure helpers extracted and covered by a new `tests/irl-sensor-robustness.test.js`
+ (finite guards, compass-staleness fallback, shortest-path yaw across 0/360).
+- [ ] No path can write `NaN` to `cameraYaw`/`cameraPitch` (add a final
+ `Number.isFinite` guard before use as a backstop).
+- [ ] `npm test` green; `npx esbuild src/irl.js --outfile=/dev/null` clean.
+- [ ] Manual: on a real phone, spinning past north and waving the device through a
+ magnetic dead-zone never spins/freezes the avatar. Document what you tested.
+- [ ] Changelog entry if the user-visible jitter/spin is something holders would notice.
diff --git a/tasks/irl-production/02-orientation-resize-fov.md b/tasks/irl-production/02-orientation-resize-fov.md
new file mode 100644
index 000000000..571c29dad
--- /dev/null
+++ b/tasks/irl-production/02-orientation-resize-fov.md
@@ -0,0 +1,56 @@
+# Task 02 — Orientation changes, resize, and camera FOV fidelity
+
+**Phase:** 1 (AR correctness) · **Effort:** M · **Files:** `src/irl.js`, `pages/irl.html`
+
+## Why
+The AR math assumes portrait. When a user rotates to landscape, or the viewport
+resizes (browser chrome show/hide on scroll, split view), the camera optics and
+the gyro frame drift out of agreement with the real world: the avatar changes
+scale or slides off its anchor. A polished AR product holds the anchor through
+rotation.
+
+## Read first (verify before fixing)
+- FOV derivation from the video track — `src/irl.js:342-359` (runs once in `enableAR`)
+- Resize handler — search `addEventListener('resize'` and `function resize` in `src/irl.js`
+- Gyro yaw/pitch math (portrait assumption) — `src/irl.js:858-894`, GPS branch `~3946-3964`
+- Viewport meta + safe-area CSS — `pages/irl.html` `<meta name="viewport">` and `.irl-*` layout
+
+## Scope — confirm, then fix
+
+1. **FOV not re-derived on rotate.** The camera FOV is computed from the video
+ track resolution once in `enableAR()`. On `orientationchange` the resize handler
+ updates canvas size + `camera.aspect` but not FOV, so avatar scale is wrong in
+ landscape. On orientation change (and when the video track's reported dimensions
+ change), re-read `track.getSettings()` and re-derive FOV with the existing math.
+
+2. **Portrait-only gyro frame.** The yaw/pitch mapping assumes portrait. On a
+ screen-orientation change, fold `screen.orientation.angle` into the orientation
+ interpretation so the lock stays true when the device is held in landscape
+ (or document this as an explicit "portrait recommended" constraint with a
+ one-time hint if landscape support is deferred — but prefer to support it).
+
+3. **Resize/`visualViewport` robustness.** Ensure resize re-applies the perf tier's
+ pixel ratio and `renderer.setSize` correctly, and that iOS Safari's dynamic
+ toolbar (which fires resize on scroll) does not thrash. Debounce if needed.
+
+4. **Safe-area + notch.** Verify all fixed-position controls respect
+ `env(safe-area-inset-*)` in both orientations (joystick, bottom controls,
+ topbar). See task 10 for the full responsive pass; here just the AR-canvas /
+ camera-coupled pieces.
+
+## Implementation guidance
+- Listen to both `orientationchange` and `screen.orientation`'s `change` event
+ (feature-detect; iOS support varies) plus `resize`, funnel into one
+ `onViewportChanged()` that re-derives FOV + aspect + pixel ratio together.
+- Keep the FOV re-derivation a no-op when AR is off (no video track).
+
+## Out of scope
+Sensor finite-guards (task 01); pure responsive CSS not coupled to the camera (task 10).
+
+## Definition of done
+- [ ] Rotating the device portrait↔landscape keeps the avatar at correct real-world
+ scale and on its anchor (manual, real device — document results).
+- [ ] No console errors on rapid rotate/resize; renderer pixel ratio honored.
+- [ ] Any extracted angle math unit-tested.
+- [ ] `npm test` green; esbuild clean.
+- [ ] Changelog entry if behavior visibly improves for users.