mirror of
https://github.com/bitbaum/substrata.git
synced 2026-12-04 05:30:25 +01:00
main
39
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
138e4c8d58 |
fix(deploy): the price backfill ends in time to be recorded (#281)
First deploy after #276 (run 40594377157): prices finished in 12.5 minutes (715 listings, 835008 points, 23 expected gaps), then the 30-minute facts pass ran into the 40-minute limit, the child was killed, exit 1, so the backfill was not recorded and every deploy would repeat it. Facts now stop at 15 minutes; the daily timer takes the rest. |
||
|
|
f172a773f6 |
feat(markets): a directory of every company in the universe, and an honest count of what each page can show (#272)
* feat(markets): a directory of every company in the universe, and an honest count of what each page can show /markets/directory filters the universe by theme, country, tier and page kind and searches by name, ticker or theme through searchkit; one column of rows on a phone, sixty at a time. /data/companies now counts what each page can show (quote and SEC filings, quote only, identity only) from identifiers alone, and lists every company considered and out with the test it failed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE * fix(markets): the directory's Show more is a 44px target 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> |
||
|
|
d6185e5bd5 |
feat(universe): defence theme, 22 fund files, 20 SEC codes, and revenue for filers with no float (#269)
The first wave admitted 594 companies from 731 candidates. This wave reads 22 issuer holdings files (was 14) and 20 SEC industry codes (was 6), adds the twelfth theme (defence & aerospace) and lets a 20-F or 40-F filer, which states no 10-K cover float, clear the revenue floor on its own tagged annual revenue in US dollars (no rate is ever invented). 793 admitted (tier A 133, tier B 660) from 1,013 candidates; 220 considered and not admitted. Funds read and dropped because their subject is not a theme (KOMP, XME, PAVE, HYDR, CTEC, RNRG, QCLN, FAN) are named in the ADR. Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
a88a29e447 |
feat(company): prices for the whole universe, a name check on every new line, and a list of what is not known (#271)
The daily run kept prices and filings for the 28 hand-checked seed lines only; every other company page read its source live, per request. It now walks the seed first, then every admitted universe line the price source serves, stalest first, within its time. A ticker can be another company's on another exchange, so a line that is not a seed line is stored and drawn only if the source's own name for the symbol agrees with the company's; a mismatch is refused with both names. More venue codes are read (Sao Paulo, Madrid, Milan, Stockholm, Oslo, Warsaw, Johannesburg, Singapore, Shanghai/Shenzhen by symbol, TSX then TSX Venture). Each company page gets 'What we do not know yet': every gap with its reason, the documents that would fill it and a work-queue task, and a 'Why it is here' sentence built only from the rows that admit it. Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
73dd498f49 |
feat(market-data): share prices, SEC fundamentals and filing-based holders, with Ask tools and charts (#249)
* feat(market-data): share prices, SEC fundamentals and filing-based holders, with Ask tools and charts Prices: daily split-adjusted closes from Yahoo Finance's chart endpoint (query1, then query2), stored in research_price_points by /api/cron/prices, read by priceHistory(ticker, range) with a live fallback; returns, 52-week extremes, drawdown and moving averages computed in code. Stooq (browser challenge), Nasdaq (browser agent only) and Alpha Vantage (unadjusted free closes) were tested and rejected; the reasons and the licence position are in lib/market-data/prices/chain.ts. Fundamentals: SEC XBRL company facts per CIK — revenue, margins, R&D, capex, cash, assets, debt, shares — each point with form, accession and filing link; a typed "unavailable" with the reason for companies the SEC holds nothing for. Holders: the proxy's ownership table, structured Schedules 13G/13D filed since (issuer checked, 0% amendments honoured) and recent Forms 4, with the rest as a typed remainder that says what it is — never a bare "Other 87%". The company page's ownership view and share bar carry the same remainder. Ask: price_history, fundamentals and holders tools; a price question plans price_history and the answer draws a line chart built in code (answer charts routed like answer tables); four ask-evals rows. Keyed by ticker in lib/market-data/identity.ts with a committed seed (config/market-seed.ts) as the seam for the company universe. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE * fix(market-data): fundamentals lists newest first so a length cut keeps the latest years 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> |
||
|
|
3ed7dff5ed |
feat(universe): a written rule for which companies are in — and the first 461 identified companies (#250)
* docs(universe): the company-universe methodology — three tests, tiers, evidence Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE * feat(universe): admit companies by a written rule — theme, materiality, identity, each cited A company is in when cited sources place it in a frontier-technology theme, show it clears a size floor, and identify it in a registry. admit() applies the rule from config/universe-themes.ts; whyCompany() answers for any name (in, out with the failed test, considered, named, or queued as a GapTask); company_membership lets the Ask answer it; /data/companies prints the rule from the same config. Tier B companies are a derived entity source with an 'Identified, not profiled' page; a stub the universe identifies is promoted in place. Adapters: issuer fund holdings (ARK, Global X, First Trust, Defiance, State Street), SEC EDGAR tickers/public float/SIC, GLEIF and Wikidata by ISIN, Wikidata industry classes; tested on recorded responses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE * data(universe): first wave — 461 tier B companies from 14 funds, EDGAR, GLEIF, Wikidata 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> |
||
|
|
c4f7f50435 |
Re-check the stale data honestly, monthly, without a laptop; rank the Ask evals on a fixed day (#247)
* fix(index): rank the Ask evals on a fixed day, and hand every producer the build's now buildChunks(now) keyed its memo by now's day but called the event and quality producers without it, so a caller pinning now still got today's recency and today's date-dependent quality findings. On 2026-10-25 the lapsed 30-day series re-read added 139 quote-checked-recently findings to the index and one pushed science:high-na-euv to sixth for 'How ready is high-NA EUV technology?'. Reproduced at |
||
|
|
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> |
||
|
|
3112ba2353 |
fix(research): migrate the kz Comtrade rows; dedupe flows by HS code (#233)
- config/candidates/relations.json: the nine Comtrade ships_to rows from the kz pilot (#231) regenerated through the adapter from the same URLs and replaced in place: quote from "reporterCode" through "netWgt", commodity text, note, locator and ids. Same flows, same weights, same grades; the migration refused any row whose flow changed. - run-task: a stored flow is matched by (from, type, to, asOf, HS code), not only by id, so a commodity-text change can never re-propose it. - config/candidates/events.json: submittedBy.model "not recorded" -> "unrecorded"; nothing else changed. - Tests: no old id and no flow twice in the sidecar; a stored flow is skipped under new commodity text; write tests use flows main does not hold. Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
70e2a863a9 |
fix(research): data-entry tooling gaps from the country:kz pilot (#232)
- submittedBy.model: the schema asks for "unrecorded" (adapters write "deterministic-adapter"); no text asks for a model id; old values still parse. - Comtrade: the quote spans "reporterCode" through "netWgt", so reporter, partner and weight stand in one literal span (adapter records may run to 800 chars; hand quotes stay at 400). volume.commodity names what HS 284410 covers, and a new optional relation `note` says the weight is the compound's mass, not uranium content. - run-task: leads are held back on --write and in rows.json unless --include-leads; the dry run prints why each row is a lead; rows already in the corpus or sidecar are skipped; the run ends with a plain-text list (rows written, rows skipped with reasons) to paste into a PR. - prompts/data-entry.md: all of the above, plus what to do when a box cannot be filled honestly. Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
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> |
||
|
|
78943594ab |
fix: restore the data-entry contract (#211) and the search index (#212), removed by #213 (#216)
* feat(entry): the data-entry contract — candidate rows a cheaper model may add, validated at the gate (#211) PR 5 of docs/architecture/2026-10-23-knowledge-system.md §3. - lib/entry/candidate.ts: candidate types derived from each config row (CandidateOf<Row>), and the folds that merge a sidecar row into its config list flagged `evidence: 'candidate'`. No runtime config import, so config modules include it without a cycle. - lib/entry/schemas.ts (+ vocab.ts, shape.ts): one Zod schema per facet, each `satisfies z.ZodType<…Candidate>`, refs resolved through resolveIn / the config's closed lists; events reuse lib/event-rules eventProblems. - config/candidates/<facet>.json: eight empty sidecars, merged into COVERAGE, EVENTS, ENDOWMENTS, FACILITIES, INSTRUMENTS, SCIENCE, OWNERSHIP and the corpus series the way substrata-events-accepted.json is merged into EVENTS. - A candidate producer reads "Candidate source", never "Sourced" (verificationFor takes the row's evidence), and coverage progress does not count it. - scripts/research/add.ts <facet> <json|-> [--dry-run] [--branch] [--schema]: exit 2 schema, 3 unreachable, 4 quote absent (verbatimIn), 5 duplicate; appends sorted, idempotent; --branch commits on data/<facet>-<key>. - test/candidates.test.ts: every sidecar row passes its schema, is `candidate`, has url + asOf <= today; the gate exits 4 / appends sorted / exits 5 against a local HTTP server. - prompts/data-entry.md: the §3.4 prompt, how to run it, the printed shapes. - NODE_TYPE_LABEL moves to config/substrata.ts and the ownership labels to config/substrata-ownership-labels.ts (both re-exported) to keep the two config files under their size ceilings. Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE Co-authored-by: Claude <noreply@anthropic.com> (cherry picked from commit |
||
|
|
d6ce2d3347 |
feat(places): material profiles with charts and grouped restrictions; a country page; Niger leads with uranium (#214)
Material page (/resources/[slug]), one anatomy for every resource: at-a-glance tiles (world production and year, top producer and share, HHI with its method, exporters restricting it), production by country as a chartkit BarChart over the ranking table, reserves vs production as two ShareBars, year-over-year, the bottlenecks it holds up, export restrictions grouped by measure kind with counts, then each country as a <details> row (count and newest date in the summary; the top five open on desktop, all closed on a phone), events, sources. Country page (/world/[iso2]) through EntityProfile with country modules: header with roles as one scrolling row, at-a-glance tiles, what it produces as bars of world share (drawn against the whole world, so 1.6% looks like 1.6%), companies, rules, restrictions, events, related, discussion. /world?country=xx redirects there; the country entity links there. The Niger rule: a headline or a produces chart never leads with a share under 1% or a rank past 10th; those go under "Also produces, small shares". A measured uranium table (World Nuclear Association, fetched by scripts/research/wna-uranium.py into research/wna-uranium.json, joined like EIA) makes Niger read uranium first, 8th in the world. chartkit BarChart gains `max`, the value a full bar stands for. check:places-layout measures the four pages at 320/390/1440, light and dark, with chatkit's broken-word audit and chartkit's chart audit. Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
366d3edb30 |
feat(ask): the Ask panel scrolls, expands to /chat, and answers draw charts (#213)
The owner's phone (2026-10-23, /atlas, Ask Substrata over a bottleneck): the
answer could not be scrolled, there was no way to expand it, "Quick replies"
was a heading over nothing, "3 records read" a stray line, and the composer
carried "Model: Auto" and a paperclip.
- The panel is chatkit's ChatScreen in a sheet (AskPanel): on a phone a
bottom sheet to 92% of the visual viewport with a grip; from 768px a
right-hand panel. One title row: Ask Substrata · Expand · Close.
- Expand hands the whole thread to /chat (lib/ask-thread.ts); the URL
carries only an id and the conversation id continues.
- Suggested replies are chatkit's reply row (nothing drawn when empty);
records read are the thought row above the answer ("Read 3 records").
- Composer: microphone and send; the key chip only with a BYOK key.
- Charts in answers (chatkit 0.15): chart blocks drawn by chartkit
(LineChart, BarChart, ShareBars, Timeline, StatTiles) on every chat
surface; chartable tools return page links and plain numbers.
- --ck-page mapped to the surface token: unmapped, the dark theme drew
light text on chatkit's near-white page.
- check:ask-layout (scripts/ux/ask-layout.mjs): 320/390/1440, light and
dark — the thread scrolls, no sideways overflow, 44px targets, no cut
words, Expand lands on /chat with the same turns.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
329dd587d8 |
feat(entry): the data-entry contract — candidate rows a cheaper model may add, validated at the gate (#211)
PR 5 of docs/architecture/2026-10-23-knowledge-system.md §3. - lib/entry/candidate.ts: candidate types derived from each config row (CandidateOf<Row>), and the folds that merge a sidecar row into its config list flagged `evidence: 'candidate'`. No runtime config import, so config modules include it without a cycle. - lib/entry/schemas.ts (+ vocab.ts, shape.ts): one Zod schema per facet, each `satisfies z.ZodType<…Candidate>`, refs resolved through resolveIn / the config's closed lists; events reuse lib/event-rules eventProblems. - config/candidates/<facet>.json: eight empty sidecars, merged into COVERAGE, EVENTS, ENDOWMENTS, FACILITIES, INSTRUMENTS, SCIENCE, OWNERSHIP and the corpus series the way substrata-events-accepted.json is merged into EVENTS. - A candidate producer reads "Candidate source", never "Sourced" (verificationFor takes the row's evidence), and coverage progress does not count it. - scripts/research/add.ts <facet> <json|-> [--dry-run] [--branch] [--schema]: exit 2 schema, 3 unreachable, 4 quote absent (verbatimIn), 5 duplicate; appends sorted, idempotent; --branch commits on data/<facet>-<key>. - test/candidates.test.ts: every sidecar row passes its schema, is `candidate`, has url + asOf <= today; the gate exits 4 / appends sorted / exits 5 against a local HTTP server. - prompts/data-entry.md: the §3.4 prompt, how to run it, the printed shapes. - NODE_TYPE_LABEL moves to config/substrata.ts and the ownership labels to config/substrata-ownership-labels.ts (both re-exported) to keep the two config files under their size ceilings. Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
c9b421d54f |
feat(atlas): producer sites on the globe, and every chain as a route you can follow (#175)
Producers on the globe - research/producer-places.json places 997 of the 1,167 facility locations in the USGS Minerals Yearbook tables, in 37 countries, from GeoNames (CC BY 4.0), matched offline by scripts/research/geocode-producers.py. - Each point states its precision (the facility, the nearest town, or only the province) and the GeoNames entry it came from. A named province must hold the point, "N km north of X" is applied as an offset, and a bare name with distant namesakes is left out rather than guessed. - test/producer-sites.test.ts fails if a dot lands inside another country. The quality page measures the same through lib/quality/checks-places.ts. - The globe draws sites as dots, or rings when only the province is known. A click flies in close and opens the site's facilities, capacity and both sources in the panel. Chains as routes - app/atlas/chain-route.ts is the one route model: every step two levels up and down, numbered in the order material moves, each placed where it is made. - The diagram (AtlasChain) now reads left to right through every step, with makers inside the bottleneck's card. This fixes the connector that ran through the part suppliers' cards. - "On the globe" lays the same route over the Earth: one lifted arc per hop, a light running input to output, and labels numbered like the panel's list. The globe's input wiring moves to globe-control.ts; sites and routes are painted by globe-overlay.ts. Claude-Session: https://claude.ai/code/session_013Xssd1hFZCUSxqjACjoVBB Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
3c9322a7d0 |
fix(resources): every producer capacity names its own unit (#122)
USGS overrides the table's default unit per commodity in an unheaded column; the extractor dropped it, so China's largest gallium plant read 'capacity 150' under a table unit of thousand metric tons (150,000 t for a ~900 t/yr metal). Each row now carries its unit (ditto and wrapped cells resolved); 1,486 rows, none missing or cut off. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
3cf5c26f49 |
feat(data): quality criteria, automated checks and /data/quality; fix what they found (#116)
* fix(data): correct what the quality checks and a 36-row source sample found - listings: 8 pinned home lines stored a composite FIGI that OpenFIGI cannot resolve (openfigi.com/id 404, ID_BB_GLOBAL mapping empty); pinnedLine now keeps the exchange line's own FIGI (TSMC, UMC, GlobalWafers, ASE, SMIC, Rio Tinto, NKT, TSMC Advanced Packaging) - sanctions: all 49 EU amendment dates were a day early (Brussels-midnight stamps read in UTC); 4 OFAC programmes had empty titles (menu link parsed first) - usgs-producers: wrapped workbook cells were split into bogus facilities (64 fragments -> 5); Chile's copper table had lost Escondida, Spence, Sierra Gorda and 12 more rows behind a 'Continued' commodity cell - events/dependencies: 7 paraphrased quotes replaced with the source's verbatim text; SK Siltron event names its directory company - series: 18 Cameco points get the date their MD&A states - directory: Shin-Etsu Handotai source 404 replaced; Fangyuan careers URL (domain does not resolve) set to null as its evidence already said Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(data): written quality criteria per dataset, automated checks, /data/quality - config/substrata-quality.ts: 15 datasets x 6 criteria (completeness, correctness, provenance, freshness, link health, consistency); each a rule or 'na' with a reason; freshness reuses config/substrata-freshness.ts - lib/quality: pure checks (USGS world sums, quote states the value, names resolve, cross-dataset agreement with USGS) run in verify with a failure-count ratchet (test/quality.test.ts); network checks (links with 3 tries and a blocked/broken distinction, quotes on page, SEC ticker file, OpenFIGI mapping, USGS values on the chapter PDF) run on a rotation via /api/cron/quality - migration 014: research_quality_checks + research_quality_runs (trend) - /data/quality: scores, counts, trend and every failing row with its source and a prefilled correction issue; linked from /data, footer, palette - check-series.ts shares the reader (CDATA and ' ,' fixes found by the sample) - pnpm run quality [-- --network | --all | --json out.json]; no AI anywhere Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
6c32aa5931 |
refactor(research): one queue per engine; fix(ask): usable model picker on phones (#111)
* refactor(research): one queue per engine — the database, not committed worklists The event sweep and producer sourcing each had two queues: a committed file from the old hand-run CLI (research/events.json, research/evidence.json) and the database queue the box timers fill. /api/events read the file and reported a sweep from 2026-09-15 while the real one runs hourly, and the freshness gate would have failed the build around 2026-10-16. - /api/events reads freshness() from research_sweep_candidates (force-dynamic), with sweep.readable=false instead of a fake answer when the DB is down. - Bottleneck pages read open research_source_candidates live (ProducersTable + openCandidatesFor); null -> "could not be read", never "nothing found". The corpus now says sourced/unverified only; found pages never change a row's state, the export or the search index. - Removed EVENT_WORKLIST/candidatesAwaiting, EVIDENCE/evidenceFor, both JSON files, both CLIs, the weekly research-sweep workflow and their npm scripts. Unreviewed rows were copied into the DB first (25 sweep leads, 2 source pages; the rest were present or belonged to rows since sourced). - Freshness: dropped the two file datasets; new test fails when a committed research/*.json has no DATASETS row or a declared file is gone; a test fails if either worklist file comes back. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(ask): model picker gets a labelled button on narrow composers At 390px the free-model select was squeezed to "A…", at 320px to a bare chevron. Below a 28rem composer width (a container query, so the dock counts too) the bar shows Dictate, Attach, "Model <name> ▾", Ask; the button opens the picker full width underneath together with "Use your own AI key instead". Wide composers are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
af6d128c87 |
feat(atlas): measured resources, producers, restrictions, sanctions and ranked peers in the country panel (#107)
* wip(resources): country panel data — OECD restrictions, sanctions, EIA energy, USGS producers Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(atlas): country panel with measured resources, producers, restrictions, sanctions and ranked peers Replaces "Similar geologies" (first eight countries sharing any directory resource, so Russia's peer was Timor-Leste) with "Peers on <resource>": the other leading producers by the same USGS/EIA column. Per resource the panel now shows production (latest and prior year, change), world rank and share, reserves and reserves-to-production, USGS Minerals Yearbook producers, corpus producer rows, OECD export restrictions, sanctions measures that name the resource, and USGS/corpus statements — or "not recorded". Adds /resources/[slug] (world ranking, HHI, CSV, restrictions by country) and computed country headlines in place of directory blurbs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
82d8d5d07c |
feat(resources): USGS world production and reserves per country, and a choropleth API for the map (#105)
research/usgs-mcs.json is read from the Mineral Commodity Summaries 2026 chapter tables (19 commodities, public domain) by scripts/research/usgs-mcs.py, which reads word coordinates so superscript footnotes and "e" markers are kept as markers, not glued to numbers. The script refuses to write a file whose country rows do not add up to the USGS world total. lib/resources/choropleth.ts is the map's API: value, share, rank, status and USGS notes per ISO code for a resource's production or reserves, with unit, year and source. A country USGS does not list is absent, not zero; a withheld figure is not a number; no share of a "more than" total. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
e4467e2a46 |
feat: dependency rows as graph edges, 26 sourced rows, pinned home listings, series min-move (#94)
* feat(graph): dependency rows are graph edges — profiles, /api/graph and Ask read them Each row in config/substrata-dependencies.ts becomes a depends-on or sells-into relation carrying its source and verbatim sentence. Company and bottleneck profiles get a 'What it rests on' section; /api/graph edges carry quote and scope; Ask gains trace_dependencies (upstream/downstream walk, one quoted sentence per hop) and get_company/get_bottleneck list the rows. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(dependencies): 26 sourced rows for hyperscalers, labs, equipment makers, Marvell and the grid queue Microsoft, Google, AWS, CoreWeave, OpenAI, Anthropic and Marvell rest on foundry/HBM/grid/transformers/turbines/switchgear; KLA, Tokyo Electron, ASM International and Canon sell into foundry, memory and packaging; grid interconnection needs switchgear (LBNL). Each row: fetched URL, verbatim sentence, scope. Gaps rewritten with what was looked for and why it fails. get_bottleneck lists dependencies by name so producers stay in budget. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(listings): pinned home lines where OpenFIGI truncates names — 2330 TT, RIO LN and 7 more A pin is ticker + exchange + the exact OpenFIGI name, read by hand off the mapping API; the generator accepts it only while all three match. The strict matcher is unchanged. Re-ran research:listings for the nine slugs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(series): 3% minimum move before tightens/loosens; merge the duplicate transformer lead-time series Moves under MIN_MOVE_PCT show their sign and read 'flat' (method documented). NIAC's 2021/2024 Wood Mackenzie points join the headline power transformer series. A test makes the next single-point split a reviewed decision. CSV export split into lib/series-csv.ts (300-line cap). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
03309d4713 |
feat(series): dated, sourced number series per bottleneck — key numbers, claims, /data/series, CSV, desk alerts (#92)
* feat(series): dated, sourced number series per bottleneck, with key numbers, claims, CSV and desk alerts Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(series): keep desk.ts and the desk page under the size ceiling; showSeries optional like showScience Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * refactor(methods): series methods in their own file, like graph and science Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
303350b1e3 |
feat(careers): open roles from public job boards, skills and training per bottleneck (#91)
* feat(careers): open roles from public job boards, skills and training paths per bottleneck - research/job-boards.json: all 138 directory companies' careers pages and ATS, each checked on the company's own site; 6 on public Greenhouse/Ashby APIs are read daily (ASM, MetOx, Anthropic, OpenAI, xAI, CoreWeave), the rest linked. - research_jobs (scripts/db/011-jobs.sql) + POST /api/cron/jobs: daily fetch, filed under role family, seniority, bottlenecks and skills by published rules. - /careers: filters (bottleneck, family, company, country, seniority, remote), which bottlenecks are hiring most; /careers/[slug] per bottleneck; /careers/paths (O*NET 31.0 + ESCO records, posting skill counts, 56 checked learning paths); /careers/companies; hiring section on company pages. - Desk: follow companies/role families for jobs; new postings are a desk source. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Cato <41178744+catomean@users.noreply.github.com> * feat(careers): chain roles by default, sidebar hiring board, tighter filing rules Software and business postings are filed under bottlenecks by title only (AI labs' boilerplate named foundries and grid interconnection); the board defaults to roles in the chain with a scope switch; the hiring counts sit beside the list; learning paths come before the occupational record. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Cato <41178744+catomean@users.noreply.github.com> * refactor(desk): relative dates in lib/when.ts, job rows loaded in lib/desk-jobs.ts Keeps lib/desk.ts and the desk page under the 300-line ceiling with the job and science sources both on the desk. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: Cato <41178744+catomean@users.noreply.github.com> --------- Signed-off-by: Cato <41178744+catomean@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
ff66ed6918 |
feat(review): AI-drafted events from sweep leads, one-click review, accept path to git (#85)
* feat(review): AI-drafted events from sweep leads, one-click review, accept path to git Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(review): pace drafting on per-minute limits, mark the quote in context, document the accept path Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * chore(db): number the drafts migration 010 — 007 is taken by two parallel branches Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
fc1c8f8be0 |
feat: exposure screen, tickers from SEC + OpenFIGI, SEC filings on the desk (#84)
* feat(exposure): listings from SEC+OpenFIGI, exposure screen + CSV, EDGAR filings fetch Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(exposure): strict listing matcher with regressions; filings on the desk; tickers on company and bottleneck pages Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * feat(exposure): listings data for all 138 directory companies 96 listed (13 via a parent), 7 private, 35 no listing found. Every ticker carries its OpenFIGI or SEC source; matches were reviewed by hand, and the three false matches the first rule made are now regression tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> |
||
|
|
4bdf827736 |
fix(chat): retrieval quality — word-boundary scoring, IDF weighting, relevance floor (#73)
* docs: the concept — one corpus, five latencies, and who actually pays Strategy SSOT for where the research goes and who it is for. The three questions it answers: - Why the nearest comparable product (sell-side equity research) is beatable: its unit of analysis is a ticker while the unit of causation is a node, coverage follows market capitalisation rather than causal weight, the horizon is a quarter against constraints that clear on a decade, sector silos cut across every interesting chain, and nothing it publishes can be scored. - The idea to build around: a constraint is visible in five record systems at five different latencies — science (5-15y), funding (2-7y), talent (1-5y), policy (0-3y), market (0-1y). Equity research reads the bottom row. Reading the top rows years earlier, and showing the working, is the whole product claim. It needs one schema change: every observation typed by layer and carrying both dates, so lead time becomes a measured property of the corpus rather than a boast. - Who pays, ranked by fit rather than cheque size. Procurement and supply assurance first, because they are the only customer who corrects the map instead of only reading it. Also records the rule that keeps a holistic map from becoming a general database: every row must traverse to a bottleneck and through it to a loop, enforced as a build gate rather than as editorial taste. The corpus has already failed this once — 30 of 51 country rows connected to nothing. No code or corpus changes; everything described is unbuilt and the document says so. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9tLC1kS4qNVdRxcHuPZ5c * feat(chat): bring your own frontier key, and a web-lookup gate that lied Two changes to the assistant, one a real bug fix and one a new feature. FIX: `webLookupEnabled()` checked SEARXNG_URL only, while `webSearch()` itself walks three backends (SearXNG, then Brave, then Tavily). A box configured with just a Brave or Tavily key had a fully working lookup behind a gate reporting it off — the system prompt told the model "You have no tools", the outside-corpus escape hatch never opened, and the one env var that would have fixed it was the one this function forgot to read. Now checks all three, with a regression test. FEATURE: a reader can now supply their own API key (OpenAI, Anthropic, or OpenRouter — a fixed list, never a free-form base URL, because this server makes the outbound call on their behalf and an arbitrary URL there is SSRF with their bearer token attached) and get answered by a genuine frontier model instead of the free tier's small, rationed chain: - `lib/byok-shared.ts` — types, the closed vendor list, and validation, with no server-only dependency, so the client settings panel can import it without pulling `@bitbaum/ai-kit` into the browser bundle. - `lib/byok.ts` — `completeByok()`. OpenAI and OpenRouter go through ai-kit's `complete()` with a one-link ephemeral chain (never `process.env`); Anthropic's Messages API isn't the OpenAI shape everything else in ai-kit speaks, so it's called directly. - `lib/byok-store.ts` — the reader's own browser is where the key lives between requests, guarded against private-mode/blocked-storage failures. It is never sent anywhere but this component's own request and never touches this project's servers between requests. - `lib/chat.ts` — one `runCompletion` closure now backs all three completion call sites (initial answer, outside-corpus fallback, grounding repair), fed by either the free chain or `completeByok`. BYOK gets a larger token budget and longer timeout — the free tier's ceiling exists to ration a shared pool that does not apply to a reader's own paid key — and the system prompt names the model running and tells it to use more of its own judgement in BACKGROUND, while the citation rules (a finding is a numbered row, nothing else is [F#] or [W#]) stay identical regardless of which model is answering. Works even with zero free providers configured. - `app/api/chat/route.ts` — validates `byok` if present, skips the free-chain `isOfferedModel` gate (irrelevant to a vendor-native model id), and surfaces a `ByokError` message to the reader directly ("your key was rejected") rather than the generic "temporarily unavailable" wall, since that failure is the vendor talking to them, not this deployment breaking. - `components/portal/ResearchChat.tsx` — a "Frontier key" control next to the model picker opens a small panel (provider, key, model id); once set it replaces the free-model select with a pill naming what is answering, and the empty-state copy says so too. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9tLC1kS4qNVdRxcHuPZ5c * feat(coverage): 16 producer rows sourced, 2 removed for being wrong A pass over the 31 unverified producer leads still open in the coverage universe, cross-referenced against `research/evidence.json`'s candidate pages (20 leads already had a candidate excerpt on file, waiting for someone to read it and decide) plus fresh web research for the rest and for the ones whose only stored evidence was too weak to stand behind. PROMOTED TO SOURCED (16), each read and cited against a specific source: - Sibanye-Stillwater and Impala Platinum — ruthenium, mining role. The Sibanye row cites their own SEC trading-statement filing, which reports actual ruthenium ounces produced (258koz, 2025) — about as primary as a production claim gets. - Ferrotec — quartz, own site. - Chalco, East Hope Group, Zhuhai Fangyuan, 5N Plus — gallium, refining. The first of these was on file as "Chinalco", which turned out to be the wrong entity: Chalco (Aluminum Corporation of China Limited) is the listed subsidiary that actually runs the alumina refineries gallium comes off; Chinalco is its unlisted state-owned parent. Renamed, with both names kept as aliases since trade press uses both for the same business — and the evidence file's own row renamed to match, since a test holds every evidence row to a producer that still exists. - Chemours, Syensqo, AGC, Engineered Fluids — two-phase dielectric immersion coolant, refining/conversion. - AMSC — REBCO tape, conversion. - QatarEnergy and Linde — liquid helium. Off-take from Qatar's Ras Laffan Helium 2 (the world's largest liquefaction train) splits Air Liquide 50% / Linde 30% / Iwatani the remainder, per the same source for both. - China Northern Rare Earth and Shenghe Resources — Nd-Pr metal, refining. Shenghe's dysprosium row stays unverified: the evidence found supports their Nd-Pr business specifically, not dysprosium, and a citation that does not name the actual claim is not a citation. REMOVED, not promoted (2) — the research found the row was no longer true, and a wrong row is worse than an absent one: - REC Silicon, electronic-grade polysilicon. Butte, Montana stopped polysilicon production in Feb 2024; Moses Lake shut down Dec 2024 and stayed closed through the Feb 2026 restart decision; the company now says it has "completely discontinued the production of polysilicon" — Butte makes only silane gas today. - 3M, two-phase dielectric immersion coolant. 3M announced in Dec 2022 it would exit all PFAS manufacturing by end of 2025, and did: Novec and Fluorinert stopped shipping (last order date 31 March 2025). Left as an inline, sourced note rather than forced into the EVENTS/PARTICIPANTS schemas, which are their own curated exercises this pass didn't attempt. LEFT ALONE ON PURPOSE (not promoted): Baosteel Gases (every source is a syndicated press-release aggregator repeating the same sentence — no primary trace); Nyrstar (Trafigura's own release says they are CONSIDERING a gallium project at Port Pirie, not running one — an aspiration is not a role). `sourced()` gained an optional `aliases` param, matching `lead()`, for the Chalco/Chinalco rename. Coverage: 63/94 (67%) sourced before this pass, 79/92 (86%) after. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9tLC1kS4qNVdRxcHuPZ5c * feat(research): the producer-sourcing engine runs on a timer too, two ways The event sweep already outgrew being a CLI-only tool: it has a shared judgement module (`lib/sweep.ts`), a scheduled route (`POST /api/cron/sweep`), a Postgres review queue, and a `/review` page a human reads. Producer sourcing (`pnpm research:source`) was still stuck where the sweep started — a script a person has to remember to run. This closes that gap by extending the exact pattern that already proved itself, rather than inventing a second one, plus a fully independent second leg that needs no box access at all. WHAT MOVED - `lib/source.ts` — the query, the domain ranking and the excerpt-match judgement, extracted from `scripts/research/source-producers.ts` so the CLI and the timer cannot quietly stop agreeing about what counts as a candidate. `scripts/research/source-producers.ts` now imports it and keeps only what is genuinely its own: argument parsing, the evidence FILE, and the blindness-streak guard. SCHEDULED, BOX-DRIVEN (needs manual setup, documented in docs/INFRASTRUCTURE.md and docs/IMPLEMENTATION-PLAN.md): - `lib/source-store.ts` — `runScheduledSourcing()` examines a few least-recently-checked unsourced rows per call and files candidates into `research_source_candidates`, never into the coverage file: a running server has no working tree to commit a promotion into, same reasoning `lib/sweep-store.ts` already documents for events. - `scripts/db/004-source-sweep.sql` — the queue, mirroring `003-sweep.sql`'s shape. Apply via `scripts/provision-service.py`; the generic deploy workflow does not do this automatically. - `app/api/cron/source/route.ts` — `CRON_SECRET`-gated, same as `app/api/cron/sweep`. Needs registering in whatever schedule `/opt/_appcron/run.sh` already drives the sweep on. - `/review` gains a third feed: candidates from producer sourcing, decided the same way as event leads — accepting marks a candidate worth promoting, it does not write `sourced()` anywhere. That stays a person reading the excerpt and editing `config/substrata-coverage.ts`. SCHEDULED, GITHUB-ACTIONS-DRIVEN (works today once a secret is added, no box access needed): - `.github/workflows/research-sweep.yml` — runs `research:source` and `research:sweep` weekly against a Brave or Tavily key (`BRAVE_SEARCH_API_KEY` / `TAVILY_API_KEY` — ai-kit's `webSearch()` already falls through to these when SearXNG, loopback-only on bitbaum, isn't reachable) and opens a DRAFT PR with whatever lands in `research/evidence.json` / `research/events.json`. Skips cleanly with an `::notice::` until a secret exists. Draft on purpose: the fleet's auto-merge sweep leaves drafts alone, so nothing merges until a person has actually read the rows. Never touches `config/`. Tests: `test/source.test.ts` covers the pure judgement in `lib/source.ts` (normalise, nameStem, query building, own-domain detection, the window-match rule) the same way `test/sweep.test.ts` already covers `lib/sweep.ts`. `test/sweep.test.ts` gains one more assertion: the new cron route is gated the same way the old one is. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9tLC1kS4qNVdRxcHuPZ5c * feat(participants): source 54 of 101 directory entries (equipment through deployment) Every row in `substrata-participants.ts` started `source: null` — unlike the producer coverage universe, this directory had no sourcing helper at all, so nothing in it could ever read as verified. Added `s()` alongside `p()`, mirroring `sourced()`/`lead()` in `substrata-coverage.ts`, and used it to cite every entry across five layers: equipment (12, e.g. ASML, Carl Zeiss SMT, Trumpf, Applied Materials — each checked against the company's own product page), fabrication (6: TSMC, Samsung Foundry, Intel Foundry, SMIC, GlobalFoundries, UMC), packaging (6: TSMC Advanced Packaging's CoWoS, ASE, Amkor, and the three HBM makers), systems (7: NVIDIA, AMD, Broadcom, Marvell, Vertiv, Arista, Supermicro), energy (8: transformer, turbine, HV cable and grid-equipment makers), actuation (7: the precision-drive duopoly, the robot makers, Renishaw), and deployment (8: the hyperscalers, the three frontier labs named in the directory, and CoreWeave). Every citation was checked against a live fetch or search of the source itself before being added — a company's own product/technology page where one exists and answers the claim, trade press or a filing where it does not (Sibanye-Stillwater's own SEC production-update filing for its ruthenium row, Data Center Frontier for xAI's Colossus). Names, layers and roles are what is claimed sourced; the scarcity grade stays a judgement, exactly as `s()`'s own comment says. 46 rows remain unverified: extraction, refining and conversion layers — left for a follow-up pass rather than rushed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9tLC1kS4qNVdRxcHuPZ5c * feat(participants): source extraction and refining layers (27 more) Continues the pass started for equipment through deployment. 81 of 101 rows now carry a source. Extraction (12): The Quartz Corp and Sibelco's own Spruce Pine pages, Sibanye-Stillwater's SEC filing and Impala Platinum reused from the earlier producer-coverage pass, Nornickel, MP Materials' own Mountain Pass page, Lynas's own about page, and the three tin miners plus QatarEnergy/ExxonMobil reused from `substrata-coverage.ts` — same companies, same claims, no reason to re-derive a citation already found. Refining (15): the three merchant polysilicon refiners plus OCI, the PGM refiners (Heraeus, Johnson Matthey, Umicore), the gas majors, and `Chinalco` renamed to `Chalco` here too — same entity correction as the coverage file: Chalco (Aluminum Corporation of China Limited) is the listed subsidiary that actually runs the gallium-yielding alumina refineries. 20 rows remain: the conversion layer. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9tLC1kS4qNVdRxcHuPZ5c * feat(participants): source the conversion layer — all 101 directory rows now sourced Completes the pass: every row in `substrata-participants.ts` now carries a primary source, up from zero at the start of it. Conversion (19): the prime-wafer makers, the fused-quartz specialists, the wide-bandgap and diamond materials firms, the REBCO tape makers, the two rare-earth magnet-alloy specialists (Neo Performance Materials, Less Common Metals — the only two genuinely new searches in this batch; the other 17 reused citations already found and checked in `substrata-coverage.ts` for the same companies), and the electrical-steel and solder makers. `p()`, the unverified-lead helper, is now unused — every row calls `s()`. Kept rather than deleted (the file's own header says a new participant starts as a lead), with an eslint-disable and a comment saying why, dated, so the next person to touch this file knows the state was checked, not missed. Coverage summary for this whole pass: 101/101 participants sourced, against 0/101 at the start. Two entity-name corrections carried over from the producer-coverage pass (Chinalco → Chalco, in both refining and extraction) for consistency across the two files. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9tLC1kS4qNVdRxcHuPZ5c * refactor(byok): use Anthropic's own SDK instead of a hand-rolled client Decision on "should this use a package": yes, for exactly one of the two vendor calls in `lib/byok.ts`, and deliberately no for the other — the two are not the same situation. WHY THE OPENAI-COMPATIBLE PATH STAYS AS IS `completeOpenAiCompatible` (OpenAI and OpenRouter) already goes through `@bitbaum/ai-kit`'s `complete()`, which exists specifically to be the one client for every vendor that speaks the OpenAI chat-completions shape. Adding the `openai` npm package here would mean two clients for the same wire format in one file, and it's the fleet's own documented lesson (ai-kit's `complete.ts` header) that duplicated hand-rolled clients are the failure mode, not the fix. No change. WHY THE ANTHROPIC PATH DOES NOT Anthropic's Messages API isn't the shape ai-kit speaks, so this file hand-rolled a hand-rolled `fetch` call: manual AbortController/timeout racing, manual JSON error-body parsing, manual status-code-to-message mapping. That is precisely the "conventions differ because nothing ever offered to own them" pattern ai-kit's own header describes for the fleet at large — just scoped to one vendor instead of eight. Anthropic publishes the thing that owns it: `@anthropic-ai/sdk` gives typed errors (`AuthenticationError`, `NotFoundError`, `RateLimitError`, `APIConnectionTimeoutError`) that already distinguish exactly the failures this file was hand-classifying by status code, and a `timeout` + `signal` pair on the request options that race correctly against each other (verified by reading `client.js`: the external signal is wired into the same internal AbortController the timeout arms, not left to fight it). Swapping in the SDK deletes the hand-rolled error mapping in favour of five `instanceof` checks and removes the manual AbortController plumbing entirely. `maxRetries: 0`, deliberately: this is one link, not a chain the caller can fall through, so a failure should reach the reader immediately rather than being silently retried inside a budget the caller already timed. Verified against the real Anthropic API with a syntactically-valid but invalid key: the SDK's `AuthenticationError` maps to the same "Anthropic rejected that key." message the hand-rolled version produced, confirming the swap is behaviour-preserving where it matters — what the reader sees on the four error paths (bad key, unknown model, rate limit, timeout) is unchanged; only how this file gets there is simpler. Lockfile note for whoever next touches `pnpm-lock.yaml` by hand: this sandbox cannot fetch `bitbaum/listkit`'s git-hosted tarball (its own CI can), so the new `@anthropic-ai/sdk` entries here were generated against a temporary local git-protocol substitution for that one dependency, then merged back byte-for-byte against the committed `listkit` resolution — verified with `pnpm install --frozen-lockfile` reporting "Lockfile is up to date, resolution step is skipped" before failing on the same pre-existing, sandbox-only `listkit` fetch this repo already had. `git diff pnpm-lock.yaml` is pure addition; the three `listkit` lines are untouched. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9tLC1kS4qNVdRxcHuPZ5c * fix(chat): retrieval quality — word-boundary scoring, IDF weighting, relevance floor The assistant answered a "biggest robotics bottleneck" question with a thin, wrong "ABB Robotics" citation, "not in your data" for the actual chokepoints, and a source list dominated by unrelated development banks and country directory rows. Root causes, all in the retrieval path rather than the model or prompt: - searchResearch()/chatContext() scored raw substring hits with a flat title/body bonus and no notion of how common a word is across the corpus, so boilerplate connector text ("Bottlenecks its mandate could fund relief for: …", repeated on every capital and country row) systematically outscored real, specific content. - Actuation-layer companies (Harmonic Drive Systems, Nabtesco, FANUC, Yaskawa, Renishaw, KUKA) derived their searchable topics only from a COVERAGE materials join they don't have, so they carried empty topics and were unreachable by any query — and the same join gap meant their already-sourced directory citation (person.source) was never surfaced, so their pages read "unverified" when a real source existed. - Bottleneck entities never used the word "bottleneck"/"chokepoint" in their own retrieval text, while capital/country boilerplate used it constantly. Fixes: word-boundary tokenization with document-frequency weighting in research-index.ts (rare words score more than ubiquitous ones); participants.ts now also derives technologies/industries and a directory source from a participant's own chain layer, not only the coverage join; boilerplate connector phrases reworded to drop the generic "bottleneck(s)" wording while keeping the specific cross-referenced names; a minimum relevance floor in chatContext so a single coincidental common-word match no longer fills the citation list; an expanded stopword list for generic superlatives/category nouns ("biggest", "companies") that discriminate nothing in this corpus. Added a regression test reproducing the reported query and pinning that the known noise (European Investment Bank, DOE Loan Programs Office, KfW) is excluded and an actual robotics/actuation record is retrieved. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C9tLC1kS4qNVdRxcHuPZ5c --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
c54611814a |
feat(sweep): run the research sweep on a timer, into a queue rather than the corpus (#68)
The site's promise is that it tells you what changed, and it has been reading "Updated 2026-09-14" for four days because the sweep only ran when a person ran it. 92% of company profiles carry no dated event at all. That is the deepest problem on the site: a research service that is visibly stale has stopped being the thing it claims to be. The sweep now runs unattended, and deliberately cannot publish. Where it writes is the whole design. The corpus stays files in git, accepted by a person in a commit, because "a human read this and accepted it" is the claim every row on the site makes. A timer writing into it would publish rows nobody read, and a release directory is replaced by the next deploy anyway. So findings land in `research_sweep_candidates`: a queue of leads, none of which reaches a page until somebody promotes it. A test greps the scheduled path for `writeFile` and the corpus paths to keep that true. It is a route rather than a script because the box runs releases, not checkouts, and the fleet's cron convention calls an authenticated route. A missing CRON_SECRET refuses with 503 rather than running: an open sweep endpoint spends web and model budget for whoever finds it. Runs are bounded to four nodes and rotate by least-recently-swept, so a run fits the wrapper's 300s and coverage still moves across all 33 bottlenecks. Each run records what it did, so "how fresh is this" is answerable from evidence instead of inferred from the newest event — and a node the search backend could not reach is recorded as blindness, not as a quiet week. What decides whether something IS an event moved to `lib/sweep.ts`, shared by the script and the timer. Two copies of that judgement would have drifted, and the hand-run and scheduled sweeps would have quietly stopped agreeing. Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
70022c7202 |
feat(map): a dossier for every country, not a demo for one (#53)
* feat(map): a dossier for every country, not a demo for one Index all 177 landmasses. Geology directory plus extra endowments so Chile, Kenya, Greenland, Colombia are real pages. Lithium countries link to the chemicals bottleneck; uranium countries to the fuel cycle. World view gets resource filters, coverage counts, similar geologies, and an SVG of connected records. * fix(map): drop unused country-resources import |
||
|
|
8549216642 |
Capital, Learn, and one module that owns every internal URL (#41)
* feat(portal): capital, learn, and one module that owns every internal URL Three things the site was missing, and a gate for the class of bug the third one introduces. **Capital.** The loop model has nine stages and `capital` read "not covered yet". The obvious version of this section would imply money is the scarce thing — but the site's own research says otherwise, and one of the published calls rests on it: transformer lead times stay long *because* capital has been available for two years without shortening the queue. So the claim is narrower: capital is rarely scarce, capital with the right mandate and the right patience is. `willNotFund` is the load-bearing field, and `FUNDING_ASSESSMENTS` says out loud where funding is not the constraint. Three providers, not the five drafted. Two were cut because the mandate sentences could not be found on their own pages — the same bar the policy section uses. **Learn.** The glossary was 32 entries rendered as one undifferentiated block at the bottom of About, with no anchor per term, so nothing could link to a definition. It moves to /learn and gains an anchor each, alongside four explainers built on the existing bip-kit path — `lib/notes.ts` generalised to collections rather than a second content pipeline. **Links.** 29 hand-built entity URLs in twelve distinct shapes; an `href()` helper in lib/site.ts that nothing used. `lib/links.ts` owns them now. The test that walks every href the data can generate caught a real bug on its first run: KfW is German and /policy/de does not exist, because a jurisdiction only earns a page once something is recorded under it. Fixed by making POLICY_PAGES the single fact that generateStaticParams, the test and the capital page all read. Event `participants` were not merely unlinked — they were never rendered. An event knew it was about Samsung Memory and the reader was never told. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 * feat(portal): capital on the bottleneck pages, in the map, and in the stage model Four loose ends from the capital pass. A bottleneck page now answers "who could fund relief" — leading with whether funding is the constraint at all, because for most rows on this site it is not, and a section that opened with providers would imply the opposite. Policy proponents link to their Markets page. There is exactly one proponent recorded as having lobbied for a rule, and it had a page all along: the policy record spells it "thyssenkrupp Electrical Steel" and the directory "ThyssenKrupp Electrical Steel", so an exact-name lookup called it a miss. `hasMarketPage()` matches on the slug, and the link test makes the same call the page does so the two cannot drift. /api/map gains capital, so an agent reading the map sees what a reader sees. And the capital stage stops saying "not covered yet". That phrase is still true of two other stages, so it cannot be banned by pattern — the new gate checks the claim against the data for the stage that makes it. Proved by mutation: restore the old line and the test fails. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 * research: promote five producer rows, and stop the block list eating real domains Five of the 35 unsourced producer rows now cite the company's own page — 57 to 62 of 92. Shanghai Superconductor's own tape page lists the 12 mm grade the row is about; POSCO's product page explains grain-oriented electrical steel; ExxonMobil, Gazprom and Air Liquide each document the helium operation on their own site. The other thirty did not clear the bar, and the bar is the one already written into `sourced()`: the company's own page. Market-report farms, stock-quote pages and a YouTube video are not sources. Two rows are worth flagging rather than promoting — the only evidence found for Nyrstar and gallium is a 2023 piece saying it was *considering* gallium projects, and REC Silicon's polysilicon evidence is about the Moses Lake closure. Neither is a source; both stay unsourced. Pruning the event worklist turned up a bug worth more than the prune. `host.includes('x.com')` matched `semiconductorx.com` and `simplytronix.com`, so the sweep had been discarding trade press invisibly — a filtered result leaves no trace. The list mixes full hosts and bare names, and the first fix broke the bare ones silently: the prune dropped 12 where it should have dropped 20. Now a full host matches itself or a subdomain and a bare name matches a whole label. Event candidates 77 to 57, all twenty drops junk domains, and `--prune` applies the live filter to stored rows so there is never a second definition of what counts as junk. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 * fix(portal): say a kind's funding limit once, and keep screenshot output out of the repo `willNotFund` describes the KIND of money, not the provider, so a bottleneck funded by two development banks printed the same sentence twice in a row and read as a rendering fault. It is now said once per kind. Phrasing it as a sentence did not survive contact with the data — "a venture capital will not fund" and "a export credit will not fund" are both wrong, and no article works across all ten kinds. It is a label now, in the same mono style the page already uses for "grade that ships" and "part of the process", where a noun phrase is what belongs. Verified in the built page, not just the source: the kind's limit appears under EIB and not again under KfW. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
2a40db31e4 |
research: cite every readiness score, accept nine events, and source part of the directory (#40)
SCIENCE — all twelve readiness scores now cite a source, and reading those sources moved three of them. High-NA EUV was scored 7 on 'delivered for development, not yet volume production'. ASML's own July 2026 release says Intel Foundry entered high-volume manufacturing on High-NA-patterned layers at matched yields, so it is 8. Neon recycling was scored 8 on 'adopted after 2022 and effective'; SK hynix was still calling its own system an industry first in April 2024 at 72.7% recovery, which is a pilot at one firm, so it is 6. The third is not a score error but a scope error: the quartz entry claimed the synthetic inner crucible layer was the open question. The source says fusing synthetic powder onto the inside of a natural crucible is established practice — what stays natural is the BODY, which is what the bottleneck is actually about. The entry is rewritten to describe that, and scored lower rather than higher as a result. Sources are seven company or organisation announcements, an SEC filing, a Department of Energy article and two peer-reviewed papers. No market-research vendors: where only one of those existed the row would have stayed uncited. EVENTS — 77 candidates triaged: 17 real, 54 not events at all, 3 matching a different meaning of the term (REBCO is also a Russian crude blend, NEON an ecological observatory), 3 syndications of one press release. Nine accepted, taking the record from 14 to 23. The Tennessee polysilicon row was upgraded from a headline to the story: it is Wacker's Charleston plant, 600 workers, and the cause is a US trade measure that drove off both its customers — a policy tightening the bottleneck it was written to loosen. That bears directly on the Section 232 call published yesterday. Since most of the noise came from a known set of domains, the sweep now filters them before a person sees them. DIRECTORY — a participant row's existence source is derived from its verified maker rows rather than researched twice, so 12 of 101 rows now carry evidence for the factual half and it grows automatically as rows are promoted. The replaceability grade stays explicitly a judgement: no single page asserts how hard a company is to replace, and the page says so. The stale-absence gate gains the science citations, since 'none of them yet carries a citation' stopped being true in this commit. Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
b2b49f708a |
feat(calls): start the track record, and fix the engine that was mistaking blindness for absence (#39)
THE ENGINE BUG 33 producer rows were filed as 'nothing' — including "Air Liquide" helium and "MP Materials" rare earth, which cannot plausibly return zero results. The timestamps gave it away: 18 of them finished in under three seconds, which is the inter-row pause plus a search and no page read at all. The shared SearXNG instance had begun answering HTTP 200 with an empty result list. ai-kit reports that as 'nothing' — correctly, the request succeeded — and 'nothing' is not 'could_not_look', so the outage guard never fired and a backend brownout was recorded as an absence of producers. That is precisely the failure the three-valued design exists to prevent, and it happened because the third value was attached to the wrong signal. A run of consecutive empty searches is now treated as blindness. A worse look also no longer overwrites a better one: re-running with --all had already destroyed three good rows when the backend hiccuped mid-run, which is the same mistake wearing different clothes. Also: read 8 of 10 results rather than 3 of 5, and read the company's own domain first, because every one of the 131 candidates the first run accepted came from a company-owned domain and not one from a news site. Producer aliases and extra material trade names for the rows where the web writes a different word than the catalogue does. Candidates went from 59 rows to 73. Nine of those passed the analyst bar — the organisation's own document, or a recognised industry body — taking verified producer rows from 48 to 57 of 92. Resellers, market-report vendors, stock-profile sites and PR wires were rejected, which is most of what the engine turns up. CALLS The first seven dated calls, each naming the observation that settles it, the date by which reality must answer, and the thesis claim it tests — which is what turns six general views into something that can be marked. No hit rate is published until ten have resolved, because a percentage from a handful is noise wearing a number, and wrong calls will stay on the page. Publishing them made two existing sentences false — About and one note both said no call had ever been made. Both are fixed here, and a new gate fails the build if any rendered string claims an absence the data has since filled, because that class of error recurs every time the data catches up with the prose. Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
d1ed442a69 |
feat(events): the loop in nine stages, an assessment per bottleneck, dated events, and Today as the front page (#35)
* feat(events): the loop in nine stages, an assessment per bottleneck, dated events, and Today as the front page Every bottleneck now sits on one of nine stages of the loop and carries an analyst's binding score (the four mandate tests, 0–3 each) and a horizon: binding now, within two years, beyond. Events are a typed record — date, kind, effect, bottlenecks, source, quote — accepted by an analyst; a weekly sweep files candidates into research/events.json and never promotes. The front page is Today: the last thirty days of events, what is binding now, and where the loop is covered. The board moves to /board, grouped by stage with score and horizon. /events lists accepted events with chips. /api/events and /api/map carry the new records. Public copy stops leaning on the words singularity and recursive self-improvement. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 * research: first event sweep, 12 accepted events, partly-sourced rows say so 77 candidates filed by the sweep; 8 accepted after reading the page and taking the date from it (plus the 4 seeded from the source engine's finds). A node with most producers sourced now reads '6/7 sourced' rather than 'candidate'. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |
||
|
|
687abef748 |
feat(research): commission the substrate-of-recursion programme, research engine, JSON map and correction intake (#31)
* feat(research): commission the substrate-of-recursion programme, research engine, JSON map and correction intake A research programme file with layers, open questions and falsifiers, cross-referenced to the coverage universe by test. An engine that searches the fleet's SearXNG through ai-kit for a source behind each unverified producer row and files candidates, never findings, into a committed evidence file. /api/health and /api/map so agents consume the map as data. Prefilled public-issue links so a wrong row is one click to report. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 * fix(research): search on the material's trade name, match name and material in one window Each listing now carries the term the trade uses, so the engine asks for "Yunnan Tin" tin rather than "Yunnan Tin" high-purity. A page is a candidate only where the company name and a material term share a window, and that window is the excerpt filed. Also replaces a stray NUL in the row key with a shared evidenceKey helper. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 * chore(research): exempt the engine-written evidence file from prettier; summarise the all-materials layer Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 * research: first engine run — 59 of 92 producer rows have a candidate source Every unverified row examined through the fleet's SearXNG. 59 rows carry at least one page naming the company alongside the material (131 pages filed with excerpts), 33 found nothing usable, 0 could not look. Nothing is promoted: every row still reads unverified or candidate until an analyst attaches the source. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y6ecRd91ZsPPcjuNkKTFV2 --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> |