Repository navigation
refactor(unfao): S4 — the GAUL lookup is one artifact, read once, publicly named - #162
Merged
Merged
Conversation
…licly named Closes #152; closes register C-66 and C-68. Epic #148. The 888 KB lookup was read three times per delivery: once eagerly in the manager's __init__ into a GaulLookupEnricher the contract path never used, then twice more through pyarrow, once per consumer. The path that reached those consumers was _DEFAULT_LOOKUP — a leading-underscore name imported across three module boundaries, so a refactor entitled to move it would have broken live call sites. Both trace to the same mistake: the artifact's identity was owned by one of its consumers. lookup_version was a @staticmethod on the enricher that never touched the instance — a fact about the artifact wearing the enricher's coat. New unfao/gaul_lookup.py holds that identity: LOOKUP_PATH (public), version() and load(). _save_contract reads once and threads the table to both consumers, each of which already accepted it as a parameter (DIP) — so this is threading one value, not a redesign. The pandas enricher leaves the delivery path entirely. GaulLookupEnricher is NOT retired — it remains the build/verification path's object, covered by test_enrichment.py. What changed is that it no longer owns the artifact. Its _read_version delegates rather than duplicating, and a test asserts both routes report the same stamp, so provenance cannot differ by which path produced it. C-60 deliberately NOT fixed here. version() still reaches three levels into views-datafactory's ledger shape and degrades to "unknown" silently. It was moved VERBATIM — moving and changing behaviour in one commit is exactly what S5 must not do, and the same discipline applies here. The limitation is documented at its new home with a pointer to C-60's own scope. tests/test_gaul_lookup_access.py pins the fix rather than the symptom: one declared home, a source-scan asserting exactly one gaul_lookup.load() in the manager, and a signature check that both consumers still ACCEPT the table rather than fetching it — so a revert to per-consumer reads fails loudly instead of quietly restoring the count. ruff clean; 295 passed, 41 xfailed, 5 known local pyarrow byte-parity failures (CI authoritative). No file under wire/ or fixtures/ touched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #152 · Epic #148 · Register C-66 and C-68 closed
Both concerns, one root cause
The artifact's identity was owned by one of its consumers.
_DEFAULT_LOOKUP— private, imported across 3 modulesgaul_lookup.LOOKUP_PATH— public, declared@staticmethodonGaulLookupEnricherthat never touched the instancegaul_lookup.version()lookup_versionwas a fact about the artifact wearing the enricher's coat. Newunfao/gaul_lookup.pyholds that identity — path, version, oneload()._save_contractreads once and threads the table to both consumers, each of which already accepted it as a parameter (DIP), so this threads one value rather than redesigning anything.GaulLookupEnricheris not retiredIt remains the build/verification path's object, covered by
test_enrichment.py. What changed is that it no longer owns the artifact. Its_read_versiondelegates rather than duplicating, and a test asserts both routes report the same stamp — otherwise provenance could differ depending on which path produced it.What I deliberately did not fix
C-60 stays open.
version()still reaches three levels into views-datafactory's ledger shape and degrades to"unknown"silently. It was moved verbatim.Moving and changing behaviour in one commit is exactly what S5 must not do; the same discipline applies here. The limitation is documented at its new home with a pointer to C-60's own scope, so the next reader finds it rather than rediscovering it.
Tests pin the fix, not the symptom
tests/test_gaul_lookup_access.py— one declared home; a source-scan asserting exactly onegaul_lookup.load()in the manager; and a signature check that both consumers still accept the table rather than fetching it. That last one matters: without it, a revert to per-consumer reads would quietly restore the count and the "one read" assertion would be the only thing standing, which a well-meaning refactor could satisfy while re-introducing the problem elsewhere.Verification
ruffclean · 295 passed, 41 xfailed · the 5 failures are the known local pyarrow byte-parity tests; CI authoritative · no file underwire/orfixtures/touched.Register: 71 concerns, 29 open, 42 resolved. Integrity guard green.
🤖 Generated with Claude Code