Skip to content

test: tighten mock contract + expand e2e.yml so future #207-class bugs cannot ship #210

@gerchowl

Description

@gerchowl

Context

#207 (split into PRs #208 and #209) was a real contract bug — per-file bake/derive didn't emit `release-manifest.json` — that all four client unit suites and the Python E2E missed. Caught only on a live anvil-dev dagger run hitting the JS/shell/Rust clients. The user asked the right question: can mocks catch this in the future, and is `mat-vis-tst` the next-level test that should have caught it?

Both, yes. This issue does both.

Part A — sharper unit-test contract

Mocks DID exercise `bake_one_per_file` and `derive_smaller_tier` end-to-end, but only asserted the happy path (textures committed, sentinel last). They didn't assert WHICH manifest entries are produced, so a missing `release-manifest.json` op was invisible.

Adds

  • `tests/test_hf_bake_per_file.py::test_commit_operations_include_release_manifest`:

    • Run `bake_one_per_file` against mocked HfApi
    • Assert: across `api.create_commit.call_args_list`, exactly one op writes `path_in_repo == "release-manifest.json"`
    • Assert: that commit's ops also contain the source catalog (`.json`)
    • Assert: the manifest commit carries `parent_commit` (CAS retry primitive)
  • `tests/test_hf_derive_per_file.py::test_commit_operations_include_release_manifest_after_derive`:

    • Same shape; covers the derive path's manifest emission
  • A small substrate-contract module `tests/_substrate_contract.py` (or a fixture) that lists the required commit-path-set for any bake/derive completion: `{.json, release-manifest.json, //.tier_complete}`. Both bake and derive tests assert their commit history covers this set. Future contract changes update the fixture once.

Part B — `mat-vis-tst` as the gate

`mat-vis-tst` exists for exactly this — catching contract slips that mocks can't. `tests/e2e/test_per_file_roundtrip.py` already exists (#193) but currently only:

Expands

`tests/e2e/test_per_file_roundtrip.py` matrix:

`e2e.yml` workflow extension:

  • After the existing Python E2E job, fan out one job per language (JS, shell, Rust) with the throwaway tag in the env. Each fetches a real per-file PNG/byte-stream and asserts magic.
  • Final job: `mat-vis-baker audit-orphans --repo gerchowl/mat-vis-tst` and assert `orphans == 0` post-cleanup

Why this matters

The Python client masks manifest 404s with tree-fallback (`client.py:544`); the JS/shell/Rust clients hard-fail. Without exercising those clients against real bytes from a fresh bake, contract slips on the manifest are invisible until ship-day.

Acceptance

  • Unit tests assert manifest path appears in commit ops for both bake and derive
  • Unit tests assert `parent_commit` is set on the manifest commit (CAS retry)
  • E2E runs the multi-source bake + derive scenario locally with `MAT_VIS_E2E=1 pytest tests/e2e/`
  • e2e.yml fans out JS / shell / Rust jobs after the Python suite
  • e2e.yml includes a final `audit-orphans` assertion
  • Live anvil-dev re-run confirms green nightly flow

Estimate

~80 LOC across 3 test files + ~40 LOC YAML for the workflow. Small, mostly mechanical; benefits compound across the whole milestone.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions