Skip to content
quarry Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 51dd3d4ffaa4ef567accfd36133ddf9a00a3cc1dfee7b25debb3d14937730878
Ticket: 6f5995173d9bae904977e9212d74721ded55da81
export a repository as a single .fossil file, without serving it
User & Date: dmestas on 2026-08-18 17:58:38
Changes

  1. comment changed to:
    Moved from zit#99, closed there. It lands here because the decision the issue turns on is the SQLite dependency: zit deliberately has none and would vendor one for a single verb, while quarry already depends on ncruces/go-sqlite3. An exported .fossil is also derived output — fully reconstructible from the store — so holding it here does not run into RFC 0001 §11 the way unversioned files did.
    
    ## The gap
    
    Getting a zit repository out as a `.fossil` file requires standing up a server and running another tool against it:
    
    ```
    zit serve --port 8080 &
    fossil clone http://127.0.0.1:8080/ out.fossil
    ```
    
    That is what `scripts/roundtrip-fossil.sh` does, and it works — the sync protocol is a complete export path, which is why there is no `export-fossil` verb today and why `export-git` exists (git speaks a different protocol and needs `fast-import`).
    
    But it is the wrong shape for the thing people actually want, which is one file:
    
    ```
    zit export-fossil out.fossil
    ```
    
    The current route needs a free port, a background process, a readiness wait, a second binary on PATH, and a cleanup path for the server when the clone fails. That is a lot of moving parts for "give me the file", and every one of them is a way for a script to hang or leak. #95 made exactly this argument for `tarball`: `zit open` into a throwaway checkout could already produce a tree, and the verb still earned its place because a release pipeline should not have to orchestrate one.
    
    ## Why it is not just `tarball` for repositories
    
    A tarball is a snapshot of one check-in's files. This is the whole artifact corpus with its history intact — the output is a repository a stock `fossil` opens, clones, and syncs with, not an archive of a tree.
    
    The obvious uses are the ones the server route makes awkward:
    
    - **Handing someone a repository** who has fossil but not zit, without hosting anything.
    - **Backups and mirrors** in a cron job, where a background server is a liability.
    - **Air-gapped transfer.** No port, no listener, no network namespace.
    - **CI artifacts.** The round-trip harness itself would become a two-line step.
    
    ## What it would do
    
    Write a SQLite fossil repository containing every artifact this store holds, plus the derived tables fossil expects (`blob`, `delta`, `filename`, `mlink`, `plink`, `event`, `tagxref`).
    
    The honest question is how much of that has to be built versus derived. Fossil's own answer is `fossil rebuild`, which reconstructs every derived table from the artifact corpus alone — so a minimal export could write `blob`/`delta` and leave the rest to a `rebuild` on the far side, at the cost of the recipient running one command. Writing the derived tables directly is more work and produces a file that is immediately usable.
    
    Worth deciding explicitly rather than discovering: **a repository that needs `fossil rebuild` before it is usable is a different product from one that does not.**
    
    ## What already exists
    
    Most of the hard parts are done:
    
    - **The artifact corpus is byte-exact.** `import-fossil --compatible` preserves hashes and project code, and #73 verified the round trip against stock fossil, so the artifacts a zit store holds are already the artifacts fossil wants.
    - **The enumeration exists.** `zit frames` walks every stored artifact; `Repository.blob` reconstructs and hash-verifies content.
    - **The differential harness exists.** `scripts/roundtrip-fossil.sh` already compares an exported repository against its origin by artifact set, `test-integrity`, event counts, shun table, and phantoms — it would need its third step swapped from serve-and-clone to one command, and would then be testing this verb.
    
    ## Open questions
    
    - **SQLite.** zit has no SQLite dependency and deliberately reads none on import — `import-fossil` uses the sync protocol precisely to avoid it. Writing a `.fossil` means writing SQLite's file format. Vendoring SQLite for one verb is a large dependency for a narrow feature; emitting the format directly is a real amount of code and a compatibility surface that will outlive the reason for it. **This is the decision the issue turns on**, and it deserves an answer before any implementation.
    - **Which tables.** As above: `blob`/`delta` plus a `rebuild` on the far side, or the full derived set.
    - **The shun table.** A clone adopts it (#73). An export must carry it, or the exported repository would serve content its origin was ordered to remove.
    - **Compression parity.** zit's frames and fossil's blobs both use the §4.1 container. Whether bytes can be moved across without re-compressing is worth checking — it decides whether this is an O(store) copy or an O(store) recompress.
    
    ## Not asking for
    
    A general fossil writer, a `--rebuild` mode, or incremental export. One file, whole repository, one command.
    
  2. status changed to: "open"
  3. title changed to:
    export a repository as a single .fossil file, without serving it
    
  4. type changed to: "feature"