Files
CatoandClaude Opus 5 375a2448f8 The web as a schema, and the seams for eight languages (#61)
* feat(relations): the web becomes a schema, and every join says how well it is evidenced

Substrata's claim is that these constraints are connected — a firm makes a
material, a rule governs it, a mandate could fund relief. The joins are the
product, so they now get the same discipline as the rows.

Relations were free strings built ad hoc per kind, and that cost three things.

`makes` and `produced by` were the same fact declared twice, in two directions,
with nothing making them agree. A relation is declared once now and read from
both ends, so they cannot drift.

A policy instrument was emitted with `kind: 'capital'`, so rules rendered as
capital on a country dossier. Instruments are policy entities, and a test holds
that.

And no edge carried evidence at all, so an unverified lead and a sourced finding
rendered as the same line — the one thing this site exists to keep apart. Every
relation now states how well THE JOIN is stood up, which is not how well either
end is: a sourced company and a sourced material can still be connected by
nothing but a directory guess, and it says so.

335 relations across seven kinds. `governed-by` is new: which rules govern a
bottleneck was not in the graph at all.

`lib/graph.ts` keeps its shape and becomes an adapter, so /api/graph, the
country dossier, chat retrieval and the profile module inherit the fixes. Labels
come from the entity registry, so a country is its name rather than its ISO
code, and the graph route stops carrying a hand-copied kind list that had
already fallen a kind behind.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2

* feat(i18n): open the seams for eight languages, without faking a single translation

The expensive part of shipping in eight languages is not translating. It is
discovering afterwards that the code assumed one — strings welded into
components, dates built by hand, a layout that only goes left to right. Those
assumptions are cheap to remove now and painful to remove at scale, so they are
removed now. No translation is invented in the process.

The content divides into three kinds that cannot share a mechanism.

**Interface strings** are keyed, in `lib/i18n/messages.ts`. English is the
source and defines the key set, so a missing key is a type error rather than a
blank on a page. Every other locale is deliberately partial: a missing string
falls back to English, and `gapsIn()` and `coverageOf()` report exactly what
fell back. A fallback nobody can measure is how a half-translated product ships
without anyone finding out. All twenty profile-module titles and the evidence
vocabulary are migrated, and a test fails the build if a module writes a title
into the component — a string welded into a component is one no translator can
reach. Proved by mutation.

**Research prose** — about 5,500 words — is Substrata's own writing, so it is
translatable, and a translation is a claim like any other: it carries who made
it and when. `readProse()` reports whether the text is really in the language
asked for. A machine translation may exist as a draft and may never count as
checked, because prose that reads fluently but was never verified is
indistinguishable, to a reader, from prose that was.

**Quotations** — about 1,000 words — are never translated. The entire
evidentiary value of a quote is that these are the words the source published;
a translated mandate sentence presented as the EIB's own would be invented
evidence. `Quotation` has no translations field, so the type enforces it rather
than a convention.

Also: `lang` and `dir` on the document, so Arabic flips the layout and not just
the text, and locale-aware date and number formatting, because the corpus stores
ISO dates for storage reasons and no reader wants to read one.

Not done, and deliberately not faked: no translations exist, every non-English
locale reports 0%, and there is no /de/ routing — that is cheap to add once
strings are external and pointless before translations exist, since it would
ship seven locales silently serving English. docs/LOCALIZATION.md records the
rules and what is left.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 06:07:52 -07:00

15 lines
615 B
TypeScript

import { NextRequest } from 'next/server';
import { GRAPH_KINDS, neighbors, type GraphKind } from '@/lib/graph';
// The kinds the graph serves, not a second copy of them: this list had already
// fallen behind by one — `policy` is a node kind now.
export function GET(request: NextRequest) {
const kind = request.nextUrl.searchParams.get('kind') as GraphKind | null;
const id = request.nextUrl.searchParams.get('id');
if (!kind || !id || !GRAPH_KINDS.includes(kind)) {
return Response.json({ error: 'Pass kind and id.' }, { status: 400 });
}
return Response.json({ data: neighbors(kind, id) });
}