Skip to content

The Drift Log · Certifying that code does something

Certifying Software Invariants Across the Verification Ladder

18 November 2026 · 6 min read · 1255 words · established

A crystal artifact under orange probe beams inside a test rig

Replacing binary CI exit codes with a four-verdict verification ladder distinguishes basic test passes from true invariant certification.

A deployment pipeline goes green. The binary builds, twenty-four integration tests execute without an unhandled exception, and the artifact is promoted to staging. Two hours later, a customer provides an empty array wrapped in a pagination envelope, and a background worker deadlocks across four database connections.

The pipeline did not lie. Every test in the suite executed and reached its terminal assertion. What failed was the assumption that a green test suite constitutes verification.

A standard test suite proves only that specific inputs did not trigger fatal exceptions during a specific execution pass. It does not prove that functional invariants hold across boundary conditions, under resource contention, or against hostile inputs. Treating a passing suite as proof of correctness is why teams spend their careers triaging regressions in code that already had high test coverage.

Moving beyond this failure mode requires replacing binary pass/fail reporting with an explicit verification ladder.

The Mirage of the Binary Exit Code

Traditional continuous integration reduces all runtime behaviour to a zero or non-zero exit code. This binary collapse creates a false equivalence between five entirely different states of knowledge:

  1. The code compiled and linked.
  2. The runtime environment booted.
  3. Hardcoded example cases returned pre-calculated outputs.
  4. The component preserved its safety invariants across adverse inputs.
  5. The component has a closed-form mathematical proof of correctness.

When CI reports a pass, it usually means state 3 occurred. The engineering team often assumes state 4.

This gap exists because unit tests are typically written by the author of the implementation. The author tests the assumptions they considered while writing the code; they rarely test the assumptions they overlooked. A test suite that exercises five happy paths and two anticipated error branches provides zero evidence about how the component handles integer overflow, unexpected interleaving, or malformed payloads.

To achieve meaningful code certification, a test harness must evaluate components against formal contracts rather than isolated examples. That requires a vocabulary that distinguishes between what has been tested and what has actually been verified.

The Four Verdicts of a Verification Harness

An honest verification ladder cannot be binary. When a harness runs an artifact against an input space, it must report one of four mutually exclusive verdicts:

[ Artifact Under Test ]
          │
          ▼
┌───────────────────┐
│ Harness Execution │
└─────────┬─────────┘
          │
    ┌─────┴───────────────────────┬────────────────────────┐
    ▼                             ▼                        ▼
[ FAILED ]               [ INCONCLUSIVE ]            [ PROVISIONAL ]
(Contract violated)    (Harness cannot exercise)  (Reproducible, unproven)
                                                           │
                                                           ▼ (Adverse gauntlet)
                                                     [ CERTIFIED ]
                                                 (Invariants hold)

1. FAILED

The component violated an explicit invariant. It threw an unhandled exception, deadlocked, returned a value outside its contract boundary, or corrupted internal state. This is an unambiguous negative result.

2. INCONCLUSIVE

The harness was unable to exercise the component's input contract. This occurs when missing mock topologies, network partitions in the harness, or unresolvable dependencies prevent execution. Crucially, INCONCLUSIVE is a limitation of the test harness, not an assertion of an artifact defect. Collapsing an inconclusive run into a test failure penalises the code for harness limits; collapsing it into a pass invites outages.

3. PROVISIONAL

The artifact compiles cleanly, executes predictably, and passes basic smoke validation. Its build is byte-for-byte reproducible. However, its functional invariants have not yet been evaluated under adverse, generated, or fuzz-tested input conditions. The code runs, but correctness remains unasserted.

4. CERTIFIED

The component has been subjected to invariant testing across its entire declared input contract. The harness has generated boundary mutations, evaluated state invariants after arbitrary call sequences, and confirmed that preconditions, postconditions, and error guarantees hold without exception.

Distinguishing between PROVISIONAL and CERTIFIED changes how teams manage technical risk. A provisional artifact is acceptable for internal tooling or non-critical spikes; a certified artifact is required for multi-tenant data paths and cryptographic operations.

An Executable Proof: Invariant Verification in Practice

Consider a bounded queue that processes batches of transactions. A typical developer writes three unit tests: push an item, pop an item, assert the queue is empty.

// A common, brittle implementation
export class TransactionBatcher {
  private buffer: Transaction[] = [];

  constructor(private readonly maxBatchSize: number) {
    if (maxBatchSize <= 0) throw new Error("Invalid batch size");
  }

  public push(tx: Transaction): Transaction[] | null {
    this.buffer.push(tx);
    if (this.buffer.length >= this.maxBatchSize) {
      const batch = this.buffer;
      this.buffer = []; // Memory leak if references are held elsewhere
      return batch;
    }
    return null;
  }

  public drain(): Transaction[] {
    const items = [...this.buffer];
    this.buffer.length = 0;
    return items;
  }
}

A standard test suite pushes ten items with a batch size of ten, asserts a batch returns, and leaves CI green.

A verification harness does not test ten items. It defines invariants and attempts to break them:

  1. Conservation Invariant: count(pushed) == count(emitted) + count(buffered).
  2. Order Invariant: For any two items A and B where A was pushed before B, A must appear before B in emission.
  3. Bound Invariant: count(buffered) < maxBatchSize at all quiescent states.
  4. Idempotence Invariant: drain() called twice consecutively returns empty on the second call.

When the harness executes against these contracts using randomized batch sizes (maxBatchSize = MAX_SAFE_INTEGER), rapid concurrent flushing, and payload mutation, it transforms an ad-hoc script into an executable proof. If the harness cannot explore the boundary conditions due to generator limits, it flags the run as INCONCLUSIVE, refusing to issue a false certificate of compliance.

Why Invariant Verification is Hard

If invariant verification were straightforward, every continuous integration runner would do it. It is difficult because of state space explosion.

A function taking two 32-bit integers has $2^{64}$ possible input combinations. You cannot exhaustively run them. Instead, property-based testing and contract harnesses must pick partition representatives: minimum values, maximum values, zero, negative numbers, off-by-one boundaries, and pseudo-random distributions across the interior space.

Stateful components compound this complexity. If a class exposes five methods, the search space is not merely five sets of arguments; it is every valid sequence of method calls across arbitrary timeline depths. Proving that an invariant holds after a 50-step sequence of interleaved push, drain, and resize calls requires harness orchestration that standard unit frameworks do not provide.

Recognising this difficulty is why honest labeling matters. Admitting that an internal component is PROVISIONAL because your harness cannot afford the compute time or generator complexity to reach CERTIFIED is an engineering choice. Calling that same component "fully tested" because five unit tests ran in 40 milliseconds is a lie that invites production failures.

How SHPBL Approves Code

SHPBL applies this exact verification ladder to reusable software components. Our catalog contains model-independent, computed code owned outright with no runtime dependencies on generative models.

Every artifact must pass through a multi-tier certification test harness before promotion. Our pipeline evaluates software against strict input contracts and records explicit verdicts: CERTIFIED when invariants hold under our adverse verification gauntlet, PROVISIONAL when artifacts are structurally repeatable but await complete contract execution, and INCONCLUSIVE when harness boundaries prevent full coverage. We do not aggregate these counts; each tier is reported independently.

Teams can run a free repository evaluation to map their own components against this standard, run our gauntlet via the Practitioner tier, or acquire outright ownership of the Complete Master Library.

Monday Morning: Stop Lying With Binary CI

You do not need to rewrite your entire test infrastructure this weekend to start benefiting from verification ladders. You can introduce precision to your existing pipeline with three practical steps on Monday:

  1. Audit your assertions for invariant coverage. Pick your most critical service module. Identify its core safety invariant—the single property that must never be violated, regardless of input. Check if your current suite actually tests that property across edge cases, or if it merely asserts that a mock was called.
  2. Explicitly mark unverified code. Create a distinct status in your build metadata for artifacts that have only passed basic smoke tests. Label them PROVISIONAL. Ensure downstream consumers know the difference between code that compiles and code that has endured hostile inputs.
  3. Handle infrastructure limits honestly. If a test step skips because a database container was unavailable, stop letting the build pass with a warning. Mark the run INCONCLUSIVE and block promotion until the verification gauntlet actually runs.

Keep reading

Next in the log

The Strategic Master Library · written and reviewed under the house's own epistemic rules: nothing claimed that we cannot show.