Files
hanzo.ai/lib/api/research.ts
zeekay 17d9611cb3 The Decision Suite reads its false alarms and timings from their runs, so all sixteen rows are measured and 16 of 16 is stated
Row 15 reads the public suite's in-the-wild run (Kai 24 of 600 flagged,
Jev 126) and guard-3's sealed set as its second read (4.05% against
17.56%). The cost row states the decision.latency runs beside the model
list's rates: a cached decision in process in 0.3 ms on a GPU to 2 ms on a
CPU against a hosted call's 133 ms, a cold one in 23 to 70 ms. /kai's lead
now carries all five lines. The research read keeps Kai's and Jev's runs on
a decision benchmark and every system on an Enso one, so no other baseline
reaches a page.
2026-10-15 11:52:08 -07:00

41 lines
1.9 KiB
TypeScript

/**
* The research API's runs, read when a page asks for them: the one source of
* every Kai figure the site prints.
*
* `GET /v1/research/runs?org=hanzo` answers anonymously, with the public runs
* alone; `bench post` in hanzo-inc/kai files them. It is read through
* `lib/api/read`, once per page load and shared by every part that asks, and
* nothing stands in for it: a page shows what the runs hold, says it is reading
* them, or says the API is unreachable (components/api/state). lib/kai derives
* the boards from what this returns.
*/
import { read } from './read'
import { WHO, type Run } from '../kai'
export const RESEARCH = '/v1/research/runs?org=hanzo'
const object = (v: unknown): Record<string, unknown> | null =>
v && typeof v === 'object' && !Array.isArray(v) ? (v as Record<string, unknown>) : null
/**
* Which runs a page keeps: an Enso benchmark's every system, since its board is
* the field Enso routes over; every other benchmark's Kai and Jev alone, the two
* the decision boards compare. Any other system's run on a decision benchmark is
* dropped as it is read, so no other baseline reaches a page.
*/
const kept = (r: Run) => r.benchmark.startsWith('enso.') || (WHO as readonly string[]).includes(r.system)
/** The runs in a body: `data`, each with an id, a benchmark, a system and a version, less the runs no page compares. Anything else is not the document. */
export function toRuns(body: unknown): Run[] | null {
const rows = object(body)?.data
if (!Array.isArray(rows)) return null
const ok = rows.every((r) => {
const x = object(r)
return typeof x?.id === 'string' && typeof x.benchmark === 'string' && typeof x.system === 'string' && typeof x.version === 'string'
})
return ok ? (rows as Run[]).filter(kept) : null
}
/** Every public run, as the research API holds it now. */
export const runs = (): Promise<Run[]> => read(RESEARCH, toRuns)