Skip to content

feat(content-hash): add blake3_file primitive for dev daemon-identity isolation (#891) - #892

Merged
zackees merged 1 commit into
mainfrom
feat/891-blake3-file-content-hash
Aug 7, 2026
Merged

feat(content-hash): add blake3_file primitive for dev daemon-identity isolation (#891)#892
zackees merged 1 commit into
mainfrom
feat/891-blake3-file-content-hash

Conversation

@zackees

@zackees zackees commented Aug 7, 2026

Copy link
Copy Markdown
Owner

What

Adds running_process::blake3_file(&Path) -> io::Result<Hash> (module content_hash, re-exported at the crate root, feature client) — the shared content-hash primitive requested in #891.

Why

soldr-daemon, FastLED/fbuild, and standalone zccache all obtain their daemon identity/discovery through running-process, and all three hit the same dev failure: two builds sharing one home root (e.g. ~/.soldr-dev) rendezvous on the same daemon pipe + pid file, each sees the other as "stale-version" and displaces it on every invocation — a displace-stale war that wedges the compile daemon. The shims are already version-namespaced; the daemon identity is not. Rather than reimplement isolation in each consumer, provide it once here — the common service everyone routes through.

The primitive

pub fn blake3_file(path: &Path) -> io::Result<Hash>;   // impl: Hasher::new().update_mmap_rayon(path)?
  • Hashes the bytes, not the path string — path-hashing returns the same value across rebuilds → no isolation; content changes every build → identity changes every build (isolates same-version rebuilds), which is the whole point.
  • mmaps the file, does not hash the loaded image — the mapped module is mutated by ASLR relocations, the resolved IAT, and live .data/.bss, so it differs from the file and differs every run (ASLR) → a nonce. update_mmap_rayon on the file is page-cache-warm and multi-core (~1–3 ms for a 20 MB binary).

Consumers stamp dev identity as "<version>-<first-16-hex of blake3_file(current_exe)>", computed once and propagated as a value down the process tree (see the issue for the client/daemon agreement).

Changes

  • crates/running-process/src/content_hash.rs — the primitive + Hash re-export + 6 unit tests (hashes-bytes-not-path, path-independence, content-sensitivity, empty file, stable first-16-hex stamp, missing-file io::Error).
  • Cargo.toml — enable blake3's mmap + rayon features (required by update_mmap_rayon).
  • lib.rspub mod content_hash + pub use content_hash::blake3_file (both feature-gated on client, where blake3 already lives; soldr/zccache/fbuild all consume client).
  • docs/api_snapshot_rust.txt — regenerated for the new re-export.
  • CHANGELOG.md — Unreleased entry.

Validation

Local (MSVC), all via soldr cargo:

  • soldr cargo test -p running-process --features client --lib content_hash → 6 passed
  • soldr cargo clippy -p running-process --features client --lib -- -D warnings → clean
  • soldr cargo fmt check → clean

Refs: zackees/soldr#2352 (design of record + evidence), zackees/soldr#2353 (interim soldr-side fix).

Closes #891

🤖 Generated with Claude Code

… isolation (#891)

soldr-daemon, FastLED/fbuild, and standalone zccache all obtain their
daemon identity/discovery through running-process, and all three hit the
same dev failure: two builds sharing one home root rendezvous on the same
daemon pipe + pid file, each sees the other as "stale-version" and
displaces it on every invocation — a displace-stale war that wedges the
compile daemon. The shims are already version-namespaced; the daemon
identity is not. Provide the isolation primitive once here, the common
service everyone routes through.

- Add running_process::content_hash::blake3_file(&Path) -> io::Result<Hash>
  (re-exported at the crate root, feature `client`). Hashes the file's
  BYTES via blake3::Hasher::update_mmap_rayon: content-based (so
  same-version rebuilds isolate), mmap+multi-core (page-cache-warm, ~1-3ms
  for a 20MB binary), and immune to the ASLR/IAT/.data mutation that makes
  the loaded image a per-run nonce.
- Enable blake3's `mmap` + `rayon` features (required by update_mmap_rayon).
- Unit tests: hashes-bytes-not-path, path-independence, content-sensitivity,
  empty file, stable first-16-hex stamp, missing-file io::Error.
- Regenerate docs/api_snapshot_rust.txt for the new re-export.

Refs: zackees/soldr#2352 (design of record + evidence), zackees/soldr#2353
(interim soldr-side fix).

Closes #891

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zackees
zackees merged commit ab0ff00 into main Aug 7, 2026
16 checks passed
@zackees
zackees deleted the feat/891-blake3-file-content-hash branch August 7, 2026 23:33
@zackees zackees mentioned this pull request Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose blake3_file(&Path) content-hash primitive for dev daemon-identity isolation (soldr/zccache/fbuild)

1 participant