# Repair-acceptance case study

This is a constructed, executable process laboratory. It does not run an
AI agent, Kubernetes, cloud infrastructure or a production workload.

## Requirements and execution boundary

Use Python 3.12 or later. No third-party package is required for the study.
The recorded campaign used Python 3.12.2 on Windows 11.

The runner starts Python child processes, creates SQLite data in a fresh
temporary directory and makes HTTP requests only to `127.0.0.1`. It uses
automatically allocated local ports, except when restarting its own
dependency on the same port. Proxy environment settings are bypassed for
these loopback requests.

It terminates only the processes it started and removes only its own
temporary trial directory. It does not alter system services, use cloud
credentials, access a container socket or contact a model provider.
The credential strings in the fixtures are synthetic test values.

## Reproduce

From this directory:

```text
python -B -m unittest -v test_study
python -B study.py --output reproduced
python -B analyse.py reproduced
```

The default is five repetitions, specified in `protocol.json`: 300 trials.
For a quicker development check:

```text
python -B study.py --output smoke --repetitions 1
python -B analyse.py smoke
```

The output directory must not already exist. Do not mix campaigns.
The protocol and case labels are designed inputs, not preregistered
population hypotheses.

Timing values, target identifiers, timestamps and raw file hashes will
differ between executions. Investigate inconsistent outcomes; do not
replace a single anomalous trial and report the resulting mixture.

## File map

| File | Purpose |
| --- | --- |
| `protocol.json` | Scopes, repetitions, timing boundary and development amendment. |
| `cases.json` | Twelve authored repairs and reference labels consulted during analysis. |
| `service.py` | Real loopback HTTP application and SQLite-backed dependency. |
| `study.py` | Fixture setup, incident reproduction, repair application, independent probes, transitions and receipts. |
| `test_study.py` | Focused mechanism, composition, missing-evidence and receipt-validity tests. |
| `analyse.py` | Input validation, complete-cohort checks, case summaries and SVG figures. |
| `sources.json` | Source-to-claim map for the paper. |
| `results/trials.jsonl` | Final campaign: one JSON record per case/profile/repetition. |
| `results/inputs/` | Exact protocol, cases, services, controller and analyser frozen before the campaign. |
| `results/manifest.json` | Run metadata and SHA-256 digests. |
| `results/case-outcomes.csv` | One row per authored case, with all five profile results. |
| `results/summary.csv` | Case counts and exact local timing summaries. |
| `results/example-receipt.json` | Expired example from a temporary source-repair target. |
| `results/analysis-manifest.json` | Derived-product and analyser digests. |
| `development-run/` | Original campaign and its source snapshots, retained separately. |
| `prior-run/` | The earlier four-profile campaign, derived outputs and exact analyser, retained separately. |

The analyser checks that the executable inputs match the selected
campaign. It refuses to analyse either archived campaign against the
current source.

To reanalyse `prior-run`, use a separate extracted copy. From that
campaign's `inputs` directory, run `python -B analyse.py ..`. Its frozen
analyser imports the earlier controller, protocol and case definitions.
This regenerates the earlier derived files without changing the primary
campaign.

The timeout-affected `development-run` has raw observations and measured
inputs. Its variable outcomes prevented an accepted summary. Inspect
those raw records separately.

## What executes

Every trial preflights the dependency, then demonstrates the original
unavailable-backend incident. After applying its candidate, it performs a
write and readback through the application.

The state profile adds desired/active agreement, two enabled declarations
and exact preservation of three historical records. Comparisons normalise
the fixture's documented equivalent backend names. The declarations
check configuration only. Monitoring and controller liveness remain
untested.

The source-chain profile also compares the desired configuration with
the packaged release. Restart and lifecycle profiles include this cheap
check before executing transitions.

Restart loads the active file. Reconciliation copies desired to active
and restarts. Replacement starts the application using the release
configuration. Rotation changes the dependency and client delivery
credentials and restarts the dependency on its existing endpoint,
without restarting the application.

Each transition is followed by transaction and preservation checks.
The rotation obligation requires live credential pickup. A policy that
permits or requires a coordinated client rollout would need a different
test sequence.

The service never reads case identifiers or expected outcomes. Labels
are consulted only by analysis to verify the intended fixture behaviour.
The fixtures demonstrate mechanisms and do not estimate how frequently
agents produce them.

## Decisions and receipts

A confirmed violation fails the profile and stops later checks.
The later checks remain explicitly `not-run`.

Missing evidence produces `inconclusive`, unless another check observes a
violation. An accepted receipt requires the complete `lifecycle` profile.
A narrower pass is `scope-only`.

The receipt fingerprint binds a target identity and the specified
configuration/launch inputs. It does not continuously observe the target
or sign the evidence. The controller and service have the same operating
system privileges. This is not a hostile-agent security boundary.

`assess_receipt` checks the complete scope, protocol and verifier digests,
ordered successful checks, current fingerprint and validity interval.
The receipt records verification start and completion separately. It
cannot apply before completion or extend beyond the illustrative
900-second lifetime measured from completion.

This is metadata validation of a prior observation, with no new live
health or preservation probe. Receipts are unsigned and are not
authorisations to operate another system.

## Interpreting the captured results

The final campaign has 12/0/0 passed/failed/inconclusive cases for
transaction checks, 7/4/1 for state checks, 6/5/1 for the source chain,
5/6/1 for source chain and restart, and 3/7/2 for the declared lifecycle.

These are counts over twelve designed cases. Each of the five
repetitions reuses those cases to check consistency and measure elapsed
time.

Timing summaries use only the three valid controls, with fifteen
observations per profile. They include tested transitions and waits, and
exclude initial setup, repair application and final cleanup. The p95
describes the captured timings; it provides no confidence bound.

The first complete development campaign had a single unexpected 502
dependency timeout in one transaction-only trial. The protocol records
the preflight and deadline correction, followed by a complete 240-trial
four-profile campaign.

Protocol 1.1.0 strengthens that comparison with a release inspection and
a valid control using different equivalent backend names across layers.
All 300 final trials were newly executed after that revision. The
stronger baseline catches the stale release before replacement, so
replacement receives no incremental detection credit in the new
comparison. Reconciliation also adds no first rejection. Service-specific
configuration rules could identify the remaining mechanisms in this small
fixture.

No production reliability, agent ranking, cost benefit, universal
durability guarantee or optimal test sequence is established.
