# test-coverage

> Every algorithm contract in this domain is listed with its position on the derivation loop, its intent and invariant, the flow it walks, its productions as a…

Page: Ontology · Algorithms
Canonical: https://banes-lab.com/ontology/algorithms#algo-domain-test-coverage

Every algorithm contract in this domain is listed with its position on the derivation loop, its intent and invariant, the flow it walks, its productions as a grammar, what it composes and is composed by, which forces and principles it answers to, what grounds it and what it grounds, and an exemplar where the record carries one. The diagram shows what composes what inside the domain.

Relations diagram

What composes what inside this domain.

```mermaid
flowchart LR
n_coverage_workspace["Coverage Workspace"]
n_surface_grid_walk["Surface Grid Walk"]
n_uncovered_gap_derivation["Uncovered Gap Derivation"]
n_coverage_risk_prioritisation["Coverage Risk Prioritisation"]
n_technique_invariant_selection["Technique and Invariant Selection"]
n_test_authoring["Test Authoring"]
n_evidence_verdict["Evidence Verdict"]
n_coverage_ledger["Coverage Ledger"]
n_coverage_completion["Coverage Completion"]
n_test_coverage_kernel["Test Coverage Kernel"]
n_test_coverage_concern["<Test Coverage Concern>"]
n_test_coverage_kernel --> n_coverage_workspace
n_test_coverage_kernel --> n_surface_grid_walk
n_test_coverage_kernel --> n_uncovered_gap_derivation
n_test_coverage_kernel --> n_coverage_risk_prioritisation
n_test_coverage_kernel --> n_technique_invariant_selection
n_test_coverage_kernel --> n_test_authoring
n_test_coverage_kernel --> n_evidence_verdict
n_test_coverage_kernel --> n_coverage_ledger
n_test_coverage_kernel --> n_coverage_completion
```

### Coverage Workspace

