Skip to content

fix: accept RFC 3339 datetimes for stale_after, per OKF §5.5 - #44

Merged
akeemjenkins merged 1 commit into
mainfrom
fix/34-stale-after-datetime
Nov 8, 2026
Merged

akeemjenkins merged 1 commit into
mainfrom
fix/34-stale-after-datetime

Conversation

@akeemjenkins

Copy link
Copy Markdown
Contributor

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_after as "an absolute instant," and its own example is a full datetime:

stale_after: 2026-09-23T00:00:00Z   # content is stale on/after this instant

okf validate only accepted a bare YYYY-MM-DD date. It rejected the spec's own example with okf/lifecycle/stale-after-invalid and 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

  • New concept.ParseStaleAfter accepts:
    • an RFC 3339 datetime with a zone, Z or an offset, quoted or unquoted (2026-10-03T00:00:00Z, 2026-10-03T00:00:00+00:00, "2026-10-03T00:00:00Z")
    • a YYYY-MM-DD date, which keeps its current meaning of midnight UTC, so existing bundles are unaffected
  • A datetime with no zone (2026-10-03T00:00:00) is still an error, because it isn't an absolute instant.
  • IsStale compares instants (now >= stale_after), so show and list report stale correctly for datetime values too.
  • Rule descriptions in okf schema and 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, plus IsStale boundary tests for an offset datetime and a quoted datetime
  • internal/validate: each form from the issue is accepted, stale and fresh datetimes warn or don't, and a datetime without a zone is rejected
  • cmd/okf e2e: validate exits 0 on the spec's example, and show returns stale: true and the original stale_after string unchanged

Verification

gofmt -l . && go vet ./... && go test -race ./... && golangci-lint run ./...

All pass locally, with 0 lint issues. I also reran the issue's repro values against the built binary:

stale_after before after
2026-10-03T00:00:00Z error, exit 1 valid (stale warning), exit 0
2026-10-03T00:00:00+00:00 error, exit 1 valid (stale warning), exit 0
"2026-10-03T00:00:00Z" error, exit 1 valid (stale warning), exit 0
2026-10-03 valid valid (unchanged)
2026-10-03T00:00:00 (no zone) error error (unchanged)

Closes #34

🤖 Generated with Claude Code

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
akeemjenkins force-pushed the fix/34-stale-after-datetime branch from 6402093 to beecc60 Compare November 7, 2026 06:35
@akeemjenkins
akeemjenkins merged commit 802abaa into main Nov 8, 2026
6 checks passed
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>
@akeemjenkins
akeemjenkins deleted the fix/34-stale-after-datetime branch November 24, 2026 05:27
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.

validate rejects the spec's own §5.5 example for stale_after (datetime), demands YYYY-MM-DD

1 participant