From 466f6f7e223f56670feabb0737cf97f708aa45f2 Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 20 Nov 2026 17:55:31 +0000 Subject: watch: one source interface, and the fail-closed check lives with the source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The step machine reached into two of watch's internals and reassembled the rules itself: `mirror::read_tree` then `Tree::recipe_hash` to re-derive the hash a reviewer approved, and `digests::cached_path` then `digests::download_and_cache` then its own comparison to check a payload. The comparison is the part that must never be skipped, and it was sitting in whichever step happened to want a file — a step could have forgotten it and nothing would have noticed. `watch::sources` is the interface now: what a tree hashes to, and a guarantee that a cached source is the bytes its name claims. `verify_cached` owns the fail-closed test and its message verbatim. `download_and_cache` and `cached_path` are `pub(crate)` again, so the cache layout is watch's business again; `watch/mod.rs` no longer re-exports them. `src/pipeline` now names exactly one watch path. Detection is untouched by construction — no git-invoking function changed — and the census agrees: 264 successful git execs on the detect binary before and after. (An initial reading of 1320 vs 264 was PATH-probe ENOENTs from a differing shell PATH, not git work; counted with suite-cost.py's own rule of successful execve only, the two runs are identical.) watch.pub 31->30. `read_tree` moved into the test-only column: the pipeline stopped naming it, and what remains are watch's own calls plus the two tests that exercise its one-batch-read contract directly. 277 passed / 0 failed, clippy -D warnings clean. --- src/watch/digests.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/watch/digests.rs') diff --git a/src/watch/digests.rs b/src/watch/digests.rs index b95bd6c..534b5bd 100644 --- a/src/watch/digests.rs +++ b/src/watch/digests.rs @@ -92,7 +92,7 @@ pub fn resolve_sources( Ok(out) } -pub fn download_and_cache(cfg: &Config, db: &Db, url: &str) -> Result<(String, u64)> { +pub(crate) fn download_and_cache(cfg: &Config, db: &Db, url: &str) -> Result<(String, u64)> { let tmp = cfg.source_cache_dir().join(format!("tmp-{}", crate::hash::short(url.as_bytes(), 16))); let (digest, size) = crate::fetch::fetch_to(url, &tmp)?; let dest = cfg.source_cache_path(&digest); @@ -109,7 +109,7 @@ pub fn download_and_cache(cfg: &Config, db: &Db, url: &str) -> Result<(String, u Ok((digest, size)) } -pub fn cached_path(db: &Db, url: &str, digest: &str) -> Option { +pub(crate) fn cached_path(db: &Db, url: &str, digest: &str) -> Option { db::source_cache_path(db, url, digest) .ok() .flatten() -- cgit v1.2.3