Skip to content

S4 — Retire the _validate replica: test the gate that exists, where it lives (C-03) #185

Closed

Description

@Polichinel

Part of epic #181. Closes register C-03 (Tier 3).

Background

tests/test_validation.py opens with this:

"Note: views-pipeline-core may not be installed in test environments, so we replicate the validation logic here rather than importing the manager class. The logic tested matches unfao.py:_validate() exactly."

That claim is now false, and has been since #149.

The _validate that existed when the file was written null-gated the nine GAUL metadata columns. The _validate that exists today does not — its own docstring says so:

def _validate(self) -> None:
    """Assert the read produced what the save needs, then check coverage.

    Neither payload is null-gated here. The historical artifact's metadata
    null-gate fires at build time (``historical.assert_metadata_complete``);
    ...
    """

It now asserts that _read resolved (_historical_frame is not None, _forecast_resolution is not None) and calls _check_coverage. The null gate moved to contract/historical.assert_metadata_complete during the frame-native migration.

So the test file:

  1. tests a gate that no longer lives where it says,
  2. asserts fidelity to a method it no longer resembles,
  3. hardcodes REQUIRED_METADATA_COLS as a 9-element literal instead of importing gaul_schema.METADATA_COLS — the exact single-source-of-truth defect C-70 was resolved to prevent.

Point 3 already has a witness in the suite: tests/test_falsification_campaign_4_3.py:32 notes "The validation tests use a hardcoded REQUIRED_METADATA_COLS list that…". Someone saw it and moved on.

C-03's registered residual is exactly these two gaps: "the standalone _validate() replica and the missing enrich→validate end-to-end test." The first has since decayed from a duplication risk into an active falsehood.

Work

  1. Delete the replica's false claim and the duplicated column list. Import METADATA_COLS from views_postprocessing.contract.gaul_schema. The list stops being a copy.
  2. Re-point the null-gate tests at the module that owns the gate. The behaviour C-01 fixed (null validation, and the failure messages the CIC promises) is real and worth keeping — it just lives in contract/historical.assert_metadata_complete now. Test it there, directly, with no replica: that module is dependency-light and imports fine without pipeline-core, so the original justification for replicating no longer applies either.
  3. Correct the module docstring to say what the file now tests and where the gate lives.
  4. Close C-03's second residual — the missing enrich→validate end-to-end path — or state in the register why it stays open. test_historical_parity.py and test_historical_builder.py may already cover it end to end via the frame-native path; check before writing a new test. Do not add a redundant test to close an entry.

Acceptance criteria

  • No hardcoded copy of the nine metadata column names anywhere in tests/.
  • No test file claims to replicate a manager method.
  • The null-gate behaviour is asserted against historical.assert_metadata_complete, the module that performs it.
  • _validate's current contract (both resolution assertions + the coverage call) has at least one test, or the register states why it does not.
  • C-03 is closed with the command that proves it, or its remaining scope is narrowed in writing.

Testing

ruff check .
pytest -q tests/test_validation.py tests/test_historical_builder.py tests/test_historical_parity.py
pytest -q

Sanity check that the replica is really gone:

grep -rn "REQUIRED_METADATA_COLS\|matches unfao.py" tests/

Dependencies

None.

Files

  • tests/test_validation.py — the replica and the false claim
  • views_postprocessing/unfao/managers/unfao.py:228-262 — _validate / _check_coverage as they actually are
  • views_postprocessing/contract/historical.py — assert_metadata_complete, where the gate lives
  • views_postprocessing/contract/gaul_schema.py:48 — METADATA_COLS, the declared contract (C-70)
  • tests/test_falsification_campaign_4_3.py:32 — the earlier witness
  • docs/CICs/UNFAOPostProcessorManager.md — check it does not repeat the stale claim

Activity

  1. added
    storyA single reviewable unit of an epic
    testingTest/parity/validation work
    on Aug 1, 2026
  2. added a commit that references this issue on Aug 2, 2026
  3. Polichinel commented on Aug 2, 2026

    @Polichinel
    CollaboratorAuthor

    Landed in #200. C-03 closed.

    The old tests/test_validation.py ran 43 parametrised cases against a function it defined itself — zero production code. If assert_metadata_complete had been deleted outright, every one would still have passed.

    Replaced by 14 tests of the real gate, parametrised over the imported METADATA_COLS. The numbers are the argument:

    old (43) new (14)
    narrow the gate to one column all pass 9 fail

    C-03's second residual is relocated to #18 by number. Every leg is covered — enrichment, artifact build, reader parity, invariants, wire e2e, null-gate. What remains is the manager orchestrating them, which needs a production-like Appwrite environment þing-02 D2 forbids.

    Three discharged assert False probes retired, with dated notes. C-36 predicted this: "a fixed finding won't auto-flip — inherent to marker-style tests." One was a stated scope extension (about test_enrichment.py, not the replica) — verified false first, called out in the PR rather than buried.

    Review caught the story closing C-03 while the CIC still cited it as open next to a now-false "replica tests". Corrected.

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

    storyA single reviewable unit of an epictestingTest/parity/validation work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions