* feat(research): search through ai-kit's keyless fallback when the box's backends fail
Since 2026-11-11 the box's SearXNG has not answered and there is no paid
key, so the Ask assistant, the event sweep and producer sourcing could not
look anything up. Every web search now walks the configured backends and
then ai-kit's keyless ones (GDELT news, then Wikipedia), from one place:
lib/web-search.ts. Whether looking up is offered still follows the
configured backends (webLookupEnabled, now ai-kit's own defaultProviders),
so a deployment or a test with none makes no request.
Needs @bitbaum/ai-kit 1.25.0 (the dependency bump follows).
Claude-Session: https://claude.ai/code/session_019MDtmuvTGrpo3VChP3skH8
* fix(health): the web probe walks the same chain as Ask, behind the same gate
Claude-Session: https://claude.ai/code/session_019MDtmuvTGrpo3VChP3skH8
* chore(deps): @bitbaum/ai-kit ^1.25.0 (keyless search fallback)
Claude-Session: https://claude.ai/code/session_019MDtmuvTGrpo3VChP3skH8
* test(web-search): type the test env the way next build checks it
Claude-Session: https://claude.ai/code/session_019MDtmuvTGrpo3VChP3skH8
---------
Co-authored-by: Claude <noreply@anthropic.com>
* feat(research): runs record what their search backends did, and /api/health/web says it now
The event sweep and producer sourcing failed for a day on production with
nothing on /data/freshness but "no search reached a search backend".
- Each sweep and sourcing run records its search backends' outcome in
ai-kit's own words (search_note, e.g. "searxng unreachable"); migration
018 adds the column. /data/freshness shows it beside a failing run.
- /api/health/web searches once for a fixed phrase and reports which
backends are configured (names only) and what each did. One probe per
ten minutes, shared by concurrent callers.
- docs/operations/auto-updates.md: what runs, when, what it needs, where
it leaves a trace, and what to do when a run is failing.
Claude-Session: https://claude.ai/code/session_019MDtmuvTGrpo3VChP3skH8
* fix(data-layer): read double-quoted identifiers in migrations
declaredObjects read `CREATE TABLE IF NOT EXISTS "users"` as a table named
"if", so 017-accounts.sql looked incomplete on any database that predates
the ledger: it would be re-run, and the ownership hand-over would miss its
real tables. CI's real-Postgres test caught it once 017 stopped being the
newest file ("must be owner of table accounts").
Tables, indexes, ALTER TABLE targets and added columns may now be quoted.
Claude-Session: https://claude.ai/code/session_019MDtmuvTGrpo3VChP3skH8
---------
Co-authored-by: Claude <noreply@anthropic.com>
- Respond with HTTP 200 from GET /api/health/freshness while preserving the ok: false payload when feeds or datasets need attention
- Prevent footer FreshnessBadge from triggering 503 Service Unavailable network errors during page browsing
- Update README documentation for /api/health/freshness
- Add automated test in test/freshness.test.ts verifying GET /api/health/freshness returns 200 with the full report
- Add timeout signals for PRICES_RUN_BUDGET_MS and PRICES_PORTION_MS in POST /api/cron/prices
- Propagate per-ticker and per-company timeout signals in fetchAllPrices and refreshMarketFacts
- Check abort signal in gatherHolders, fetchPrices, and openWebFetch
- Use abort-aware sleep in sourceFetch pacing and 429 retry waits
- Add automated tests in test/market-prices.test.ts verifying timeout signals and signal checks
- Define PRICES_RUN_BUDGET_MS (200s) and PRICES_PORTION_MS (140s) to keep daily price and fact runs well within the 300s curl timeout of the systemd wrapper
- Forward request.signal from POST /api/cron/prices to fetchAllPrices, refreshMarketFacts, and sourceFetch
- Bound individual fetch timeouts to remaining budget and abort promptly when signal is aborted
- Ensure research_price_runs and research_market_fact_runs always record completion (finished_at = now()) on early exit
- Add automated test in test/market-prices.test.ts verifying runtime budget enforcement and signal forwarding
- Export AUTO_UPDATES_RUN_BUDGET_MS (200s) to keep hourly auto-updates well within the 300s curl timeout of the systemd wrapper
- Forward request.signal from POST /api/cron/auto-updates to runAutoUpdates
- Pass signal and budget bounds down through draftLeads and byokAsk to ai-kit complete
- Stop starting new leads and abort in-flight requests when the budget expires or signal is aborted
- Bound per-request page reads to remaining budget
- Add automated test in test/update-now.test.ts verifying runtime budget enforcement and signal forwarding
- Define JOBS_RUN_BUDGET_MS (200s) to keep daily job board fetches well within the 300s curl timeout of the systemd wrapper
- Forward request.signal from POST /api/cron/jobs to fetchJobs
- Stop starting new board requests and job upserts when the budget expires or signal is aborted
- Bound per-request fetch timeouts to remaining budget
- Ensure research_job_runs always records completion (finished_at = now()) on early exit
- Add automated test in test/careers.test.ts verifying runtime budget enforcement and signal forwarding
- Read candidate pages concurrently with Promise.all in lib/sweep.ts rather than awaiting each serially, bounding page reading time per node
- Add SWEEP_RUN_BUDGET_MS (200s) and budget/signal checking to runScheduledSweep in lib/sweep-store.ts so scheduled runs finish well within the 300s box curl timeout
- Pass request.signal from POST /api/cron/sweep to runScheduledSweep
- Add automated tests in test/sweep.test.ts verifying budget enforcement and concurrent candidate reads
- Align SCHEDULED.budgetMs to 200s (200_000ms) to ensure scheduled quality runs finish well within the 300s box wrapper
- Forward request.signal from POST /api/cron/quality to runQuality
- Pass signal and remaining time bounds to probeUrl, quotesAt, pageText, secVerdicts, figiVerdicts, and mcsVerdicts
- Stop starting new lanes and work in pool when signal is aborted or deadline is reached
- Add automated test in test/quality.test.ts verifying budget bounds and signal forwarding
- Read candidate pages concurrently with Promise.all in lib/source.ts rather than awaiting each serially, bounding page reading time per row
- Define SOURCE_RUN_BUDGET_MS (200s) and budget/signal checking to runScheduledSourcing in lib/source-store.ts so scheduled runs finish well within the 300s box curl timeout
- Pass request.signal from POST /api/cron/source to runScheduledSourcing
- Add automated tests in test/source.test.ts verifying budget enforcement and concurrent candidate reads
- Define SCIENCE_RUN_BUDGET_MS (200s) to keep hourly science feed fetches well within the 300s curl timeout of the systemd wrapper
- Forward request.signal from POST /api/cron/science to fetchScience
- Stop starting bottleneck queries and source fetches when the budget expires or signal is aborted
- Bound per-request fetch timeouts to remaining budget and abort immediately on signal
- Ensure research_science_runs always records completion (finished_at = now()) on early exit
- Add automated test verifying runtime budget enforcement and signal forwarding
- Define FILINGS_RUN_BUDGET_MS (200s) to keep hourly EDGAR fetches well within the 300s curl timeout of the systemd wrapper
- Forward request.signal from POST /api/cron/filings to fetchFilings
- Stop starting feed and registrant requests when the budget expires or signal is aborted
- Bound per-request fetch timeouts to the remaining budget so individual requests do not overrun
- Ensure research_filing_runs always records completion (finished_at = now()) on early exit
- Add automated test verifying runtime budget enforcement and signal forwarding
* feat(auth): Substrata accounts on @bitbaum/accountkit, not only OrangeCat
Readers can create an account with an email and a password or a passkey,
and turn on two-step codes. Continue with OrangeCat stays one way in.
next-auth and lib/identity.ts are gone; /api/auth serves AccountKit's
runtime, and /sign-in, /sign-up and the account panel in
/account/settings are its shared screens in Substrata's look.
Desks, follows, saved AI keys and SUBSTRATA_REVIEWER_ACTOR_IDS stay keyed on
the OrangeCat actor id: legacyIdentityProvider keeps it for anyone whose
first way in was OrangeCat. The six account tables are
scripts/db/017-accounts.sql, additive and re-runnable, applied by the deploy.
Rebuilds the stale draft #184 on current main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
* test(data-layer): the pre-ledger case names the newest migration, not 016
Adding 017-accounts.sql made the test treat 016 as one of the files that
predate the ledger; it now asks for whatever file is newest.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9
---------
Co-authored-by: Claude <noreply@anthropic.com>
* feat(deploy): the deploy applies migrations, installs timers and runs the one-time price backfill
Before the release goes live, deploy.yml now applies pending scripts/db/*.sql
(one transaction each, recorded in public.schema_migrations, first run checks
existing objects before baselining) and installs deploy/systemd units. A failure
stops the deploy with the live release untouched. After the release, the price
backfill runs once and is recorded in public.schema_oneshots.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* docs: name no migration file that does not exist
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>
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>
The owner could not ask Substrata about a screenshot of a post: every
composer passed attach={false}, and /api/chat took no pictures.
- One composer (AskComposer) on the home box, the Ask panel and /chat:
Camera / Photos / Files, paste and drop, pictures shrunk to 1024px in
the browser (Heidi's limits), text files inlined, a message queued while
a turn runs, the draft shared between surfaces.
- /api/chat validates pictures (strict data URLs, three at most, 1.5 MB,
never stored or logged) and attached text, with a larger body cap.
- A turn that brings material is a claim check: one read call returns the
visible text and checkable claims as JSON (claims whose numbers the
material never printed are dropped), each claim is searched and, for a
seed company, priced; the answer is bottom line first, one status per
claim with a citation or "Not found", reasoning labelled, and no figure
only the material gives repeated as fact. Every existing guard runs.
- No model that can see: one sentence (paste the text, or add a key);
nothing is guessed.
- The home box hands its message and attachments to /chat (?send=).
Tests: claim-check (fixture, fake vision model, fake web), handoff, image
validation; two eval rows; ask-layout picks a picture into /chat's box.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
* 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>
The owner, 2026-10-25: asked about future demand for neon, the Ask read six
pages and answered with one US table. Analytical questions (outlooks,
forecasts, what-ifs, comparisons of impact, "when could X be commercial") are
now routed to a research mode:
- route.ts classifies `analysis`; loop.ts hands those to research.ts
- research-plan.ts: one model call writes 3-6 sub-questions with a query each,
validated in code (listed corpus tools, their own arguments); a code plan by
question kind when the call fails or times out (7 s)
- research-read.ts: every sub-question searched in parallel through lookUp
(SSRF-safe readPage, PDFs), one 15 s deadline, passages kept round-robin,
one URL once, two per site, primary/trade/analyst before farms, as [W#]
- research-shape.ts: bottom line first, then What is established, What drives
it, Scenarios, What would change this, Confidence and gaps, Sources (from
the citations); uncited forecasts dropped; unanswered sub-questions said by
code and filed through gaps.ts
- scenario-calc.ts: the model names cited inputs and cases, code checks every
input against its passage, computes low/base/high with the formula shown and
draws a line chart through the chat_ui chart block
- default deny holds reasoning sections to the labelled-background rule
- api/chat: "Reading <site>…" now reaches the reader (onRead was dropped);
analysis answers get more output room
- tests with fakes for the five owner questions; ask-evals rows; a script to
ask them live after deploy (scripts/ux/ask-live.ts)
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
* 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 8e85c7e, 71978bd and 2fd9194 with the clock
pinned: every one passes on 2026-10-24 and fails on 2026-10-25 (before #242
the row that fell out was jobs-niger instead). No commit introduced it.
The evals test ranking, not the calendar; staleness has its own gates.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* feat(research): --write dates only what a re-check actually found
check-series.ts --write sets checkedOn on a series only when every point's
quote was re-read in that run and found; misses and unreachable pages keep
their last real date. check-job-boards.ts re-opens each careers page and
re-dates only records that still hold; the file's own date is the oldest
record's. Both are named as the refresh in config/substrata-freshness.ts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* data: re-read 2026-10-25 — 128 of 139 series, 109 of 138 job-board records
check-series.ts --write: 535 of 574 quotes found, 0 missing, 39 unreachable
from the sandbox (31 www.asml.com press releases now 301 to investor.asml.com,
which answers 403; 8 data.bls.gov 503). The 11 series behind them keep
2026-09-24. check-job-boards.ts --write: 109 records held, 29 not confirmed
(kept at 2026-09-24).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* data: listings re-searched 2026-10-25 (SEC tickers + OpenFIGI, all 138)
pnpm run research:listings, full mode (not --revalidate, which re-applies the
rule to stored rows without searching): every OpenFIGI search answered. Two
rows moved: Air Liquide's SEC OTC line (AIQUF) is no longer in the SEC ticker
table; Fanuc now has one (FANUF, CIK 1446596). The 7 private rows come from
config/substrata-listing-overrides.ts, as the script defines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* ci(data): a monthly re-check that commits only what it re-read and found
.github/workflows/recheck-data.yml runs check-series --write, check-claims
--write and check-job-boards --write (and the ~70-minute listings re-search
on the schedule or when asked), then commits to the dispatched branch or
opens a bot/recheck-data-<date> PR. Token: FLEET_PAT, else GITHUB_TOKEN, as
in auto-merge.yml; a GITHUB_TOKEN push triggers no CI, so the PAT is preferred.
check-claims.ts dates research/claims.json only when every claim's sentence
still reads in its file and every series it cites was re-read and found
today, and prints the latest values beside each claim for the reviewer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* data: three dead ASML source URLs point at the same releases as filed with the SEC
The 2019-Q4, 2020 annual and 2024-Q2 press releases on www.asml.com now 301
to ASML's generic press-release index. The same releases are exhibits to
ASML's Form 6-K filings (0000937966-20-000003, -21-000003, -24-000019);
all seven quotes were re-read there and found. One quote is shortened to a
verbatim span of the same sentence: the filed HTML splits 'at' across a tag
('a t'), so the sentence's opening cannot be matched mechanically.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* ci(data): run the re-check once on this branch (temporary push trigger)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* data: re-check 2026-10-25 (scheduled re-read)
Dates moved only for what was re-read and found in this run; see the workflow summary for every row that was not.
* fix(quality): a word split across two style runs reads as one word
SEC filings print some words as two font runs ('EU</font><font …>V'), and the
reader turned every tag into a space, so 'EUV' read 'EU V' and a quote copied
from the rendered page missed. Only a letter-run-letter split is joined; a
footnote run ('billion</font><font>2') and every other tag stay a space.
Full re-read before/after: no quote that was found is lost.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* data: ASML points the runner cannot open, re-sourced to the same releases on SEC EDGAR
investor.asml.com answers 403 to GitHub's runners as well as to the sandbox.
Sixteen points whose page could not be opened from either now cite the same
press release as filed with the SEC (Form 6-K); each quote was re-read there
and found. The 2020-Q4 bookings quote is back to its full sentence (the page
reader now joins 'a t'). SICC: the quotes carried the old reader's split
('S iC'); they now read 'SiC', as the page does, and are found.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* feat(research): job boards re-checked in a browser, and absences re-checked too
A careers page whose served HTML lacks the system's mark is drawn in Chromium
(the workspace's Playwright); failing that, the tenant the evidence names
must still answer as that system. A record saying something is NOT there
holds while it still is not (no careers link, site still down, hosts named
still not answering). The workflow installs Chromium for it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* data: re-check 2026-10-25 (scheduled re-read)
Dates moved only for what was re-read and found in this run; see the workflow summary for every row that was not.
* data: job boards — every site the evidence names may show the system; 4 more held
Run from the sandbox with Chromium on the 11 records the runner could not
confirm: chalco, openai, supermicro and ase-technology… held where a site the
record names still shows its system; 7 stay at 2026-09-24 (listed in the PR).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* ci(data): drop the one-off push trigger; schedule and dispatch only
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* feat(freshness): rows tried and not confirmed are a visible, expiring exception
A re-check that cannot confirm a row (a source that refuses our servers, a
page that changed) now records it in the dataset file's 'unconfirmed' list
with the reason and the day it was tried — written by check-series and
check-job-boards --write, never by hand; a row confirmed later leaves it.
The gate counts a listed row as tried on that day: the dataset is judged by
the oldest of each row's own check or recorded try, so an entry expires like
any date and next month's run must try again. A dataset with listed rows is
never 'fresh' (it reads 'late' and is under Needs attention), and
/data/freshness and /api/health/freshness name every row with its reason.
Tests: a row neither dated nor listed fails, an expired entry fails, a
listing for another row covers nothing, and the table renders the list.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* data: record the rows no re-check could confirm on 2026-10-25
check-series --write lists us-employment-semiconductor-related-device-
manufacturing (data.bls.gov answered 503 to the sandbox and to GitHub's
runner; BLS refuses datacenter addresses). check-job-boards --write lists
air-products, umc (403), tanaka-kikinzoku (504), baosteel-gases,
element-six and yaskawa. nippon-steel was re-opened: its recruit page's
yelloop.jp link is an alumni network; /recruit/hq/ still links its axol
entry (job.axol.jp/bx/s/nipponsteel_27), so the evidence names that page
and the record held.
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>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* feat(home): the homepage, rebuilt ask-first
The hero is the Ask box (chatkit composer plus four questions, one built from
the worst bottleneck); sending opens /chat with the question started. Worst
right now is one row component with a fixed gauge column; what changed falls
back to the sweep's unchecked finds or is absent, never an empty box; the
numbers are four equal linked cells; doors share one anatomy; the footer is
calm. The page is served from a 60 second cache: the shell learns its reader
from /api/me in the browser instead of reading the session while rendering.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* fix(home): centred column, aligned worst rows, broken-word scan
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>
Substrata was the product whose Ask answered "nothing in our database" with
no way forward, and nobody knew until the owner said so. From here every
turn is in the loop:
- chatkit 0.14: thumbs under every answer (ChatThread onFeedback); a thumb
down asks why. POST /api/chat/feedback (zod, same-origin, rate limited)
keeps it in chat_feedback.
- chat_turns: /api/chat logs the question and, when the loop ends, the
answer with the status and tool labels the reader watched, the page it was
asked from and whether it failed. Ids are random uuids the browser mints
per thread and per answer; no reader, no IP, no key.
- GET /api/chat/review-export: bearer CHAT_REVIEW_TOKEN (constant-time; 401
otherwise, 503 while unset), {product, scope, transcripts} in chatkit's
ChatTranscript shape — at most 50 conversations since `since`, 30 turns
each, 4,000 characters a turn, with their feedback. The scope is built
from the system prompt's role line and the tool registry, never typed
twice.
- scripts/db/015-chat-review.sql, .env.example, docs/INFRASTRUCTURE.md
"Chat review", test/chat-review.test.ts.
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
Co-authored-by: Claude <noreply@anthropic.com>
The discussion module mounts on every entity profile, and with it the
"Fact-check with Substrata" button, but /api/factcheck only resolved
/notes/ and /learn/ paths. On /science/high-na-euv (and every other
profile) the button answered 404 "No article at that path."
Resolve the page through the entity registry as well, in a small
factcheckSubject helper, and test it against every path the discussion
module mounts on.
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat(ask): suggested replies — one tap sends the likely next message
After an answer that asks something back, or whose next step is obvious,
two to four replies sit under the latest answer in the Ask panel, written by
the model in the reader's language; one tap sends it through the same
`chat.ask` the composer uses. From @bitbaum/chatkit 0.6 (bitbaum/chatkit#13).
- package.json / pnpm-lock.yaml: chatkit repinned 0.4.1 → 0.6.0 (163c879,
chatkit#13 merged). 0.5 and 0.6 are additive; nothing Ask uses changed.
- prompt.ts / loop.ts: REPLIES_INSTRUCTION appended only when the caller is
a conversation (`replies: true`, set by /api/chat) — the factcheck route's
runAgentToAnswer is never asked.
- parse.ts `finalAnswer`: extractReplies BEFORE tidyAnswer, on the final
answer, on a stream that broke mid-answer, and on a grounding revision, so
the block never reaches the stored answer, the history the next question
sends, or Copy. Replies travel as `done.data.replies`.
- ResearchChat: `onReply={ask}` on ChatThread, which also strips the block
from the streaming text while it is still being written.
Fixed on the way:
- A question under three characters ("No", "OK", "Ja") was dropped by the
panel without a word, and the composer then cleared it from the box.
`ask` now resolves false when it does not send, so the composer keeps the
draft; the floor is two characters, one constant (QUESTION_LENGTH) shared
by the panel and /api/chat; an over-long question says so instead of
failing at the server.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mg5wrkfw95JWfmAz8yRT1j
* docs(changelog): suggested replies in Ask (#167)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mg5wrkfw95JWfmAz8yRT1j
---------
Co-authored-by: Claude <noreply@anthropic.com>
Round five, asked across the site as a reader (2026-10-02). On /science,
/policy and /markets Ask said the corpus did not hold what the page it was
on showed. New tools over existing data:
- relief_technologies (readiness 1-9, what each would relieve, source);
- research_pipeline (collected papers/grants per bottleneck);
- policy_rules (status, effect, who asked for each, linked);
- recent_filings (SEC 8-K/6-K kind + link; says it holds no text);
- find_numbers (price/lead-time series by what they measure);
- resource_production measure=reserves.
Planner routes by wording and by the section the reader is on.
Two answers in the browser ended mid-word ('Listed: AS'): a turn that stops
at the output limit is now continued once; a figure-check revision that is
cut short is dropped for the original minus the unsupported sentences; free
output budget 1800 -> 2400.
'Update news now' on a bottleneck page also searches its research
databases (internet only, no AI, 6 h cooldown). The sweep stores pages
under their address without tracking parameters (Google's srsltid made one
blog post eight 'new' leads); stored duplicates collapse in the list.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Round four of grading Ask on real questions (2026-10-02):
- Asked about a Taiwan blockade, gpt-oss invented '~70% of capacity' and
'>80% of wafer output' and attributed them to records. grounding.ts now
compares every figure in an answer with the text of everything looked up;
figures from nowhere go back once, to be removed or marked 'Outside the
corpus'. Fired on 2 of 12 answers in testing.
- scenario_impact: the /scenarios engine as a tool (makers lost/left,
downstream, exposed companies with listings). Blockade / embargo / ban /
what-if questions are routed to it.
- 'Samsung' finds Samsung Foundry/Memory; 'neon and helium' reads both;
EUV/HBM acronyms count as distinctive words.
- Answers show the figures their rows carry, not bare name lists.
- question.ts (what a question names) split from plan.ts; runAgentToAnswer
to its own file (file ceilings).
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(ask): Ask is @bitbaum/chatkit, with a working microphone
The chat was hand-built: a Dictate button with no server leg (dead on
Firefox and on Chromium without Google speech), no Retry or Copy, a scroll
that jumped to the bottom on every token, Enter ignoring IME composition,
and a composer of mismatched controls. It is now the fleet's chat:
chatkit's ChatThread and Composer, with Substrata's parts in its slots —
evidence under each answer (records / unreviewed leads / web pages, never
merged), the model or own-key control, the starters.
- /api/transcribe: ai-kit 1.20 speechChain + looksLikeSilence (moved there
from Heidi so every app shares them); rate limited per address.
- Retry replaces the failed turn instead of repeating the question.
- Text files attach as before; a picture says it is not read yet.
- --ck-* mapped to Substrata's tokens in globals.css; ask.css 523 -> 225
lines (only the dock, page and Substrata's own parts remain).
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(ask): one model control, composer pinned in the dock, links models mistype
Seen on the new chat at 390px and in the dock:
- the model select (as wide as its longest model id) and 'Your AI key'
wrapped the composer onto three rows: one select now, its last choice
opens the key panel;
- in the dock the composer scrolled out of the panel under a long answer:
pinned, with the panel header sticky so Close stays in reach;
- Gemini closed links with ']' and gpt-oss wrote '[Title] (url)': both
repaired in tidyAnswer.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Measured on 12 real questions (2026-10-02): 3 'answered' with a raw
'TOOL: …' line, tools ran with empty arguments, and answers lacked data
the site has.
- Final round: a text tool call is run once and the model told to write;
TOOL/ARGS lines never reach the reader; a turn with no prose names the
records read instead of a blank.
- Tool arguments accept the names models use (id, slug, q, search…).
- ai-kit 1.19.1: Gemini's parallel tool calls stay separate (they were
glued into one call with unparseable arguments). Release-age exemption
for our own packages is by name, not version.
- get_bottleneck carries key_numbers (dated, sourced series: e.g. 128 weeks
transformer lead time) within its own budget.
- New tools: resource_production (USGS/EIA by country, synonyms like
palladium -> PGM series), open_roles (live job board).
- listed_exposure adds listed makers one step downstream (EUV -> TSMC,
Samsung, Intel) and names each ticker's exchange.
- Planner: jobs, resources and countries looked up before the model;
'machines' etc. no longer pick a bottleneck alone.
- Prompt: answer first; figures with unit/date/link; news leads with the
newest unreviewed leads; no relationships not in the results; absence is
not evidence; off-topic gets a one-line redirect.
- loop.ts failure handling moved to answer.ts (file ceiling).
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Five files typed the host themselves (BYOK referer, two user agents, a
diagram caption, metadataBase). They now read SITE.host / SITE.url, so the
move to substrata.ch is a one-line change. Guarded by one-site-host.test.ts
(mutation-checked). No behaviour change.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* 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>
- ai-kit ^1.17.0; /api/ai-key/models uses @bitbaum/ai-kit/byok-probe instead
of fetchCatalog, which said "works" for a dead OpenRouter key (its /models
is public; only /key refuses)
- PUT and PATCH probe the key again before sealing and reject a model the key
cannot use (lib/byok-check.ts); a dead key is never stored
- one admission rule, lib/byok-admit.ts, shared by the server and the
browser-only path, so "Use this key" stays off until a check passed
- panel: paste -> auto-check (600ms) -> select of the key's models with the
strongest preselected; free text only when the vendor lists none; the
vendor's refusal in its own words; Change model / Replace key / Remove
- tests: unchecked, refused and unlisted keys rejected; routes vet before
they write (each guard proven by mutation)
- docs: Ask moves to @bitbaum/chatkit once it is published
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A lead nobody decides on within LEAD_EXPIRY_DAYS (30) is expired: kept in
research_sweep_candidates, never deleted or rewritten, but out of the review
queue and its freshness age. The review queue is judged on OPEN leads only —
late past 7 days (a slow reviewer, reported), stale past 31 (only a broken
expiry or queue can get there, so it still 503s).
- lib/lead-expiry.ts: the constant, the pure leadState rule and the SQL
predicates it must agree with; method `lead-expiry` documents it
- /review, /data, /data/freshness count expired leads and link to the new
/data/freshness/expired list
- desk and company pages label an expired lead "expired, never reviewed";
the reader's leadMaxAgeDays window is unchanged; Ask says EXPIRED
- test/lead-expiry.test.ts: boundary, SQL/JS agreement, open-only queue and
freshness, expired retrievable + no DELETE; each mutation-proven
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* 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>
* feat(ai): drafting runs only on readers' own keys; ratchet against free-tier background AI
The hourly drafter spent the site's free models. Remove the free-chain path
(freeAsk, backgroundMay); drafting now takes an Ask built from a reader key
(lib/byok-ask.ts). /api/cron/drafts is gone; /api/cron/auto-updates drafts
only for readers who opted in, on their stored key, capped per day (013).
test/no-free-background-ai walks the import graph from every cron route and
fails on any path to the free chain; proven by mutation.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(updates): Update news now for every reader; AI summaries and auto-updates on the reader's own key
- Bottleneck, company and desk pages: "Update news now" sweeps the web
(no AI, signed out too, rate-limited, 15-min cooldown) and lists the leads.
- "Summarise with AI" drafts up to three on the reader's key (browser or
sealed); without one it explains the free AI is kept for questions and
opens the key panel.
- /account/settings#auto-updates: opt-in hourly drafting on the stored key,
daily cap with a token estimate (3.4k/draft, measured).
- Honest copy: /data/freshness reports drafting as on demand, /review, /data
AI spend, desk and docs say drafting runs only on readers' keys.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Background drafting no longer uses OpenRouter, whose ~50 free requests/day
are shared by every app on the box; it waits for Groq instead.
- Free-model Ask and fact-checks: 40 per visitor per day (own keys uncapped),
so one visitor cannot spend the shared pool.
- SEC filings: read EDGAR's latest 8-K/6-K feeds hourly and fetch only the
registrants in them, plus a rotating sixth, instead of all 51 every hour.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The timing log from #98/#99 showed one question 38 s to first text behind
OpenRouter links that never produced a token (nemotron-3-super: empty 200,
nemotron-3.5-lightning: hung to the 25 s link timeout). firstTokenMs bounds
the wait per link; the chain's last link is exempt, so a slow answer still
beats none.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Measured live 2026-09-25 on the three questions George's report named: first
text 9.0-33.0 s, done 18.7-34.4 s, all served by 10 s OpenRouter links.
- lib/chat-agent/plan.ts: lookups the page and the question's words make
obvious (listed_exposure, recent_leads, trace_dependencies, named records)
run locally in parallel before the first model call. When the plan found the
record AND the ask, the model gets no tools: one call. Page questions are
capped at two model calls; the web is never pre-fetched.
- listed_exposure tool + listing on get_company: tickers with the listed /
parent / private status in words (Hitachi Energy -> parent Hitachi 6501 JP).
- 【/path】 and similar training-format markers become markdown links.
- ai-kit 1.14.0: light reasoning on Groq gpt-oss, rolling-window cooldowns,
per-model daily refusals (bitbaum/ai-kit#71).
- research_ask_timing (012) + /data#ask-latency: p50/p90 over the last day,
no question text stored; journal line 'substrata ask-timing'.
- test/ask-plan.test.ts: the three measured questions take one model call; any
page question at most two, even against a model that always wants more.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- /for/{equities,commodities,industry,jobs,learning}: one view per reader,
composed from existing screens (X-ray, exposure, filings, series, events,
scenarios, science pipeline, careers, learning paths); homepage opens the
five doors straight under the hero; header gains a 'For you' group
- /data/freshness + /api/health/freshness: every feed's last good run, last
failure and cadence from research_*_runs, every committed dataset's checked
date against a declared maximum age, and the review queue; footer badge
- test/freshness.test.ts fails the build when a committed dataset is stale
- PageHeader shared by careers, exposure, freshness and the reader views
- Ask dock: key panel no longer pushes the conversation out at 390 px
- 'rails' -> 'bottlenecks' in desk, settings, X-ray and Ask copy
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* 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>
ai-kit 1.13.0 classBudget: drafting may spend <=25% of the day and never below
a 50% floor kept for Ask (env-tunable); spend recorded per class per UTC day
(research_ai_spend) and shown on /data#ai-budget with its method.
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* 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>
* feat(graph): sourced dependency layer, portfolio x-ray and scenario logic
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(xray,scenarios): portfolio x-ray and what-if pages over the sourced graph
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(scenarios): readable share URLs, output share on direct hits, contain table overflow on phones
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(ask): fast, any-AI via shared ai-kit BYOK, and one-click claim verification
- BYOK on @bitbaum/ai-kit/byok (1.12.0): ten OpenAI-shaped vendors incl.
Anthropic and Gemini, streamed with tools; drops @anthropic-ai/sdk and the
local byok-shared copy. Signed-in keys sealed server-side (ai-kit/seal,
SUBSTRATA_BYOK_SECRET, research_ai_keys); signed-out keys stay in the browser.
Model picker reads the vendor's live catalogue. Panel in Ask and /account/settings#ai.
- Speed: status before any lookup, parallel tool calls, 3-round cap, page-only
questions skip tools, free-chain link cooldown after 429s, parallel web reads,
trimmed history.
- Verify: Check this on every Figure, event rows, bottleneck facts, company lede.
Reads the cited source + searches the web in parallel before the model, answers
Supported/Contradicted/Outdated/Unverifiable with quoted passages and links.
- /api/factcheck now runs the same agent loop.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(ask): claim context for list values, computed figures check via their method, no web search for bare numbers
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* 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>
* 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>
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>
* feat(desk): make the desk controllable — filters, marks, rails, sweep settings
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(desk): reconcile with Ask — one railsOf, lead reads in sweep-queue
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(desk): whole-word rail matching; split review queue; size ratchet baseline
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(desk): trace every number to a constant; no 'analyst' wording; rebaseline sizes
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* feat(search): one grouped index with instant results, typo tolerance and highlights
- lib/search.ts: one index over every entity plus events, evidence
candidates and glossary terms; ranks name > aliases > body with
prefix matching and edit-distance correction for unknown words;
highlighted titles and snippets; per-type counts.
- /api/search for the header's instant results; header box becomes a
combobox (up/down, Enter, Esc, '/' to focus).
- /search: live as you type, grouped by type, clickable type filters.
- Events get anchors so a search hit can land on the event.
- test/search.test.ts: 21 query -> top-result pairs from the real corpus.
lib/research-index.ts and chat retrieval are unchanged.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* fix(search): rank half-typed words by their common completion; no URLs in snippets
A prefix is weighted as its commonest completion, so 'gallium ch' finds
China before Chalco. Source URLs are stripped from the search text, and a
hit whose name already matched shows its description, not a passage.
Keyboard hints only show where there is a keyboard.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Ask used to keyword-probe the corpus, hand the top rows to a small model in one
shot, and return the whole answer at the end. It did not know the reader, had
no way to look anything up, and returned nothing until the end.
Now it runs a tool loop on ai-kit's free chain (BYOK chains too):
- tools: search_corpus, get_bottleneck, get_company, get_record,
list_bottlenecks, list_events, recent_leads (research_sweep_candidates),
web_search. Every row comes back labelled with its evidence state
- context: the page's record, loaded in advance; the section for pages that
are not records; a signed-in reader's follows and rails
- streams text as it is written, reads both tool protocols, and keeps
TOOL:/ARGS: lines and <think> out of the stream
- when the budget is spent it says so and lists the records it read,
never a made-up answer
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>