18 Commits
Author SHA1 Message Date
CatoandClaude bf1f73e259 feat(auth): account mail on, so the sign-in link and recovery appear (#322)
Substrata created its account runtime with `mail: { configured: false }`, so
the sign-in link, "Forgot your password?" and address confirmation could
never appear, and a forgotten password had no way back.

- lib/auth.ts sends account mail through AccountKit's `createAuthMailer`
  (mail-kit, the fleet's RESEND_API_KEY). Without a key the options stay
  hidden, as before; confirming an address is never a wall.
- The sign-in, sign-up and account pages pass `mailConfigured()` to
  `signInMethods`, and a reset link that lands on /sign-in is no longer
  redirected away for a signed-in reader.
- The account journey first asserts every way in the env switches on:
  password and passkey always, the link only with mail, "Continue with
  OrangeCat" and the shared sign-in button with their clients. CI sets
  synthetic, unreachable OIDC clients so both buttons are checked.
- @bitbaum/mail-kit is a direct dependency (AccountKit's optional peer).


Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-01 23:21:22 +01:00
CatoandClaude 9ca43d25db ci(accounts): a browser journey proves an account can be made and used (#301)
A new `account` job in browser-smoke.yml runs scripts/ux/account-journey.mjs
in Chromium against the production build and a PostgreSQL built from
scripts/db/*.sql: sign up with email and password (mail is off, so the
account signs in at once), see the account menu, sign out, have a wrong
password refused, sign back in, and a foreign origin gets 403.

The fleet's shared journey assumes account mail, which Substrata does not
send, so this drives Substrata's own screens.

lib/auth.ts now also trusts AUTH_URL as an origin, so the journey passes
with better-auth's origin check on (NODE_ENV=test and TEST stay unset). On
the box, lib/request-guards.ts already reads AUTH_URL as the public origin.


Claude-Session: https://claude.ai/code/session_019MDtmuJhiHPASaR5k8raL9

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-30 11:13:53 +01:00
CatoandClaude Opus 5.5 6e5bbf3483 feat(markets): a company page that reads like a markets product (#259)
* feat(markets): a company page that reads like a markets product

The owner, 2026-10-25: "I don't see any beautiful charts on stock
performance … think Bloomberg, think Yahoo Finance", and on NVIDIA's
holders, "'other' is 87%. We have a vague idea of what that means."

Every company page now carries one market frame, in one order, whatever
the company is (docs/design/company-page.md): a header quote (ticker,
exchange, currency, last close, 1-day change, date, "delayed end-of-day ·
Yahoo Finance"), then share price, key statistics, revenue and net income
by year, who owns it, how it does business, and peers. A section with no
data stays and says what source would fill it, with a Send-evidence link.

- Share price: a line chart with one row of six equal range cells
  (1M·3M·6M·YTD·1Y·5Y), the page's only client island. Every range is
  computed on the server, along with its return, span and largest fall,
  the 52-week range, a returns table and the 50/200-day averages
  (prices/compute.ts).
- Key statistics: eight equal cells. Market value is computed only where
  close × cover shares is the value; otherwise "Not computed" with the
  reason. Each annual figure shows its fiscal year, growth and filing.
- Financials: chartkit's new ColumnChart (0.2.0) for five fiscal years
  from XBRL, plus rows with growth and margin computed in code.
- Who owns it: holders from 13G/13D/proxy. The remainder is labelled
  "Others, each below 5%" in the legend (chartkit's new ShareBars
  otherLabel) and explained in its row. A company with no listing shows
  the owners the relation graph states.
- How it does business: customers, suppliers, competitors (always), and
  stakes, sites and partners from lib/graph, one row anatomy. An empty
  group names the filings that would fill it, and points to the quoted
  dependency rows where they exist.
- Peers: the same chain step (tier A) or the same theme (tier B), with
  last close, 1Y return and a sparkline.

Tier B companies get prices, financials and holders: lib/market-data/company.ts
joins a slug to a listing. It tries the seed first, then the universe
ticker on a venue the price source serves. New venues (US composite,
London, Hong Kong, Korea, Taiwan, Toronto, SIX) are added to Yahoo's
suffixes. Ambiguous venue codes are not guessed. Sections stream in their
own Suspense boundaries, with reads deduplicated per request, so a slow
price source never delays the header. Ask charts link "Open <Company>" to
the page, and the holders bar in answers carries the remainder label.

Verified: pnpm run verify; pnpm run build; test/company-page.test.ts;
scripts/ux/company-layout.mjs at 320/390/768/1440 on NVIDIA, Oklo,
SpaceX, NAC Kazatomprom and a stub, against live Yahoo and SEC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

* docs(design): the header's quote lives in price-view.ts

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-27 13:43:25 +01:00
CatoandClaude ac8056fd77 refactor(ask): chatkit ChatApp for the panel and /chat (#262)
The Ask panel and /chat were Substrata's own assembly of chatkit's pieces
(ChatScreen, Composer, ChatThread) with no chat list, no New chat and no
reload. They are now chatkit 0.18's ChatApp, the same app Heidi, Loki and
OrangeCat move onto: Chats drawer (a rail on a wide screen) with search,
rename and delete, New chat, temporary chat, titles, the queue, Stop and
the open chat reopened on reload. Chats are kept on the reader's device
(localConversationStore); no server conversations, no migration.

Substrata keeps only its own parts: the transport (askTransport: /api/chat
with pictures, the stream into turn.update, the evidence on the message,
the server's own words on a failed turn), chartkit renderers, AnswerFooter,
the key and "Send evidence" under the composer, one composer configuration
shared with the home box. Panel and /chat share the store and the open
chat, so Expand is only a bigger frame (lib/ask-thread.ts goes). A message
from elsewhere (Check this, ?q=, the home box's ?send= with its pictures)
opens a new chat and is sent through the composer, since ChatApp has no
send handle yet (lib/chat/drive-composer.ts says so).


Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-27 12:35:27 +01:00
CatoandClaude 0dc40c2530 feat(ask): attach screenshots, read them, check their claims (#260)
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>
2026-10-27 10:36:52 +01:00
Cato 2507e3bc59 fix(ci): install app browser smoke dependency (#252) 2026-10-26 04:11:20 +01:00
CatoandClaude 30c7137d60 feat(ask): research mode for analytical and forward-looking questions (#248)
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>
2026-10-25 12:59:15 +01:00
CatoandClaude e7959fb3d9 feat(ask): tables not walls, reviewed entity aliases, and the graph as chat tools (#222)
Asked live on 2026-10-24 which companies mine uranium in Kazakhstan and who
owns them, the Ask answered correctly from the USGS 2023 yearbook but pasted
the cell as one paragraph of sixteen ventures and one of sixteen places; the
graph split Kazatomprom in two; and no tool read the graph at all.

- Tables: producers_in builds an answer table in code from its rows
  (operator | owners as printed | commodity | location | capacity | year),
  one row per venture of a "Companies:" cell, every cell verbatim; a place
  list or capacity printed once for many rows is a shared note, never
  divided. registry.ts routes a result's `table` to the answer, not the
  model; the model is told not to paste. Drawn under the prose
  (AnswerTables): a table where wide, cards where narrow (container query),
  eight rows then "Show all", long places folded.
- Entity aliases: config/entity-aliases.ts holds reviewed pairs only
  (NAC Kazatomp JSC, UraniumOne Inc., Glencore), each with the rows that
  justify it; lib/graph/alias-match.ts proposes by named rules and
  `pnpm run research:alias-candidates` prints proposals with evidence.
  research/usgs-relations.json regenerated.
- related_to and how_connected over lib/graph: rows with share, grade,
  counted flag, source quote (the venture's part of a long cell, verbatim)
  and reading kind; leads listed apart and never counted. Planned first for
  who owns / shareholders / holds stakes / partners / how connected; the
  ladder counts related_to owners as covering the owners link.
- Six no-wall evals (Inkai, Kazatomprom, Cameco, Sumitomo, Collahuasi,
  Gazprom) with graded verbatim quotes; check:ask-layout draws the table at
  320/390/1440.


Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-24 08:29:39 +02:00
CatoandClaude a59f0634b6 fix(chat): the widget is the edge tab on /chat, not hidden (#218)
Hidden made the owner's widget fall back to a bar across the top of the page,
a different widget from the one on every other page. The edge tab keeps the
same live-status handle everywhere, and still stays off the reply row. The
Ask layout check models the tab and passes.


Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-24 07:42:51 +02:00
CatoandClaude 9d54efe06d fix(ask): units copied as the table gives them, one composer on panel and /chat, the widget steps aside (#215)
Live on 2026-10-23, asked who produces gallium, the answer said Russia
made "6 kt". USGS reports 6,000 kg (6 t), so that was a thousandfold
overstatement.

- resource_production rows carry `display`, the quantity exactly as the
  table prints it ("6,000 kg (estimated)"), and no second spelling. The
  "(= 6 t)" reading added on 2026-10-02 is gone: it was the "6" the model
  re-unitted. Series rows (find_numbers, key_numbers) carry `display` too.
- Prompt honesty rule: copy a quantity's `display` verbatim; never
  convert or abbreviate a unit, never rebuild one from value_number.
- grounding.ts unitMismatches: an answer quantity whose digits match a
  row's in another unit of the same family ("6 kt" vs "6,000 kg") is
  flagged and handled exactly like an unsupported figure (sent back once,
  else its sentence is dropped). The unit test uses the live answer.
- One composer on the panel and on /chat: no "Ask a question" kicker, no
  paperclip on either. /api/chat takes a question of at most 4,000
  characters and no files; an attachment was pasted text that a long file
  pushed into a refusal.
- The Loki launcher steps aside while the Ask sheet is open and on /chat
  via the widget's host directive data-fc-place="hidden" on the rendered
  region. Not Loki.hide()/show(): those write the visitor's own stored
  "hide on this site" and would overwrite it.
- check:ask-layout: nothing but the sheet's UI over the reply row, the
  launcher back on close and absent on /chat, and /chat's composer has
  the panel's controls and no kicker.
- @bitbaum/chatkit ^0.15.1: a heading written over the reply row is not
  drawn ("Quick follow-up options").


Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-23 13:43:18 +02:00
CatoandClaude 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>
2026-10-23 13:03:36 +02:00
CatoandClaude 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>
2026-10-23 13:00:25 +02:00
CatoandClaude Fable 5.1 d096d9ee59 feat(markets): company profiles — at a glance, ownership, charts, section menu (#208)
* wip: company profiles — at a glance, ownership, charts, section menu

* feat(markets): company profiles — at a glance, ownership, charts, section menu

Opening ASML, GE Vernova or Sibelco now reads in one order on every
company: header with five StatTiles at a glance (bottlenecks held, hardest
binding, directory grade, listing, events) → what it holds, each row the
front page's board-row with a chartkit Meter linking to the assessment →
ownership and investors (new config/substrata-ownership.ts, 25 companies,
every holder with the document and as-of date it was read from; a share
nobody read off a document is null and reads as a lead; ShareBars for the
sourced ones) → numbers it reports (series filed under the company, as
LineCharts and sparkline rows) → what has happened (events that name it,
events on what it holds and its SEC filings on one Timeline, then the lists)
→ unread leads (three, then "All n") → what could loosen its grip → ways to
take part → hiring → others at the same step → what it connects to →
sources → discussion. The section menu is the existing SectionNav (a
strip under the top bar on a phone, a rail from 1280px), built from the
headings. Charts are @bitbaum/chartkit's; the page keeps only its placement.

Ask gets an `ownership` tool ("who owns X"), with the same rows.

Gates: test/ownership.test.ts (sources, as-of dates, sums ≤ 100, status
agrees with the listing record, the tool answers for listed / private /
unknown), module order in test/profile.test.ts, and
scripts/ux/profile-layout.mjs (`check:profile-layout`): three companies at
320/390/1440 light and dark — no sideways scroll, every target 44px, five
tiles of one shape, meters in one x, the menu lists only real sections, no
word cut mid-letter.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-23 11:23:48 +02:00
CatoandClaude 78405cda00 chore(chatkit): 0.14.2 — the home layout check runs chatkit's broken-word audit (#207)
The inline Range check in scripts/ux/home-layout.mjs was a copy of
findBrokenWords, written while 0.14.2 was unpublished. The export is now
the one check every product runs, so the copy goes.


Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-23 11:04:32 +02:00
CatoandClaude Sonnet 5.5 408d9d77f1 feat(home): the homepage, rebuilt ask-first (#204)
* 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>
2026-10-22 23:02:26 +02:00
CatoandClaude Opus 5.5 3453927d1b chore(ux): production measurements after #119 — 20/20 task runs, 0 dead ends (#121)
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 01:16:18 -07:00
CatoandClaude Opus 5.5 77a2b95d2f fix(tools): 44px breadcrumb and reader-tab targets; careers sidebar above Ask; X-ray keeps an early paste; after-deploy measurements (#119)
- The render sweep, run over the tool pages, flagged 14px breadcrumb links
  (15 hand-written copies, now class "crumbs" with inline padding: 44px
  target, same line), 40px reader tabs, and the careers sidebar ending under
  the Ask button at 1440.
- A list pasted into the X-ray before hydration sat in the box with the
  button grey; the client now adopts it on mount (found by scripts/ux).
- scripts/ux/reports/after.* and compare.md: 11/20 -> 20/20 task runs
  passing against production, dead ends 6 -> 1 (the early-paste case above).

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 01:01:28 -07:00
CatoandClaude Opus 5.5 f1c5a7a654 feat(tools): task-flow criteria + measurement; answer first, one header, one empty state (#117)
* chore(ux): task flows with step and time budgets; production baseline

Ten top tasks across five audiences, each with a success criterion, a step
budget (clicks, keystrokes, choices and screens of scrolling) and a
time-to-first-answer budget, driven at 390 and 1440. Plus a dead-end check:
every empty or error state must offer the next action.

Baseline against production: 9 of 20 task runs pass; 3 of 5 empty/error
states are dead ends.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat(tools): answer first, one header, one empty state, no dead ends

Measured by scripts/ux (baseline in the previous commit), then fixed worst first:

- X-ray: names the biggest single-source risk, the country most weight rests
  on alone, and the most-shared bottleneck first (lib/xray/headline.ts,
  ranking only); scrolls the answer into view; Ctrl/Cmd+Enter runs; a list
  nobody could read offers the sample instead of a blank report; shared
  PageHeader; privacy note folded to one line; placeholder no longer looks
  like a filled portfolio.
- Scenarios: result first, picker folded under it; presets before the form;
  a Copy link button instead of a printed URL; an unreadable ?at says so.
- Careers: regions (Europe, North America, …) in the place filter, so
  "process engineers in Europe" is one choice, not thirty; results before
  the hiring sidebar on a phone.
- Data series: shared PageHeader and filter bar (auto-applies), search reads
  the bottleneck name, 40 rows then Show more (all 145 made a 1 MB page).
- Science pipeline: PageHeader with the counts in one line; jump links to
  what the feeds collected.
- Bottleneck pages: a signed-out reader sees Follow (sign in, come back)
  instead of nothing.
- Update news now: Try again on failure; a next step when nothing is new.
- Shared: Empty takes an action (desk, exposure, careers, series, pipeline,
  x-ray, reader views); a real not-found page with ways on; filter bars show
  one loading state; CopyLink; desk settings use PageHeader.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 00:40:42 -07:00