@ontology-kit/okb 0.1.0 → 0.3.0-alpha.210

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +1 -1
  2. package/dist/check.d.ts +43 -0
  3. package/dist/check.js +83 -0
  4. package/dist/checks.d.ts +1 -1
  5. package/dist/checks.js +4 -4
  6. package/dist/cli.js +11 -705
  7. package/dist/clidocs.d.ts +0 -2
  8. package/dist/clidocs.js +5 -27
  9. package/dist/clock.js +1 -1
  10. package/dist/command-table.d.ts +134 -0
  11. package/dist/command-table.js +82 -0
  12. package/dist/commands/documents.d.ts +3 -0
  13. package/dist/commands/documents.js +250 -0
  14. package/dist/commands/getting-started.d.ts +3 -0
  15. package/dist/commands/getting-started.js +135 -0
  16. package/dist/commands/housekeeping.d.ts +3 -0
  17. package/dist/commands/housekeeping.js +203 -0
  18. package/dist/commands/modeling.d.ts +3 -0
  19. package/dist/commands/modeling.js +433 -0
  20. package/dist/commands/planning.d.ts +3 -0
  21. package/dist/commands/planning.js +212 -0
  22. package/dist/commands/reviewing.d.ts +3 -0
  23. package/dist/commands/reviewing.js +177 -0
  24. package/dist/commands/skills.d.ts +3 -0
  25. package/dist/commands/skills.js +52 -0
  26. package/dist/commands.d.ts +10 -22
  27. package/dist/commands.js +15 -622
  28. package/dist/diff.d.ts +85 -0
  29. package/dist/diff.js +323 -0
  30. package/dist/export.d.ts +1 -1
  31. package/dist/export.js +1 -1
  32. package/dist/families.d.ts +1 -1
  33. package/dist/families.js +1 -1
  34. package/dist/help.d.ts +11 -2
  35. package/dist/help.js +51 -57
  36. package/dist/kbdocs.d.ts +18 -0
  37. package/dist/kbdocs.js +393 -0
  38. package/dist/metakb.d.ts +1 -1
  39. package/dist/metakb.js +1 -1
  40. package/dist/naming.d.ts +2 -2
  41. package/dist/naming.js +2 -2
  42. package/dist/ontology-ref.d.ts +20 -0
  43. package/dist/ontology-ref.js +108 -0
  44. package/dist/ops/admin.d.ts +1 -1
  45. package/dist/ops/admin.js +24 -7
  46. package/dist/ops/classes.d.ts +1 -1
  47. package/dist/ops/classes.js +13 -5
  48. package/dist/ops/instances.d.ts +2 -1
  49. package/dist/ops/instances.js +7 -1
  50. package/dist/ops/links.d.ts +1 -1
  51. package/dist/ops/links.js +1 -1
  52. package/dist/ops/naming.d.ts +1 -1
  53. package/dist/ops/naming.js +3 -1
  54. package/dist/ops/scope.d.ts +5 -1
  55. package/dist/ops/scope.js +19 -1
  56. package/dist/ops/slots.d.ts +1 -1
  57. package/dist/ops/slots.js +15 -2
  58. package/dist/ops/values.d.ts +1 -1
  59. package/dist/ops/values.js +5 -1
  60. package/dist/provenance.d.ts +4 -2
  61. package/dist/provenance.js +58 -17
  62. package/dist/release.d.ts +52 -0
  63. package/dist/release.js +337 -0
  64. package/dist/render.d.ts +64 -1
  65. package/dist/render.js +240 -3
  66. package/dist/resync.d.ts +98 -0
  67. package/dist/resync.js +234 -0
  68. package/dist/review.d.ts +1 -1
  69. package/dist/review.js +1 -1
  70. package/dist/reviewdocs.d.ts +42 -0
  71. package/dist/reviewdocs.js +263 -0
  72. package/dist/runner.d.ts +3 -0
  73. package/dist/runner.js +79 -0
  74. package/dist/skills.js +1 -1
  75. package/dist/status.d.ts +1 -1
  76. package/dist/status.js +1 -1
  77. package/dist/types.d.ts +1 -1
  78. package/dist/types.js +1 -1
  79. package/dist/verifynote.d.ts +18 -0
  80. package/dist/verifynote.js +92 -0
  81. package/dist/workflows.d.ts +256 -0
  82. package/dist/workflows.js +223 -0
  83. package/meta-kb/data/manifest.json +2 -2
  84. package/meta-kb/data/nodes.json +8 -8
  85. package/package.json +9 -4
  86. package/schema/edge.schema.json +68 -0
  87. package/schema/edges.schema.json +9 -0
  88. package/schema/node.schema.json +893 -0
  89. package/schema/nodes.schema.json +9 -0
  90. package/schema/okb.schema.json +41 -0
  91. package/skills/build-domain-kb-from-docs/SKILL.md +20 -2
  92. package/skills/ontology-coach/SKILL.md +6 -2
  93. package/skills/ontology-maintainer/SKILL.md +152 -0
  94. package/skills/ontology-review/SKILL.md +3 -1
  95. package/skills/ontology-signoff/SKILL.md +182 -0
  96. package/templates/okb-check.yml +132 -0
  97. package/templates/pull_request_template.md +16 -0
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://ontology-kit.dev/schema/okb-lpg-3/nodes.schema.json",
4
+ "title": "An older nodes.json (okb-lpg/3 folders written before the one-per-line layout): an array of nodes",
5
+ "type": "array",
6
+ "items": {
7
+ "$ref": "node.schema.json"
8
+ }
9
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://ontology-kit.dev/schema/okb-lpg-3/okb.schema.json",
4
+ "title": "An okb manifest (okb-lpg/3): okb.json",
5
+ "type": "object",
6
+ "required": [
7
+ "format",
8
+ "currentStep"
9
+ ],
10
+ "properties": {
11
+ "$schema": {
12
+ "type": "string",
13
+ "description": "Optional pointer for editors; okb ignores it."
14
+ },
15
+ "format": {
16
+ "const": "okb-lpg/3"
17
+ },
18
+ "currentStep": {
19
+ "type": "integer",
20
+ "minimum": 1,
21
+ "maximum": 8
22
+ },
23
+ "name": {
24
+ "type": "string"
25
+ },
26
+ "created": {
27
+ "type": "string"
28
+ },
29
+ "metaKbVersion": {
30
+ "type": "string"
31
+ },
32
+ "version": {
33
+ "type": "string",
34
+ "description": "The knowledge base's release version, set by okb release."
35
+ },
36
+ "okbVersion": {
37
+ "type": "string",
38
+ "description": "The okb version the KB was built with; okb check warns when the installed okb is older."
39
+ }
40
+ }
41
+ }
@@ -5,11 +5,11 @@ description: Use when extracting design-system (or other) documentation, usually
5
5
 
