From 63f3f9096c9cee169250c089c1ff3fa763942796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Shixiang=20Wang=20=28=E7=8E=8B=E8=AF=97=E7=BF=94=29?= Date: Tue, 24 Nov 2026 10:19:21 +0800 Subject: [PATCH 1/3] test: pin law 2 timed face -- a hardlink crossing a clock tick is not a bytes move The scheduled sanitizer(address) leg reddened 2026-11-23 (run 45200867538) on hardlinked_alias_shares_the_decoding: the VCache identity key carries a ctime whole-second stamp, POSIX link() bumps ctime, and when the link lands after the base stat crossed a second the two stats disagreed on a field no bytes move ever produced -- a spurious miss on the bridge layout itself, late-linked aliases decoding twice. This adds the deterministic probe: base decoded, forced second crossing (1.1 s, same idiom as the bytes-moved law), alias linked last. Three runs against the unfixed key: 3/3 FAILED at the ptr_eq law, right reason, timing-independent. --- src/rust/engine/tests/batch_v_cache.rs | 47 +++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/rust/engine/tests/batch_v_cache.rs b/src/rust/engine/tests/batch_v_cache.rs index bc876271..bfe571af 100644 --- a/src/rust/engine/tests/batch_v_cache.rs +++ b/src/rust/engine/tests/batch_v_cache.rs @@ -21,7 +21,11 @@ //! sharing, the point of the exercise) with the naive-parse bytes //! bit-for-bit (`assert_eq!` on the Vec); //! 2. a hard-linked alias of that path shares the same Rc (that is the -//! bridge's layout, so it is the contract that must work); +//! bridge's layout, so it is the contract that must work) — including +//! an alias linked AFTER the base's first decode: POSIX `link()` +//! bumps the shared inode's ctime, and a ctime bump with untouched +//! bytes is not a move (law 4 keys on mtime), so the clock second the +//! link lands in must not cost the shared entry; //! 3. a distinct file with equal bytes does NOT share (identity is the //! key, not content hashing — no false aliasing across cases); //! 4. any move of the bytes under a name (length or mtime moved) forces @@ -178,6 +182,47 @@ fn hardlinked_aliases_decode_correctly_and_independently() { } } +#[cfg(unix)] +#[test] +fn a_hardlink_after_a_clock_tick_still_shares_the_decoding() { + // Law 2's timed face, and the sanitizer-leg race made deterministic: + // the bridge links case names after the base may already have been + // decoded, POSIX `link()` bumps the shared inode's ctime, and the key + // is a whole-second clock -- so when the link crosses a tick the two + // stats disagree on ctime while no byte ever moved. The sleep mirrors + // `bytes_moved_under_a_name_force_a_fresh_decode`: the crossing is + // forced, never flaked. + let t = Tmp::new("late-link"); + let p = t.join("shared.csv"); + write_grid(&p, M, N, 0); + let mut c = VCache::new(); + let a = c.decode(&p, M, N, K).expect("decode base"); + std::thread::sleep(std::time::Duration::from_millis(1_100)); // base stat first, tick second, link last + let alias = t.join("late.csv"); + fs::hard_link(&p, &alias).expect("hard_link"); + let got = c.decode(&alias, M, N, K).expect("decode late alias"); + assert!(Rc::ptr_eq(&a, &got), "a link that crossed a clock tick is not a bytes move and must share the base decoding"); + assert_eq!(*got, *a, "late alias bytes"); +} + +#[cfg(not(unix))] +#[test] +fn a_hardlink_after_a_clock_tick_decodes_fresh_and_correctly() { + // Fail-closed twin of `a_hardlink_after_a_clock_tick_still_shares_the_decoding`: + // there is no key to disagree about here, so every late alias is its + // own fresh read of the bytes on disk. + let t = Tmp::new("late-link"); + let p = t.join("shared.csv"); + write_grid(&p, M, N, 0); + let mut c = VCache::new(); + let a = c.decode(&p, M, N, K).expect("decode base"); + assert_eq!(*a, naive_read(&p, MN), "base bytes"); + let alias = t.join("late.csv"); + fs::hard_link(&p, &alias).expect("hard_link"); + let got = c.decode(&alias, M, N, K).expect("decode late alias"); + assert_eq!(*got, naive_read(&alias, MN), "the late alias must decode to the bytes on disk through its own fresh read"); +} + #[test] fn equal_bytes_under_different_names_do_not_share() { // Keyed on file identity, never content: two distinct files holding From 0aa34f6ba16b69ff0c61197426f4b230df6a9c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Shixiang=20Wang=20=28=E7=8E=8B=E8=AF=97=E7=BF=94=29?= Date: Tue, 24 Nov 2026 10:19:21 +0800 Subject: [PATCH 2/3] fix: drop ctime from the batch V-cache identity key mtime carries the freshness law alone: any bytes move moves mtime with it, so every window ctime guarded, mtime already guarded. The extra field bought nothing and byte-less metadata events (link(), chmod) bumped it, costing shared entries -- the spurious misses that panicked the sanitizer leg. The test-file law 4 always read "length or mtime moved": the key field was unclaimed implementation drift, now pinned by the late-link twin in tests/batch_v_cache.rs. GREEN: batch_v_cache 6/6 (was 1 failed deterministic), full engine suite 335 tests 0 failed, clippy --workspace -D warnings clean. --- src/rust/engine/src/vcache.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/rust/engine/src/vcache.rs b/src/rust/engine/src/vcache.rs index ae9eff97..add9a572 100644 --- a/src/rust/engine/src/vcache.rs +++ b/src/rust/engine/src/vcache.rs @@ -6,7 +6,7 @@ //! a fifty-case batch otherwise asks the kernel to decode and validate //! byte-identical inputs fifty times. This module shares the decoded read //! inside one batch process: cache identity is the FILE identity (device, -//! inode, byte length, and the kernel-reported mtime/ctime seconds -- +//! inode, byte length, and the kernel-reported mtime second -- //! `std::os::unix`, no content hashing), and a hit hands back a clone of //! the same `Rc`. //! @@ -16,12 +16,16 @@ //! CLI's reader is a thin delegate to it, so fault TEXT cannot drift; //! * faults are fail-closed and never cached; //! * any move of the bytes under a name (length, or the kernel's -//! mtime/ctime seconds, moved) forces a fresh decode. The same-inode, -//! same-length, same-clock-second rewrite is the one theoretical stale -//! window: unreachable under the serving law that case bytes are -//! written once and then read-only (campaign law, attested input -//! hashes), and every emitted byte is gated downstream by the P2 -//! bit-identity family regardless; +//! mtime second, moved) forces a fresh decode. ctime is deliberately +//! not in the key: it also rises on byte-less metadata events such as +//! link(), so keying on it would buy no staleness protection a bytes +//! move does not already give (a bytes move moves mtime with it) and +//! would trade in spurious misses on the bridge's own late-linked +//! layout; the same-inode, same-length, same-clock-second rewrite is +//! the one theoretical stale window: unreachable under the serving law +//! that case bytes are written once and then read-only (campaign law, +//! attested input hashes), and every emitted byte is gated downstream +//! by the P2 bit-identity family regardless; //! * two distinct files never fold together, even when their bytes are //! equal (content hashing would fold them -- identity must not). @@ -81,7 +85,6 @@ struct Key { ino: u64, len: u64, mtime: i64, - ctime: i64, } /// The per-process V memo. One instance per batch (the batch entry builds @@ -131,7 +134,6 @@ impl VCache { ino: md.ino(), len: md.len(), mtime: md.mtime(), - ctime: md.ctime(), }; if let Some(hit) = self.entries.get(&key) { return Ok(hit.clone()); From 4db0821662b968799950e07f81877036a86a17a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Shixiang=20Wang=20=28=E7=8E=8B=E8=AF=97=E7=BF=94=29?= Date: Tue, 24 Nov 2026 10:19:21 +0800 Subject: [PATCH 3/3] ci: pin the scheduled sanitizer legs to ubuntu-24.04 Issue #74 image-dating ruling, same law as the valgrind arm above: sanitizer verdicts must be observed over a still environment. The 2026-11-23 race rode ubuntu-latest while the image moved underneath it; the defect itself is now pinned out by law, the pin keeps the observation window still. --- .github/workflows/scheduled.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 20cc2705..22e8e5d6 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -120,7 +120,15 @@ jobs: retention-days: 14 sanitizer: - runs-on: ubuntu-latest + # Pinned, never `-latest` (issue #74 ruling, same law as `valgrind` + # above): the leg's verdicts must be observed over a still environment. + # Its 2026-11-23 red was exactly an image-float class race -- the + # VCache identity key held a ctime whole-second stamp that a late + # hard_link could bump between two stats; the defect is now pinned + # out by law in src/rust/engine/tests/batch_v_cache.rs (late-link + # twin), and the image pin keeps the observation window from moving + # underneath it. + runs-on: ubuntu-24.04 # Hard gate: the 22 s/12 s archived legs (D1) died at target discovery. timeout-minutes: 90 strategy: