fix(cache): catch same-length edits made within one timestamp tick #860
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 332 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.347
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #860"
general
weight: 0.35
jbellis
On filesystems with coarse timestamps, such as ZFS (1 ms tick), a source file rewritten with the same length within one tick of mbx's pre-compile snapshot passed the check that inputs did not change during compilation. Length, mtime, ctime and inode can all stay equal across such a rewrite. mbx then accepted the file as unchanged, although the compiler might have read the old bytes. This affected both the Rust and the C/C++ paths.
The cause:
FileSnapshot::capturetook a metadata-only snapshot everywhere except NFS, and never appliedidentity_is_racy, the "racily clean" guard that digest reuse already uses (the same problem git guards its index against). The verification then accepted the matching snapshot and skipped the start-time check.Now, when a file's metadata is still inside the race window at capture time (20 ms; 2 s for whole-second timestamps), the snapshot also records the content digest, and an equal-metadata ledger hit is not trusted for it. For a local file, verification then requires both the full metadata identity (including ctime) and the bytes to match. A same-length rewrite in the same tick is caught by its digest, and an edit that restores the original bytes is caught by its ctime. NFS and compiler-artifact snapshots keep their existing timestamp tolerance. Settled files keep the cheap metadata-only snapshot, with no extra reads. The public API and the persisted formats are unchanged.
Reproduced on ZFS before the fix: a same-length rewrite passed both the pre-compile and the final verification on the first attempt. A wrong cache entry end to end was not reproduced.
Tests: deterministic tests drive the capture with an observation time inside the race window, and model identical metadata after a same-length rewrite. They fail without the fix. Another test rejects an edit that restores the original bytes, and another checks that settled snapshots read no content.
Soak: on a 96-core workstation whose cache and targets are on ZFS, in a build combining this change with the other pending fixes, from 2026-10-27 23:01Z to 2026-10-28 08:01Z, under normal agent and benchmark load. Four checks and 23 snapshots found no regression attributable to the build. The window was interrupted by a host reboot. No input-change bypasses or verification divergences were seen. The wrapper time that includes snapshot capture fell from 185 to 96 ms per compile over the soak, so the extra hashing did not show up as a cost.
Reported as jbellis/mr-boxington#39.
AI-assisted — Tool: Claude Code; model: anthropic/claude-opus-5-5; version: 2.1.306.
🤖 Generated with Claude Code