Skip to content

Stage 3 — Swap _append_metadata to the lookup enricher #24

@Polichinel

Description

@Polichinel

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

  1. The swap_append_metadata uses 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).
  2. mapping.py stays in the repo, inert. Not deleted, not selectable by config — one live truth (umbrella: deletion is a separate decision after one verified production cycle).
  3. 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.
  4. 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.py now 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions