Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/origin-link-score-matches-links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modelschemas/client': minor
---

`completeness` on `GET /v1/status` no longer scores origin links: `originLink` (`{ have, need }`) is replaced by `originLinks`, the number of live models with `sameAs` set, which is not part of `score`. See docs/api-changes.md.
5 changes: 4 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ register→execute), `pnpm run client-smoke` (typed client),
shares `classifyAndBundle` with the sync engine), `pnpm run gap:report -- --table`
(per-provider score for the facts `@tanstack/ai-models` needs: chat, image,
video and audio rows on their own fact sets, null-activity rows as a gap,
and origin links; one
and an origin-link count (not scored); one
`/v1/models` request; `docs/source-silent/<provider>.md` lists facts a provider does not
publish; `--check` exits 1 below `--target`). Admin sync:
`curl -X POST localhost:3100/v1/admin/sync/openrouter -H "X-Admin-Key: $ADMIN_KEY"`.
Expand Down Expand Up @@ -183,6 +183,9 @@ ones).
`scripts/gap-report.ts`; the Worker bundles `docs/source-silent/*.md`
(`source-silent.ts`). The 15-minute cron scores once after the poll
(`recordCompleteness`, one `cache_meta` row); requests only read it.
Origin links are not scored: `originLinks` counts rows with `sameAs`
served, the links `reconcileSameAs` wrote (pinned by
`origin-link-score.worker.test.ts`).
BytePlus chat, Seedance, and Seedream cards come
from its public ModelArk pricing doc (`byteplus-pricing.ts`; the console
pricing view and `arkcli pricing` are login-gated). An id that page
Expand Down
11 changes: 11 additions & 0 deletions docs/api-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ Non-additive changes to the catalog and estimate API. Package release
steps stay in the README under "Releasing on npm". npm package changelogs
are written by changesets.

**Breaking:** `completeness` on `GET /v1/status` and `GET /v1/providers`
no longer scores origin links. `originLink` (`{ have, need }`) is replaced
by `originLinks`, the number of live models with `sameAs` set: a count,
not part of `score`, `filled` or `needed`. The old `need` counted every
model whose id another provider also lists, including models no link rule
can link (no declared maker's row, regional twins, a stated upstream that
matches nothing). Scores drop the origin term, so a provider with links
no longer gets a lift from them. Scores are null until the first models
poll after the deploy. A `source-silent` ledger entry for `originLink` is
now refused.

**Added (0.1.x):** model rows gain `sameAsRoot` and `firstParty` (#719),
and `factSources` gains `firstParty`. `sameAs` can now be name-inferred
for a row whose provider states no upstream: `factSources.sameAs` is then
Expand Down
9 changes: 4 additions & 5 deletions docs/source-silent/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ that is not a models.dev price), `endpoint`, `modalities` (input) and
`outputModalities`. A row with a null activity is scored on `activity`,
which it always lacks: classify the row, do not ledger it. Rows of an
activity with no fact set (embeddings, moderation, decision, world,
search) are listed with `facts: null` and not scored. `originLink` is
scored on every row: a row needs an upstream link when its raw id or an
alias, also with dots read as hyphens, matches a row at another provider
and no row links to it; a row with `sameAs` set has one. A provider-wide
entry applies to every activity that scores that key.
search) are listed with `facts: null` and not scored. Origin links are
not scored: the report counts rows with `sameAs` served (`originLinks`),
and a ledger entry for `originLink` is refused. A provider-wide entry
applies to every activity that scores that key.

For a fact missing only on particular models, use the exact native raw model id:
`- provider/maker/model-id: fact — why, https://provider.example/model, checked YYYY-MM-DD`.
Expand Down
24 changes: 6 additions & 18 deletions openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -1305,23 +1305,23 @@
},
"completeness": {
"type": "object",
"description": "The gap-report score over the live models of the provider (src/lib/completeness.ts). Each activity has its own fact set. chat: contextWindow, maxOutput, modalities, priced, cacheRead, capabilities, reasoning, efforts, requestMap, endpoint, replayReasoningContent. image, video and audio: priced (any stored rate card that is not a models.dev price), endpoint, modalities (input) and outputModalities. A row with a null activity is in unclassified and counts as one missing fact (activity). Rows of an activity with no fact set (embeddings, moderation, decision, world, search) are listed with score null and do not change the score. originLink is scored on every row: a row needs an upstream link when its raw id or an alias, also with dots read as hyphens, matches a row at another provider and no row links to it; a row with sameAs set needs one and has it. Summed per model, each fact counted only where it applies. requestMap applies on chat/completions, completions, and responses routes. replayReasoningContent applies on chat/completions routes whose rows reason. A stated cached-input absence (factSources.cacheRead path not-offered) fills cacheRead. Provider-wide and exact-model source-silent exceptions are excluded. Computed at the models poll (completenessComputedAt), not per request.",
"description": "The gap-report score over the live models of the provider (src/lib/completeness.ts). Each activity has its own fact set. chat: contextWindow, maxOutput, modalities, priced, cacheRead, capabilities, reasoning, efforts, requestMap, endpoint, replayReasoningContent. image, video and audio: priced (any stored rate card that is not a models.dev price), endpoint, modalities (input) and outputModalities. A row with a null activity is in unclassified and counts as one missing fact (activity). Rows of an activity with no fact set (embeddings, moderation, decision, world, search) are listed with score null and do not change the score. Origin links are not scored: originLinks counts them. Summed per model, each fact counted only where it applies. requestMap applies on chat/completions, completions, and responses routes. replayReasoningContent applies on chat/completions routes whose rows reason. A stated cached-input absence (factSources.cacheRead path not-offered) fills cacheRead. Provider-wide and exact-model source-silent exceptions are excluded. Computed at the models poll (completenessComputedAt), not per request.",
"required": [
"score",
"rows",
"filled",
"needed",
"silent",
"activities",
"originLink"
"originLinks"
],
"properties": {
"score": {
"type": [
"number",
"null"
],
"description": "filled / needed, 0 to 1, over every scored activity and originLink. 1 when every fact that applies is in silent. null when nothing is scored (every live model is of an activity with no fact set and none needs an origin link), when no score is stored yet, and when the live models changed since the stored score."
"description": "filled / needed, 0 to 1, over every scored activity. 1 when every fact that applies is in silent. null when nothing is scored (every live model is of an activity with no fact set), when no score is stored yet, and when the live models changed since the stored score."
},
"rows": {
"type": "integer",
Expand Down Expand Up @@ -1373,21 +1373,9 @@
}
}
},
"originLink": {
"type": "object",
"description": "Models that need an upstream link (need) and models that have one (have, sameAs set). Silent and exact-model exceptions are not subtracted here.",
"required": [
"have",
"need"
],
"properties": {
"have": {
"type": "integer"
},
"need": {
"type": "integer"
}
}
"originLinks": {
"type": "integer",
"description": "Live models whose sameAs is served: links to the origin row at another provider. A count, not part of score: whether an unlinked model could be linked depends on what the link rules read and the catalog does not serve (stated upstreams that match nothing, the namespace table, the maker declaration). 0 when no score is served."
}
}
},
Expand Down
11 changes: 4 additions & 7 deletions packages/client/src/generated/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ export type ServiceStatus = {
priced: number
}
/**
* The gap-report score over the live models of the provider (src/lib/completeness.ts). Each activity has its own fact set. chat: contextWindow, maxOutput, modalities, priced, cacheRead, capabilities, reasoning, efforts, requestMap, endpoint, replayReasoningContent. image, video and audio: priced (any stored rate card that is not a models.dev price), endpoint, modalities (input) and outputModalities. A row with a null activity is in unclassified and counts as one missing fact (activity). Rows of an activity with no fact set (embeddings, moderation, decision, world, search) are listed with score null and do not change the score. originLink is scored on every row: a row needs an upstream link when its raw id or an alias, also with dots read as hyphens, matches a row at another provider and no row links to it; a row with sameAs set needs one and has it. Summed per model, each fact counted only where it applies. requestMap applies on chat/completions, completions, and responses routes. replayReasoningContent applies on chat/completions routes whose rows reason. A stated cached-input absence (factSources.cacheRead path not-offered) fills cacheRead. Provider-wide and exact-model source-silent exceptions are excluded. Computed at the models poll (completenessComputedAt), not per request.
* The gap-report score over the live models of the provider (src/lib/completeness.ts). Each activity has its own fact set. chat: contextWindow, maxOutput, modalities, priced, cacheRead, capabilities, reasoning, efforts, requestMap, endpoint, replayReasoningContent. image, video and audio: priced (any stored rate card that is not a models.dev price), endpoint, modalities (input) and outputModalities. A row with a null activity is in unclassified and counts as one missing fact (activity). Rows of an activity with no fact set (embeddings, moderation, decision, world, search) are listed with score null and do not change the score. Origin links are not scored: originLinks counts them. Summed per model, each fact counted only where it applies. requestMap applies on chat/completions, completions, and responses routes. replayReasoningContent applies on chat/completions routes whose rows reason. A stated cached-input absence (factSources.cacheRead path not-offered) fills cacheRead. Provider-wide and exact-model source-silent exceptions are excluded. Computed at the models poll (completenessComputedAt), not per request.
*/
completeness?: {
/**
* filled / needed, 0 to 1, over every scored activity and originLink. 1 when every fact that applies is in silent. null when nothing is scored (every live model is of an activity with no fact set and none needs an origin link), when no score is stored yet, and when the live models changed since the stored score.
* filled / needed, 0 to 1, over every scored activity. 1 when every fact that applies is in silent. null when nothing is scored (every live model is of an activity with no fact set), when no score is stored yet, and when the live models changed since the stored score.
*/
score: number | null
/**
Expand Down Expand Up @@ -150,12 +150,9 @@ export type ServiceStatus = {
}
}
/**
* Models that need an upstream link (need) and models that have one (have, sameAs set). Silent and exact-model exceptions are not subtracted here.
* Live models whose sameAs is served: links to the origin row at another provider. A count, not part of score: whether an unlinked model could be linked depends on what the link rules read and the catalog does not serve (stated upstreams that match nothing, the namespace table, the maker declaration). 0 when no score is served.
*/
originLink: {
have: number
need: number
}
originLinks: number
}
/**
* Model tallies count live models only: what GET /v1/models lists by default. Deprecated models are in deprecated and nowhere else.
Expand Down
2 changes: 1 addition & 1 deletion scripts/gap-report.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe('gap report scoring', () => {
expect(speech.providers[0]?.score).toBeNull()
expect(formatTable(speech)).toContain('n/a')
expect(formatTable(speech)).toMatch(
/unscored.*originLink.*media\.outputModalities/,
/unscored.*originLinks.*media\.outputModalities/,
)
expect(failing(speech, 1, ['speech', 'absent'])).toEqual(['absent'])
})
Expand Down
8 changes: 3 additions & 5 deletions scripts/gap-report.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Gap report: which facts `@tanstack/ai-models` needs are still missing,
* per provider and activity, with origin-link coverage. One HTTP request;
* per provider and activity, with origin-link counts. One HTTP request;
* no per-model detail calls.
*
* pnpm run gap:report # JSON
Expand Down Expand Up @@ -110,7 +110,7 @@ export function formatTable(report: GapReport): string {
...MEDIA,
'noAct',
'unscored',
'originLink',
'originLinks',
'm.dev',
...CHAT_FACT_KEYS,
...MEDIA_FACT_KEYS.map((key) => `media.${key}`),
Expand All @@ -126,9 +126,7 @@ export function formatTable(report: GapReport): string {
}),
String(p.activities[UNCLASSIFIED]?.rows ?? 0),
String(unscoredRows(p)),
p.silent.includes('originLink')
? 'silent'
: `${p.originLink.have}/${p.originLink.need}`,
String(p.originLinks),
String(p.fromModelsDev),
...CHAT_FACT_KEYS.map((key) => factCell(p, key, ['chat'])),
...MEDIA_FACT_KEYS.map((key) => factCell(p, key, MEDIA)),
Expand Down
2 changes: 1 addition & 1 deletion skill/modelschemas/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ spec syncs daily. Responses are JSON unless noted (`text/typescript`,
the full card. `/v1/status` counts live `priced` models per provider
and scores `completeness` (the share of facts filled: chat, image,
video and audio rows on their own fact sets, a null activity as a gap,
and origin links; `score` is null when nothing is scored). A provider there carries `docsFailing`,
and an origin-link count, not scored; `score` is null when nothing is scored). A provider there carries `docsFailing`,
`priceClearsRefused`, `updateStorm`, or `staleProbes` while its
stored docs facts or prices may be stale, one poll rewrote most of its
live rows, or a probe record is older than 90 days. A model row's
Expand Down
49 changes: 22 additions & 27 deletions src/lib/completeness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { describe, expect, it } from 'vitest'

import {
buildReport,
originIndex,
parseLedger,
rowCompleteness,
scoreRow,
Expand Down Expand Up @@ -191,41 +190,37 @@ describe('origin links', () => {
sameAs: { provider: 'maker', rawId: 'model-4-5' },
}

it('needs a link where another provider lists the same id', () => {
// The link rules' cases are pinned against reconcileSameAs in
// src/server/ingest/origin-link-score.worker.test.ts.
it('counts the links the service wrote and scores none', () => {
const report = buildReport([
origin,
linked,
// The same name, unlinked: the rules found no single maker root.
{ provider: 'host', rawId: 'model-4.5' },
{ provider: 'host', rawId: 'own-model' },
])
const by = (id: string) =>
report.providers.find((p) => p.provider === id)?.originLink
// The link target is the origin: it needs no link of its own.
expect(by('maker')).toEqual({ have: 0, need: 0, modelSilent: 0 })
expect(by('gateway')).toEqual({ have: 1, need: 1, modelSilent: 0 })
// Matches after dots are read as hyphens; `own-model` matches nothing.
expect(by('host')).toEqual({ have: 0, need: 1, modelSilent: 0 })
report.providers.find((p) => p.provider === id)?.originLinks
expect(by('maker')).toBe(0)
expect(by('gateway')).toBe(1)
expect(by('host')).toBe(0)
// Each row lacks only its activity: the link adds nothing to the score.
expect(report.providers.map((p) => p.score)).toEqual([0, 0, 0])
})

it('matches by alias and ignores ids at the same provider', () => {
const report = buildReport([
{ provider: 'maker', rawId: 'm-latest', aliases: ['m-1'] },
{ provider: 'maker', rawId: 'm-1' },
{ provider: 'host', rawId: 'm-1' },
])
const by = (id: string) =>
report.providers.find((p) => p.provider === id)?.originLink.need
expect(by('maker')).toBe(2)
expect(by('host')).toBe(1)
})

it('names the missing facts of one row', () => {
it('leaves a link out of one row’s facts', () => {
const row: ModelRow = { ...chat, maxOutput: null }
const origins = originIndex([row, { provider: 'other', rawId: 'm' }])
expect(
rowCompleteness(
scoreRow(row, parseLedger('- host: cacheRead — none'), origins),
),
).toEqual({ filled: 9, needed: 11, missing: ['maxOutput', 'originLink'] })
rowCompleteness(scoreRow(row, parseLedger('- host: cacheRead — none'))),
).toEqual({ filled: 9, needed: 10, missing: ['maxOutput'] })
expect(
rowCompleteness(scoreRow({ ...row, sameAs: linked.sameAs })),
).toEqual({ filled: 10, needed: 11, missing: ['maxOutput'] })
})

it('refuses an origin-link ledger entry', () => {
expect(() => parseLedger('- host: originLink — none')).toThrow(
/origin links are not scored/,
)
})
})
Loading
Loading