11 Commits
Author SHA1 Message Date
CatoandClaude 901e349e6c fix(quality,graph): entity quality counts, registry/graph import cycle, repo docs (#425)
Co-authored-by: Claude <noreply@anthropic.com>
2026-12-02 08:39:51 +01:00
CatoandClaude 3c6860d110 refactor(dates): validate and count days with @bitbaum/whenkit (#381)
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>
2026-11-12 08:49:49 +01:00
CatoandClaude 932d2b0082 feat(stubs): compact "What the sources say", and no person minted as a company (#236)
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>
2026-10-24 11:00:09 +02:00
CatoandClaude Opus 5.5 2d0eb1d6aa feat(entities): stub companies from the relation graph, and a lab entity kind (#235)
* 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>
2026-10-24 10:51:06 +02:00
CatoandClaude 59ccaa532c feat(coverage): mass-balance coverage ratio, inference rules, and "How complete is this picture" (#227)
- 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>
2026-10-24 09:26:12 +02:00
CatoandClaude Sonnet 5.5 5c7da90a25 fix(graph): a flow's commodity is part of its relation id (#224)
* 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>
2026-10-24 08:43:42 +02:00
CatoandClaude b2042d210e feat(sources): source adapters, PDF sources in add.ts, and the task runner (#223)
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>
2026-10-24 08:37:08 +02:00
CatoandClaude e7959fb3d9 feat(ask): tables not walls, reviewed entity aliases, and the graph as chat tools (#222)
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>
2026-10-24 08:29:39 +02:00
CatoandClaude 554a477e6d feat(graph): the typed, sourced, dated relation graph, with its first 1,815 edges (#221)
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>
2026-10-24 07:55:03 +02:00
CatoandClaude a61d4d0e73 feat(dossier): the dossier standard, computed completeness and the gap work queue (#220)
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>
2026-10-24 07:49:50 +02:00
CatoandClaude ddcbf3d340 docs(architecture): the research systems — the answer ladder, the relation graph, dossiers (#217)
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>
2026-10-24 07:20:51 +02:00