# One-block copy ledger

A synthetic accounting example, not a reproduction of a performance experiment.
Run with Node.js 22 or later:

```sh
node model.mjs
node --test model.test.mjs
```

[Executable ledger](model.mjs) | [Tests](model.test.mjs) |
[Definition and primary sources](https://hesela.dev/terms/doubly-distorted-mirrors/)

## Constructed trace

One new 4096-byte block version, no overwrites or coalescing:

| Completed event | New-version locations | Data writes so far | Data bytes written |
| --- | --- | ---: | ---: |
| Enqueue only | None on disk | 0 | 0 |
| Temporary write on disk 0 | temp-0 | 1 | 4096 |
| Temporary write on disk 1 | temp-0, temp-1 | 2 | 8192 |
| Fixed-location write on disk 0 | temp-0, temp-1, home-0 | 3 | 12288 |
| Retire temp-0 | temp-1, home-0 | 3 | 12288 |

The retirement changes live locations, not the accumulated write count.
Before the second disk write, losing disk 0 loses the only disk copy of
this version. After both temporary writes, either single-disk loss leaves a
copy, conditional on the assumptions below. Keeping two locations on disk 0
alone would not give the same protection.

## Assumptions and limits

A write event means the complete new version is readable at a known location.
The test has no partially completed writes, device caches, mapping-log failures,
old-version recovery, commit acknowledgements or simultaneous disk failures.
Its two-disk predicate is a data-copy property, not an end-to-end durability
guarantee. The ordering check is deliberately limited to this chosen trace.

Byte counts exclude mapping metadata, journals, retries and device-internal
traffic. No elapsed time, seek cost, IOPS or energy is inferred. Spare space is
assumed sufficient. Early retirement is a negative control and must fail.
