# Repair windows: detection does not replenish redundancy

In an ideal 4-of-6 erasure-coded object, two missing fragments can be rebuilt.
Three missing fragments cannot. A perfect detector can report every loss and
still leave the object unrecoverable if repair starts too late.

This is a deterministic teaching example, not HAIL's coding construction,
security proof, empirical durability estimate or recommended repair interval.

## State and ordering

There are n distinct fragment locations. Any k correct fragments recover the
object, following the MDS erasure abstraction in
[RFC 5510, sections 3.1 and 8.3](https://www.rfc-editor.org/rfc/rfc5510.html).
The decoder knows which fragments are missing. Silent corruption, Byzantine
responses and failed authentication are outside this model.

Every period has three ordered operations:

1. A specified set of fragment locations loses its contents.
2. An ideal audit identifies all missing fragments and tests whether k remain.
3. At a scheduled repair boundary, all missing fragments are restored only if
   recovery is still possible.

The audit does not itself change data. A repeated hit on an already missing
fragment does not create a second erasure. Unrecovered erasures persist across
periods. Once fewer than k fragments remain, later repair cannot recreate the
object from these fragments; no external copy is modeled.

Repair is instantaneous at the boundary, successful and trusted, and the next
loss happens afterwards. Real repair duration, failures during repair, partial
repairs, metadata loss and verifier compromise are omitted. Periods have no
assigned duration, so the example yields no calendar-time recommendation.

## Exhaustive result

For n=6, k=4, three periods and exactly one hit per period, there are
6 * 6 * 6 = 216 ordered schedules. Enumeration includes repeated hits.

| Repair boundary | Schedules examined | Schedules losing recovery |
| --- | ---: | ---: |
| After every period | 216 | 0 |
| After every two periods | 216 | 0 |
| After every three periods | 216 | 120 |
| No repair | 216 | 120 |

The last two rows lose recovery precisely when all three hits are distinct:
6 * 5 * 4 = 120. On the third-period boundary the loss occurs before repair,
so a repair attempt cannot rescue those schedules. A trace of hits 0, 1, 0 has
only two missing fragments and remains recoverable without repair.

The counts are properties of the enumerated schedule set. No probability
distribution over schedules, device independence or real-world event rate is
assumed. Dividing 120 by 216 would require an explicitly chosen uniform
schedule model to interpret the result as a probability.

## General boundary

Starting from a fully repaired state, at most b new distinct erasures per period
can accumulate to at most min(n, b*d) before a repair after d periods.
For k >= 1, the condition b*d <= n-k is sufficient to survive every schedule in
that interval under the stated assumptions. It is also necessary for this
worst-case guarantee: if b*d > n-k, choose fresh locations until n-k+1 have
been lost. Particular schedules with repeated hits can survive longer.

This bound belongs to the ideal known-erasure model. It must not be substituted
for HAIL's adversarial coding constraints or detection probabilities.

## Reproduce

Requires Python 3.10+ standard library only. Run in this directory:

```sh
python3 -B model.py --check
python3 -B -m unittest -v test_model.py
```

[Model](model.py), [tests](test_model.py), [results](results.json) and
[source metadata](sources.json) are downloadable together with this method.
The model has no random seed because it exhaustively enumerates bounded states.

## Reading connection

[HAIL](https://hesela.dev/terms/hail/) provides the historical research context.
[Proof of retrievability](https://hesela.dev/terms/proof-of-retrievability/)
distinguishes a protocol's extraction guarantee from one successful challenge.
[Erasure coding](https://hesela.dev/terms/erasure-coding/) supplies the
recovery vocabulary. This example implements neither cryptographic protocol.

The practical question is not only whether damage can be detected, but whether
enough verified fragments remain until repair actually completes.
