@ontology-kit/okb 0.3.0-alpha.23 → 0.3.0-alpha.68

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 (47) hide show
  1. package/dist/check.js +21 -2
  2. package/dist/checks.js +23 -0
  3. package/dist/cli.js +2 -2
  4. package/dist/command-table.d.ts +21 -11
  5. package/dist/command-table.js +24 -21
  6. package/dist/commands/documents.js +2 -2
  7. package/dist/commands/modeling.js +68 -34
  8. package/dist/commands/planning.js +40 -1
  9. package/dist/commands/reviewing.js +52 -10
  10. package/dist/cqanswer.d.ts +51 -0
  11. package/dist/cqanswer.js +76 -0
  12. package/dist/export-changes.d.ts +40 -0
  13. package/dist/export-changes.js +115 -0
  14. package/dist/export-csv.d.ts +17 -0
  15. package/dist/export-csv.js +188 -0
  16. package/dist/export.d.ts +33 -2
  17. package/dist/export.js +69 -11
  18. package/dist/ops/admin.d.ts +1 -1
  19. package/dist/ops/admin.js +2 -1
  20. package/dist/ops/classes.js +2 -2
  21. package/dist/ops/common.d.ts +12 -2
  22. package/dist/ops/common.js +3 -0
  23. package/dist/ops/instances.js +2 -2
  24. package/dist/ops/links.d.ts +1 -1
  25. package/dist/ops/links.js +2 -1
  26. package/dist/ops/scope.d.ts +9 -2
  27. package/dist/ops/scope.js +19 -3
  28. package/dist/ops/slots.js +6 -6
  29. package/dist/provenance.d.ts +1 -1
  30. package/dist/provenance.js +3 -2
  31. package/dist/render.d.ts +15 -2
  32. package/dist/render.js +25 -5
  33. package/dist/runner.js +22 -17
  34. package/dist/verifynote.d.ts +4 -3
  35. package/dist/verifynote.js +3 -2
  36. package/dist/workflows.d.ts +31 -7
  37. package/dist/workflows.js +56 -9
  38. package/meta-kb/data/edges.json +25 -0
  39. package/meta-kb/data/manifest.json +4 -4
  40. package/meta-kb/data/nodes.json +39 -2
  41. package/package.json +2 -2
  42. package/schema/node.schema.json +22 -1
  43. package/skills/build-domain-kb-from-docs/SKILL.md +1 -1
  44. package/skills/ontology-coach/SKILL.md +2 -2
  45. package/skills/ontology-maintainer/SKILL.md +1 -1
  46. package/skills/ontology-review/SKILL.md +1 -1
  47. package/skills/ontology-signoff/SKILL.md +1 -1
@@ -1989,6 +1989,21 @@
1989
1989
  "type": "GOVERNS",
1990
1990
  "to": "concept.competency-question"
1991
1991
  },
1992
+ {
1993
+ "from": "rule.scope-cq-expected-answer",
1994
+ "type": "JUSTIFIED_BY",
1995
+ "to": "rat.scope-cq-expected-answer"
1996
+ },
1997
+ {
1998
+ "from": "rat.scope-cq-expected-answer",
1999
+ "type": "CITES",
2000
+ "to": "loc.o101.cq-litmus"
2001
+ },
2002
+ {
2003
+ "from": "rule.scope-cq-expected-answer",
2004
+ "type": "GOVERNS",
2005
+ "to": "concept.competency-question"
2006
+ },
1992
2007
  {
1993
2008
  "from": "rule.scope-no-unneeded",
1994
2009
  "type": "JUSTIFIED_BY",
@@ -2144,6 +2159,16 @@
2144
2159
  "type": "GOVERNS",
2145
2160
  "to": "concept.lpg"
2146
2161
  },
2162
+ {
2163
+ "from": "rule.struct-no-save-leftovers",
2164
+ "type": "JUSTIFIED_BY",
2165
+ "to": "rat.struct-no-save-leftovers"
2166
+ },
2167
+ {
2168
+ "from": "rule.struct-no-save-leftovers",
2169
+ "type": "GOVERNS",
2170
+ "to": "concept.lpg"
2171
+ },
2147
2172
  {
2148
2173
  "from": "rule.prov-verified",
2149
2174
  "type": "JUSTIFIED_BY",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.6.3",
2
+ "version": "2.8.0",
3
3
  "formatVersion": "okb-lpg/3",
4
4
  "nodeCounts": {
5
5
  "MetaKB": 1,
@@ -7,13 +7,13 @@
7
7
  "SourceLocation": 127,
8
8
  "Principle": 7,
9
9
  "Concept": 40,
10
- "Rule": 57,
11
- "Rationale": 57,
10
+ "Rule": 59,
11
+ "Rationale": 59,
12
12
  "Decision": 10,
13
13
  "Step": 8,
14
14
  "NodeType": 11,
15
15
  "EdgeType": 14
16
16
  },
17
- "edgeCount": 634,
17
+ "edgeCount": 639,
18
18
  "quotesVerified": true
19
19
  }
@@ -2,7 +2,7 @@
2
2
  {
3
3
  "type": "MetaKB",
4
4
  "id": "metakb",
5
- "version": "2.6.3",
5
+ "version": "2.8.0",
6
6
  "formatVersion": "okb-lpg/3",
7
7
  "description": "Rules, method and vocabulary for building ontologies, derived from Ontology 101 (Noy & McGuinness 2001) and Gruber (1993)."
8
8
  },
@@ -2359,6 +2359,25 @@
2359
2359
  "id": "rat.scope-cq-coverage",
2360
2360
  "explanation": "Competency questions are the litmus test: does the ontology contain enough information to answer them? NEEDS links make that test explicit and checkable."
2361
2361
  },
2362
+ {
2363
+ "type": "Rule",
2364
+ "id": "rule.scope-cq-expected-answer",
2365
+ "key": "scope-cq-expected-answer",
2366
+ "modality": "SHOULD",
2367
+ "basis": "interpretive",
2368
+ "check": "heuristic",
2369
+ "severity": "warning",
2370
+ "fromStep": 8,
2371
+ "statement": "Each competency question should record the answer the ontology is expected to give.",
2372
+ "plainLanguage": "Write down what each question should return, so a script can tell you when a change stops the ontology from answering it.",
2373
+ "review": "Read each stored query next to its question: does it really ask what the question asks?",
2374
+ "fix": "`okb cq answer <n> --query '<JSON>' --expect A,B,C`."
2375
+ },
2376
+ {
2377
+ "type": "Rationale",
2378
+ "id": "rat.scope-cq-expected-answer",
2379
+ "explanation": "Competency questions are the litmus test, but a test nobody runs proves nothing. A stored query and its expected names turn each question into a regression check that `okb cq check` and `okb check` run on every change. okb can see that no answer is stored, not that the stored one is the right answer."
2380
+ },
2362
2381
  {
2363
2382
  "type": "Rule",
2364
2383
  "id": "rule.scope-no-unneeded",
@@ -2508,6 +2527,24 @@
2508
2527
  "id": "rat.struct-well-formed",
2509
2528
  "explanation": "Every other check assumes the graph is structurally sound."
2510
2529
  },
2530
+ {
2531
+ "type": "Rule",
2532
+ "id": "rule.struct-no-save-leftovers",
2533
+ "key": "struct-no-save-leftovers",
2534
+ "modality": "SHOULD",
2535
+ "basis": "operational",
2536
+ "check": "mechanical",
2537
+ "severity": "warning",
2538
+ "fromStep": 1,
2539
+ "statement": "An ontology folder should hold no leftovers of an interrupted save: no okb.json.tmp, nodes.jsonl.tmp or edges.jsonl.tmp, and no .okb.saving.tmp marker.",
2540
+ "plainLanguage": "A save that was killed halfway can leave new nodes next to old edges, and nothing else notices. Leftover temp files are the sign.",
2541
+ "fix": "If a command is running, wait for it. If the marker is there, run any okb command that changes this folder: it finishes the save. If only `*.tmp` files are there, run `okb validate` to check the real files agree (a save killed halfway can leave new nodes beside old edges), restore the folder from git or a backup if they don't, then delete the leftovers."
2542
+ },
2543
+ {
2544
+ "type": "Rationale",
2545
+ "id": "rat.struct-no-save-leftovers",
2546
+ "explanation": "A folder with leftovers can pass every other check while some of its files come from an older save. Older okb versions, and a save killed before it finished writing, leave temp files with no marker, so no load finishes them on its own."
2547
+ },
2511
2548
  {
2512
2549
  "type": "Rule",
2513
2550
  "id": "rule.prov-verified",
@@ -3196,7 +3233,7 @@
3196
3233
  "id",
3197
3234
  "text"
3198
3235
  ],
3199
- "description": "A question the ontology must answer. status: draft | answerable."
3236
+ "description": "A question the ontology must answer. status: draft | answerable. answer (`okb cq answer`): {query, expect[], match: exact | includes}, a declarative find/traverse/slots query and the names it must return, which `okb cq check` evaluates."
3200
3237
  },
3201
3238
  {
3202
3239
  "type": "NodeType",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ontology-kit/okb",
3
- "version": "0.3.0-alpha.23",
3
+ "version": "0.3.0-alpha.68",
4
4
  "license": "MIT",
5
5
  "description": "A toolkit for building knowledge graphs with guardrails: a checked file format, rules from a meta-KB, provenance down to verbatim quotes, and skills that drive it.",
6
6
  "homepage": "https://ontology-kit.dev",
@@ -62,7 +62,7 @@
62
62
  "pdfjs-dist": "^6.3.289"
63
63
  },
64
64
  "dependencies": {
65
- "@ontology-kit/reader": "0.3.0-alpha.23",
65
+ "@ontology-kit/reader": "0.3.0-alpha.68",
66
66
  "yaml": "^2.8.0"
67
67
  },
68
68
  "scripts": {
@@ -223,7 +223,7 @@
223
223
  },
224
224
  "CompetencyQuestion": {
225
225
  "title": "CompetencyQuestion",
226
- "description": "A question the ontology must answer. status: draft | answerable.",
226
+ "description": "A question the ontology must answer. status: draft | answerable. answer (`okb cq answer`): {query, expect[], match: exact | includes}, a declarative find/traverse/slots query and the names it must return, which `okb cq check` evaluates.",
227
227
  "type": "object",
228
228
  "required": [
229
229
  "id",
@@ -256,6 +256,27 @@
256
256
  "draft",
257
257
  "answerable"
258
258
  ]
259
+ },
260
+ "answer": {
261
+ "type": "object",
262
+ "required": [
263
+ "query",
264
+ "expect"
265
+ ],
266
+ "properties": {
267
+ "query": {
268
+ "type": "object"
269
+ },
270
+ "expect": {
271
+ "$ref": "#/$defs/Strings"
272
+ },
273
+ "match": {
274
+ "enum": [
275
+ "exact",
276
+ "includes"
277
+ ]
278
+ }
279
+ }
259
280
  }
260
281
  }
261
282
  },
@@ -5,7 +5,7 @@ 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.6.3.** It should match the meta-KB version that `okb version` prints.
8
+ **Version 2.8.0.** 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
 
@@ -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.6.3.** It should match the meta-KB version that `okb version` prints.
8
+ **Version 2.8.0.** 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
 
@@ -74,7 +74,7 @@ Pick one competency question and add just enough instances to answer it end to e
74
74
 
75
75
  ### Step 8: Review and iterate
76
76
 
77
- 1. For each competency question, ask what answers it and link it: `okb cq link <n> <Class|slot>...`. A question with nothing to link means something is missing, so go back and add it. okb then suggests the question's family; widen it with the user (see below).
77
+ 1. For each competency question, ask what answers it and link it: `okb cq link <n> <Class|slot>...`. A question with nothing to link means something is missing, so go back and add it. okb then suggests the question's family; widen it with the user (see below). Then store what each question should return, so a script can tell when a change breaks it: `okb cq answer <n> --query '<JSON>' --expect A,B,C` (queries are `find`, `traverse` or `slots`; `okb cq answer --help` shows the shapes). `okb cq check` runs them all, and `okb check` includes it.
78
78
  2. `okb validate --all`: fix errors; fix or explain warnings.
79
79
  3. Run the **ontology-review** skill (or `okb review` yourself) for the judgment rules a script can't check.
80
80
  4. Suggest showing the tree (`okb diagram --out diagram.md`) to someone who knows the domain.
@@ -5,7 +5,7 @@ description: Use when someone looks after an existing okb knowledge base that is
5
5
 
6
6
  # Maintain an existing KB
7
7
 
8
- **Version 2.6.3.** It should match the meta-KB version that `okb version` prints.
8
+ **Version 2.8.0.** It should match the meta-KB version that `okb version` prints.
9
9
 
10
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
11
 
@@ -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.6.3.** It should match the meta-KB version that `okb version` prints.
8
+ **Version 2.8.0.** 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
 
@@ -5,7 +5,7 @@ description: Use when a subject-matter expert or a pull request reviewer has to
5
5
 
6
6
  # Sign off on a KB
7
7
 
8
- **Version 2.6.3.** It should match the meta-KB version that `okb version` prints.
8
+ **Version 2.8.0.** It should match the meta-KB version that `okb version` prints.
9
9
 
10
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
11