Repository navigation
Description
Epic: #148 · Depends on S3 · Closes C-66, C-68
Background
The ADR-011 GAUL lookup (data/gaul_lookup.parquet, 888 KB, 64,742 rows) is read three times per contract run:
| Site | What it does | Used by the contract path? |
|---|---|---|
managers/unfao.py:98 |
self._enricher = GaulLookupEnricher() — eager, unconditional; reads the parquet into pandas at enrichment.py:48 |
No |
managers/unfao.py:460 |
pq.read_table(_DEFAULT_LOOKUP) → wire_sink.deliver_run |
yes |
managers/unfao.py:612 |
pq.read_table(_DEFAULT_LOOKUP) → historical.build_historical_table |
yes |
So every run pays three reads of one artifact, one of them into a representation the delivery no longer uses. After S1 deletes _append_metadata, GaulLookupEnricher's only remaining consumer is scripts/build_gaul_lookup.py's tests and the enricher's own suite.
Separately, _DEFAULT_LOOKUP is a private name imported across module boundaries — defined enrichment.py:33, imported managers/unfao.py:18, used at :460 and :612. The leading underscore says "internal"; three modules depend on it. A refactor splitting enrichment.py (#89) is entitled to move or rename it and would break two live call sites silently.
Work
- Remove
self._enricher = GaulLookupEnricher()from__init__(:98) — the contract path never uses the instance - Promote the lookup path to a declared public constant.
unfao/product.pyis the declared home for delivery declarations (its docstring: "Everything here is a declaration, never an inference") — the artifact a delivery depends on belongs there, not behind an underscore in the enricher - Read the table once per run and pass it to both consumers —
deliver_runandbuild_historical_tablealready takelookupas a parameter (DIP, established bywire/sidecar.py:10-13), so this is threading one value, not a redesign - Leave
GaulLookupEnricheritself in place — it is still the build/verification path's object andtests/test_enrichment.py(159 lines) covers it. Its retirement is S4 — enrichment.py: numpy/pyarrow keyed gather (drop pandas merge) #89's business.
Acceptance criteria
- The lookup parquet is read once per delivery run — asserted by test (count reads, or assert the same object reaches both consumers)
- No underscore-prefixed name is imported across a module boundary:
grep -rn "import _\|import .*, _" views_postprocessing/clean for this case -
GaulLookupEnricheris not instantiated on the delivery path -
tests/test_gaul_lookup_fidelity.py(18 tests) still green — it imports the lookup path and must follow the rename
Testing / validation
ruff check . · full suite green · byte-parity e2e green — the sidecar is built from this table, so a threading mistake would show up as changed bytes.
Activity
refactor(unfao): S4 — the GAUL lookup is one artifact, read once, pub…
Polichinel commentedon Jul 31, 2026
Done in PR #162 (merged to
development). Three reads per delivery → one;_DEFAULT_LOOKUP→ publicgaul_lookup.LOOKUP_PATH; the pandas enricher leaves the delivery path entirely. Register C-66 and C-68 closed.C-60 deliberately left open:
version()still degrades to"unknown"silently — it was moved verbatim, because moving and changing behaviour in one commit is the discipline S5 depends on. Documented at its new home with a pointer to C-60's scope.