Repository navigation
Description
Stage 3 — Swap _append_metadata to the lookup enricher
Part of the FAO global delivery plan — umbrella: #20. Hard-gated on Stage 2 (#23): zero unexplained differences. This is the ONLY behavioral code change in the entire delivery plan.
Why this exists
After Stages 0–2, the lookup enricher is built, tested, and characterized against real production output. This stage makes it live: _append_metadata() (views_postprocessing/unfao/managers/unfao.py:140-163) stops calling the runtime mapper and calls the enricher. Everything upstream (_read) and downstream (_validate, _save) is untouched — the validation gate (unfao.py:188-221) keeps guarding exactly as before, and because the enricher surfaces unknown gids as nulls (pinned by a Stage-1 test), the fail-loud guarantee survives the swap.
Spec
- The swap —
_append_metadatauses the Stage-1 enricher. The mapper import (get_default_mapper,unfao.py:19,41) goes away from the manager; with it goes the import-time loading of 774 MB of shapefiles (register C-02's trigger in this code path). mapping.pystays in the repo, inert. Not deleted, not selectable by config — one live truth (umbrella: deletion is a separate decision after one verified production cycle).- Delete the dead commented-out config blocks
unfao.py:80-107(two alternative AppwriteConfig blocks). This is D-09's only "do now" exception: they are a mis-uncomment hazard during exactly this kind of high-stakes week, and removing comments is zero-risk. - Re-run africa_me_legacy on the production machine — same procedure as Stage 0.
Verification (definition of done)
- Full test suite green (the boundary-contract tests in
tests/test_integration.pynow exercise the enricher path) - Production africa_me run green end to end
- Output schema (columns, dtypes, index) identical to the Stage-0
baseline_schema.md— byte-for-byte on the schema, values differing only per the Stage-2 explained classes - Runtime and memory recorded and compared to the Stage-0 numbers (expect enrichment to collapse from minutes/hours to seconds)
- Revert path documented below, verified to be a single commit
- Umbrella [UMBRELLA] FAO global delivery: lookup-based enrichment (ADR-011) + global coverage #20 updated — this unblocks Stage 4 (views-models, #LINK_G)
Revert path
This change must land as one commit touching only unfao.py (method body + dead-block deletion) so that git revert <sha> restores the mapper path instantly. If anything looks wrong in the verification run, revert first, diagnose second.
Explicitly NOT in this issue
- No region change (that is Stage 4, views-models)
- No deletion of
mapping.py, shapefiles, or geopandas from dependencies (post-cycle decision) - No store/Appwrite changes, no multi-store
DeliveryProfile(register C-33, deferred per D-09) - No fixes to the pipeline-core read path (C-26..C-29, deferred)
Activity
Polichinel commentedon Jun 26, 2026
Smoke-test result — enrichment verified (with one benign caveat)
Ran the
africa_me_legacysmoke test from views-models (postprocessors/un_fao). Because the full delivery is blocked on forecast-path config (below), I verified the #24 enrichment in isolation via a historical-only path (_read_historical_data→_append_metadata, no forecast, no upload):GaulLookupEnricherloaded64742 cellsfromgaul_lookup.parquet(version=land_gaul@f74d3b2b).africa_me_legacyactuals: 5,729,070 rows (13,110 cells × 437 months).country_iso_a3,admin0/1/2_gaul*, coords. Spot-check correct (ZAF → Western Cape → South Africa → Overberg). Exit 0.✅ The geopandas-mapper →
GaulLookupEnricherswap produces correct output.One benign coverage caveat
2,185 rows = exactly 5 cells have no GAUL-lookup match (enricher warns "will fail validation"). Mapped to coords they are remote islands / offshore ocean:
62356= Marion Island / Prince Edward Is. (−46.75, +37.75); the other 4 are offshore Madagascar/Namibia. These are the "land cells GAUL doesn't cover" (cf. #127's 82-globally note). Not an enrichment bug — an artifact of the oldafrica_me_legacyregion. It self-resolves underland_gaul(that region excludes uncovered cells upstream). A fullafrica_me_legacydelivery would fail completeness validation on these 5 until they're excluded — please confirm the un_fao validation excludes GAUL-uncovered cells.Forecast-path findings (NOT #24 — found en route)
APPWRITE_PROD_FORECASTS_COLLECTION_ID='forecasts_metadata'is wrong — that collection doesn't exist in the live Appwrite. The README value is not canonical; please correct it.{category: forecast, name: <ensemble>}); the configured ensemble (rusty_bucket) produces no forecast, so the delivery's forecast half can't run until a real-forecast ensemble is referenced or one is delivered.artifacts,notebooks,reports,data/{generated,processed,raw}) —PostprocessorPathManagerfails without them. Created on the views-models side.Recommendation
Closeable as enrichment-verified, provided the validation excludes the GAUL-uncovered cells (cleanest under
land_gaul, views-models#127). Suggest a fail-loud startup check for credentials + collection existence, and a dry-run/skip-upload flag (there's none today). Full evidence in views-modelsreports/un_fao_delivery_{prerun,postrun}_postmortem.md.Polichinel commentedon Jun 26, 2026
Done and verified. The
_append_metadataswap toGaulLookupEnricheris live ondevelopment; the un_faoafrica_me_legacysmoke test (post-run postmortem, 2026-06-26) confirmed correct enrichment of 5.7M real actuals (64,742 cells, sample assignments correct). One benign coverage caveat: 5 sub-Antarctic ocean cells have no GAUL match — these are the GAUL-uncovered cells excluded by construction underland_gaul(S4/C-30), not an enrichment bug. Closing — this unblocks views-models#127 (the land_gaul go-global flip).