Commit Graph
128 Commits
Author SHA1 Message Date
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 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
Cato 33c95f90d5 Gaps: a place is an ISO code or a Wikidata item, resolved through the shared place model (#554)
* Gaps: a proposal on a topic and on a coverage line, and a registry of responsible offices checked by statistics:verify

A proposal is Solon's own statement of what collecting a measure would take, signed as such. An office is an institution's own channel (a page, a general e-mail or telephone, a postal address), never a person; each e-mail or telephone must be among the words its cited page is expected to hold, and statistics:verify reads the page again. A coverage line names its office, which must belong to the same place. Statistics Denmark is the first office, read from its contact page; the crime-by-background topic carries a proposal drawn from its own purposes, cautions and companions.

* Gaps: a place is an ISO code or a Wikidata item, resolved through the shared place model; South Ossetia's office and first line

The gap place reference took only iso_3166_1 and the pages read place.value as an ISO code. It now takes the shared place id (ISO 3166-1, else Wikidata), and a country pack with no ISO region carries its own nation id, so a place is named from its pack, never special-cased. South Ossetia's Statistics Office and its crime-by-background line (offender table by sex, age and occupation only, per the 2025 compendium) are the first rows.
2026-11-11 18:18:18 +01:00
Cato 9b874277fe Gaps: a proposal on a topic and on a coverage line, and a registry of responsible offices checked by statistics:verify (#549)
A proposal is Solon's own statement of what collecting a measure would take, signed as such. An office is an institution's own channel (a page, a general e-mail or telephone, a postal address), never a person; each e-mail or telephone must be among the words its cited page is expected to hold, and statistics:verify reads the page again. A coverage line names its office, which must belong to the same place. Statistics Denmark is the first office, read from its contact page; the crime-by-background topic carries a proposal drawn from its own purposes, cautions and companions.
2026-11-11 17:58:32 +01:00
Cato 61ac1968eb Atlas: a chosen place is framed by its own outline (geo-kit createFocus); parent drawn faintly; Open <place> (#548)
The atlas flew to the bounds of whatever was drawn inside a country (the
Wyoming bug). The choice is now geo-kit's createFocus: the camera frames the
place's own outline, never a child's; the place it is part of is drawn
faintly; the card offers 'Open <place>'. The country's coarse outline stays
as land under its places (no gap west of Liechtenstein) and place names that
would overlap are left for a closer zoom, as in draft #492.

Claude-Session: https://claude.ai/code/session_019MDtmsegw9dJ7eykLcT7Fe
2026-11-11 17:50:12 +01:00
CatoandClaude 4913a47792 feat(places): what a place is like, measured; how its law is changed; what changed (#533)
- Measured: the figures a reader acts on, chosen in config
  (PROFILE_FIGURES) and shown only where the place has a value: what the
  state takes and spends (OECD, else the World Bank's government
  consumption under its own label), four World Bank governance indicators,
  homicides. Each with its latest value and year, its position among the
  countries reporting that year (left out below 20; the ends said as
  highest and lowest), a 15-year sparkline and its source; chartkit's
  Meter and Sparkline.
- How its law is changed: the official routes of every authority from the
  place up, the same card an act's page shows.
- What changed lately: acts that took effect in the past year by the
  publisher's own date, newest first, with the count.
- The glance no longer repeats the routes; the law card says "below it",
  not "communes", for every place under a country; Russian sentences no
  longer put a place's name after a preposition undeclined.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-11 08:00:24 +01:00
CatoandClaude bb6fbffa2c feat(places): one page shape for every place, photographs for every subdivision, served by Solon (#532)
- The page: a hero with where the place sits, its kind, name, status line,
  headline facts and one main action (its constitution, else its law); below,
  the law and what a resident can do beside the place at a glance, which no
  longer repeats the hero. The same shape with or without a photograph.
- The places inside a place are photo tiles, the world index's tile, when most
  have a photograph. The world index opens on the Earth from Apollo 17 and is
  grouped by kind of place.
- Photographs for 9,296 places: places:photos --all reads every ISO 3166-2
  subdivision, Swiss commune, US state and county Wikidata holds; a Swiss
  canton's FSO number reaches its ISO code through a config crosswalk. Iran,
  Tanzania, Appenzell Ausserrhoden and Jura chosen by hand.
- Solon serves the photographs itself (/api/place-photo, place_photo_bytes):
  each Commons thumbnail read once, politely, kept across deploys. About one in
  sixteen tiles came up black when the image optimiser hit Wikimedia's limits.
  The places-data workflow reads the world list's photographs after a deploy.
- /credits pages through the place photographs.
- Fixed: the chat's "Thought for {time}" label threw a formatting error in
  every language.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 21:55:46 +01:00
CatoandClaude 8c27ece452 feat(places): every place opens on its photograph, and shares with it (#531)
- places:photos finds any place on Wikidata by its world entry or by an
  identifier whose scheme names a Wikidata property (ISO 3166-1/-2, FSO
  municipality, US FIPS), and chooses one free photograph from Commons:
  the original of its Wikivoyage banner, its image, aerial or night view,
  else a panorama as a strip. A person can replace any choice in one line.
- A full-screen hero on country, territory and subdivision pages: name,
  kind, capital, population, area, and the photo's author and licence.
- A share card for every place (/api/og/place) with its photograph.
- /credits lists every place photograph; the world index is a wall of
  photographs.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 21:12:42 +01:00
CatoandClaude 09b0a02928 feat(world,law): every place's profile, places beyond the UN on the map, more constitutions (#530)
- Kinds of place, by what each does (src/lib/config/world/kinds.ts): UN
  member (un.org's list, with admission), observer, self-governing, territory,
  proclaimed (one stated rule: Wikidata micronation, not dissolved, at least
  30 Wikipedias: Sealand, Liberland, Molossia, ...), special jurisdiction
  (Próspera), project (seasteading). They join the world list with pages,
  law authorities (keyed by slug) and places in the law plan.
- `pnpm run world:profiles` writes every place's facts from Wikidata (CC0)
  and the UN's list: data/world/profiles.json for pages, a small extras.json
  for the map. Area: the preferred figure, else the smallest (Taiwan's
  governed area, not its claim).
- A profile card on every country, territory, self-governing and proclaimed
  place page: its kind in a neutral sentence, capital, population, area,
  languages, currency, government, heads of state and government, UN
  admission or founding, website, the way into its constitution and law,
  and where the facts come from. Wikidata descriptions only for special
  jurisdictions and projects (they can judge: "Scheinstaat").
- The map: "All places" or "Beyond the UN", shading and dots, and a list by
  kind under the switch.
- Constitutions: the owner decided a law's text is never held back for want
  of a recorded copyright provision (LicenseRef-official-law; the country's
  own provision is cited where recorded). The copy reader follows indexes of
  editions (only from a short page, only to the same document), reads a
  constitution split into subpages whole, reads Markdown, cuts more article
  forms (Art. 1º, Article premier, Roman numerals, § only without articles,
  第一条, المادة/الفصل), and stops at a second printing. Liberland's
  constitution from its own repository.
- docs/design/2026-11-world-of-jurisdictions.md; roadmap, changelog.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 20:41:45 +01:00
CatoandClaude 68759b9847 feat(law): a plan for every country's law, and Russia's and Ukraine's constitutions (#529)
- A law authority for every country of the world list: listed ones keep
  their key; any other is its alpha-2 code, or alpha-3 where a canton holds
  the two letters (fra, geo, bel).
- The plan as data (data/law/plan.json, src/lib/law/plan): per country,
  the constitution in force by Constitute's index, candidate copies from
  Wikidata, the source chosen by an unambiguous rule or by a person with a
  reason, the provision of its own law that puts official texts outside
  copyright, the national readers. `pnpm run law:plan seed` re-reads the
  sources and keeps every person's decision; `pnpm run law:plan status`
  counts progress from the database and derives each country's next step.
- One reader for any country's constitution (law:text plan-constitutions):
  a Wikisource page through the REST API or any document copy (PDF/HTML),
  cut into articles for many languages, stored as status `copy` with who
  keeps it and the day read. Refused: no copyright basis recorded, too few
  articles, or a copy naming no year since the last recorded amendment. A
  copy attaches to the constitution a register already lists; a country
  whose constitution is held from its publisher is left alone. Waits as
  long as a 429 asks.
- Russia's Constitution (ru.wikisource, as amended in 2020: 137 articles
  and the five inserted) and Ukraine's (the Constitutional Court's copy,
  with the 2016 and 2019 amendments; uk.wikisource's was refused as older),
  with their routes: Russia Art. 134-136; Ukraine Art. 93, 154-157 and the
  people's referendum (Art. 72, 74). Licences: Russia Civil Code Art.
  1259(6), Ukraine Law No. 2811-IX Art. 8(1)(3).
- The act page says whose copy a text is. Law sync runs Russia's register
  and the plan's constitutions weekly.
- statistics sync test writes the metric it names, instead of relying on
  another file having done so first.
- docs/design/2026-11-law-of-every-country.md; roadmap, changelog.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 20:11:43 +01:00
CatoandClaude Opus 5.5 2829402aa0 feat(law,amend,contested): propose in Russian, Russia's register and routes, a pseudonym per proposal (#528)
* feat(contested,amend): a South Ossetian reader can propose a change in Russian

- Amend pages (write a change, support it, the official route) translated
  into Russian, French and Italian; AMEND_LOCALES now holds every language.
- "Propose terms" on a contested place led to the primary organization's
  form ("you are not a member of OrangeCat"). It now opens each side's law
  to pick the article, where amendments are filed and supported.
- The claimant's quotes, published only in English, read in the reader's
  language from the config catalog; their labels too. The coverage test
  holds them to every language.
- Roadmap: a scenario side (as a subject of the Russian Federation), "my
  life under each", Georgia's budget.

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

* feat(law,amend): Russia's register, its official routes, and a pseudonym per proposal

- Pseudonyms: a signed-in person is named in the public amendment record by
  anon:<HMAC(key, proposal, account)>, never actor:<id>, so their proposals
  cannot be linked to each other or to them. Rows written earlier keep their
  name and are recognised as the same person. The filing rate limit moves
  into the process, so no lasting list of who filed is kept to count it.
  SOLON_PSEUDONYM_SECRET (falls back to the session secret).
- Russia: one reader over the official publication portal's JSON API
  (PRAVO_GOV_RU), one entry per authority: federal Constitution, laws on its
  amendment, federal constitutional and federal laws (8,012 acts), and North
  Ossetia–Alania's constitutional laws and laws (1,095). The portal's
  robots.txt disallows /File, where the scanned texts are, so the register
  only. Laws are not objects of copyright (Civil Code Art. 1259(6)).
- Routes: federal bills (Constitution Art. 104, citizens hold no initiative)
  and the Russian Public Initiative, federal and regional bars, each from the
  page opened; in Russian. An act page shows its official routes whether or
  not Solon holds its text.
- Authorities may carry their own names per language (North Ossetia–Alania).
- docs/research/2026-11-russia-sources.md; roadmap and changelog.

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

* test(law): count only this file's acts in the South Ossetian dry-run check

Another integration file registers the Parliament's acts at the same time,
so counting every parliamentrso act raced it (CI: expected 8 to be 5).

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-10 19:34:05 +01:00
CatoandClaude Opus 5.5 d3cd864ca5 feat(i18n,money): every page in the reader's language and one currency (#527)
* feat: one currency and one language for the reader; codes read from their Word files

Money: every amount on the budget and comparison pages is in the currency
the reader picks (?in=, CHF by default), converted at the budget year's
average rate, and the page says from what and whose rate. Rates are data
(data/money/rates.json, pnpm run money:rates): Eurostat's annual euro rates
for 151 currencies and, for the rouble after 2021, the Bank of Russia's
official rate averaged over the year. src/lib/money imports nothing from
Solon, ready to become the fleet's package. Eurostat budgets are now also
read in million euro beside the shares of GDP (generated from the same
taxonomies); a budget knows its GDP, so both show.

Language: a law in another language reads in the reader's, as a machine
translation labelled as one with the authentic text a click away. The
translations are a cache keyed by the sha256 of the words (text_translations,
migration 0030), each answer checked before it is kept (one per passage,
every number kept, no passage ballooned); titles in lists use it too, and
pnpm run law:translate fills titles ahead of readers. Places are named in
the reader's language when the data has the name (Tskhinval, not город
Цхинвал), their own names still listed.

Texts: a South Ossetian code printed as a page linking Word files is read
from the file worded as its text (never the contents file), with
word-extractor; --stubs reads again the acts held only as such a page.

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

* feat(i18n,money): every page in the reader's language and one currency

- Money defaults to US dollars; the reader's choice is remembered site-wide
  in a cookie (/api/preferences/currency) and used by budgets, contested
  places and the structures comparison, which now adds the reader's
  equivalent beside an amount quoted in its own currency.
- Configured words (statistics scales, tax forms, budget lines and their
  COFOG/ESA labels, source attributions, publishers) get their other
  languages from one catalog, data/i18n/config.json, keyed by the English.
  localized() and cite() read it; a test fails while any text a translated
  page shows lacks a language; pnpm run i18n:config reports gaps.
- Citations rewritten in English instead of mixed Russian/English; source
  lists show the localized attribution; budget document captions read in
  the reader's language with the original quoted below.
- The voting method lab and South Ossetia's legislative route translated.

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-10 17:28:03 +01:00
CatoandClaude a25b15a4a5 feat: one currency and one language for the reader; codes read from their Word files (#526)
Money: every amount on the budget and comparison pages is in the currency
the reader picks (?in=, CHF by default), converted at the budget year's
average rate, and the page says from what and whose rate. Rates are data
(data/money/rates.json, pnpm run money:rates): Eurostat's annual euro rates
for 151 currencies and, for the rouble after 2021, the Bank of Russia's
official rate averaged over the year. src/lib/money imports nothing from
Solon, ready to become the fleet's package. Eurostat budgets are now also
read in million euro beside the shares of GDP (generated from the same
taxonomies); a budget knows its GDP, so both show.

Language: a law in another language reads in the reader's, as a machine
translation labelled as one with the authentic text a click away. The
translations are a cache keyed by the sha256 of the words (text_translations,
migration 0030), each answer checked before it is kept (one per passage,
every number kept, no passage ballooned); titles in lists use it too, and
pnpm run law:translate fills titles ahead of readers. Places are named in
the reader's language when the data has the name (Tskhinval, not город
Цхинвал), their own names still listed.

Texts: a South Ossetian code printed as a page linking Word files is read
from the file worded as its text (never the contents file), with
word-extractor; --stubs reads again the acts held only as such a page.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 15:34:48 +01:00
CatoandClaude 32e7f6cb28 feat(budgets): public budgets as a product, on one model for every place (#525)
Budgets become their own section, /budgets and /budgets/<place>, built so
that every page and analysis works for any place and any source:

- Taxonomies are the single source (src/lib/config/budgets): COFOG for
  what money is spent on (80 codes, Eurostat's labels), ESA 2010 for where
  it comes from. They generate the budget.<scope>.<side>.<code> metrics and
  the per-country Eurostat sources; scope (general government or a state
  budget) is part of every key.
- Eurostat's government finance for 30 countries from 1995, through a new
  eurostat_json adapter (a JSON-stat reader that knows no country): spending
  by function and group, revenue by kind, the balance, in shares of GDP.
  Every division is also a statistic with its map and ranking. Reuse is
  authorised with acknowledgement (LicenseRef-eurostat-reuse).
- Budget laws are documents held to their stated totals: South Ossetia's
  2023 outturn (revenue line by line) and 2023 allocations by section, each
  line placed on the classifications, the placement explained.
- src/lib/budgets: one Budget shape for both inputs; pure analysis
  (breakdown with what the parts leave over, allowing for rounding; a total
  given with no breakdown; self-reliance; history; which year to show).
- Pages: key figures, who pays, spending by function opened into groups,
  revenue by kind, the years, sources down to the publisher's own lines,
  "propose a change to this budget"; a budget card on a country's page.
- The contested places' budget section now uses these components; their
  ledger, the quote component and rowsOf were made shared rather than kept
  as copies, and SITE_URL lives in site-config.

Design: docs/design/2026-11-budgets.md.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 15:04:10 +01:00
CatoandClaude Opus 5.5 e17536ddd1 Contested law: each side's budget, who may propose a law, taxes; the plan from comparison to change (#521)
* feat(places): contested law, one place's two sets of law side by side

Every place the world list marks as claimed (South Ossetia, Abkhazia,
Transnistria, Northern Cyprus, Somaliland, Kosovo) gets a comparison page at
/places/contested/<slug>: the same questions for every place, each side's own
words quoted in their language beside a translation, with the page and the day
read; a side with nothing read shows the gap. South Ossetia and Georgia are
compared from their constitutions on four questions (territory, citizenship,
moving and leaving, defence). /places/contested lists them all.

- Config: src/lib/config/places/contested.ts (topics in five languages, the
  contest, the quotes); schema and checks in src/lib/places/contested.ts;
  the pure view in src/lib/places/contest-view.ts.
- Every page of a claimed place says who claims it and links the comparison,
  which also restores the line the South Ossetia pack page lost when the world
  slug began redirecting to the pack.
- statistics:verify re-reads every quoted page weekly.
- Design: docs/design/2026-11-contested-law.md (why, as a system: rule sets
  competing for the same people, results per side, terms proposed with support
  counted per electorate; the plan for shared-area and layered disputes).

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

* feat(places): what each side's budget rests on, who may propose a law, taxes

The South Ossetia comparison gains three things a resident can act on:

- Taxes, quoted from the Tax Code (Part Two) the Parliament publishes as a
  Word file: 12% on a person's income (Art. 228), 20% on profit (Art. 286),
  10% VAT (Art. 166); Georgia's rates from PwC's summary, cited as a summary.
- Who may propose a law: South Ossetia's Constitution gives the right to the
  President, deputies, the Government and named bodies, not to citizens
  (Art. 69); Georgia's to 25,000 voters among others (Art. 45). South
  Ossetia's official route is now data: a bill reaches the Parliament through
  any one deputy.
- The 2023 budget as its execution law states it, as a ledger whose lines
  must add up to the stated total: 81% of revenue was aid from the Russian
  Federation; own revenue covered 18.5% of spending; spending the same from
  own revenue alone would take 5.4 times that revenue or 81.5% less spending.
  Arithmetic on the law's figures, labelled as not a forecast.

Every held article on the page links "propose a change". A quote in the
reader's own language is shown without a translation.

docs/design/2026-11-from-comparison-to-change.md: the three columns (now,
the other side, could be), the loop from reading the law to changing it and
the gap at each step for South Ossetia, the safety work needed before Solon is
promoted where proposing is risky (the public amendment log names the account
behind every act today), credibility by electorate, and the build order.

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-10 14:25:55 +01:00
CatoandClaude 7fc644dbb1 feat(places): contested law, one place's two sets of law side by side (#520)
Every place the world list marks as claimed (South Ossetia, Abkhazia,
Transnistria, Northern Cyprus, Somaliland, Kosovo) gets a comparison page at
/places/contested/<slug>: the same questions for every place, each side's own
words quoted in their language beside a translation, with the page and the day
read; a side with nothing read shows the gap. South Ossetia and Georgia are
compared from their constitutions on four questions (territory, citizenship,
moving and leaving, defence). /places/contested lists them all.

- Config: src/lib/config/places/contested.ts (topics in five languages, the
  contest, the quotes); schema and checks in src/lib/places/contested.ts;
  the pure view in src/lib/places/contest-view.ts.
- Every page of a claimed place says who claims it and links the comparison,
  which also restores the line the South Ossetia pack page lost when the world
  slug began redirecting to the pack.
- statistics:verify re-reads every quoted page weekly.
- Design: docs/design/2026-11-contested-law.md (why, as a system: rule sets
  competing for the same people, results per side, terms proposed with support
  counted per electorate; the plan for shared-area and layered disputes).


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 14:02:51 +01:00
Cato 3b0e2a86d5 South Ossetia: the Republic's own copyright law admits the Parliament's texts (#512)
Law of the Republic on copyright and related rights (12 December 2012, no. 64),
Art. 8: laws, court decisions and other legislative, administrative and judicial
texts are not objects of copyright. Found by reading the titles of all 575 acts
in the Parliament's listings; quoted on a new licence entry. The Parliament's
texts are admitted, the register's counts are now exact (480 laws, 33
constitutional laws, 62 resolutions).
2026-11-10 12:11:22 +01:00
Cato b469b0552a Law: an act's status can be 'not stated by the publisher'; South Ossetia's acts are recorded so (#499)
* Law: an act's status can be 'not stated by the publisher'; South Ossetia's acts are recorded so

legal_acts.status_stated (default true, migration 0025). When false, in_force
only keeps the act findable and no page, count, Markdown or tool calls it in
force: coverage counts it apart, the place tree still lists the place, act
rows and pages say the status is not stated, in five languages. The register
importer takes statusStated per row and updates it; the South Ossetia
registers set it false.

* Law counts: say that an act with no stated status is counted
2026-11-10 11:55:21 +01:00
Cato 39ddbf253f South Ossetia: text reader for the President's decrees (and the Parliament's, held back) (#500)
* South Ossetia: text reader (L1) for the Parliament's acts and the President's decrees

A node page or post cut into preamble, chapters and articles, dated by the
Parliament's own date field or the decree's closing lines, numbered from the
header or closing lines when it prints one (act_number, <year>/<number>).
Commands law:text parliamentrso-text|presidentruo-text, paced by the site's
crawl-delay and a second respectively; verify reads only the act's body on a
Drupal page. Fixtures from the live pages, unit and database tests.

* South Ossetia: text reader (L1): the President's decrees stored, the Parliament's refused until its terms are found

A node page or post cut into preamble, chapters and articles, dated by the
Parliament's date field or a decree's closing lines, numbered <year>/<number>
(act_number) when the act prints one. law:text presidentruo-text and
parliamentrso-text, --act to read chosen ids, paced by the site's crawl-delay
and a second. The Parliament's texts are refused while its config says no
terms admit them. verify reads only the act's body on a Drupal page.
2026-11-10 11:32:50 +01:00
CatoandClaude Opus 5.5 7dcbdc2787 Places, statistics, navigation and a new mark: the globe, every country a place, methods, gaps, research with AI, a header that fits, the owl (#458)
* feat(places): a globe that names the world, and zooms where you point

geo-kit 0.4.0 labels; countries, subdivisions (Natural Earth 1:10m) and
every place of 1,000+ people (GeoNames, CC BY 4.0) loaded a country at a
time; blue sea, land on the page surface, light and dark; credit line
names the sources and how to steer.

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

* feat(statistics): how the rankings are made; one country registry

Nine indexes of freedom and governance described the same way, with
quoted licence terms, what is unread, the same critical questions per
kind, and checked AI explanation from what was read. Country codes for
the law globe, statistics map and OECD sources come from one registry
generated from Natural Earth; a test ties every named country to it.

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

* fix(places): calm labels on geo-kit 0.5.0, towns actually drawn, land never drawn as sea

Quiet type hierarchy with room per style; zoom buttons kept clear;
subdivisions and states painted on their own layers; GeoNames towns were
loaded but never added to the labels (a patch had not applied), and the
loaders no longer drop a fetch when the view changes.

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

* feat(places): every country a place; governance scores for all

A world pack of 235 countries generated from the registry, World Bank
indicators for each and OECD tax series for its 38 members, staggered so
no publisher sees a burst; six World Bank governance scores (CC BY 4.0)
on a governance dimension; a rate fixed by law is no longer flagged for
staying put; the importer names itself and paces the OECD.

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

* feat(statistics): deep research with AI over Solon's data and law

A model with read-only tools (catalog, series, dimensions, methods, law,
and the web where configured) gathers numbered sources; the report is
written from them alone and checked: numbers, citations, paragraphs,
verdict words. Failing reports are dropped; sources stay listed.

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

* fix(places): the world pack has one root, so countries are world/<name>

235 nations in one pack each claimed the root path; Andorra became
'world'. A root place (the Earth) now holds them, as other packs hold
their subdivisions.

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

* test(places): the world pack's data has one root

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

* docs(roadmap): second-level subdivisions need a licence read per country

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

* feat(statistics): code compulsory old-age provision for CH and US

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

* fix(places): the OECD answers a plain request, not Node's default

Its gateway returned 500 for accept-language: * and 200 for a plain
language and a data type (found by trying headers one at a time; the
earlier rate-limit explanation was wrong). The importer now sends
accept and accept-language; the 6 s OECD pacing and the five-minute
stagger are gone.

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

* feat(statistics): what is measured, and where it is not

A registry and pages for the places where statistical offices collect and
publish different things: per topic and breakdown, what each office's own
pages say (checked weekly), the law that frames it, where a gap lies, what
must accompany a new measure, the objections with safeguards, who decides.
First topic: crime by a person's background, nine places; descriptive, no
characterisation of offices or people.

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

* feat(site): a header that fits, Find over everything, an engineering audit

Four panels of four or five links (Law, Places, Data, Governance) instead
of 27, a Find palette over pages, statistics, places and laws (Ctrl/Cmd+K
or /), the phone menu as folds. Six import cycles fixed and gated in
verify; docs/design/2026-11-engineering-audit.md records what was measured,
the one-source map and the debt in order.

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

* feat(brand): the owl, and one drawing behind every place the mark appears

Solon's mark is now Athens' little owl (the bird on the coins of Solon's
city) with the fleet's rotorelief rings for eyes: the Cat's sibling, where
the old balance was a line icon from no family.

brand/solon-mark.svg is the only drawing. `pnpm run brand` writes the
mark data (header, footer, share card), the favicon, the app icons and
the deck/press exports from it; a test fails when a copy drifts. The
candidates it was chosen over are in brand/concepts with the reasons.

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

* docs(brand): where the marks should live next, and why a copy remains

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

* test(e2e): follow the curated header and the folded phone menu

The phone menu folds the site by section (only the current one opens), so
the test opens Platform before it looks for Security. The Governance
panel no longer carries the ideas page (the footer does); the panel test
follows Decisions instead.

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

* refactor(law): name an authority by its place, in the reader's language

Law authorities hand-wrote 80 English names ("Confederation", "Zürich")
for places Places already names in every language. Pages now read the
place's own name (loadAuthorityNames, once per request); a country with no
place yet is named by Intl, the cantons together and the European Union
from messages, and two places of one name get their level ("Zürich
(Gemeinde)"). The config's field is now `label`: English, for logs, the
API, llms.txt and prompts only.

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

* feat(brand): one statement of what Solon is, on the card, in search and on the phone

The share card, the meta description and the app manifest each carried
their own line about Solon, and all three still described governance
alone. They now read the home page's hero (Home.hero), in the reader's
language: the card is per locale, set in Inter from the design-tokens
package (Cyrillic included, nothing fetched), with the owl, and sizes its
headline so every language fits on two lines. Meta.description is gone.

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

* fix(brand): the owl favicon is linked, and iOS gets its own icon

The layout's explicit `icons` replaced Next's file convention, so the
generated icon.svg was never linked and only favicon.ico was. Without it,
Next links favicon.ico, icon.svg and apple-icon.png (180, full bleed,
written by `pnpm run brand -- --png` like the others).

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

* Test: the world pack's own root is not a reserved path segment

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-10 11:11:37 +01:00
CatoandClaude Sonnet 5.5 57b0be27a8 Design: every place at every level, one model, one page, one map behaviour (#486)
* Design: every place at every level, one model, one page, one map behaviour

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

* Design: acceptance criteria from the 2026-11-10 QA walk, each mapped to a step

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

* Design: the globe sidebar's count is part of the count-contradiction item

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

* Design: what a real browser showed, and QA 8 is already #458's

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

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 11:00:31 +01:00
Cato 8e7fc9cada South Ossetia: register of acts (L0) from the Parliament's listings and the President's API (#487)
Authority `rso` (place Wikidata Q23427, topLevel: no ISO code, and `so` is
Solothurn's). Two format readers, config-driven: a Drupal taxonomy listing
(Parliament, honours the 90 s crawl-delay) and the WordPress REST API
(President, 1,849 acts with decrees, documents and treaties under one id).
Fixtures from the live pages, unit tests and a database integration test;
commands `law:text parliamentrso|presidentruo` and the two workflows' lists.
Licence entry for the President's site quoting its reuse page.

Claude-Session: https://claude.ai/code/session_019MDtmuWnz7uS87NvSiDSDs
2026-11-10 10:49:12 +01:00
Cato f48c443671 South Ossetia: sources research note and the place's structure (#484)
* South Ossetia: research note and the place's structure (pack, Wikidata scheme, five units)

Adds the sources research note (publishers, reachability from a runner, counts
measured, statistics read, gaps) and the first rows of the place: a pack with no
ISO code (identified by Wikidata), the five administrative-territorial units of
Constitution Art. 3 para. 2 as part_of the nation, names with the authority's
own Russian first. Claims, administration and recognitions follow as their own
sources, once the world backbone rows they point at are on main.

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

* South Ossetia research note: recognitions, Georgia's own wording, what the place model needs

Claude-Session: https://claude.ai/code/session_019MDtmuWnz7uS87NvSiDSDs
2026-11-10 10:11:27 +01:00
CatoandClaude f7ead78789 feat(statistics): exit dimension coded from law; index licences read (#457)
Rubrics exit.renounce_citizenship and exit.departure_tax; CH, EE, US
codings from BüG, KodS, 8 USC 1481 and 26 USC 877A. Licence findings
for ten freedom indexes recorded.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-09 11:42:30 +01:00
CatoandClaude 83093c5dbf feat(statistics): screen charts for sense, and explain pages with checked AI (#456)
Figures outside a metric's plausible band are left out and listed; misleading
comparisons carry a warning. Each page's figures become numbered facts; an AI
explanation is written from them only and dropped unless every number and
citation is in them.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-09 11:17:33 +01:00
CatoandClaude Sonnet 5.5 33d8a690cd Statistics: coded assessments and the compulsion dimension (#453)
* feat(statistics): the law beside the numbers — series, law links, timelines, axes, saved views

Implements the roadmap section {#stats} (docs/design/2026-11-freedom-laws-statistics.md):

- Series as facts: a `statistic` block on metrics (definition, publisher,
  series code); World Bank (WDI API) and OECD (SDMX) adapters; five series
  for CH, LI, EE and US, read monthly; a publisher's 5xx is retried twice.
- An append-only `statistic_records` log for law links, events and
  enforcement, written from a curated, source-checked list by
  `statistics:sync` and the daily places cron; three links checked against
  Fedlex and Riigi Teataja.
- /statistics (ranked bars, axes with reader or group weights),
  /statistics/<metric> (line chart, a timeline of linked acts' versions over
  the same years, the law, enforcement, sources), /statistics/view/<sha256>;
  on @bitbaum/chartkit; five languages.
- Saved views under the sha256 of their spec; a proposal that links one
  carries it as evidence (proposal_evidence), attached in the same
  transaction.
- Roadmap and changelog updated; what remains is listed with its reason.

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

* feat(statistics): law event pages, clickable timelines, maps, scatter, parallel coordinates, reader-built axes

- Events: what changed (wording before/after), how it came about, votes with
  party breakdowns, who initiated/sponsored/recommended/opposed, claims and
  critiques kept apart from what happened, each line with the page it was read
  on; five loaded (Estonia 2023, US TCJA 2017, two Swiss firearms ballots,
  Kennesaw 1982). /statistics/event/<slug>, /statistics/events; timeline marks
  open them; the numbers around an event (line cut at the change, peers apart,
  a before/at/after table).
- Numbers that mean the same everywhere: central-government-only series
  retired for all-levels OECD series; a per-statistic scope sentence; central
  share of tax as a decentralisation proxy; SDMX series told apart by `match`.
- A world map per statistic on geo-kit, /statistics/compare scatter, parallel
  coordinates per axis, a reader-built axis kept in the link, saved axes.
- Fetch: four retries with backoff and a pause between a source's requests.
- Tests, roadmap, changelog and design note updated.

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

* feat(statistics): coded assessments and the compulsion dimension

A rubric registry and an assessment record kind in the append-only log.
A coding names its rubric version, a point of the written scale, the
provisions and quotes it was read from, a confidence and its reason, and
is settled only when someone other than the coder has reviewed it.
First codings, from statutes: compulsory military service in CH, EE, US.

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

* feat(statistics): coded assessments and the compulsion dimension

A rubric registry and an assessment record kind in the append-only log.
A coding names its rubric version, a point of the written scale, the
provisions and quotes it was read from, a confidence and its reason, and
is settled only when someone other than the coder has reviewed it.
First codings, from statutes: compulsory military service in CH, EE, US.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-09 10:06:14 +01:00
CatoandClaude Sonnet 5.5 c50c65fffa Statistics: law, practice and outcome as layers, data-integrity plumbing, and the freedom framework (#452)
* feat(statistics): the law beside the numbers — series, law links, timelines, axes, saved views

Implements the roadmap section {#stats} (docs/design/2026-11-freedom-laws-statistics.md):

- Series as facts: a `statistic` block on metrics (definition, publisher,
  series code); World Bank (WDI API) and OECD (SDMX) adapters; five series
  for CH, LI, EE and US, read monthly; a publisher's 5xx is retried twice.
- An append-only `statistic_records` log for law links, events and
  enforcement, written from a curated, source-checked list by
  `statistics:sync` and the daily places cron; three links checked against
  Fedlex and Riigi Teataja.
- /statistics (ranked bars, axes with reader or group weights),
  /statistics/<metric> (line chart, a timeline of linked acts' versions over
  the same years, the law, enforcement, sources), /statistics/view/<sha256>;
  on @bitbaum/chartkit; five languages.
- Saved views under the sha256 of their spec; a proposal that links one
  carries it as evidence (proposal_evidence), attached in the same
  transaction.
- Roadmap and changelog updated; what remains is listed with its reason.

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

* feat(statistics): law event pages, clickable timelines, maps, scatter, parallel coordinates, reader-built axes

- Events: what changed (wording before/after), how it came about, votes with
  party breakdowns, who initiated/sponsored/recommended/opposed, claims and
  critiques kept apart from what happened, each line with the page it was read
  on; five loaded (Estonia 2023, US TCJA 2017, two Swiss firearms ballots,
  Kennesaw 1982). /statistics/event/<slug>, /statistics/events; timeline marks
  open them; the numbers around an event (line cut at the change, peers apart,
  a before/at/after table).
- Numbers that mean the same everywhere: central-government-only series
  retired for all-levels OECD series; a per-statistic scope sentence; central
  share of tax as a decentralisation proxy; SDMX series told apart by `match`.
- A world map per statistic on geo-kit, /statistics/compare scatter, parallel
  coordinates per axis, a reader-built axis kept in the link, saved axes.
- Fetch: four retries with backoff and a pause between a source's requests.
- Tests, roadmap, changelog and design note updated.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-09 09:40:57 +01:00
CatoandClaude Sonnet 5.5 568fc14323 Statistics beside the law: series, law events, timelines, maps, axes and saved views (#441)
* feat(statistics): the law beside the numbers — series, law links, timelines, axes, saved views

Implements the roadmap section {#stats} (docs/design/2026-11-freedom-laws-statistics.md):

- Series as facts: a `statistic` block on metrics (definition, publisher,
  series code); World Bank (WDI API) and OECD (SDMX) adapters; five series
  for CH, LI, EE and US, read monthly; a publisher's 5xx is retried twice.
- An append-only `statistic_records` log for law links, events and
  enforcement, written from a curated, source-checked list by
  `statistics:sync` and the daily places cron; three links checked against
  Fedlex and Riigi Teataja.
- /statistics (ranked bars, axes with reader or group weights),
  /statistics/<metric> (line chart, a timeline of linked acts' versions over
  the same years, the law, enforcement, sources), /statistics/view/<sha256>;
  on @bitbaum/chartkit; five languages.
- Saved views under the sha256 of their spec; a proposal that links one
  carries it as evidence (proposal_evidence), attached in the same
  transaction.
- Roadmap and changelog updated; what remains is listed with its reason.

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

* feat(statistics): law event pages, clickable timelines, maps, scatter, parallel coordinates, reader-built axes

- Events: what changed (wording before/after), how it came about, votes with
  party breakdowns, who initiated/sponsored/recommended/opposed, claims and
  critiques kept apart from what happened, each line with the page it was read
  on; five loaded (Estonia 2023, US TCJA 2017, two Swiss firearms ballots,
  Kennesaw 1982). /statistics/event/<slug>, /statistics/events; timeline marks
  open them; the numbers around an event (line cut at the change, peers apart,
  a before/at/after table).
- Numbers that mean the same everywhere: central-government-only series
  retired for all-levels OECD series; a per-statistic scope sentence; central
  share of tax as a decentralisation proxy; SDMX series told apart by `match`.
- A world map per statistic on geo-kit, /statistics/compare scatter, parallel
  coordinates per axis, a reader-built axis kept in the link, saved axes.
- Fetch: four retries with backoff and a pause between a source's requests.
- Tests, roadmap, changelog and design note updated.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-09 09:15:42 +01:00
CatoandClaude d1b06d5c9f Cut 'Article N – Title' headings into articles; re-cut held municipal PDFs (#439)
A commune's regulation whose headings put a dash between the number and the
title (Neuchâtel) was stored as one block. The cutter accepts the dash, and
recut-municipal cuts the held PDFs again from their snapshots.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-08 14:59:04 +01:00
CatoandClaude 79cbd7760e docs(roadmap): the law beside the numbers — statistics, enforcement, axes and charts (#438)
Records the owner's direction for a statistics, enforcement and
visualization layer: series as facts in the existing places model, links
from data to provisions, enforcement as attributed assertions beside the
statute, law events read from act versions, axes and weights as versioned
policies rather than a Solon score, chartkit/geo-kit charts traceable to
source and statute, saved views as proposal evidence. Narrated explainers
recorded under Later.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-08 14:58:19 +01:00
CatoandClaude Opus 5.5 cfdd8267a8 Law: Genève, Lausanne, Köniz, Fribourg, Neuchâtel, Lugano and Bellinzona from the pages they link their acts from (#432)
* Law: Köniz, Fribourg and Neuchâtel from the page each links its acts from

Three of Switzerland's twenty most populous communes link their regulations
as PDFs from one page of their own, the way Liechtenstein's communes do, so
each is a config of the linked-documents adapter. The adapter now takes the
commune's language (Fribourg and Neuchâtel are read in French) and may leave
out documents by their address, as Köniz marks acts adopted but not yet in
force, and repealed ones, only in the file's name. Tests use the documents'
real addresses.

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

* Law: Lugano and Bellinzona from the page each links its acts from

Ticino's two largest communes link their regulations from one page each:
Lugano's "Legislazione", whose act pages (/law/<id>/<title>) serve the PDF,
and Bellinzona's "Legislazione comunale", whose files are served by document
id. Both are configs of the linked-documents adapter, read in Italian, with
what Ticino's communes call an act and what a form or a message. Tests use
the documents' real addresses.

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

* Law: Genève and Lausanne; a commune's list may run past 40 pages

Genève lists its about 250 municipal regulations ten to a page, each with
its file or its own page; Lausanne lists about 190 acts, each with its own
entry and a file served by id. Both are configs of the linked-documents
adapter, read in French. The adapter now opens as many pages as a config
says (maxPages, 40 unless said), skips a page after the first that cannot be
read instead of failing the whole list, and knows French and Italian download
buttons, so a button-only link is titled by its title attribute.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-08 12:26:12 +01:00
CatoandClaude 209748197a Law: one reader for communes on the i-web CMS; Luzern, Thun, Chur, Schaffhausen and Sion (#431)
Five of Switzerland's twenty most populous communes publish their
collection through the i-web CMS's legal module. The new adapter
(publishers/iweb.ts) is config-driven like linked-documents: the pages that
hold the collection and which links lead to more of it. It reads the list
from the table's data-entities JSON, each act's in-force and end days and
earlier versions from its page's <dl> (German and French labels), the
document from the page's own table, and an earlier version's file past the
notice i-web puts in front of it.

The module's shape comes from two public readers of i-web sites, as none of
the cities could be opened from the sandbox; the fixtures say so. Unit tests
cover the parsing and the adapter, an integration test loads a collection end
to end with history. Names in the cities' languages are aliases, so a
question about Lucerne or Coire asks the city's law with the canton's.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-08 12:12:36 +01:00
CatoandClaude Opus 5.5 93082c148a Law: Winterthur, St. Gallen and Biel/Bienne from their LexWork collections (#430)
* Law: Winterthur, St. Gallen and Biel/Bienne from their LexWork collections

Three of Switzerland's twenty most populous communes keep their systematic
collections on LexWork (winterthur.tlex.ch, st.gallen.tlex.ch,
biel-bienne.tlex.ch), the platform Solon already reads for Zug's and
Glarus's communes. Each is a commune authority within its canton, with the
names people use for it, and a configured collection. A test holds every
configured collection to a commune the register knows.

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

* Design: the LexWork section names the three cities added

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-08 11:38:00 +01:00
CatoandClaude 8ea236862f Design: the 2026-11-08 direction, as principles (#417)
The owner's direction after seeing the globe and the Places map side by
side, recorded beside the 2026-11-06 direction: the legal puzzle of the
world shown layer by layer with local rules first-class, exit easy, one of
each thing, find the law rather than report it blocked, AI that helps the
citizen act, building in public, packages by default, robust plumbing.
Marked as guidance, not copy: Solon's own words stay neutral.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-08 08:44:32 +01:00
CatoandClaude 36536730c5 Light theme: follow the device, or the reader's pick in the header (#414)
Solon was pinned to dark. The shared tokens already carry both themes
(:root light, .dark overrides), so this decides which one is on:

- src/components/theme/: the choices, a head script that sets the `dark`
  class, `data-theme` and `color-scheme` before the first paint (no flash),
  and a header toggle (Light / Dark / Device) kept in localStorage. No
  framework or Solon name in theme.ts, so it can move into
  @bitbaum/design-tokens ({#theme-package}).
- <html> drops the pinned class and carries suppressHydrationWarning.
- Photographs stay dark on purpose: FullBleed and AudienceTile wear `dark`,
  and the transparent header over a page that opens on a photograph does
  too (HEADER_OVER_PHOTO_ROUTES, held to the pages by a test).
- Bands that used bg-surface-public (near-black in both themes) use a new
  `.band`: the public surface in dark, white in light. The footer too.
- bip-kit's variables are set in both themes, not only under html.dark.
- The law globe reads its tokens again when <html>'s class changes.
- text-white and text-green-400 replaced by tokens.
- Toggle words in all five languages; e2e check of device, pick and reload.
- Docs: ui-guidelines theme section, CLAUDE.md, AGENTS.md, README, ROADMAP
  {#themes}, CHANGELOG {#theme-light}.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-08 08:38:24 +01:00
CatoandClaude f514bff14b Law: read a refusing publisher from the Internet Archive's dated copy; Triesenberg (#413)
When a publisher's page or document answers with a refusal (HTTP 403, 429,
503, or a bot-check page such as LiteSpeed's "Bot Verification"), the
publisher reader asks the Wayback Machine for its newest capture and reads
the raw bytes (id_). Solon keeps its own user agent and solves nothing.

Links in a captured page resolve to the publisher's addresses, so the act's
identity stays the official URL. A version read from a copy records the
copy's address (web.archive.org/web/<timestamp>id_/<original>) as its
source, which names the archive and the capture day, so no migration is
needed; the importer version is marked +archive. The act page says "Copy
read on {date} from the Internet Archive's copy of {captured}" in all five
languages, the Markdown and the search tool name the copy apart from the
publisher's page.

Triesenberg (li7004) is configured as a WordPress commune and is the first
read this way. The ask-scope test now uses Bern (BFS 351) as a commune
without a collection.


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-08 08:29:14 +01:00
CatoandClaude 8156da240b The engine for amending the law (#401)
Anyone can propose a change to an act Solon holds, and the record of it
cannot be quietly rewritten (design: docs/design/2026-11-amending-the-law.md).

- Changes are replace / insert / repeal on one provision each (Akoma Ntoso's
  textual modifications), each pinned to the sha256 of the exact text it
  amends; changes that do not fit the text in force are refused with the
  reason, and an amendment whose text the publisher later changes is shown
  as outdated rather than silently re-applied
- Revisions are immutable and carry a content hash; support binds to one
  revision, by account or by a Bitcoin signature anyone can recount; anyone
  may fork, and the lineage is kept
- Every act is an event in one hash-chained log (verifyChain recomputes it);
  triggers make the database refuse any UPDATE or DELETE on all four tables
- The redline is computed word by word (jsdiff; the fleet has no diff package)
- Official routes as sourced data: the federal popular initiative (Art. 139)
  and petition (Art. 33) to start; each amendment shows the routes its act
  can take
- Abuse limits: 20 filings an hour per author; a support that changes
  nothing is refused
- API under /api/v1/law/amendments; 27 integration tests against Postgres,
  and the full integration suite passes on a fresh database


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

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-06 16:04:34 +01:00
CatoandClaude Opus 5.5 a7cdf46f40 Put the law in the main menu and lead with it (#400)
* Put the law in the main menu and lead with it

Production has held the text of every federal, cantonal and Liechtenstein
act in force since 2026-11-01, but /law was in neither the header nor the
footer, and the roadmap and coverage page still said the text was not held.

- Law is a header panel (find, ask, what Solon holds); use cases move to
  the footer to keep the header at four panels
- The home page leads with the open law; the Glarus section becomes one
  root among three (open assembly, public ledger, forkable rules)
- The ideas page adds the public ledger, rules as open source and
  polycentric law
- The coverage page and ROADMAP.md say what production holds; the roadmap
  gains "Law you can act on", the globe, Wyoming, exit/fork and a provable
  record
- docs/design/2026-11-global-law-and-exit.md records the direction and order

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

* Point the header e2e test at a panel that is still in the header

Use cases moved to the footer, so the panel-navigation test now opens
Governance and follows its ideas link.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-06 14:43:45 +01:00
CatoandClaude Sonnet 5.5 2e47306422 feat(law): search goes through searchkit (typos forgiven, titles ranked, did-you-mean) (#383)
* feat(law): read scanned commune acts by OCR, and never drop text before a late first article

A commune that publishes a scan (pages as pictures, no text layer) failed as
"no text in the PDF": Vaduz 5, Schaan 4, Eschen 2, Schellenberg 2. The
commune loader now draws each page (unpdf + @napi-rs/canvas) and reads it with
tesseract.js in the act's language, in process: nothing to install on the box,
no model called. The version's source says so: law-text-publisher-1+ocr.

Schellenberg's hall regulation numbers sections "1." and "2." before an
"Art. 3"; the cutter kept Art. 3 and dropped the rest. When the first article
found is not article 1, the text before it is now kept as one provision.

Live on schellenberg.li: both scans read (2 of 2), 6 acts, 106 provisions.

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

* fix(law): an act's page address follows the register when the publisher's address changes

An act first listed at a wrong address kept it for ever: the register import
added a page address only for a new act. Schellenberg's 35 acts were first read
without the page's <base href> (fixed in #361) and stayed at /service/files/...,
so the load kept fetching a web page instead of the PDF ("Invalid PDF
structure" x35), and the official page shown to readers was a dead link.

For a known act, a different official_url now supersedes the old one and the
new is current; unchanged is untouched. Reproduced locally with stale
addresses: 35 corrected, 3 acts loaded, 55 provisions.

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

* fix(law): store a PDF's NUL as a space, and find Lilex pages the issue number does not give

Cantonal: a 47-page intercantonal annex (LexFind 24607) failed to insert. Its
PDF holds one NUL where a glyph has no character (a dash between two words),
and Postgres cannot store NUL. cleanPdfText and blockText replace it with a
space, so no reader can hit it.

Lilex: an act's page address came only from its Landesgesetzblatt issue.
- 59 acts had none (Austrian-era decrees, issues like 60/1): the publisher's own
  Gebietssystematik names each page; all 59 resolve (the act's listing, then each
  parent, once per listing).
- The EEA agreement's page is ...001, not ...000; found the same way (the first
  of the rows a treaty is listed under).
- Two acts have no consolidated page at all (a Bekanntmachung of 1941, a 2020
  EEA decision): the gazette entry links a PDF, which is read.
- gesetze.li answers an unknown address with a maintenance notice carrying the
  proof-of-work script; that is now "no page", not a challenge that stops the run.
- refresh reads these the same way, so they stay current.

Live against gesetze.li into a local database: 0.110 (129 provisions), 641.291,
0.110.042.08 (4), 210.109, 210.111, 210.116 all store.

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

* feat(law): read a scanned cantonal document by OCR

LexFind document 13622 (a 881 KB scan, no text layer) failed as "no text in
the document": the cantonal importer had no OCR fallback. It now uses the
shared provisionsOfPdf (the commune loader's), reading German, French and
Italian together because the file's own language is not known. A scanned
version's source carries law-text-cantonal-2+ocr.

On the real scan: scanned, 2 articles (Geltungsdauer und Kuendigung, Aenderung
der Vereinbarung).

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

* docs(law): how Swiss communes publish their law — a survey of the 26 cantons

Five research passes, each reporting only what it opened. No canton hosts its
communes' law centrally except Basel-Stadt (3 communes). Two platforms span many
communes: LexWork (name.tlex.ch, about thirty found) and the i-web.ch CMS (about
fifty estimated). Basel-Landschaft's single CMS is behind a Cloudflare challenge,
reported and not worked around. Lists the order to build in and what is not verified.

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

* feat(law): read the communes' LexWork collections — Zug and Glarus, 14 communes, 1,164 acts with their dated versions

Many communes keep their law in a LexWork (Sitrox) collection at
<commune>.tlex.ch. The app's own JSON interface is open (no login; robots.txt
blocks only the search endpoints), so it is read as data: the list of acts,
each act by systematic number, the day each version took effect (versions are
dated by the publisher), and the article tree. Versions older than the
structured text are held as a PDF and read like any PDF.

- config LEXWORK: the 14 instances verified live (11 Zug communes, 3 Glarus), each
  an authority bfs<number>, within its canton; ACT_TEXT_FORMATS gains json.
- text/lexwork.ts (fetch, dates, versions, article tree), text/import-lexwork.ts.
- law:text lexwork [--host]; Law text load workflow source lexwork.
- Survey doc: the interface is confirmed open.

Live into a local database: Zug 50 versions then 0 failures, Glarus Nord 12 versions /
452 provisions, no failures. Integration test: old version ends the day before the
new one, a second run stores nothing.

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

* fix(law): a LexWork version that cannot be read no longer stops the current one

The first production load of Zug and Glarus stored 1,498 dated versions
(21,823 provisions) and left 4 acts without text: one old version of each
failed with "no text", and the loop, which stores oldest first, stopped
there and never reached the current version.

Each version is now read on its own: a failure is reported for that version
and the rest go on. A version the publisher holds with no text at all (Cham's
act 3-1 is a blank Word page published under a placeholder 1900 date) is
reported as emptyAtPublisher, not as a failure, and nothing is invented.

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

* feat(law): register the federal acts Fedlex lists and the register lacks; tell two acts of one number apart

The register of federal acts comes from LexFind, which lags Fedlex by days. Fedlex's
own list showed two acts the register did not hold (SR 0.973.276.71, 129.1) and one
number carried by two acts (SR 0.424.21: the 2005 framework agreement on nuclear-energy
research and its 2025 renewal), which the importer skipped, leaving the registered one
without any text.

The Fedlex text load now:
- tells two acts of one number apart by the address of their own Fedlex page (the
  register's official_url or ch_eli), never guessing; where the register cannot tell,
  the number is still reported ambiguous and left alone;
- registers any act Fedlex lists that the register lacks, from Fedlex's own list (title
  from the act's expression, ch_eli, its page), and reads it.

Against real Fedlex into a scratch database: 5,336 acts registered, none with a
placeholder title, SR 0.424.21 held as two acts with their 2005 and 2025 titles.

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

* fix(law): ask Fedlex for titles apart from the list, which had lost five acts

The title I added to the Fedlex list query in #380 made Fedlex return five fewer
acts in force (5,336 against 5,341, which an independent count of the same filter
confirms): those five were still held, but would no longer have been kept current.
The list query is back to what it was; the titles of the acts to be registered are
asked in a second, small query (VALUES over their addresses, validated, 100 at a time).

Against real Fedlex: 5,341 versions again, 5,340 distinct numbers, and the 2005 and
2025 framework agreements' titles come back.

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

* feat(law): find the law by words or by place; act contents; llms.txt, sitemap, Markdown for models

One search box over titles and text, a place tree derived from the authorities,
place pages, breadcrumb and contents on acts, /llms.txt, robots, sitemaps,
per-act Markdown/JSON, place hierarchy in law_authorities, offset in law_find_acts.

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

* fix(law): list sitemaps without a database, which the build does not have

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

* feat(law): search goes through searchkit: typos forgiven, titles ranked and marked, did-you-mean

The vocabulary of act-title words expands what is typed; the database returns
candidates; searchkit ranks titles. Landing, MCP law_find_acts/law_search and
REST search share one path. foldedSql moves to places/fold for both searches.

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

* style: format places/search.ts

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 09:21:37 +01:00
CatoandClaude Sonnet 5.5 4531541601 feat(law): find the law by words or by place; contents on acts; llms.txt, sitemap and Markdown for models (#382)
* feat(law): read scanned commune acts by OCR, and never drop text before a late first article

A commune that publishes a scan (pages as pictures, no text layer) failed as
"no text in the PDF": Vaduz 5, Schaan 4, Eschen 2, Schellenberg 2. The
commune loader now draws each page (unpdf + @napi-rs/canvas) and reads it with
tesseract.js in the act's language, in process: nothing to install on the box,
no model called. The version's source says so: law-text-publisher-1+ocr.

Schellenberg's hall regulation numbers sections "1." and "2." before an
"Art. 3"; the cutter kept Art. 3 and dropped the rest. When the first article
found is not article 1, the text before it is now kept as one provision.

Live on schellenberg.li: both scans read (2 of 2), 6 acts, 106 provisions.

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

* fix(law): an act's page address follows the register when the publisher's address changes

An act first listed at a wrong address kept it for ever: the register import
added a page address only for a new act. Schellenberg's 35 acts were first read
without the page's <base href> (fixed in #361) and stayed at /service/files/...,
so the load kept fetching a web page instead of the PDF ("Invalid PDF
structure" x35), and the official page shown to readers was a dead link.

For a known act, a different official_url now supersedes the old one and the
new is current; unchanged is untouched. Reproduced locally with stale
addresses: 35 corrected, 3 acts loaded, 55 provisions.

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

* fix(law): store a PDF's NUL as a space, and find Lilex pages the issue number does not give

Cantonal: a 47-page intercantonal annex (LexFind 24607) failed to insert. Its
PDF holds one NUL where a glyph has no character (a dash between two words),
and Postgres cannot store NUL. cleanPdfText and blockText replace it with a
space, so no reader can hit it.

Lilex: an act's page address came only from its Landesgesetzblatt issue.
- 59 acts had none (Austrian-era decrees, issues like 60/1): the publisher's own
  Gebietssystematik names each page; all 59 resolve (the act's listing, then each
  parent, once per listing).
- The EEA agreement's page is ...001, not ...000; found the same way (the first
  of the rows a treaty is listed under).
- Two acts have no consolidated page at all (a Bekanntmachung of 1941, a 2020
  EEA decision): the gazette entry links a PDF, which is read.
- gesetze.li answers an unknown address with a maintenance notice carrying the
  proof-of-work script; that is now "no page", not a challenge that stops the run.
- refresh reads these the same way, so they stay current.

Live against gesetze.li into a local database: 0.110 (129 provisions), 641.291,
0.110.042.08 (4), 210.109, 210.111, 210.116 all store.

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

* feat(law): read a scanned cantonal document by OCR

LexFind document 13622 (a 881 KB scan, no text layer) failed as "no text in
the document": the cantonal importer had no OCR fallback. It now uses the
shared provisionsOfPdf (the commune loader's), reading German, French and
Italian together because the file's own language is not known. A scanned
version's source carries law-text-cantonal-2+ocr.

On the real scan: scanned, 2 articles (Geltungsdauer und Kuendigung, Aenderung
der Vereinbarung).

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

* docs(law): how Swiss communes publish their law — a survey of the 26 cantons

Five research passes, each reporting only what it opened. No canton hosts its
communes' law centrally except Basel-Stadt (3 communes). Two platforms span many
communes: LexWork (name.tlex.ch, about thirty found) and the i-web.ch CMS (about
fifty estimated). Basel-Landschaft's single CMS is behind a Cloudflare challenge,
reported and not worked around. Lists the order to build in and what is not verified.

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

* feat(law): read the communes' LexWork collections — Zug and Glarus, 14 communes, 1,164 acts with their dated versions

Many communes keep their law in a LexWork (Sitrox) collection at
<commune>.tlex.ch. The app's own JSON interface is open (no login; robots.txt
blocks only the search endpoints), so it is read as data: the list of acts,
each act by systematic number, the day each version took effect (versions are
dated by the publisher), and the article tree. Versions older than the
structured text are held as a PDF and read like any PDF.

- config LEXWORK: the 14 instances verified live (11 Zug communes, 3 Glarus), each
  an authority bfs<number>, within its canton; ACT_TEXT_FORMATS gains json.
- text/lexwork.ts (fetch, dates, versions, article tree), text/import-lexwork.ts.
- law:text lexwork [--host]; Law text load workflow source lexwork.
- Survey doc: the interface is confirmed open.

Live into a local database: Zug 50 versions then 0 failures, Glarus Nord 12 versions /
452 provisions, no failures. Integration test: old version ends the day before the
new one, a second run stores nothing.

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

* fix(law): a LexWork version that cannot be read no longer stops the current one

The first production load of Zug and Glarus stored 1,498 dated versions
(21,823 provisions) and left 4 acts without text: one old version of each
failed with "no text", and the loop, which stores oldest first, stopped
there and never reached the current version.

Each version is now read on its own: a failure is reported for that version
and the rest go on. A version the publisher holds with no text at all (Cham's
act 3-1 is a blank Word page published under a placeholder 1900 date) is
reported as emptyAtPublisher, not as a failure, and nothing is invented.

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

* feat(law): register the federal acts Fedlex lists and the register lacks; tell two acts of one number apart

The register of federal acts comes from LexFind, which lags Fedlex by days. Fedlex's
own list showed two acts the register did not hold (SR 0.973.276.71, 129.1) and one
number carried by two acts (SR 0.424.21: the 2005 framework agreement on nuclear-energy
research and its 2025 renewal), which the importer skipped, leaving the registered one
without any text.

The Fedlex text load now:
- tells two acts of one number apart by the address of their own Fedlex page (the
  register's official_url or ch_eli), never guessing; where the register cannot tell,
  the number is still reported ambiguous and left alone;
- registers any act Fedlex lists that the register lacks, from Fedlex's own list (title
  from the act's expression, ch_eli, its page), and reads it.

Against real Fedlex into a scratch database: 5,336 acts registered, none with a
placeholder title, SR 0.424.21 held as two acts with their 2005 and 2025 titles.

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

* fix(law): ask Fedlex for titles apart from the list, which had lost five acts

The title I added to the Fedlex list query in #380 made Fedlex return five fewer
acts in force (5,336 against 5,341, which an independent count of the same filter
confirms): those five were still held, but would no longer have been kept current.
The list query is back to what it was; the titles of the acts to be registered are
asked in a second, small query (VALUES over their addresses, validated, 100 at a time).

Against real Fedlex: 5,341 versions again, 5,340 distinct numbers, and the 2005 and
2025 framework agreements' titles come back.

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

* feat(law): find the law by words or by place; act contents; llms.txt, sitemap, Markdown for models

One search box over titles and text, a place tree derived from the authorities,
place pages, breadcrumb and contents on acts, /llms.txt, robots, sitemaps,
per-act Markdown/JSON, place hierarchy in law_authorities, offset in law_find_acts.

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

* fix(law): list sitemaps without a database, which the build does not have

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-02 08:56:15 +01:00
CatoandClaude Sonnet 5.5 0473c417ae feat(law): register the federal acts Fedlex lists and the register lacks; tell two acts of one number apart (#380)
* feat(law): read scanned commune acts by OCR, and never drop text before a late first article

A commune that publishes a scan (pages as pictures, no text layer) failed as
"no text in the PDF": Vaduz 5, Schaan 4, Eschen 2, Schellenberg 2. The
commune loader now draws each page (unpdf + @napi-rs/canvas) and reads it with
tesseract.js in the act's language, in process: nothing to install on the box,
no model called. The version's source says so: law-text-publisher-1+ocr.

Schellenberg's hall regulation numbers sections "1." and "2." before an
"Art. 3"; the cutter kept Art. 3 and dropped the rest. When the first article
found is not article 1, the text before it is now kept as one provision.

Live on schellenberg.li: both scans read (2 of 2), 6 acts, 106 provisions.

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

* fix(law): an act's page address follows the register when the publisher's address changes

An act first listed at a wrong address kept it for ever: the register import
added a page address only for a new act. Schellenberg's 35 acts were first read
without the page's <base href> (fixed in #361) and stayed at /service/files/...,
so the load kept fetching a web page instead of the PDF ("Invalid PDF
structure" x35), and the official page shown to readers was a dead link.

For a known act, a different official_url now supersedes the old one and the
new is current; unchanged is untouched. Reproduced locally with stale
addresses: 35 corrected, 3 acts loaded, 55 provisions.

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

* fix(law): store a PDF's NUL as a space, and find Lilex pages the issue number does not give

Cantonal: a 47-page intercantonal annex (LexFind 24607) failed to insert. Its
PDF holds one NUL where a glyph has no character (a dash between two words),
and Postgres cannot store NUL. cleanPdfText and blockText replace it with a
space, so no reader can hit it.

Lilex: an act's page address came only from its Landesgesetzblatt issue.
- 59 acts had none (Austrian-era decrees, issues like 60/1): the publisher's own
  Gebietssystematik names each page; all 59 resolve (the act's listing, then each
  parent, once per listing).
- The EEA agreement's page is ...001, not ...000; found the same way (the first
  of the rows a treaty is listed under).
- Two acts have no consolidated page at all (a Bekanntmachung of 1941, a 2020
  EEA decision): the gazette entry links a PDF, which is read.
- gesetze.li answers an unknown address with a maintenance notice carrying the
  proof-of-work script; that is now "no page", not a challenge that stops the run.
- refresh reads these the same way, so they stay current.

Live against gesetze.li into a local database: 0.110 (129 provisions), 641.291,
0.110.042.08 (4), 210.109, 210.111, 210.116 all store.

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

* feat(law): read a scanned cantonal document by OCR

LexFind document 13622 (a 881 KB scan, no text layer) failed as "no text in
the document": the cantonal importer had no OCR fallback. It now uses the
shared provisionsOfPdf (the commune loader's), reading German, French and
Italian together because the file's own language is not known. A scanned
version's source carries law-text-cantonal-2+ocr.

On the real scan: scanned, 2 articles (Geltungsdauer und Kuendigung, Aenderung
der Vereinbarung).

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

* docs(law): how Swiss communes publish their law — a survey of the 26 cantons

Five research passes, each reporting only what it opened. No canton hosts its
communes' law centrally except Basel-Stadt (3 communes). Two platforms span many
communes: LexWork (name.tlex.ch, about thirty found) and the i-web.ch CMS (about
fifty estimated). Basel-Landschaft's single CMS is behind a Cloudflare challenge,
reported and not worked around. Lists the order to build in and what is not verified.

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

* feat(law): read the communes' LexWork collections — Zug and Glarus, 14 communes, 1,164 acts with their dated versions

Many communes keep their law in a LexWork (Sitrox) collection at
<commune>.tlex.ch. The app's own JSON interface is open (no login; robots.txt
blocks only the search endpoints), so it is read as data: the list of acts,
each act by systematic number, the day each version took effect (versions are
dated by the publisher), and the article tree. Versions older than the
structured text are held as a PDF and read like any PDF.

- config LEXWORK: the 14 instances verified live (11 Zug communes, 3 Glarus), each
  an authority bfs<number>, within its canton; ACT_TEXT_FORMATS gains json.
- text/lexwork.ts (fetch, dates, versions, article tree), text/import-lexwork.ts.
- law:text lexwork [--host]; Law text load workflow source lexwork.
- Survey doc: the interface is confirmed open.

Live into a local database: Zug 50 versions then 0 failures, Glarus Nord 12 versions /
452 provisions, no failures. Integration test: old version ends the day before the
new one, a second run stores nothing.

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

* fix(law): a LexWork version that cannot be read no longer stops the current one

The first production load of Zug and Glarus stored 1,498 dated versions
(21,823 provisions) and left 4 acts without text: one old version of each
failed with "no text", and the loop, which stores oldest first, stopped
there and never reached the current version.

Each version is now read on its own: a failure is reported for that version
and the rest go on. A version the publisher holds with no text at all (Cham's
act 3-1 is a blank Word page published under a placeholder 1900 date) is
reported as emptyAtPublisher, not as a failure, and nothing is invented.

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

* feat(law): register the federal acts Fedlex lists and the register lacks; tell two acts of one number apart

The register of federal acts comes from LexFind, which lags Fedlex by days. Fedlex's
own list showed two acts the register did not hold (SR 0.973.276.71, 129.1) and one
number carried by two acts (SR 0.424.21: the 2005 framework agreement on nuclear-energy
research and its 2025 renewal), which the importer skipped, leaving the registered one
without any text.

The Fedlex text load now:
- tells two acts of one number apart by the address of their own Fedlex page (the
  register's official_url or ch_eli), never guessing; where the register cannot tell,
  the number is still reported ambiguous and left alone;
- registers any act Fedlex lists that the register lacks, from Fedlex's own list (title
  from the act's expression, ch_eli, its page), and reads it.

Against real Fedlex into a scratch database: 5,336 acts registered, none with a
placeholder title, SR 0.424.21 held as two acts with their 2005 and 2025 titles.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-01 21:49:08 +01:00
CatoandClaude Sonnet 5.5 6ec36ff7bf fix(law): a LexWork version that cannot be read no longer stops the current one (#376)
* feat(law): read scanned commune acts by OCR, and never drop text before a late first article

A commune that publishes a scan (pages as pictures, no text layer) failed as
"no text in the PDF": Vaduz 5, Schaan 4, Eschen 2, Schellenberg 2. The
commune loader now draws each page (unpdf + @napi-rs/canvas) and reads it with
tesseract.js in the act's language, in process: nothing to install on the box,
no model called. The version's source says so: law-text-publisher-1+ocr.

Schellenberg's hall regulation numbers sections "1." and "2." before an
"Art. 3"; the cutter kept Art. 3 and dropped the rest. When the first article
found is not article 1, the text before it is now kept as one provision.

Live on schellenberg.li: both scans read (2 of 2), 6 acts, 106 provisions.

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

* fix(law): an act's page address follows the register when the publisher's address changes

An act first listed at a wrong address kept it for ever: the register import
added a page address only for a new act. Schellenberg's 35 acts were first read
without the page's <base href> (fixed in #361) and stayed at /service/files/...,
so the load kept fetching a web page instead of the PDF ("Invalid PDF
structure" x35), and the official page shown to readers was a dead link.

For a known act, a different official_url now supersedes the old one and the
new is current; unchanged is untouched. Reproduced locally with stale
addresses: 35 corrected, 3 acts loaded, 55 provisions.

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

* fix(law): store a PDF's NUL as a space, and find Lilex pages the issue number does not give

Cantonal: a 47-page intercantonal annex (LexFind 24607) failed to insert. Its
PDF holds one NUL where a glyph has no character (a dash between two words),
and Postgres cannot store NUL. cleanPdfText and blockText replace it with a
space, so no reader can hit it.

Lilex: an act's page address came only from its Landesgesetzblatt issue.
- 59 acts had none (Austrian-era decrees, issues like 60/1): the publisher's own
  Gebietssystematik names each page; all 59 resolve (the act's listing, then each
  parent, once per listing).
- The EEA agreement's page is ...001, not ...000; found the same way (the first
  of the rows a treaty is listed under).
- Two acts have no consolidated page at all (a Bekanntmachung of 1941, a 2020
  EEA decision): the gazette entry links a PDF, which is read.
- gesetze.li answers an unknown address with a maintenance notice carrying the
  proof-of-work script; that is now "no page", not a challenge that stops the run.
- refresh reads these the same way, so they stay current.

Live against gesetze.li into a local database: 0.110 (129 provisions), 641.291,
0.110.042.08 (4), 210.109, 210.111, 210.116 all store.

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

* feat(law): read a scanned cantonal document by OCR

LexFind document 13622 (a 881 KB scan, no text layer) failed as "no text in
the document": the cantonal importer had no OCR fallback. It now uses the
shared provisionsOfPdf (the commune loader's), reading German, French and
Italian together because the file's own language is not known. A scanned
version's source carries law-text-cantonal-2+ocr.

On the real scan: scanned, 2 articles (Geltungsdauer und Kuendigung, Aenderung
der Vereinbarung).

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

* docs(law): how Swiss communes publish their law — a survey of the 26 cantons

Five research passes, each reporting only what it opened. No canton hosts its
communes' law centrally except Basel-Stadt (3 communes). Two platforms span many
communes: LexWork (name.tlex.ch, about thirty found) and the i-web.ch CMS (about
fifty estimated). Basel-Landschaft's single CMS is behind a Cloudflare challenge,
reported and not worked around. Lists the order to build in and what is not verified.

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

* feat(law): read the communes' LexWork collections — Zug and Glarus, 14 communes, 1,164 acts with their dated versions

Many communes keep their law in a LexWork (Sitrox) collection at
<commune>.tlex.ch. The app's own JSON interface is open (no login; robots.txt
blocks only the search endpoints), so it is read as data: the list of acts,
each act by systematic number, the day each version took effect (versions are
dated by the publisher), and the article tree. Versions older than the
structured text are held as a PDF and read like any PDF.

- config LEXWORK: the 14 instances verified live (11 Zug communes, 3 Glarus), each
  an authority bfs<number>, within its canton; ACT_TEXT_FORMATS gains json.
- text/lexwork.ts (fetch, dates, versions, article tree), text/import-lexwork.ts.
- law:text lexwork [--host]; Law text load workflow source lexwork.
- Survey doc: the interface is confirmed open.

Live into a local database: Zug 50 versions then 0 failures, Glarus Nord 12 versions /
452 provisions, no failures. Integration test: old version ends the day before the
new one, a second run stores nothing.

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

* fix(law): a LexWork version that cannot be read no longer stops the current one

The first production load of Zug and Glarus stored 1,498 dated versions
(21,823 provisions) and left 4 acts without text: one old version of each
failed with "no text", and the loop, which stores oldest first, stopped
there and never reached the current version.

Each version is now read on its own: a failure is reported for that version
and the rest go on. A version the publisher holds with no text at all (Cham's
act 3-1 is a blank Word page published under a placeholder 1900 date) is
reported as emptyAtPublisher, not as a failure, and nothing is invented.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-01 19:46:21 +01:00
CatoandClaude Sonnet 5.5 663afd685e feat(law): read the communes' LexWork collections — Zug and Glarus, 14 communes, 1,164 acts with dated versions (#374)
* feat(law): read scanned commune acts by OCR, and never drop text before a late first article

A commune that publishes a scan (pages as pictures, no text layer) failed as
"no text in the PDF": Vaduz 5, Schaan 4, Eschen 2, Schellenberg 2. The
commune loader now draws each page (unpdf + @napi-rs/canvas) and reads it with
tesseract.js in the act's language, in process: nothing to install on the box,
no model called. The version's source says so: law-text-publisher-1+ocr.

Schellenberg's hall regulation numbers sections "1." and "2." before an
"Art. 3"; the cutter kept Art. 3 and dropped the rest. When the first article
found is not article 1, the text before it is now kept as one provision.

Live on schellenberg.li: both scans read (2 of 2), 6 acts, 106 provisions.

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

* fix(law): an act's page address follows the register when the publisher's address changes

An act first listed at a wrong address kept it for ever: the register import
added a page address only for a new act. Schellenberg's 35 acts were first read
without the page's <base href> (fixed in #361) and stayed at /service/files/...,
so the load kept fetching a web page instead of the PDF ("Invalid PDF
structure" x35), and the official page shown to readers was a dead link.

For a known act, a different official_url now supersedes the old one and the
new is current; unchanged is untouched. Reproduced locally with stale
addresses: 35 corrected, 3 acts loaded, 55 provisions.

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

* fix(law): store a PDF's NUL as a space, and find Lilex pages the issue number does not give

Cantonal: a 47-page intercantonal annex (LexFind 24607) failed to insert. Its
PDF holds one NUL where a glyph has no character (a dash between two words),
and Postgres cannot store NUL. cleanPdfText and blockText replace it with a
space, so no reader can hit it.

Lilex: an act's page address came only from its Landesgesetzblatt issue.
- 59 acts had none (Austrian-era decrees, issues like 60/1): the publisher's own
  Gebietssystematik names each page; all 59 resolve (the act's listing, then each
  parent, once per listing).
- The EEA agreement's page is ...001, not ...000; found the same way (the first
  of the rows a treaty is listed under).
- Two acts have no consolidated page at all (a Bekanntmachung of 1941, a 2020
  EEA decision): the gazette entry links a PDF, which is read.
- gesetze.li answers an unknown address with a maintenance notice carrying the
  proof-of-work script; that is now "no page", not a challenge that stops the run.
- refresh reads these the same way, so they stay current.

Live against gesetze.li into a local database: 0.110 (129 provisions), 641.291,
0.110.042.08 (4), 210.109, 210.111, 210.116 all store.

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

* feat(law): read a scanned cantonal document by OCR

LexFind document 13622 (a 881 KB scan, no text layer) failed as "no text in
the document": the cantonal importer had no OCR fallback. It now uses the
shared provisionsOfPdf (the commune loader's), reading German, French and
Italian together because the file's own language is not known. A scanned
version's source carries law-text-cantonal-2+ocr.

On the real scan: scanned, 2 articles (Geltungsdauer und Kuendigung, Aenderung
der Vereinbarung).

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

* docs(law): how Swiss communes publish their law — a survey of the 26 cantons

Five research passes, each reporting only what it opened. No canton hosts its
communes' law centrally except Basel-Stadt (3 communes). Two platforms span many
communes: LexWork (name.tlex.ch, about thirty found) and the i-web.ch CMS (about
fifty estimated). Basel-Landschaft's single CMS is behind a Cloudflare challenge,
reported and not worked around. Lists the order to build in and what is not verified.

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

* feat(law): read the communes' LexWork collections — Zug and Glarus, 14 communes, 1,164 acts with their dated versions

Many communes keep their law in a LexWork (Sitrox) collection at
<commune>.tlex.ch. The app's own JSON interface is open (no login; robots.txt
blocks only the search endpoints), so it is read as data: the list of acts,
each act by systematic number, the day each version took effect (versions are
dated by the publisher), and the article tree. Versions older than the
structured text are held as a PDF and read like any PDF.

- config LEXWORK: the 14 instances verified live (11 Zug communes, 3 Glarus), each
  an authority bfs<number>, within its canton; ACT_TEXT_FORMATS gains json.
- text/lexwork.ts (fetch, dates, versions, article tree), text/import-lexwork.ts.
- law:text lexwork [--host]; Law text load workflow source lexwork.
- Survey doc: the interface is confirmed open.

Live into a local database: Zug 50 versions then 0 failures, Glarus Nord 12 versions /
452 provisions, no failures. Integration test: old version ends the day before the
new one, a second run stores nothing.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-01 18:52:17 +01:00
CatoandClaude Sonnet 5.5 9f46e1febf docs(law): how Swiss communes publish their law — a survey of the 26 cantons (#373)
* feat(law): read scanned commune acts by OCR, and never drop text before a late first article

A commune that publishes a scan (pages as pictures, no text layer) failed as
"no text in the PDF": Vaduz 5, Schaan 4, Eschen 2, Schellenberg 2. The
commune loader now draws each page (unpdf + @napi-rs/canvas) and reads it with
tesseract.js in the act's language, in process: nothing to install on the box,
no model called. The version's source says so: law-text-publisher-1+ocr.

Schellenberg's hall regulation numbers sections "1." and "2." before an
"Art. 3"; the cutter kept Art. 3 and dropped the rest. When the first article
found is not article 1, the text before it is now kept as one provision.

Live on schellenberg.li: both scans read (2 of 2), 6 acts, 106 provisions.

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

* fix(law): an act's page address follows the register when the publisher's address changes

An act first listed at a wrong address kept it for ever: the register import
added a page address only for a new act. Schellenberg's 35 acts were first read
without the page's <base href> (fixed in #361) and stayed at /service/files/...,
so the load kept fetching a web page instead of the PDF ("Invalid PDF
structure" x35), and the official page shown to readers was a dead link.

For a known act, a different official_url now supersedes the old one and the
new is current; unchanged is untouched. Reproduced locally with stale
addresses: 35 corrected, 3 acts loaded, 55 provisions.

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

* fix(law): store a PDF's NUL as a space, and find Lilex pages the issue number does not give

Cantonal: a 47-page intercantonal annex (LexFind 24607) failed to insert. Its
PDF holds one NUL where a glyph has no character (a dash between two words),
and Postgres cannot store NUL. cleanPdfText and blockText replace it with a
space, so no reader can hit it.

Lilex: an act's page address came only from its Landesgesetzblatt issue.
- 59 acts had none (Austrian-era decrees, issues like 60/1): the publisher's own
  Gebietssystematik names each page; all 59 resolve (the act's listing, then each
  parent, once per listing).
- The EEA agreement's page is ...001, not ...000; found the same way (the first
  of the rows a treaty is listed under).
- Two acts have no consolidated page at all (a Bekanntmachung of 1941, a 2020
  EEA decision): the gazette entry links a PDF, which is read.
- gesetze.li answers an unknown address with a maintenance notice carrying the
  proof-of-work script; that is now "no page", not a challenge that stops the run.
- refresh reads these the same way, so they stay current.

Live against gesetze.li into a local database: 0.110 (129 provisions), 641.291,
0.110.042.08 (4), 210.109, 210.111, 210.116 all store.

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

* feat(law): read a scanned cantonal document by OCR

LexFind document 13622 (a 881 KB scan, no text layer) failed as "no text in
the document": the cantonal importer had no OCR fallback. It now uses the
shared provisionsOfPdf (the commune loader's), reading German, French and
Italian together because the file's own language is not known. A scanned
version's source carries law-text-cantonal-2+ocr.

On the real scan: scanned, 2 articles (Geltungsdauer und Kuendigung, Aenderung
der Vereinbarung).

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

* docs(law): how Swiss communes publish their law — a survey of the 26 cantons

Five research passes, each reporting only what it opened. No canton hosts its
communes' law centrally except Basel-Stadt (3 communes). Two platforms span many
communes: LexWork (name.tlex.ch, about thirty found) and the i-web.ch CMS (about
fifty estimated). Basel-Landschaft's single CMS is behind a Cloudflare challenge,
reported and not worked around. Lists the order to build in and what is not verified.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-01 18:38:45 +01:00
CatoandClaude Sonnet 5.5 0709f41fcd feat(law): read a scanned cantonal document by OCR (#370)
* feat(law): read scanned commune acts by OCR, and never drop text before a late first article

A commune that publishes a scan (pages as pictures, no text layer) failed as
"no text in the PDF": Vaduz 5, Schaan 4, Eschen 2, Schellenberg 2. The
commune loader now draws each page (unpdf + @napi-rs/canvas) and reads it with
tesseract.js in the act's language, in process: nothing to install on the box,
no model called. The version's source says so: law-text-publisher-1+ocr.

Schellenberg's hall regulation numbers sections "1." and "2." before an
"Art. 3"; the cutter kept Art. 3 and dropped the rest. When the first article
found is not article 1, the text before it is now kept as one provision.

Live on schellenberg.li: both scans read (2 of 2), 6 acts, 106 provisions.

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

* fix(law): an act's page address follows the register when the publisher's address changes

An act first listed at a wrong address kept it for ever: the register import
added a page address only for a new act. Schellenberg's 35 acts were first read
without the page's <base href> (fixed in #361) and stayed at /service/files/...,
so the load kept fetching a web page instead of the PDF ("Invalid PDF
structure" x35), and the official page shown to readers was a dead link.

For a known act, a different official_url now supersedes the old one and the
new is current; unchanged is untouched. Reproduced locally with stale
addresses: 35 corrected, 3 acts loaded, 55 provisions.

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

* fix(law): store a PDF's NUL as a space, and find Lilex pages the issue number does not give

Cantonal: a 47-page intercantonal annex (LexFind 24607) failed to insert. Its
PDF holds one NUL where a glyph has no character (a dash between two words),
and Postgres cannot store NUL. cleanPdfText and blockText replace it with a
space, so no reader can hit it.

Lilex: an act's page address came only from its Landesgesetzblatt issue.
- 59 acts had none (Austrian-era decrees, issues like 60/1): the publisher's own
  Gebietssystematik names each page; all 59 resolve (the act's listing, then each
  parent, once per listing).
- The EEA agreement's page is ...001, not ...000; found the same way (the first
  of the rows a treaty is listed under).
- Two acts have no consolidated page at all (a Bekanntmachung of 1941, a 2020
  EEA decision): the gazette entry links a PDF, which is read.
- gesetze.li answers an unknown address with a maintenance notice carrying the
  proof-of-work script; that is now "no page", not a challenge that stops the run.
- refresh reads these the same way, so they stay current.

Live against gesetze.li into a local database: 0.110 (129 provisions), 641.291,
0.110.042.08 (4), 210.109, 210.111, 210.116 all store.

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

* feat(law): read a scanned cantonal document by OCR

LexFind document 13622 (a 881 KB scan, no text layer) failed as "no text in
the document": the cantonal importer had no OCR fallback. It now uses the
shared provisionsOfPdf (the commune loader's), reading German, French and
Italian together because the file's own language is not known. A scanned
version's source carries law-text-cantonal-2+ocr.

On the real scan: scanned, 2 articles (Geltungsdauer und Kuendigung, Aenderung
der Vereinbarung).

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-01 11:15:13 +01:00
CatoandClaude Sonnet 5.5 c968dcab29 fix(law): store a PDF's NUL as a space, and find the Lilex pages the issue number does not give (#369)
* feat(law): read scanned commune acts by OCR, and never drop text before a late first article

A commune that publishes a scan (pages as pictures, no text layer) failed as
"no text in the PDF": Vaduz 5, Schaan 4, Eschen 2, Schellenberg 2. The
commune loader now draws each page (unpdf + @napi-rs/canvas) and reads it with
tesseract.js in the act's language, in process: nothing to install on the box,
no model called. The version's source says so: law-text-publisher-1+ocr.

Schellenberg's hall regulation numbers sections "1." and "2." before an
"Art. 3"; the cutter kept Art. 3 and dropped the rest. When the first article
found is not article 1, the text before it is now kept as one provision.

Live on schellenberg.li: both scans read (2 of 2), 6 acts, 106 provisions.

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

* fix(law): an act's page address follows the register when the publisher's address changes

An act first listed at a wrong address kept it for ever: the register import
added a page address only for a new act. Schellenberg's 35 acts were first read
without the page's <base href> (fixed in #361) and stayed at /service/files/...,
so the load kept fetching a web page instead of the PDF ("Invalid PDF
structure" x35), and the official page shown to readers was a dead link.

For a known act, a different official_url now supersedes the old one and the
new is current; unchanged is untouched. Reproduced locally with stale
addresses: 35 corrected, 3 acts loaded, 55 provisions.

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

* fix(law): store a PDF's NUL as a space, and find Lilex pages the issue number does not give

Cantonal: a 47-page intercantonal annex (LexFind 24607) failed to insert. Its
PDF holds one NUL where a glyph has no character (a dash between two words),
and Postgres cannot store NUL. cleanPdfText and blockText replace it with a
space, so no reader can hit it.

Lilex: an act's page address came only from its Landesgesetzblatt issue.
- 59 acts had none (Austrian-era decrees, issues like 60/1): the publisher's own
  Gebietssystematik names each page; all 59 resolve (the act's listing, then each
  parent, once per listing).
- The EEA agreement's page is ...001, not ...000; found the same way (the first
  of the rows a treaty is listed under).
- Two acts have no consolidated page at all (a Bekanntmachung of 1941, a 2020
  EEA decision): the gazette entry links a PDF, which is read.
- gesetze.li answers an unknown address with a maintenance notice carrying the
  proof-of-work script; that is now "no page", not a challenge that stops the run.
- refresh reads these the same way, so they stay current.

Live against gesetze.li into a local database: 0.110 (129 provisions), 641.291,
0.110.042.08 (4), 210.109, 210.111, 210.116 all store.

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

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-11-01 10:28:00 +01:00