knott 0.2.0__tar.gz → 0.4.0__tar.gz

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 (220) hide show
  1. {knott-0.2.0 → knott-0.4.0}/PKG-INFO +30 -4
  2. {knott-0.2.0 → knott-0.4.0}/README.md +29 -3
  3. {knott-0.2.0 → knott-0.4.0}/SPEC.md +70 -17
  4. {knott-0.2.0 → knott-0.4.0}/docs/.knott/schemas/issue_code.yaml +1 -1
  5. {knott-0.2.0 → knott-0.4.0}/docs/README.md +7 -4
  6. knott-0.4.0/docs/commands/types.md +30 -0
  7. {knott-0.2.0 → knott-0.4.0}/docs/commands/validate.md +16 -2
  8. knott-0.4.0/docs/commands/view.md +23 -0
  9. knott-0.4.0/docs/concepts/attribute.md +68 -0
  10. knott-0.4.0/docs/concepts/kid.md +50 -0
  11. {knott-0.2.0 → knott-0.4.0}/docs/concepts/ontology.md +9 -7
  12. {knott-0.2.0 → knott-0.4.0}/docs/concepts/reference-resolution.md +12 -1
  13. {knott-0.2.0 → knott-0.4.0}/docs/decisions/0002-relative-paths-not-ids.md +2 -0
  14. knott-0.4.0/docs/decisions/0005-empty-values.md +29 -0
  15. knott-0.4.0/docs/decisions/0008-structured-attributes.md +27 -0
  16. knott-0.4.0/docs/decisions/0009-kid-identity.md +26 -0
  17. {knott-0.2.0 → knott-0.4.0}/docs/guides/agent-workflow.md +3 -1
  18. {knott-0.2.0 → knott-0.4.0}/docs/guides/python-api.md +10 -2
  19. {knott-0.2.0 → knott-0.4.0}/docs/guides/writing-schemas.md +51 -1
  20. {knott-0.2.0 → knott-0.4.0}/docs/issues/attribute-missing.md +2 -0
  21. {knott-0.2.0 → knott-0.4.0}/docs/issues/attribute-type-mismatch.md +5 -1
  22. knott-0.4.0/docs/issues/attribute-unknown-field.md +26 -0
  23. knott-0.4.0/docs/issues/kid-duplicate.md +27 -0
  24. knott-0.4.0/docs/issues/kid-invalid.md +25 -0
  25. knott-0.4.0/docs/issues/kid-missing.md +25 -0
  26. knott-0.4.0/docs/issues/relation-target-ambiguous.md +20 -0
  27. {knott-0.2.0 → knott-0.4.0}/docs/issues/schema-unknown-target.md +1 -1
  28. knott-0.4.0/docs/plans/completed/20261007-ontology-viewer.md +176 -0
  29. knott-0.4.0/docs/plans/completed/20261019-structured-attributes.md +238 -0
  30. knott-0.4.0/docs/plans/completed/20261022-kid-identity.md +56 -0
  31. {knott-0.2.0 → knott-0.4.0}/pyproject.toml +1 -1
  32. {knott-0.2.0 → knott-0.4.0}/src/knott/__init__.py +17 -1
  33. {knott-0.2.0 → knott-0.4.0}/src/knott/_skills/knott/SKILL.md +35 -6
  34. knott-0.4.0/src/knott/_view/ontology.html +505 -0
  35. {knott-0.2.0 → knott-0.4.0}/src/knott/api.py +143 -4
  36. {knott-0.2.0 → knott-0.4.0}/src/knott/cli.py +132 -11
  37. knott-0.4.0/src/knott/models.py +117 -0
  38. {knott-0.2.0 → knott-0.4.0}/src/knott/schema/loader.py +176 -33
  39. knott-0.4.0/src/knott/schema/models.py +89 -0
  40. {knott-0.2.0 → knott-0.4.0}/src/knott/schema/validator.py +165 -26
  41. {knott-0.2.0 → knott-0.4.0}/src/knott/vault/entity.py +19 -0
  42. knott-0.4.0/src/knott/vault/fix.py +73 -0
  43. knott-0.4.0/src/knott/vault/kid.py +69 -0
  44. {knott-0.2.0 → knott-0.4.0}/src/knott/vault/links.py +46 -3
  45. knott-0.4.0/src/knott/view.py +31 -0
  46. knott-0.4.0/tests/fixtures/kid-identity/.knott/schemas/lexeme.yaml +5 -0
  47. knott-0.4.0/tests/fixtures/kid-identity/.knott/schemas/topic.yaml +4 -0
  48. knott-0.4.0/tests/fixtures/kid-identity/lexemes/archive/namas.md +5 -0
  49. knott-0.4.0/tests/fixtures/kid-identity/lexemes/draugas-copy.md +5 -0
  50. knott-0.4.0/tests/fixtures/kid-identity/lexemes/draugas.md +5 -0
  51. knott-0.4.0/tests/fixtures/kid-identity/lexemes/nokid.md +4 -0
  52. knott-0.4.0/tests/fixtures/kid-identity/lexemes/upper.md +5 -0
  53. knott-0.4.0/tests/fixtures/kid-identity/topics/broken.md +10 -0
  54. knott-0.4.0/tests/fixtures/kid-identity/topics/home.md +6 -0
  55. knott-0.4.0/tests/fixtures/structured-attributes/.knott/schemas/lexeme.yaml +29 -0
  56. knott-0.4.0/tests/fixtures/structured-attributes/lexemes/broken.md +14 -0
  57. knott-0.4.0/tests/fixtures/structured-attributes/lexemes/draugas.md +14 -0
  58. knott-0.4.0/tests/test_api.py +187 -0
  59. knott-0.4.0/tests/test_attributes.py +236 -0
  60. {knott-0.2.0 → knott-0.4.0}/tests/test_cli.py +179 -1
  61. {knott-0.2.0 → knott-0.4.0}/tests/test_entities.py +32 -0
  62. knott-0.4.0/tests/test_fix.py +169 -0
  63. knott-0.4.0/tests/test_kid.py +204 -0
  64. knott-0.4.0/tests/test_schemas.py +272 -0
  65. knott-0.4.0/tests/test_view.py +135 -0
  66. {knott-0.2.0 → knott-0.4.0}/uv.lock +1 -1
  67. knott-0.2.0/docs/commands/types.md +0 -18
  68. knott-0.2.0/docs/concepts/attribute.md +0 -27
  69. knott-0.2.0/docs/decisions/0005-empty-values.md +0 -24
  70. knott-0.2.0/src/knott/models.py +0 -50
  71. knott-0.2.0/src/knott/schema/models.py +0 -42
  72. knott-0.2.0/tests/test_api.py +0 -55
  73. knott-0.2.0/tests/test_attributes.py +0 -102
  74. knott-0.2.0/tests/test_schemas.py +0 -92
  75. {knott-0.2.0 → knott-0.4.0}/.gitignore +0 -0
  76. {knott-0.2.0 → knott-0.4.0}/LICENSE +0 -0
  77. {knott-0.2.0 → knott-0.4.0}/RELEASING.md +0 -0
  78. {knott-0.2.0 → knott-0.4.0}/docs/.knott/config.yaml +0 -0
  79. {knott-0.2.0 → knott-0.4.0}/docs/.knott/schemas/command.yaml +0 -0
  80. {knott-0.2.0 → knott-0.4.0}/docs/.knott/schemas/concept.yaml +0 -0
  81. {knott-0.2.0 → knott-0.4.0}/docs/.knott/schemas/decision.yaml +0 -0
  82. {knott-0.2.0 → knott-0.4.0}/docs/.knott/schemas/guide.yaml +0 -0
  83. {knott-0.2.0 → knott-0.4.0}/docs/commands/init.md +0 -0
  84. {knott-0.2.0 → knott-0.4.0}/docs/commands/skill.md +0 -0
  85. {knott-0.2.0 → knott-0.4.0}/docs/commands/version.md +0 -0
  86. {knott-0.2.0 → knott-0.4.0}/docs/concepts/entity.md +0 -0
  87. {knott-0.2.0 → knott-0.4.0}/docs/concepts/frontmatter.md +0 -0
  88. {knott-0.2.0 → knott-0.4.0}/docs/concepts/issue.md +0 -0
  89. {knott-0.2.0 → knott-0.4.0}/docs/concepts/relation.md +0 -0
  90. {knott-0.2.0 → knott-0.4.0}/docs/concepts/schema.md +0 -0
  91. {knott-0.2.0 → knott-0.4.0}/docs/concepts/vault.md +0 -0
  92. {knott-0.2.0 → knott-0.4.0}/docs/decisions/0001-markdown-is-source-of-truth.md +0 -0
  93. {knott-0.2.0 → knott-0.4.0}/docs/decisions/0003-source-side-relations.md +0 -0
  94. {knott-0.2.0 → knott-0.4.0}/docs/decisions/0004-strict-typing.md +0 -0
  95. {knott-0.2.0 → knott-0.4.0}/docs/decisions/0006-symlinks-and-containment.md +0 -0
  96. {knott-0.2.0 → knott-0.4.0}/docs/decisions/0007-parser-robustness.md +0 -0
  97. {knott-0.2.0 → knott-0.4.0}/docs/guides/getting-started.md +0 -0
  98. {knott-0.2.0 → knott-0.4.0}/docs/guides/obsidian.md +0 -0
  99. {knott-0.2.0 → knott-0.4.0}/docs/issues/entity-invalid-frontmatter.md +0 -0
  100. {knott-0.2.0 → knott-0.4.0}/docs/issues/entity-unknown-type.md +0 -0
  101. {knott-0.2.0 → knott-0.4.0}/docs/issues/not-an-entity.md +0 -0
  102. {knott-0.2.0 → knott-0.4.0}/docs/issues/relation-invalid-value.md +0 -0
  103. {knott-0.2.0 → knott-0.4.0}/docs/issues/relation-missing.md +0 -0
  104. {knott-0.2.0 → knott-0.4.0}/docs/issues/relation-target-not-entity.md +0 -0
  105. {knott-0.2.0 → knott-0.4.0}/docs/issues/relation-target-not-found.md +0 -0
  106. {knott-0.2.0 → knott-0.4.0}/docs/issues/relation-target-outside-vault.md +0 -0
  107. {knott-0.2.0 → knott-0.4.0}/docs/issues/relation-target-type-mismatch.md +0 -0
  108. {knott-0.2.0 → knott-0.4.0}/docs/issues/schema-duplicate-type.md +0 -0
  109. {knott-0.2.0 → knott-0.4.0}/docs/issues/schema-field-conflict.md +0 -0
  110. {knott-0.2.0 → knott-0.4.0}/docs/issues/schema-invalid-field.md +0 -0
  111. {knott-0.2.0 → knott-0.4.0}/docs/issues/schema-invalid-yaml.md +0 -0
  112. {knott-0.2.0 → knott-0.4.0}/docs/plans/completed/20261007-skill-install-command.md +0 -0
  113. {knott-0.2.0 → knott-0.4.0}/src/knott/_values.py +0 -0
  114. {knott-0.2.0 → knott-0.4.0}/src/knott/_yaml.py +0 -0
  115. {knott-0.2.0 → knott-0.4.0}/src/knott/errors.py +0 -0
  116. {knott-0.2.0 → knott-0.4.0}/src/knott/py.typed +0 -0
  117. {knott-0.2.0 → knott-0.4.0}/src/knott/schema/__init__.py +0 -0
  118. {knott-0.2.0 → knott-0.4.0}/src/knott/skills.py +0 -0
  119. {knott-0.2.0 → knott-0.4.0}/src/knott/vault/__init__.py +0 -0
  120. {knott-0.2.0 → knott-0.4.0}/src/knott/vault/discovery.py +0 -0
  121. {knott-0.2.0 → knott-0.4.0}/tests/__init__.py +0 -0
  122. {knott-0.2.0 → knott-0.4.0}/tests/conftest.py +0 -0
  123. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/duplicate-schema-type/.knott/config.yaml +0 -0
  124. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/duplicate-schema-type/.knott/schemas/legacy/script.yaml +0 -0
  125. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/duplicate-schema-type/.knott/schemas/podcast/transcript.yaml +0 -0
  126. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/duplicate-schema-type/.knott/schemas/script.yaml +0 -0
  127. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/duplicate-schema-type/scripts/episode-42.md +0 -0
  128. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/invalid-frontmatter/.knott/config.yaml +0 -0
  129. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/invalid-frontmatter/.knott/schemas/podcast/transcript.yaml +0 -0
  130. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/invalid-frontmatter/.knott/schemas/script.yaml +0 -0
  131. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/invalid-frontmatter/bom-crlf-ok.md +0 -0
  132. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/invalid-frontmatter/broken-yaml.md +0 -0
  133. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/invalid-frontmatter/not-a-mapping.md +0 -0
  134. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/invalid-frontmatter/scripts/episode-42.md +0 -0
  135. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/invalid-frontmatter/unclosed.md +0 -0
  136. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/invalid-frontmatter/unquoted-link.md +0 -0
  137. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-relation-target/.knott/config.yaml +0 -0
  138. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-relation-target/.knott/schemas/podcast/transcript.yaml +0 -0
  139. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-relation-target/.knott/schemas/script.yaml +0 -0
  140. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-relation-target/notes/plain.md +0 -0
  141. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-relation-target/scripts/episode-42.md +0 -0
  142. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-relation-target/transcripts/episode-42.md +0 -0
  143. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-relation-target/transcripts/plain-note-target.md +0 -0
  144. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-relation-target/transcripts/wrong-case.md +0 -0
  145. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-required-field/.knott/config.yaml +0 -0
  146. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-required-field/.knott/schemas/podcast/transcript.yaml +0 -0
  147. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-required-field/.knott/schemas/script.yaml +0 -0
  148. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-required-field/scripts/blank-title.md +0 -0
  149. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-required-field/scripts/episode-42.md +0 -0
  150. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/missing-required-field/scripts/untitled.md +0 -0
  151. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-list/.knott/config.yaml +0 -0
  152. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-list/.knott/schemas/compilation.yaml +0 -0
  153. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-list/.knott/schemas/podcast/transcript.yaml +0 -0
  154. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-list/.knott/schemas/script.yaml +0 -0
  155. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-list/compilations/best-of.md +0 -0
  156. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-list/compilations/empty.md +0 -0
  157. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-list/compilations/partly-broken.md +0 -0
  158. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-list/scripts/episode-42.md +0 -0
  159. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-list/scripts/episode-43.md +0 -0
  160. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-markdown-link/.knott/config.yaml +0 -0
  161. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-markdown-link/.knott/schemas/podcast/transcript.yaml +0 -0
  162. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-markdown-link/.knott/schemas/script.yaml +0 -0
  163. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-markdown-link/scripts/episode 43.md +0 -0
  164. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-markdown-link/scripts/episode-42.md +0 -0
  165. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-markdown-link/transcripts/angle.md +0 -0
  166. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-markdown-link/transcripts/link.md +0 -0
  167. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-markdown-link/transcripts/percent.md +0 -0
  168. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-outside-vault/.knott/config.yaml +0 -0
  169. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-outside-vault/.knott/schemas/podcast/transcript.yaml +0 -0
  170. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-outside-vault/.knott/schemas/script.yaml +0 -0
  171. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-outside-vault/scripts/episode-42.md +0 -0
  172. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-outside-vault/transcripts/escape.md +0 -0
  173. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-outside-vault/transcripts/invalid-forms.md +0 -0
  174. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-outside-vault/transcripts/not-a-string.md +0 -0
  175. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/relation-outside-vault/transcripts/unquoted-wikilink.md +0 -0
  176. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/schema-unknown-key/.knott/config.yaml +0 -0
  177. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/schema-unknown-key/.knott/schemas/Bad_Name.yaml +0 -0
  178. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/schema-unknown-key/.knott/schemas/bad-fields.yaml +0 -0
  179. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/schema-unknown-key/.knott/schemas/broken.yaml +0 -0
  180. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/schema-unknown-key/.knott/schemas/note.yaml +0 -0
  181. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/schema-unknown-key/.knott/schemas/podcast/transcript.yaml +0 -0
  182. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/schema-unknown-key/.knott/schemas/script.yaml +0 -0
  183. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/schema-unknown-key/scripts/episode-42.md +0 -0
  184. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-relation-target-type/.knott/config.yaml +0 -0
  185. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-relation-target-type/.knott/schemas/podcast/transcript.yaml +0 -0
  186. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-relation-target-type/.knott/schemas/review.yaml +0 -0
  187. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-relation-target-type/.knott/schemas/script.yaml +0 -0
  188. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-relation-target-type/scripts/episode-42.md +0 -0
  189. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-type/.knott/config.yaml +0 -0
  190. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-type/.knott/schemas/podcast/transcript.yaml +0 -0
  191. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-type/.knott/schemas/script.yaml +0 -0
  192. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-type/notes/mystery.md +0 -0
  193. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/unknown-type/scripts/episode-42.md +0 -0
  194. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/.knott/config.yaml +0 -0
  195. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/.knott/schemas/feedback.yaml +0 -0
  196. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/.knott/schemas/podcast/transcript.yaml +0 -0
  197. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/.knott/schemas/script.yaml +0 -0
  198. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/.obsidian/ignored.md +0 -0
  199. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/feedback/episode-42-review.md +0 -0
  200. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/notes/plain-note.md +0 -0
  201. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/notes/readme.txt +0 -0
  202. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/notes/untyped-note.md +0 -0
  203. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/scripts/episode-42.md +0 -0
  204. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/valid-vault/transcripts/episode-42.md +0 -0
  205. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-attribute-type/.knott/schemas/record.yaml +0 -0
  206. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-attribute-type/bool-as-int.md +0 -0
  207. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-attribute-type/datetime-as-date.md +0 -0
  208. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-attribute-type/good.md +0 -0
  209. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-attribute-type/misc.md +0 -0
  210. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-attribute-type/unquoted-no.md +0 -0
  211. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-attribute-type/yaml11.md +0 -0
  212. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-relation-target-type/.knott/config.yaml +0 -0
  213. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-relation-target-type/.knott/schemas/feedback.yaml +0 -0
  214. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-relation-target-type/.knott/schemas/podcast/transcript.yaml +0 -0
  215. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-relation-target-type/.knott/schemas/script.yaml +0 -0
  216. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-relation-target-type/scripts/episode-42.md +0 -0
  217. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-relation-target-type/scripts/foo.md +0 -0
  218. {knott-0.2.0 → knott-0.4.0}/tests/fixtures/wrong-relation-target-type/transcripts/foo.md +0 -0
  219. {knott-0.2.0 → knott-0.4.0}/tests/test_relations.py +0 -0
  220. {knott-0.2.0 → knott-0.4.0}/tests/test_skills.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: knott
3
- Version: 0.2.0
3
+ Version: 0.4.0
4
4
  Summary: A local, file-first knowledge layer for AI agents: typed Markdown entities, schemas, and semantic relations.
5
5
  Project-URL: Homepage, https://github.com/nesterione/knott
6
6
  Project-URL: Repository, https://github.com/nesterione/knott
@@ -92,8 +92,9 @@ $ knott validate
92
92
  | Command | Purpose |
93
93
  |---|---|
94
94
  | `knott init [PATH]` | Create `.knott/schemas/` and `.knott/config.yaml` |
95
- | `knott validate [PATH...]` | Check all schemas, plus all entities or those under `PATH` (`--format json` for agents) |
96
- | `knott types [--verbose]` | List discovered types |
95
+ | `knott validate [PATH...]` | Check all schemas, plus all entities or those under `PATH` (`--format json` for agents, `--fix` to add missing `kid`s) |
96
+ | `knott types [--verbose]` | List discovered types (`--verbose`: attributes, nested shapes and relations) |
97
+ | `knott view [PATH]` | Draw the ontology as an HTML page and open it (`-o FILE`, `--no-open`) |
97
98
  | `knott version` | Print the installed version |
98
99
  | `knott skill install [PATH]` | Install the bundled Agent Skill to `.claude/skills` and/or `.agents/skills` (`--claude`, `--agents`; asks interactively without flags) |
99
100
 
@@ -101,7 +102,21 @@ Exit codes: `0` valid, `1` validation issues, `2` usage or configuration error.
101
102
 
102
103
  ## Schemas
103
104
 
104
- Schemas live in `.knott/schemas/**/*.yaml`, one type per file. Attribute types: `string`, `integer`, `number`, `boolean`, `date`, `datetime`. Typing is strict: an unquoted `no` is a boolean, not a string. Relations name a `target` type and are stored only on the source entity.
105
+ Schemas live in `.knott/schemas/**/*.yaml`, one type per file. Attribute types: `string`, `integer`, `number`, `boolean`, `date`, `datetime`, plus `list`, `object` and `map` built from them and nested to any depth. Typing is strict: an unquoted `no` is a boolean, not a string. Relations name a `target` type and are stored only on the source entity.
106
+
107
+ Structured attributes are checked at every level, and problems name their exact location, e.g. `senses[1].ru`:
108
+
109
+ ```yaml
110
+ attributes:
111
+ senses:
112
+ type: list
113
+ required: true
114
+ items:
115
+ type: object
116
+ fields:
117
+ id: {type: string, required: true}
118
+ ru: {type: string, required: true}
119
+ ```
105
120
 
106
121
  ## Relations
107
122
 
@@ -114,6 +129,16 @@ derived_from: "[Episode 42 script](../scripts/episode-42.md)"
114
129
 
115
130
  Wikilinks, URLs, `#fragments`, and absolute paths are rejected. Matching is case-sensitive on every OS.
116
131
 
132
+ ### Stable identity
133
+
134
+ `knott validate --fix` gives every entity a `kid`, a knott-managed UUID that survives moves and renames. A relation can then refer to it as `kid:<uuid>`. A schema can require one with `kid: required`. Markdown links stay the recommended form; use `kid:` where a reference must survive renames.
135
+
136
+ ```yaml
137
+ kid: 3f2b8c1e-9d4a-4c2e-b7f1-0a6d5e9c8b21
138
+ includes:
139
+ - kid:0192f4a1-7c3e-4b2a-9f10-3d5e8c2b4a61
140
+ ```
141
+
117
142
  ### Obsidian
118
143
 
119
144
  Markdown links in properties are clickable in Obsidian 1.11+ and are updated on rename. Use these settings:
@@ -130,6 +155,7 @@ vault = Knott.open(".") # walks up to the vault root
130
155
  result = vault.validate() # or vault.validate(["transcripts/foo.md"])
131
156
  result.ok, result.issues, result.stats
132
157
  vault.types() # ["script", "transcript"]
158
+ vault.ontology() # Ontology(vault, types, schema_issues)
133
159
  ```
134
160
 
135
161
  Validation problems come back as data; only usage errors raise (`KnottError` subclasses).
@@ -65,8 +65,9 @@ $ knott validate
65
65
  | Command | Purpose |
66
66
  |---|---|
67
67
  | `knott init [PATH]` | Create `.knott/schemas/` and `.knott/config.yaml` |
68
- | `knott validate [PATH...]` | Check all schemas, plus all entities or those under `PATH` (`--format json` for agents) |
69
- | `knott types [--verbose]` | List discovered types |
68
+ | `knott validate [PATH...]` | Check all schemas, plus all entities or those under `PATH` (`--format json` for agents, `--fix` to add missing `kid`s) |
69
+ | `knott types [--verbose]` | List discovered types (`--verbose`: attributes, nested shapes and relations) |
70
+ | `knott view [PATH]` | Draw the ontology as an HTML page and open it (`-o FILE`, `--no-open`) |
70
71
  | `knott version` | Print the installed version |
71
72
  | `knott skill install [PATH]` | Install the bundled Agent Skill to `.claude/skills` and/or `.agents/skills` (`--claude`, `--agents`; asks interactively without flags) |
72
73
 
@@ -74,7 +75,21 @@ Exit codes: `0` valid, `1` validation issues, `2` usage or configuration error.
74
75
 
75
76
  ## Schemas
76
77
 
77
- Schemas live in `.knott/schemas/**/*.yaml`, one type per file. Attribute types: `string`, `integer`, `number`, `boolean`, `date`, `datetime`. Typing is strict: an unquoted `no` is a boolean, not a string. Relations name a `target` type and are stored only on the source entity.
78
+ Schemas live in `.knott/schemas/**/*.yaml`, one type per file. Attribute types: `string`, `integer`, `number`, `boolean`, `date`, `datetime`, plus `list`, `object` and `map` built from them and nested to any depth. Typing is strict: an unquoted `no` is a boolean, not a string. Relations name a `target` type and are stored only on the source entity.
79
+
80
+ Structured attributes are checked at every level, and problems name their exact location, e.g. `senses[1].ru`:
81
+
82
+ ```yaml
83
+ attributes:
84
+ senses:
85
+ type: list
86
+ required: true
87
+ items:
88
+ type: object
89
+ fields:
90
+ id: {type: string, required: true}
91
+ ru: {type: string, required: true}
92
+ ```
78
93
 
79
94
  ## Relations
80
95
 
@@ -87,6 +102,16 @@ derived_from: "[Episode 42 script](../scripts/episode-42.md)"
87
102
 
88
103
  Wikilinks, URLs, `#fragments`, and absolute paths are rejected. Matching is case-sensitive on every OS.
89
104
 
105
+ ### Stable identity
106
+
107
+ `knott validate --fix` gives every entity a `kid`, a knott-managed UUID that survives moves and renames. A relation can then refer to it as `kid:<uuid>`. A schema can require one with `kid: required`. Markdown links stay the recommended form; use `kid:` where a reference must survive renames.
108
+
109
+ ```yaml
110
+ kid: 3f2b8c1e-9d4a-4c2e-b7f1-0a6d5e9c8b21
111
+ includes:
112
+ - kid:0192f4a1-7c3e-4b2a-9f10-3d5e8c2b4a61
113
+ ```
114
+
90
115
  ### Obsidian
91
116
 
92
117
  Markdown links in properties are clickable in Obsidian 1.11+ and are updated on rename. Use these settings:
@@ -103,6 +128,7 @@ vault = Knott.open(".") # walks up to the vault root
103
128
  result = vault.validate() # or vault.validate(["transcripts/foo.md"])
104
129
  result.ok, result.issues, result.stats
105
130
  vault.types() # ["script", "transcript"]
131
+ vault.ontology() # Ontology(vault, types, schema_issues)
106
132
  ```
107
133
 
108
134
  Validation problems come back as data; only usage errors raise (`KnottError` subclasses).
@@ -238,11 +238,15 @@ Allowed keys:
238
238
  |---|---|---|---|
239
239
  | top | `type` | yes | matches `^[a-z][a-z0-9_-]*$` |
240
240
  | top | `description` | no | string |
241
+ | top | `kid` | no | `required`: every entity of this type must have a `kid` (§12) |
241
242
  | top | `attributes` | no | mapping of field name → attribute definition |
242
243
  | top | `relations` | no | mapping of field name → relation definition |
243
- | attribute | `type` | yes | one of the scalar types in §8 |
244
+ | attribute | `type` | yes | a scalar type in §8, or `list`, `object` or `map` |
244
245
  | attribute | `required` | no | boolean, default `false` |
245
246
  | attribute | `description` | no | string |
247
+ | attribute | `items` | with `type: list` | the definition of each item (`type`, `description`, nesting keys; no `required`) |
248
+ | attribute | `fields` | with `type: object` | non-empty mapping of field name → attribute definition |
249
+ | attribute | `values` | with `type: map` | the definition of each value (`type`, `description`, nesting keys; no `required`) |
246
250
  | relation | `target` | yes | an existing schema `type` (self-reference allowed) |
247
251
  | relation | `required` | no | boolean, default `false` |
248
252
  | relation | `description` | no | string |
@@ -250,7 +254,8 @@ Allowed keys:
250
254
  Schema rules:
251
255
 
252
256
  - Unknown keys in a schema file are errors. Knott owns these files, so a typo such as `atributes:` must not pass silently.
253
- - Field names must not be `type`.
257
+ - Top-level field names must not be `type` or `kid`. Fields nested inside an `object` may be.
258
+ - `items`, `fields` and `values` are allowed only with their own `type`, and are required there.
254
259
  - A field name cannot be both an attribute and a relation in the same schema.
255
260
 
256
261
  Schemas serve three purposes:
@@ -286,7 +291,35 @@ Rules:
286
291
  - A key that is present with a `null` or empty value counts as absent.
287
292
  - `required: true` means the key is present and not null.
288
293
 
289
- Not in v0: enums, unions, lists, nested objects, custom scalars, inheritance, composition.
294
+ ### Structured attributes
295
+
296
+ An attribute can also be a `list` (every item matches `items`), an `object` (exactly the declared `fields`; objects are closed) or a `map` (free string keys; every value matches `values`). Shapes nest to any depth:
297
+
298
+ ```yaml
299
+ attributes:
300
+ senses:
301
+ type: list
302
+ required: true
303
+ items:
304
+ type: object
305
+ fields:
306
+ id: {type: string, required: true}
307
+ ru: {type: string, required: true}
308
+ forms:
309
+ type: map
310
+ values:
311
+ type: map
312
+ values: {type: string}
313
+ ```
314
+
315
+ - Every nested value is checked against its definition. Problems give the full path in `field` (`senses[1].ru`, `forms.sg.acc`) and the nested line.
316
+ - An empty container of the declared kind (`[]` for a list, `{}` for an object or map) counts as absent, so a required list needs at least one item. An empty container of another kind is a type mismatch. List items and map values are never absent.
317
+ - An undeclared key in an object is `attribute-unknown-field`. A non-string map key is a type mismatch.
318
+ - A value of the wrong kind is reported once, without checking its contents.
319
+
320
+ See `docs/decisions/0008-structured-attributes.md`.
321
+
322
+ Not in v0: enums, unions, relations inside structured values, item counts, named reusable shapes, custom scalars, inheritance, composition.
290
323
 
291
324
  ---
292
325
 
@@ -314,7 +347,7 @@ Reverse navigation is left to tools: Obsidian backlinks, or a future derived ind
314
347
 
315
348
  ## 11. Relation references
316
349
 
317
- In v0, relations use **relative filesystem paths**, not Knott IDs.
350
+ Relations use **relative filesystem paths** by default. A reference may also name an entity by its `kid` (§12).
318
351
 
319
352
  ### Value shape
320
353
 
@@ -370,6 +403,8 @@ target is a Knott entity → relation-target-not-entit
370
403
  target's type equals relation.target → relation-target-type-mismatch
371
404
  ```
372
405
 
406
+ A reference written `kid:<uuid>` skips the path steps. It must be a canonical lowercase UUID (`relation-invalid-value`; a `[label](kid:…)` link is rejected too), exactly one entity must have that `kid` (`relation-target-not-found`, or `relation-target-ambiguous` when several do), and then the type check runs as above.
407
+
373
408
  Use exact case matching so results are the same on case-insensitive filesystems (macOS) and case-sensitive ones (Linux).
374
409
 
375
410
  An unquoted `[label](path)` is not valid YAML, so it surfaces as `entity-invalid-frontmatter`. That error should also suggest quoting the value when the failing line looks like a Markdown link.
@@ -378,17 +413,23 @@ If the schema marks a relation `required: true`, the key must be present with at
378
413
 
379
414
  ---
380
415
 
381
- ## 12. Stable IDs
382
-
383
- Out of scope for v0. Paths are human-readable, inspectable, clickable, and Git-friendly.
416
+ ## 12. Stable identity: `kid`
384
417
 
385
- The design should not block a later
418
+ Every entity may carry a knott-managed identity that survives moves and renames:
386
419
 
387
420
  ```yaml
388
- id: some-stable-id
421
+ type: lexeme
422
+ kid: 3f2b8c1e-9d4a-4c2e-b7f1-0a6d5e9c8b21
389
423
  ```
390
424
 
391
- with a `path ↔ id` mapping. Concretely: keep relation resolution in one module (`vault/links.py`) behind a single function. Build no ID infrastructure now.
425
+ - `kid` is a reserved top-level key, like `type`. Its value is a canonical lowercase UUID (any version; knott generates v4). Other spellings are `kid-invalid`, and the message gives the canonical form.
426
+ - It is optional unless the schema says `kid: required` (`kid-missing`).
427
+ - It is unique across the vault, whatever the type. A duplicate is reported once (`kid-duplicate`), on the first claimant by path, naming every claimant. A scoped run reports a duplicate only if one of its claimants is in scope.
428
+ - `knott validate --fix` inserts `kid: <uuid4>` into every in-scope entity without a `kid` key: one line, after `type:` (or before the closing `---`), with the rest of the file unchanged, re-parsed before it is written. It never changes an existing `kid`, including duplicates. This is knott's only edit to user files.
429
+ - Relations may refer to an entity as `kid:<uuid>` (§11). Markdown links remain the default.
430
+ - Resolution stays behind `resolve_reference()` in `vault/links.py`. The `kid` index is built once per run, only when a run needs it.
431
+
432
+ A `kid` does not detect two entities describing the same concept. See `docs/decisions/0009-kid-identity.md`.
392
433
 
393
434
  ---
394
435
 
@@ -400,15 +441,17 @@ Validation is the primary feature of v0. A run loads all schemas, then validates
400
441
 
401
442
  - Each schema file is valid YAML and a mapping.
402
443
  - `type` is present and well-formed. No unknown keys (§7).
403
- - Each attribute has a known scalar `type`.
444
+ - Each attribute has a known `type`; `list`, `object` and `map` have their nested definition, recursively valid.
404
445
  - Each relation `target` names a discovered type.
446
+ - `kid`, when present, is `required`.
405
447
  - No duplicate `type` across files.
406
- - No field name collisions, and no field named `type`.
448
+ - No field name collisions, and no field named `type` or `kid`.
407
449
 
408
450
  ### Entity validation
409
451
 
410
452
  - `type` names a discovered schema (`entity-unknown-type`).
411
- - Declared attributes: required ones are present (`attribute-missing`) and values match their type (`attribute-type-mismatch`).
453
+ - `kid`: present when the schema requires it (`kid-missing`), a canonical UUID (`kid-invalid`), and unique (`kid-duplicate`).
454
+ - Declared attributes: required ones are present (`attribute-missing`) and values match their type (`attribute-type-mismatch`), at every nesting level. Declared objects have no undeclared keys (`attribute-unknown-field`).
412
455
  - Declared relations: checked as in §11.
413
456
  - Undeclared keys are allowed and not checked. Strict schemas may come later.
414
457
 
@@ -435,9 +478,11 @@ Keep the CLI deliberately small:
435
478
 
436
479
  ```
437
480
  knott init [PATH]
438
- knott validate [PATH...]
481
+ knott validate [PATH...] [--fix]
439
482
  knott types
440
483
  knott version
484
+ knott skill install [PATH]
485
+ knott view [PATH]
441
486
  ```
442
487
 
443
488
  ### `knott init [PATH]`
@@ -448,7 +493,7 @@ If `.knott/` already exists, it changes nothing, prints that the vault is alread
448
493
 
449
494
  ### `knott validate [PATH...]`
450
495
 
451
- See §13 for scope and §20 for output.
496
+ See §13 for scope and §20 for output. `--fix` first gives a `kid` to every in-scope entity that has none (§12), prints `+ kid <path>` for each, then validates. With `--format json`, the output gains `"fixed": [{path, kid}]`.
452
497
 
453
498
  ### `knott types`
454
499
 
@@ -466,6 +511,10 @@ If schema errors exist, `types` still prints the types it could load, writes the
466
511
 
467
512
  Prints the installed Knott version.
468
513
 
514
+ ### `knott view [PATH] [-o FILE] [--no-open]`
515
+
516
+ Writes the vault's ontology (types, attributes, relations, entity counts) as one self-contained static HTML page and opens it in the browser. No server and no network. Relations to undefined types point to a dashed "ghost" type. Schema errors still produce a page, with a note to run `knott validate`; a vault with no types exits with code `2`. See `docs/commands/view.md`.
517
+
469
518
  ---
470
519
 
471
520
  ## 15. Authoring
@@ -577,9 +626,11 @@ Success output:
577
626
  schema-invalid-yaml schema-invalid-field schema-duplicate-type
578
627
  schema-unknown-target schema-field-conflict
579
628
  entity-invalid-frontmatter entity-unknown-type not-an-entity
580
- attribute-missing attribute-type-mismatch
629
+ kid-missing kid-invalid kid-duplicate
630
+ attribute-missing attribute-type-mismatch attribute-unknown-field
581
631
  relation-missing relation-invalid-value relation-target-outside-vault
582
632
  relation-target-not-found relation-target-not-entity relation-target-type-mismatch
633
+ relation-target-ambiguous
583
634
  ```
584
635
 
585
636
  ### Exit codes
@@ -604,7 +655,9 @@ result = vault.validate() # or vault.validate(["transcripts/foo.md"])
604
655
  result.ok # bool
605
656
  result.issues # list[Issue], sorted
606
657
  result.stats # schemas / entities / relations counts
658
+ vault.validate(fix=True) # add missing kids first; result.fixed lists them
607
659
  types = vault.types() # list[str], sorted
660
+ ontology = vault.ontology() # Ontology: types with attributes, relations, counts
608
661
  ```
609
662
 
610
663
  `validate()` returns validation problems as data and never raises for them. It raises only for `2`-class conditions (`KnottError` subclasses in `errors.py`).
@@ -640,7 +693,7 @@ At minimum, test: schema discovery and parsing, entity detection, attribute typi
640
693
 
641
694
  Do not add, unless needed purely to meet the requirements above:
642
695
 
643
- database as source of truth · search indexes · semantic or vector search · embeddings · stable entity IDs · automatic inverse relations · global relation registry · RDF / OWL · inference or reasoning · schema inheritance, composition, or versioning · migration framework · UI · HTTP server · daemon · filesystem watcher · automatic knowledge extraction · automatic memory selection · agent deciding autonomously what to persist · plugin architecture · wikilink resolution.
696
+ database as source of truth · search indexes · semantic or vector search · embeddings · automatic inverse relations · global relation registry · RDF / OWL · inference or reasoning · schema inheritance, composition, or versioning · migration framework · UI (an interactive or served app; the static page `knott view` writes is not one) · HTTP server · daemon · filesystem watcher · automatic knowledge extraction · automatic memory selection · agent deciding autonomously what to persist · plugin architecture · wikilink resolution.
644
697
 
645
698
  Avoid speculative abstractions. Prefer the smallest implementation that satisfies the contract.
646
699
 
@@ -9,7 +9,7 @@ attributes:
9
9
  stage:
10
10
  type: string
11
11
  required: true
12
- description: Where it is detected - schema, entity, attribute, or relation.
12
+ description: Where it is detected - schema, entity, kid, attribute, or relation.
13
13
  relations:
14
14
  about:
15
15
  target: concept
@@ -17,7 +17,7 @@ This README has no frontmatter, so Knott treats it as an ordinary note.
17
17
 
18
18
  ## Concepts
19
19
 
20
- [Vault](concepts/vault.md) · [Entity](concepts/entity.md) · [Frontmatter](concepts/frontmatter.md) · [Schema](concepts/schema.md) · [Attribute](concepts/attribute.md) · [Relation](concepts/relation.md) · [Reference resolution](concepts/reference-resolution.md) · [Issue](concepts/issue.md) · [Ontology](concepts/ontology.md)
20
+ [Vault](concepts/vault.md) · [Entity](concepts/entity.md) · [Frontmatter](concepts/frontmatter.md) · [Schema](concepts/schema.md) · [Attribute](concepts/attribute.md) · [Relation](concepts/relation.md) · [Reference resolution](concepts/reference-resolution.md) · [Kid](concepts/kid.md) · [Issue](concepts/issue.md) · [Ontology](concepts/ontology.md)
21
21
 
22
22
  ## Guides
23
23
 
@@ -29,7 +29,7 @@ This README has no frontmatter, so Knott treats it as an ordinary note.
29
29
 
30
30
  ## Commands
31
31
 
32
- [init](commands/init.md) · [validate](commands/validate.md) · [types](commands/types.md) · [version](commands/version.md) · [skill](commands/skill.md)
32
+ [init](commands/init.md) · [validate](commands/validate.md) · [types](commands/types.md) · [version](commands/version.md) · [skill](commands/skill.md) · [view](commands/view.md)
33
33
 
34
34
  ## Issue codes
35
35
 
@@ -37,8 +37,9 @@ This README has no frontmatter, so Knott treats it as an ordinary note.
37
37
  |---|---|
38
38
  | schema | [schema-invalid-yaml](issues/schema-invalid-yaml.md) · [schema-invalid-field](issues/schema-invalid-field.md) · [schema-duplicate-type](issues/schema-duplicate-type.md) · [schema-unknown-target](issues/schema-unknown-target.md) · [schema-field-conflict](issues/schema-field-conflict.md) |
39
39
  | entity | [entity-invalid-frontmatter](issues/entity-invalid-frontmatter.md) · [entity-unknown-type](issues/entity-unknown-type.md) · [not-an-entity](issues/not-an-entity.md) |
40
- | attribute | [attribute-missing](issues/attribute-missing.md) · [attribute-type-mismatch](issues/attribute-type-mismatch.md) |
41
- | relation | [relation-missing](issues/relation-missing.md) · [relation-invalid-value](issues/relation-invalid-value.md) · [relation-target-outside-vault](issues/relation-target-outside-vault.md) · [relation-target-not-found](issues/relation-target-not-found.md) · [relation-target-not-entity](issues/relation-target-not-entity.md) · [relation-target-type-mismatch](issues/relation-target-type-mismatch.md) |
40
+ | kid | [kid-missing](issues/kid-missing.md) · [kid-invalid](issues/kid-invalid.md) · [kid-duplicate](issues/kid-duplicate.md) |
41
+ | attribute | [attribute-missing](issues/attribute-missing.md) · [attribute-type-mismatch](issues/attribute-type-mismatch.md) · [attribute-unknown-field](issues/attribute-unknown-field.md) |
42
+ | relation | [relation-missing](issues/relation-missing.md) · [relation-invalid-value](issues/relation-invalid-value.md) · [relation-target-outside-vault](issues/relation-target-outside-vault.md) · [relation-target-not-found](issues/relation-target-not-found.md) · [relation-target-not-entity](issues/relation-target-not-entity.md) · [relation-target-type-mismatch](issues/relation-target-type-mismatch.md) · [relation-target-ambiguous](issues/relation-target-ambiguous.md) |
42
43
 
43
44
  ## Design decisions
44
45
 
@@ -49,3 +50,5 @@ This README has no frontmatter, so Knott treats it as an ordinary note.
49
50
  5. [What counts as an empty value](decisions/0005-empty-values.md)
50
51
  6. [Symlinks cannot take a relation outside the vault](decisions/0006-symlinks-and-containment.md)
51
52
  7. [Hostile YAML is reported, never crashes or hangs](decisions/0007-parser-robustness.md)
53
+ 8. [Structured attributes use explicit keywords, and objects are closed](decisions/0008-structured-attributes.md)
54
+ 9. [Entities get a knott-managed `kid`](decisions/0009-kid-identity.md)
@@ -0,0 +1,30 @@
1
+ ---
2
+ type: command
3
+ title: knott types
4
+ synopsis: knott types [--verbose]
5
+ writes_files: false
6
+ concepts: "[Schema](../concepts/schema.md)"
7
+ ---
8
+ # knott types
9
+
10
+ Prints discovered type names, one per line, sorted. `--verbose` adds each type's schema file, description, attributes and relations, so an agent knows what to write before opening the YAML:
11
+
12
+ ```
13
+ $ knott types --verbose
14
+ lexeme (.knott/schemas/lexeme.yaml)
15
+ A word with its senses and forms.
16
+ attributes:
17
+ lemma* string
18
+ tags list of string
19
+ senses* list of object
20
+ each item: One sense per meaning.
21
+ id* string
22
+ ru* string Russian gloss
23
+ forms map of map of string
24
+ relations:
25
+ topic* → topic
26
+ ```
27
+
28
+ A type whose schema says `kid: required` shows `kid: required` under its description. `*` marks a required field. Object fields are indented under their attribute. A relation to a type no schema defines is marked `(undefined type)`. Types are separated by a blank line.
29
+
30
+ If some schemas have errors, it still prints the types it could load, writes the errors to stderr, and exits `1`.
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  type: command
3
3
  title: knott validate
4
- synopsis: knott validate [PATH...] [--format text|json]
5
- writes_files: false
4
+ synopsis: knott validate [PATH...] [--format text|json] [--fix]
5
+ writes_files: true
6
6
  concepts:
7
7
  - "[Schema](../concepts/schema.md)"
8
8
  - "[Entity](../concepts/entity.md)"
@@ -34,6 +34,20 @@ Success:
34
34
 
35
35
  `--format json` prints `{"ok": …, "stats": {…}, "issues": [{code, path, line, field, message}]}`, the form agents should parse.
36
36
 
37
+ ## `--fix`
38
+
39
+ Gives a [kid](../concepts/kid.md) to every checked entity that has no `kid` key, then validates. Each changed file is listed first:
40
+
41
+ ```
42
+ $ knott validate --fix lexemes/
43
+ + kid lexemes/namas.md
44
+
45
+ ✓ 2 schemas
46
+ …
47
+ ```
48
+
49
+ The edit is a single inserted line, `kid: <new uuid>`, after the `type:` line; nothing else in the file changes. `--fix` never touches an existing `kid`, even an empty, invalid or duplicated one. With `--format json`, the output gains `"fixed": [{"path", "kid"}]`. Without `--fix`, `validate` never writes.
50
+
37
51
  ## Exit codes
38
52
 
39
53
  | Code | Meaning |
@@ -0,0 +1,23 @@
1
+ ---
2
+ type: command
3
+ title: knott view
4
+ synopsis: knott view [PATH] [-o FILE] [--no-open]
5
+ writes_files: true
6
+ concepts:
7
+ - "[Ontology](../concepts/ontology.md)"
8
+ - "[Schema](../concepts/schema.md)"
9
+ ---
10
+ # knott view
11
+
12
+ Draws the vault's ontology as one static HTML page and opens it in the browser. `PATH` is any path inside the vault, default the current directory.
13
+
14
+ Each type is a box with its name and entity count. Each relation is an arrow: solid if required, dashed if optional. A relation to a type with no schema points to a dashed "ghost" box. Hover a type to highlight its neighbours. Click it to open a panel with its description, attributes, relations and the types that point to it.
15
+
16
+ Three layouts sit behind a toggle: **Layered** (default), **Force** and **Radial**. The page remembers the last one, and the URL hash (`#layered`, `#force`, `#radial`) selects one directly.
17
+
18
+ | Flag | Effect |
19
+ |---|---|
20
+ | `-o`, `--output FILE` | Write the page to `FILE`. Default: `knott-ontology-<vault>.html` in a private `knott-<uid>` folder in the temp directory, overwritten each run. |
21
+ | `--no-open` | Write the page without opening a browser. |
22
+
23
+ The page is self-contained: no server and no network. It prints `Wrote <path>` and exits `0`. If some schemas have errors, it still draws the types it could load, writes `N schema issues — run knott validate` to stderr, and exits `0`. If no browser opens, it writes `could not open a browser; open <path>` to stderr. A vault with no types, a `PATH` that doesn't exist, or an output file it cannot write (`error: cannot write <path>: …`) exits `2`. The default folder must be a real directory owned by you and closed to others; otherwise the command refuses to write there and exits `2`.
@@ -0,0 +1,68 @@
1
+ ---
2
+ type: concept
3
+ title: Attribute
4
+ summary: A typed value that belongs to the entity itself (a scalar, list, object or map), declared under `attributes:` in its schema.
5
+ spec_section: "§8"
6
+ related:
7
+ - "[Schema](schema.md)"
8
+ - "[Frontmatter](frontmatter.md)"
9
+ ---
10
+ # Attribute
11
+
12
+ An attribute is a scalar, or a **list**, **object** or **map** built from scalars and nested to any depth.
13
+
14
+ ## Scalars
15
+
16
+ Typing is strict. There is no coercion beyond this table:
17
+
18
+ | Type | Accepts | Rejects |
19
+ |---|---|---|
20
+ | `string` | YAML strings | numbers, booleans, dates (unquoted `42`, `no`, `2026-10-06`) |
21
+ | `integer` | YAML integers | booleans, floats |
22
+ | `number` | integers and floats | booleans |
23
+ | `boolean` | `true` / `false` | everything else, including `yes`/`no`/`on`/`off` |
24
+ | `date` | YAML date, or `"2026-10-06"` | datetimes |
25
+ | `datetime` | YAML timestamp, or ISO 8601 string with a time | plain dates |
26
+
27
+ ## Lists, objects and maps
28
+
29
+ ```yaml
30
+ attributes:
31
+ tags:
32
+ type: list
33
+ items: {type: string}
34
+ senses:
35
+ type: list
36
+ required: true
37
+ items:
38
+ type: object
39
+ description: One sense per meaning.
40
+ fields:
41
+ id: {type: string, required: true}
42
+ ru: {type: string, required: true, description: Russian gloss}
43
+ forms: # forms.sg.nom, forms.pl.gen, …
44
+ type: map
45
+ values:
46
+ type: map
47
+ values: {type: string}
48
+ ```
49
+
50
+ | `type` | Holds | Nested key |
51
+ |---|---|---|
52
+ | `list` | a YAML sequence; every item matches `items` | `items` (a definition) |
53
+ | `object` | a YAML mapping with exactly the declared keys | `fields` (name → definition) |
54
+ | `map` | a YAML mapping with free string keys; every value matches `values` | `values` (a definition) |
55
+
56
+ - Object fields take `type`, `required` and `description`, like top-level attributes. A field may be named `type`.
57
+ - `items` and `values` take `type` and `description`, but not `required`.
58
+ - Objects are **closed**: an undeclared key is `attribute-unknown-field`. Use a `map` when the keys are free.
59
+ - Map keys must be strings; quote keys that YAML would read as numbers or booleans.
60
+ - Problems name the exact location, e.g. `senses[1].ru` or `forms.sg.acc`, with its line.
61
+
62
+ See [decision 0008](../decisions/0008-structured-attributes.md).
63
+
64
+ ## Absent values
65
+
66
+ A key that is present with `null` or an empty string counts as **absent**. So does an empty container of the declared kind: `[]` for a list, `{}` for an object or map. `required: true` means present and not empty, so a required list needs at least one item. An empty container of another kind (`title: []`) is a type mismatch. A list item or map value is never absent. See [decision 0005](../decisions/0005-empty-values.md).
67
+
68
+ Not supported yet: enums, unions, relations inside structured values, item counts, custom scalars.
@@ -0,0 +1,50 @@
1
+ ---
2
+ type: concept
3
+ title: Kid
4
+ summary: The knott-managed identity of an entity, a lowercase UUID under the reserved `kid` key, which survives moves and renames.
5
+ spec_section: "§12"
6
+ related:
7
+ - "[Entity](entity.md)"
8
+ - "[Reference resolution](reference-resolution.md)"
9
+ - "[Schema](schema.md)"
10
+ ---
11
+ # Kid
12
+
13
+ A **kid** ("knott id") identifies an entity independently of its file path:
14
+
15
+ ```yaml
16
+ ---
17
+ type: lexeme
18
+ kid: 3f2b8c1e-9d4a-4c2e-b7f1-0a6d5e9c8b21
19
+ lemma: restoranas
20
+ ---
21
+ ```
22
+
23
+ - **Reserved.** `kid` is a top-level frontmatter key owned by knott, like `type`. A schema can't declare a field named `kid` (a field inside an `object` attribute can).
24
+ - **Format.** A canonical lowercase UUID: `8-4-4-4-12` hex digits, any version. Uppercase or `{…}` forms are rejected, and the message gives the lowercase form.
25
+ - **Unique** across the whole vault, whatever the type. A duplicate is reported once, naming every file that claims it.
26
+ - **Optional** unless the type's schema says `kid: required`.
27
+
28
+ ## Getting one
29
+
30
+ Don't invent one by hand. Run:
31
+
32
+ ```sh
33
+ knott validate --fix [PATH...]
34
+ ```
35
+
36
+ Every checked entity without a `kid` key gets `kid: <new uuid>`, inserted as one line after `type:`. Nothing else in the file changes. An entity whose `kid` is present but empty or invalid is left for you to fix, and so is a duplicate.
37
+
38
+ **Copying a file copies its `kid`.** Delete the `kid:` line from the copy, then run `--fix`.
39
+
40
+ ## Referring to it
41
+
42
+ ```yaml
43
+ includes:
44
+ - "[Draugas](../lexemes/draugas.md)" # default: a clickable Markdown link
45
+ - kid:3f2b8c1e-9d4a-4c2e-b7f1-0a6d5e9c8b21 # survives moves and renames
46
+ ```
47
+
48
+ A `kid:` reference is checked like a path: the entity exists, and its type matches the relation's `target`. It must be written on its own, not inside a Markdown link. See [Reference resolution](reference-resolution.md).
49
+
50
+ A `kid` does **not** stop two files from describing the same concept; each just gets its own `kid`. See [decision 0009](../decisions/0009-kid-identity.md).
@@ -26,16 +26,18 @@ decision ──── affects ───────┘
26
26
  decision ── supersedes ──▶ decision
27
27
  ```
28
28
 
29
- | Type | Holds | Key relations |
30
- |---|---|---|
31
- | `concept` | the model's core ideas | `related → concept` |
32
- | `command` | CLI commands | `concepts → concept` |
33
- | `issue_code` | every validation code, cause and fix | `about → concept` (required) |
34
- | `guide` | how-tos | `concepts → concept`, `commands → command` |
35
- | `decision` | design records | `affects → concept` (required), `supersedes → decision` |
29
+ | Type | Holds | Key relations |
30
+ | ------------ | ------------------------------------ | ------------------------------------------------------- |
31
+ | `concept` | the model's core ideas | `related → concept` |
32
+ | `command` | CLI commands | `concepts → concept` |
33
+ | `issue_code` | every validation code, cause and fix | `about → concept` (required) |
34
+ | `guide` | how-tos | `concepts → concept`, `commands → command` |
35
+ | `decision` | design records | `affects → concept` (required), `supersedes → decision` |
36
36
 
37
37
  Run `knott types --verbose` inside `docs/` to see them, and `knott validate` to check the whole folder.
38
38
 
39
+ Run `knott view` inside `docs/` to explore it interactively.
40
+
39
41
  ## Designing your own
40
42
 
41
43
  - Start with 2–4 types. Add one when you find yourself writing the same frontmatter keys repeatedly.
@@ -20,6 +20,17 @@ Each reference is resolved **relative to the directory of the file that contains
20
20
  | 5 | target is a Knott entity | `relation-target-not-entity` |
21
21
  | 6 | target's `type` equals the relation's `target` | `relation-target-type-mismatch` |
22
22
 
23
+ ## `kid:` references
24
+
25
+ A reference written `kid:<uuid>` names an entity by its [kid](kid.md) instead of its path, so it survives moves and renames. Steps 2–4 are replaced by:
26
+
27
+ | # | Check | Failure code |
28
+ |---|---|---|
29
+ | 2 | the value after `kid:` is a canonical lowercase UUID, written on its own (not as `[label](kid:…)`) | `relation-invalid-value` |
30
+ | 3 | exactly one entity has that `kid` | `relation-target-not-found`, or `relation-target-ambiguous` when several do |
31
+
32
+ Steps 5 and 6 then run as for a path. Markdown links remain the default form, because they are readable and clickable in Obsidian.
33
+
23
34
  ## Markdown links
24
35
 
25
36
  `[label](destination)`: the label is ignored. The destination may be wrapped in `<…>` (needed for spaces) or percent-encoded (`%20`). In YAML the whole thing must be quoted.
@@ -32,4 +43,4 @@ macOS filesystems are case-insensitive by default, Linux's are not. Matching cas
32
43
 
33
44
  Wikilinks (`[[note]]`): they resolve by note name rather than path. An unquoted `[[note]]` is even parsed by YAML as a nested list.
34
45
 
35
- All of this lives behind one function, `resolve_reference()` in `src/knott/vault/links.py`, so stable IDs can replace paths later without touching anything else.
46
+ All of this lives behind one function, `resolve_reference()` in `src/knott/vault/links.py`.
@@ -14,3 +14,5 @@ affects:
14
14
  **Decision.** v0 references are relative filesystem paths (plain, or as a Markdown link). Wikilinks are rejected because they resolve by name, not path.
15
15
 
16
16
  **Consequences.** Links are human-readable, clickable in Obsidian, and Git-friendly. Renames can break them, so Knott reports `relation-target-not-found` and Obsidian's link updating covers the common case. All resolution sits behind one function, `resolve_reference()`, so an `id:` scheme can be added later in one place.
17
+
18
+ **Amended 2026-10-22** by [0009](0009-kid-identity.md): relations may also be written `kid:<uuid>`, resolved through the same function. Relative paths, and Markdown links in particular, remain the default and recommended form.