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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.14.0.0 - 2026-11-27

- **`narPrefix` in `NovaCache.NAR.Stream` parses a NAR that more input follows: it finishes at the root node's close, without awaiting more input, with the bytes after that close. `NarStep` takes the type of the result `NarDone` carries, which is `()` from `narStream`.** The parser accepted an archive only at the end of its input and failed on any byte after the root node, so a NAR inside a stream that goes on past it, as the worker protocol sends one followed by the rest of the request, could not be parsed without knowing its length first. Upstream's `parseDump` at 2.36.0 reads a NAR from such a stream by stopping at the root node's close and leaving what follows to the stream's next reader, and `narPrefix` does the same, through the node parsing `narStream` uses. The bytes it finishes with are a suffix of the last chunk fed, so the archive is every byte fed before them, which is what a caller hashes and counts. An input that ends before the root node's close fails as truncated, as `narStream` fails it. `narStream` still requires the end of input after the root node, and a consumer matching its `NarDone` now matches `NarDone ()`.
- **The NAR parser refuses what upstream's parser refuses past the grammar: a keyword over 32 bytes, an entry name over 255, a symlink target over 4095, a symlink target that is empty or holds NUL, and a node 64 directories deep. `serialiseFromPath` and `withNarSource` refuse an entry 64 levels below the root with `path '<path>' exceeds maximum NAR directory depth of 64`. `maxWireStringBytes` and `narStreamBounded` go.** Upstream's `parseDump` at 2.36.0 reads each keyword with a 32-byte limit, a name with 255 and a target with 4095, the magic with its own 13 and the executable marker with 0, refusing a longer declared length from its prefix before the bytes it declares are read; it refuses an empty target or one holding NUL once read, and a node at depth 64, the root at 0, once its entry's `node` keyword is read. The parser held every structural string to 64 KiB instead and checked neither targets nor depth, so it accepted archives upstream refuses, and `narStream`, `narPrefix` and `deserialise` now refuse them at the same points, naming the string and its limit or the entry. Upstream's dump refuses a tree that deep as well, so the walk does too, before reading the entry's status; it still archives a name or a target past its limit, as upstream's dump does, and such an archive does not parse. Every structural string now has a limit of at most 4095 bytes, so the 64 KiB bound never applied: `narStream` holds no bound of its own, and `deserialise` drives it as it is. The depth limit is exported as `narMaxDepth`.

## 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.
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.13 && < 0.14
build-depends: nova-cache >= 0.14 && < 0.15
```

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

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

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

This file was deleted.

1 change: 0 additions & 1 deletion changelog.d/nar-upstream-limits.md

This file was deleted.

2 changes: 1 addition & 1 deletion nova-cache.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cabal-version: 3.4
-- 3.0 an in-package component name shadowed its external namesake
-- (the hazard the zstandard library's name dodges, documented there).
name: nova-cache
version: 0.13.0.0
version: 0.14.0.0
synopsis: Nix binary cache protocol: NAR, narinfo, signing and a WAI server
description:
The Nix binary cache protocol in Haskell: nix-base32, NAR serialization
Expand Down
Loading