Documentation
¶
Overview ¶
Package okf checks OKF v0.2 bundles.
The spec is deliberately permissive: only three rules are conformance failures. That split is why findings carry a severity — everything beyond §11 is advice and must never fail a build. A repo whose graph carries an invariant the spec cannot express passes it to CheckBundle as a Rule.
Index ¶
- func Main(args []string, w io.Writer, rules ...Rule) int
- func MainWith(args []string, w io.Writer, rules Rules) int
- func Parse(text string) (map[string]any, string, error)
- func ParseTimestamp(raw any) (time.Time, error)
- func Reserved(rel string) bool
- type Bundle
- type BundleRule
- type Doc
- type Finding
- type Rule
- type Rules
- type Severity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Main ¶
Main runs the `okf check` CLI and returns the process exit code. A repo with its own rules wires them in here rather than forking the command. `sweep` is dispatched by cmd/okf instead: it runs the fleet rules, which import this package, so the engine cannot reach them.
func Parse ¶
Parse splits an OKF document into its YAML frontmatter and body. A document with no frontmatter block yields a nil map and no error; whether that is a violation depends on the filename, which Parse does not know.
func ParseTimestamp ¶ added in v0.6.0
ParseTimestamp reads an OKF timestamp. §5 requires an ISO 8601 datetime with an explicit UTC offset, and YAML hands those over already decoded; the date and quoted forms are still parsed here because grading how a value was spelled is a producer rule, not the engine's job.
Types ¶
type Bundle ¶ added in v0.2.0
Bundle is every parsed document in one root, index.md and log.md included.
func Load ¶ added in v0.6.0
Load parses every .md under a root and reports nothing. A consumer that renders or indexes a bundle wants the documents without an opinion attached; a document whose frontmatter will not parse is skipped, because CheckBundle is where that is a finding.
func (Bundle) Concepts ¶ added in v0.2.0
Concepts returns the documents that are not index.md or log.md.
func (Bundle) Find ¶ added in v0.2.0
Find returns the document at this bundle-relative path, or false.
func (Bundle) Links ¶ added in v0.6.0
Links returns d's bundle-local link targets that resolve to a document in b, in body order, deduped, self-links dropped. This is the same resolution CheckBundle uses to find dangling links and orphans — including the "/"-rooted spelling, which a consumer that drops it renders as no edge at all.
type BundleRule ¶ added in v0.2.0
BundleRule is a caller-supplied check over a whole bundle. A Rule runs per concept and so cannot see the reserved files, the link graph, or any pair of concepts at once.
type Doc ¶
type Doc struct {
Root string // bundle root, as given to CheckBundle
Rel string // bundle-relative path, slash-separated
FM map[string]any // frontmatter
Body string
// FMText is the frontmatter as written. A rule needs it to grade how a
// value was spelled: YAML decodes `2026-12-31` and `2026-12-31T00:00:00Z`
// to the same time.Time, so FM alone cannot tell an offset was omitted.
FMText string
}
Doc is one parsed concept, handed to a Rule.
type Finding ¶
func CheckAgainst ¶ added in v0.6.0
CheckAgainst reports what root lost relative to the same bundle at a git ref. A concept absent from the ref is new and cannot have shrunk.
func CheckBundle ¶
CheckBundle walks a bundle root and reports conformance errors (§11) and advisory warnings, plus whatever the caller's rules report.
func CheckBundleWith ¶ added in v0.2.0
CheckBundleWith is CheckBundle with bundle-wide rules as well. Their findings are appended after the per-concept ones and sorted among themselves, so adding one cannot move a line the stock check already prints.
type Rule ¶
Rule is a caller-supplied check over one concept. It runs on concepts only, never on the reserved index.md and log.md. A Finding with an empty Path is stamped with the concept's.
type Rules ¶ added in v0.2.0
type Rules struct {
Doc []Rule
Bundle []BundleRule
}
Rules is what a caller passes to CheckBundleWith and MainWith.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
okf
command
Command okf checks OKF bundles.
|
Command okf checks OKF bundles. |
|
okfrules
command
Command okfrules is okf's check with this fleet's shared rules wired in, for the repos that are not Go and cannot build one of their own.
|
Command okfrules is okf's check with this fleet's shared rules wired in, for the repos that are not Go and cannot build one of their own. |
|
Package rules holds the invariants every bundle in this fleet keeps but the OKF spec deliberately does not: §11 forbids rejecting a bundle over an unknown type, a missing key or a broken link, so a local vocabulary is only a rule while something asserts it.
|
Package rules holds the invariants every bundle in this fleet keeps but the OKF spec deliberately does not: §11 forbids rejecting a bundle over an unknown type, a missing key or a broken link, so a local vocabulary is only a rule while something asserts it. |
|
Package verify re-confirms what a concept points outward at, and records the result as §5.3's machine-confirmed tier.
|
Package verify re-confirms what a concept points outward at, and records the result as §5.3's machine-confirmed tier. |
|
Package viz renders an OKF bundle as one self-contained HTML page: the concept graph, each concept's frontmatter and body, and who cites whom.
|
Package viz renders an OKF bundle as one self-contained HTML page: the concept graph, each concept's frontmatter and body, and who cites whom. |