Skip to content

refactor: renew tests and verification over semantic-precision substrate #267

Closed

Description

@Sinity

Outcome

Finish the semantic-precision renewal program by aligning tests, fixtures, and verification tooling with the renewed substrate and surface contracts.

Problem or opportunity

The source, schema, lib/storage, and surface renewal slices are progressively replacing weak payload plumbing with explicit typed contracts. The remaining endgame risk is verification drift: tests, fixtures, showcase scaffolding, and devtools helpers can keep encoding the older loose shapes even after the production code is renewed.

If that drift is not addressed deliberately, future refactors will keep paying a hidden compatibility tax in test helpers and verification tooling.

Expected scope

Likely modules include:

  • tests/infra/
  • selected tests/unit/ fixtures and contract suites
  • selected devtools/ verification and rendering helpers
  • selected showcase/quality references where verification surfaces still assume legacy payload shapes

Strengthened execution scope

Before implementation, the current helper survey found a concrete drift pattern: tests/infra/storage_records.py uses one loose dict[str, object] alias both for JSON metadata and for Pydantic model payloads, while tests/infra/archive_scenarios.py still allows raw content-block dictionaries in authored scenario fixtures.

This issue should therefore land a stricter vertical slice rather than only adding coverage:

  • Split test-helper JSON metadata contracts from internal record-construction payloads.
  • Reject non-JSON provider metadata, attachment metadata, and content-block payload fragments in shared storage builders instead of silently dropping or stringifying arbitrary Python objects.
  • Replace raw archive-scenario content-block dictionaries with a typed scenario content-block fixture API.
  • Add regression tests proving legacy loose shapes fail loudly at the fixture boundary.
  • Register a focused validation lane for verification-substrate contracts so these helper invariants stay runnable through devtools run-validation-lanes.

Constraints and invariants

  • Keep the work focused on verification alignment, not unrelated product behavior changes.
  • Prefer deleting brittle compatibility scaffolding rather than preserving two fixture shapes.
  • The tranche should land after the remaining source/lib/surface renewal slices it depends on.
  • Production archive semantics and user-facing CLI/MCP output must stay unchanged; this is a verification substrate renewal.

Acceptance criteria

  • Test fixtures and helper builders reflect the renewed typed contracts directly.
  • Verification/devtools helpers no longer compensate for obsolete loose payload shapes.
  • Storage-record helpers distinguish JSON metadata from internal model payload dictionaries.
  • Archive scenarios use typed content-block fixtures and reject raw dictionary blocks.
  • Invalid non-JSON metadata/content-block inputs fail with actionable context.
  • A focused validation lane covers the renewed verification-substrate helper contracts.
  • The tranche lands as a coherent PR with devtools verify green.

Verification plan

Run focused infra/devtools tests first, then devtools render-all --check, then devtools verify before merge.

Non-goals or explicitly deferred work

  • Broad new feature work in tests or devtools.
  • Reintroducing compatibility layers solely to preserve older helper shapes.

Ref #315

Activity

  1. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Execution started on feature/refactor/verification-substrate-contracts.

    Strengthened target before implementation:

    • separate JSON metadata contracts from internal Pydantic record payloads in shared storage-record helpers;
    • make archive scenarios use typed content-block fixtures rather than raw dictionaries;
    • add failure tests for legacy loose metadata/content-block shapes;
    • add a focused validation lane for verification-substrate helper contracts.

    I will keep production behavior unchanged and verify with focused infra/devtools tests plus devtools verify before PR.

  2. Sinity commented on Apr 23, 2026

    @Sinity
    OwnerAuthor

    Completed in PR #374 and squash-merged as 1856ad086d5b5576e69321dfe66e159e610bc395.

    What landed:

    • ScenarioContentBlock now provides typed authored content-block fixtures for archive scenarios, and raw dictionary content blocks fail at seed time.
    • Shared storage-record helpers now validate provider metadata, attachment metadata, content-block tool input, and content-block metadata as JSON-compatible at the fixture boundary.
    • Internal model-construction payloads are separated from JSON metadata validation in tests/infra/storage_records.py.
    • Added regression tests for invalid loose metadata/content-block inputs.
    • Added verification-substrate-contracts to validation lanes and declared operation metadata for fixture seeding/building.
    • Regenerated docs/test-quality-workflows.md and docs/verification-catalog.md.

    Verification before merge:

    • focused infra/devtools pytest: passed
    • devtools run-validation-lanes --lane verification-substrate-contracts: 13 passed
    • targeted ruff/mypy: passed
    • projection/scale focused pytest: 160 passed
    • devtools render-all --check: passed
    • devtools verify: all checks passed
    • push pre-flight devtools verify --quick: passed

    GitHub automation remained pending, but there were no inline review threads and local verification was clean.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions