Commit Graph
558 Commits
Author SHA1 Message Date
CatoandClaude Opus 5.5 d4926ef51f feat(statistics): one question per page — the figure, how it compares, where it comes from
A metric page was 14,890 px on a phone: the figure for the place asked for
appeared only as the last row of a data table, under a 187-row table and
~190 checkboxes, and every empty state and diagnostic panel was open.

Now the page leads with the place's figure (year, unit, rank, change since
the first year, and one link to the publisher's own number); then a short
ranking around the place beside the globe (Atlas via MetricMap, its table
removed); then the place year by year; then the sources. Scope, data checks,
an empty law or enforcement record and the AI explanation are behind one
closed "More about these figures". Every figure in the ranking opens the
publisher's page it was read from. 4,700 px on a phone.

- sanity: few_places counts the places the page ranks, not the one chosen
  ("Only 1 place(s) to compare" on a page that ranks 187).
- one place picker; several places and years behind a disclosure.
- a place asked for with no figure says so instead of silently showing all.
- one decimal count per page, so a column reads evenly.
- map caption no longer reads "Rule of Law, :" for a unitless measure.
- index rows open the measure on the place chosen there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 12:52:56 +01:00
CatoandClaude Opus 5.5 3003d81379 feat(globe): one globe, one level per tap, one colour scale with its legend (#607)
* feat(globe): one globe, one level per tap, one colour scale with its legend

The home page, /places, /places/tax and every statistic now draw the same
globe (`Atlas`, configured by `mode` and `layer`), not two renderers with
their own colours.

Drill-down: what is drawn and what a tap can reach follow the place chosen,
never the zoom (`drill.ts`). World -> country -> its first-level places
(Wyoming whole, beside the other states) -> the places Solon draws there
(Wyoming's counties) -> a county's towns. A tap reaches only a child of the
place open; Back goes up one level. Opening the United States used to draw
Wyoming's counties directly, so the tap after "Wyoming" chose a county.

The map data now carries the levels between a country and its drawn places
(`above`), the pack's ISO 3166-2 places (`regions`, so Texas opens its page),
and how much law Solon holds at each place (`law`, from counts.ts).

Colour: one scale from the design tokens, read out by a legend under the
globe on every page: acts of law in force, 1-9 to 10,000 and more, and
"none yet", which is now the colour such places are painted.

Phone: the canvas takes `touch-action: pan-y` so a vertical swipe scrolls the
page; town dots answer within 22px (a 44px target), nearest first; Back,
the place's page and the legend sit outside the canvas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(ci): give tests 30 s on the merge check's shared, low-priority runners

Three CPU-heavy unit tests overran Vitest's 5 s default when the laptop ran
two forge-ops jobs at nice 15 and failed solon#607's merge check on code that
passes everywhere else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 11:35:03 +01:00
CatoandClaude Opus 5.5 fa6d46541f feat(statistics): one place across every measure, by theme — not 34 full rankings (#606)
* test(law): build each authority's chain once in the counts check

The check rebuilt every authority's chain once per pair (quadratic); it took
5–11 s and timed out under load, failing unrelated changes' verify. Same
assertion, chains computed up front: 0.18 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>

* feat(statistics): one place across every measure, by theme — not 34 full rankings

/statistics was ~82 desktop / 134 phone screens: 34 ranked lists of every
country (2,923 rows), no way to find a place, the calculator mid-page.

- Pick a place (default Switzerland, ?place=): one row per measure with its
  latest figure, year and where it stands in words ("Higher than 23% of the
  186 other places", or highest/lowest), grouped into six themes.
- Themes in config (lib/config/statistics/themes.ts); a test keeps every
  statistic in exactly one theme and every theme named in all five languages.
- The full ranking of every place stays one click away on each measure's page.
- The weighting calculator is folded until opened (opens itself when a link
  carries weights). Now ~9 phone / ~5 desktop screens.

Co-Authored-By: Claude Opus 5.5 <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 <noreply@anthropic.com>
2026-11-20 01:30:33 +01:00
CatoandClaude Opus 5.5 6ce6ff7832 feat(places): keep place photographs in R2, not Postgres (#605)
place_photo_bytes held 4,234 Wikimedia Commons thumbnails (1.7 GB of a 4.3 GB
database), copied into every nightly backup until the off-site store filled
(2026-11-16). Photographs are files: they belong in object storage.

- photo-keep-r2.ts: an S3/R2 keep, and a layered keep (R2 first; a photograph
  found only in Postgres is copied to R2 on first read; new ones go to R2).
- The place-photo and og routes use placePhotoKeep(): R2 when the four
  PHOTOS_S3_* settings exist, Postgres exactly as before otherwise.
- scripts/places-photos-to-r2.ts (places:photos:to-r2): one-off resumable copy.
- Same S3 client as evig (@aws-sdk/client-s3).

Expand first: the table stays until R2 is verified serving; dropping it is a
later change (a drop in the same deploy blocks later deploys).

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-20 00:30:03 +01:00
CatoandClaude Opus 5.5 f6e6be7c61 chore(ci): one check per change — remove the merge sweep, check on PRs only (#604)
Removes the fleet auto-merge sweep caller (and wake chain where present);
checks run on pull requests only, not again after merging; a deploy that
waited for CI on main now deploys on push. The forge merge check
(forge/verify) verifies each PR on its merge result and merges it.

Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 22:06:11 +01:00
CatoandClaude Opus 5.5 fdca9eb964 fix(deps): next 16.4.6 — known vulnerabilities (#603)
Signed-off-by: Cato <41178744+catomean@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 21:24:22 +01:00
Catoandfleet-reconciler b4f4034f6d chore(deps): raise shared package floors to published versions (#601)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-19 15:11:06 +01:00
CatoandClaude Opus 5.5 c6d4a7d6f1 Give one-line prose fields the microphone; chatkit 0.45.0 (#599)
* Give one-line prose fields the microphone (TextBox multiline={false})

Proposal title, amendment title and heading, organization name, place
fields and founder name, and the statistics question now use TextBox, so
each has chatkit's dictation like the longer text boxes.

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

* Bump @bitbaum/chatkit to ^0.45.0; the door's question gets the microphone

chatkit 0.45.0 lets DictationField be uncontrolled (name + defaultValue),
so the plain GET form on What you can do uses TextBox multiline={false}
and still posts its title without client state. TextBox already passes
every DictationField prop through, so it needs no change.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-15 20:52:05 +01:00
Catoandfleet-reconciler 4541eb2cec chore(deps): raise shared package floors to published versions (#600)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 19:33:49 +01:00
Catoandfleet-reconciler 9808c64b87 chore(deps): raise shared package floors to published versions (#598)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 18:22:45 +01:00
Catoandfleet-reconciler c6d285d524 chore(deps): raise shared package floors to published versions (#597)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 17:23:38 +01:00
Catoandfleet-reconciler da450387fc chore(deps): raise shared package floors to published versions (#596)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 16:32:49 +01:00
Catoandfleet-reconciler fd6ac823fe chore(deps): raise shared package floors to published versions (#595)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 15:05:42 +01:00
Catoandfleet-reconciler 68c239abc8 chore(deps): raise shared package floors to published versions (#594)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 13:57:15 +01:00
Catoandfleet-reconciler 813f6b2913 chore(deps): raise shared package floors to published versions (#593)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 12:44:10 +01:00
Catoandfleet-reconciler 3ddefaeae1 chore(deps): raise shared package floors to published versions (#592)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 12:02:58 +01:00
Catoandfleet-reconciler 6518bf447d chore(deps): raise shared package floors to published versions (#591)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 04:02:52 +01:00
Catoandfleet-reconciler d01a51be02 chore(deps): raise shared package floors to published versions (#590)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 02:31:56 +01:00
Catoandfleet-reconciler df971d5705 chore(deps): raise shared package floors to published versions (#589)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-15 02:03:14 +01:00
Catoandfleet-reconciler c83d104b44 chore(deps): raise shared package floors to published versions (#588)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-14 19:36:31 +01:00
Catoandfleet-reconciler 253178e824 chore(deps): raise shared package floors to published versions (#587)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-14 13:26:09 +01:00
CatoandClaude Opus 5.5 063d3f9fba fix(law): a page is translated when its reader asks (#586)
* fix(law): a page is translated when its reader asks

The translation loader asked on every view of a law page whose language was
not cached yet, so anything that ran the page's script spent the free AI day
every app on the server shares. On 14 Nov every labelled Solon call was law
translation. The page now offers "Translate this page"; a tap is a person.
What one reader had translated is stored for the next.

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

* test(person-seat): each seat joins after the last, so 'first to join' is decided

joined_at is stored to the millisecond; two seats inserted in a row could
share it, the tie fell to the random member id, and the backfill clash test
expected A before B one run in a few (CI on #586). The helper now gives each
seat a distinct, increasing join time.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-14 13:21:56 +01:00
Catoandfleet-reconciler 76dffe6c9d chore(deps): raise shared package floors to published versions (#584)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-14 11:45:23 +01:00
CatoandClaude a16a3931e6 feat(ai): every model call says what it is for (#585)
Each ai-kit call names its feature (governance-chat, law-ask, law-translate,
statistics-research, statistics-explain, dictation), so the server's usage log
can say what Solon spent the shared free pool on. On 14 Nov Groq's whole free
day was used by Solon before 09:10 UTC and the log could not say for what. A
test keeps a new call from arriving without a label.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-14 11:36:05 +01:00
Catoandfleet-reconciler a55a59e7ea chore(deps): raise shared package floors to published versions (#398)
Opened by bitbaum/fleet .github/workflows/internal-currency.yml.

The fleet's own packages ship features in MINORS, so
version-currency.mjs — which judges by major — reports nothing while
consumers drift. This is the instrument that sees it, and it opens
the fix rather than reporting it.

If this PR is red, that is the useful outcome: it names a repo that
cannot take the new version, which nothing else in the fleet would
have told us.

Co-authored-by: fleet-reconciler <fleet@bitbaum.invalid>
2026-11-14 11:04:51 +01:00
CatoandClaude 71383bbaf4 Blog: post on OrangeCat in one tap, share anywhere (#524)
* feat(blog): post any blog post on OrangeCat in one tap

Each post is served as bip-kit's cross-post JSON at /api/blog/<slug>
(prerendered with the site, links made absolute), and the post page ends
with "Post on OrangeCat", which opens OrangeCat's article composer filled in
with Solon's project named. Whoever taps it posts on their own wall; the owner
of Solon's OrangeCat project gets Solon's wall preselected too.

bip-kit 0.7.0 is consumed from its verified Git release (v0.7.0): its npm
publish failed with ENEEDAUTH because the npm trusted-publisher link for
@bitbaum/bip-kit is not configured.

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

* fix(deps): bip-kit v0.7.1, which builds from its Git release in CI

v0.7.0 failed to build when pnpm 11 prepared it inside CI's store
(TS2883 on inferred component types); 0.7.1 declares every component's
return type. Reproduced with a store under a node_modules path: v0.7.0
fails, v0.7.1 installs and builds.

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

* feat(blog): a shared post previews as itself

Post pages inherited the layout's Open Graph block, so a link shared on X,
LinkedIn or WhatsApp previewed as "Solon". Each post now carries its own
title, summary, canonical URL, author and date (type article).

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

* feat(blog): share a post anywhere, OrangeCat first

The post page ends with bip-kit's ShareRow: "Post on OrangeCat" (the
cross-post, the one primary action), Copy link, the device share sheet where
there is one, then X, LinkedIn, Bluesky, Hacker News, WhatsApp, Telegram and
email, in one line that scrolls sideways. bip-kit v0.8.0 from its Git release.

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

* fix(deps): bip-kit v0.8.1, the share button's label readable on Solon's transparent page

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

* fix(deps): bip-kit 0.8.1 from npm, now that trusted publishing works

Drops the Git-release install and its build allowance.

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

* fix(deps): bip-kit 0.9.1 (components build under React 18 too, so the canary can take it)

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 20:41:31 +01:00
CatoandClaude 02917956cb test(rate-limit): ask well after the back-off, not at its last millisecond (#583)
The limiter backs off 30 s from when the shared store FAILED, so the
back-off ends 30 s plus however long the failure took. The test asked at
exactly +30 000 ms and failed whenever the rejection took a millisecond:
twice in CI on 2026-11-13, the second time on main, which blocked the
deploy of #582.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 14:20:50 +01:00
CatoandClaude d4fa30e017 fix(law): a spent free pool is asked once per page view, then not at all for ten minutes; nothing is translated for a crawler (#582)
A law page in a language Solon does not hold yet asks the server to
translate it as soon as it is opened, by anyone and by any crawler that
runs the page's script. With the free pools spent, every batch of every
page still walked every model: the fleet usage log showed 29 answered and
1,783 failed calls from Solon in ninety minutes on 2026-11-13, against the
pool every app on the server shares (it is why the Cat could not answer).

- translateMissing stops at the first batch nobody answers and reports it
  (onUnanswered); a batch whose answer fails its checks still only skips
  that batch.
- /api/law/translate pauses ten minutes after that, answering 503 without
  asking a model, and answers 204 to a crawler's page view.

Tests: translate-guards (pause, crawler names, a person's browser passes);
translate.integration gains 'stops at the first batch nobody answers'.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 14:02:11 +01:00
CatoandClaude 08fa1bc8a7 ops(keys): share-model-keys no longer copies GEMINI_API_KEY to the box (#581)
The key was retired on the box on 2026-11-13 (loki fleet-env.sh retire):
it sat on a billed Google project and cost about $567 on 10-11 Nov. This
workflow could have written it back into this app's env.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 12:02:38 +01:00
CatoandClaude Fable 5.2 0af51df8f9 chore(deps): @bitbaum/ai-kit 1.26.0: Google out of the free AI chain (#579)
* chore(deps): @bitbaum/ai-kit 1.26.0: Google out of the free AI chain

ai-kit <=1.25 put Google's Gemini API in the free model chain on the
fleet-wide GEMINI_API_KEY, which sits on a billed Google project.
1.26 builds no Google link (freeChain = Groq, then OpenRouter :free),
keeps paid AI off unless an app opts in, and adds daily caps.

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

* chore(deps): @bitbaum/ai-kit 1.27.0, the version kivvi canaries now

Kivvi moved to 1.27.0 (the fleet usage log), so the rollout gate no longer
passes 1.26.0. Same spend rules; adds one line per model call under
AI_USAGE_DIR when the box sets it.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-13 11:02:39 +01:00
CatoandClaude 7fc0b7e731 Rate limit: limitkit decides, the windows live in Postgres (#569)
* Rate limit: limitkit decides, the windows live in Postgres

The assistants' limiter was a per-process Map: every deploy gave everyone a
fresh allowance and each instance counted on its own. The decision is now
@bitbaum/limitkit's sliding window, and the windows are held in
rate_limit_windows (migration 0035, additive), one transaction per decision,
serialized per key.

- Seven routes take their bucket from one table of numbers (unchanged).
- Retry-After and the RateLimit headers come from the window, not a constant.
- The address is the hop the proxy wrote (limitkit clientIp), not the first
  X-Forwarded-For entry, which the caller chooses.
- Stored keys are keyed digests; no address or account id is held.
- Without a database, or while it is unreachable, the same rule runs from
  memory and the store is retried after 30 seconds.

Replaces #563, whose migration number collided with 0034_member_person_tag.

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

* Rate limit: refusals never reach the database; the limiter has its own pool

Review of this change found that every check, refused or not, ran a
transaction on the app's only pool and waited on the advisory lock while
holding a connection: a flood from one address made unrelated queries wait
seconds. And a database that hangs never fell back to memory.

- A refusal is remembered per process until its window opens (other
  instances can only add hits, so it cannot open earlier), and writes
  nothing when it is decided by the database.
- Decisions for one key run one at a time per process, so a burst from one
  caller takes one connection, not all of them.
- The limiter has its own pool (3 connections, 1 s to get one), lock and
  statement timeouts, and a 1.5 s deadline per decision; past it, memory
  decides. The 30 s back-off is measured from the failure.
- Memory shadows this process's allowed requests, so a fallback continues
  the count instead of starting a fresh one.
- No session secret, no shared store: the keys would be plain digests of
  addresses. The digest input is domain-separated.
- The sweep compares on the database's clock, the one that wrote touched_at.
- The warning log carries an error code, never the query or its parameters.

Measured on Postgres 16: 3000 concurrent requests from one refused caller
allow none, and an unrelated query on another pool answers in 4 ms (it
waited 2.5-6.8 s before).

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 18:34:07 +01:00
Cato cb9fcd3f51 fix(law): every page prints a country's own law count, from counts.ts (#578)
/places printed Liechtenstein as 3,748 laws and its place page as 3,412
laws in force. Both were read from the same coverage query; they counted
different things. 3,412 is the national acts in force whose text Solon
holds; 3,748 is those plus the 336 of the eleven communes. The atlas list,
the globe tooltip and the /places/world tiles printed the total with a
bare "laws", while the place page and the Law page print the national
count and list the communes below it.

- counts.ts gains heldOf(coverage): what a count counts, said once. The
  globe, the place page and loadLawCounts all build from it.
- globe.ts no longer sums a country's authorities itself; it reads
  rollUp from counts.ts (the test still checks it against that old sum).
- The atlas list row, the map tooltip and the world tiles print `own`,
  the figure the place page prints. The shade still covers everything
  within. A country holding only communal law says so ("Regions and
  communes: N") instead of "Places only".
2026-11-12 10:24:43 +01:00
CatoandClaude Opus 5.5 5f27700b14 feat(places): a new country pack takes its country over from the world pack; generated data refreshed monthly (#577)
* fix(law): a recut keeps the mark of a text read by OCR

The weekly recut wrote every cantonal version it examined back with the plain
importer version, so a text read from a scan by OCR (`…+ocr`) lost the mark
that says how it was read, and an older version so marked was examined again
at the head of every run. Any version carrying this reader's version with a
mark (+archive, +ocr, or both) is now current, and a version brought up to
date keeps every mark it had.

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

* feat(places): a pack of its own takes a country over from the world pack

Adding a pack is how a country gets places in depth, and the path had never
run: a new pack's root resolved to the world pack's row, which kept its pack
and path; the new pack's places hung under world/...; and a world file still
stating the country would set the root's level back and give it a parent.

- A pack may `yield` (the world pack does): it holds a place only until a
  pack of the place's own names it.
- Then the place moves: same row (its figures and records stay), new pack and
  path, the new path canonical in place_paths and the old one redirecting, and
  the parents other sources stated for it superseded.
- What the world pack held under a moved place that the batch does not restate
  ends that day; restated later, it moves and is current again.
- A batch of a yielding pack leaves alone a place another pack holds and every
  place it states under one, so a world file not yet regenerated, the
  countries' or the subdivisions', cannot take a country back.
- An integration test adds Quuxland, a made-up country the world pack holds
  first, and checks all of it, rerun-safe on one database.

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

* feat(data): one command refreshes every generated dataset, and a monthly workflow opens the PR

The world's profiles, its countries, every country's subdivisions, the world
list's photographs and the law plan were refreshed only when someone ran three
to five commands on a laptop, in an order nobody wrote down; all were last
read on 2026-11-10.

- `pnpm run data:refresh [--only a,b] [--list]` (scripts/data-refresh.ts)
  runs the generators in the order they build on each other. One that fails
  keeps its old files and is reported; the rest still run. A new generator is
  one entry.
- .github/workflows/data-refresh.yml runs it on the 4th of each month (or on
  dispatch, for some), and opens a pull request when anything changed, as
  bitbaum/substrata's recheck-data.yml does; the sweep merges it on green CI
  and the deploy's places-data job imports it.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 09:27:44 +01:00
CatoandClaude Opus 5.5 266a4d5b68 perf: the World Bank fetched from a runner; statistics in one query; imports and deploys skip what did not change (#576)
* perf(places): place pages kept for an hour; the run log indexed and bounded; a place's country by its ISO code

- A place's country (its profile, budget, photograph and share card) is its
  own ISO 3166-1 code, else its pack's root, else a world nation's slug, never
  the last slug segment: the Djibouti Region (world/djibouti/djibouti), the
  City of San Marino and the US state of Georgia showed a country's page.
- /places/[...slug] is ISR for an hour with nothing built ahead, instead of
  force-dynamic: its queries run about once an hour per place and language.
- place_import_runs gets indexes on (source_key, started_at) and (status,
  finished_at); sourceRuns is one DISTINCT ON query, read once per call and
  passed to the worker.
- Runs a stopped process left `running` are closed as failed after two worker
  budgets, so they are reported once and backed off.
- The worker starts on a day with nothing due as well, for the daily rebuild
  of the ancestors view.
- verify runs places:world-countries --check, now comparing the countries the
  file holds rather than CLDR's names; geography:world writes its registry as
  Prettier formats it. The engineering audit's claim that both were checked is
  corrected.

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

* feat(places): a source a publisher refuses to the box is fetched daily from a runner

The World Bank's API answers the box HTTP 403 (2026-11-10), and its source is
the only one for eight statistics in about 210 countries: none had ever loaded
in production, and the box's queue failed it and alerted every cycle.

- A source may say `fetchFrom: "runner"`. The box's worker leaves it out of
  its queue; `pnpm run places:queue --from runner` drains it, with the same
  cadence, retries and run log.
- places-load-cloud.yml runs that daily (and on dispatch with kind=queue),
  through its SSH tunnel to the production database, copying the snapshots
  back to the box as it already did for hand-dispatched loads.
- The World Bank's source is the one runner source; a test fails if another
  side gets it.

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

* refactor(statistics): a governance indicator is five lines; shared scopes and sentence()

- statistic-templates.ts holds sentence() (moved from the budgets' metrics),
  the scope of general government at every level and the scope of a
  perception score, and wgiMetric({ key, code, name }).
- The six Worldwide Governance Indicators are written with wgiMetric: 204
  lines become 66, and the generated metrics were checked identical to the
  hand-written ones, word for word in every language.
- Government consumption and tax revenue share one scope sentence instead of
  two copies.

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

* perf(statistics): every statistic in one query; a new statistic adds no queries

- loadSeriesFor(db, config, keys, locale, { latestOnly }) reads any number of
  metrics in one facts query and names their places once. latestOnly keeps
  each place's latest value within the metric's plausible band, as a chart's
  screening leaves it.
- /statistics: 4 queries instead of 136 (34 statistics x loadSeries +
  placeLabels); 104-131 ms instead of 325-548 ms on a database holding the
  live OECD, Eurostat and World Bank figures. Checked identical to the old
  per-metric query for all 34 statistics (2,403 series), and latest-only
  identical to the screened full series.
- The dimension, event, compare and saved-view pages load their metrics in
  one call each.
- placeLabels groups names and codes once instead of filtering every row per
  place, and builds one Intl.DisplayNames for the list.
- facts gets a partial index on (metric_key, jurisdiction_id, valid_from DESC)
  for current, unvaried figures.

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

* perf(ci): a deploy that touched no Places data clones, installs and reads nothing

places-data.yml ran after every deploy: a full clone and pnpm install on the
memory-tight box, a runner install, and 798 image requests through the live
site, though most deploys change no Places data and no photograph.

- A first job diffs the deployed commit against the one this workflow last
  loaded successfully (a failed load is retried by the next deploy; a
  dispatch, perhaps a dry run, does not count). The import runs when Places
  data, its config, adapters or importer changed; the photo warm-up when
  photos.json or the photo code changed. A dispatch runs both.
- The box fetches the deployed commit at depth 1 instead of cloning the
  repository's history.

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

* perf(places): an old /places/<slug> link is redirected after a two-query lookup

It ran the full place-page load (about 17 queries) only to learn whether the
world pack holds the place. Links no longer point there (#572); the redirect
stays for old ones.

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

* perf(law): a register import reads only its own register, and stops when nothing changed

About 34 register imports run every week. Each made one query per law
authority (311, one after another) and read every current act, title, number
and page in the law database, however small its register; and
missingFromSource counted every act sharing the identity scheme, so it was
wrong for every publisher_ref register.

- A retrieval whose acts, as read, are those the register last applied is
  recorded as applied and `unchanged` and goes no further. The recorded
  importer version carries a hash of the rows read, so the same bytes read by
  a changed reader are applied again.
- The authorities the retrieval names are resolved to places in one query.
- Known acts are read for the identities the retrieval lists, a thousand at
  a time, with their titles, numbers and pages for those acts only.
- missingFromSource counts only the identities this register itself stated.

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

* fix(law): the weekly sync waits for a heavy load; verify reads a sample, a second apart

- law-sync.yml took /tmp/solon-law-load.lock while a heavy load dispatched by
  hand (law-text.yml) takes /tmp/solon-law-load-heavy.lock, so the two never
  excluded each other, the pairing that ran the box out of memory on
  2026-11-08. The sync now takes the heavy lock, and after two hours' wait
  leaves that week's sync be, saying so.
- `law:text verify` read its sample size from --limit, which the workflow
  passes every source (1,500 by default): a dispatch read 1,500 publisher
  pages back to back. It reads --sample (30 by default) and pauses a second
  between reads.

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

* fix(law): an act held in two languages is listed once, titled in the reader's language

recentChanges joined every current title to every current version, so an act
held in German and French appeared up to four times in a place's recent
changes (with repeated React keys), and a constitution's title on the
profile card came out in whichever language the database returned first.

- actTitleSql (src/lib/law/act-title.ts): an act's current title in the
  reader's language, else its first other language, as one value.
- recentChanges takes the reader's language and keeps one row an act, its
  latest current version; the profile's constitution lookup uses the same
  title rule.
- An integration test holds one act in two languages.

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

* refactor(generators): one polite Wikidata client; scratch scripts removed

world-profiles, places-photos and law-plan each carried their own SPARQL
helper: world-profiles retried any error four times (a 400 included), law-plan
did not retry at all, and each sent its own user agent. They use the shared
client (src/lib/wikidata/query.ts), which waits as long as the server asks on
a 429 or 503 and fails at once on anything else. law-plan now checks that
Constitute's index answered before reading it. scripts/_ws.ts and _ws2.ts,
committed scratch files, are deleted.

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

* refactor(statistics): one rule a unit, so a statistic in a new unit is a line in units.ts

What a unit means was decided in six places: the chart scale (present.ts),
the label (shared.ts), the brief's value text and points (brief.ts), the
profile figure's format (place-figures.tsx), the axis panel's percent sign
and the divisor a published percentage is stored with (sources.ts). A
statistic in a count or a currency would have been shown with no unit, or
scaled wrong, in some of them.

src/lib/config/places/units.ts holds, per unit, its scale and decimals,
whether publishers print it in per cent, whether it is a percentage, and the
key of its words under Statistics.units; every site reads it. A test fails
when a unit's words are missing in a language. Nothing shown changes.

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

* perf(law): a place's page counts its own authorities' acts, not the whole register's

loadPlaceLaw ran loadLawCoverage, three aggregates over every act and version
in the law database, to show the counts of a handful of authorities: the
place's chain and the parts of its nearest. loadLawCoverage takes an optional
list of authorities and counts only theirs; a place's page passes the ones it
shows. Checked against a database of 9,119 acts in 14 authorities: the counts
of all 132 shown authorities are the same as before. The pages that show the
whole register still count it all.

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

* fix: findings of an adversarial review of this stack

- Place pages are rendered on every visit again: ISR made Next keep every
  rendered URL on the server's disk (a few thousand places in five languages,
  and any made-up path besides, with no bound), and kept a not-found path as
  not found for an hour. A view's cost is cut where it is spent instead.
- A failed source retried by a once-a-day queue (the runner's) waited a full
  24 hours from the failed run's start, so the next day's run, starting a few
  minutes earlier, missed it: retries allow two hours' slack.
- Abandoned runs are closed after eight hours, longer than any import runs
  from the box or a runner (a workflow job stops at six), instead of after
  two worker budgets.
- One concurrency group for every cloud load, so the daily queue and a fetch
  dispatched by hand never write the same source at once.
- The saved-axis page scores, as the index does, on each place's latest
  plausible value; loadSeriesFor dedupes its keys.
- places-data runs the import weekly whatever changed, for a file applied
  while some of its places were not held (`+partial`) or one whose import
  failed.
- An unchanged register import still reports what the register no longer
  lists.
- The shared Wikidata client retries 500, 502 and 504 too, as world-profiles
  did; a bad query still fails at once.
- The weekly law sync waits 45 minutes for the heavy lock, not two hours.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 09:11:31 +01:00
CatoandClaude Opus 5.5 a7ae061a79 perf(places): one national-statistics source per publisher, for every country; figures credited to whoever published them (#575)
* perf(places): one national-statistics source per publisher, for every country it covers

The OECD's and Eurostat's series were one source a country (68 sources, 310
requests a cycle) and the pack countries had World Bank sources of their own.
Each publisher is now one source that asks for every country at once: SDMX's
+-joined reference areas, JSON-stat's repeated geo. 17 requests instead of 350.

- A metric names its reader (series.read, and database for a World Bank series
  outside the WDI); a publisher's source is generated from the metrics that name
  it, so a new statistic is its metric and nothing else. Retired metrics are no
  longer read.
- A pack's sources are computed from the sources that name the pack; a written
  list that differs is a configuration error.
- formerKeys keep what was read under a source's old key credited to it:
  findSource resolves them for a page's sources, coverage and budgets.
- A figure is credited to its metric's series where that reader read it, else
  to the source that supplied it.
- A batch of figures alone leaves out, and reports once per place, figures for
  a place not held here.

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

* fix(places): left-out country figures are read again; one line per publisher; gaps reported

From an adversarial review of the previous commit:

- A retrieval that left out figures for a country not held here was recorded
  as applied, so the same bytes were skipped as unchanged and the figures
  never arrived. It is now recorded with a +partial importer version and read
  again on the next run. Only a country is left out; any other unknown place
  (a mistyped commune number in a hand-kept table) still fails the run.
- An unchanged figure keeps the key it was first read under, so a place or a
  budget could list the same publisher twice. Both now merge by the source a
  key resolves to, dated by its latest reading.
- Sources of many countries reported no gaps at all. They now report one line
  a series: the countries asked for that it holds no value for (adapters/gaps.ts).
- Tests that passed for the wrong reason now fail on the defect they name: a
  real two-country Eurostat cube, coverage with the current key read last, a
  former key resolving to a publisher other than the series'.
- Stale docs: the Eurostat fetch command, where OECD_MEMBERS and
  EUROSTAT_GOV_COUNTRIES live, the World Bank's request count.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 08:58:20 +01:00
CatoandClaude Opus 5.5 b261787c2d fix(person-seat): decide on fresh person tags; one key is one seat in every encoding (#574)
* fix(membership): one key cannot hold a second seat under its uncompressed address

verifyMessage named only the addresses of the serialization the header
chose. The header's compression flag is not signed, so the holder of a key
seated under its compressed address could lower the header by 4 and claim
the uncompressed P2PKH address with the same r||s. keyAddresses now always
holds every standard address of the recovered point: P2PKH of the
uncompressed key, and P2PKH, P2WPKH and P2SH-P2WPKH of the compressed key.
Validity stays tied to the claimed address and the header.

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

* fix(person-seat): decide on fresh person tags; a stored tag is only a cache

After an OrangeCat identity is handed over its tag changes, so the tag
Solon stored at admission was wrong both ways: the former holder was
refused (and the operator told the two were once linked), and the new
holder could take a second seat.

- personTagsFor asks OrangeCat for many accounts in one request (chunked
  at 100); personTagFor uses it.
- No OrangeCat client configured is now "could not ask", not "cannot be
  told apart", so add-member refuses instead of seating unchecked and the
  backfill exits 1.
- seatHeldByPerson asks for the candidate and every non-retired human seat
  at once, decides on those answers only, and rewrites stored tags that
  changed (null for one OrangeCat now leaves out). planPersonTags never
  writes one tag to two seats; a clash between existing seats is reported
  instead of thrown, and add-member prints it.
- backfill-person-tags asks once per organization per 100 seats, has a
  --refresh mode, and its dry run finds clashes between untagged seats.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 08:37:28 +01:00
CatoandClaude 7e54703945 Places: a cited override can correct any fact the profile card takes from Wikidata (#573)
Overrides covered only languages and currencies. Capital, population,
area, government, head of state and of government, founding date and
website came from Wikidata with no way for a sourced correction to replace
them. Every one of them can now be overridden, for any place, in the
same table and the same shape as Wikidata's data; the card prints the
citation beside the value as it already did for languages.

- FactOverride is typed per fact; overrideProblem holds each row to its
  fact's form (codes, names with English, a positive count and year, an
  https source) and the table's test runs it on every row.
- applyOverrides is one generic function; loadWorldProfile takes the
  table as an argument so a test can hand in made-up rows.
- No data changes: the one row (South Ossetia's languages, its
  constitution, Art. 4) is unchanged. No place is named in code.

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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 08:16:21 +01:00
CatoandClaude a4c2b1d202 Places: world list, index, atlas, comparison and contest links go to the page, not a redirect (#572)
Checked on production after #560: the /places index linked the pack summary
by its key (/places/united_states, /places/south_ossetia: 308), and every
country no pack holds was linked as /places/<slug>, which answers 307 to
/places/world/<slug> (the world list, the atlas, the claimant on a contested
place's comparison: /places/georgia). The comparison table linked columns by
slug_path.

- regionHref (place-href.ts) applies the place page's own rule: a pack's
  root; else the world pack's place for an ISO country; else the entry's own
  page for a claimed place or one the world pack does not hold.
- The index uses packHref; comparison columns carry their canonical path.
- A test fails when any file other than place-href.ts and the redirects
  themselves writes a /places/ path from a variable.

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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 07:56:53 +01:00
CatoandClaude 53d8edc79d perf(places): an import skips what it already applied; the ancestors view is rebuilt only when a place moved (#571)
- A retrieval whose bytes the source last applied, read by the same importer,
  is recorded as an applied run marked unchanged and goes no further. The
  importer version now carries a hash of the source's options and packs
  (applied.ts, importerVersion), so a changed option reads the same bytes
  again; the repo-file importer uses the same string.
- Adapters say how retrievals compare: independentRetrievals (World Bank,
  OECD, Eurostat: one part each) against their own address; any other
  against the source's latest reading, so an earlier edition re-applies;
  publishesFiles (boundaries) always read again. The snapshot is kept either
  way.
- place_ancestors is rebuilt only when places or part_of relations changed
  (a non-concurrent refresh locks it against page reads), and once a day by
  the queue worker for relations whose validity starts or ends later.
- Facts are compared only for the metrics a batch states, and superseded and
  inserted a thousand rows a statement instead of one.

Measured locally on a fresh database: an unchanged file now takes about a
second (process start); the 4,759 subdivisions import in 7 s (was 10).


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 07:29:47 +01:00
CatoandClaude 3cb4b06b80 feat(places): the places inside every country, from Wikidata's ISO 3166-2 codes (#570)
- scripts/places-world-subdivisions.ts writes data/places/world/subdivisions.json:
  every item with an ISO 3166-2 code (P300, statement neither ended nor
  deprecated, item not dissolved) in every country no pack holds, named in
  five languages, with its item number. 4,759 places in 194 countries.
- Each sits under its nearest coded ancestor by P131+ (a department in its
  region), else under its country (src/lib/places/nesting.ts, pure, tested):
  two equally near ancestors that do not lie in each other (Brcko District)
  mean the place lies in both, so it sits under what they share. The world
  pack gains three tiers below a country.
- Neutral by the world list's rule: an item that is itself a world entry, and
  the codes in SUBDIVISIONS_WITH_OWN_PAGE (Taiwan, Abkhazia, Transnistria,
  Kosovo), keep their own pages and are not listed inside a claimant.
- The world-subdivisions source imports it after the deploy, like every file
  under data/places. Ten seconds locally.
- The importer inserts identifiers, names, relations and instruments a
  thousand rows a statement: five thousand places passed Postgres's 65,535
  parameters in one.
- One Wikidata helper (src/lib/wikidata/query.ts) for scripts.
- A banner photo fills a tile at full width, not enlarged from 960 into a
  blur; a place's line no longer names the world.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 07:16:16 +01:00
CatoandClaude b0c29d6bac fix(places): the scheduled import is a queue; the World Bank is asked for all countries at once (#568)
The figures on country pages had loaded for four countries. Two causes:

- The cron route did all its work inside the request, and the box's timer
  stops its curl at 300 s. It now starts one worker per process that drains
  the queue of sources the run log says are behind (importQueue: latest run
  not applied on or after the last day the cadence names) and answers at
  once. A source never loaded loads whatever its day; a failed one is tried
  again a day later, a week later after three in a row; a fetch that fails
  before any import is recorded as a failed run. The route answers 500 when
  a run failed since the last call. Replaces firstLoads.
- The World Bank's indicators were one source a country: 235 sources, ten
  requests each, all due on the 9th. The adapter now also reads many
  countries in one request (country/all), and the world pack has one source,
  worldbank-wdi-world: ten requests. Pack countries keep theirs.

Also: a request that gets no answer is retried twice (the World Bank's API
hung for two minutes and answered the same request in half a second); a
profile's figures are ranked in one query instead of one per figure.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 07:04:31 +01:00
CatoandClaude 5f2b669363 fix(propose): a visitor who arrives with a suggestion sees that it is kept (#567)
OrangeCat's 'Govern it with Solon' sends a signed-out visitor to /propose
with the suggestion in the link. The draft survives sign-in and joining, but
the gate showed only 'Only members can make a suggestion' and two buttons
(seen on a phone, 2026-11-12): nothing said their words were kept, so the
page read as having forgotten what they came for.

The gate now shows the suggestion's title and says the form opens with it
filled in once they are a member.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 06:51:17 +01:00
CatoandClaude 1b5e007b23 feat(membership): one person, one human seat per organization (#565)
A person on OrangeCat can hold several identities, each its own account
with its own actor id. A seat goes to an account, so one person could hold
several seats in the same organization, one per identity.

Solon now asks OrangeCat for a person tag per account (orangecat ADR-0014
D7): two accounts carry the same tag exactly when one person holds both.
The tag is keyed per client and per scope, and Solon's scope is the
organization, so it says nothing about who the person is or about their
seats elsewhere.

- members.person_tag, and a unique index on (organization, person_tag) for
  human seats that are not retired. A suspended seat still counts: a
  suspension is not dodged by being seated under another identity.
- seatHeldByPerson is what an admission asks before giving a seat. Three
  answers: may be seated (with the tag to store), already seated (naming
  the seat), or OrangeCat could not be asked, which is not a 'no' and not
  a licence to seat either.
- The founding seat and an organization's founder are tagged as created.
  No clash is possible there (nobody else is on the human roster), so the
  seat never waits on another service; a missed tag is picked up by
  scripts/backfill-person-tags.ts.
- scripts/add-member.ts checks before seating an --oc-actor, and refuses
  when it cannot ask unless --skip-person-check is passed.
- 0034 also carries a snapshot correction: 0033 added
  legal_provisions.heading_path by hand without recording it.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 06:39:10 +01:00
CatoandClaude 6f009b424f Tests: verify measures coverage and holds a floor (#564)
verify ran the unit tests without measuring them. It now runs
test:coverage (v8, every file under src counted), prints the summary, and
fails below a floor set just under today's figures (statements 46.8,
branches 37.6, functions 42.7, lines 46.8). pnpm run test stays the
unmeasured quick loop. The three places that describe verify say what it
runs, check:cycles included.

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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 05:58:25 +01:00
CatoandClaude 8a48a45cf0 law text (gesetze.li): hold every heading, footnote-marked word and table cell the page prints (#559)
Found by running the order-aware verify offline on 27 acts; each cause is generic:
- footnote marks inside an annex, a heading or a one-block page glued digits to words
- a title above a single article (sacht before art), a title line under a numbered heading
  (tit1ue) and a run of headings with no text between them were not held
- an annex's headings are listed above each annex, not once per page (II. printed twice)
- table cells with bare text were joined into one word (blockText)

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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-12 05:14:35 +01:00
CatoandClaude Fable 5.2 6289d3a19b fix(membership): one Bitcoin key is one seat, under any of its addresses (#562)
* fix(membership): one Bitcoin key is one seat, under any of its addresses

verifyMessage accepts a claimed address when it matches any standard
derivation of the recovered key (P2PKH, P2WPKH, P2SH-P2WPKH), and the
founding-seat check compared the claimed address string. A key already
seated under one form could take a second seat in the same organization
under another: an agent's service key seated as 1..., then claimed again
as bc1q... by a human founder.

verifyMessage now reports every address the recovered key answers to,
and registerMember refuses when any of them holds a seat. No schema
change: existing members are stored by address only, and the public key
cannot be derived from an address, so the comparison stays on addresses.

The integration test seats a key under the legacy form and claims the
other two; it fails on the previous check.

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

* docs(changelog): one Fixed list per day

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 23:52:47 +01:00
Cato dc7d4bb6ec law text: order-aware verify for PDF acts; keep the text before a PDF act's first article (#561)
- verify reads PDF versions too (any authority): the text layer is read again, cut the way the
  reader cuts it (repeated header/footer lines, page numbers, split words), and compared in
  order. A scanned PDF is reported as not compared. A short title block at the start is
  reported as such, never as word for word.
- parseCantonalProvisions keeps what comes before the first article when it is more than a
  title (enacting formula, legal basis), not only when the first heading is a later number.

Claude-Session: https://claude.ai/code/session_019MDtmt65Ai8jku68kDmxUU
2026-11-11 22:26:56 +01:00
Cato 8de220c324 Places: every internal place link is built from the canonical path, so no click answers 308 (#560)
Breadcrumbs, child lists, the atlas, search, the map and the places API built
URLs from jurisdictions.slug_path; for a pack root written with underscores
each click redirected once. The loaders now carry the canonical path from
place_paths (canonicalPathSql), and placeHref/packHref in place-href.ts build
every link from it. Tests: a pure one with divergent paths, and an
integration one that resolves every rendered link through findPlace.

Claude-Session: https://claude.ai/code/session_019MDtmsegw9dJ7eykLcT7Fe
2026-11-11 22:22:22 +01:00
Cato 933d8a7f78 law text: chapter headings held on the provisions under them; verify compares in order (#558)
- Provision.headingPath (jsonb heading_path, migration 0033, additive): tit1/tit2/tit3 of a
  gesetze.li page are attached to the articles under them, shown above the first one, and
  counted by law:text verify. A heading is still not a provision.
- verify: a gazette masthead table is page furniture (FURNITURE_TABLES), footnote marks and
  inline tags (CO<sub>2</sub>) are read as the reader reads them.
- verify: a sequence score (Myers diff over words) and the longest missing run next to the
  bag score; an act is word-for-word only when every page word is held in the page's order.

Fixtures: Kundmachung 2022308000, AIFMV and Waffengesetz excerpts.

Claude-Session: https://claude.ai/code/session_019MDtmt65Ai8jku68kDmxUU
2026-11-11 20:22:37 +01:00
Cato 3a849cc8aa Places: a cited override beats Wikidata for any place's languages or currencies (#557)
FACT_OVERRIDES (src/lib/config/world/overrides.ts) is a table of place, fact,
value and citation; applyOverrides takes it ahead of Wikidata in
loadWorldProfile and the profile card prints the citation beside the fact. No
place is named in code. First row: South Ossetia's official languages are
Ossetian and Russian (Constitution, Art. 4), not Wikidata's Georgian, Russian.

Claude-Session: https://claude.ai/code/session_019MDtmsegw9dJ7eykLcT7Fe
2026-11-11 20:18:03 +01:00