# When merging changes removes a legal write schedule

This is an executable, finite illustration, not a filesystem implementation,
formal verification, performance experiment, or power-failure test.

## Evidence

Christopher Frost, Mike Mammarella, Eddie Kohler, Andrew de los Reyes,
Shant Hovsepian, Andrew Matsuoka and Lei Zhang. Generalized File System
Dependencies. SOSP 2007, pp. 307-320.
https://read.seas.harvard.edu/~kohler/pubs/frost07generalized.pdf
Bibliography: https://read.seas.harvard.edu/~kohler/pubs/

Section 4.3 distinguishes a mergeability condition from a conservative,
bounded implementation heuristic. Sections 3 and 4.1 explain dependency
semantics and restrictions on future dependency additions. We do not
implement that historical heuristic, byte patches or its API.

## Our constructed examples

Indices identify patches, letters identify blocks. An edge i -> j means
that i requires j. Same-block prerequisites may commit in one write.

1. A0 <- B1 <- A2, plus A2 -> A0: writing A0, then B1, then A2 works.
   Requiring A0 and A2 in one write leaves no legal first write.
2. B0 <- A1 <- A2, plus A2 -> B0: first write B0, then A1 and A2.
   A cross-block prerequisite does not by itself prevent the merge.
3. A0 <- A1 <- A2, plus A2 -> A0: all three may commit together.

These traces expose two invalid shortcuts: accepting every overlapping pair,
or rejecting every pair that has any off-block prerequisite.

## Reproduce

With Node.js supporting ESM and the built-in test runner:

    node model.mjs --check
    node --test model.test.mjs

Run model.mjs --write only when intentionally regenerating result.json.

The enumeration fixes the pair at oldest/newest indices, with a direct
overlap edge. For n patches there are n(n-1)/2 - 1 optional older-directed
edges and n-2 binary block labels. The number of cases is therefore
2^(n(n-1)/2-1) * 2^(n-2). For n=2,3,4,5 the counts are 1,8,128,4096.

The path predicate searches for a newer-to-older path passing through another
block. An independent breadth-first oracle searches completed-patch subsets:
each transition commits a nonempty subset on one block, all prerequisites
being already committed or included in the same transition. Pair endpoints
are either both present or both absent. It never calls the path predicate.

result.json records counts, agreement and complete example traces. There is
no random sampling, seed, confidence interval or empirical population.
Zero mismatches in this finite domain is not a proof for arbitrary graphs,
future dependency additions, concurrent writes, partial writes or hardware.

The model assumes overlapping endpoints but does not represent changed byte
ranges, undo payloads, empty patches, flushes, controllers or error recovery.
Its schedules are abstract commitment events, not POSIX calls or block traces.

## Additional regression coverage

The test suite separately enumerates every pair position in age-ordered DAGs
of 2..4 patches. Pair endpoints use block A; each other patch independently
uses A, B or C. A direct newer-to-older pair edge is mandatory. There are
sum(n=2..4) binomial(n,2) * 2^(n(n-1)/2-1) * 3^(n-2) = 1,765 cases.
For every case, it checks agreement, validates each complete returned write
trace, and checks every edge of a blocking witness. These cases overlap the
main enumeration, so the two counts must not be added as unique graphs.
This is regression coverage, not an extension of result.json's declared domain.

Inputs must be dense arrays: missing block labels, dependency rows, dependency
indices and pair indices are rejected with TypeError. JavaScript array holes
must not silently become absent constraints. Explicit boundary tests include
the supported eight-patch maximum and rejection of a ninth patch.

## Provenance

Reviewed and generated 2026-12-01. Original model and tests by Hesela team.
Source paper was read from the author's PDF; no paper figures or code copied.
Retrieved PDF SHA-256:
7d958ec20f18d86741a343bdbb1b903ddf07b55a304c23023de73709dfa3088d
All numeric outputs are generated, never hand-entered. The source repository
tracks the model, tests, result and publication checks together.
