/** * The map as data, for machines. * * The site renders the research for people. This builds the same objects — * the same coverage rows, the same evidence, the same thesis — into one JSON * document for an agent or a script that wants to consume the map rather * than scrape the prose. Nothing here is a second copy: every field is read * from the config the pages are drawn from, so the API cannot say something * the site does not. * * The verification vocabulary is the site's: `sourced` is a checked claim and * `unverified` is not. Pages the sourcing engine found are a review queue in * the database, not corpus, so this document (and the export digest built * from it) never carries them. * * Created: 2026-09-14 */ import { COMPANY, MANDATE_CURVES, MATERIALS, areaFor } from '@/config/substrata'; import { CHOKEPOINTS, COVERAGE } from '@/config/substrata-coverage'; import { chokepointProgress, coverageProgress } from '@/lib/coverage-progress'; import { INVESTMENT_THESIS } from '@/config/substrata-acting'; import { CAPITAL_KINDS, CAPITAL_PROVIDERS, FUNDING_ASSESSMENTS } from '@/config/substrata-capital'; import { CHAIN_LAYERS, PARTICIPANTS } from '@/config/substrata-participants'; import { verificationFor } from '@/config/substrata-evidence'; import { RESEARCH_PROGRAMMES, programmeProgress } from '@/config/substrata-programmes'; import { CALLS, record } from '@/config/substrata-calls'; import { eventsNewestFirst } from '@/config/substrata-events'; import { STAGES } from '@/config/substrata-stages'; import { BOTTLENECKS } from '@/lib/bottlenecks'; import { SITE } from '@/lib/site'; export function buildMap() { const coverage = coverageProgress(); const chokepoints = chokepointProgress(); return { name: COMPANY.name, tagline: COMPANY.tagline, host: SITE.host, generatedAt: new Date().toISOString(), notice: 'Research, not advice. A row is "sourced" when a claim is backed by a primary source and ' + '"unverified" otherwise. Only "sourced" is a finding. A bottleneck whose rows are only ' + 'partly sourced reads "candidate".', progress: { producers: { total: coverage.total, sourced: coverage.sourced, }, chokepoints: { total: chokepoints.total, sourced: chokepoints.sourced }, }, stages: STAGES.map((stage) => ({ id: stage.id, name: stage.name, reliefTime: stage.reliefTime, bottlenecks: BOTTLENECKS.filter((b) => b.stage === stage.id).map((b) => b.slug), })), bottlenecks: BOTTLENECKS.map((b) => ({ slug: b.slug, name: b.name, kind: b.kind, stage: b.stage, binding: b.binding, score: b.score, horizon: b.horizon, judgedOn: b.judgedOn, state: b.state, events: b.events.map((e) => e.id), })), events: eventsNewestFirst(), calls: { record: record(), items: CALLS.map((call) => ({ id: call.id, madeOn: call.madeOn, claim: call.claim, tests: call.tests, bottlenecks: call.bottlenecks, resolveBy: call.resolveBy, settledBy: call.settledBy, resolution: call.resolution, })), }, curves: MANDATE_CURVES.map((curve) => ({ id: curve.id, label: curve.label, test: curve.test })), materials: COVERAGE.map((entry) => { const listing = MATERIALS.find((m) => m.title === entry.material); return { material: entry.material, area: listing ? areaFor(listing).id : null, curve: listing ? areaFor(listing).curve : null, spec: listing?.spec ?? null, thesis: entry.thesis, producers: entry.producers.map((producer) => ({ name: producer.name, jurisdictions: producer.jurisdictions, role: producer.role, verification: verificationFor(producer.source, producer.evidence), source: producer.source, })), }; }), chokepoints: CHOKEPOINTS.map((point) => ({ name: point.name, type: point.type, curve: point.curve, jurisdictions: point.jurisdictions, why: point.why, verification: point.source ? 'sourced' : 'unverified', source: point.source, })), participants: { layers: CHAIN_LAYERS.map((layer) => ({ id: layer.id, name: layer.name, curve: layer.curve })), rows: PARTICIPANTS.map((item) => ({ name: item.name, layer: item.layer, role: item.role, jurisdictions: item.jurisdictions, scarcity: item.scarcity, why: item.why, })), }, // Capital is a map of who funds what on whose mandate. `willNotFund` is the // field that carries it, and `constraint` says out loud where money is not // what is missing — which, for most rows here, is the answer. Nothing in // this block is advice on where to put money. capital: { kinds: CAPITAL_KINDS.map((kind) => ({ id: kind.id, name: kind.name, plain: kind.plain, chequeSize: kind.chequeSize, horizon: kind.horizon, willFund: kind.willFund, willNotFund: kind.willNotFund, })), providers: CAPITAL_PROVIDERS.map((provider) => ({ id: provider.id, name: provider.name, kind: provider.kind, jurisdiction: provider.jurisdiction, mandate: provider.mandate, canMove: provider.canMove, source: provider.source, primary: provider.primary, quote: provider.quote, readOn: provider.readOn, })), funding: FUNDING_ASSESSMENTS.map((item) => ({ bottleneck: item.bottleneck, constraint: item.constraint, why: item.why, })), }, thesis: INVESTMENT_THESIS.map((claim) => ({ id: claim.id, claim: claim.claim, falsifier: claim.falsifier, })), programmes: RESEARCH_PROGRAMMES.map((programme) => ({ id: programme.id, title: programme.title, question: programme.question, opened: programme.opened, status: programme.status, progress: programmeProgress(programme), layers: programme.layers.map((layer) => ({ id: layer.id, name: layer.name, period: layer.period, gatedBy: layer.gatedBy, })), questions: programme.questions.map((q) => ({ id: q.id, question: q.question, settledBy: q.settledBy, })), })), }; } export type SubstrataMap = ReturnType;