Seven local copies of the YYYY-MM-DD regex (registry schema, entry
vocabulary, graph validation, event rules, event drafts, two quality
checks) and three hand-rolled day calculations (price window dayBefore and
daysBetween, starter rotation day count) are replaced by whenkit's
isISODate, addDays and daysBetween, per the packages-first rule.
isISODate also rejects impossible calendar days (2026-02-30), which the
regex let through; every stored row still passes. The entry isoDate schema
carries JSON Schema format "date", and the printed shape notes YYYY-MM-DD,
so the data-entry shape still states the form after the pattern is gone.
package-plan.json binds the new files under the dates block.
Claude-Session: https://claude.ai/code/session_019MDtmuvTGrpo3VChP3skH8
Co-authored-by: Claude <noreply@anthropic.com>
The stub page grouped by what each relation says (Owns a stake in (16),
Operates, Owned by, Ships to), one line per relation: counterparty, share or
volume where stated, year, grade. A quote sits in a collapsed per-row
disclosure; a cell that backs several rows is printed once below with its
row count. Nothing in a quote is cut. NAC Kazatomprom JSC at 390px goes from
5,193px to 2,349px tall.
Ownership holders: a founder printed by a personal name (Jensen Huang, Lee
Jae-yong) and a group of holders (a family, ADR holders) are skipped when
the graph mints company nodes, with the reason counted in graphStats. The
ownership rows and pages keep every holder. Stubs: 1,188 to 1,186.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
* feat(entities): stub companies from the relation graph, and a lab entity kind
Stub companies: every minted company:<slug> node a stated or corroborated
relation touches (1,188 today; NAC Kazatomprom JSC, JV Inkai LLP, Uranium One
Inc.) becomes an entity built from the graph at load, with evidence "stub", a
page on the existing /markets/[slug] route that lists only the relations
naming it (grade, quote, source), and the note that no profile is held.
Rendered on demand, so the static page count is unchanged. The graph's
producers resolve against the directory only (resolveInDirectory), so the
stubs never change the graph they come from. Search and retrieval rank stubs
at 0.6 and leave word rarity to full-weight documents, so profiled rankings
do not move. Events and relations may name a stub; ownership and facility
operator fields stay directory-only. Reviewed aliases redirect to the
canonical page.
Labs: a closed-set `lab` kind (allowEmpty until the pilot fills it), the
labs candidate facet with schema and add.ts gate, a /labs/[slug] profile
(what it works on, where and how to join, stated funders from finances
relations), the lab dossier on lab:<id> with research fronts kept as their
own science kind, and the country people_labs box counting lab rows. Seeds
no lab data. Person is not added: the ADR pins it for office and board
holders, not lab staff.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* test(stubs): assert the summary's invariants, not its tail
Main now carries the pilot's Kazatomprom relations, so its stub summary
names a second source and the shipments. The test keeps what must hold:
the yearbook leads, the stakes and the shipments are named.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
---------
Co-authored-by: Claude <noreply@anthropic.com>
- lib/coverage: capacity cells read without guessing (NA, estimates, per-material
parts, two-figure cells left unreadable), exact unit factors only, basis
matching per national series, a group capacity counted once.
- coverageFor/coverageOf: named capacity / national production (USGS MCS, WNA),
with every row, both sources and the arithmetic, or the reason it cannot be
computed; rows with a named operator, operators with a stated owner, flows.
- Three inference rules (co-ownership, same-parent, registry-bridge) write
derived/lead proposals to research/derived-relations.json; the store holds
them apart in `proposals`, never walked, counted or indexed.
- Country pages: "How complete is this picture" under the dossier; chat tool
coverage_of(country, resource?).
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
* fix(graph): a flow's commodity is part of its relation id
Uranium and refined copper from Kazakhstan to China in the same year are two
relations, but the id was from|type|to|asOf, so the second was skipped as a
duplicate. One rule now (lib/graph/id.ts) is shared by the graph validator and
the candidate path; ids without a stated commodity are unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* style: prettier on run-task
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
---------
Co-authored-by: Claude <noreply@anthropic.com>
Adapters turn free public registries and filings into candidate relation
rows with their quotes cut from the fetched text. They never write curated
data, never guess an identity and never infer.
- add.ts reads PDFs (unpdf 1.8.1, pinned): page-by-page text, the quote
check forgives line breaks and line-end hyphenation only, and prints the
page it found the quote on. Same exit codes.
- lib/sources: an explicit host allow-list with agent strings, pacing, 429
back-off and a .tmp cache; adapters for UN Comtrade (public preview, no
key), SEC EDGAR, GLEIF, Wikidata (lead unless a second source agrees) and
Kazatomprom's IR PDFs. One gate (finalise) drops any row whose quote is
not in the fetched text; every row carries provenance.
- scripts/research/run-task.ts: a dossier task in, the adapters that serve
its box in dry run, each row marked whether it fills the box; --write goes
through add.ts.
- Candidate rows may carry source.locator and provenance.
- prompts/data-entry.md: the adapter workflow a data agent follows first.
- Tests on recorded real responses only (test/fixtures/sources).
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
Asked live on 2026-10-24 which companies mine uranium in Kazakhstan and who
owns them, the Ask answered correctly from the USGS 2023 yearbook but pasted
the cell as one paragraph of sixteen ventures and one of sixteen places; the
graph split Kazatomprom in two; and no tool read the graph at all.
- Tables: producers_in builds an answer table in code from its rows
(operator | owners as printed | commodity | location | capacity | year),
one row per venture of a "Companies:" cell, every cell verbatim; a place
list or capacity printed once for many rows is a shared note, never
divided. registry.ts routes a result's `table` to the answer, not the
model; the model is told not to paste. Drawn under the prose
(AnswerTables): a table where wide, cards where narrow (container query),
eight rows then "Show all", long places folded.
- Entity aliases: config/entity-aliases.ts holds reviewed pairs only
(NAC Kazatomp JSC, UraniumOne Inc., Glencore), each with the rows that
justify it; lib/graph/alias-match.ts proposes by named rules and
`pnpm run research:alias-candidates` prints proposals with evidence.
research/usgs-relations.json regenerated.
- related_to and how_connected over lib/graph: rows with share, grade,
counted flag, source quote (the venture's part of a long cell, verbatim)
and reading kind; leads listed apart and never counted. Planned first for
who owns / shareholders / holds stakes / partners / how connected; the
ladder counts related_to owners as covering the owners link.
- Six no-wall evals (Inkai, Kazatomprom, Cameco, Sumitomo, Collahuasi,
Gazprom) with graded verbatim quotes; check:ask-layout draws the table at
320/390/1440.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
lib/graph: store + read API (relationsFrom/To, neighbours, pathsBetween,
relationEvidence, graphNode), a validator that throws on any relation without
a source, quote and date and enforces each grade's promise (corroborated needs
two sources, derived its chain and rule, a lead is never counted).
Edges from data already held:
- USGS Minerals Yearbook facility cells parsed conservatively into operates/owns
(shares only where printed); scripts/research/build-usgs-relations.ts writes
research/usgs-relations.json with a report of every string left unparsed.
- Ownership holders (stated with a share, lead without) and facility operators.
Candidate path: config/candidates/relations.json folded in through
config/substrata-relations.ts; add.ts accepts the `relations` facet with the
same gates and exit codes. Relation chunks in the retrieval index.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
Every country, company, resource and lab is filled against fixed boxes, each
full/thin/empty by one written rule over the rows that exist (only stated and
corroborated rows count). lib/dossier holds the boxes with named thresholds,
allowed sources and a worked example; compute.ts derives each box from config,
research/*.json and the candidate files; tasks.ts and scripts/research/gaps.ts
emit one GapTask per empty or thin box with a prompt-ready instruction, ordered
by demand then the owner's country list. Seams: RelationCounter for the graph,
recordDemand for the answer ladder. Shown on /data/quality (priority countries)
and on every /world/<iso2> page. GapTask.entity widens to SubjectId so a
resource's boxes can be tasks.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
The live Ask said Kazakh uranium operators were "not recorded in the corpus"
while research/usgs-producers.json holds 35 Kazakh facility rows with operator
and owner. The wall was missing plumbing, not missing data. This records the
skeleton to build before more data: a ladder that never ends in a refusal, a
typed sourced relation graph, evidence grades, derived-edge rules with a
mass-balance coverage ratio, dossiers whose completeness is computed, and a gap
queue a cheaper model can work. lib/graph/types.ts is the shared contract.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>