Skip to content

S1 — Coverage contract: complete-coverage invariant + cell-count logging (C-34) #53

Description

@Polichinel

Epic: #51 · S1 · depends on #61 (S0) · story implementation

Problem (C-34)

Nothing asserts how many cells the FAO pipeline should process; a wrong/stale region delivers partial coverage to FAO with no signal. _validate checks only metadata nulls.

Build shape (per the epic design contract)

  • delivery/coverage.py (representation-free): assert_complete_coverage(received_gids: set[int], expected_count: int) -> None (raise on mismatch); region→expected-count constant alongside (delivery/ constants). No pandas.
  • unfao/extraction.py: cells_of(df) -> set[int] — the only pandas line.
  • Manager: calls assert_complete_coverage(cells_of(df), EXPECTED[region]) via the S0 hook; logs fetched/enriched/unmapped counts.

Two checks: (a) internal consistency — received gids survive to delivery (expected = the gids that arrived); (b) region intent — count matches the intended region (expected = declared constant; to be sourced from datafactory region metadata when it publishes it — same companion shape as S2's last_valid_month_id).

Acceptance criteria

  • delivery/coverage.py is a pure, pandas-free function with the region constant; unit-tested on plain sets/ints.
  • Manager logs cell counts and raises on expected≠actual (under- and over-coverage).
  • Tests: correct count passes; under- and over-coverage each raise.

Files

views_postprocessing/delivery/coverage.py (new), views_postprocessing/unfao/extraction.py (extend), unfao/managers/unfao.py (call), tests/.

Activity

  1. Polichinel commented on Jun 26, 2026

    @Polichinel
    CollaboratorAuthor

    Build shape (per the epic's post-/falsify design contract, 2026-06-26)

    Do not add coverage logic to the pandas _validate god-method. Build it as:

    • views_postprocessing/delivery/coverage.py (representation-free): a pure function, e.g. assert_complete_coverage(received_gids: set[int], expected_count: int) -> None (raise on mismatch), and the region→expected-count constant lives alongside (delivery/ constants). No pandas import here.
    • views_postprocessing/unfao/extraction.py: cells_of(df) -> set[int] — the only pandas-aware line for this guard.
    • Manager: assert_complete_coverage(cells_of(self._df), EXPECTED[region]) — extract → call → raise. The guard is called, not a method.

    Two checks (from the earlier deep-dive): (a) internal consistency — received gids survive to delivery (expected = the gids that arrived); (b) region intent — count matches the intended region (expected = declared constant, sourced from datafactory's region metadata when it publishes it — same companion as #52's last_valid_month_id).

    Tests live against delivery/coverage.py on plain sets/ints (no framework). The design-contract stubs in tests/test_input_integrity_design_contract.py already enforce the placement + pandas-free rules.

  2. changed the title [-]S2 — Coverage contract: assert expected cell count + log cell counts (C-34)[/-] [+]S1 — Coverage contract: complete-coverage invariant + cell-count logging (C-34)[/+] on Jun 26, 2026
  3. Polichinel commented on Jun 26, 2026

    @Polichinel
    CollaboratorAuthor

    Delivered and merged to development via #64 (input-integrity sprint S0–S6). ruff clean, 126 passed / 44 xfailed. Closing — the auto-close keyword did not fire because #64 merged into development, not the default branch. Live-run validation of the residual contracts (C-25 identity name/loa, C-43 enrichment equivalence) is tracked in the risk register and exercised by the go-global run (views-models#127).

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

    implementationCode implementation workstoryA single reviewable unit of an epic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions