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.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
IRL: pins hardening, discovery e2e, changelog regen
nirholas54d6edb17094
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 32224bfc0..dcc71fa88 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -22,6 +22,7 @@ Public history for [three.ws](https://three.ws), newest first. New pages come fr- **IRL is sharper on phones, in any orientation** — We polished IRL for the device it lives on. Every on-screen control now clears the notch and home indicator on modern phones — in portrait and landscape both — so nothing hides behind the camera cutout or rounded corners. On the narrowest phones the bottom controls wrap cleanly instead of squishing or clipping, and every button is a full finger-sized target. Typing a caption or message no longer makes Safari zoom the page in, long agent names truncate neatly instead of overflowing, and the calibrate readouts stay legible whichever way you hold the phone. (`/irl`) `[improvement]`- **IRL stays fast and recovers gracefully in long AR sessions** — IRL is built to run for an hour without slowing down. Swapping your avatar now fully releases the previous 3D model from memory instead of leaving it behind, so trying on a dozen looks in one session no longer piles up. If your phone reclaims graphics memory and the camera view would otherwise go black — a common thing on mobile after the tab sits idle — IRL now pauses cleanly and restores the scene, with a clear "AR paused, restoring…" card and a one-tap reload if your device needs it. Backgrounding the tab pauses the render loop and quiets the camera to save battery, then resumes the moment you come back. And as you move, avatars you walk past stop holding a load slot ahead of the ones you're heading toward, so the nearest agents always render first. (`/irl`) `[improvement]`- **IRL surfaces now show clear loading, empty, and error states** — Every IRL screen that loads data now has a designed loading, empty, and error state — no more stuck "Loading…" or blank screens. Open "My pins" and you'll see a skeleton while it loads, a friendly nudge to drop your first agent when you have none, and a one-tap Retry if the network hiccups. Tapping an agent shows the same care: if its profile can't load, you get a clear message and Retry while its name and a link to the full profile stay put. The nearby radar reads as intentionally empty ("Be the first to pin here") instead of a broken dial, and the count beside it no longer flashes "0 nearby" before we've finished looking. On devices that can't run the AR view, you get a helpful card explaining why and where to go next — not a bare error. (`/irl`) `[improvement]`+- **IRL teaches you how to find agents — and an empty area now feels alive** — IRL has no map and no list on purpose: you find agents by walking up to them and looking through your camera. The first time you open it, a short card now explains that idea — agents are hidden in the world around you, dropping your own lets someone else stumble on it later, and we never show a roster of where agents are, not even to you. You can reopen that explainer any time from the small "?" in the corner. And when you're somewhere quiet with nobody pinned yet, instead of a blank screen you'll see a gentle "Look around 👀 · or be the first to pin here" prompt with a one-tap way to place your own agent — so an empty spot reads as "keep exploring," not "this is broken." The moment a real agent comes into range, the prompt fades away on its own. (`/irl`) `[improvement]`- **One API, many services: the three.ws API gateway** — We bundled a stack of popular third-party APIs behind a single three.ws API so you can reach them all with one integration, one key, and one bill. The first providers are live at /api/v1/x — CoinGecko (live prices and ranked market data), DefiLlama (protocol TVL across all of DeFi), and any OpenAI-compatible LLM — with more landing over the coming releases. Discover everything with one call to GET /api/v1, which returns the full catalog: every provider, endpoint, parameter, and price. You can pay three ways, your choice per call: bring your own upstream key (we just route it, no markup), use a three.ws API key on your plan, or pay-per-call in USDC with no account at all. Every response uses one consistent shape with standard rate-limit headers, and the platform's own capabilities — text sentiment, market and narrative intelligence, and verified agent-card lookups — live under the same /api/v1 surface. `[feature, sdk]`- **Paid market-intel never charges you for unavailable data** — The pay-per-call market-intel endpoints (the $THREE Town Oracle and the crypto-intel kiosk) used to hand back an estimated "neutral" reading — and still take the payment — when their live price feed was rate-limited. They now return a clean "temporarily unavailable, retry shortly" instead, and crucially the payment is never settled when live data is missing. You only pay when you get a real, live signal. `[fix]`- **Platform-wide API security hardening** — We completed a full security audit of the API and tightened it across the board. Server errors no longer echo internal details back to callers — they return a short reference code you can quote to support, while the real diagnostics stay server-side (this also closes a path where a backend service key could surface in an error message). Account-changing actions made from the website — updating preferences, managing webhooks and payout wallets, marking notifications read, scheduling posts, setting skill prices — now carry cross-site request-forgery protection, so a malicious page can't act on your behalf. Sign-in, wallet-linking, GitHub connect and sensitive admin actions gained rate limits, and image-analysis requests are now screened so a supplied URL can't be used to probe internal systems. API access via developer keys is unaffected. `[security]`diff --git a/api/irl/pins.js b/api/irl/pins.jsindex f92b3473a..65c7a04bc 100644--- a/api/irl/pins.js+++ b/api/irl/pins.js@@ -1281,8 +1281,19 @@ export default wrap(async (req, res) => {updates.avatarUrl = c.value;}if ('x402Endpoint' in updates) {- const c = safeRemoteUrl(updates.x402Endpoint, { allowRelative: false });- if (!c.ok) return json(res, 400, { error: 'invalid x402Endpoint' });+ // Enforce the SAME first-party / allow-listed payment-host gate as POST —+ // safePaymentEndpoint, not bare safeRemoteUrl. Editing a pin must not be a+ // back door to point its Pay button at an arbitrary external drain host+ // (the exact vector the POST allow-list closes). Relative same-origin paths+ // stay first-party; a null/'' clears the endpoint.+ const c = safePaymentEndpoint(updates.x402Endpoint);+ if (!c.ok) {+ return json(res, 422, {+ error: 'endpoint',+ field: 'x402Endpoint',+ message: 'Pay endpoints must be hosted on three.ws.',+ });+ }updates.x402Endpoint = c.value;}diff --git a/data/changelog.json b/data/changelog.jsonindex d693cbc94..7b037d46f 100644--- a/data/changelog.json+++ b/data/changelog.json@@ -1,6 +1,15 @@{"$comment": "Curated changelog entries for three.ws — the editorial layer of the public changelog. New PAGE launches are tracked automatically via the `added` field in data/pages.json; this file is for everything else holders care about: improvements, fixes, SDK releases, trading/payments capabilities, security work. scripts/build-page-index.mjs merges both sources into CHANGELOG.md, public/changelog.json, and public/changelog.xml. Newest first. Allowed tags: feature, improvement, fix, sdk, infra, docs, security. `link` is optional and must be a live three.ws path.","entries": [+ {+ "date": "2026-06-19",+ "title": "IRL teaches you how to find agents — and an empty area now feels alive",+ "summary": "IRL has no map and no list on purpose: you find agents by walking up to them and looking through your camera. The first time you open it, a short card now explains that idea — agents are hidden in the world around you, dropping your own lets someone else stumble on it later, and we never show a roster of where agents are, not even to you. You can reopen that explainer any time from the small \"?\" in the corner. And when you're somewhere quiet with nobody pinned yet, instead of a blank screen you'll see a gentle \"Look around 👀 · or be the first to pin here\" prompt with a one-tap way to place your own agent — so an empty spot reads as \"keep exploring,\" not \"this is broken.\" The moment a real agent comes into range, the prompt fades away on its own.",+ "tags": [+ "improvement"+ ],+ "link": "/irl"+ },{"date": "2026-06-19","title": "IRL stays fast and recovers gracefully in long AR sessions",diff --git a/public/changelog.json b/public/changelog.jsonindex f573da554..1711dee1c 100644--- a/public/changelog.json+++ b/public/changelog.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-19T09:44:21.703Z",+ "generated_at": "2026-06-19T09:46:01.138Z","generated_by": "scripts/build-page-index.mjs from data/pages.json + data/changelog.json","site": {"name": "three.ws",@@ -170,6 +170,16 @@"improvement"]},+ {+ "date": "2026-06-19",+ "type": "update",+ "title": "IRL teaches you how to find agents — and an empty area now feels alive",+ "summary": "IRL has no map and no list on purpose: you find agents by walking up to them and looking through your camera. The first time you open it, a short card now explains that idea — agents are hidden in the world around you, dropping your own lets someone else stumble on it later, and we never show a roster of where agents are, not even to you. You can reopen that explainer any time from the small \"?\" in the corner. And when you're somewhere quiet with nobody pinned yet, instead of a blank screen you'll see a gentle \"Look around 👀 · or be the first to pin here\" prompt with a one-tap way to place your own agent — so an empty spot reads as \"keep exploring,\" not \"this is broken.\" The moment a real agent comes into range, the prompt fades away on its own.",+ "link": "/irl",+ "tags": [+ "improvement"+ ]+ },{"date": "2026-06-19","type": "update",diff --git a/public/changelog.xml b/public/changelog.xmlindex 49a696a8c..4f7c50381 100644--- a/public/changelog.xml+++ b/public/changelog.xml@@ -134,6 +134,14 @@<category>improvement</category><description>Every IRL screen that loads data now has a designed loading, empty, and error state — no more stuck "Loading…" or blank screens. Open "My pins" and you'll see a skeleton while it loads, a friendly nudge to drop your first agent when you have none, and a one-tap Retry if the network hiccups. Tapping an agent shows the same care: if its profile can't load, you get a clear message and Retry while its name and a link to the full profile stay put. The nearby radar reads as intentionally empty ("Be the first to pin here") instead of a broken dial, and the count beside it no longer flashes "0 nearby" before we've finished looking. On devices that can't run the AR view, you get a helpful card explaining why and where to go next — not a bare error.</description></item>+ <item>+ <title>IRL teaches you how to find agents — and an empty area now feels alive</title>+ <link>https://three.ws/irl</link>+ <guid isPermaLink="false">2026-06-19:IRL teaches you how to find agents — and an empty area now feels alive</guid>+ <pubDate>Fri, 19 Jun 2026 12:00:00 GMT</pubDate>+ <category>improvement</category>+ <description>IRL has no map and no list on purpose: you find agents by walking up to them and looking through your camera. The first time you open it, a short card now explains that idea — agents are hidden in the world around you, dropping your own lets someone else stumble on it later, and we never show a roster of where agents are, not even to you. You can reopen that explainer any time from the small "?" in the corner. And when you're somewhere quiet with nobody pinned yet, instead of a blank screen you'll see a gentle "Look around 👀 · or be the first to pin here" prompt with a one-tap way to place your own agent — so an empty spot reads as "keep exploring," not "this is broken." The moment a real agent comes into range, the prompt fades away on its own.</description>+ </item><item><title>One API, many services: the three.ws API gateway</title><link>https://three.ws/changelog</link>diff --git a/public/features.json b/public/features.jsonindex c3506a765..8c6d83523 100644--- a/public/features.json+++ b/public/features.json@@ -1,5 +1,5 @@{- "generated_at": "2026-06-19T09:44:21.311Z",+ "generated_at": "2026-06-19T09:46:00.967Z","generated_by": "scripts/build-page-index.mjs from data/pages.json","site": {"name": "three.ws",diff --git a/src/irl.js b/src/irl.jsindex f6f36ef5f..512505773 100644--- a/src/irl.js+++ b/src/irl.js@@ -54,7 +54,7 @@ import { startOnboarding, ensurePermission, needsMotionGesture, setPermissionStaimport { 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 { roomOriginWorld, agentWorldPosition, localToGeo, calibrateRoomOrigin } from './irl/room-anchor.js';import { anchorPoseToPin, yawDegFromQuat } from './irl/floor-anchor.js';import { initRoomMode } from './irl/room-mode.js';import { isFiniteReading, isCompassFresh, shouldUseAbsoluteYaw, resolveLockYaw, clampPitch, screenPitchDeg } from './irl/sensor-fusion.js';@@ -1413,17 +1413,38 @@ function pinHeightM(pin) {// 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. The proximity-poll// projection delivers these as snake_case, the one shape this reads.++// Per-room viewer-local frame rotation (R2 relative-frame alignment). A room+// placed WITHOUT an absolute compass (origin_yaw_deg ≠ 0, or anchor_source+// 'gyro-gps:rel') can't recover true north from GPS alone, so its layout may+// render rotated for another viewer. The one-tap "face the room's front and tap"+// alignment captures an extra rotation THIS viewer applies on top of the stored+// frame so the cluster sits where the real room is. It's viewer-local — never+// sent to the server, it doesn't move the room for anyone else — and persisted+// per room so it survives a reload.+const ROOM_ALIGN_KEY = 'irl_room_align_v1';+const _roomYawOffset = new Map(); // roomId → extra degrees, viewer-local+try {+ const saved = JSON.parse(localStorage.getItem(ROOM_ALIGN_KEY) || '{}');+ for (const [k, v] of Object.entries(saved)) if (Number.isFinite(v)) _roomYawOffset.set(k, v);+} catch { /* corrupt store → start fresh */ }+function persistRoomAlign() {+ try { localStorage.setItem(ROOM_ALIGN_KEY, JSON.stringify(Object.fromEntries(_roomYawOffset))); } catch { /* private mode */ }+}+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;+ const extra = _roomYawOffset.get(pin.room_id) || 0;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,+ // Stored frame + this viewer's one-tap alignment (0 for a true-north room).+ originYawDeg: (Number(pin.origin_yaw_deg) || 0) + extra,};}@@ -2428,7 +2449,15 @@ function showXrError(err) {}async function enterFloorAnchor() {+ // Block while a prior camera/XR handoff is still settling — a fast double-tap, or+ // a tap during disableAR → session start, must not start a second session or+ // re-acquire the camera underneath this one.+ if (_arTransitioning) return;+ // Re-tapping the button once the session is fully live toggles it off. (Mid-startup+ // the guard above already absorbed the tap, so this only ever ends a started+ // session — never a half-built one.)if (xrSession) { await xrSession.end(); return; }+ _arTransitioning = true;// immersive-ar owns the rear camera and the full screen; release the// getUserMedia passthrough first so the two don't contend for the camera.// Remember whether the user was in camera-AR so we can put them back there on@@ -2441,6 +2470,7 @@ async function enterFloorAnchor() {if (xrOverlay) xrOverlay.hidden = false;resetXrHint();+ let failedStart = false;try {xrSession = new WebXRSession(xrViewer, {domOverlayRoot: xrOverlay,@@ -2458,28 +2488,59 @@ async function enterFloorAnchor() {// placement, so don't surprise them with a pin saved after they walk// away (parity with the gyro path's arActive gate).floorPersist.drop();- // WebXRSession restores an opaque clear color on exit; IRL renders- // over the page gradient with a transparent canvas — put that back.+ // WebXRSession restored an OPAQUE clear color on exit (_handleEnd); IRL+ // always renders the canvas transparent (alpha:true) over the page+ // gradient or the camera feed. Re-assert transparent + the ground that+ // matches the mode we return to, so passthrough resumes rather than a+ // black fill.renderer.setClearColor(0x000000, 0);- if (!arActive) scene.background = null;+ scene.background = null;if (anchorBtn) anchorBtn.classList.remove('is-active');if (xrOverlay) xrOverlay.hidden = true;- // Return the user to camera-AR if that's where they came from — same- // path whether they tapped Exit or the OS ended the session.- if (resumeAR && !arActive) enableAR();+ if (resumeAR) {+ // Returning to camera-AR: show the soft passthrough contact shadow+ // now; enableAR() re-acquires the stream and finishes the rest (FOV,+ // status) async. enableAR() no-ops if a failed start left the guard+ // raised — the post-settle resume below covers that case.+ groundOpaque.visible = false;+ groundShadow.visible = true;+ enableAR();+ } else {+ // Back to the plain 3D view: opaque ground, no passthrough shadow.+ groundOpaque.visible = true;+ groundShadow.visible = false;+ }},});await xrSession.start();setStatus('Floor anchoring on — find the floor, then tap to place your agent');} catch (err) {log.error('[irl] WebXR start failed:', err);+ failedStart = true;+ // A session that created its XRSession but threw mid-setup never reached+ // setAnimationLoop, so its 'end' (→ onEnd) won't fire on its own. Tear it down+ // explicitly so we don't leak a live immersive session, and reset the renderer+ // state it touched (xr.enabled was set true before requestSession; an opaque+ // clear color restored on its 'end'). The IRL RAF kept running through the+ // failure, so the scene stays live — never frozen.+ const failed = xrSession;xrSession = null;+ if (failed) { try { await failed.end(); } catch {} }+ renderer.xr.enabled = false;+ renderer.setClearColor(0x000000, 0);+ scene.background = null;if (anchorBtn) anchorBtn.classList.remove('is-active');- // The start failed before any session existed, so onEnd never runs — restore- // the camera-AR the user was in directly so the entry attempt isn't one-way.- if (resumeAR && !arActive) enableAR();+ if (xrOverlay) xrOverlay.hidden = true;showXrError(err);+ } finally {+ _arTransitioning = false;}+ // Resume camera-AR once the guard has cleared. On a failed start, onEnd's own+ // resume was suppressed by the still-raised guard (when the session reached+ // _handleEnd), or onEnd never fired (requestSession rejected) — either way the+ // entry attempt must not be one-way. No-op on success or when there was no AR to+ // return to; enableAR() re-checks every precondition.+ if (failedStart && resumeAR && !arActive && !xrSession) enableAR();}// Entry point for a placed floor anchor: persist it now if we have a GPS fix,diff --git a/tests/api/irl-pins-hardening.test.js b/tests/api/irl-pins-hardening.test.jsindex 006b32768..08ce5e003 100644--- a/tests/api/irl-pins-hardening.test.js+++ b/tests/api/irl-pins-hardening.test.js@@ -235,6 +235,27 @@ describe('DELETE /api/irl/pins — pin-id validation', () => {});});+// ── PATCH x402 edit must enforce the SAME allow-list as POST (task 13) ────────+// Editing a pin can't be a back door around the first-party payment-host gate.+describe('PATCH /api/irl/pins — x402 edit honours the payment-host allow-list', () => {+ beforeEach(() => { sessionUser = { id: 'owner-uuid' }; });+ it('422s an arbitrary external x402 host on edit, never reaching the UPDATE', async () => {+ const { res, body } = await patch({ id: UUID, x402Endpoint: 'https://evil.example.com/drain' });+ expect(res.statusCode).toBe(422);+ expect(body.error).toBe('endpoint');+ expect(body.field).toBe('x402Endpoint');+ const ranEdit = sqlMock.mock.calls.some(([s]) =>+ /UPDATE irl_pins SET[\s\S]*x402_endpoint/i.test(Array.isArray(s) ? s.join(' ') : String(s)));+ expect(ranEdit).toBe(false);+ });+ it('accepts a same-origin relative pay path on edit (passes the allow-list)', async () => {+ const { res } = await patch({ id: UUID, x402Endpoint: '/api/x402-pay' });+ // Allow-list accepted it — not a 422 endpoint rejection. (The mocked field-edit+ // UPDATE returns no row, so the handler then 404s; the point is it got past the gate.)+ expect(res.statusCode).not.toBe(422);+ });+});+// ── Expiry guard on mutations (task 13) ──────────────────────────────────────describe('calibrate — refuses an expired pin', () => {it('404s an expired pin even for the owner, and never UPDATEs', async () => {diff --git a/tests/e2e/irl-discovery.spec.js b/tests/e2e/irl-discovery.spec.jsnew file mode 100644index 000000000..05f53ac51--- /dev/null+++ b/tests/e2e/irl-discovery.spec.js@@ -0,0 +1,183 @@+/**+ * /irl discovery + location-privacy — Playwright e2e (task 07).+ *+ * Locks the headline privacy invariant end-to-end in a real browser: agents are+ * discovered ONLY by being physically near them. There is no roster, no map, and+ * the client must never hold the coordinates of an out-of-range agent — even one+ * the server (wrongly) hands it.+ *+ * Hermetic by construction: /api/irl/pins is routed to deterministic rows and the+ * fix-token mint is stubbed, so no live DB, RPC, or socket is touched. A tiny+ * DEV-only seam (window.__irlE2E, src/irl.js) drives the REAL proximity reconcile+ * (loadNearbyPins → the asymmetric ENTER/EXIT hysteresis band) against a fixed GPS+ * and reads back exactly what the client is holding — so the assertions exercise the+ * production discovery path, not a test double of it.+ *+ * Coverage:+ * • zero pins → the designed empty state ("be the first to pin here")+ * • served-but-far → an out-of-range pin is NEVER rendered or held+ * • walk into range → the in-range pin spawns and renders+ * • mixed response → only the in-range pin survives; the far coordinate is+ * provably absent from client state (the privacy assertion)+ * • no console errors anywhere in the flow+ */++import { test, expect } from '@playwright/test';++// The viewer's fixed origin. A precision-6 cell somewhere ordinary (downtown SF).+const VIEWER = { lat: 37.7749, lng: -122.4194 };++// A nearby pin row in the shape /api/irl/pins returns. Coordinates are filled per+// test from the viewer origin + a metres offset so the distance is exact.+function pinRow(id, lat, lng, name) {+ return {+ id,+ lat,+ lng,+ heading: 0,+ avatar_url: '/avatars/default.glb',+ avatar_name: name,+ caption: '',+ x402_endpoint: null,+ agent_id: null,+ placed_at: '2026-01-01T00:00:00Z',+ view_count: 0,+ room_id: null,+ rel_east_m: null,+ rel_north_m: null,+ origin_lat: null,+ origin_lng: null,+ origin_yaw_deg: null,+ gps_accuracy_m: 8,+ altitude_m: null,+ anchor_source: null,+ avatar_version: 0,+ };+}++// Offset (north/east metres) → a coordinate, mirroring the seam's own helper so the+// spec can plant a pin at an exact distance without booting the app first.+function offset(lat, lng, north, east) {+ const mLat = 110540;+ const mLng = 111320 * Math.cos(lat * (Math.PI / 180));+ return { lat: lat + north / mLat, lng: lng + east / mLng };+}++// Install hermetic routes: the nearby read serves whatever `served()` returns now+// (so a test can change the response between polls), and the fix-token mint is a+// no-op stub. Returns a setter the test drives.+async function installRoutes(page) {+ let served = [];+ // Only the nearby read (query form) — never /api/irl/pins/mine.+ await page.route(/\/api\/irl\/pins\?/, (route) =>+ route.fulfill({ json: { pins: served } }),+ );+ await page.route('**/api/irl/fix-token', (route) =>+ route.fulfill({ json: { token: 'e2e-fix', expires_in: 300 } }),+ );+ return (rows) => { served = rows; };+}++// Boot /irl and wait for the app + its DEV e2e seam to be live (proves WebGL came+// up and irl.js evaluated). The first cold hit transforms the full three.js graph.+async function bootIrl(page) {+ await page.goto('/irl');+ await page.waitForFunction(() => !!window.__irlE2E, null, { timeout: 90_000 });+}++// Collect console errors, ignoring dev-server noise (Vite HMR websocket can't reach+// the forwarded test origin in headless Codespaces — not a product bug).+function trackConsoleErrors(page) {+ const errors = [];+ page.on('console', (m) => {+ if (m.type() !== 'error') return;+ const t = m.text();+ if (/websocket|hmr|wss:|vite|favicon|net::ERR/i.test(t)) return;+ errors.push(t);+ });+ page.on('pageerror', (err) => {+ if (/websocket|hmr|wss:/i.test(err.message)) return;+ errors.push(`pageerror: ${err.message}`);+ });+ return errors;+}++test.describe('/irl discovery + location privacy', () => {+ test('out-of-range hidden, in-range renders, empty state, no console errors', async ({ page }) => {+ test.setTimeout(120_000);+ const errors = trackConsoleErrors(page);+ const setServed = await installRoutes(page);++ await bootIrl(page);+ await page.evaluate((v) => window.__irlE2E.setGps(v.lat, v.lng), VIEWER);++ // (c) Zero pins → designed empty state, never a blank void.+ setServed([]);+ await page.evaluate(() => window.__irlE2E.poll());+ expect(await page.evaluate(() => window.__irlE2E.nearby())).toEqual([]);+ const badge = page.locator('#irl-nearby-badge');+ await expect(badge).toHaveClass(/is-empty/);+ await expect(badge).toContainText(/be the first to pin here/i);++ // (a) A served pin 200 m away — far past the 40 m ENTER gate — is NEVER+ // rendered and never enters client state. Even if the server leaks a far row,+ // the client band refuses it.+ const far = offset(VIEWER.lat, VIEWER.lng, 200, 0);+ setServed([pinRow('pin-far', far.lat, far.lng, 'Faraway')]);+ await page.evaluate(() => window.__irlE2E.poll());+ expect(await page.evaluate(() => window.__irlE2E.nearby())).toEqual([]);+ await expect(badge).toHaveClass(/is-empty/);++ // (b) Walk into range: the same agent is now 10 m away (inside ENTER) → it+ // crosses the gate, spawns, and renders.+ const near = offset(VIEWER.lat, VIEWER.lng, 10, 0);+ setServed([pinRow('pin-near', near.lat, near.lng, 'Closeby')]);+ await page.evaluate(() => window.__irlE2E.poll());+ const held = await page.evaluate(() => window.__irlE2E.nearby());+ expect(held).toHaveLength(1);+ expect(held[0].id).toBe('pin-near');+ expect(held[0].rendered).toBe(true);+ expect(held[0].distance).toBeLessThanOrEqual(40);+ await expect(badge).toContainText(/1 nearby/);++ // (d) The whole flow ran without a single console error from our code.+ expect(errors).toEqual([]);+ });++ test('privacy: a mixed response keeps only the in-range pin — the far coordinate never reaches the client', async ({ page }) => {+ test.setTimeout(120_000);+ const errors = trackConsoleErrors(page);+ const setServed = await installRoutes(page);++ await bootIrl(page);+ await page.evaluate((v) => window.__irlE2E.setGps(v.lat, v.lng), VIEWER);++ // The server returns BOTH an in-range pin (8 m) and a far one (300 m) in the+ // same payload — the exact shape a roster leak would take. The client must+ // keep only the in-range pin; the far coordinate must be absent everywhere.+ const near = offset(VIEWER.lat, VIEWER.lng, 8, 0);+ const far = offset(VIEWER.lat, VIEWER.lng, 300, 0);+ setServed([+ pinRow('pin-in', near.lat, near.lng, 'InRange'),+ pinRow('pin-out', far.lat, far.lng, 'OutOfRange'),+ ]);+ await page.evaluate(() => window.__irlE2E.poll());++ const held = await page.evaluate(() => window.__irlE2E.nearby());+ // Exactly one pin — the in-range one — is held.+ expect(held).toHaveLength(1);+ expect(held[0].id).toBe('pin-in');++ // The far pin's id and coordinate are provably absent from the client's pin+ // state. We serialize the whole held set and assert the out-of-range latitude+ // (a value the client would only have if it stored the far row) never appears.+ const serialized = JSON.stringify(held);+ expect(serialized).not.toContain('pin-out');+ expect(serialized).not.toContain(String(far.lat));++ // And the DOM agrees: a label for the out-of-range agent was never mounted.+ expect(await page.locator('text=OutOfRange').count()).toBe(0);++ expect(errors).toEqual([]);+ });+});