# Hazard to mitigation: a bounded queue evidence kit

This original fictional teaching case links an exposure, mitigation requirement, implementation and observed evidence. It does not approve product intent, accept residual risk or certify a system. Read CONTRACT.md and EVIDENCE-HANDOFF.json first.

## Reproduce locally

Use CPython 3.12 or later, standard library only. No Proof, network, account, solver, credentials or installation is needed. The retained primary run used CPython 3.14.7 on macOS; a replay on another runtime is a new observation.

From the extracted kit directory, with a new output directory:

```sh
python3 -B reproduce.py --output replay-output
```

The wrapper must exit0. Its baseline and reject-all children intentionally exit1; only corrected exits0. Wrapper success means the expected contrast reproduced, not acceptance of the faulty variants. Inspect replay-output/summary.json and the three complete stdout records. Do not use Python -O to remove assertions. The wrapper refuses an existing output directory.

## The selected result

One deterministic single-thread schedule runs on three fresh implementations. Each performs7 publications,8 drains,3 joins (two initial,one explicit replacement) and one profiled core constructor:19 selected method entries and17 complete state observations per variant. Across all variants:21 publish entries,24 drain entries,9 join entries,3 core constructors,57 selected method entries and51 snapshots. These are not51 distinct tests or all-function/branch coverage.

| Variant | Full literal snapshots | Full contract | Weaker resource-only gate | Slow queue peak |
|---|---:|---|---|---|
| baseline |7/17|fail|fail|6messages/24logical payload bytes|
| corrected |17/17|pass|pass|3messages/12logical payload bytes|
| reject-all control |1/17|fail|pass|0messages/0bytes|

The bound is PER QUEUE. Healthy peak is1message/4bytes for baseline and corrected. Maximum total logical payload across the two current queues was28bytes baseline,16corrected,0control. Logical byte accounting excludes object/allocator overhead, delivery-history/observer memory, heap/RSS and transport buffers. This is not a throughput, concurrency or memory-exhaustion benchmark.

At publication4 the correction clears slow's3queued messages/12bytes, leaves the offered4unenqueued and marks only slow inactive. Offers5/6skip it while healthy receives1..7. Explicit rejoin advances slow generation1to2; new slow receives only future7, with no replay promise. Local inactive state is not an actual socket/network close.

## Evidence and boundaries

- implementation.py is the actual deque implementation; run.py calls it directly and records selected method entry/return/source identities and full state.
- expected.json is a before-execution authored literal oracle. Exact JSON types, keys and values are compared; expected behavior is not inferred from the correction.
- captured/primary retains original commands, stdout, stderr, dates, runtime and results. The historical article's slow-tab table was an unexecuted plan; no production incident is authenticated here.
- EXECUTION-REVIEW.json separates counts, results and exclusions. PROVENANCE.json identifies source bytes and capture-specific fields. Runtime codeobject hashes vary even within the same function/run here; no cause is inferred. They are not one immutable function identity digest. Stable file/function-text hashes, qualified name/line and actual profile arguments/returns provide separate grounding.
- hazard-record.json is the unchanged pre-run authored record; EVIDENCE-HANDOFF.json links the selected completed observations without rewriting that history. Risk and release decisions remain NOT ASSESSED.
- MANIFEST.json lists payload members; SHA256SUMS covers payload members plus MANIFEST.json and excludes itself. The outer ZIP checksum is delivered separately.

The reject-all variant shows why a memory bound alone is insufficient: zero queues are bounded even when no healthy work completes. The strong oracle also checks overflow receipts, full contents and payload bytes, healthy progress, retired-session state and future-only rejoin. Other capacities, payload lengths, clients, interleavings, transport behavior, atomicity/cache duties and release authority remain outside this experiment.
