Skip to content

Check CBS codes and implausible dates; sweep 90 days weekly - #323

Merged
joepio merged 3 commits into
mainfrom
claude/project-thread-ufkjn9
Oct 5, 2026
Merged

joepio merged 3 commits into
mainfrom
claude/project-thread-ufkjn9

Conversation

@joepio

@joepio joepio commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Requested by Joep · project thread

Two responses to VNG's weekly status of 28 September, in separate commits.

1. CBS codes and implausible future dates

Before: Dordrecht had no cbsId in /api/status, so VNG's weekly check drops it from municipal coverage. Oirschot's newest content was 1 January 2078 (an ingekomen stuk whose iBabs "Datum" field reads 1-1-2078), and it heads every date-sorted search for Oirschot. VNG reports Schiermonnikoog with a 2099 date as well.

After: Dordrecht carries GM0505, and a catalog test fails when any gemeente lacks a well-formed, unshared GM code (the Amsterdam stadsdelen under GM0363 excepted). A date more than two years ahead is treated as a typo at the source.

How:

  • src/util/plausible_date.ts: the two-year horizon.
  • iBabs register entries whose date field is beyond it fall back to the entry's MutationDate.
  • Projection leaves start_date and document_month empty for such a date (sorts last instead of first).
  • /api/status computes latestContentDate in its own query bounded to the horizon, so rows already in the index with 2078 or 2099 stop reporting it as soon as this deploys. Kept separate from the last_indexed query because a range clause would drop rows without start_date from that one.

The Oirschot row in the index keeps its 2078 sort date until the entry is imported again. A manual import for Oirschot with a window covering that entry's MutationDate (or the next projection bump) fixes it.

2. Weekly 90-day sweep

Before: the nightly import only looks at meetings from 7 days back to 7 days ahead. Documents a council attaches to a meeting weeks later (besluitenlijsten, notulen, answers) are never imported, and the weekly coverage check counts them as missing. VNG saw the gaps grow by 677 documents across 179 municipalities in one week.

After: on Saturday night the scheduler also enqueues the 90..8 days before the nightly window for every source, so Sunday's coverage check measures what it found.

How: scheduledWindows() in src/scheduler.ts returns the nightly window, plus the adjacent sweep window on Saturdays (Europe/Amsterdam). Runs are ordinary scheduled / full runs, so blocklist checks, the S3 cache shortcut and iBabs pacing all apply unchanged. The existing "skip while scheduled runs are still active" guard covers both windows.

This is a hypothesis from the code, not yet measured: if the gaps in coverage do not shrink after the first Saturday, the cause lies elsewhere.

Tests: touched suites (plausible_date, registers, motions, source_catalog, status_api, scheduler, ingest_scheduler, scheduler_backfill_isolation) pass, deno check on all tests, oxlint, oxfmt on changed files, vite build.

VNG's weekly status of 28 September flagged Dordrecht without a CBS code
and Oirschot (2078) and Schiermonnikoog (2099) with content dated decades
ahead.

- Dordrecht gets GM0505; a catalog test now requires every gemeente to
  carry a well-formed, unshared GM code (Amsterdam's stadsdelen excepted).
- A date more than two years ahead is treated as a typo: an iBabs register
  entry falls back to its MutationDate, projection leaves start_date and
  document_month empty, and /api/status bounds latestContentDate so rows
  already indexed with such a year no longer report it.
@joepio joepio self-assigned this Sep 28, 2026
Councils attach besluitenlijsten, notulen and answers to meetings weeks
after they took place. The nightly -7..+7 day window has moved past those
meetings by then, so the documents were never imported, and the weekly
coverage check (12 months back) counted them as missing: VNG's status of
28 September saw the gaps grow by 677 documents across 179 municipalities
in one week.

On Saturday night the scheduler now also enqueues the 90..8 days before the
nightly window, so Sunday's coverage check measures the result. Documents
already held come from the object-store cache.
@joepio joepio changed the title Check CBS codes and implausible future dates Check CBS codes and implausible dates; sweep 90 days weekly Sep 28, 2026
@joepio
joepio marked this pull request as ready for review October 5, 2026 10:57
@joepio
joepio merged commit 56fe196 into main Oct 5, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants