# A batch crash, a smaller witness, and a repair that still does the work

This original fictional teaching worker receives a direct Python `list[str]` and
stores usable text in SQLite. The earlier article's production-like story was
illustrative; this kit does not authenticate a customer incident or historical
run. These are new local executions against the exact exported implementation.

## Run

Use Python 3.10 or newer with its standard-library `sqlite3` module. No package,
Proof service, network, credential or customer data is required. From the extracted
kit directory:

```sh
python3 reproduce.py
```

The default `rerun-output/` must be absent or empty. Preserve a previous run by
choosing a fresh directory:

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

Wrapper exit **0 means the complete expected experiment reproduced**, including
children that must fail. It does not accept the baseline, an always-noop patch,
or an entire failure class. Commands, UTC times, versions, source hashes and raw
stdout/stderr are retained in the selected output directory.

## Declare the behavior before patching

The direct-call precondition is an exact list whose elements are exact strings,
with no active transaction on the supplied connection. No absent argument,
`None`, map, non-string element, bytes, HTTP or parser policy is established.

A string is usable if `strip()` is nonempty. This classifies blankness only:
usable original text, including its spaces, must be stored unchanged. The few
ASCII whitespace examples are not a Unicode-whitespace or parser matrix.

Newly authored fictional decisions:

- Raw `[]`: return the exact no-op response and preserve existing rows.
- Nonempty all-blank list: reject as `no_usable_records`, report the skipped count,
  and preserve existing rows.
- At least one usable string: append every usable original string in order,
  return the first usable string, and report stored/skipped counts.

Every invocation starts with one existing row, `[1, "preexisting"]`. The independent
oracle compares literal responses, exact types/keys and all ordered rows after
closing and reopening the database. It also records immediate state and an open
transaction. A no-op or rejection cannot quietly erase the earlier row.

## What actually fails

The baseline filters blank strings, then `_persist_usable()` reads `usable[0]`
to supply the first actual INSERT before writing the remaining strings. This
is a real work-path assumption, not an unused exception probe. An empty or
all-blank list makes that access raise `IndexError` before any BEGIN or INSERT.

`run_cases.py` catches and records the exception from the exact callable; a caught
observation is not an uncaught process crash. The wrapper separately runs
`crash_child.py`, which calls the same byte-identical baseline with three blank
strings and **does not catch the exception**. That Python child exits 1 with the
actual `IndexError: list index out of range` traceback. The expected exception,
source site and unchanged database are checked; a generic setup/import failure
or bare nonzero exit does not satisfy this experiment.

The corrected function distinguishes raw empty input from a filtered-empty list
before using the same valid work path. It must keep populated and mixed cases
working, rather than merely return without crashing.

## Retained witnesses and regression cases

The original witness is `["", " ", "\t"]`. A measured greedy first-element
deletion sequence executes four inputs with lengths **3 → 2 → 1 → 0**. Every
observation retains the same exception type/message, file/function/line/source text
and `batch.py` hash. Three deletions reach `[]`.

This does **not** make the inputs semantically interchangeable: the original
nonempty all-blank batch must reject, while the smaller empty list must no-op.
Keep both witnesses. This is one actual deletion sequence, not a general delta
debugger, parser shrink campaign or claim about a global minimum across input
representations or failures.

The seven prewritten literal cases are:

| Case | Input | Required result | New stored bodies |
| --- | --- | --- | --- |
| Minimal empty | `[]` | `noop`, first null, stored 0, skipped 0 | none |
| Original all blank | `["", " ", "\t"]` | rejected `no_usable_records`, stored 0, skipped 3 | none |
| Blank singleton | `[""]` | rejected `no_usable_records`, stored 0, skipped 1 | none |
| Single valid | `["alpha"]` | applied, first alpha, stored 1, skipped 0 | alpha |
| Multiple valid | `["alpha", "beta"]` | applied, first alpha, stored 2, skipped 0 | alpha, beta |
| Mixed | `["", "alpha", " \t", "beta"]` | applied, first alpha, stored 2, skipped 2 | alpha, beta |
| Padded valid | `[" padded "]` | applied, first unchanged, stored 1, skipped 0 | ` padded ` |

Exact response keys/types and row IDs/bodies are in `cases.json`; no expected
answer is computed from the worker's filtering or persistence code.

## Gate contrasts

| Gate | Passed / executed | Child exit |
| --- | ---: | ---: |
| Baseline, two populated cases | 2 / 2 | 0 |
| Baseline, full seven response/state checks | 4 / 7 | 1 |
| Corrected, full seven response/state checks | 7 / 7 | 0 |
| Always-noop candidate, weak no-exception gate | 7 / 7 | 0 |
| Always-noop candidate, response/state gate | 1 / 7 | 1 |

The deliberately wrong always-noop candidate stops exceptions but drops all four
selected populated/mixed cases and returns the wrong rejection behavior. The
response/state gate detects those losses. A green no-exception gate alone cannot
accept the repair.

Per wrapper run there are **30 suite calls**, **4 reduction calls**, and **1
uncaught-child call**, totaling **35 exported-function invocations**. The seven
regression cases plus two reduction intermediates give **nine distinct batch
arrays**. Original/minimal reduction inputs already belong to the seven cases;
repeated runs and the separate crash child do not add unique cases.

## Database configuration and evidence limits

Connections use `isolation_level=None` and explicitly pin legacy transaction
control on Python 3.12+. PRAGMAs select DELETE journaling and FULL synchronous
mode. Valid work uses explicit BEGIN IMMEDIATE, first/remainder inserts and COMMIT;
SQLite errors are explicitly rolled back and raised. The tested indexing failure
occurs before the transaction. Runtime and actual settings are recorded.

Close/reopen observes persisted rows at that point. It does not test power-loss
durability, crash recovery, SQL failure, locking, interrupted retry, duplicates,
idempotency, concurrency or restarts. No sibling-entry-point sweep or wider crash
class is accepted. The callable's list/string preconditions do not establish every
nil, absent, map, placeholder or malformed input policy.

`observed/` contains the original raw run and summary; new reruns cannot overwrite
it. `PROVENANCE.json`, `manifest.json` and `SHA256SUMS` bind the files. The exact
implementation remains executable without Proof. No Proof issue transition,
evidence capture, solver or class-closure check was executed by this kit.
