Skip to content

refactor(unfao): S4 — the GAUL lookup is one artifact, read once, publicly named - #162

Merged
Polichinel merged 1 commit into
developmentfrom
feat/s4-lookup-access-hygiene
Jul 31, 2026
Merged

Polichinel merged 1 commit into
developmentfrom
feat/s4-lookup-access-hygiene

Conversation

@Polichinel

Copy link
Copy Markdown
Collaborator

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.

before after
reads per delivery 3 1
the path _DEFAULT_LOOKUP — private, imported across 3 modules gaul_lookup.LOOKUP_PATH — public, declared
the version stamp @staticmethod on GaulLookupEnricher that never touched the instance gaul_lookup.version()
pandas on the delivery path yes (the eager enricher) none

lookup_version was a fact about the artifact wearing the enricher's coat. New unfao/gaul_lookup.py holds that identity — path, version, one load(). _save_contract reads 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.

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 — 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 one gaul_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

ruff clean · 295 passed, 41 xfailed · the 5 failures are the known local pyarrow byte-parity tests; CI authoritative · no file under wire/ or fixtures/ touched.

Register: 71 concerns, 29 open, 42 resolved. Integrity guard green.

🤖 Generated with Claude Code

…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>
@Polichinel
Polichinel merged commit 5dc4443 into development Jul 31, 2026
4 checks passed
@Polichinel
Polichinel deleted the feat/s4-lookup-access-hygiene branch July 31, 2026 19:13
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