roadmap

Stage 6: allocation and write

Appendix to 813. file_allocation_table. It records what stage 6 built, the evidence, and the one design choice an architect may want to revisit before the crate publishes. Stage 6 landed in two pull requests: the first changed the table and nothing above it, and the second wrote files.

The first pull request: the table

No nife type appears in a public signature.

The choice an architect may revisit

The write half could have been a write_sector method on SectorDevice, or a second trait. This stage takes the second. Read-only users (the fuzz targets, the macOS image tests, and milestone 140, mount a drive this system did not create, whose first stratum only reads) then never need a method they cannot honestly implement.

Prior art, from memory and not re-read for this page: rust-fatfs takes one Read + Write + Seek bound for every operation, so a read-only volume needs a wrapper that fails writes; embedded-sdmmc puts read and write on one block-device trait. The cost of a second trait is one more name in the public API. The choice is reversible until the first publication, the name has a ratified block, and nothing outside the crate uses it yet.

The evidence

check result
Kani, seven new harnesses a_stored_entry_reads_back_and_disturbs_nothing_else and encoding_inverts_decoding cover every type, cluster, byte window and value. allocation_takes_one_free_cluster_and_nothing_else, a_release_frees_only_its_own_chain and a_cut_keeps_exactly_the_head_of_the_chain run over a model table of one to four clusters with every entry chosen by the solver. every_sector_parses_to_hints_inside_the_volume and a_store_changes_only_the_two_hints cover every 512-byte FSInfo sector
falsification each harness has a patch that turns it red at its own assertion: a FAT12 store that keeps the wrong bits, a bad entry encoded one past its marker, a parse that believes any free count, a next-free hint stored four bytes late, a search that treats a reserved entry as free, a release that frees before it looks, and a cut that walks one cluster too far
unit tests allocation from a hint, a wrap, a full volume, bad and reserved entries never taken, every entry of a 350-cluster FAT12 table stored without disturbing a neighbor, an entry straddling two table sectors, a chain freed and cut at every length, a broken chain, a looping chain, a refused write that leaves nothing leaked, and the FSInfo signatures and edges
oracle tests on FAT12, FAT16 (512 and 4096-byte sectors) and FAT32 volumes rust-fatfs formatted, this crate allocates a chain of 40 clusters and one of 7, cuts the first to 12, and frees both. After each step rust-fatfs counts the same free clusters, on FAT32 the FSInfo count equals the true one, and at the end the boot area and both tables are byte for byte what they were. fsck.fat accepts the empty volume and the freed volume. A scrambled run of 400 grow, cut and free steps keeps the count and every chain's length against a model

Kani bounds what it unrolls. The allocation harnesses cover four clusters at most. The operations' own loops are bounded by the cluster count, and the oracle tests run them over volumes of tens of thousands of clusters.

Names minted

Every name in this stage has a ratified Name: block in its source.

The second pull request: files

check result
Kani, two new harnesses a_partial_sector_write_keeps_the_head_and_zeroes_the_slack proves the sector merge (head kept, slack zeroed, new bytes in place) over every 16-byte sector, since the merge takes any slice length. a_write_extends_the_chain_to_the_size_and_stays_inside_it runs the real cursor and chain extension over a model of three one-sector clusters: two writes of up to 700 bytes, the second at any position in the file. The size, the position, the touched sectors and the chain length all come out right and no other cluster is in use. It takes about five minutes. One harness over both did not close in 20 minutes, so the proof is split; the oracle tests join the halves on real volumes
falsification one patch zeroes the slack a byte late, the other shrinks the size on an overwrite; each turns its harness red at its own assertion
unit tests odd chunk sizes, overwrite with slack, clamped seek, grow and shrink, remove and slot reuse, directory entries as files, a full fixed root, a refused write, a damaged chain
mutation cargo mutants --in-diff over this pull request tests 287 mutants: 239 caught, 30 unviable, and 18 that notes/project-metrics/mutation-triage.csv rules on. Thirteen are equivalent (bounds that only cap a loop, a cursor restart that reaches the same cluster, a full-sector write through the merge path) and five are gaps: four on the 65,536-entry directory ceiling, since killed by a_directory_stops_growing_at_65536_entries, and one that only cargo-mutants' 20-second bound hides
fuzz the parser target found a listing that went on after an error once it ran on the indexed scan; the done flag now lives in the scan, with a unit test
oracle tests on FAT12, FAT16 (512 and 4096-byte sectors) and FAT32 volumes rust-fatfs formatted, the test writes ten files of sizes around the sector and cluster boundaries in odd chunks. rust-fatfs lists and reads the same names and bytes, counts the same free clusters, and fsck.fat -n accepts the volume after the create, after an overwrite across a cluster boundary, an append, a shrink, a grow and a delete, and after every file is deleted. The clean bit reads dirty mid-change and clean after sync. A FAT32 root grows past a cluster, and a FAT16 root refuses the 513th file

Names minted in the second pull request

Ratified 2026-11-01 (UTC): WriteError, FileWriter, Volume::create_file, open_file_writer, remove_file and is_clean, and the modules write_cursor and file_writer.