# Fictional display conversion: requirements, failure and correction

An original, executable software teaching fixture. Its units are arbitrary
`ticks` and `u`; it models no clinical value, physical measurement, actual device,
patient, diagnosis, treatment or clinical performance. It illustrates why a
display refactor needs explicit conversion, rounding and missing-data behavior.

## Contract and source

`fixture/requirements.json` states an explicitly fictional teaching contract:

- Valid available inputs are exact integers from 0 through 40, inclusive.
  Four ticks equal one arbitrary display unit `u`.
- Display one decimal place. An exact nonnegative halfway value rounds upward
  to the next tenth. Thus 1 tick is 0.25 u, displayed as `0.3`.
- Negative inputs are invalid and are never rounded, including any negative
  would-be halfway value. Booleans, strings and floats are also invalid.
- `None` means unavailable: text `Unavailable`, no numeric unit. It is not zero.
- Invalid input has an explicit invalid state/reason and no unit.

`fixture/display.py` contains a deliberately wrong baseline, an implemented
correction, and two explicitly hand-applied mutants. The baseline formats ties
to even and substitutes numeric zero for missing input. The correction handles
missing input separately and uses exact integer arithmetic for the declared
rounding rule. The two mutants restore one fault at a time.

## Inspect the oracle

`fixture/cases.json` has 12 selected contract cases with literal expectations.
`fixture/integer-domain-oracle.json` is an explicit answer table for all 41
accepted integer inputs. Each run independently cross-checks that literal table
using `Decimal` and `ROUND_HALF_UP`, rather than the correction's integer formula.
The expected missing/type/range outputs are literal contract records.

The two campaigns have different purposes. Selected valid integer cases overlap
the 41-integer campaign, so do not describe them as 53 distinct inputs or as a
complete test of every invalid Python value.

## Reproduce

Prerequisite: Python 3.9 or later. Standard library only; no pip dependencies,
network service, credentials or Proof CLI are needed. Inspect the source, extract
the kit, then run from its root using a new output directory:

```sh
python3 -B reproduce.py --output rerun-results
```

The wrapper executes these four independent processes from the kit root:

```sh
python3 -B fixture/run_cases.py --implementation baseline
python3 -B fixture/run_cases.py --implementation corrected
python3 -B fixture/run_cases.py --implementation mutant_ties_even
python3 -B fixture/run_cases.py --implementation mutant_missing_as_zero
```

| Implementation | Selected contract cases | Separate integer-domain checks | Expected process exit |
| --- | --- | --- | --- |
| Baseline | 9/12 pass; T04, T06 and T07 fail | 31/41 pass | 1 |
| Corrected | 12/12 pass | 41/41 pass | 0 |
| Ties-to-even mutant | 10/12 pass; T04 and T06 fail | 31/41 pass | 1 |
| Missing-as-zero mutant | 11/12 pass; T07 fails | 41/41 pass | 1 |

The wrapper returns 0 when the expected contrast, including the deliberate
failures, is reproduced. That exit does not approve a candidate or a release.
It refuses to overwrite captured or nonempty output directories. Each new run
records its own time, interpreter, platform, commands and source hashes.

`captured/` contains the retained actual execution, including complete
expected/observed outputs and its SHA-256 manifest. The kit-wide `SHA256SUMS`
identifies the delivered files. Digests identify bytes; they do not authenticate
a reviewer or establish a release decision.

## What the result establishes

The executed correction satisfies the literal selected cases and the complete
declared 0–40 integer conversion table. The selected mutants demonstrate that
these particular checks can detect the two deliberately reintroduced faults.
This is a local function/text-conversion result. No UI rendering, locale,
hardware, timing, stale-data or concurrency behavior was tested. No risk
classification, lifecycle completeness, device validation, final device release,
FDA clearance, IEC 62304 conformity or Proof execution is established.
