1# @ajax/mesh-jobd-store
23The job log file, an append-only file of job log records (`@ajax/mesh-jobs-log`).
45- **Appends.** Records are fsynced before anything that depends on them leaves (`mj_durable`). A
6 write or sync that fails is fatal to the caller (fail-stop). A write that failed half-way is first
7 cut back to the last whole record, so a torn tail is never followed by a record (review finding 4).
8- **Start.** The log is replayed, a torn last record is dropped, and the file is rewritten compacted.
9- **Compaction.** When the file grows past twice its last compact size plus 8 MiB, it is rewritten
10 whole as the replica's own log, through a renamed file, so a failed compaction leaves the log as it
11 was.
12- **In memory.** Without a path, nothing is written.
1314## Ported from
1516[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT):
17`crates/mesh-host/src/jobd.rs`: `Store` (`open`, `rewrite`, `wants_compact`, its `Disk`).
1819## Tests
2021`tests/store.c`: the Rust's `a_torn_write_is_cut_back` (a failed half-write cut back, a torn tail at
22start dropped and rewritten), compaction, and the in-memory store.
2324## Licence
2526MIT. See the repository's LICENSE.