Repository navigation
Conversation
OKF v0.2 §5.5 defines stale_after as an absolute instant and shows a datetime example, but validate rejected anything but YYYY-MM-DD and the stale check ignored datetimes. Parse both forms through one helper, concept.ParseStaleAfter, used by IsStale and validateV02. A datetime is stale from that instant on; a date keeps its behavior (stale from 00:00 UTC of that day). Fixes okfcli#34
This branch has not been deployed
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.
Problem
OKF v0.2 §5.5 defines
stale_afteras "an absolute instant" and says a concept is stale whennow >= stale_after. Its example is a datetime:okf validaterejects that form withokf/lifecycle/stale-after-invalid("must be an absolute YYYY-MM-DD date"), andFrontmatter.IsStaletreats it as unparseable, sookf showreportsstale: falsefor a datetime that has already passed. §11 says a validator must accept every conformant bundle.Change
concept.ParseStaleAfteraccepts an RFC 3339 datetime with any offset (through the existingParseDatetime) or aYYYY-MM-DDdate.Frontmatter.IsStaleandvalidateV02both use it, so validation and the stale check cannot disagree.okf/lifecycle/stale-after-invalidas an error. The message and the rule description now name both accepted forms:'stale_after' must be an RFC 3339 datetime or a YYYY-MM-DD date, got "soon" (OKF §5.5).okf/lifecycle/stalewarning readsnow >= stale_afterinstead oftoday >= stale_after. Rule IDs, severities, commands and JSON shape are unchanged.Tests
internal/concept: table-drivenTestIsStale_DateAndDatetimeFormscovers dates in the past, in the future and today; datetimes in the past, in the future, exactly at now and one second after; quoted datetimes; non-UTC offsets on both sides of now; and invalid values (soon,2026-13-01, a datetime without an offset).internal/validate:TestValidate_DatetimeStaleAfterchecks that datetime values raise nookf/lifecycle/stale-after-invalidfinding, raise theokf/lifecycle/stalewarning when past and raise nothing when in the future.TestValidate_MalformedStaleAfterchecks that the message names both forms.All pass locally on go1.27.0. Against a bundle with
stale_after: 2026-09-01T00:00:00Z(run on 2026-10-06), the built binary reports only the stale warning fromvalidate, andokf show <bundle> <id> | jq .concept.staleprintstrue. With a datetime one year ahead it printsfalse. v0.5.0 reportsstale-after-invalidfor the same bundle.Fixes #34
Drafted with Claude Code and tested locally.