test(rust-audit): cover iso8601 civil-date conversion with fixed-time cases#2163
Merged
imran-siddique merged 1 commit intoMay 12, 2026
Conversation
… cases `audit::iso8601_now` re-implements the Howard Hinnant civil-from-days algorithm to avoid a chrono dependency. Until now it was only smoke-tested for format shape (length and delimiter positions) — the actual date math was unverified, so a regression in the era / day-of-era arithmetic would silently produce wrong timestamps in every audit entry. Factor the formatting body into a pure `iso8601_from_unix_secs(secs)` helper so it can be tested with known inputs, and assert eight reference points covering edges that exercise the algorithm: - Unix epoch (1970-01-01) - 2000-01-01 (divisible-by-400 century year) - 2000-02-29 and 2024-02-29 (both kinds of leap year) - 2024-03-01 (day after leap day — guards off-by-one in `mp`) - 2024-12-31T23:59:59 (last second of a leap year) - 1e9 and 1.7e9 seconds (common reference points) No behavioural change — `iso8601_now()` still reads `SystemTime::now()` and produces the same output.
🤖 AI Agent: test-generator — `agent-governance-rust/agentmesh/src/audit.rs`
|
🤖 AI Agent: security-scanner — View detailsNo security issues found. |
🤖 AI Agent: docs-sync-checker — Docs SyncDocs Sync
|
🤖 AI Agent: code-reviewer — View detailsTL;DR: 0 blockers, 0 warnings. No issues found. Clean change. |
🤖 AI Agent: breaking-change-detector — API CompatibilityAPI Compatibility
|
|
🟡 Contributor Check: MEDIUM
Automated check by AGT Contributor Check. |
PR Review Summary
Verdict: ✅ Ready for human review |
MohammadHaroonAbuomar
pushed a commit
to MohammadHaroonAbuomar/agt-acs
that referenced
this pull request
Jun 1, 2026
… cases (microsoft#2163) `audit::iso8601_now` re-implements the Howard Hinnant civil-from-days algorithm to avoid a chrono dependency. Until now it was only smoke-tested for format shape (length and delimiter positions) — the actual date math was unverified, so a regression in the era / day-of-era arithmetic would silently produce wrong timestamps in every audit entry. Factor the formatting body into a pure `iso8601_from_unix_secs(secs)` helper so it can be tested with known inputs, and assert eight reference points covering edges that exercise the algorithm: - Unix epoch (1970-01-01) - 2000-01-01 (divisible-by-400 century year) - 2000-02-29 and 2024-02-29 (both kinds of leap year) - 2024-03-01 (day after leap day — guards off-by-one in `mp`) - 2024-12-31T23:59:59 (last second of a leap year) - 1e9 and 1.7e9 seconds (common reference points) No behavioural change — `iso8601_now()` still reads `SystemTime::now()` and produces the same output.
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
agent-governance-rust/agentmesh/src/audit.rsre-implements the Howard Hinnant civil-from-days algorithm insideiso8601_nowto avoid pulling in chrono. The only existing test for it asserted shape (length and delimiter positions) — the actual era / day-of-era arithmetic was unverified, so a regression in the date math would silently produce wrong timestamps in every audit entry.Change
iso8601_from_unix_secs(secs: u64) -> Stringhelper.iso8601_now()still readsSystemTime::now()and produces identical output.test_iso8601_from_unix_secs_known_valuesasserting eight reference points:mp)Reference timestamps cross-checked against
DateTimeOffset.FromUnixTimeSeconds.Tests
cargo test -p agentmesh --lib audit::— 27 passed, 0 failed.Test plan
mpformula) is perturbedtest_iso8601_now_formatshape check still passesiso8601_now()Surfaced during independent audit conducted by @finnoybu (Ken Tannenbaum, AEGIS Initiative); [LOW, Rust].