diff --git a/BACKEND_HANDOFF.md b/BACKEND_HANDOFF.md
index 24bc271..8fb645d 100644
--- a/BACKEND_HANDOFF.md
+++ b/BACKEND_HANDOFF.md
@@ -242,6 +242,18 @@ Published only. Unknown AND unpublished return the SAME 404 body
}
```
+### HOUSE profile (Wave 5A, D2)
+The reserved handle `HOUSE_HANDLE` (env, default `vyndr`) resolves to the
+PUBLIC model record (`getModelAggregate()` with NO userId → the `user_id=NULL`
+ledger rows) WITHOUT a `public_profiles` row, and is ALWAYS public (the
+partner-pitch weapon). Same response shape + two extra fields:
+`{ ..., house: true, label: 'VYNDR MODEL · PUBLIC RECORD' }`. Entries are the
+public settled rows (`user_id IS NULL`, misses included). Reserved before the
+publish lookup — a user who claims it is shadowed. Every OTHER handle keeps the
+private-by-default, byte-identical-404 contract. It never 404s (a fetch failure
+degrades to an honest empty/building state). Portrait share crop: route handler
+`GET /u/[handle]/portrait` → 1080×1350 PNG (real aggregate or tagline fallback).
+
### `GET|POST /api/profiles/me` (requireAuth)
GET → `{ profile: { handle, published, created_at } | null }`.
POST `{ handle, published }` → upsert own row (service role). Handle must
diff --git a/src/routes/profiles.js b/src/routes/profiles.js
index 8e0f753..402c395 100644
--- a/src/routes/profiles.js
+++ b/src/routes/profiles.js
@@ -19,6 +19,13 @@
* PRIVACY: PRIVATE BY DEFAULT — `published` only flips via the explicit
* toggle. NO EXISTENCE LEAK: an unknown handle and an unpublished handle
* return the byte-identical 404 body.
+ *
+ * HOUSE PROFILE (Wave 5A, D2) — the reserved `HOUSE_HANDLE` (default `vyndr`)
+ * resolves to the PUBLIC model record (`getModelAggregate()` with NO userId →
+ * the `user_id = NULL` ledger rows). It needs NO public_profiles row and is
+ * ALWAYS public (it's the partner-pitch weapon: the real house record). It is
+ * the ONLY special case; every OTHER handle keeps the private-by-default,
+ * no-existence-leak contract intact.
*/
const express = require('express');
@@ -30,6 +37,10 @@ const router = express.Router();
router.use(createRateLimit({ windowMs: 60_000, max: 60 }));
const HANDLE_RE = /^[a-z0-9_]{3,20}$/;
+// Reserved house handle → the public model record (user_id = NULL). Operators
+// can override via env; it must still satisfy HANDLE_RE to be reachable.
+const HOUSE_HANDLE = String(process.env.HOUSE_HANDLE || 'vyndr').trim().toLowerCase();
+const HOUSE_LABEL = 'VYNDR MODEL · PUBLIC RECORD';
// Same 404 body for unknown AND unpublished — never confirm a handle exists.
const NOT_FOUND = { error: 'Profile not found' };
// Same columns as /api/ledger (routes/ledger.js ROW_COLUMNS).
@@ -94,6 +105,10 @@ router.get('/:handle', async (req, res) => {
const handle = String(req.params.handle || '').trim().toLowerCase();
// Invalid shape can't exist (DB CHECK) → same 404, no query needed.
if (!HANDLE_RE.test(handle)) return res.status(404).json(NOT_FOUND);
+ // HOUSE handle → the public model record. Checked BEFORE the
+ // public_profiles lookup so the handle is reserved (a user who claims it is
+ // shadowed). This is the ONLY handle that bypasses the publish gate.
+ if (handle === HOUSE_HANDLE) return sendHouseProfile(res);
const sb = sbOrNull();
if (!sb) return res.status(404).json(NOT_FOUND);
try {
@@ -131,4 +146,52 @@ router.get('/:handle', async (req, res) => {
}
});
+/**
+ * The house/model profile — the PUBLIC model record (user_id = NULL), served
+ * as a shareable /u profile WITHOUT a public_profiles row. Same response shape
+ * the page already consumes (aggregate + by_tier + settled entries), plus
+ * `house: true` + a label so the UI can distinguish it from a user profile.
+ * It always "exists" → a fetch failure degrades to an honest empty/building
+ * state, never a 404.
+ */
+async function sendHouseProfile(res) {
+ const sb = sbOrNull();
+ try {
+ // NO userId → the public `user_id = NULL` aggregate (the real house
+ // record + Wave-3 by_tier). getModelAggregate self-empties without env.
+ const aggregate = await ledgerService.getModelAggregate(sb ? { sb } : {});
+ let entries = [];
+ if (sb) {
+ // ALL public settled reads, misses included — nothing curated.
+ const { data, error } = await sb.from('ledger_entries')
+ .select(ROW_COLUMNS)
+ .is('user_id', null)
+ .not('outcome', 'is', null)
+ .order('graded_at', { ascending: false })
+ .limit(ENTRY_LIMIT);
+ if (error) throw new Error(error.message);
+ entries = data || [];
+ }
+ res.set('Cache-Control', 'public, max-age=60');
+ return res.json({
+ handle: HOUSE_HANDLE,
+ house: true,
+ label: HOUSE_LABEL,
+ aggregate,
+ entries,
+ min_sample: ledgerService.MIN_AGG_SAMPLE,
+ });
+ } catch (err) {
+ console.error('[profiles/house]', err.message);
+ return res.status(200).json({
+ handle: HOUSE_HANDLE,
+ house: true,
+ label: HOUSE_LABEL,
+ aggregate: null,
+ entries: [],
+ min_sample: ledgerService.MIN_AGG_SAMPLE,
+ });
+ }
+}
+
module.exports = router;
diff --git a/tests/unit/houseProfile.test.js b/tests/unit/houseProfile.test.js
new file mode 100644
index 0000000..751cf13
--- /dev/null
+++ b/tests/unit/houseProfile.test.js
@@ -0,0 +1,170 @@
+// Wave 5A (D2) — the HOUSE/model /u profile. The reserved house handle
+// (`vyndr`) resolves to the PUBLIC model record (user_id = NULL) WITHOUT a
+// public_profiles row — the partner-pitch weapon. Every OTHER handle keeps the
+// private-by-default, no-existence-leak 404 (a byte-identical body for unknown
+// AND unpublished). Supabase + auth mocked (profilesRoutes.test.js pattern) —
+// no network, no live Supabase.
+
+const express = require('express');
+const request = require('supertest');
+const fs = require('fs');
+const path = require('path');
+
+jest.mock('../../src/middleware/auth', () => ({
+ requireAuth: (req, res, next) => {
+ if (!req.headers.authorization) return res.status(401).json({ error: 'auth required' });
+ req.user = { id: 'u1', tier: 'analyst' };
+ return next();
+ },
+}));
+
+const mockState = {
+ profileRow: null,
+ ledgerRows: [],
+ filters: [], // [table, filters[]]
+};
+
+function mockChain(table) {
+ const b = { _filters: [] };
+ const rec = (op) => (...args) => { b._filters.push([op, ...args]); return b; };
+ b.select = () => b;
+ b.eq = rec('eq');
+ b.is = rec('is');
+ b.not = rec('not');
+ b.gte = rec('gte');
+ b.order = () => b;
+ b.maybeSingle = () => {
+ mockState.filters.push([table, b._filters]);
+ return Promise.resolve({ data: mockState.profileRow, error: null });
+ };
+ b.limit = () => {
+ mockState.filters.push([table, b._filters]);
+ return Promise.resolve({ data: mockState.ledgerRows, error: null, count: 0 });
+ };
+ b.then = (resolve, reject) => {
+ mockState.filters.push([table, b._filters]);
+ return Promise.resolve({ data: mockState.ledgerRows, error: null, count: 0 }).then(resolve, reject);
+ };
+ return b;
+}
+
+jest.mock('../../src/utils/supabase', () => ({
+ getSupabaseServiceClient: () => ({ from: (table) => mockChain(table) }),
+}));
+
+process.env.SUPABASE_URL = 'https://test.supabase.co';
+process.env.SUPABASE_SERVICE_ROLE_KEY = 'test-key';
+
+function mountApp() {
+ // resetModules forces profiles.js to re-read process.env.HOUSE_HANDLE (jest
+ // ignores require.cache deletes). The jest.mock factories re-apply.
+ jest.resetModules();
+ const routes = require('../../src/routes/profiles');
+ const app = express();
+ app.use(express.json());
+ app.use('/api/profiles', routes);
+ return app;
+}
+
+beforeEach(() => {
+ mockState.profileRow = null;
+ mockState.ledgerRows.length = 0;
+ mockState.filters.length = 0;
+});
+
+describe('GET /api/profiles/vyndr — the HOUSE/model profile', () => {
+ test('resolves the public user_id=NULL aggregate with NO public_profiles row', async () => {
+ // Note: profileRow stays null — the house handle must NOT need a claim.
+ mockState.ledgerRows.push({ id: 'r1', player_name: 'Judge', outcome: 'hit', grade: 'A', clv_result: 'beat', clv: 0.5 });
+ const res = await request(mountApp()).get('/api/profiles/vyndr');
+
+ expect(res.status).toBe(200);
+ expect(res.body.handle).toBe('vyndr');
+ expect(res.body.house).toBe(true);
+ expect(res.body.label).toBe('VYNDR MODEL · PUBLIC RECORD');
+ expect(res.body.min_sample).toBe(20);
+ expect(res.body.aggregate).toBeTruthy();
+ // Wave 3 per-tier calibration rides along inside the aggregate.
+ expect(res.body.aggregate.by_tier).toBeDefined();
+ // n<20 gate honored: hit_pct is present but null (not a small-sample %).
+ expect(res.body.aggregate.hit_pct).toBeNull();
+ expect(Array.isArray(res.body.entries)).toBe(true);
+
+ // The public_profiles table was NEVER queried (handle is reserved).
+ expect(mockState.filters.filter(([t]) => t === 'public_profiles')).toHaveLength(0);
+
+ // Every ledger query is the PUBLIC record (user_id IS NULL), never a user.
+ const ledgerQueries = mockState.filters.filter(([t]) => t === 'ledger_entries');
+ expect(ledgerQueries.length).toBeGreaterThan(0);
+ for (const [, filters] of ledgerQueries) {
+ expect(filters.some((f) => f[0] === 'is' && f[1] === 'user_id' && f[2] === null)).toBe(true);
+ expect(filters.some((f) => f[0] === 'eq' && f[1] === 'user_id')).toBe(false);
+ }
+ // The entries list is settled rows only.
+ const entriesQ = ledgerQueries.find(([, f]) => f.some((x) => x[0] === 'not' && x[1] === 'outcome'));
+ expect(entriesQ).toBeTruthy();
+ });
+
+ test('honors an env override for the house handle', async () => {
+ const prev = process.env.HOUSE_HANDLE;
+ process.env.HOUSE_HANDLE = 'house';
+ try {
+ const res = await request(mountApp()).get('/api/profiles/house');
+ expect(res.status).toBe(200);
+ expect(res.body.house).toBe(true);
+ // The default handle is no longer reserved → falls through to 404.
+ const other = await request(mountApp()).get('/api/profiles/vyndr');
+ expect(other.status).toBe(404);
+ } finally {
+ if (prev === undefined) delete process.env.HOUSE_HANDLE; else process.env.HOUSE_HANDLE = prev;
+ }
+ });
+});
+
+describe('privacy preserved — the house handle is the ONLY special case', () => {
+ test('NO EXISTENCE LEAK — unknown and unpublished USER handles are byte-identical 404s', async () => {
+ mockState.profileRow = null;
+ const unknown = await request(mountApp()).get('/api/profiles/ghost_handle');
+
+ mockState.profileRow = { user_id: 'u3', handle: 'private_kev', published: false };
+ const unpublished = await request(mountApp()).get('/api/profiles/private_kev');
+
+ expect(unknown.status).toBe(404);
+ expect(unpublished.status).toBe(404);
+ expect(unknown.body).toEqual(unpublished.body);
+ expect(unknown.body).toEqual({ error: 'Profile not found' });
+ });
+
+ test('an unpublished USER handle still leaks NO ledger data', async () => {
+ mockState.profileRow = { user_id: 'u3', handle: 'private_kev', published: false };
+ mockState.ledgerRows.push({ id: 'r1', player_name: 'Judge', outcome: 'hit', grade: 'A' });
+ const res = await request(mountApp()).get('/api/profiles/private_kev');
+ expect(res.status).toBe(404);
+ expect(res.body.entries).toBeUndefined();
+ expect(mockState.filters.filter(([t]) => t === 'ledger_entries')).toHaveLength(0);
+ });
+});
+
+describe('/u/[handle] renders the house label + per-tier calibration', () => {
+ const WEB = path.join(__dirname, '..', '..', 'web', 'src');
+ const read = (rel) => fs.readFileSync(path.join(WEB, rel), 'utf8');
+
+ it('PublicProfile shows the house label off data.house + keeps TierRecord', () => {
+ const src = read('app/u/[handle]/PublicProfile.tsx');
+ expect(src).toContain('VYNDR MODEL · PUBLIC RECORD');
+ expect(src).toMatch(/data\.house/);
+ expect(src).toContain('TierRecord');
+ });
+
+ it('has a portrait 1080x1350 share crop route', () => {
+ const src = read('app/u/[handle]/portrait/route.tsx');
+ expect(src).toContain('1080');
+ expect(src).toContain('1350');
+ expect(src).not.toContain("runtime = 'edge'");
+ });
+
+ it('is discoverable — a link to /u/vyndr on the ledger + landing record surfaces', () => {
+ expect(read('app/ledger/page.tsx')).toContain('/u/vyndr');
+ expect(read('app/page.tsx')).toContain('/u/vyndr');
+ });
+});
diff --git a/web/src/app/ledger/page.tsx b/web/src/app/ledger/page.tsx
index 6a73355..2c46a37 100644
--- a/web/src/app/ledger/page.tsx
+++ b/web/src/app/ledger/page.tsx
@@ -1,6 +1,7 @@
'use client';
import { useCallback, useEffect, useState } from 'react';
+import Link from 'next/link';
import { GradePill } from '@/components/GradeCard';
import { useAuth } from '@/contexts/AuthContext';
import { Skeleton, EmptyState, ArchetypeBadge, BookWordmark, TierRecord } from '@/components/vyndr';
@@ -284,6 +285,17 @@ function ModelHeader({ agg, minSample }: { agg: ModelAggregate; minSample: numbe
{/* Wave 3 (Addition 2) — the ONE shared record-by-grade-tier table,
identical here, on the dashboard, and on /u. */}
- PUBLIC LEDGER + {isHouse ? (data.label || 'VYNDR MODEL · PUBLIC RECORD') : 'PUBLIC LEDGER'}
- Every settled read. Wins and misses. Nothing curated. + {isHouse + ? 'The VYNDR model’s public record. Every graded read, wins and misses, closing-line value included.' + : 'Every settled read. Wins and misses. Nothing curated.'}