Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## 0.13.0.0 - 2026-11-16

- **The server removes entries and NARs itself: `DELETE /<hash>.narinfo` removes an entry, `POST /reclaim` removes the NARs no narinfo names and the abandoned multipart uploads, and `GET /reclaim` lists what it would remove.** No request removed anything, and the one removal path, `reclaim-nars --delete`, ran on the host against the store directory and shared no lock with the server, so it raced the server twice: a narinfo that arrived after its listing, for a NAR past the minimum age, lost that NAR, as upstream's `nix copy` can send one after skipping a NAR the cache holds, and a NAR uploaded again after its listing was removed despite its new modification time. The README asked for no push in progress during a run. The server now orders its removals against its uploads through a gate each `FileStore` carries: a narinfo upload holds it, alongside other uploads, from the check of its NAR through its write, each rename into `nar/` holds it for the rename, and a reclaim or a narinfo removal holds it alone, the reclaim from its scan through its last removal. So a narinfo is never stored naming a NAR a reclaim removes, and a NAR that arrives during a reclaim lands after it. A removal waiting for the gate lets nothing new take it, so a stream of uploads cannot hold it off; uploads wait while a reclaim reads the store, and no request body is read under the gate. A run's rules are unchanged: a minimum age of two weeks by modification time (`?min-age-hours=N` sets another, and any other query is refused with 400), a narinfo that cannot be resolved or a store with NARs and no narinfo blocks the run with 409, and a removal that fails makes the answer a 500. All three requests need the write key, which can already replace any entry. `DELETE` leaves the NAR to the reclaim, which removes it once nothing names it, as attic's garbage collection reaps a NAR once no object refers to it. A narinfo uploaded for a path the cache holds replaces the entry, which lets a push store a smaller encoding of the same NAR, and the NAR it displaces is reclaimed the same way. Upstream ships no garbage collection for binary caches, so there is no server behavior to match, only its client's: `BinaryCacheStore::narFromPath` turns a missing NAR into `SubstituteGone`, which a substitution logs as a warning before it tries the next substituter (2.35.6), so a client holding a narinfo whose NAR was removed sees a miss, not a failure. One server serves a store directory.
- **`nova-cache-server reclaim-nars` exits nonzero, naming the requests that replace it.** The server removes NARs itself. The subcommand's name is still recognized so that a script running it stops: the server ignores arguments it does not know, and would otherwise start a second server over the store.
- **`FileStore`'s constructor is no longer exported: `newFileStore` makes one, with the gate that orders the store's additions against its removals.** `fsRoot`, `fsStoreDir` and `fsPriority` remain fields, and a copy made by a record update shares the original's gate. `withoutRemoval` and `withRemoval` in `NovaCache.Store` hold it; `writeNar`, `writeNarStreaming` and `completeUpload` take it for their rename, and `removeNarInfo` and `NarInfoRemoveResult` are new. `fileStoreAt` goes, since its one caller was `reclaim-nars`, and `FileStore` loses its `Show` instance. In `NovaCache.Reclaim`, `scanStore` takes the clock it reads after its listings and lists the staged uploads into `StoreScan`'s new `scanStagedUploads`; `planStore`, `StorePlan`, `listReclaimable`, `reclaim` and `Reclaimed` are new. `NovaCache.Server` gains `storeNarInfo`, which checks, signs and writes a narinfo within one hold of the gate, `NarInfoWrite`, and `parseMinimumAge`. `stm` joins the dependencies, for the gate's `TVar`. These changes break the library's API, which is why this is a major version.
- **A NAR can be uploaded in parts, past a proxy's limit on request bodies: `POST /nar/<file>/uploads` begins an upload, `PUT /nar/<file>/uploads/<id>/<n>` sends part `n`, and `POST /nar/<file>/uploads/<id>` joins the parts into `nar/<file>`.** A NAR went up in one `PUT /nar/<file>`, and a proxy in front of the server can refuse a body over its own limit, as Cloudflare does over 100 MB on its Free and Pro plans, so a larger NAR could not reach a cache behind one. Upstream's `HttpBinaryCacheStore` also sends each file in one `PUT` (2.35.6), and only its S3 store uploads in parts, through S3's own API, so there is no upstream HTTP protocol to match. The requests follow S3's multipart upload in plain paths: the server issues the upload's id, parts are numbered from 1, a part sent again replaces the one held, and the completion declares the total size, which S3 makes optional (`x-amz-mp-object-size`) and this server requires. Each request is authenticated as the other writes are. Parts are staged under `uploads/`, outside `nar/`, each streamed to disk in constant memory and renamed into place whole, and they go in order: a part that would leave a gap is refused with 409. The completion's body declares the part count and the total size, as `Parts:` and `FileSize:` lines in narinfo's form, and is refused with 413 when the declared size is over the cap, or with 409 unless the upload holds that many parts and they join to that size; only a join that matches is renamed into `nar/`, so an upload in progress or abandoned never appears there, and the narinfo check verifies the joined file's `FileSize` and `FileHash` as before. An upload's parts together are held to the 4 GB of a single `PUT`, checked as each part arrives and again at completion, since two parts written at once can each pass the first check; an upload holds at most 10,000 parts, S3's limit, and a name too long to stage (its directory's name is the NAR's with the 32-digit id before it) is refused with 400. `POST /reclaim` also removes an upload nothing has been written to for its minimum age: no narinfo can name a staged upload's parts, so removing them never leaves a narinfo without its NAR. `newFileStore` creates `uploads/`. The library gains the upload's store operations in `NovaCache.Store` (`beginUpload`, `writeUploadPart`, `completeUpload`, `listStagedUploads`, `removeUpload`) with the types they take and return, `UploadId` and `PartNumber`'s parse and render functions, and `maxUploadParts`; `selectAbandoned` and `UploadPlan` in `NovaCache.Reclaim`; and the completion body's `parseUploadTotals`, `renderUploadTotals` and `maxUploadTotalsBodySize` in `NovaCache.Server`.
- **`nova-cache-server` serves no landing page of its own: `GET /` answers the library's line of plain text, or, given `--root-page FILE`, that file as HTML.** The executable served cache.novavero.ai's branded page to every operator who ran it, with that deployment's name, styling and links, where the library has kept the root page per deployment through `scRootResponse` all along. A deployment's page is now a file it ships beside its unit, as upstream's cache.nixos.org serves a static page at its root; the public cache's is `deploy/index.html`, styled by novavero.ai's stylesheets. The server reads the file once at startup and refuses to start if it cannot. The executable's page also showed the signing key's public half and a count of stored paths; the plain-text line shows neither, and the server prints the public key in its startup log. The library gains `htmlRootResponse` in `NovaCache.Server`. Nix clients never request `/`, so substitution is unchanged.
- **The server writes its log to stdout line by line.** Under systemd its stdout is a pipe to the journal, where GHC buffered it by block, so the startup lines reached the journal only when the first request's log line flushed it, or, with `LOG_REQUESTS=0`, when a block filled.
- **When `serialiseFromPath` or `withNarSource` fails to read an entry's status, a symlink's target, a directory's listing or a regular file, it throws `NarWalkError`, naming the access, the entry and the `IOException` beneath.** A failure in any of these four accesses escaped as GHC's bare `IOException`, so a caller could tell which access failed on which entry only by parsing GHC's text. Upstream's `PosixSourceAccessor` at 2.24.9 words each access its own way (`opening file '/d/tree/sub/locked': Permission denied`, `reading directory /d/tree/sub: Permission denied`), and a caller reporting failures as upstream does needs the access as a value. `WalkAccess` says which of the four failed (a file's open, size and reads are one access), `nwePath` is the entry's on-disk path, and `nweCause` is the `IOException` itself. `withNarSource` throws a file's read failure from the pull that reads it. Only an `IOException` is wrapped: an asynchronous exception passes through as itself, and whatever an `ExecBitResolver` throws arrives as thrown. A caller that catches `IOException` around a walk no longer catches these failures, which is why this is a major version.
- **`serialiseFromPath` and `withNarSource` refuse a FIFO, a socket or a device with upstream's error at 2.24.9, `file '<path>' has an unsupported type`.** The walk took every entry that is not a directory or a symlink for a regular file, through `doesFileExist`, which is true for anything that is not a directory, so the refusal written for these types never ran. `serialiseFromPath` then read the entry with `ByteString.readFile`, which reads anything that is not a regular file to its end of input: a FIFO with no writer, or `/dev/null`, archived as an empty regular file, and a device with no end, such as `/dev/zero`, was read without bound. `withNarSource` failed at the pull for the entry's contents, with the `IOException` `hFileSize` raises for a file that is not regular, after earlier pulls had returned part of the archive, and a socket failed both entry points as a file read. Each entry's type now comes from one `lstat`, classified by its file mode as upstream's `SourceAccessor::dumpPath` classifies it, and any type but a regular file, a directory or a symlink is refused before it is read; `withNarSource` refuses before its continuation runs. The refusal is an `IOException`, as the walk's other refusals of what it finds are, not a `NarWalkError`: no access failed, and no `IOException` lies beneath it. An entry that vanishes mid-walk fails the access that finds it gone, as a `NarWalkError`, unless the first read to find it gone is `defaultExecBitResolver`'s own status read, which throws its bare `IOException` as any resolver's failure arrives. Windows has no file mode, and its classification is unchanged.
- **A failed `withNarSource` pull stays failed: every later pull rethrows the same exception, as the xz, zstd and bzip2 sources' pulls do.** A pull that found a file shorter than the size it had read marked the source drained before it threw, so the next pull returned the empty chunk that marks a clean end, and a consumer that caught the failure and pulled again took a truncated archive for a complete one. Any exception raised while a pull runs now latches, asynchronous ones included, since a pull interrupted after its read consumed bytes it never returned leaves the archive as torn as a failed one. An asynchronous exception that arrives as a pull returns, after the source has moved past the chunk it was returning, is not latched, so a consumer must not pull again after an asynchronous exception. A pull after any other failure, such as a file that could not be opened, rethrows it as well, where it used to carry on from where the failure left the source. The file a failed pull held open is closed as the failure latches, not when the continuation exits.

## 0.12.0.1 - 2026-11-05

- **The README in the package describes 0.12: its version bounds, the server's required `CACHE_API_KEY`, and which codecs are pure.** The README in the 0.12.0.0 tarball, the one Hackage shows, gave bounds that exclude 0.12 itself and a server command that exits at once, since the server refuses to start without `CACHE_API_KEY` unless given `--allow-open-writes`. It also called the WAI server optional, where `NovaCache.Server` is always part of the library and only the executable sits behind `-f server`, and counted one-shot xz decompression and zstd compression among the `IO` operations, where both are pure. The test command now passes `--enable-tests`, as CI's does.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ in `IO`. nova-cache is the protocol layer under
## Installation

```cabal
build-depends: nova-cache >= 0.12 && < 0.13
build-depends: nova-cache >= 0.13 && < 0.14
```

The codecs are separate sublibraries, named alongside the main library:

```cabal
build-depends: nova-cache:{nova-cache, xz, zstandard} >= 0.12 && < 0.13
build-depends: nova-cache:{nova-cache, xz, zstandard} >= 0.13 && < 0.14
```

libbz2 and libzstd are bundled. liblzma comes from the `xz` package, which
Expand Down
1 change: 0 additions & 1 deletion changelog.d/multipart-nar-upload.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/nar-source-latch.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/nar-unsupported-types.md

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/nar-walk-access-errors.md

This file was deleted.

Loading
Loading