logicsrc/apps/logicsrc-web/contract/spec-discovery.contract.test.ts
Anthony Ettinger 699eff427a
Some checks are pending
CI / build (push) Waiting to run
test / test (push) Waiting to run
OpenModel 0.1: what a model costs, from the provider that bills you (#212)
There is no shortage of places to look up an AI model and nowhere to look
up what it costs you, from the provider that will bill you, in a form a
program can read. Every provider publishes prices as a marketing page and
every comparison site scrapes those pages. The best of them, models.dev,
is a community database: 8,179 provider offerings across 223 providers,
maintained by volunteers reading pricing pages. Good work, and still a
third party writing down what a company charges.

OpenModel is that table served by its author at
/.well-known/openmodel.json: price per million tokens in, out and cached,
context and output limits, modalities, and what each model can do.

The unit is the offering, a provider and a model together, because the
same model reaches a buyer from many providers at many prices and the
price is the question they came with.

Two rules decide what a row means, and both come from measuring the real
data. A published zero is a fact: of those 8,179 offerings, 638 cost
nothing and 424 published no price at all, so a reader that collapses the
two invents a free model or hides one. And absent is unstated, never
false, because a false travels further than a blank and comes back quoted
as a fact.

Origin is the proof, as with every catalog spec here: a file naming a
provider's web and served by somebody else is a stranger's claim about
that company's prices.

The first reader is the models collection at nichedb.dev/c/models, which
reads descriptors beside the models.dev catalogue in the same vocabulary
so one feed catches both.

Registered in the one registry, with docs/openmodel.md and a docs-only
entry (no landing page yet), and added to the spec-discovery contract so
the family page, docs index, llms feeds and sitemap are proven to carry
it.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-24 11:21:10 -07:00

43 lines
2.2 KiB
TypeScript

import { describe, expect, it, vi } from "vitest";
import { familyOfSpec } from "../src/lib/specs";
import { listDocs, readDoc } from "../src/lib/docs";
import { GET as llms } from "../src/app/llms.txt/route";
import { GET as llmsFull } from "../src/app/llms-full.txt/route";
import sitemap from "../src/app/sitemap";
// Spec discovery must work even when the optional blog database is offline.
vi.mock("../src/lib/supabase", () => ({ publicClient: () => { throw new Error("offline"); } }));
describe.each([
{ slug: "openagent", name: "OpenAgent", family: "people" },
{ slug: "openskill", name: "OpenSkill", family: "people" },
{ slug: "openabtest", name: "OpenABTest", family: "process" },
{ slug: "openfleet", name: "OpenFleet", family: "process" },
{ slug: "openrental", name: "OpenRental", family: "catalogs" },
{ slug: "openmodel", name: "OpenModel", family: "catalogs" },
{ slug: "openwall", name: "OpenWall", family: "people" },
{ slug: "openobject", name: "OpenObject", family: "catalogs" },
{ slug: "openslice", name: "OpenSlice", family: "catalogs" },
{ slug: "openstack", name: "OpenStack.md", family: "catalogs" }
])("$name public discovery", ({ slug, name, family }) => {
it("serves the specification through its family and docs index", () => {
expect(familyOfSpec(slug)?.slug).toBe(family);
expect(listDocs()).toContainEqual(expect.objectContaining({ slug, title: name }));
expect(readDoc(slug)).toMatch(/Status: \*{0,2}0\.1/);
});
it("includes a reachable docs URL and the full contract in the LLM feeds", async () => {
// A spec with a landing page is linked there and cites its docs URL after
// it; a docs-only spec is linked straight to /docs/<slug>. Both must name
// the docs URL somewhere on the line.
const text = await llms().text();
expect(text).toMatch(new RegExp(`\\[${name}\\]\\(https://[^)]+/(docs/)?${slug}\\)`));
expect(text).toContain(`/docs/${slug}`);
expect(await llmsFull().text()).toContain(readDoc(slug)!.trim());
});
it("includes the docs route in the sitemap without a blog connection", async () => {
const entries = await sitemap();
expect(entries.some((entry) => new URL(entry.url).pathname === `/docs/${slug}`)).toBe(true);
});
});