Store: NAR names as raw bytes - nova-cache 0.7 and the write-boundary decode - #83
Merged
Conversation
… decode nova-cache 0.7 carries NAR entry names and symlink targets as raw bytes, as upstream does, so non-UTF-8 names now reach the store. The store invariant is unchanged - every materialized name is valid Unicode - so the decode moves to the write boundary: decodeNarText refuses bytes with no Unicode reading before anything is written. The Text name machinery is untouched; NAR building from the filesystem encodes its Unicode names at the two construction sites.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
nova-cache 0.7.0.0 carries NAR entry names and symlink targets as raw byte strings, as upstream does; the parser no longer rejects a non-UTF-8 name, so those bytes now reach the store. The store's invariant is unchanged: every materialized name is valid Unicode - a name every platform the store targets can hold - so the decode moves to the write boundary.
decodeNarTextdecodes each directory entry name and symlink target at unpack, and bytes with no Unicode reading refuse the unpack with a typed error before anything is written.The name machinery (
isSafeNarName, case-hack renaming, collision detection, link ordering) is unchanged and staysText-based: under the invariant, every policy-passed name is decoded text.caseHackSuffix'sTextform is derived once from the library constant (a total latin1 read of the ASCII suffix). NAR building from the filesystem (builtins.path/filterSource) encodes its Unicode names to UTF-8 at the two construction sites.Bounds move to
nova-cache >= 0.7 && < 0.8, built against the published Hackage release.Tests and measurement
Two new refusal tests (non-UTF-8 entry name, non-UTF-8 symlink target); the rest of the suite is unchanged and green. Benchmarked before and after on the profiling harness: allocation and residency identical to the byte, timing differences within run-to-run noise.