Files
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

87 lines
3.3 KiB
YAML

name: Data refresh
# The generated datasets (the world's profiles and countries, every country's
# subdivisions, the world list's photographs, the plan for every country's
# law) were refreshed only when someone ran their generators on a laptop, in
# an order nobody wrote down. This runs them every month, in order
# (`pnpm run data:refresh`, scripts/data-refresh.ts), and opens a pull request
# when anything changed. The sweep merges it when CI is green, and the deploy's
# places-data job imports what changed. A generator that fails keeps its old
# files; the PR body names it.
#
# TOKEN: FLEET_PAT when the org secret exists, else GITHUB_TOKEN, as in
# auto-merge.yml and bitbaum/substrata's recheck-data.yml. Prefer the PAT: a
# push or a PR made with GITHUB_TOKEN triggers no workflows, so CI would never
# run on the data commit.
on:
schedule:
# The 4th of each month, 03:41 UTC.
- cron: "41 3 4 * *"
workflow_dispatch:
inputs:
only:
description: "Only these generators, comma-separated (empty: all; see `pnpm run data:refresh --list`)"
required: false
default: ""
permissions:
contents: write
pull-requests: write
concurrency:
group: data-refresh
cancel-in-progress: false
jobs:
refresh:
runs-on: ubuntu-latest
timeout-minutes: 120
env:
GH_TOKEN: ${{ secrets.FLEET_PAT || github.token }}
steps:
- uses: actions/checkout@v7
with:
token: ${{ secrets.FLEET_PAT || github.token }}
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v7
with:
node-version-file: .nvmrc
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Run the generators
env:
ONLY: ${{ inputs.only }}
run: |
set -o pipefail
[[ -z "$ONLY" || "$ONLY" =~ ^[a-z0-9,-]+$ ]] || { echo "only: generator keys, comma-separated"; exit 1; }
only=""; [ -n "$ONLY" ] && only="--only $ONLY"
# A failed generator keeps its files; the rest are still committed.
pnpm run data:refresh $only 2>&1 | tee report.txt || true
pnpm exec prettier --write data/world data/places/world data/law src/lib/config/world/extras.json >/dev/null
- name: Open a pull request with what changed
run: |
if git diff --quiet; then
echo "Nothing changed." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
day=$(date -u +%F)
branch="bot/data-refresh-$day"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git switch -c "$branch"
git add -A data src/lib/config/world/extras.json
git commit -q -m "data: refresh $day (scheduled)" \
-m "pnpm run data:refresh; see the pull request for any generator that failed."
git push origin "HEAD:$branch"
{
echo "The monthly refresh of the generated datasets (\`.github/workflows/data-refresh.yml\`, \`pnpm run data:refresh\`)."
echo
git diff --stat HEAD~1 | tail -n 20 | sed 's/^/ /'
echo
grep -E "^FAILED|every generator ran" report.txt || true
} > body.md
gh pr create --base main --head "$branch" --title "data: refresh $day" --body-file body.md