Skip to content

[Global-PGM S1] Global metadata bundle via interim GAUL→ISO3 crosswalk (#231) - #238

Merged
Polichinel merged 3 commits into
developmentfrom
feat/global-pgm-s1-metadata-regen
Jul 21, 2026
Merged

[Global-PGM S1] Global metadata bundle via interim GAUL→ISO3 crosswalk (#231)#238
Polichinel merged 3 commits into
developmentfrom
feat/global-pgm-s1-metadata-regen

Conversation

@Polichinel

Copy link
Copy Markdown
Contributor

Closes #231. Part of epic #230 (tracker #237).

What

The viewser pg_metadata queryset is still Africa+ME at the source (verified: 11,169,720 rows = 13,110 cells × 852 months), while the platform's data supply — views-datafactory, which the models already consume — is global and GAUL-coded. Per the decision on #231, the bundled priogrid.parquet is now built from the factory's harvested GAUL-2024 admin assets via an explicitly interim crosswalk: GAUL iso3_code → VIEWS isoabcountry_id, duplicate isoab resolved to the most-recently-observed entity.

Numbers

  • Bundle: 13,110 → 66,205 cells; rusty_bucket global-forecast coverage 20.2% → 99.5% (Ukraine et al. now resolve, incl. future months).
  • Regression vs the old bundle on the Africa+ME overlap: 98.8% identical; 157 border cells differ (GAUL 2024 vs VIEWS DB borders, e.g. the Aouzou strip), 122 old cells now unmatched (disputed-territory class: Western Sahara 101, Hala'ib 8…). All declared in the stamp's new priogrid_source block (source sha256s, crosswalk rule, per-code unmatched histogram).
  • Country table: byte-identical (still the global viewser country queryset).

Changes

  • scripts/build_entity_metadata.py: source seam (--priogrid-source datafactory|viewser, legacy queryset kept); pure read_gaul_cells / active_country_by_isoab / crosswalk_priogrid; ≥50k-cell floor guard; no machine-local paths in committed provenance.
  • Runtime accessors: untouched — they depend only on the bundle schema contract, which is the containment story for the coding transition (register C-211, new).
  • Tests: 3 new pure crosswalk tests; test_sample_scale.py decoupled from bundle size (fixed 13,110-gid subset, pinned budget); stamp required-fields updated.

Ritual

review-diff: REVIEW → 1 warning (local path in stamp) + 2 suggestions addressed; re-run verified. ship-it: ruff clean, 365 passed (2 skipped, 1 xfailed).

🤖 Generated with Claude Code

…swalk (#231)

The viewser pgm loa is still Africa+ME-bounded, but the platform's data
supply (views-datafactory, which the models already consume) is global and
GAUL-coded. Rebuild the bundled priogrid table from the factory's harvested
GAUL-2024 admin assets: iso3_code → VIEWS isoab → country_id, duplicate
isoab resolved to the most-recently-observed entity. 13,110 → 66,205 cells;
rusty_bucket global forecast coverage 20.2% → 99.5%. Declared, not silent:
the stamp's new priogrid_source block records source sha256s, the crosswalk
rule, and exactly which codes could not map (disputed/non-VIEWS territories,
~0.5% of land cells). Explicitly an INTERIM handover (decision on #231):
runtime accessors depend only on the bundle schema, so the eventual platform
coding standard lands as a build-script-only change (register C-211).

Build script gains the source seam (--priogrid-source datafactory|viewser,
legacy queryset kept); pure crosswalk functions unit-tested; sample-scale
canary decoupled from bundle size (fixed 13,110-gid subset, pinned budget).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 20, 2026
@Polichinel

Copy link
Copy Markdown
Contributor Author

Max-effort review follow-up: all 15 findings are now tracked as actionable issues (13 in-repo: #239 #240 #241 #242 #243 #244 #245 #246 #247 #248 #249 #250 #251; 2 cross-repo: views-platform/views-datafactory#341, views-platform/views-postprocessing#123). #239#250 are candidates to fix on this branch pre-merge; #251 is a standalone efficiency follow-up.

Polichinel and others added 2 commits July 21, 2026 01:27
…e nets (#239#250)

Executes 12 of the 13 issues from the PR #238 max-effort review, in
dependency order, with one bundle regeneration:

Crosswalk behavior: iso3 normalized once — bucket, map, and histogram read
the same stripped value (#241); read_gaul_cells validates gid uniqueness,
set-identity across the two harvest files, and full 259,200-cell
completeness at cause (#240, #239 — the 50k output floor is demoted to
defence-in-depth); active-active isoab collisions raise instead of silently
relabelling a country (#242); unmatched_iso3 is deterministically ordered
by (-count, code) so the committed stamp is byte-reproducible (#243);
harvest filenames live in one GAUL_HARVEST_FILES constant consumed by both
the reader and the sha256 provenance (#244).

Stamp contract: querysets reported per actual branch; per-source inner-key
contract validated at write time; max_month_id.priogrid nullability
documented and tested; coverage accounting pinned by the 259,200 partition
identity (#246). The GAUL Kosovo→Serbia absorption (10 cells, VIEWS 232 →
233) is declared in known_gaul_absorptions and validated against the built
table every regen (#249).

Nets: priogrid row floor (>60k) + continental canaries (#245); sample-scale
canary comment corrected to the measured 235,440 cell-frames and its scope
boundary documented (#247).

Words: coverage prose now states both denominators — 99.50% of the 64,818-
cell forecast region (322 unmatched) vs 29,373 of 95,578 GAUL land cells
grid-wide, Antarctica-dominated (#248); register C-112/C-22 no longer
contradict C-211 and the header date is current (#250).

Parquet bytes unchanged (normalization is a no-op on the clean harvest);
stamp regenerated once with the new ordering + declarations. 378 tests
green (13 new).

Closes #239, closes #240, closes #241, closes #242, closes #243,
closes #244, closes #245, closes #246, closes #247, closes #248,
closes #249, closes #250.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Follow-up medium review of the hardening batch surfaced 8 findings; all
addressed:

The absorption net now checks BOTH directions: forward (declared Kosovo
gids map to Serbia, Kosovo empty) and reverse — every active, assignable
country with zero cells must be declared. First real run of the reverse
check immediately caught what the one-way net could not see: Luxembourg,
Singapore, and The Gambia are active countries GAUL majority-coding folds
entirely into neighbours, and the SUN/YUG codes are dead in GAUL 2024 —
all now declared in the stamp's new declared_zero_cell_countries block
(with four unique-ISO retired states), each with its reason.

Also: Kosovo stamp test gains the datafactory skip-guard its siblings had
and now binds the absorbed gids to the declared absorber (SRB), not merely
to 'one uniform country'; the absorption 'cells' count is derived from the
gid list (stamped_absorptions) instead of hand-maintained; null month_id
rows are refused at the resolver door (they would bypass the collision
guard yet win the sort — latent, now closed); the coverage test reads the
required-key contract and PRIO_GRID_N_CELLS from the script instead of
re-typing them; the full-harvest test reuses _write_harvest; _load_script
is lru_cached (13 re-execs -> 1, ~245ms CI saved, verified mutation-free).

Bundle regenerated: parquets byte-identical, stamp gains the zero-cell
declarations. 382 tests green (4 new).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Polichinel
Polichinel merged commit ac3d332 into development Jul 21, 2026
1 check passed
@Polichinel
Polichinel deleted the feat/global-pgm-s1-metadata-regen branch July 21, 2026 00:16
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.

1 participant