Skip to content

S3 — Collapse the two extraction seams into one #151

Closed

Description

@Polichinel

Epic: #148 · Depends on S1 · Closes C-65

Background

ADR-012 designates unfao/extraction.py as "the single pandas-aware module" — the one place a representation change lands. The representation change already landed beside it: unfao/frame_extraction.py implements the same operations frame-natively and is what production calls.

After S1, extraction.py (103 lines) retains one reachable function:

Function Reachable after S1? Frame equivalent
file_metadata yes — managers/unfao.py:48 (_ContractStorePort) —
months_of no frame_extraction.months_of
drop_months_above no frame_extraction.drop_months_above
cells_of no frame_extraction.cells_of
unmapped_cell_count no historical.unmapped_cell_count

Two seams for one concept is the CRP violation D-11 predicted: WET-before-DRY was correct during the migration and expires when the migration completes. It has.

Work

file_metadata is not extraction at all — it normalises a store document's metadata dict. It belongs with its one caller, not in a module named for a representation it no longer touches.

  • Move file_metadata (and only it) to sit beside _ContractStorePort, or into a small store-facing module if that reads better once S1 has shrunk the manager
  • Delete unfao/extraction.py
  • Retarget tests/test_extraction.py (96 lines) at the surviving function — do not delete the file; the file_metadata assertions are still worth having
  • Remove extraction from the manager's import line (:21)

Acceptance criteria

  • Exactly one extraction module remains, and it is frame-native
  • grep -rn "unfao.extraction\|from views_postprocessing.unfao import.*extraction" views_postprocessing/ returns nothing
  • file_metadata's tests still run and still assert the same behaviour
  • pandas no longer imported by any surviving module in unfao/ except enrichment.py (S4's subject)

Testing / validation

ruff check . · full suite green · test_hop_b_sink_e2e.py green — file_metadata is on the contract read path, so its move must be provably behaviour-neutral.

Activity

  1. added
    story
    implementation
    on Jul 31, 2026
  2. added a commit that references this issue on Jul 31, 2026
    cdf4a42
  3. Polichinel commented on Jul 31, 2026

    @Polichinel
    CollaboratorAuthor

    Done in PR #161 (merged to development). extraction.py deleted; file_metadata moved to unfao/store_metadata.py (sibling of source_metadata.py — producer facts / store facts). Tests followed the code: parity assertions in test_frame_extraction.py became absolute ones (same expected values, no deleted module to route through), and test_input_integrity_e2e.py now feeds the invariants primitives, which is how the delivery calls them. Register C-65 closed. The design-contract file's "no premature Extractor Protocol" note is marked vindicated — WET-before-DRY paid out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    implementationstory

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions