mirror of
https://github.com/bitbaum/substrata.git
synced 2026-12-05 08:57:13 +01:00
main
11
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
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 |
||
|
|
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> |
||
|
|
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> |
||
|
|
cfaf05a10c |
refactor: split the god files by job, and globals.css by feature (#83)
Every code file the size ratchet grandfathered is now under its 300-line
ceiling, split by what it does rather than by line count:
- lib/search.ts -> entry + lib/search/{text,corpus,build,expand,score,snippets}
- lib/chat-tools.ts -> lib/chat-tools/ (one module per tool family + registry)
- lib/chat-agent.ts -> lib/chat-agent/{loop,parse,turn,prompt,stream-gate}
- lib/chat.ts -> lib/chat/{types,retrieve,models,answer}
- ResearchChat.tsx -> components/portal/chat/ (thread, turn, composer,
BYOK panel, contribute form, hooks)
- SearchBox.tsx -> components/portal/search/ (popover, page form, shared)
- profile modules, lib/bottlenecks.ts, lib/participants.ts -> build/board
and module-family files beside them
- app/page.tsx, app/markets/[slug]/page.tsx, app/policy/page.tsx -> section
components in private _home/_sections folders
globals.css (2379 -> 664 lines) keeps tokens, base and site chrome; the
feature blocks moved to app/styles/*.css, imported from the root layout in
the order they had inside globals.css so the cascade is unchanged.
Screenshots of /, /search?q=asml, /markets/asml, the EUV bottleneck, /chat,
/notes, /atlas, /policy and /talent at 390/820/1440px are pixel-identical
to main.
The config/ corpus files stay grandfathered as data; the logic that was in
them moved to lib/ (coverage-progress.ts, participants.ts, geo.ts).
Also: the desk's "Open on" select said "Last all time"; and
INFRASTRUCTURE.md now records the hourly :17 sweep timer, the everyHours
setting that decides whether a run is due, and that 005-desk.sql is applied.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
||
|
|
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> |
||
|
|
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> |
||
|
|
6e25553f6d |
feat(portal): sections for policy, markets and science; plain language; and a test that fails the build on untrue copy (#37)
An audit found the site claiming a firm that does not exist: declining business every week, notes on a schedule, analysts, a desk, a compliance function, two phases running at once. All of it is gone, and test/truth.test.ts now walks every renderable string and fails the build if any of those phrases return. The mandate, acting and disclosure pages described that same firm; they are replaced by one About page that says plainly who makes this (one person and AI agents, since 2026-08-26), what exists, and what does not. Three new sections. Policy carries twelve rules fetched and read today from government sources, each with a verbatim sentence, a status that admits when something is adopted but not yet in force, and a named backer only where an organisation asked in its own document. Markets joins the directory to the verified producer rows and gives every organisation a page, while saying plainly that the directory's grades are unsourced. Science lists twelve candidate reliefs with a readiness judgement and says on every row that the judgement is not yet cited. Navigation becomes seven sections. Every bottleneck gains a plain-English line, technology and industry tags, and filters by both. Binding becomes Severity, horizon becomes When it bites, and sourced/candidate/unverified become Verified/Source found/Unverified, all defined in a fold-out legend. 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> |
||
|
|
103a544a0e |
research: source 48 of 92 producer rows from the engine's candidates (#33)
An analyst pass over the 59 candidate rows. A row was promoted only where the company's own page, filing or release states that it handles the material in that step; aggregators, news and encyclopaedias were left as candidates. 11 rows stay candidate (Minsur, Ferrotec, REC Silicon, 5N Plus for gallium, Chinalco, East Hope, Zhuhai Fangyuan, Baosteel Gases, Impala Platinum, SK Siltron CSS, 3M). The candidate count is now taken from the joined rows, so a sourced row stops counting as waiting. 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> |