EITI: accept a derived us_ein alongside registeredAs (fixes the shippable half of #26) - #46
Merged
StephenAbbott merged 1 commit intoJul 18, 2026
Conversation
US EITI identifications are federal EINs in NN-NNNNNNN form, not the state-registry numbers GLEIF publishes as registeredAs, so US subjects never joined the committed EITI index. Wire an EIN path: - eiti.py: fetch_by_registration accepts a derived `us_ein` tried alongside registeredAs. Matching stays country-scoped and (via the existing _norm_forms digit-stripping) punctuation-insensitive, so a dashed EIN joins the index cleanly. - lookup.py: add US -> us_ein to _EITI_IDENTIFIER_KEY_BY_COUNTRY so a US match corroborates on the EIN, and let a derived us_ein trigger EITI dispatch / be passed through. Tests cover dashed-EIN normalisation, country-scoped matching with wrong-EIN and wrong-country decoys, the us_ein dispatch/hit wiring, and the widened conservative-key map. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Implements #26's "at minimum" tier plus the consumption half of Option A — deliberately not the whole thing; the boundary and why below.
What's in
fetch_by_registration(country, registration_number, us_ein=...):registeredAspath byte-identical and tried first; when it misses, the EIN is tried through the same country-scoped, punctuation-insensitive_match_identification(your_norm_formsclaim held — the committed artifact stores dashed EINs, and both42-1638663and421638663match Alpha Natural Resources).US: "us_ein"in_EITI_IDENTIFIER_KEY_BY_COUNTRY(so_bh_eiticorroborates on the EIN, per the issue's exact map entry), and the EITI dispatch fires on a derivedus_eineven withoutregisteredAs.registeredAsdecoy absent from the US bucket so the positive match provably comes from the EIN path. Wiring tests each go red with the implementation reverted.What's deliberately out, and why
EDGAR-side EIN derivation (
ctx.derived["us_ein"]has no producer yet, so live US subjects don't match end-to-end from this PR alone — "an EIN arriving from any source joins cleanly" is what's true today, which is the issue's own "once derived" framing). Two structural reasons rather than scope-dodging:_dispatchruns before any EDGAR resolution exists in the loop (CIK lands mid-loop or in the post-loop fallback), so feeding EITI needs a post-loop re-dispatch; andsec_edgar.pycurrently extracts no EIN at all — that's new API surface (company facts, live-network-gated). Happy to take that as its own PR if you want to settle the re-dispatch shape; same for part 2, which your issue conditions on the upstream filter fix.Two follow-up notes for whenever derivation lands: the dispatch condition isn't country-gated (a stray non-US
us_einwould harmlessly dispatch-and-miss — the scope lives in the matcher), and the BODS mapper's_EITI_SCHEME_BY_COUNTRYhas no US entry (plusus_einisn't in reconcile's_STRONG_KEYS), so reconcile-level merge keys won't fire on EINs yet.Suite: 2358 → 2364, 0 failed.
Generated by Claude Fable 5 (brief, review), Claude Opus 4.8 (implementation)