okf

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package okf implements an Open Knowledge Format (OKF) v0.1 conformance validator. It walks a bundle directory and reports structural violations as errors (which break conformance) and recommended-practice gaps as warnings. The logic is pure: it depends only on internal/model and internal/parse and never opens a store, so callers can validate a bundle without a database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendLog

func AppendLog(dirAbs string, kind LogKind, conceptName, link string, when time.Time) error

AppendLog records a concept change in dirAbs/log.md, the reserved per-directory changelog. It maintains a newest-first list of ISO-8601 (YYYY-MM-DD) date sections, each holding "- **<Kind>** [name](link)" bullets.

The file is created with a "# Log" title and NO YAML frontmatter (E3 forbids frontmatter in a reserved file). A new bullet is inserted at the top of today's section; when today's section is absent it is created immediately after the title, above any older sections, so the date headings stay newest-first (W5). Existing content is never reordered. The write is atomic.

func IsReservedOKFFile

func IsReservedOKFFile(base string) bool

IsReservedOKFFile reports whether base is an OKF reserved file (log.md or index.md), which must never get its own log entry.

Types

type Issue

type Issue struct {
	Code     string   `json:"code"`
	Severity Severity `json:"severity"`
	File     string   `json:"file"`
	Message  string   `json:"message"`
}

Issue is a single validation finding. File is bundle-relative with forward-slash separators, or "" for a bundle-level issue.

type LogKind

type LogKind string

LogKind is the leading bold word of a log.md bullet: the lifecycle event a concept entry records.

const (
	// LogCreation marks a concept written for the first time.
	LogCreation LogKind = "Creation"
	// LogUpdate marks an existing concept overwritten in place.
	LogUpdate LogKind = "Update"
	// LogDeprecation marks a concept retired.
	LogDeprecation LogKind = "Deprecation"
)

type Report

type Report struct {
	Bundle   string  `json:"bundle"`
	Files    int     `json:"files"`
	Issues   []Issue `json:"issues"`
	Errors   int     `json:"errors"`
	Warnings int     `json:"warnings"`
}

Report is the outcome of validating a bundle: the issues found and their tallies. A bundle is OKF v0.1 conformant when it has zero errors.

func Validate

func Validate(ctx context.Context, bundle string) (Report, error)

Validate walks bundle and checks OKF v0.1 conformance. It classifies each markdown file as a reserved file (index.md, log.md) or a concept file and applies the rule set, returning a Report. It returns a non-nil error only on a filesystem I/O failure (WalkDir or ReadFile); non-conformance is reported through the Report, not as an error.

func (Report) OK

func (r Report) OK() bool

OK reports whether the bundle is conformant (no errors). Warnings do not break conformance.

type Severity

type Severity int

Severity classifies an Issue as a conformance error or a recommendation.

const (
	// SevError marks a conformance-breaking violation (E-rules).
	SevError Severity = iota
	// SevWarning marks a recommended-practice gap (W-rules).
	SevWarning
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL