gunk-dev/the-valley

node.cue

source933f202462e5main's published tip history
3.2 KiB
1// The structured layer of a knowledge-graph node: what a node's YAML
2// frontmatter must say. The prose body is not described here — it is prose,
3// and the writing conventions that govern it (.the-valley/README.md) are
4// for a reader, not a validator.
5//
6// The convention this file makes checkable is documented in
7// .the-valley/README.md: one file per node, `<id>-<slug>.md`, in the
8// directory its type names. The type table below carries the directory
9// names so the linter and the schema agree on them by construction.
10//
11// Like the host and event schemas, this file is deliberately not Nix. The
12// knowledge lint in this repo is one consumer; any other tool that reads a
13// graph reads the same file.
14//
15// Validate one node's frontmatter:
16// cue vet -c -d '#Node' schema/node.cue <frontmatter>.yaml
17package knowledge
18
19// #Node is one node's frontmatter. The common fields are stated once and
20// the per-type differences follow, because a node's type decides both its
21// id prefix and the states it can be in.
22#Node: {
23 // The node's type. It fixes the id prefix, the status enum, and the
24 // directory the file lives in.
25 type: "outcome" | "bug" | "idea" | "decision"
26
27 // The node's own id, which is also the leading token of its filename.
28 id: #Id
29
30 // The node's state. The values differ per type; see below.
31 status: string
32
33 // A one-line human title. Free prose, but never empty — the title is
34 // how a node reads in a listing.
35 title: string & !=""
36
37 // The date the node was created, as YYYY-MM-DD.
38 created: #Date
39
40 // Where the content came from: a date and a venue, never a person
41 // (.the-valley/README.md, disembodied voice).
42 source?: string
43
44 if type == "outcome" {
45 id: =~"^oc-"
46 status: "open" | "in-progress" | "done" | "abandoned"
47
48 // The one typed edge that exists today: the node ids this
49 // outcome waits on. Any node type may block an outcome. Only
50 // outcomes carry it, so the field is absent — and rejected — on
51 // every other type.
52 blocked_by: [...#Id]
53 }
54
55 if type == "bug" {
56 id: =~"^bd-"
57 status: "open" | "closed"
58 }
59
60 if type == "idea" {
61 id: =~"^ida-"
62 status: "raw" | "exploring" | "adopted" | "superseded"
63 }
64
65 if type == "decision" {
66 id: =~"^dcr-"
67 status: "proposed" | "decided" | "superseded"
68 }
69}
70
71// A node id: a type prefix and a short hash of the slug. The hash is not
72// re-derived here — the convention names an example algorithm rather than
73// pinning one, so only the shape is checkable.
74#Id: =~"^(oc|bd|ida|dcr)-[0-9a-f]{7}$"
75
76#Date: =~"^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
77
78// #Graph is a whole graph: every node's frontmatter, keyed by the node
79// file's path. The key is the path rather than the id so that a vet failure
80// names the file a reader has to open. The lint builds one document in this
81// shape and vets it in a single pass, which is why one run reports every
82// node's errors instead of stopping at the first bad file.
83#Graph: [string]: #Node
84
85// The directory each type's nodes live in, relative to the graph root. The
86// linter reads this table rather than carrying its own copy, so adding a
87// node type is an edit to this file alone.
88#Directories: {
89 outcome: "outcomes"
90 bug: "bugs"
91 idea: "ideas"
92 decision: "decisions"
93}