# Green tests, missed clamp requirement

This original teaching kit calls the exact exported functions in `clamp.py`.
It shows three distinct reasons a green result can be insufficient: a missing
input, an assertion that permits a forbidden result, and a finite selection that
does not exercise a deliberately wrong interior case. It is not a customer or
production incident.

## Reproduce

Use ordinary Python 3.10 or newer, with assertions enabled. No packages, Proof
service, credential or network connection are required. From the extracted kit:

```sh
python3 reproduce.py
```

`rerun-output/` must be absent or empty. Preserve a previous run by selecting a new
directory:

```sh
python3 reproduce.py --output-dir another-run
```

The wrapper exits **0 when all expected passing and failing observations are
reproduced**, not when every implementation is accepted. It retains commands,
UTC timestamps, runtime settings, source hashes and raw stdout/stderr. Do not run
it with `-O` or `PYTHONOPTIMIZE`: the unchanged historical snippet contains actual
`assert` statements, which optimized Python can remove. The new structured harness
uses explicit comparisons rather than `assert` for acceptance.

## Authored contract and independent oracle

The fictional input precondition is `type(requested) is int`, excluding booleans.
The rule returns 1 below 1; preserves the requested integer from 1 through 20
inclusive; and returns 20 above 20. **Negative integers are allowed and clamp to
1 by a newly authored teaching rule.** The old article did not establish that
negative-input policy. It is not inferred from current behavior or asserted as
approved product intent.

No parser or type validator is implemented here. Behavior for booleans, floats,
strings and other values outside that precondition is unspecified and unperformed.
Python integers use arbitrary precision; this is not a fixed-width overflow test.

The selected table in `cases.json` has nine literal expected values:

| Requested | Required | Selection reason |
| ---: | ---: | --- |
| -1 | 1 | Newly declared negative-input policy |
| 0 | 1 | Just below the inclusive lower limit; original failing input |
| 1 | 1 | At the inclusive lower limit; retained original case |
| 2 | 2 | Just above the lower limit |
| 10 | 10 | Retained nominal case |
| 19 | 19 | Just below the upper limit |
| 20 | 20 | At the inclusive upper limit |
| 21 | 20 | Just above the upper limit |
| 30 | 20 | Retained far-upper case |

The six edge neighbors are 0/1/2 and 19/20/21. They are part of the nine, not six
additional distinct cases. Input 7 with literal expected result 7 is intentionally
held out from that table for a separate seeded-control challenge. The complete
experiment therefore uses **ten distinct requested integer values**.

Expected values are authored literals in a test-owned JSON table. The new harness
does not compute its expected result by copying the candidate `max/min` repair.
See `contract.json` for exact domain, implementation descriptions and exclusions.

## Observed contrasts

| Implementation and gate | Passed / executed | Child exit |
| --- | ---: | ---: |
| Upper-only baseline, existing 1/10/30 with literal oracle | 3 / 3 | 0 |
| Upper-only baseline, original input 0 with literal oracle | 0 / 1 | 1 |
| Upper-only baseline, six neighbors with deliberately weak 0..20 assertion | 6 / 6 | 0 |
| Upper-only baseline, selected nine with literal oracle | 7 / 9 | 1 |
| Corrected implementation, selected nine | 9 / 9 | 0 |
| Constant-one wrong implementation, selected nine | 3 / 9 | 1 |
| Cap-nineteen wrong implementation, selected nine | 6 / 9 | 1 |
| Seeded interior-hole implementation, selected nine | 9 / 9 | 0 |
| Seeded interior-hole implementation, held-out 7 | 0 / 1 | 1 |
| Corrected implementation, held-out 7 | 1 / 1 | 0 |

The upper-only baseline returns 0 for requested 0, violating required result 1.
The existing three tests omit that input. Merely adding edge inputs is still
insufficient if the assertion accepts `0 <= actual <= 20`: that deliberately weak
gate accepts all six neighbors while retaining the known lower-bound violation.
The exact nine-case oracle rejects baseline inputs -1 and 0.

The actual corrected function is `max(1, min(requested, 20))`; it passes the nine
literal expectations and the separate input 7. Known-wrong constant-one and
cap-nineteen implementations are rejected, showing that the exact assertions
distinguish some incorrect behavior rather than accepting any bounded output.

The interior-hole variant is deliberately seeded to return 8 at requested 7 and
otherwise use the corrected calculation. It passes the selected nine but fails
the intentionally held-out input. This is a designed demonstration of finite
selection limits, not a randomized campaign, measured mutation score or
statistically independent validation set. It does not establish defect-class
closure; it shows why the selected green result alone cannot support that claim.

## Historical identity versus fresh execution

`historical-snippet.py` is the unchanged code extracted from the retained canonical
article, which attributes an execution to **2 October 2026**. The original raw log
and runtime are not available in this kit; that old execution is not authenticated
by this work. `historical-origin.json` records source hashes and that limit.

The wrapper separately **fresh-executes** those exact snippet bytes. It prints:

```text
Existing cases: 3 passed
Boundary case: requested=0, expected=1, actual=0
```

It then really raises `AssertionError`, exits 1 and retains raw stderr. This replay
uses its own current UTC timestamps and runtime, never the old date. The original
snippet's passing expected expression mirrors the proposed repair; it is preserved
for historical identity, while new acceptance uses independent literal values.

## Files and bounded interpretation

`observed/` holds the original fresh run's raw child output and summary. A new rerun
uses its own chosen output directory and cannot overwrite the retained observations.
`PROVENANCE.json`, `manifest.json` and `SHA256SUMS` bind the shipped files. The kit
contains no customer code, private input or API key.

One original failing input fixed is instance evidence. The selected table adds
bounded requirement checks at both limits, a nominal input and the declared
negative policy. Neither those passes nor the rejected seeded controls prove the
rule for every Python integer, close a defect class, or cover a real caller's
parser, representation limits, scheduler, resource limits or integration.
Collection and duration examples, if discussed elsewhere, remain illustrative.
No Proof CLI command, solver or CI merge policy is executed by this kit.
