Repository navigation
fix: accept RFC 3339 datetimes for stale_after, per OKF §5.5 - #44
Merged
Merged
Conversation
OKF §5.5 defines stale_after as "an absolute instant" and its own example is a full datetime (2026-09-23T00:00:00Z), but validate only accepted a bare YYYY-MM-DD date and rejected the spec's example while citing §5.5. §11 requires a validator to accept every conformant bundle, so the validator was stricter than the spec it checks. stale_after now accepts an RFC 3339 datetime with a zone (Z or an offset, quoted or not) as well as YYYY-MM-DD, which keeps its existing meaning of midnight UTC. A datetime with no zone is still rejected because it is not an absolute instant. Staleness compares by instant, so show/list report stale correctly for datetime values too. Regression tests were written first and failed before the fix: unit tests for the parser and IsStale, validate tests for each form in the report, and an end-to-end test through validate and show. Reported-by: Alexander Heidl (@alexheidl) Closes #34 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
akeemjenkins
force-pushed
the
fix/34-stale-after-datetime
branch
from
November 7, 2026 06:35
6402093 to
beecc60
Compare
Open
3 tasks
Mokkori-Tom
pushed a commit
to Mokkori-Tom/toji
that referenced
this pull request
Nov 15, 2026
OKF §5.5 defines stale_after as "an absolute instant" and its own example is a full datetime (2026-09-23T00:00:00Z), but validate only accepted a bare YYYY-MM-DD date and rejected the spec's example while citing §5.5. §11 requires a validator to accept every conformant bundle, so the validator was stricter than the spec it checks. stale_after now accepts an RFC 3339 datetime with a zone (Z or an offset, quoted or not) as well as YYYY-MM-DD, which keeps its existing meaning of midnight UTC. A datetime with no zone is still rejected because it is not an absolute instant. Staleness compares by instant, so show/list report stale correctly for datetime values too. Regression tests were written first and failed before the fix: unit tests for the parser and IsStale, validate tests for each form in the report, and an end-to-end test through validate and show. Reported-by: Alexander Heidl (@alexheidl) Closes okfcli#34 Co-Authored-By: Claude Opus 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.
Fixes #34. Thanks to @alexheidl for the report. It quoted the spec text, gave the exact failing values, reproduced the problem on two separate bundles, and linked it to the same "stricter than the spec" pattern as #26 and #27. That made this a quick fix.
The bug
OKF v0.2 §5.5 defines
stale_afteras "an absolute instant," and its own example is a full datetime:okf validateonly accepted a bareYYYY-MM-DDdate. It rejected the spec's own example withokf/lifecycle/stale-after-invalidand cited §5.5 for a rule §5.5 doesn't contain. §11 says a validator MUST accept every conformant bundle, so the issue's first suggestion was the right one: accept the datetime form and leave the spec as it is.The change
concept.ParseStaleAfteraccepts:Zor an offset, quoted or unquoted (2026-10-03T00:00:00Z,2026-10-03T00:00:00+00:00,"2026-10-03T00:00:00Z")YYYY-MM-DDdate, which keeps its current meaning of midnight UTC, so existing bundles are unaffected2026-10-03T00:00:00) is still an error, because it isn't an absolute instant.IsStalecompares instants (now >= stale_after), soshowandlistreportstalecorrectly for datetime values too.okf schemaand SARIF output, the finding messages, and the README now describe the accepted forms. Rule IDs, severities and exit codes are unchanged.Tests (written first, failed before the fix)
internal/concept: parser table for valid and invalid forms, plusIsStaleboundary tests for an offset datetime and a quoted datetimeinternal/validate: each form from the issue is accepted, stale and fresh datetimes warn or don't, and a datetime without a zone is rejectedcmd/okfe2e:validateexits 0 on the spec's example, andshowreturnsstale: trueand the originalstale_afterstring unchangedVerification
All pass locally, with 0 lint issues. I also reran the issue's repro values against the built binary:
stale_after2026-10-03T00:00:00Z2026-10-03T00:00:00+00:00"2026-10-03T00:00:00Z"2026-10-032026-10-03T00:00:00(no zone)Closes #34
🤖 Generated with Claude Code