# Disjunctive leases: a stable witness is not a current observation

A small executable companion to the [glossary entry](https://hesela.dev/terms/disjunctive-lease/).
This is original synthetic Boolean reasoning, not a FARSITE execution or benchmark.

## Question

When can a client retain a known OR of other clients' bits while another client
is allowed to change its own bit? The distinction is between an observed value
and permission to rely on it remaining unchanged.

## Four inspectable cases

Clients are ordered X, Y, Z; Y is the observer in every row.
A fixed bit cannot change while the considered permissions remain in force.
An unknown protected value is not the Boolean value false.

| Case | Current bits X/Y/Z | Protected value for Y | Requested writer | Grant while retaining Y's read? |
| --- | --- | --- | --- | --- |
| Fixed witness | true/false/false | true | Z | Yes |
| Mutable witness X | true/false/false | unknown | Z | Not applicable: Y has no safe read |
| Self-exclusion | false/true/false | false | Z | No |
| Release sole witness | true/false/false | true | X | No |

The second row deliberately has a currently true OR but no fixed witness.
The third row makes Y true without changing Y's own aggregate.
In the last row, letting X change would destroy the assumption that kept Y's
answer stable. These are counterexamples to two tempting shortcuts:
treating a current value as protected knowledge, or counting the observer's
own contribution as a witness.

## Method and limits

[model.py](model.py) computes read and write permission predicates.
[test_model.py](test_model.py) separately enumerates every future assignment
of independently writable bits for one through four clients, then checks
whether each reader's aggregate can change. Tests cover invalid inputs,
empty other-client sets and an inconsistent starting read grant.
[results.json](results.json) is generated, never manually copied.

This abstraction deliberately omits messages, lease expiry, client failure,
recovery, fairness, latency, handle counts, and content writes. It is not a
verification of implementation code, a liveness proof, or a performance estimate.
A write-grant check assumes the existing readers already have consistent grants.

## Replay

Use Python 3.10 or newer, with no third-party packages.

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

Omit --check to regenerate the example JSON. The tests use unittest assertions,
so optimized Python does not disable verification.

## Source boundary

The permission model follows sections 4.5-4.7 of Douceur and Howell's
[Black Box Leases](https://www.microsoft.com/en-us/research/wp-content/uploads/2005/09/tr-2005-120.pdf),
MSR-TR-2005-120 (2005). The
[OSDI 2006 paper](https://www.usenix.org/legacy/event/osdi06/tech/full_papers/douceur/douceur_html/)
provides the implementation context and separate empirical experiment.
The report's general black-box abstraction is broader than its Boolean-OR specialization.

Metadata and exact section locators: [sources.json](sources.json).
Only Hesela's original example/code are distributed here, under [LICENSE](LICENSE);
the linked third-party papers retain their own rights.
