Skip to content

test(rust): keep production-gap accounting invariant across equivalent harness assertion forms #3284

Closed

Description

@EffortlessSteven

Parent: #3213
Depends on: #3283
Existing partial implementation: PR #3273 — inline #[cfg(test)] role only

Builder-Ready Plan

Plan disposition: builder-ready after the source-role model covers the intended test/evidence surfaces. This is S3.

Problem

Source-role classification should stop ordinary harness code from becoming the production subject, but #3213 also carries a stronger observed failure: semantically equivalent test assertions can change the reported production-gap denominator solely because one form uses explicit control flow and Result<()> plumbing.

The producer needs a discriminating corpus proving test syntax affects oracle/evidence facts only where the semantic assertion actually changes—not because if, return Err, ?, map_err, Ok(()), or helper calls are available as probe shapes.

Current evidence

Reproduction / example

Equivalent pair:

assert!(actual == expected, "actual={actual:?}");
if actual != expected {
    return Err(anyhow!("actual={actual:?}"));
}
Ok(())

For the same production owner and exact comparison, the production-seam inventory and credited discriminator/oracle meaning should agree. Harness-only control-flow shapes must not add production subjects.

Non-equivalent control:

assert!(actual.is_ok());

versus an exact variant/value assertion must remain distinguishable in oracle strength.

Suspected root area

  • test/evidence source-role filtering before probe seeding;
  • Rust assertion/oracle extraction and normalized assertion shape;
  • helper/control-flow fact extraction;
  • production-gap denominator aggregation;
  • governed fixtures/goldens and mutation/removal tests.

Fix plan

  1. Build a table-driven fixture corpus over the same production owner, inputs, and expected observable using equivalent harness forms:
assert!
assert_eq! / assert_ne!
if ... return Err(...)
match ... { wrong => Err(...), _ => Ok(()) }
Result<()> with ? / map_err
assert_cmd chains
.contains() / exact output checks
helper function inside evidence role
  1. Define the semantic projection used for equality: production subject inventory, owner/relation identity, activation/discriminator facts, oracle kind/strength, limitations, and actionable production gaps.
  2. Prove harness-role functions/control flow never enter the production subject inventory under the supported source roles.
  3. Normalize equivalent assertion evidence only when the same comparison/observable is structurally established. Do not infer exactness from messages or names.
  4. Retain negative controls for broad is_ok/contains/status-only assertions, wrong target, unrelated strong assertion, opaque helper, and changed expected value.
  5. Add removal experiments that re-enable probe seeding for evidence-role functions or make assertion syntax drive denominator changes; the corpus must fail.
  6. Keep production controls with identical syntax eligible for normal findings.
  7. Preserve unknown/opaque states where helper semantics cannot be resolved.

Acceptance tests

  • Equivalent exact-value/variant assertions across supported forms produce the same production subject inventory and actionable-gap count.
  • Result<()>, terminal Ok(()), ?, map_err, assertion-driver calls, and harness-only .contains() do not create recursive production obligations.
  • Adding a focused test can reduce or leave unchanged the production gap count; harness plumbing alone cannot increase it.
  • Broad versus exact oracle forms remain different where semantics differ.
  • Wrong-target and unrelated-strong-assertion controls remain non-crediting.
  • Production-source functions using the same if, ?, map_err, or return shapes remain ordinary production subjects.
  • Opaque/custom helpers remain limited rather than guessed equivalent.
  • Removal experiments fail for evidence-role probe leakage and syntax-dependent denominator drift.

Non-goals

  • No claim that all assertion forms are semantically equivalent.
  • No arbitrary custom matcher interpretation.
  • No output/gate source-role disclosure; S4 owns convergence.
  • No downstream suppression removal before publication.
  • No threshold relaxation or support promotion.

Dependencies / sequencing

Risk / rollback

Risk is over-normalizing assertions and crediting a weak oracle as exact. Require structural equality of owner, input, comparison, expected observable, and target; keep broad/opaque controls. Rollback removes normalization/corpus changes while retaining producer source role.

Verification notes

Run focused assertion/oracle and source-role tests, the governed equivalence corpus, goldens, evidence-promotion honesty, full Rust analyzer tests, formatting, Clippy, dogfood, and cargo xtask check-pr. Inspect semantic fixture diffs rather than only aggregate counts.

Claim boundary

Completion proves the supported production-gap denominator and oracle meaning do not depend on equivalent test-harness syntax. It does not expose the role consistently across every public surface or remove downstream suppressions.

Activity

  1. added
    status/needs-work
    on Aug 15, 2026
  2. coderabbitai commented on Aug 15, 2026

    @coderabbitai
    🔗 Related PRs

    #3167 - test(product): prove equality-boundary repair closes [merged]
    #3190 - fix(output): keep mixed health repairs visible [merged]
    #3193 - test(fixtures): isolate unchanged proof identity [merged]
    #3203 - test(gate): reject vacuous non-promotion charters [merged]
    #3273 - fix(rust): classify cfg(test) helpers as evidence [open]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

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

    status/needs-work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions