Files
RedBear-OS/src
vasilito 298a6ed74c cookbook: source content hash for cache invalidation
Implements Improvement 2 from local/docs/BUILD-SYSTEM-IMPROVEMENT-PROPOSAL.md.

Replaces the mtime-only source invalidation with a BLAKE3 content hash
of every file in the source tree (plus recipe.toml and patches). The hash
catches content modifications that preserve mtime (git checkout, git
bisect, cp -a, rsync -a) and silently leave the cache stale.

Design choices:
- Hash written to target/<arch>/source_hash.txt after each successful
  build, atomically (tmp + rename) to survive concurrent builds.
- Two-tier check: mtime fast-path (skip hash compute when mtime says
  'changed'); hash verification (when mtime says 'unchanged', still
  compute hash to catch mtime-preserving edits). The hash compute cost
  is one pass over the source tree per build — acceptable for the
  correctness gain.
- Symlinks are NOT followed in collect_files_recursive (avoids cycles
  and surprises across the sysroot).
- Unreadable files are hashed as <unreadable> sentinel so a permission
  fix later changes the hash and triggers a rebuild (correct
  behavior).
- Patch filenames are hashed alongside contents so reordering or
  renaming patches invalidates the cache (order matters for atomic apply).
- Devices, sockets, .git/, target/, *.swp, *.tmp are excluded.

Smoke-tested: hash is deterministic and different source dirs produce
different hashes. Cookbook compiles cleanly. Integration with the
existing source_changed decision is via OR (mtime OR hash triggers
rebuild).
2026-07-10 22:19:14 +03:00
..
2026-07-05 22:29:19 +03:00