fix(prefetch): render an unset FILETIME as "-", not 1601-01-01 - #4
Merged
Merged
Conversation
FILETIME 0 is the Windows "not set" sentinel. filetime_to_iso currently
converts it to the FILETIME epoch and jiff accepts the result, so it
returns Some("1601-01-01T00:00:00Z") rather than None -- meaning
print_record's "-" fallback can never engage for an unset timestamp.
Adds a #[cfg(test)] module to the bin (mirroring the convention in
forensic/src/lib.rs) covering both the sentinel and a genuine FILETIME.
RED: tests::unset_filetime_has_no_rendering fails
left: Some("1601-01-01T00:00:00Z")
right: None
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
filetime_to_iso mapped the Windows "not set" sentinel (FILETIME 0) onto the FILETIME epoch, which jiff accepts, so the CLI would print a real-looking last-run time of 1601-01-01T00:00:00Z for a timestamp that was never recorded. Returning None lets print_record's existing "-" fallback engage, matching how memory-forensic's format_filetime renders the same sentinel. Scope note: prefetch-core already breaks on the first non-positive FILETIME (core/src/lib.rs:159), so a record parsed by this workspace never carries a 0 and the CLI's own call site could not reach the bad rendering today. ExecutionRecord's fields are public, so this makes the conversion correct on its own terms rather than resting on an upstream invariant the call site does not state. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prefetch4n6'sfiletime_to_isohad no guard for FILETIME0, the Windows "not set" sentinel. It computed0 / 10_000_000 - 11_644_473_600, andjiff::Timestamp::from_secondaccepts that value, so the function returnedSome("1601-01-01T00:00:00Z")instead ofNone— an absent timestamp rendered as a real-looking date. ReturningNoneletsprint_record's existing-fallback engage, matching howmemory-forensic'sformat_filetimerenders the same sentinel.Scope note — this is hardening, not a live user-visible bug
prefetch-corealready breaks on the first non-positive FILETIME (core/src/lib.rs:159,Some(t) if t > 0 => push, _ => break), soExecutionRecord.last_run_filetimesnever carries a0for a record parsed by this workspace, and the CLI's own call site could not reach the bad rendering today. Verified empirically: a synthetic SCCA v30 with all eight last-run FILETIMEs zeroed yieldslast_run_times = [].The fix still stands on its own —
ExecutionRecord's fields are public, so a consumer can construct one directly, and the conversion should be correct without resting on an upstream invariant the call site does not state.Testability seam
Added a
#[cfg(test)] mod testsinside the bin rather than promotingfiletime_to_isointo the library. It mirrors the convention already inforensic/src/lib.rs:196(same#[allow(clippy::unwrap_used, clippy::expect_used)]attribute), keeps the diff minimal, and avoids adding published API surface toprefetch-forensicfor a CLI-only rendering helper. The coverage gate iscargo llvm-cov --workspace --lib, so bin code sits outside the denominator either way.TDD
Two commits, RED then GREEN.
RED (
bc0f60f) —tests::unset_filetime_has_no_renderingfails:GREEN (
935077f) — both bin tests pass.Pre-push gate
cargo build,cargo test(17 passed, 0 failed),cargo clippy --all-targets -- -D warnings,cargo fmt --check— all clean.Deliberately out of scope
Non-zero pre-epoch / negative FILETIMEs still convert to a pre-1970 date.
memory-forensicrenders those aspre-1970 (0x…);prefetch-core'st > 0filter means they cannot arrive through the parse path here either. Left alone to keep the change minimal.🤖 Generated with Claude Code