Spice’s browser app used to install beside its executable as a tree of files. I wanted one movable binary instead, so I tried what I had done years earlier in Zippy: append a ZIP to the finished executable. Mach-O ran the Spice binary, unzip found the central directory, and the archive survived intact. Then codesign --verify --strict rejected it.
Apple’s guidance is unusually direct: appending data to a Mach-O executable is prohibited. For embedded data it says to create a section at link time. The archive could travel inside the executable, but it had to become part of the executable before signing.
The archive became a linker input
The build writes the Spice rack, one ZIP carrying its release-owned content, into a small relocatable object. Its read-only section is __TEXT,__spicezip in Mach-O and spicezip in ELF and PE32+. Linker symbols mark the first byte and length, so rack::linked exposes an ordinary static slice. The program does not need to find or parse itself at runtime.
The object writer handles Mach-O, ELF, and PE32+, then the archive is linked before symbol extraction, stripping, and signing. After those steps, the release pipeline reads the section back and runs the executable’s version report. The section must match the assembled rack, and the report must name the same product and app generation.
That order matters. The first attempt added bytes after the linker had finished. The working version gives the linker the bytes before anything records or signs the final image.
A ZIP of finished gzip streams
The section contains a standard ZIP envelope, but this archive stores every member with ZIP’s STORE method instead of asking ZIP to compress it. Each file is first encoded as its own deterministic gzip stream. The central directory makes those finished streams addressable.
This arrangement serves two consumers without converting between their formats:
executable image (Mach-O, ELF, or PE32+)
└── linked read-only rack section
└── `spicezip` byte slice (start + length)
└── ZIP central directory
├── app/...gz stored gzip streams
├── SKILL.md.gz stored gzip stream
├── spice.toml.gz stored gzip stream
├── LICENSE.txt.gz stored gzip stream
├── build.json.gz stored gzip stream
└── docs/...gz stored gzip streamsA browser already understands Content-Encoding: gzip. Keeping those exact bytes in the archive means an app request does not need to inflate a ZIP member and compress it again for HTTP. The same stored app streams also move unchanged from the staged app archive into the larger rack.
Reproducibility is part of the format, not a promise made around it. The rack writer sorts normalized paths, fixes the ZIP timestamp, and stores every member without ZIP compression. The gzip layer fixes each stream’s header and checks one complete deflate stream against its declared size and CRC. Rack admission refuses repeated or unnormalized paths, encryption, non-STORE members, inconsistent headers or sizes, and ranges outside the archive.
The app’s shell names its generation in every qualified asset URL, so that generation cannot be the digest of the archive containing the shell without creating a self-reference. The build stages the app under that existing generation identity, then computes a separate digest for the completed rack. The same app generation and tracked sources produce the same rack bytes.
The rack grew beyond the original app archive without adding another carrier. Its source list adds the authoritative SKILL.md, packages gate/defaults/spice.toml as spice.toml, and includes the license, build record, and tracked documentation. App members retain their already-compressed streams; only the added sources are deflated during assembly.
Reading it back out
The section is not only a build-time assertion. I read it back from the installed arm64 Mach-O. This exact exercise is for macOS; the section names are different in ELF and PE32+. Run each shell block below in the same shell. The extracted files remain under $work for inspection until the final cleanup:
work=$(mktemp -d)
spice=/absolute/path/to/spice
read -r offset size <<EOF
$(otool -l "$spice" | awk '
$1 == "sectname" { section = $2 }
section == "__spicezip" && $1 == "size" { size = $2 }
section == "__spicezip" && $1 == "offset" { print $2, size; exit }
')
EOF
test -n "$offset" && test -n "$size"
dd if="$spice" of="$work/rack.zip" bs=1 \
skip="$offset" count="$((size))" 2>/dev/nullTest the raw section bytes as a rack:
(cd "$work" && unzip -tq rack.zip)unzip reports No errors detected in compressed data of rack.zip. Then confirm that the app shell is a stored gzip member rather than a second compressed representation:
unzip -lv "$work/rack.zip" app/app.html.gz |
awk '$2 == "Stored" { print $2, $8 }'That prints Stored app/app.html.gz. Because that member is stored, unzip -p returns its gzip bytes unchanged:
unzip -p "$work/rack.zip" app/app.html.gz > "$work/app.html.gz"
gzip -t "$work/app.html.gz"
gzip -dc "$work/app.html.gz" | head -n 1The validation command succeeds silently, and the last command prints <!doctype html>. Remove the temporary files and shell variables when done:
rm -rf "$work"
unset work spice offset sizeServing the rack without unpacking it
An installed process admits its linked rack once. The central directory becomes an index from each app path to its static gzip slice, content type, and strong ETag. HTML is the exception: the shell and renderer documents are also inflated once at startup so Spice can derive their content security policies. The archived representations use their gzip bytes unchanged.
For an archived asset, Spice returns Bytes::from_static over the indexed slice, with Content-Encoding: gzip and Vary: Accept-Encoding. It performs no per-file read, decompression, recompression, or app-wide uncompressed cache. A client that refuses gzip gets 406 for a gzip representation rather than a silently transformed body.
The /rtl/ view is not an archived representation. It adds dir="rtl" to the already-inflated shell and serves uncompressed HTML with its own ETag, using the same generation’s assets.
Installation therefore publishes no app tree. The executable is the app carrier, and upgrading the app means atomically replacing that executable. The same rack supplies spice://SKILL.md and the documentation agents read, so their operating instructions come from the executable implementing them, not from an independently updated copy.
An installed resident holds one app generation, not a history of embedded archives. A request qualified with an old generation gets 410 Gone and the current generation header. The page then reloads once while handing its unsent drafts to its successor. The packaging contract here is only that the process serves the one generation its binary actually carries.
What remains outside
The development path deliberately differs. A staged spice up serves the unzipped generation so a new app can hot-swap without relinking the executable. If an older staged generation lacks a file from the current inventory, Spice answers 410 Gone instead of serving a partial page. Ordinary development builds may link no rack at all. Installed serving refuses an absent or malformed rack rather than falling back to a sidecar directory.
The rack is also not Spice’s database or configuration store. Journals, repository configuration, installation receipts, and hooks remain external because they are mutable authority or operator-owned state. Putting them in the executable would conflate a release with the state it operates on.
Nor does the archive make every useful decision into a bundled asset. Spice’s routing matcher avoids model files and a model service for a different reason, covered in Why rare words route Spice work. The shared rule is only that an optional external dependency should not strand the appliance.
The failed appended ZIP left a useful boundary. Immutable bytes that define a release belong inside the image before it is signed. Mutable authority stays outside. The rack packages the app, instructions, and documentation together without pretending they are the whole system.