Skip to content

fix(storage): propagate clock error in applied_at_ms (TD-08)#456

Merged
intendednull merged 1 commit into
auto-fix/batch-2026-04-28-002530from
auto-fix/issue-254-timestamp-anyhow
Apr 28, 2026
Merged

fix(storage): propagate clock error in applied_at_ms (TD-08)#456
intendednull merged 1 commit into
auto-fix/batch-2026-04-28-002530from
auto-fix/issue-254-timestamp-anyhow

Conversation

@intendednull
Copy link
Copy Markdown
Owner

what

migration insert in crates/storage/src/store.rs did:

SystemTime::now().duration_since(UNIX_EPOCH)
    .map(|d| d.as_millis() as i64)
    .unwrap_or(0);

clock pre-1970 -> applied_at_ms = 0 silently lands in schema_version. rest of crate hands back anyhow::Result. mismatch.

fix

.map_err(anyhow::Error::from)? on the duration_since. function already returns anyhow::Result<()>, the ? just falls through.

only one call site in the storage crate (grep clean). no shared helper, one line plus comment.

test

extended schema_version_table_exists_after_open. now reads back applied_at_ms alongside version and asserts every row has applied_at_ms > 0. pins behaviour off the legacy 0 fallback under normal clock.

error-branch test (clock pre-1970) would need SystemTime mocking infra the crate does not have today. out of scope for this issue. comment in test notes that.

storage tier (lowest covering this insert path).

verify

$ cargo fmt --check -p willow-storage
(clean)

$ cargo clippy -p willow-storage --all-targets -- -D warnings
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.40s

$ cargo test -p willow-storage
test result: ok. 35 passed; 0 failed; 0 ignored; 0 measured

storage is native-only (rusqlite + tokio in Cargo.toml), no wasm check.

Refs #254


Generated by Claude Code

migration insert used `.unwrap_or(0)` on `SystemTime::now`
duration. clock pre-1970 means `applied_at_ms = 0` lands in
schema_version, silent. rest of crate returns `anyhow::Result`,
so just `?` it.

only one site in the storage crate, no helper needed.

test: extend `schema_version_table_exists_after_open` to read
back `applied_at_ms` and assert > 0. pins behaviour against
the legacy `0` fallback under normal clock. error-branch
test would need time mocking the crate doesn't have, out of
scope.

TD-08, refs #254
@intendednull intendednull merged commit 87c1648 into auto-fix/batch-2026-04-28-002530 Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants