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
fix(likeness): keep benchmark runs out of the gate rate they are meant to measure
nirholas6727e22c206b
diff --git a/api/_lib/likeness-store.js b/api/_lib/likeness-store.jsindex 7014403b3..082ee7164 100644--- a/api/_lib/likeness-store.js+++ b/api/_lib/likeness-store.js@@ -88,6 +88,42 @@ function safeParse(text) {}}+// The status a benchmark subject is filed under.+//+// A live `scripts/likeness-eval.mjs --live` run submits REAL reconstructions+// through the real pipeline, so each one registers a real generation record and+// would otherwise be picked up by the next sweep and counted toward the gate+// rate the roadmap is judged on. That is benchmark traffic scoring itself, and+// a metric that quietly includes its own test harness is not measuring the+// product any more.+//+// Filing the score under this status rather than 'ok' solves both halves at+// once and needs no new column: the distribution's aggregates and histogram+// already filter `status = 'ok'`, so a benchmark row can never move the gate+// rate, while the outcome breakdown and the recent table carry no status filter,+// so the row stays visible and honest rather than hidden. The work-queue join+// excludes any creation that already has a row of any status, so the subject is+// also never re-picked.+export const BENCHMARK_STATUS = 'benchmark';++// Which generation record a reconstruct job produced. Live mode holds a job id+// and needs the creation id to file against; nothing else walks that direction.+export async function creationIdForJob(jobId) {+ if (!likenessStoreEnabled() || !jobId) return null;+ try {+ const rows = await sql`+ select id, avatar_id from forge_creations+ where replicate_job_id = ${jobId} and path = 'reconstruct'+ limit 1+ `;+ return rows[0] ? { creationId: rows[0].id, avatarId: rows[0].avatar_id } : null;+ } catch (err) {+ if (isDbUnavailableError(err)) console.warn('[likeness] creation lookup skipped (db unavailable):', err?.message);+ else console.error('[likeness] creation lookup failed:', err?.message);+ return null;+ }+}+// Upsert one score. Re-scoring the same creation with a newer instrument// overwrites in place and bumps scored_at, matching how sim_readiness_grades// treats a re-grade: one current measurement per subject, never a growing pilediff --git a/docs/likeness-eval.md b/docs/likeness-eval.mdindex af209f379..1adecaf65 100644--- a/docs/likeness-eval.md+++ b/docs/likeness-eval.md@@ -146,9 +146,16 @@ of a distinct avatar from the public library, submits that portrait as thereconstruction photo, polls the job to completion, and scores the finishedavatar against the exact bytes it was built from. The subjects are therefore**synthesised**, never real people's photos, for the same reason the-reconstruction worker synthesises its reference set. Live results are printed-but deliberately **not** filed: a benchmark run is not a user's generation, and-storing it would move the distribution the roadmap is judged on.+reconstruction worker synthesises its reference set.++A live subject *is* a real generation record, because live mode submits a real+reconstruction. Not filing it would not keep it out of the numbers, only defer+them: the next sweep would find an unscored creation and count it toward the+gate rate like any user's avatar. So it is filed deliberately, under the status+`benchmark`, which the distribution's `status = 'ok'` filter excludes from every+aggregate while the outcome breakdown and the recent table still show it. The+work queue keys on a row existing at all rather than on its status, so the+subject is never re-picked either. Backfill subjects keep their real status.Both modes print a **cross-subject control**: every avatar is also scoredagainst every *other* subject's captures. A likeness number is unfalsifiable@@ -193,11 +200,13 @@ This is the baseline Phase 1 has to move. It is quoted here so the next run hassomething to be compared against, and it is only comparable within`threews.likeness.sface.v1`.-The board will read one subject higher than this table. Verifying `--live`-submitted a real reconstruction, which registered a generation record like any-other, and the next backfill scored it at 2.32. The table above is deliberately-left as the snapshot it was, rather than being rewritten every time the-population grows.+The board reads one subject higher than this table, and that discrepancy is what+produced the `benchmark` status described above. Verifying `--live` submitted a+real reconstruction, which registered a generation record like any other, and+the next backfill scored it at 2.32 as if a user had made it. Live subjects are+now filed as `benchmark` so they cannot reach the gate rate; the one that landed+before the fix is left where it is rather than quietly edited out of a published+baseline. The table above stays the dated snapshot it was.## Reading the resultsdiff --git a/scripts/likeness-eval.mjs b/scripts/likeness-eval.mjsindex e2f7161d4..cfe329a77 100644--- a/scripts/likeness-eval.mjs+++ b/scripts/likeness-eval.mjs@@ -52,6 +52,8 @@ import {scoreLikeness,} from '../api/_lib/likeness-score.js';import {+ BENCHMARK_STATUS,+ creationIdForJob,likenessStoreEnabled,recordLikenessScore,unscoredReconstructions,@@ -320,18 +322,28 @@ async function main() {for (const subject of subjects) {const result = await scoreLikeness({ glbUrl: subject.glbUrl, captures: subject.captures });const control = await embeddingsFor(subject);- // Only backfill subjects are filed. A live subject is a benchmark run, not- // a user's generation, and writing it into the same table would move the- // distribution the roadmap is judged on with traffic nobody asked for.- // Live mode reports "not-stored" for exactly that reason.+ // A live subject IS a real generation record, because live mode submits a+ // real reconstruction. Leaving it unfiled does not keep it out of the+ // numbers, it just defers it: the next sweep finds an unscored creation+ // and counts it toward the gate rate like any user's avatar. So it is+ // filed deliberately, under BENCHMARK_STATUS, which the distribution's+ // `status = 'ok'` filter excludes from the gate maths while the outcome+ // breakdown still shows it. Backfill subjects keep their real status.let stored = false;- if (subject.creationId && likenessStoreEnabled()) {- stored = await recordLikenessScore({- creationId: subject.creationId,- avatarId: subject.avatarId,- jobId: subject.jobId,- result,- });+ let filedAs = null;+ if (likenessStoreEnabled()) {+ const target = subject.creationId+ ? { creationId: subject.creationId, avatarId: subject.avatarId }+ : await creationIdForJob(subject.jobId);+ if (target?.creationId) {+ filedAs = liveArg ? BENCHMARK_STATUS : result.status;+ stored = await recordLikenessScore({+ creationId: target.creationId,+ avatarId: target.avatarId ?? subject.avatarId,+ jobId: subject.jobId,+ result: liveArg ? { ...result, status: BENCHMARK_STATUS } : result,+ });+ }}scored.push({ ...subject, result, ...control, stored });const views = result.views@@ -340,7 +352,7 @@ async function main() {log(` [${subject.index + 1}] ${result.status.padEnd(18)} ` +`score=${fmt(result.likenessScore, 2)} cos=${fmt(result.identityCosine)} ` +- `falloff=${fmt(result.turnFalloff)} ${stored ? 'stored' : 'not-stored'}\n` ++ `falloff=${fmt(result.turnFalloff)} ${stored ? `filed:${filedAs}` : 'not-filed'}\n` +` ${views}`,);}diff --git a/tests/likeness-score.test.js b/tests/likeness-score.test.jsindex 1d8e232ad..18c99bdfe 100644--- a/tests/likeness-score.test.js+++ b/tests/likeness-score.test.js@@ -54,7 +54,12 @@ const {cosineToScore5,scoreLikeness,} = await import('../api/_lib/likeness-score.js');-const { capturesFromParams, recentLikenessScores } = await import('../api/_lib/likeness-store.js');+const {+ BENCHMARK_STATUS,+ capturesFromParams,+ recentLikenessScores,+ unscoredReconstructions,+} = await import('../api/_lib/likeness-store.js');// A unit vector at a chosen angle from the reference, so a test can request an// exact cosine instead of hoping a random pair lands near one.@@ -272,6 +277,31 @@ describe('capturesFromParams', () => {});});+describe('benchmark subjects stay out of the gate maths', () => {+ it('files under a status the distribution aggregates exclude', async () => {+ // The distribution's aggregates and histogram filter `status = 'ok'`, so+ // this one constant is the whole mechanism keeping a --live run from+ // counting itself toward the roadmap gate. If it ever equals 'ok', a+ // benchmark subject becomes a user's avatar as far as the metric knows.+ expect(BENCHMARK_STATUS).not.toBe('ok');+ });++ it('still removes the subject from the sweep queue', async () => {+ // The queue's `left join ... is null` keys on the row existing at all, not+ // on its status, so a filed benchmark row is never re-picked and scored a+ // second time as a real generation.+ sqlRows.mockResolvedValueOnce([]);+ const queued = await unscoredReconstructions({ limit: 5 });+ expect(queued).toEqual([]);+ const [strings] = sqlRows.mock.calls[0];+ const query = strings.join('?');+ expect(query).toContain('left join avatar_likeness_scores');+ expect(query).toContain('s.creation_id is null');+ // Deliberately NOT filtered by status: any row of any status excludes it.+ expect(query).not.toMatch(/s\.status\s*=/);+ });+});+describe('recentLikenessScores column mapping', () => {it('keeps "not measured" null instead of reporting it as zero', async () => {// A single-capture reconstruction stores capture_cohesion as NULL, because