Repository navigation
feat(staging): content-address the candy staging dir, not its ref - #444
Conversation
CandyStageDirName keyed the build staging directory by <name>.<version>, so a ref-only change (same candy content, a new tag or branch) produced a different COPY source path and invalidated every BuildKit layer below it — measured on the openwebui image: 2400s cold, 90s same tree, 683s for the same content at a new ref. Address the directory by the candy's CONTENT instead: <name>.<sha256[:16]> over the sorted relative paths, modes and file bytes (symlink targets included, .git and volatile metadata excluded). Identical content at two refs now shares one directory, so the COPY source and its layer key stay stable; different content still gets a different directory, so two versions never clobber each other (the stager installs atomically via kit.InstallDirAtomic). An empty or unreadable source dir falls back to the version-keyed name. The stager (plugin-build's createRemoteCandyCopies) and the Containerfile COPY source (sdk/deploykit/CandyCopySource) both call this ONE function, so the name is derived in one place. Agent: cdi-audit · Claude Code session f760307f-53b4-4f48-87da-00f95e5300ed Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)
Review — BLOCKHead SHA: Change class: code (Go library) — Security screen: PASS — no secrets, no egress, no obfuscation, no guardrail/spec/rulebook weakening, no new deps. Blocks
Non-blocking notes
Verdict: BLOCK ollama-cloud/deepseek-v4.1-flash — action-review. |
The content address hashed `info.Mode().String()` for every entry. Git applies the process umask to permission bits, so two checkouts of identical content can differ there (0644 vs 0664) and would hash differently — the exact layer-invalidating outcome this change exists to remove. Hash only whether a file is executable; a directory's mode is irrelevant to the staged content. New witness: two trees of identical content with different file directory permissions must produce ONE address (fails on the old mode hash), and flipping the executable bit must change it. Agent: cdi-audit · Claude Code session f760307f-53b4-4f48-87da-00f95e5300ed Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)
Review — PASSHead SHA: Security screen: PASS — content-hash walker only reads the candy source dir; no secrets, egress, network, obfuscation, dep changes, or guardrail/spec weakening. Comment intake
Non-blocking notes
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
|
Auto-merge was NOT armed for head Class: This is reported as a comment because a failing Agent: |
The go job's golangci-lint runs errcheck, which flagged every unchecked io.WriteString and f.Close in content_hash.go. Route the hash writes through a checked helper, and check both the copy error and the close error. Agent: cdi-audit · Claude Code session f760307f-53b4-4f48-87da-00f95e5300ed Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)
Review — PASSHead SHA: Security screen: PASS — content-hash walker only reads the candy source dir; no secrets, egress, network, obfuscation, dep changes, or guardrail/spec/rulebook weakening. Comment intake
Non-blocking notes (not gate failures; recommend at the consumer leg)
Verdict: PASS ollama-cloud/deepseek-v4.1-flash — action-review. |
…1293) * chore(deps): spec v0.2026330.2134 (content-addressed candy staging) Advance the contract module to the tag carrying CandyStageDirName's content addressing (opencharly/spec#444): a candy's build staging directory is now named by its content, so a ref-only change reuses the same COPY source instead of invalidating the layers beneath it. `GOWORK=off go build ./...` passes on the new requirement; the end-to-end two-ref build measurement is the next leg. Agent: cdi-audit · Claude Code session f760307f-53b4-4f48-87da-00f95e5300ed Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system) * chore(deps): keep the tools modules on the shared spec pin The canonical-pin gate (tools/gomod-canonical) requires every module in this repo to require the same spec version. The charly module moved to v0.2026330.2134; bump the three tools modules to it as well, and re-tidy. Agent: cdi-audit · Claude Code session f760307f-53b4-4f48-87da-00f95e5300ed Assisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)
Summary
CandyStageDirNamekeyed the build staging directory by<name>.<version>, so a ref-only change —the same candy content at a new tag or branch — produced a different
COPYsource path andinvalidated every BuildKit layer beneath it. Measured on the openwebui image: 2400 s cold, 90 s for
the same tree, 683 s for the same content at a new ref.
This addresses the directory by the candy's content:
<name>.<sha256[:16]>over the sortedrelative paths, each regular file's executable bit and bytes (symlink targets included;
.git,mtimes, owners and the other permission bits excluded — git applies the umask to those, so they differ
between checkouts of identical content). Consequences:
COPYsource and itslayer key stay stable, so a ref-only change reuses the cached pixi stage instead of re-executing it.
already installs atomically (
kit.InstallDirAtomic, renameat2 RENAME_EXCHANGE).under an address it could not derive.
The stager (
plugin-build'screateRemoteCandyCopies,host_prep.go:180) and theCOPYsource(
sdk/deploykit'sCandyCopySource,candy_stage.go:41) both call this ONE function, so the name isderived in one place — the change is a single implementation, not a second naming path.
Head:
f3c26fca7922381246f52d0ca0b7f95b22fc1176Diff: 4 files changed, 226 insertions(+), 6 deletions(-)
deploy/deploy_ops.go—CandyStageDirNamederives the content addressdeploy/content_hash.go—dirContentHash, the deterministic walk (new)deploy/deploy_ops_candykey_test.go— the existingfakeCandygainsGetVersion/GetSourceDirdeploy/content_hash_test.go— the three witnesses (new)How tested
The umask witness fails on the previous mode-string hash (measured):
It asserts both directions: two trees of identical content with different file/directory permissions
produce ONE address, and flipping the executable bit changes it.
The same-content test is the regression witness: two separate checkouts of identical content at
two versions must produce the SAME directory (and it asserts the name is no longer
name.version);the different-content test asserts they must NOT collide.
A compile-compat check of the consumer (
sdk) against this module — it does not itself prove the changed branch, the in-module witnesses do:Spike
<name>.<version>The cross-repo proof (producer-first)
specis a Go-module dependency ofcharly, so the end-to-end measurement — two builds of identicalcontent at two refs, comparing the pixi stage duration against the 683 s baseline — runs at the
consumer's leg: this PR merges and tags,
charlybumps itsspecrequirement to that tag, the binaryis rebuilt, and the two builds are pasted there. That is the sanctioned producer-first order
(
/charly-internals:git-workflowB6), not a deferral of this change's own gate: this PR's gate is theunit witnesses above, which fail without the change.
Rulebook compliance
/charly-internals:go,/charly-internals:designand/charly-internals:git-workflowloaded.
opencharly/charly#1289; no new finding is parked.layer-pixi#6).origin/main; no force-push.consumer leg, sequenced by producer-first.
Change classification
No breaking change to a wire shape. The staging directory NAME changes, so the first build after
the change re-executes the layers once (a new COPY source); after that, ref-only changes reuse them.
Breaking change + rollback: none — reverting restores the version-keyed name.
Filed issues
its measured performance lever).
Agent:
cdi-audit· Claude Code sessionf760307f-53b4-4f48-87da-00f95e5300edAssisted-by: Claude Code deepseek-v4.1-flash:cloud (analysed on a live system)