Behavior parity is an observable contract

Parity evidence compares source and target on the same representative inputs; it does not merely check that the target compiles. The contract may contain outputs, errors, status codes, side effects, ordering, timing, idempotency, retries, and persistence behavior—only the measures that are truly observable to the consumer.

The comparison must separate expected equivalence, acceptable difference, and blocking discrepancy. If the oracle or baseline is missing, the result is not “parity,” but Unknown.

Source-to-target comparison matrix

DimensionSource baselineTarget observationDecision
Inputsrepresentative request/statesame controlled inputconfirm coverage
Outputvalue, status, shapetarget value, status, shapeequivalent or investigate
Errorstype, code, message boundarytarget error behaviorblocking on contract drift
Side effectswrites/events/notificationstarget effects and countcheck idempotency
Ordering/timingobservable sequence/latency classtarget sequence/latency classonly if the contract requires it
Evidencecommand, test, log, fixturematching anchorUnknown without anchors

Evidence collection order

  1. Define representative cases and record the source revision and environment assumptions.
  2. Record the observable contract: inputs, outputs, errors, side effects, and invariants.
  3. Repeat the same cases on the target in a controlled surface.
  4. Compare results for each dimension instead of reducing everything to one score.
  5. Save evidence anchors, discrepancy, confidence, and the owner of the next decision.
  6. Stop or choose HOLD when there is an unexplained difference or no oracle.

What does not prove parity

  • a successful build without runtime or contract checks;
  • one happy-path case without errors and side effects;
  • the same internal implementation or class names;
  • a general “compatible” statement without source/target observations;
  • a filled template without actual command or test outputs.

Canonical lesson source · JavaRush

Open JavaRush material