# File length cannot identify the blocks that must be flushed

Hesela worked example, 2026-12-04. This is an original, executable teaching
model, not a DFSCQ run, a Coq proof replay, a crash experiment or a benchmark.

## The source boundary

DFSCQ's SOSP 2017 paper qualifies its simplified data-synchronization contract
with a per-file block-stability condition: block lists must extend monotonically
through the pending tree history. Shrinking a file breaks that condition; flushing
the metadata log restores it by retaining one tree. Section 6.1 also explains why
freed blocks cannot be reused immediately while older metadata may survive.
These are research-system properties, not universal Linux API promises.
[Chen et al., sections 5.3-5.5 and 6.1](https://pdos.csail.mit.edu/papers/dfscq.pdf).

## A two-block example

Keep one inode throughout the example. A, B and C label different storage blocks;
their position in each list is the logical offset. They are not byte values.
Each row retains all metadata states still considered by our model.

| Stage | Retained block lists, oldest first | Latest length (blocks) | Old mapping outside the current list |
| --- | --- | ---: | --- |
| Initial | A,B | 2 | None |
| Truncate | A,B; A | 1 | B at offset 1 |
| Regrow | A,B; A; A,C | 2 | B at offset 1 |
| Metadata-log flush | A,C | 2 | None |

The starting and regrown files both have two blocks. A length-only comparison
therefore declares a match, yet the second position changed from B to C.
A current-list walk visits A and C; it cannot visit B through that list.
Our result records the missing historical mapping explicitly as state 0,
offset 1, block B. This demonstrates a limitation of the candidate reasoning,
not observed corruption or a failed system call.

Compare monotonic growth: A; A,B; A,B,C. Every earlier mapping remains at the
same offset in the latest list. The current targets cover all earlier lists.

## What the check proves

The model tests an ordered-prefix condition, not just a block count or a set
intersection. A,B followed by B,A preserves both count and set, but changes both
logical offsets. The tests reject that as stable.

Coverage alone is also insufficient to characterize the history. The artificial
sequence A,B; A; A,B ends with all old mappings present, but contains a shrinking
transition. We include it only as a negative predicate test. It is not a valid
claim that DFSCQ reuses B before the required barrier.

The metadata-log-flush row removes older lists from consideration. It does not
mark A or C as written to stable storage: the model contains no dirty buffers,
data values, device completion or data-flush operation. Restoring an invariant
is not the same operation as persisting file contents.

## Reproduce and inspect

The packet uses only Node.js built-ins. Keep these files in the same directory:

- [Model](https://hesela.dev/research/dfscq-block-identity/model.mjs)
- [Tests](https://hesela.dev/research/dfscq-block-identity/model.test.mjs)
- [Generator](https://hesela.dev/research/dfscq-block-identity/generate.mjs)
- [Generated results](https://hesela.dev/research/dfscq-block-identity/results.json)

Run:

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

The generator's explicit --write mode rebuilds the JSON. Checking never writes.
No random seed, external package, device access or network is used. The exhaustive
test covers 125 three-state histories over five short block lists; many are
deliberate invalid histories. It checks the predicates, not the completeness of
a filesystem state space.

Input is a nonempty list of dense block lists. Empty files are allowed.
Within a state, identities must be distinct nonempty ASCII labels. There are no
holes, partial blocks, inode deletion/reuse, multiple files, concurrent calls,
allocation simulation, recovery implementation or physical failure probabilities.

## Apply the distinction carefully

When reviewing a durability argument, record the object identity, logical offset
and set of metadata states still eligible after recovery. Do not substitute file
length for that information. Keep the condition for discarding old states separate
from the condition for completing the data writes.

On Linux, fdatasync includes metadata needed to retrieve the data, including a
changed file size; synchronization of the containing directory is a separate
concern. The teaching model does not replace that API contract.
[Linux fsync(2), DESCRIPTION](https://man7.org/linux/man-pages/man2/fsync.2.html).

The authors warn that the FSCQ/DFSCQ research software is unmaintained and includes
unverified integration components. This packet does not install or execute it.
[Pinned author README](https://github.com/mit-pdos/fscq/blob/2c7ef9c268fd79a81b26b44ef720f8e6a1e938a0/README.md).

Related: [DFSCQ corpus entry](https://hesela.dev/terms/dfscq/),
[source identity and paper locators](https://hesela.dev/research/dfscq/source-map.json).
