Skip to content

explain contract: handler variants are under-constrained and four known branches have no fixture #1278

Description

@jeremi

What

Two gaps in the bregctl explain JSON Schema contract under products/breg/contracts/explain/, gated by crates/registry-bregctl/tests/explain_contract.rs.

1. ActionsExplanation does not tie backend fields to handler.kind

Only the common handler fields are required. There is no oneOf or conditional binding the backend-specific members to the discriminator, so the schema accepts:

  • kind: "rhai" without scriptSha256, rhaiVersion, or limits
  • kind: "wasm" without moduleSha256 or compatibility

Those fields are pinned precisely because they are the ones a consumer verifies a handler against. Dropping one from explain_actions today still passes the gate, which is the one thing the gate exists to catch. Model the two handler variants separately and require each variant's own members.

2. Four branches are pinned from source and never instantiated

explain_contract.rs replays the real binary over 11 fixtures and 2 scenarios. None of them reaches:

  • a WASM action handler (handler.kind == "wasm") — already recorded under "Unexercised branches" in the contract README
  • the "clear" field-mutation kind in ActionsExplanation and ChangeRequestsExplanation — also already recorded there
  • a project omitting package or manifestProjection, so explain_model serializes them as null
  • an authority inventory failure, so explain_access carries a non-null claimContractError

The last two were widened to accept null and the snake_case error vocabulary in PR #1271 after the review connector caught that the schemas refused valid payloads. The schemas are now correct, but nothing replays either branch, so the same class of defect can recur unseen. A conflicting-claim scenario (ConflictingClaimExpectation is the reachable one) and a fixture without production metadata would close both.

Item 1 is the merge-relevant half: it is a gate that does not gate. Item 2 is coverage.

Provenance

Raised by the review connector on PR #1271. Item 1 is verbatim; item 2 extends the README's existing unexercised-branch note with the two branches found while fixing the schemas.

Activity

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions