Repository navigation
clazel-x509: from_unix_seconds for path validation (3.5b P1), tier 0 - #28
Merged
Merged
Conversation
…kwards Walks days, years and months by recursion; None above year 9999; never second 60. Contract, lemmas and exec follow. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Monotone, injective, None exactly past 9999-12-31T23:59:59Z, never second 60, 400-year cycle, and the eight listed examples. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Skips whole 400-year cycles by division, walks at most 400 years and 12 months. Unit tests with the known answers, cross-checked with Python. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Leap-year century and 400 rules, February and 30-day month lengths, seconds per day, epoch year and the 9999 bound. Co-Authored-By: Claude Sonnet 5.5 <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.
Path validation P1 (3.5b,
.claude/plans/path-validation.md§1.5). It addstime::from_unix_seconds, which turns the current time in Unix seconds into theCertificateTimethat validity checks compare against.clazel-x509stays at tier 0.Commits
Spec and contract come before any exec code:
9822e8bspec:from_unix_seconds52e730acontract0e15905spec: names the year bound80e9e32lemmas and known answers276d062spec: a header reflow onlydfd492aexec and testsfd5d61bmutationsSpec
from_unix_seconds(t)is POSIX.1-2017 XBD §4.16 "Seconds Since the Epoch" read backwards. It is a plain walk:tinto days and the second of the day;is_leap_year), then month by month (using the existingdays_in_month);Noneexactly when the year would pass 9999, following RFC 5280 §4.1.2.5's four-digit years.Second 60 is never produced. The header lists the modelling choices.
Proven
These need no axioms:
lemma_from_unix_monotone:a <= bandf(b)Some implyf(a)Some andtime_le(f(a), f(b)).lemma_from_unix_injective.lemma_from_unix_none_iff:Noneifft > 253402300799.lemma_from_unix_valid: a valid calendar time, never second 60.from_unix_seconds(u64): uses the 400-year (146,097-day) cycle and walks at most 400 years and 12 months, with saturating arithmetic. It is proven equal to the spec.Known answers
Each is proven, and also unit-tested:
Noneu64::MAXNoneAll were cross-checked with Python's
calendar.timegm, and a Python port of the spec matcheddatetimeon 20,000 random values.Checks done
268 verified, 0 errorsforclazel-x509, from a clean cache. Re-run independently of the agent.cargo xtask mutate clazel-x509killed all 40 with certificates. Seven are new: dropping the 100 rule, dropping the 400 rule, February's length, the 30-day months, seconds per day, the epoch year and the 9999 bound. The 33 existing mutations are unchanged.cargo xtask checkpass.Limits
max_year() == 9999), becausecompute_onlycannot walk 8,030 years. The mutant also breakslemma_from_unix_none_iffand the 9999 example, but those can't be the certificate.independent.rswould be the tier-2 route.CI has not run yet.
🤖 Generated with Claude Code