- Stage: [orient](https://banes-lab.com/records/stage/orient.md)
- Axis: [ontology](https://banes-lab.com/records/reason/axis-ontology.md)
- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Establish the unit under test, load the test-surface catalog as the space of what can be wrong, and enumerate every surface the unit can carry, so coverage is measured against the full derivable space rather than an ad-hoc list.

Invariant
Coverage must be measured against the derivable surface space, not a remembered subset.

Flow

```text
UnitUnderTest → SurfaceCatalog → CandidateSurfaceSet → CoverageWorkspace
```

Productions

```bnf
CoverageWorkspace ::= <UnitUnderTest> "->" <SurfaceCatalog> "->" <CandidateSurfaceSet>
```

Composes
none

Composed by
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Named in the derivation of
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
Testing starts from whatever surfaces come to mind, with no record of the full space a system can fail in.
```

After

```text
unit under test → load the test-surface catalog{dimension x lens → invariant, technique} → a coverage workspace enumerating every surface the unit can carry
```

### Surface Grid Walk

- Stage: [see](https://banes-lab.com/records/stage/see.md)
- Axis: [analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- Math type: [set-theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- Yields: set | boolean

Details

Intent
Walk the dimension-by-lens grid across the catalog, mark every cell that carries a surface, and surface the empty cells as candidate gaps using the anomaly lens, so a missing aspect is detected structurally rather than by recollection.

Invariant
An empty (dimension x lens) cell that can fail is an untested aspect until a surface is derived for it.

Flow

```text
SurfaceCatalog → GridWalk → PresentCellSet → CandidateGapSet
```

Productions

```bnf
SurfaceGridWalk ::= <CandidateSurfaceSet> "->" <DimensionLensGrid> "->" <PresentCellSet> "," <CandidateGapSet>
DimensionLensGrid ::= <OntologyDimension> "x" <AnalysisLens>
```

Composes
none

Composed by
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Named in the derivation of
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)

Grounds
[anomaly](https://banes-lab.com/records/reason/lens-anomaly.md), [semantic-correctness](https://banes-lab.com/records/reason/test-surface-semantic-correctness.md)

Before

```text
Coverage is asserted from the surfaces already tested, so the empty cells of the dimension x lens grid stay invisible.
```

After

```text
catalog → walk (dimension x lens) grid → present cells (a surface exists) vs empty cells (no surface) → the candidate-gap set the anomaly lens surfaces
```

### Uncovered Gap Derivation

- Stage: [derive](https://banes-lab.com/records/stage/derive.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Reduce the candidate-gap set to the cells this unit can fail in, yielding the required-but-uncovered surfaces that still owe a test, so effort is spent on gaps that can fail rather than the full cartesian complement.

Invariant
A gap counts only where the unit can fail; the coverage obligation is the required set, not the whole grid.

Flow

```text
CandidateGapSet → FailabilityFilter → RequiredUncoveredSet
```

Productions

```bnf
UncoveredGapDerivation ::= <CandidateGapSet> "->" <FailabilityFilter> "->" <RequiredUncoveredSet>
```

Composes
none

Composed by
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Named in the derivation of
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
The gap set is treated as final, so cells that cannot fail for this unit are chased and the gaps that can fail are diluted.
```

After

```text
candidate gaps → keep only cells this unit can fail in → required-but-uncovered set = the surfaces still owed a test
```

### Coverage Risk Prioritisation

- Stage: [intent](https://banes-lab.com/records/stage/intent.md)
- Axis: [teleology](https://banes-lab.com/records/reason/axis-teleology.md)
- Math type: [optimisation](https://banes-lab.com/records/reason/math-type-optimisation.md)
- Yields: boolean | ranking

Details

Intent
Score each required-uncovered surface by failure impact and reachability, rank the surfaces, and address the highest-risk gaps first, so limited testing effort removes the most risk.

Invariant
The highest-risk uncovered surface is tested first.

Flow

```text
RequiredUncoveredSet → RiskScore → PrioritisedSurfaceQueue
```

Productions

```bnf
CoverageRiskPrioritisation ::= <RequiredUncoveredSet> "->" <RiskScoreSet> "->" <PrioritisedSurfaceQueue>
RiskScore ::= <FailureImpact> "*" <Reachability>
```

Composes
none

Composed by
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Named in the derivation of
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
[tel-priority](https://banes-lab.com/records/reason/node-tel-priority.md)

Before

```text
Every uncovered surface is treated as equally urgent, so a rarely hit cosmetic gap competes with an unguarded security boundary.
```

After

```text
required-uncovered surfaces → failure-impact x reachability → priority → the highest-risk surfaces first
```

### Technique and Invariant Selection

- Stage: [project](https://banes-lab.com/records/stage/project.md)
- Axis: [reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- Math type: [algebra](https://banes-lab.com/records/reason/math-type-algebra.md)
- Yields: ordered-structure

Details

Intent
For each prioritised surface, state the invariant that must hold and select the technique whose reasoning mode matches how that surface is observed, so the test asserts the right property by the right method.

Invariant
The technique is chosen by matching its reasoning mode to the surface, and the assertion is the surface's invariant.

Flow

```text
Surface → InvariantStatement → ModeMatchedTechnique → SurfacePlan
```

Productions

```bnf
TechniqueInvariantSelection ::= <Surface> "->" <Invariant> "," <ModeMatchedTechnique> "->" <SurfacePlan>
```

Composes
none

Composed by
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Named in the derivation of
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md)

Grounds
none

Before

```text
A test is written before deciding what must hold or how to obtain evidence, so it asserts an accidental condition with the wrong technique.
```

After

```text
surface → state its invariant (the assertion) → pick the technique whose reasoning mode matches how the surface is observed → a matched (invariant, technique) plan
```

### Test Authoring

- Stage: [act](https://banes-lab.com/records/stage/act.md)
- Axis: [formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
Realize each surface plan as an executable test: encode the predicate as an assertion and wire the evidence source the technique requires, producing a runnable test that covers the surface.

Invariant
A covered surface has an executable test whose predicate is checkable and whose evidence source is wired.

Flow

```text
SurfacePlan → PredicateAssertion → EvidenceWiring → RunnableTest
```

Productions

```bnf
TestAuthoring ::= <SurfacePlan> "->" <PredicateAssertion> "," <EvidenceWiring> "->" <RunnableTest>
```

Composes
none

Composed by
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Named in the derivation of
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
none

Before

```text
The plan stays a note; the predicate is never realized as an executable check that gathers evidence.
```

After

```text
surface plan → realize the predicate as an executable assertion → wire the evidence source the technique requires → a runnable test for the surface
```

### Evidence Verdict

- Stage: [verify](https://banes-lab.com/records/stage/verify.md)
- Axis: [verification](https://banes-lab.com/records/reason/axis-verification.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Run each test, gather its evidence, and issue the verdict: pass or fail when the evidence set is non-empty, unknown when it is empty, so an untested or unrun surface reads as unknown rather than as a silent pass.

Invariant
A verdict is pass or fail only against a non-empty evidence set; no evidence yields unknown, never pass.

Flow

```text
RunnableTest → EvidenceSet → Verdict
```

Productions

```bnf
EvidenceVerdict ::= <RunnableTest> "->" <EvidenceSet> "->" <Verdict>
Verdict ::= "pass" | "fail" | "unknown"
```

Composes
none

Composed by
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Named in the derivation of
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
[ver-evidence](https://banes-lab.com/records/reason/node-ver-evidence.md)

Before

```text
A surface with no run is silently treated as passing, so absence of evidence reads as evidence of correctness.
```

After

```text
run the test → gather evidence → non-empty evidence set: pass or fail; empty evidence set: unknown (the coverage-gap state), never pass
```

### Coverage Ledger

- Stage: [commit](https://banes-lab.com/records/stage/commit.md)
- Axis: [representation](https://banes-lab.com/records/reason/axis-representation.md)
- Math type: [information-theory](https://banes-lab.com/records/reason/math-type-information-theory.md)
- Yields: hash | novelty-score

Details

Intent
Record each surface's verdict in a durable coverage ledger together with the residual uncovered and unknown set, so coverage state is reusable evidence rather than a fact re-derived on every run.

Invariant
Coverage state is durable ledger evidence, not a per-run recomputation.

Flow

```text
VerdictSet → CoverageLedger → ResidualGapSet
```

Productions

```bnf
CoverageLedger ::= <VerdictSet> "->" <SurfaceLedger> "->" <ResidualGapSet>
```

Composes
none

Composed by
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Named in the derivation of
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)

Grounds
none

Before

```text
Each run forgets the last, so which surfaces are covered, uncovered, or unknown must be re-derived every time.
```

After

```text
verdicts → a durable coverage ledger{surface → verdict} + the residual uncovered/unknown set → reusable coverage state
```

### Coverage Completion

- Stage: [terminate](https://banes-lab.com/records/stage/terminate.md)
- Axis: [termination](https://banes-lab.com/records/reason/axis-termination.md)
- Math type: [logic](https://banes-lab.com/records/reason/math-type-logic.md)
- Yields: boolean

Details

Intent
Mark coverage complete only when every required surface carries a surface, a technique, and an invariant, and its verdict is non-unknown; any required surface still unknown leaves coverage incomplete.

Invariant
Completion is the absence of required-unknown surfaces, not an aggregate percentage.

Flow

```text
CoverageLedger → RequiredSurfaceCheck → CompletionVerdict
```

Productions

```bnf
CoverageCompletion ::= <CoverageLedger> "->" <RequiredSurfaceCheck> "->" <CompletionVerdict>
CompletionVerdict ::= "coverage_complete" | "coverage_incomplete"
```

Composes
none

Composed by
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Named in the derivation of
[Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)

Grounds
[ter-stop](https://banes-lab.com/records/reason/node-ter-stop.md)

Before

```text
Coverage is declared done while required surfaces remain unknown, so the untested cells hide behind an aggregate percentage.
```

After

```text
ledger → every required surface carries a surface + technique + invariant AND a non-unknown verdict → complete; any required-unknown remains → incomplete
```

### Test Coverage Kernel

- Math type: [computation](https://banes-lab.com/records/reason/math-type-computation.md)
- Yields: procedure

Details

Intent
Load the surface catalog for a unit, walk the dimension-by-lens grid, derive the required-uncovered surfaces, prioritise them by risk, select a mode-matched technique and invariant per surface, author the test, issue an evidence verdict, ledger the state, and terminate only when no required surface remains unknown.

Invariant
Test coverage is a derivation from the surface space to a durable verdict ledger, complete only when no required surface is unknown.

Flow

```text
Workspace → GridWalk → GapDerivation → RiskPriority → TechniqueInvariant → TestAuthoring → EvidenceVerdict → Ledger → Completion
```

Productions

```bnf
TestCoverageKernel ::= <CoverageWorkspace> "->" <SurfaceGridWalk> "->" <UncoveredGapDerivation> "->" <CoverageRiskPrioritisation> "->" <TechniqueInvariantSelection> "->" <TestAuthoring> "->" <EvidenceVerdict> "->" <CoverageLedger> "->" <CoverageCompletion>
```

Composes
[Coverage Workspace](https://banes-lab.com/records/algo/coverage-workspace.md), [Surface Grid Walk](https://banes-lab.com/records/algo/surface-grid-walk.md), [Uncovered Gap Derivation](https://banes-lab.com/records/algo/uncovered-gap-derivation.md), [Coverage Risk Prioritisation](https://banes-lab.com/records/algo/coverage-risk-prioritisation.md), [Technique and Invariant Selection](https://banes-lab.com/records/algo/technique-invariant-selection.md), [Test Authoring](https://banes-lab.com/records/algo/test-authoring.md), [Evidence Verdict](https://banes-lab.com/records/algo/evidence-verdict.md), [Coverage Ledger](https://banes-lab.com/records/algo/coverage-ledger.md), [Coverage Completion](https://banes-lab.com/records/algo/coverage-completion.md)

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md), [architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)

Grounds
[derivation-loop](https://banes-lab.com/ontology/reasoning/reason-loop-derivation-loop.md)

Derivation map

orient
[Coverage Workspace](https://banes-lab.com/records/algo/coverage-workspace.md)

see
[Surface Grid Walk](https://banes-lab.com/records/algo/surface-grid-walk.md)

derive
[Uncovered Gap Derivation](https://banes-lab.com/records/algo/uncovered-gap-derivation.md)

intent
[Coverage Risk Prioritisation](https://banes-lab.com/records/algo/coverage-risk-prioritisation.md)

project
[Technique and Invariant Selection](https://banes-lab.com/records/algo/technique-invariant-selection.md)

act
[Test Authoring](https://banes-lab.com/records/algo/test-authoring.md)

verify
[Evidence Verdict](https://banes-lab.com/records/algo/evidence-verdict.md)

commit
[Coverage Ledger](https://banes-lab.com/records/algo/coverage-ledger.md)

terminate
[Coverage Completion](https://banes-lab.com/records/algo/coverage-completion.md)

Before

```text
Coverage is pursued by intuition and reported as a percentage, so the space a system can fail in is never walked and unknown surfaces pass silently.
```

After

```text
workspace → grid walk → gap derivation → risk priority → technique+invariant → authored test → evidence verdict → ledger → completion
```

### <Test Coverage Concern>

- Meta record

Details

Intent
<Load the surface catalog for a unit> → <Walk the dimension x lens grid> → <Derive the required-uncovered surfaces> → <Prioritise by risk> → <Select a mode-matched technique and its invariant> → <Author the test> → <Issue an evidence verdict> → <Ledger the coverage state> → <Terminate when no required surface is unknown>

Invariant
Coverage is complete when every (dimension x lens) surface the unit can fail in carries a surface, a technique, and an invariant with a non-unknown verdict.

Flow

```text
SurfaceSpace → GridWalk → RequiredGaps → Priority → TechniqueInvariant → AuthoredTest → Verdict → Ledger
```

Productions

```bnf
TestCoverageConcern ::= <SurfaceCatalog> "->" <DimensionLensGrid> "->" <RequiredUncoveredSet> "->" <PrioritisedSurfaceQueue> "->" <SurfacePlanSet> "->" <RunnableTestSet> "->" <VerdictSet> "->" <CoverageLedger>
```

Composes
none

Forces
[correctness_verification](https://banes-lab.com/records/force/correctness-verification.md), [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)

Grounds
none

## Links to

- [Orient](https://banes-lab.com/records/stage/orient.md)
- [Ontology](https://banes-lab.com/records/reason/axis-ontology.md)
- [Set Theory](https://banes-lab.com/records/reason/math-type-set-theory.md)
- [Test Coverage Kernel](https://banes-lab.com/records/algo/test-coverage-kernel.md)
- [correctness_verification](https://banes-lab.com/records/force/correctness-verification.md)
- [See](https://banes-lab.com/records/stage/see.md)
- [Analysis](https://banes-lab.com/records/reason/axis-analysis.md)
- [semantic_consistency](https://banes-lab.com/records/force/semantic-consistency.md)
- [Anomaly](https://banes-lab.com/records/reason/lens-anomaly.md)
- [Semantic Correctness](https://banes-lab.com/records/reason/test-surface-semantic-correctness.md)
- [Derive](https://banes-lab.com/records/stage/derive.md)
- [Reasoning](https://banes-lab.com/records/reason/axis-reasoning.md)
- [Logic](https://banes-lab.com/records/reason/math-type-logic.md)
- [Intent](https://banes-lab.com/records/stage/intent.md)
- [Teleology](https://banes-lab.com/records/reason/axis-teleology.md)
- [Optimisation](https://banes-lab.com/records/reason/math-type-optimisation.md)
- [Tel Priority](https://banes-lab.com/records/reason/node-tel-priority.md)
- [Project](https://banes-lab.com/records/stage/project.md)
- [Algebra](https://banes-lab.com/records/reason/math-type-algebra.md)
- [contract_compatibility](https://banes-lab.com/records/force/contract-compatibility.md)
- [Act](https://banes-lab.com/records/stage/act.md)
- [Formalisation](https://banes-lab.com/records/reason/axis-formalisation.md)
- [Computation](https://banes-lab.com/records/reason/math-type-computation.md)
- [Verify](https://banes-lab.com/records/stage/verify.md)
- [Verification](https://banes-lab.com/records/reason/axis-verification.md)
- [Ver Evidence](https://banes-lab.com/records/reason/node-ver-evidence.md)
- [Commit](https://banes-lab.com/records/stage/commit.md)
- [Representation](https://banes-lab.com/records/reason/axis-representation.md)
- [Information Theory](https://banes-lab.com/records/reason/math-type-information-theory.md)
- [architecture_evolution](https://banes-lab.com/records/force/architecture-evolution.md)
- [Terminate](https://banes-lab.com/records/stage/terminate.md)
- [Termination](https://banes-lab.com/records/reason/axis-termination.md)
- [Ter Stop](https://banes-lab.com/records/reason/node-ter-stop.md)
- [Coverage Workspace](https://banes-lab.com/records/algo/coverage-workspace.md)
- [Surface Grid Walk](https://banes-lab.com/records/algo/surface-grid-walk.md)
- [Uncovered Gap Derivation](https://banes-lab.com/records/algo/uncovered-gap-derivation.md)
- [Coverage Risk Prioritisation](https://banes-lab.com/records/algo/coverage-risk-prioritisation.md)
- [Technique and Invariant Selection](https://banes-lab.com/records/algo/technique-invariant-selection.md)
- [Test Authoring](https://banes-lab.com/records/algo/test-authoring.md)
- [Evidence Verdict](https://banes-lab.com/records/algo/evidence-verdict.md)
- [Coverage Ledger](https://banes-lab.com/records/algo/coverage-ledger.md)
- [Coverage Completion](https://banes-lab.com/records/algo/coverage-completion.md)
- [The derivation loop](https://banes-lab.com/ontology/reasoning/reason-loop-derivation-loop.md)
