Fossil's formats and sync protocol, reimplemented in Zig from their specifications.
zit is a library first — a Zig analog of libfossil: the delta encoding, the
artifact formats, derived repository state, and the HTTP sync protocol as a
clean, embeddable API. The zit binary is a thin CLI over that library.
The implementation is a direct port of four companion Internet-Drafts (frozen
reference copies in docs/rfcs/):
| Module | RFC | What it specifies |
|---|---|---|
delta |
draft-fossil-delta-format-00 |
byte-level delta encoding |
artifact |
draft-fossil-artifact-format-00 |
manifest / control-artifact card format, naming, checksums |
repostate |
draft-fossil-repo-state-00 |
derived branch / tag / leaf / current-trunk views |
sync |
draft-fossil-sync-protocol-00 |
HTTP sync / clone protocol |
Implementation follows the RFC dependency layering:
delta -> artifact -> repostate -> sync
Design
The drafts are the authority, not Fossil's source. Test expectations come from the spec text and its worked examples — every normative clause a module implements gets a test citing its section. Fossil itself appears only in an on-demand interop smoke check, which may confirm a spec-derived expectation but never author one; a disagreement there means either zit misread the spec or the spec is wrong, and the spec gets an erratum rather than the code a workaround.
No module touches ambient time, randomness, filesystem, or network; effects arrive through injected interfaces. The sync client in particular is a pure state machine — bytes in, bytes out — with transport supplied by the caller. This keeps the library embeddable and makes the whole stack testable under seeded deterministic simulation, where any failure replays exactly from its seed.
Scope
zit targets the version-control substrate: the check-in (manifest), cluster, and tag/control artifact types. The collaboration types (wiki, ticket, forum, attachment, technote) are carried opaquely — stored and transported by hash, but not interpreted.
Build
Requires Zig 0.16+.
zig build # build the `zit` binary into zig-out/bin/
zig build run -- version
zig build test # run unit tests
Further named steps: zig build dst (deterministic simulation, --seed N to
replay), zig build fuzz -- <target> --seed N (seeded fuzz targets),
zig build bench (benchmarks), and zig build smoke (interop check against a
fossil binary on PATH; run manually at milestones, never part of test).
Source control
This project is itself under Fossil. The repository lives in .zit.fossil
(ignored); open a checkout with fossil open --keep .zit.fossil.