6
6
  # Build a domain KB from docs
7
7
 
8
- **Version 2.4.2.** It should match the meta-KB version that `okb version` prints.
8
+ **Version 2.6.3.** It should match the meta-KB version that `okb version` prints.
9
9
 
10
10
  Turns a documentation source (usually a markdown component doc, sometimes a PDF) into an okb ontology: Class, Slot and Instance nodes plus domain Rule nodes, each tied to a verbatim quote with its heading path and line numbers. It follows the meta-KB's rules in `packages/okb/meta-kb/` and the pipeline in `docs/EXTRACTION-PIPELINE.md` (both in the ontology-kit repository, usually `~/Projects/ontology-kit`).
11
11
 
12
- The point of this skill is to be deterministic where possible and to stop for human review everywhere else. Never auto-merge a finding this pipeline can't fully verify itself. Everything goes through okb commands; don't hand-edit nodes.json/edges.json.
12
+ The point of this skill is to be deterministic where possible and to stop for human review everywhere else. Never auto-merge a finding this pipeline can't fully verify itself. Everything goes through okb commands; don't hand-edit nodes.jsonl/edges.jsonl.
13
13
 
14
14
  ## Step 0: Set up
15
15
 
@@ -63,6 +63,8 @@ Record each result:
63
63
  - `okb verify <node> --status OVERREACH --corrected "<narrower statement>"`: the original is kept in `_originalDraft`, and the node stays blocked until a person runs `okb verify <node> --approve`.
64
64
  - `okb verify <node> --status UNSUPPORTED`, then `okb remove <node>`. It never ships.
65
65
 
66
+ **Say why, briefly.** Add `--note "..."` to every OVERREACH and UNSUPPORTED result, and to an approval that rests on a conversation. For OVERREACH, okb prints a suggested note and the exact command that stores it (a changed modality, number or few words); check it says what you meant, then pass it. For UNSUPPORTED, name the part of the statement the quote doesn't support. A note is one sentence that names the word or number, never restates the verdict ("narrowed MUST to SHOULD: the quote says \"should\"", not "overreach"). Add `--ref <url>` (a PR comment, issue or review thread, `http` or `https`) when the reasoning lives in a conversation. Never put a name, email or date in either: git and the PR keep who and when. A SUPPORTED result needs no note.
67
+
66
68
  ## Step 4: Spot-check sources
67
69
 
68
70
  For a random 10% of quotes (minimum 5), open their `sourceLink` (from `okb quote list --json`) and confirm the quote comes from the section it's about. This catches quotes taken from the wrong component's section, which Step 3 can't see.
@@ -76,6 +78,22 @@ okb drift <this-ontology> <other-ontologies-from-the-same-doc-set> # optional,
76
78
 
77
79
  Errors block the output, including `prov-verified` (unverified, UNSUPPORTED, or corrections not yet approved), `prov-cites-quote` and `prov-quote-current` (a quote no longer in the file). Warnings and hints aren't blocking, but they must be carried into the review diff, not silently dropped. When the source doc changes later, `okb source refresh <source>` re-locates every quote and reports the ones that are gone.
78
80
 
81
+ ## When the docs change
82
+
83
+ Run this path instead of starting over when a source file you already extracted from has changed. Start from the worklist:
84
+
85
+ ```bash
86
+ okb source refresh --all --json
87
+ ```
88
+
89
+ It re-locates every quote in every source (updating the lines and links of quotes that only moved) and prints one report: `gone` (quotes no longer in the text, each with `citedBy`, the rules and facts that cite it), `moved`, and `worklist`, the new, changed and removed blocks since the KB last recorded the document. It exits with code 1 when a quote is gone. Add `--dry-run` to write nothing. If a source has no baseline yet (a KB from before hashes), the report says so; there's no worklist for it until you run `okb source refresh --all --record` once.
90
+
91
+ 1. **Gone quotes first.** For each `gone` entry, read the current text near `was.locator`. If the passage was reworded, re-extract it (Step 1, `okb quote add`), re-cite the nodes in `citedBy` with `okb cite`, and verify them again (Step 3). Once every node in `citedBy` has its new citation, remove the old quote with `okb remove <old quote id>`; otherwise it stays in the KB and every refresh and `okb check` reports it as gone again. If the passage no longer exists, the nodes that cite it are no longer supported: ask the user whether to remove or rewrite them, and never keep a citation to text that isn't there.
92
+ 2. **Then the worklist.** `changed` blocks have `oldPreview` and `preview`: check whether a quote or a fact drawn from the old text is now wrong. `new` blocks are not extracted yet: do Steps 1 to 3 for the ones that state facts or rules. `removed` blocks usually show up as gone quotes already; if nothing cites them, nothing is needed. Skip blocks that aren't relevant, and say so in the review diff.
93
+ 3. **Run Step 5** (`okb validate --all`), then record the new baseline with `okb source refresh --all --record` so the next run lists only what changes after this one. Don't record before the worklist is handled: the baseline is how the next refresh knows what you've seen.
94
+
95
+ Each worklist item has a stable `id` (`<source id>:<first 12 hex of the block hash>`) so a later extraction ledger can track an outcome per block. `okb check` fails on gone quotes too, so a docs change can't merge with stale citations.
96
+
79
97
  ## Output
80
98
 
81
99
  - The updated ontology folder.
@@ -5,7 +5,7 @@ description: Coach someone who has never built an ontology or knowledge base thr
5
5
 
6
6
  # Ontology coach
7
7
 
8
- **Version 2.4.2.** It should match the meta-KB version that `okb version` prints.
8
+ **Version 2.6.3.** It should match the meta-KB version that `okb version` prints.
9
9
 
10
10
  You are coaching a beginner through building an ontology with the **ontology-kit** toolkit. They have probably never built one. Your job is to make each decision small, explain each idea just before it's needed, do the typing for them, and leave behind an ontology that passes `okb validate` plus a record of _why_ it looks the way it does.
11
11
 
@@ -81,6 +81,10 @@ Pick one competency question and add just enough instances to answer it end to e
81
81
  5. If the data is headed for a graph database, show them `okb export --format cypher --out <name>.cypher` (instances become nodes labeled with their class chain).
82
82
  6. Summarize what they built, what's deliberately left out, and what a v2 might add.
83
83
 
84
+ ## When a quote backs a rule
85
+
86
+ If the user builds from a document and `okb verify` marks an item OVERREACH or UNSUPPORTED, help them say why in a note: `okb verify <node> --status OVERREACH --corrected "..." --note "..."`. okb prints a suggested note after OVERREACH; they can store it as is. Use UNSUPPORTED, with no `--corrected`, when the quote backs none of the claim: `okb verify <node> --status UNSUPPORTED --note "..."` (say which part the quote doesn't support). When the corrected statement of a rule uses a different MUST, SHOULD or MAY from the original, okb changes the rule's stored strength to match only when the corrected statement names exactly one of MUST, MUST NOT, SHOULD, SHOULD NOT or MAY, and it differs from the stored one; with no keyword, or two different ones, it leaves the strength as it was, so check it by hand before approving; tell the person who approves it which strength the rule is stored with, and where the original wording is (`_originalDraft`). A note is one sentence that names the word or number, never restates the verdict ("narrowed MUST to SHOULD: the quote says \"should\"", not "overreach"). Add `--ref <url>` (a PR comment, issue or review thread, `http` or `https`) when the reasoning lives in a conversation. Never put a name, email or date in either: git and the PR keep who and when.
87
+
84
88
  ## Widening a question
85
89
 
86
90
  A question like "When should I use a PrimaryButton?" is one example of a type. Answering only that one passes the competency test without being very useful. Once a question is answered (Step 7, or linked in Step 8), take a moment to widen it. Do this once per question, never all at once, and never before the model exists.
@@ -94,7 +98,7 @@ A question like "When should I use a PrimaryButton?" is one example of a type. A
94
98
 
95
99
  - Don't skip scope or competency questions. Every later decision leans on them.
96
100
  - Don't make them list every possible question up front. A few examples are enough; widen each one once it's answered.
97
- - Don't edit nodes.json/edges.json by hand. Use okb, which enforces naming, stores each relationship once, fills in defaults, and keeps ids stable.
101
+ - Don't edit nodes.jsonl/edges.jsonl by hand. Use okb, which enforces naming, stores each relationship once, fills in defaults, and keeps ids stable.
98
102
  - Don't add classes, slots or instances the user didn't agree to. Suggest them and let the user decide.
99
103
  - Don't dump the glossary. Explain one idea at the moment it's needed.
100
104
  - Don't `--force` a name or waive a warning without saying why and recording a decision.
@@ -0,0 +1,152 @@
1
+ ---
2
+ name: ontology-maintainer
3
+ description: Use when someone looks after an existing okb knowledge base that is already in git and a routine change comes up, such as "the docs changed", "update the KB", "CI says a quote is missing", a reviewer asks for a fix, "add this rule or source", "rename this class", "write the PR description", "cut a release". It picks the flow, runs the okb commands in order, stops where a person must decide or approve, and ends with a pull request a reviewer can read. It does not do a first build (use ontology-coach), the extraction itself (build-domain-kb-from-docs) or modeling judgment (ontology-review), and it never approves a correction.
4
+ ---
5
+
6
+ # Maintain an existing KB
7
+
8
+ **Version 2.6.3.** It should match the meta-KB version that `okb version` prints.
9
+
10
+ For the person (or the agent working for them) who looks after a KB that was built once and is now kept in git with `okb check` in CI. It works out what is open, does the routine update, and finishes with the pull request text. It adds no commands of its own: everything goes through `okb`. The same sequences, with their output, are in the maintainer guide (<https://ontology-kit.dev/build/maintaining/>) and the CI guide (<https://ontology-kit.dev/build/check-in-ci/>); read those when a step here is not enough.
11
+
12
+ ## Hard rules
13
+
14
+ - **Never run `okb verify <id> --approve`.** A person other than the author does that, after reading the quote and the corrected statement. When one is due, say which items and give them the command to run.
15
+ - **Never edit `nodes.jsonl` or `edges.jsonl` by hand.** Use `okb` commands, which keep ids, links and provenance consistent.
16
+ - **Never keep a citation to text that isn't in the source.** A rule or fact whose quote is gone is rewritten or removed, with the user's say-so.
17
+ - **Never write an uncited rule.** A rule comes from a quote. If there is no quote, say so and stop.
18
+ - **Say what was skipped.** Every worklist block you didn't extract, every item still waiting for a person, and every check you couldn't run goes in the PR text, with the reason.
19
+ - Don't fix more than was asked. Each change in the PR should be one `okb diff` can explain.
20
+
21
+ ## Step 0: Set up and triage
22
+
23
+ 1. Find okb with `okb version`. Compare the meta-KB version it prints with this skill's version. If they differ, tell the user the skill or okb is out of date and offer `okb skills status`, then `okb skills install`, before going on.
24
+ 2. Make sure you're on a branch cut from the KB's main branch (`git fetch origin`, `git branch --show-current`, `git status --short`). Don't work on `main`.
25
+ 3. Record what is already failing, before you touch anything, so the PR neither inherits nor hides it:
26
+
27
+ ```bash
28
+ okb status
29
+ okb check
30
+ ```
31
+
32
+ 4. Pick the flow from the trigger. If the trigger is vague ("make the KB current"), start with Flow 1: let `okb check` and the refresh report choose. Say which flow you chose and why.
33
+
34
+ | Trigger | Flow |
35
+ | ------------------------------------------------------- | ---- |
36
+ | A source document changed, or CI shows missing quotes | 1 |
37
+ | CI or a reviewer reported one specific problem | 2 |
38
+ | A new source file, or a rule someone stated | 3 |
39
+ | A class, slot or instance needs a better name or a move | 4 |
40
+ | The change is done and needs a pull request description | 5 |
41
+ | `main` has the changes and the team wants a numbered KB | 6 |
42
+
43
+ ## Flow 1: The source documents changed
44
+
45
+ 1. Get the worklist. `--dry-run` writes nothing, so use it first if you're unsure:
46
+
47
+ ```bash
48
+ okb source refresh --all --json --dry-run
49
+ okb source refresh --all --json
50
+ ```
51
+
52
+ It reports `gone` (quotes no longer in the text, each with `citedBy`, the rules and facts that cite it), `moved` (updated for you) and `worklist` (new, changed and removed blocks). It exits with code 1 when a quote is gone. A source with no baseline yet has no worklist; run `okb source refresh --all --record` once for it, then carry on.
53
+
54
+ 2. **Gone quotes first.** For each `gone` entry, `quote` is the old quote's id, `text` is what it said, and `citedBy` lists every node that cites it. Read the current text near `was.locator`.
55
+ - Passage reworded: quote the new text, attach it to every node in `citedBy` (`--cites` takes one node; `okb cite` does the rest), then remove the old quote. `okb quote add` prints the new quote id. See "A quote is wrong or missing" in the maintainer guide.
56
+ - Passage no longer exists: **stop and ask the user** whether to rewrite or remove each rule and fact in `citedBy`. Never keep the citation.
57
+
58
+ ```bash
59
+ okb quote add <source id> "<the new text, word for word>" --cites <first node in citedBy>
60
+ okb cite <another node in citedBy> <new quote id>
61
+ okb remove <old quote id>
62
+ ```
63
+
64
+ 3. **Then the worklist.** A `changed` block that holds a gone quote has had that quote handled in step 2; don't do the quote twice, but still read the rest of the block, since it can change something else. For every other `changed` block, compare `oldPreview` with `preview`: is a quote or fact drawn from the old text now wrong? For each `new` block that states a fact or a rule, hand off to **build-domain-kb-from-docs** (Steps 1 to 3: quote, draft, one claim per quote). `removed` blocks usually appear as gone quotes already. Skip blocks that state nothing the KB needs, and keep a list of what you skipped and why.
65
+ 4. **Verify what changed.** `okb check` passes as soon as a citation points at text that exists; it can't tell that the new wording means something else. Every node you re-cited, and every new node, needs a fresh, separate verification pass (build-domain-kb-from-docs, Step 3), even if `okb check` is already green. Record each result with `okb verify <node> --status SUPPORTED`, or `--status OVERREACH --corrected "..." --note "..."`. Add a note to every OVERREACH and UNSUPPORTED result: It is one sentence that names the word or number, never restates the verdict ("narrowed MUST to SHOULD: the quote says \"should\"", not "overreach"). Add `--ref <url>` (a PR comment, issue or review thread, `http` or `https`) when the reasoning lives in a conversation. Never put a name, email or date in either: git and the PR keep who and when. okb prints a suggested note after OVERREACH; use it when it is right. **Stop for a person** on every OVERREACH item: tell them to read the quote and the corrected statement, then run `okb verify <node> --approve`. Do not run it.
66
+ 5. Record the new baseline only after the worklist is handled, so the next refresh lists only what changes after this one:
67
+
68
+ ```bash
69
+ okb source refresh --all --record
70
+ ```
71
+
72
+ 6. Finish:
73
+
74
+ ```bash
75
+ okb validate --all
76
+ okb check
77
+ okb diff main
78
+ ```
79
+
80
+ Done when `okb check` says "Safe to merge" (or fails only on items waiting for a person, which you list), and `okb diff main` shows only the intended changes. Then Flow 5.
81
+
82
+ ## Flow 2: A reviewer or CI asked for a fix
83
+
84
+ 1. Read the failing line. `okb check` names the command to run for each failure. If it came as a comment, run `okb check` yourself to see the same failure.
85
+ 2. Fix that one thing and nothing else:
86
+ - A wrong or missing quote: `okb quote add`, `okb cite`, `okb remove` (see Flow 1, step 2). Then every node you re-cited needs the fresh verification pass of Flow 1, step 4, even though `okb check` is green: the new quote can support different wording.
87
+ - A rule that claims more than its quote: `okb verify <node> --status OVERREACH --corrected "<narrower statement>"`.
88
+ - A validation error: `okb explain <rule-id>` says what the rule means and how to fix it.
89
+ - A modeling question ("is this really a kind of that?"): hand off to **ontology-review**.
90
+ 3. Check that the fix held and the PR still changes only what it meant to:
91
+
92
+ ```bash
93
+ okb check
94
+ okb diff main
95
+ ```
96
+
97
+ **Stop for a person** on any `--approve`, and on any fix that changes what a rule claims. Say what the rule said before and after.
98
+
99
+ ## Flow 3: Add a rule or a source
100
+
101
+ 1. A new source file:
102
+
103
+ ```bash
104
+ okb source add <path/to/doc.md> --repo-url <GitHub URL of the file>
105
+ okb source outline <source id> --quotable
106
+ ```
107
+
108
+ Then hand off to **build-domain-kb-from-docs** for extraction and verification. Report any document problems `okb source add` prints.
109
+
110
+ 2. A rule someone stated: it still needs a quote from a source. Find the passage with `okb source outline <source id> --quotable` and quote it with `okb quote add`. If no source says it, **say so and stop**. Offer two ways forward: add the source that states it, or have the owner write a rule that cites their own file (build-domain-kb-from-docs explains `--authored`). Don't write an uncited rule.
111
+ 3. `okb check`, then Flow 5. A new rule is unverified until someone verifies it, so `okb check` fails until then; list the items.
112
+
113
+ ## Flow 4: Rename or restructure
114
+
115
+ 1. Rename with `okb rename`, never remove and add (the id would change and everything that pointed to it would lose the link):
116
+
117
+ ```bash
118
+ okb rename <old name> <new name>
119
+ okb diff main
120
+ ```
121
+
122
+ `okb diff` must show a rename, not a removal plus an addition.
123
+
124
+ 2. A restructure (move a subclass, change a slot's range): hand the modeling question to **ontology-review** first. After the user decides, apply it with `okb class set` or `okb slot set` (see `okb class set` and `okb slot set` in the command reference, `okb help`).
125
+ 3. `okb check`, then Flow 5. Say in the PR that renaming a relationship changes its edge type (`:MAKER` becomes `:PRODUCER`), which breaks queries that use the old one.
126
+
127
+ ## Flow 5: Hand the pull request to a reviewer
128
+
129
+ 1. `okb diff main` (Markdown). A reviewer reads this, not the JSON lines.
130
+ 2. Fill the PR checklist (`templates/pull_request_template.md` in the okb package; the maintainer guide shows it). It needs: what changed in the knowledge, the `okb check` result, which items need a person's approval, which sources were refreshed and which worklist blocks were skipped, with reasons.
131
+ 3. Name the next human step ("`okb verify rule.x --approve` for the two corrected rules"). Don't claim the PR is approved or ready beyond what `okb check` says.
132
+
133
+ ## Flow 6: Cut a release
134
+
135
+ 1. The human decides the version number. Don't release a KB with failing checks or unapproved items.
136
+ 2. From the main branch, after the pull requests you want have merged:
137
+
138
+ ```bash
139
+ okb check
140
+ okb release <version>
141
+ okb release verify
142
+ ```
143
+
144
+ 3. Commit what it wrote, and tag the commit only if asked. See "Cut a release" in the maintainer guide.
145
+
146
+ ## What this skill doesn't do
147
+
148
+ - A first build or a blank page: use **ontology-coach**.
149
+ - Extraction and independent verification: **build-domain-kb-from-docs**. This skill decides when to call it and what to skip.
150
+ - Whether the model is sound: **ontology-review**.
151
+ - Reviewing a pull request someone else wrote: this skill prepares the PR for a reviewer, not the review.
152
+ - It can't approve its own work. Every `--approve` is a person's.
@@ -5,7 +5,7 @@ description: Review an ontology built with ontology-kit (okb) against the Ontolo
5
5
 
6
6
  # Ontology review
7
7
 
8
- **Version 2.4.2.** It should match the meta-KB version that `okb version` prints.
8
+ **Version 2.6.3.** It should match the meta-KB version that `okb version` prints.
9
9
 
10
10
  Give an okb ontology a second opinion. `okb validate` already covers the mechanical rules. The value of this review is in the rules **only a person can judge** (is this really a kind-of? are these siblings equally general? should this class be a slot value?) and in **double-checking heuristic findings**, which can be false positives. The reader may be a beginner, so every finding must be understandable without prior ontology knowledge.
11
11
 
@@ -40,6 +40,8 @@ Work through each judgment rule from `okb review` against the actual ontology. U
40
40
 
41
41
  Then double-check every **heuristic** finding from `okb validate`. Say whether it's a real problem or a false positive (for example "Sauternes" isn't a plural). A false positive should be recorded with `okb decision add ... --waives <rule-id>`.
42
42
 
43
+ For rules built from a document, read the note and `ref` link the verifier left (`okb docs --out <folder> --context` shows both beside the quote). An OVERREACH or UNSUPPORTED result with no note leaves the reviewer guessing; when you find one, suggest a note that names the word or number (one sentence, no restating the verdict) and the `okb verify <node> ... --note "..." --ref <url>` command to store it. Don't write a name or date into it.
44
+
43
45
  Also check scope: does each competency question have what it needs (`scope-cq-coverage`)? Is there content no question needs (`scope-no-unneeded`)?
44
46
 
45
47
  ## 3. Report
@@ -0,0 +1,182 @@
1
+ ---
2
+ name: ontology-signoff
3
+ description: Use when a subject-matter expert or a pull request reviewer has to confirm that the facts in an okb knowledge base are right, such as "review the KB", "sign off on these rules", "check the rules", "I'm the subject-matter expert", "I'm reviewing this PR", "approve the corrected rules", "I only have ten minutes". It shows each rule beside its quote and the source text around it, riskiest first, asks for a decision on each, records approvals the person names, and ends with a summary they can send or paste as a review comment. It talks in plain language and runs the commands for the person. It does not build a KB (ontology-coach), extract or verify (build-domain-kb-from-docs), judge modeling quality (ontology-review) or do routine updates (ontology-maintainer).
4
+ ---
5
+
6
+ # Sign off on a KB
7
+
8
+ **Version 2.6.3.** It should match the meta-KB version that `okb version` prints.
9
+
10
+ For the person who knows the subject but may not know git, JSON or the `okb` command: a subject-matter expert (SME) whose documents an agent turned into rules, or a teammate reviewing a pull request that changes a KB. The job is to put each rule in front of them with the words it came from, get a decision, and keep a record. You run the commands. They answer questions.
11
+
12
+ This is a check on facts: is this rule true, and does the source say it? It is not a check on how the KB is modeled (is this really a kind of that?). That is **ontology-review**. The commands and their output are in the maintainer guide (<https://ontology-kit.dev/build/maintaining/>) and the CI guide (<https://ontology-kit.dev/build/check-in-ci/>).
13
+
14
+ ## Hard rules
15
+
16
+ - **Approve only on the person's explicit yes for that named item.** `okb verify <id> --approve` marks one corrected rule as read and accepted. Run it only after showing that rule, and only after the person said yes to it by name ("yes, approve the white wine rule"). A "yes" to a list, "looks fine" or "approve everything" is not enough; go back and take the items one at a time. Print the exact command you ran, and which rule it was for. Never approve a batch the person hasn't read.
17
+ - **Never edit the graph to fix a comment.** If they say a rule is wrong, worded badly or missing, write it down as a follow-up with their words and the rule's id. Don't run `okb remove`, `okb verify --status` or any command that changes the KB. The maintainer acts on follow-ups.
18
+ - **Show the source before asking.** For every decision, show the rule, then the quote and the lines around it. Never ask "is this right?" about a rule without the text it came from.
19
+ - **Say what was not reviewed.** End every session with what the person did not see: items left, rules nobody read, sources that changed without a re-sync. Say it even when they stop early.
20
+ - Don't judge the rule for them. You may say what the checker found; the decision is theirs.
21
+ - Write in the person's language. Say "rule", "quote", "the document", not "node", "LPG" or "locator". Don't show JSON, ids or command output unless they ask. Keep an id in brackets after a rule's name so they can find it again.
22
+
23
+ ## Step 0: Set up
24
+
25
+ 1. Run `okb version`. Compare the meta-KB version with this skill's version (top of this file). If they differ, tell the person the skill or okb is out of date and offer `okb skills status`, then `okb skills install`, before going on.
26
+ 2. Find the KB folder (the one with `okb.json`). Make sure you are in it and that the source documents are on disk beside it: the context views read them.
27
+ 3. Pick a scratch folder for the review pages, outside the KB folder (for example a new folder under the system temp directory). Use the same one for the whole session. Never write review pages into the KB's own `docs` folder.
28
+ 4. Ask what they are here to do, in one question: "Is this the first time you're reading what was pulled out of your documents, or are you reviewing a change someone made?" First time: Story 1. A change: Story 2. If they say they have little time, run the story and use Story 3's order.
29
+ 5. Say what to expect, in two sentences: how many rules need a decision (from Step 1), and that nothing in the KB changes unless they approve a rule by name.
30
+
31
+ ## Story 1: The first review of a freshly extracted KB
32
+
33
+ Scope: everything.
34
+
35
+ 1. **Count what is open.**
36
+
37
+ ```bash
38
+ okb status
39
+ okb check
40
+ ```
41
+
42
+ `okb check` lists what blocks a merge: rules with no check yet, rules the checker could not support, corrected rules waiting for a person, and quotes no longer in the source. Tell the person the counts in a sentence: "12 rules came out of your documents. 9 passed the check. 2 were reworded by the checker and wait for you. 1 the checker could not find in the quote." If `okb check` reports quotes missing from the source, say so now: the source changed after the extraction, and the maintainer must re-sync it first (see Hand-off below).
43
+
44
+ 2. **Write the rules-in-context page** and read its top section. Problem cases come first on it:
45
+
46
+ ```bash
47
+ okb docs --out <scratch folder> --context
48
+ ```
49
+
50
+ `rules-in-context.md` lists, for each rule: the statement, how strong it is (MUST, SHOULD, MAY), the check result, the checker's note if there is one, the original wording of a corrected rule, the quote, and the source lines around the quote with the quoted lines marked.
51
+
52
+ 3. **Walk the problem items, one at a time**, in this order: the checker could not support it (`UNSUPPORTED`), reworded by the checker and not yet approved (`OVERREACH`), not checked at all, no quote, quote missing from the source. For each item use the decision prompt below.
53
+
54
+ 4. **Record the decision.** What "record" means depends on the item:
55
+ - A reworded rule, the person says yes to the corrected wording: run the approval command for that one rule, print it, and say what it did. If the new wording uses a different MUST, SHOULD or MAY from the original, say so before asking, and say which strength the rule is stored with now (okb changes the stored strength to match only when the corrected statement names exactly one of MUST, MUST NOT, SHOULD, SHOULD NOT or MAY, and it differs from the stored one; with no keyword, or two different ones, it leaves the strength as it was, so check it by hand before approving). The original wording is shown beside it.
56
+
57
+ ```bash
58
+ okb verify <rule id> --approve
59
+ ```
60
+
61
+ - Anything else (they reject the rule, want other wording, are unsure, or the rule is unsupported and they want to keep it): don't change the KB. Add it to the follow-up list with their words. Say who acts next: the maintainer.
62
+ - A rule with no check yet can't be approved here. It needs the independent check first (build-domain-kb-from-docs, Step 3). Put it on the follow-up list; the person can still say whether it reads right.
63
+
64
+ 5. **After each decision, say how many are left** ("Approved. 2 more need you.") and offer to stop.
65
+
66
+ 6. **The read-through.** Once the problem items are done, write the full reference pages and show the person the KB as a whole, so they read the rules as a set and not one by one:
67
+
68
+ ```bash
69
+ okb docs --out <scratch folder>
70
+ ```
71
+
72
+ Open the index (scope, the questions the KB answers, the class tree) and one class page at a time in plain words. Ask if anything is missing, or contradicts something else. Write every "this doesn't make sense as a whole" comment down as a follow-up. Don't edit anything.
73
+
74
+ 7. **Close out.**
75
+
76
+ ```bash
77
+ okb check
78
+ ```
79
+
80
+ Report what is left and who must act (see "End of every session").
81
+
82
+ Done when every item that needs a person has a recorded decision, and `okb check` has nothing waiting for approval, or the items that remain are listed with who must decide.
83
+
84
+ ## Story 2: Review a change
85
+
86
+ Scope: what the change touched, and what it reached: rules a class passes down to its subclasses, rules about a class whose slots changed, other rules that cite the same quote.
87
+
88
+ 1. **Get the base.** Ask which branch or version the change is measured against, usually `main`. Don't guess if it's unclear.
89
+
90
+ 2. **Say what changed, in words:**
91
+
92
+ ```bash
93
+ okb diff <base>
94
+ ```
95
+
96
+ Summarize it in plain language: what was added, removed, renamed, and which rules now say something different. A rule's old and new wording go side by side.
97
+
98
+ 3. **Write the changed-only pages.** They hold only the pages that differ from the base, plus the subclass pages a changed inherited rule reaches, plus `changes.md`:
99
+
100
+ ```bash
101
+ okb docs --out <scratch folder> --changed <base>
102
+ ```
103
+
104
+ Read `changes.md` first. If a rule's effect is wider than the pages it sits on, add `--hops 1` to also write pages one link away.
105
+
106
+ 4. **If a source document changed and the KB wasn't re-synced:** `changes.md` lists quotes that are gone or moved and blocks that are new or changed. When it does, stop. Tell the person that the document changed but nobody has updated the rules from it, so what they would sign off on is out of date, and that the maintainer has to run the re-sync first (**ontology-maintainer**, Flow 1). Don't ask for decisions on rules whose quotes are gone. Offer to continue with the rules that are unaffected, and say that the rest were not reviewed.
107
+
108
+ 5. **Write the rules-in-context page** and go to each rule the change touched or reached:
109
+
110
+ ```bash
111
+ okb docs --out <scratch folder> --context
112
+ ```
113
+
114
+ That page lists every rule, so go only to the ones `okb diff` and `changes.md` named. Problem cases first, same order as Story 1 step 3, then the changed rules that passed the check.
115
+
116
+ 6. **Decide and record,** exactly as in Story 1 step 4. A changed rule that passed the check needs a decision too: "Does this still hold?" Their "yes" is a recorded decision; no command is needed for it.
117
+
118
+ 7. **Give them the summary to post.** Write it in plain language, ready to paste as a pull request review comment:
119
+ - One line verdict: all decided and fine, or what is open.
120
+ - The rules they approved (names, with the command you ran for each).
121
+ - The rules they rejected or want reworded, in their words.
122
+ - Questions about the whole.
123
+ - What was not reviewed.
124
+
125
+ Don't post it for them. They copy it, or ask you to save it as a file outside the KB folder.
126
+
127
+ Done when the reviewer has a decision on every changed rule they were shown, and a comment to post.
128
+
129
+ ## Story 3: I only have a few minutes
130
+
131
+ Use either story, with this order, riskiest first:
132
+
133
+ 1. `UNSUPPORTED` rules.
134
+ 2. `OVERREACH` rules not yet approved.
135
+ 3. Rules not yet checked, or with no quote.
136
+ 4. Changed rules that passed the check (Story 2 only).
137
+ 5. The rest, if time is left.
138
+
139
+ After every decision, say how many are left in each group, and ask "Keep going, or stop here?" When they stop, don't skip the close-out: say what is left, and list it so nobody has to start again.
140
+
141
+ ## The decision prompt
142
+
143
+ For each item, show these in order, in this shape:
144
+
145
+ 1. What the rule says now, in one sentence, and how strong it is ("The KB says: white wine **should** be chilled before serving").
146
+ 2. What the checker found, in plain words:
147
+ - `SUPPORTED`: "The checker agreed the quote says this."
148
+ - `OVERREACH`: "The checker thought the rule said more than the quote. It proposed a narrower wording, shown below. The original is also shown."
149
+ - `UNSUPPORTED`: "The checker could not find this rule in the quote."
150
+ - Not checked: "Nobody has compared this to its quote yet."
151
+ - Add the checker's note if there is one.
152
+ 3. The quote, and the lines around it from the document, with the quoted lines marked. Name the document and the section it comes from.
153
+ 4. The question, one at a time:
154
+ - A reworded rule: "Does the new wording match what the document says? Say 'approve' with the rule's name, or tell me what's wrong."
155
+ - A rule the checker could not support, or a changed rule: "Is this rule right, given this text? Keep it, reject it, or tell me the wording you'd want."
156
+ 5. Their answer in one of four forms: **keep** (as it stands), **reject** (the rule should go), **reword** (they give the words), or **not sure** (leave it for someone else). Repeat it back in one line before you act on it. Treat "yes", "fine" and "OK" as a keep, never as approval of something they haven't been shown.
157
+
158
+ If the quote alone can't settle the question because the document says more elsewhere, say so and don't decide for them. "Not sure" is a valid answer, and it goes on the list.
159
+
160
+ ## End of every session
161
+
162
+ Whether they finished or stopped, close with:
163
+
164
+ - **Decided**: each rule with their decision. For approvals, the exact command you ran.
165
+ - **Follow-ups for the maintainer**: each rule to reject, reword or add, with their words and the rule's id. Nothing in the KB was changed for these.
166
+ - **Not reviewed**: rules not shown, rules that passed the check and that nobody read, changed sources that haven't been re-synced, and whether `okb check` still has anything waiting. Say it plainly, even if the list is long.
167
+ - **Who acts next**: usually the maintainer, with the follow-up list, or the person themselves to approve the rest when they have time.
168
+
169
+ Run `okb check` once more, and tell them whether it says "Safe to merge" or what still blocks it.
170
+
171
+ ## Hand-off
172
+
173
+ - A source changed, or quotes are missing: **ontology-maintainer**, Flow 1. Wait for it before asking for decisions that depend on the text.
174
+ - A rule needs an independent check before anyone can approve it: **build-domain-kb-from-docs**, Step 3.
175
+ - They say the structure is wrong ("these shouldn't be kinds of each other"): that is a modeling comment; capture it as a follow-up and point to **ontology-review**.
176
+
177
+ ## What this skill doesn't do
178
+
179
+ - **Build** a KB (ontology-coach), **extract or verify** from documents (build-domain-kb-from-docs), **update** it routinely (ontology-maintainer), or **judge the model** (ontology-review).
180
+ - **Change the KB** other than `okb verify --approve` on a rule the person named. Rejecting, rewording and removing are follow-ups.
181
+ - **Decide who checks the rules the checker supported.** The pipeline (`docs/EXTRACTION-PIPELINE.md`) assigns a person only to corrected rules. A rule the checker marked `SUPPORTED` was read by a second pass and no one else, and nothing in the KB makes a human look at it. This skill shows them in the read-through and in a changed-rule review, but it can't make anyone responsible for them. If it matters, tell the owner this gap exists.
182
+ - **Post the review.** The person sends the summary.
@@ -0,0 +1,132 @@
1
+ # Copy this file to .github/workflows/okb-check.yml in your knowledge base's repository.
2
+ #
3
+ # On every pull request it installs the okb version your KB pins (okbVersion in okb.json; run
4
+ # `okb pin` to set it), runs `okb check`, and posts what the PR changes (`okb diff`) as one comment
5
+ # that later pushes update. It needs no secrets. Make "Check the knowledge base" a required status
6
+ # check on your main branch so a failing check blocks the merge.
7
+ name: okb check
8
+
9
+ on:
10
+ pull_request:
11
+
12
+ # The comment needs pull-requests: write. Everything else only reads.
13
+ permissions:
14
+ contents: read
15
+ pull-requests: write
16
+
17
+ # A new push supersedes the run for the old one.
18
+ concurrency:
19
+ group: okb-check-${{ github.ref }}
20
+ cancel-in-progress: true
21
+
22
+ env:
23
+ # The folder that holds okb.json. Change it if the KB isn't at the root of the repository.
24
+ KB_DIR: .
25
+
26
+ jobs:
27
+ check:
28
+ name: Check the knowledge base
29
+ runs-on: ubuntu-latest
30
+ timeout-minutes: 15
31
+ steps:
32
+ # The full history, so `okb diff` can read the base branch.
33
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
34
+ with:
35
+ fetch-depth: 0
36
+ persist-credentials: false
37
+
38
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
39
+ with:
40
+ node-version: 24 # okb needs Node 24 or newer
41
+
42
+ - name: Install the okb version the KB pins
43
+ shell: bash
44
+ run: |
45
+ version="$(node -p "require('./$KB_DIR/okb.json').okbVersion || ''")"
46
+ if [ -z "$version" ]; then
47
+ echo "::warning::okb.json has no okbVersion, so this installs the latest okb. Run 'okb pin' and commit okb.json to pin one."
48
+ version=latest
49
+ elif ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then
50
+ echo "::error::okbVersion '$version' in okb.json isn't a version like 1.2.3."
51
+ exit 1
52
+ fi
53
+ npm install --global --no-audit --no-fund "@ontology-kit/okb@$version"
54
+ okb version
55
+
56
+ # Never stops the job: the diff and the comment still run, and the last step fails the job.
57
+ - name: Run okb check
58
+ id: check
59
+ continue-on-error: true
60
+ shell: bash
61
+ run: |
62
+ # No pipe: the step must exit with okb check's status, not tee's.
63
+ status=0
64
+ okb check -C "$KB_DIR" > "$RUNNER_TEMP/check.txt" 2>&1 || status=$?
65
+ cat "$RUNNER_TEMP/check.txt"
66
+ exit "$status"
67
+
68
+ - name: Run okb diff against the base branch
69
+ if: always()
70
+ env:
71
+ BASE_REF: ${{ github.base_ref }}
72
+ shell: bash
73
+ run: |
74
+ # The backticks are Markdown, not command substitution.
75
+ # shellcheck disable=SC2016
76
+ if ! okb diff "origin/$BASE_REF" -C "$KB_DIR" > "$RUNNER_TEMP/diff.md" 2> "$RUNNER_TEMP/diff.err"; then
77
+ printf 'okb diff could not compare with `%s`:\n\n```\n%s\n```\n' "$BASE_REF" "$(cat "$RUNNER_TEMP/diff.err")" > "$RUNNER_TEMP/diff.md"
78
+ fi
79
+
80
+ - name: Write the comment
81
+ if: always()
82
+ env:
83
+ RESULT: ${{ steps.check.outcome }}
84
+ shell: bash
85
+ run: |
86
+ # The backticks are Markdown, not command substitution.
87
+ # shellcheck disable=SC2016
88
+ {
89
+ echo '<!-- okb-check -->'
90
+ if [ "$RESULT" = success ]; then echo '## okb check: safe to merge'; else echo '## okb check: not safe to merge'; fi
91
+ echo
92
+ echo '~~~~text'
93
+ sed 's/\x1b\[[0-9;]*m//g' "$RUNNER_TEMP/check.txt"
94
+ echo '~~~~'
95
+ echo
96
+ echo '## What this PR changes'
97
+ echo
98
+ cat "$RUNNER_TEMP/diff.md"
99
+ } > "$RUNNER_TEMP/body.md"
100
+ # A comment holds at most 65536 characters.
101
+ if [ "$(wc -c < "$RUNNER_TEMP/body.md")" -gt 60000 ]; then
102
+ head -c 60000 "$RUNNER_TEMP/body.md" > "$RUNNER_TEMP/short.md"
103
+ # shellcheck disable=SC2016
104
+ printf '\n\n_(Cut short. Run `okb diff` locally for the rest.)_\n' >> "$RUNNER_TEMP/short.md"
105
+ mv "$RUNNER_TEMP/short.md" "$RUNNER_TEMP/body.md"
106
+ fi
107
+ cat "$RUNNER_TEMP/body.md" >> "$GITHUB_STEP_SUMMARY"
108
+
109
+ # A pull request from a fork gets a read-only token, so it only gets the job summary.
110
+ - name: Create or update the pull request comment
111
+ if: always() && github.event.pull_request.head.repo.full_name == github.repository
112
+ env:
113
+ GH_TOKEN: ${{ github.token }}
114
+ REPO: ${{ github.repository }}
115
+ PR: ${{ github.event.pull_request.number }}
116
+ shell: bash
117
+ run: |
118
+ # Read the list first: if gh fails, stop here rather than post a duplicate comment.
119
+ ids="$(gh api --paginate "repos/$REPO/issues/$PR/comments" --jq '.[] | select(.body | startswith("<!-- okb-check -->")) | .id')"
120
+ id="${ids%%$'\n'*}"
121
+ if [ -n "$id" ]; then
122
+ gh api --method PATCH "repos/$REPO/issues/comments/$id" -F body=@"$RUNNER_TEMP/body.md" > /dev/null
123
+ else
124
+ gh api --method POST "repos/$REPO/issues/$PR/comments" -F body=@"$RUNNER_TEMP/body.md" > /dev/null
125
+ fi
126
+
127
+ - name: Fail if okb check failed
128
+ if: steps.check.outcome == 'failure'
129
+ shell: bash
130
+ run: |
131
+ echo "::error::okb check found problems. See the summary above or the pull request comment."
132
+ exit 1
@@ -0,0 +1,16 @@
1
+ <!-- Copy this file to .github/pull_request_template.md in your knowledge base's repository. -->
2
+
3
+ ## What changed in the knowledge
4
+
5
+ <!-- One or two sentences. Paste the okb diff comment from CI, or run `okb diff main`. -->
6
+
7
+ ## Checklist
8
+
9
+ - [ ] `okb check` says "Safe to merge" (the okb check workflow ran it).
10
+ - [ ] I read `okb diff main` and every change in it is meant.
11
+ - [ ] Each new or changed rule, class or fact cites a quote from a source.
12
+ - [ ] I ran `okb source refresh` for every source document I changed, and no quote is missing.
13
+ - [ ] A person other than the author ran `okb verify <id> --approve` on every corrected item.
14
+ - [ ] I used `okb rename` (not remove and add) for every renamed class, slot or instance.
15
+ - [ ] I ran `okb pin` if I upgraded okb.
16
+ - [ ] I ran `okb release <version>` and committed the result, if this change is part of a release.