Documentation
¶
Overview ¶
Package okf is the Open Knowledge Format, publishable without the rest of keepsake.
Index ¶
- Constants
- func ExtractLinks(body, p string) []string
- func Families(c Concept) map[string][]string
- func IsActor(s string) bool
- func IsDecimal(s string) bool
- func PyDumps(v any) (string, error)
- func PyReprString(s string) string
- func Reserved(path string) bool
- func Resolve(target, directory string) (string, bool)
- func Serialize(c Concept) (string, error)
- func Storable(c Concept) error
- func Validate(c Concept) []string
- func ValidateIndex(text string, root bool) []string
- func ValidateLog(text string) []string
- type Concept
- type Map
- type NonFinite
- type Signals
- type YAMLError
Constants ¶
const ( Unverified = "unverified" MachineConfirmed = "machine-confirmed" HumanReviewed = "human-reviewed" )
The §5.3 trust tiers, lowest first.
const ( MaxPath = 1024 MaxBody = 256 * 1024 MaxTitle = 4096 )
Postgres limits in bytes, refused in advance so the agent gets a sentence instead of a driver error.
const AttestedComputation = "Attested Computation"
AttestedComputation is the OKF §10 type whose contract Families checks.
Variables ¶
This section is empty.
Functions ¶
func ExtractLinks ¶
ExtractLinks returns the concept paths body links to, deduplicated in first-seen order. It matches Python's (?<!!)\[[^\]]*\]\(\s*([^)\s]*)(?:\s+[^)]*)?\s*\) in linear time.
func Families ¶ added in v0.7.0
Families returns the OKF v0.2 §5 and §10 rules c breaks, keyed by the top-level frontmatter key at fault.
func IsActor ¶ added in v0.7.0
IsActor reports whether s is an OKF §7 actor: <producer>/<version>, human:<id> or process:<id>.
func IsDecimal ¶
IsDecimal is Python's str.isdecimal() over ASCII: non-empty and every byte a digit.
func PyDumps ¶ added in v0.7.0
PyDumps renders v as Python's default json.dumps: ", " and ": " separators, non-ASCII escaped.
func PyReprString ¶
PyReprString is Python's repr(str): single quotes unless only double quotes avoid escaping.
func Reserved ¶ added in v0.4.0
Reserved reports whether path names index.md or log.md, which OKF reserves in every directory. A backslash counts as a separator, since a Windows export writes `a\index` as a/index.md.
func Serialize ¶
Serialize renders a concept as an OKF document, failing only on a non-finite float.
func ValidateIndex ¶ added in v0.8.0
ValidateIndex returns the OKF §8 rules an index.md breaks. Only the bundle root's MAY hold frontmatter, and only okf_version.
func ValidateLog ¶ added in v0.8.0
ValidateLog returns the OKF §9 rules a log.md breaks: each date heading is YYYY-MM-DD, newest first.
Types ¶
type Concept ¶
type Concept struct {
Path string
Type string
Title string
Description string
Body string
Frontmatter *Map
Links []string
Version int
}
Concept is a single knowledge unit: a path, its frontmatter and its markdown body.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map is an insertion-ordered JSON object of string, bool, nil, json.Number, int, NonFinite, []any or *Map.
func (*Map) MarshalJSON ¶
func (*Map) UnmarshalJSON ¶
UnmarshalJSON walks tokens so that key order survives; a map[string]any would lose it.
type NonFinite ¶
type NonFinite string
NonFinite is a YAML .inf, -.inf or .nan. JSON cannot hold it, so it refuses to marshal.