# FARSITE: reaching file bytes and reaching the directory

A file-copy count cannot describe an access path that also needs a directory
decision. This exact worked example separates those conditions and makes shared
physical hosts explicit. It is a synthetic snapshot calculation, not storage
measurements or a reproduction of FARSITE.

## Historical scope

The [2002 architecture](https://www.usenix.org/legacy/event/osdi02/tech/full_papers/adya/adya_html/index.html)
distinguishes Byzantine-replicated directory state from ordinary file copies
(section 3.1). The [glossary record](https://hesela.dev/terms/farsite/)
summarizes that design.

The [2006 paper](https://www.usenix.org/legacy/event/osdi06/tech/full_papers/douceur/douceur_html/)
addresses a different problem: distributing metadata beyond one group.
Its stable identifier hierarchy separates placement from path renaming;
recursive path leases preserve namespace consistency. Crucially, section 7.1
says that the evaluated directory service had not yet incorporated BFT.
Section 8 uses 40 machines, not the target of 100,000 clients.
Combining the early fault-tolerance design with the later throughput
evaluation into one demonstrated production system would erase this boundary.

## Precisely defined event

Consider seven directory hosts and three content hosts. Each distinct physical
host is independently reachable with probability p = 9/10 at one instant.
A shared host has one state, not two independent draws.

Define D as at least five directory hosts reachable, and C as at least one
content host reachable. The event reported is D AND C. It is only a host-count
condition for an operation needing both contacts. It does not execute a
Byzantine protocol, validate replies, resolve paths or prove timely completion.
Reachable hosts here are assumed correct, mutually communicating and holding
the required current state. The directory threshold is borrowed from the
seven-member failure budget, not inferred from a measurement.

For disjoint placements:

```text
P(D) = sum(comb(7, i) * p**i * (1-p)**(7-i), i=5..7)
P(C) = 1 - (1-p)**3
P(D AND C) = P(D) * P(C)       # only for disjoint independent host sets
```

When the sets overlap, the program enumerates each unique-host state once and
adds its exact rational probability if both conditions hold.

<!-- results:start -->
| Shared hosts | Directory condition (%) | Content condition (%) | Joint condition (%) | Product of marginals (%) |
| --- | --- | --- | --- | --- |
| 0 | 97.430850 | 99.900000 | 97.333419 | 97.333419 |
| 1 | 97.430850 | 99.900000 | 97.342276 | 97.333419 |
| 2 | 97.430850 | 99.900000 | 97.371801 | 97.333419 |
| 3 | 97.430850 | 99.900000 | 97.430850 | 97.333419 |
<!-- results:end -->

Percentages are rounded to six decimals to expose the small placement
difference; the inputs are illustrative. Exact fractions are in
[results.json](results.json), not inferred measurement precision.

## What the example establishes

Content-only reachability overstates the joint condition for disjoint hosts.
More content copies cannot remove the directory condition: D AND C is a subset
of D. Improving the probability of C eventually hits this ceiling.

There is also a less obvious trap. With all three content hosts drawn from
the seven directory hosts, five reachable directory hosts force at least one
content host to be reachable: the remaining four hosts cannot meet the
directory threshold alone. Therefore P(D AND C) = P(D) in that row.
Multiplying the marginals would be wrong even though all physical hosts are
independent.

This is not a recommendation to colocate replicas. It compares only one
snapshot event, with no site failures, capacity constraints or repair traffic.
Placement can affect other objectives in the opposite direction.
A cached operation with sufficient authority may not need fresh directory
contact. Multiple directory groups, lease expiry, stale content, unavailable
keys, malicious replies and client failure need additional models. Annual
durability, downtime duration and repair deadlines cannot be obtained here.

## Reproduce and verify

Requires Python 3.10 or newer, standard library only. No network, datasets,
credentials or random seed are used.

```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
```

[model.py](model.py) exhaustively enumerates at most 16 unique hosts and rejects
duplicate identities within a replica set. [test_model.py](test_model.py)
checks 36 disjoint configurations against a binomial formula, 12 overlapping
configurations against a separate conditional formula, boundary probabilities,
identity relabeling, the subset relation and invalid parameters.
No Monte Carlo uncertainty is involved; uncertainty about real deployments is
in the assumptions, not a confidence interval around this arithmetic.

Run `python3 -B model.py --write` to regenerate results and the table.
[sources.json](sources.json) records source scope and access dates.
[LICENSE](LICENSE) covers only the new calculation code; third-party papers
are linked, not redistributed.
