# Fragment placement changes what a failure fraction means

Six lost hosts out of twelve do not determine one universal object-loss probability.
For six distinct, uniformly placed fragment holders, a two-survivor reconstruction
threshold gives **37/924 (about 4.00%)** loss. An independent-fragment model with the
same marginal loss probability gives **7/64 (10.94%)**. Requiring five survivors
reverses which model reports the larger risk.

This is a constructed mathematical example, not measured durability and not a
reproduction of Glacier's identifier-ring placement. It helps audit the assumptions
behind storage-redundancy calculations. Start with the [Glacier research-system
record](https://hesela.dev/terms/glacier/) for the historical mechanism and evidence.

## Define the event before choosing the distribution

Let H be the number of hosts, F the number destroyed in one event, n the fragment
count and r the number of surviving fragments sufficient to reconstruct an object.
The code model assumes any r distinct valid fragments suffice. No repair occurs
during this event.

Fix the failed set before drawing a uniformly random n-host placement without
replacement. Each host holds one fragment. Failures inside the fixed set may share
one cause: the randomness in this calculation is **placement**, not independent
physical failure clocks. The failed set must not be chosen in response to this
object's actual placement.

If L counts lost fragments, count the placements directly:

```text
P(L = j) = C(F,j) C(H-F,n-j) / C(H,n)
object loss: L >= n-r+1
```

C(a,b) counts b-element subsets of an a-element set; impossible choices contribute
zero. For H=12, F=6, n=6, r=2, loss means five or six fragments disappear:
(6*6 + 1)/924 = 37/924. The denominator is the 924 possible distinct holder sets,
not device-hours, observed failures or repair trials.

## The approximation does not have one error direction

The comparator removes each of six fragments independently with probability 1/2.
It does not constrain the total host losses to six. Its lost-fragment count is
binomial. Both models have three expected lost fragments, but different tails.

| Required survivors r | Distinct-holder loss | Independent-fragment loss |
| --- | --- | --- |
| 2 | 37/924, about 4.00% | 7/64, about 10.94% |
| 5 | 887/924, about 96.00% | 57/64, about 89.06% |

The second row is a counterexample to calling the independent approximation
universally conservative. It is not a recommendation to use such a weak code.
[Generated results](results.json) include every r from one through six and retain
exact fractions; displayed percentages are rounded.

## Count hosts, not just fragment files

Now put two fragments on each of three uniformly chosen distinct hosts, still
requiring any two of the six fragments. The object is lost only when all three
holders belong to the fixed six-host failure set. That probability is
C(6,3)/C(12,3) = **1/11 (about 9.09%)**. Identical fragment counts therefore need
not provide identical protection. The enumerator also supports unequal fragment
counts per occupied host, within a deliberately small 20-host limit.

If an adversary may instead select the actual holders after learning placement,
destroying five of six distinct holders suffices for the r=2 object. A six-host
budget permits this for every placement. The 4.00% calculation cannot describe
that adversary.

## Historical connection and limits

Glacier's section 4.8 uses a Bernoulli approximation with randomly distributed
vulnerabilities; it distinguishes that setting from arbitrary targeted holders.
The finite-population experiment here is an alternative, explicitly idealized
placement model, not a correction to a measured Glacier result.
[NSDI 2005 paper](https://www.usenix.org/legacy/event/nsdi05/tech/full_papers/haeberlen/haeberlen.pdf).

Informed replication offers a different design choice: use host configurations
to select survivor sets under a vulnerability model. Such sets are only as
complete as the modeled dependencies.
[USENIX ATC 2005 source](https://www.usenix.org/legacy/publications/library/proceedings/usenix05/tech/general/full_papers/junqueira/junqueira_html/node4.html).

The examples omit repair, churn, missing metadata, leases, silent corruption,
heterogeneous placement weights and shared placements across objects. An annual
failure rate cannot be substituted for F/H without a time-window and event model.
An object-survival probability cannot be raised to an object count unless the
required cross-object independence is justified.

## Reproduce and audit

Files: [model.py](model.py), [test_model.py](test_model.py),
[results.json](results.json), [sources.json](sources.json).

Run in this directory with Python 3. No third-party packages, random seeds or
external data are needed.

```sh
python3 -B model.py --check
python3 -B -m unittest discover -s . -p test_model.py
python3 -B -O -m unittest discover -s . -p test_model.py
```

The tests independently enumerate all distinct placements for host populations
one through eight, check reconstruction boundaries, enumerate binomial bit
patterns, and check grouped hosts and invalid inputs. Exact rational outputs
have no Monte Carlo error; that says nothing about physical model uncertainty.
