@cavelang/cli 0.35.0 → 0.36.1

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 (327) hide show
  1. package/README.md +224 -12
  2. package/dist/internal/act/action.js +2 -1
  3. package/dist/internal/act/action.js.map +1 -1
  4. package/dist/internal/act/declare.d.ts.map +1 -1
  5. package/dist/internal/act/declare.js +82 -53
  6. package/dist/internal/act/declare.js.map +1 -1
  7. package/dist/internal/act/engine.d.ts +4 -3
  8. package/dist/internal/act/engine.d.ts.map +1 -1
  9. package/dist/internal/act/engine.js +121 -32
  10. package/dist/internal/act/engine.js.map +1 -1
  11. package/dist/internal/automate/cancellation.d.ts +3 -0
  12. package/dist/internal/automate/cancellation.d.ts.map +1 -0
  13. package/dist/internal/automate/cancellation.js +38 -0
  14. package/dist/internal/automate/cancellation.js.map +1 -0
  15. package/dist/internal/automate/declare.d.ts.map +1 -1
  16. package/dist/internal/automate/declare.js +49 -24
  17. package/dist/internal/automate/declare.js.map +1 -1
  18. package/dist/internal/automate/engine.d.ts +7 -3
  19. package/dist/internal/automate/engine.d.ts.map +1 -1
  20. package/dist/internal/automate/engine.js +196 -93
  21. package/dist/internal/automate/engine.js.map +1 -1
  22. package/dist/internal/automate/error-message.d.ts +3 -0
  23. package/dist/internal/automate/error-message.d.ts.map +1 -0
  24. package/dist/internal/automate/error-message.js +10 -0
  25. package/dist/internal/automate/error-message.js.map +1 -0
  26. package/dist/internal/automate/main.d.ts.map +1 -1
  27. package/dist/internal/automate/main.js +238 -35
  28. package/dist/internal/automate/main.js.map +1 -1
  29. package/dist/internal/automate/options.d.ts +4 -0
  30. package/dist/internal/automate/options.d.ts.map +1 -0
  31. package/dist/internal/automate/options.js +19 -0
  32. package/dist/internal/automate/options.js.map +1 -0
  33. package/dist/internal/connect/declared.d.ts +6 -27
  34. package/dist/internal/connect/declared.d.ts.map +1 -1
  35. package/dist/internal/connect/declared.js +165 -76
  36. package/dist/internal/connect/declared.js.map +1 -1
  37. package/dist/internal/connect/error-message.d.ts +3 -0
  38. package/dist/internal/connect/error-message.d.ts.map +1 -0
  39. package/dist/internal/connect/error-message.js +10 -0
  40. package/dist/internal/connect/error-message.js.map +1 -0
  41. package/dist/internal/connect/federation.d.ts +9 -0
  42. package/dist/internal/connect/federation.d.ts.map +1 -0
  43. package/dist/internal/connect/federation.js +19 -0
  44. package/dist/internal/connect/federation.js.map +1 -0
  45. package/dist/internal/connect/fetch-failure.d.ts +3 -0
  46. package/dist/internal/connect/fetch-failure.d.ts.map +1 -0
  47. package/dist/internal/connect/fetch-failure.js +36 -0
  48. package/dist/internal/connect/fetch-failure.js.map +1 -0
  49. package/dist/internal/connect/main.d.ts +1 -0
  50. package/dist/internal/connect/main.d.ts.map +1 -1
  51. package/dist/internal/connect/main.js +288 -114
  52. package/dist/internal/connect/main.js.map +1 -1
  53. package/dist/internal/connect/options.d.ts +3 -0
  54. package/dist/internal/connect/options.d.ts.map +1 -0
  55. package/dist/internal/connect/options.js +9 -0
  56. package/dist/internal/connect/options.js.map +1 -0
  57. package/dist/internal/connect/records.d.ts +3 -0
  58. package/dist/internal/connect/records.d.ts.map +1 -0
  59. package/dist/internal/connect/records.js +21 -0
  60. package/dist/internal/connect/records.js.map +1 -0
  61. package/dist/internal/connect/run.d.ts +1 -18
  62. package/dist/internal/connect/run.d.ts.map +1 -1
  63. package/dist/internal/connect/run.js +115 -55
  64. package/dist/internal/connect/run.js.map +1 -1
  65. package/dist/internal/connect/source.d.ts +3 -1
  66. package/dist/internal/connect/source.d.ts.map +1 -1
  67. package/dist/internal/connect/source.js +226 -47
  68. package/dist/internal/connect/source.js.map +1 -1
  69. package/dist/internal/connect/template.d.ts +2 -2
  70. package/dist/internal/connect/template.d.ts.map +1 -1
  71. package/dist/internal/connect/template.js +25 -9
  72. package/dist/internal/connect/template.js.map +1 -1
  73. package/dist/internal/connect/utf8.d.ts +3 -0
  74. package/dist/internal/connect/utf8.d.ts.map +1 -0
  75. package/dist/internal/connect/utf8.js +12 -0
  76. package/dist/internal/connect/utf8.js.map +1 -0
  77. package/dist/internal/eval/cleanup.d.ts +5 -0
  78. package/dist/internal/eval/cleanup.d.ts.map +1 -0
  79. package/dist/internal/eval/cleanup.js +50 -0
  80. package/dist/internal/eval/cleanup.js.map +1 -0
  81. package/dist/internal/eval/error-message.d.ts +3 -0
  82. package/dist/internal/eval/error-message.d.ts.map +1 -0
  83. package/dist/internal/eval/error-message.js +10 -0
  84. package/dist/internal/eval/error-message.js.map +1 -0
  85. package/dist/internal/eval/judge.d.ts.map +1 -1
  86. package/dist/internal/eval/judge.js +3 -31
  87. package/dist/internal/eval/judge.js.map +1 -1
  88. package/dist/internal/eval/loop.d.ts.map +1 -1
  89. package/dist/internal/eval/loop.js +18 -4
  90. package/dist/internal/eval/loop.js.map +1 -1
  91. package/dist/internal/eval/main.d.ts.map +1 -1
  92. package/dist/internal/eval/main.js +22 -10
  93. package/dist/internal/eval/main.js.map +1 -1
  94. package/dist/internal/eval/options.d.ts +6 -0
  95. package/dist/internal/eval/options.d.ts.map +1 -0
  96. package/dist/internal/eval/options.js +31 -0
  97. package/dist/internal/eval/options.js.map +1 -0
  98. package/dist/internal/eval/queries.d.ts.map +1 -1
  99. package/dist/internal/eval/queries.js +9 -6
  100. package/dist/internal/eval/queries.js.map +1 -1
  101. package/dist/internal/eval/run.d.ts.map +1 -1
  102. package/dist/internal/eval/run.js +112 -24
  103. package/dist/internal/eval/run.js.map +1 -1
  104. package/dist/internal/eval/score.d.ts.map +1 -1
  105. package/dist/internal/eval/score.js +9 -2
  106. package/dist/internal/eval/score.js.map +1 -1
  107. package/dist/internal/eval/suite.d.ts.map +1 -1
  108. package/dist/internal/eval/suite.js +14 -2
  109. package/dist/internal/eval/suite.js.map +1 -1
  110. package/dist/internal/ingest/cleanup.d.ts +5 -0
  111. package/dist/internal/ingest/cleanup.d.ts.map +1 -0
  112. package/dist/internal/ingest/cleanup.js +50 -0
  113. package/dist/internal/ingest/cleanup.js.map +1 -0
  114. package/dist/internal/ingest/content.d.ts +6 -0
  115. package/dist/internal/ingest/content.d.ts.map +1 -0
  116. package/dist/internal/ingest/content.js +25 -0
  117. package/dist/internal/ingest/content.js.map +1 -0
  118. package/dist/internal/ingest/context.d.ts.map +1 -1
  119. package/dist/internal/ingest/context.js +25 -7
  120. package/dist/internal/ingest/context.js.map +1 -1
  121. package/dist/internal/ingest/error-message.d.ts +3 -0
  122. package/dist/internal/ingest/error-message.d.ts.map +1 -0
  123. package/dist/internal/ingest/error-message.js +10 -0
  124. package/dist/internal/ingest/error-message.js.map +1 -0
  125. package/dist/internal/ingest/files.d.ts +4 -12
  126. package/dist/internal/ingest/files.d.ts.map +1 -1
  127. package/dist/internal/ingest/files.js +22 -10
  128. package/dist/internal/ingest/files.js.map +1 -1
  129. package/dist/internal/ingest/main.d.ts.map +1 -1
  130. package/dist/internal/ingest/main.js +46 -16
  131. package/dist/internal/ingest/main.js.map +1 -1
  132. package/dist/internal/ingest/options.d.ts +6 -0
  133. package/dist/internal/ingest/options.d.ts.map +1 -0
  134. package/dist/internal/ingest/options.js +27 -0
  135. package/dist/internal/ingest/options.js.map +1 -0
  136. package/dist/internal/ingest/prompt.d.ts.map +1 -1
  137. package/dist/internal/ingest/prompt.js +14 -10
  138. package/dist/internal/ingest/prompt.js.map +1 -1
  139. package/dist/internal/ingest/run.d.ts +9 -2
  140. package/dist/internal/ingest/run.d.ts.map +1 -1
  141. package/dist/internal/ingest/run.js +206 -62
  142. package/dist/internal/ingest/run.js.map +1 -1
  143. package/dist/internal/ingest/timeout.d.ts +3 -0
  144. package/dist/internal/ingest/timeout.d.ts.map +1 -0
  145. package/dist/internal/ingest/timeout.js +14 -0
  146. package/dist/internal/ingest/timeout.js.map +1 -0
  147. package/dist/internal/ingest/web.d.ts +2 -11
  148. package/dist/internal/ingest/web.d.ts.map +1 -1
  149. package/dist/internal/ingest/web.js +131 -25
  150. package/dist/internal/ingest/web.js.map +1 -1
  151. package/dist/internal/loop/budgets.d.ts +3 -0
  152. package/dist/internal/loop/budgets.d.ts.map +1 -0
  153. package/dist/internal/loop/budgets.js +10 -0
  154. package/dist/internal/loop/budgets.js.map +1 -0
  155. package/dist/internal/loop/index.d.ts +2 -0
  156. package/dist/internal/loop/index.d.ts.map +1 -1
  157. package/dist/internal/loop/index.js +2 -0
  158. package/dist/internal/loop/index.js.map +1 -1
  159. package/dist/internal/loop/json-answer.d.ts +7 -0
  160. package/dist/internal/loop/json-answer.d.ts.map +1 -0
  161. package/dist/internal/loop/json-answer.js +79 -0
  162. package/dist/internal/loop/json-answer.js.map +1 -0
  163. package/dist/internal/loop/json-spans.d.ts +3 -0
  164. package/dist/internal/loop/json-spans.d.ts.map +1 -0
  165. package/dist/internal/loop/json-spans.js +88 -0
  166. package/dist/internal/loop/json-spans.js.map +1 -0
  167. package/dist/internal/loop/llm.d.ts +3 -2
  168. package/dist/internal/loop/llm.d.ts.map +1 -1
  169. package/dist/internal/loop/llm.js +115 -32
  170. package/dist/internal/loop/llm.js.map +1 -1
  171. package/dist/internal/loop/process.d.ts +3 -1
  172. package/dist/internal/loop/process.d.ts.map +1 -1
  173. package/dist/internal/loop/process.js +159 -59
  174. package/dist/internal/loop/process.js.map +1 -1
  175. package/dist/internal/loop/read-snapshot.d.ts +4 -0
  176. package/dist/internal/loop/read-snapshot.d.ts.map +1 -0
  177. package/dist/internal/loop/read-snapshot.js +29 -0
  178. package/dist/internal/loop/read-snapshot.js.map +1 -0
  179. package/dist/internal/loop/reconstruct.d.ts +6 -5
  180. package/dist/internal/loop/reconstruct.d.ts.map +1 -1
  181. package/dist/internal/loop/reconstruct.js +19 -8
  182. package/dist/internal/loop/reconstruct.js.map +1 -1
  183. package/dist/internal/loop/score-settings.d.ts +5 -0
  184. package/dist/internal/loop/score-settings.d.ts.map +1 -0
  185. package/dist/internal/loop/score-settings.js +14 -0
  186. package/dist/internal/loop/score-settings.js.map +1 -0
  187. package/dist/internal/loop/sqlite.d.ts.map +1 -1
  188. package/dist/internal/loop/sqlite.js +15 -7
  189. package/dist/internal/loop/sqlite.js.map +1 -1
  190. package/dist/internal/loop/store.d.ts.map +1 -1
  191. package/dist/internal/loop/store.js +11 -7
  192. package/dist/internal/loop/store.js.map +1 -1
  193. package/dist/internal/loop/timeout.d.ts +3 -0
  194. package/dist/internal/loop/timeout.d.ts.map +1 -0
  195. package/dist/internal/loop/timeout.js +13 -0
  196. package/dist/internal/loop/timeout.js.map +1 -0
  197. package/dist/internal/mcp/error-message.d.ts +3 -0
  198. package/dist/internal/mcp/error-message.d.ts.map +1 -0
  199. package/dist/internal/mcp/error-message.js +10 -0
  200. package/dist/internal/mcp/error-message.js.map +1 -0
  201. package/dist/internal/mcp/main.d.ts.map +1 -1
  202. package/dist/internal/mcp/main.js +42 -27
  203. package/dist/internal/mcp/main.js.map +1 -1
  204. package/dist/internal/mcp/read-snapshot.d.ts +4 -0
  205. package/dist/internal/mcp/read-snapshot.d.ts.map +1 -0
  206. package/dist/internal/mcp/read-snapshot.js +22 -0
  207. package/dist/internal/mcp/read-snapshot.js.map +1 -0
  208. package/dist/internal/mcp/server.d.ts.map +1 -1
  209. package/dist/internal/mcp/server.js +181 -21
  210. package/dist/internal/mcp/server.js.map +1 -1
  211. package/dist/internal/mcp/source.d.ts +3 -0
  212. package/dist/internal/mcp/source.d.ts.map +1 -0
  213. package/dist/internal/mcp/source.js +13 -0
  214. package/dist/internal/mcp/source.js.map +1 -0
  215. package/dist/internal/mcp/tools.d.ts.map +1 -1
  216. package/dist/internal/mcp/tools.js +135 -72
  217. package/dist/internal/mcp/tools.js.map +1 -1
  218. package/dist/internal/rules/declarations.d.ts +6 -0
  219. package/dist/internal/rules/declarations.d.ts.map +1 -0
  220. package/dist/internal/rules/declarations.js +14 -0
  221. package/dist/internal/rules/declarations.js.map +1 -0
  222. package/dist/internal/rules/declare.d.ts.map +1 -1
  223. package/dist/internal/rules/declare.js +30 -16
  224. package/dist/internal/rules/declare.js.map +1 -1
  225. package/dist/internal/rules/engine.d.ts +8 -7
  226. package/dist/internal/rules/engine.d.ts.map +1 -1
  227. package/dist/internal/rules/engine.js +150 -44
  228. package/dist/internal/rules/engine.js.map +1 -1
  229. package/dist/internal/shape/alias-root.d.ts +3 -0
  230. package/dist/internal/shape/alias-root.d.ts.map +1 -0
  231. package/dist/internal/shape/alias-root.js +13 -0
  232. package/dist/internal/shape/alias-root.js.map +1 -0
  233. package/dist/internal/shape/check.d.ts +15 -3
  234. package/dist/internal/shape/check.d.ts.map +1 -1
  235. package/dist/internal/shape/check.js +230 -100
  236. package/dist/internal/shape/check.js.map +1 -1
  237. package/dist/internal/shape/client.d.ts.map +1 -1
  238. package/dist/internal/shape/client.js +42 -20
  239. package/dist/internal/shape/client.js.map +1 -1
  240. package/dist/internal/shape/constraints.d.ts +8 -0
  241. package/dist/internal/shape/constraints.d.ts.map +1 -0
  242. package/dist/internal/shape/constraints.js +17 -0
  243. package/dist/internal/shape/constraints.js.map +1 -0
  244. package/dist/internal/shape/edit-distance.d.ts +3 -0
  245. package/dist/internal/shape/edit-distance.d.ts.map +1 -0
  246. package/dist/internal/shape/edit-distance.js +33 -0
  247. package/dist/internal/shape/edit-distance.js.map +1 -0
  248. package/dist/internal/shape/gate.d.ts.map +1 -1
  249. package/dist/internal/shape/gate.js +0 -0
  250. package/dist/internal/shape/gate.js.map +1 -1
  251. package/dist/internal/shape/snapshot.d.ts +4 -0
  252. package/dist/internal/shape/snapshot.d.ts.map +1 -0
  253. package/dist/internal/shape/snapshot.js +20 -0
  254. package/dist/internal/shape/snapshot.js.map +1 -0
  255. package/dist/internal/shape/suggest.d.ts +8 -6
  256. package/dist/internal/shape/suggest.d.ts.map +1 -1
  257. package/dist/internal/shape/suggest.js +208 -92
  258. package/dist/internal/shape/suggest.js.map +1 -1
  259. package/dist/internal/sync/error-message.d.ts +3 -0
  260. package/dist/internal/sync/error-message.d.ts.map +1 -0
  261. package/dist/internal/sync/error-message.js +10 -0
  262. package/dist/internal/sync/error-message.js.map +1 -0
  263. package/dist/internal/sync/index.d.ts +3 -2
  264. package/dist/internal/sync/index.d.ts.map +1 -1
  265. package/dist/internal/sync/index.js +3 -2
  266. package/dist/internal/sync/index.js.map +1 -1
  267. package/dist/internal/sync/sync.d.ts +8 -5
  268. package/dist/internal/sync/sync.d.ts.map +1 -1
  269. package/dist/internal/sync/sync.js +322 -65
  270. package/dist/internal/sync/sync.js.map +1 -1
  271. package/dist/internal/view/api.d.ts +3 -1
  272. package/dist/internal/view/api.d.ts.map +1 -1
  273. package/dist/internal/view/api.js +154 -90
  274. package/dist/internal/view/api.js.map +1 -1
  275. package/dist/internal/view/error-message.d.ts +3 -0
  276. package/dist/internal/view/error-message.d.ts.map +1 -0
  277. package/dist/internal/view/error-message.js +10 -0
  278. package/dist/internal/view/error-message.js.map +1 -0
  279. package/dist/internal/view/main.d.ts.map +1 -1
  280. package/dist/internal/view/main.js +61 -8
  281. package/dist/internal/view/main.js.map +1 -1
  282. package/dist/internal/view/page.d.ts.map +1 -1
  283. package/dist/internal/view/page.js +119 -20
  284. package/dist/internal/view/page.js.map +1 -1
  285. package/dist/internal/view/report.d.ts.map +1 -1
  286. package/dist/internal/view/report.js +180 -145
  287. package/dist/internal/view/report.js.map +1 -1
  288. package/dist/internal/view/scope.d.ts +6 -2
  289. package/dist/internal/view/scope.d.ts.map +1 -1
  290. package/dist/internal/view/scope.js +107 -24
  291. package/dist/internal/view/scope.js.map +1 -1
  292. package/dist/internal/view/sensitivity.d.ts +4 -0
  293. package/dist/internal/view/sensitivity.d.ts.map +1 -0
  294. package/dist/internal/view/sensitivity.js +11 -0
  295. package/dist/internal/view/sensitivity.js.map +1 -0
  296. package/dist/internal/view/server.d.ts.map +1 -1
  297. package/dist/internal/view/server.js +57 -20
  298. package/dist/internal/view/server.js.map +1 -1
  299. package/dist/src/atomic-output.d.ts +3 -0
  300. package/dist/src/atomic-output.d.ts.map +1 -0
  301. package/dist/src/atomic-output.js +67 -0
  302. package/dist/src/atomic-output.js.map +1 -0
  303. package/dist/src/cli.d.ts +3 -2
  304. package/dist/src/cli.d.ts.map +1 -1
  305. package/dist/src/cli.js +188 -173
  306. package/dist/src/cli.js.map +1 -1
  307. package/dist/src/dispatch.d.ts.map +1 -1
  308. package/dist/src/dispatch.js +3 -2
  309. package/dist/src/dispatch.js.map +1 -1
  310. package/dist/src/doctor.d.ts.map +1 -1
  311. package/dist/src/doctor.js +178 -102
  312. package/dist/src/doctor.js.map +1 -1
  313. package/dist/src/error-message.d.ts +3 -0
  314. package/dist/src/error-message.d.ts.map +1 -0
  315. package/dist/src/error-message.js +20 -0
  316. package/dist/src/error-message.js.map +1 -0
  317. package/dist/src/hooks-config.d.ts +3 -0
  318. package/dist/src/hooks-config.d.ts.map +1 -0
  319. package/dist/src/hooks-config.js +23 -0
  320. package/dist/src/hooks-config.js.map +1 -0
  321. package/package.json +23 -20
  322. package/src/atomic-output.ts +47 -0
  323. package/src/cli.ts +170 -147
  324. package/src/dispatch.ts +3 -2
  325. package/src/doctor.ts +192 -111
  326. package/src/error-message.ts +13 -0
  327. package/src/hooks-config.ts +22 -0
package/README.md CHANGED
@@ -3,8 +3,19 @@
3
3
  The `cave` command — the whole stack behind one binary. Runs directly from
4
4
  TypeScript sources in the workspace; npm releases contain emitted JavaScript.
5
5
 
6
- The supported Node.js lines are 22, 24, and 26: 22.18.0 is the exact minimum,
7
- 24.18.0 Active LTS is recommended, and 26.4.0 Current is also tested. Linux,
6
+ The shared CAVE text reader requires valid UTF-8 in files and standard input.
7
+ Malformed bytes produce a filename or stdin diagnostic instead of silently
8
+ becoming replacement characters. `parse`, `add` and `import` return status 1
9
+ without stdout on this decoding error; invalid additions/imports leave existing
10
+ history unchanged, and `add` rejects the input before creating a missing database.
11
+ Explicit replacement characters, accented text and emoji remain valid input.
12
+ Action execution and doctor share hook-file validation: configuration must be
13
+ valid UTF-8 JSON mapping nonblank names to command strings, with no unpaired
14
+ surrogates in names or commands. Invalid configuration fails before action
15
+ effects; doctor reports the failure without revealing configuration contents.
16
+
17
+ The supported Node.js lines are 24 and 26: 24.16.0 and 26.1.0 are their exact minimums,
18
+ 24.21.0 Active LTS is recommended, and 26.8.2 Current is also tested. Linux,
8
19
  macOS, and Windows are supported; CI represents them with Ubuntu 24.04, macOS
9
20
  15, and Windows Server 2022 and exercises the CLI's native, filesystem,
10
21
  process, and built-package paths on each.
@@ -57,6 +68,14 @@ The source modules remain separate private workspace packages for focused
57
68
  ownership and tests. See [the package migration table](../../PACKAGE_SURFACES.md)
58
69
  when updating an import from a former standalone package name.
59
70
 
71
+ The CLI build checks literal runtime imports in its published `dist/src` and
72
+ `dist/internal` trees after consolidation. External package roots must appear
73
+ in the CLI's dependencies, optional dependencies or peer dependencies; a private
74
+ workspace's development dependency alone is insufficient. Diagnostics identify
75
+ the importing file and package. Compiled tests are excluded. Computed import
76
+ names, package-local aliases, export targets and actual dependency availability
77
+ still require the installed-package smoke checks.
78
+
60
79
  ## Commands
61
80
 
62
81
  ### JSON compatibility
@@ -70,6 +89,12 @@ replace any nested database rows with the same claim record and never expose
70
89
  `claim_key`, `raw_line`, or `value_text` columns. New optional fields may be
71
90
  added within a version; incompatible shape changes require a new version.
72
91
 
92
+ Query parse failures exit with status 1 and write diagnostics to stderr, leaving
93
+ stdout empty even with `--json`. Filter line numbers count blank and comment
94
+ lines in the supplied query; separate positional arguments join with newlines.
95
+ Confidence thresholds must be finite. Correcting a failed query requires no
96
+ database rebuild or recovery.
97
+
73
98
  `cave parse --json` is the parser AST/debug surface, not a persisted claim
74
99
  record. `cave export` remains canonical CAVE text (with optional `;@` identity
75
100
  annotations), which is the language interchange contract rather than JSON.
@@ -92,42 +117,55 @@ plan against an empty in-memory store when no store exists yet.
92
117
 
93
118
  All commands—synchronous, asynchronous, and long-running—enter through one
94
119
  promise-based dispatcher. It owns argument-exception formatting, stdout and
95
- stderr routing, exit codes, and SIGINT/SIGTERM propagation. Servers, watchers,
120
+ stderr routing, exit codes, and SIGINT/SIGTERM propagation. An already-aborted
121
+ runtime signal stops dispatch before argument normalization, command loading,
122
+ or command-specific I/O; dispatch returns quietly with code 0, while the process
123
+ wrapper retains signal exit codes. Servers, watchers,
96
124
  timers, protocol readers, and stores finish their cleanup before a signal exit
97
125
  is reported. Unexpected errors are one-line and stack-free by default; set
98
126
  `CAVE_DEBUG=1` to include the diagnostic stack.
99
127
 
128
+ Ingestion cancellation also interrupts pending URL requests and response reads.
129
+ SIGINT exits with code 130 after cleanup, without reporting cancellation as an
130
+ unexpected error; strict ingestion leaves the target unchanged.
131
+
100
132
  | Command | Flags | Behavior |
101
133
  |---|---|---|
102
134
  | `parse [file…]` | `--json` | Lint (stdin by default). Exit 1 when diagnostics exist; `--json` dumps the AST document. |
103
135
  | `highlight [file…]` | | ANSI syntax colors from the tree-sitter grammar's own highlight query (see [`@cavelang/highlight`](../highlight)); `cave export` colors the same way on a terminal. |
104
136
  | `add [--db p] [file…]` | `--strict`, `--check`, `--no-prelude`, `--no-src` | Ingest. Lenient by default (problems on stderr, valid lines land); `--strict` rolls back on any problem; `--check` is the shape gate (spec §20.3) — the append rolls back if it introduces new expectation violations; `--no-prelude` starts from an empty registry instead of the standard §5.5 pairs. Claims without a `@src:` context are stamped `@src:cli` (spec §9.5); `--no-src` opts out. |
105
137
  | `import [--db p] [file…]` | `--strict`, `--no-prelude` | Restore/merge a database from CAVE text — `add` minus provenance stamping, because canonical text *is* the interchange format and replayed claims must keep their exported claim keys (spec §9.5). |
106
- | `query [--db p] <pattern…>` | `--json`, `--limit <n>`, `--cursor <t>`, `--all`, `--aliases`, `--as-of <t>`, `--at <t>`, `--resolve`, `--sources`, `--no-prelude` | Bounded CAVE-Q page (100 matches by default, maximum 1,000). Extra positionals join as lines, so `WHERE` filters ride as separate arguments. Bindings print as `?x = value`, followed by ` ; comment` when the matched claim carries one (a multi-line comment opens as `;` lines above the binding line, as it does above a claim), so evidence written next to a claim travels with the answer; fully bound patterns print the matched raw line, comment block included (or the pattern itself for transitive matches, which carry no row). Human output ends with `next: <token>` when another page exists; pass it to `--cursor` to continue the first page's frozen transaction snapshot. `--aliases` widens matching through the §13.6 closure; `--as-of <t>` reconstructs belief at a past date/timestamp/tx (spec §12.3); `--at <t>` selects valid-time claims and interpolates trajectories (spec §32.4); `--resolve` matches only the winners the §26 resolution policy picks among contested facts (incompatible with `--all`). `--sources` overlays the store's declared sources (spec §23.4) inside a rolled-back transaction — federation-lite, nothing persists, URLs included; the answer is whole (no `--cursor`), and a text store, which followed its local sources on open, loads only its URL sources here. `--no-prelude` aligns the read-time registry with a store written via `add --no-prelude`. |
138
+ | `query [--db p] <pattern…>` | `--json`, `--limit <n>`, `--cursor <t>`, `--all`, `--aliases`, `--as-of <t>`, `--at <t>`, `--resolve`, `--sources`, `--no-prelude` | Bounded CAVE-Q page (100 matches by default, maximum 1,000). Extra positionals join as lines, so `WHERE` filters ride as separate arguments. Bindings print as `?x = value`, followed by ` ; comment` when the matched claim carries one (a multi-line comment opens as `;` lines above the binding line, as it does above a claim), so evidence written next to a claim travels with the answer; fully bound patterns print the matched raw line, comment block included (or the pattern itself for transitive matches, which carry no row). Human output ends with `next: <token>` when another page exists; pass it to `--cursor` to continue the first page's frozen transaction snapshot. A historical-row or lineage change rejects the cursor; restart without `--cursor`. `--aliases` widens matching through the §13.6 closure; `--as-of <t>` reconstructs belief at a past date/timestamp/tx (spec §12.3); `--at <t>` selects valid-time claims and interpolates trajectories (spec §32.4); `--resolve` matches only the winners the §26 resolution policy picks among contested facts (incompatible with `--all`). `--sources` overlays the store's declared sources (spec §23.4) inside a rolled-back transaction — federation-lite, nothing persists, URLs included; the answer is whole (no `--cursor`), and a text store, which followed its local sources on open, loads only its URL sources here. `--no-prelude` aligns the read-time registry with a store written via `add --no-prelude`. |
107
139
  | `search [--db p] <terms…>` | `--raw`, `--limit <n>`, `--json`, `--no-prelude` | FTS5 full-text search over the store's index (spec §13.2): subject, verb, object, attribute name, value text, comment, and the raw line as written, so tags, contexts, and inverse spellings match too. The terms are one literal phrase by default (hyphenated names such as `token-expiry` are safe); `--raw` passes FTS5 MATCH syntax through (`AND`/`OR`/`NOT`, `NEAR`, `prefix*`, column filters such as `comment:heap`). Newest first, one raw line per match with its comment; `--limit` defaults to 100 (maximum 1,000) and a trailing `more matches beyond <n>` line reports a cap. `--json` emits a `cave.search/v1` object whose matches are `cave.claim/v1` records. Superseded and retracted rows stay searchable (spec §9.6); confirm currency with `query`. |
108
140
  | `resolve [--db p]` | `--aliases`, `--policy`, `--json`, `--no-prelude` | Contested facts under the §26 resolution policy: every fact more than one belief series speaks about, candidates ranked (precedence class, reliability-weighted confidence, tx) with the winner first — what `query --resolve` would match. `--policy` prints the effective policy instead: the built-in precedence ladder merged with in-band `source/<name> HAS precedence:` / `HAS reliability:` declarations. |
109
- | `derive [--db p] [rules.cave…]` | `--dry-run`, `--full`, `--aliases`, `--min-conf <p>`, `--max-passes <n>`, `--list`, `--retract <r>`, `--json`, `--no-prelude` | Declare and fire rules (spec §24, see [`@cavelang/rules`](../rules)): `premises => conclusion` forward chaining over current beliefs, `BECAUSE`/`VIA` lineage, watermark-incremental and idempotent; retracts conclusions whose premises no longer hold. |
141
+ | `derive [--db p] [rules.cave…]` | `--dry-run`, `--full`, `--aliases`, `--min-conf <p>`, `--max-passes <n>`, `--list`, `--retract <r>`, `--json`, `--no-prelude` | Declare and fire rules (spec §24, see [`@cavelang/rules`](../rules)): `premises => conclusion` forward chaining over current beliefs, `BECAUSE`/`VIA` lineage, watermark-incremental and idempotent; retracts conclusions whose premises no longer hold. Declaration errors exit nonzero in both text and JSON modes. Pass exhaustion exits nonzero, reports `complete: false` in JSON and labels the final text summary `derived (incomplete)`. |
110
142
  | `act [--db p] <name> [p=v…]` | `--declare`, `--list`, `--retract <n>`, `--dry-run`, `--no-check`, `--aliases`, `--hooks <file>`, `--json`, `--no-prelude` | Execute an action template (spec §25, see [`@cavelang/act`](../act)): validate parameters, check CAVE-Q preconditions against current belief, append effects atomically with lineage inside the §20.3 shape gate; out-of-band hooks fire after commit. |
111
- | `automate [--db p]` | `--once`, `--declare`, `--list`, `--retract <n>`, `--hooks <file>`, `--agent <template>`, `--json`, `--no-prelude` | The event-driven loop (spec §29, see [`@cavelang/automate`](../automate)): in-band `automation/<name>` trigger patterns over new claims fire rules, actions, out-of-band hooks and agent prompts; `--once` for cron, `--declare`/`--list`/`--retract` for the lifecycle; the daemon polls `MAX(tx)` and settles on change. |
143
+ | `automate [--db p]` | `--once`, `--declare`, `--list`, `--retract <n>`, `--hooks <file>`, `--agent <template>`, `--json`, `--no-prelude` | The event-driven loop (spec §29, see [`@cavelang/automate`](../automate)): in-band `automation/<name>` trigger patterns over new claims fire rules, actions, out-of-band hooks and agent prompts; `--once` for cron (nonzero on incomplete settling or failures), `--declare`/`--list`/`--retract` for the lifecycle; the daemon polls `MAX(tx)` and settles on change. |
112
144
  | `check [--db p]` | `--stale <days>`, `--json`, `--no-prelude` | Knowledge health report (spec §20, see [`@cavelang/shape`](../shape)): shape violations against in-band `EXPECTS` declarations, stale current beliefs (default horizon 90 days), review candidates (conf 0.3–0.7), alias disagreements, coverage stats. Exit 1 on violations; everything else is advisory. |
113
145
  | `backup [--db p] --out <file>` | `--force`; `--verify <file>`, `--sha256 <hex>` | Create an online, exact snapshot of the store, verify it, and publish it atomically; or verify a prior snapshot (spec §13.2.2). |
114
146
  | `restore <snapshot> --db <path>` | `--force`, `--sha256 <hex>` | Verify and atomically restore exact snapshot bytes; refuses active/stale WAL, SHM, and rollback-journal sidecars (spec §13.2.2). |
115
147
  | `generate [--db p]` | `--out <file>`, `--version <n>`, `--no-prelude` | Deterministic versioned TypeScript interfaces and store-backed readers from current `EXPECTS` claims (spec §20.4, see [`@cavelang/shape`](../shape)); embeds normalized schema and SHA-256, fails on ambiguous/unsupported expectations before writing. |
116
- | `suggest-alias [--db p]` | `--min <s>`, `--limit <n>`, `--agent <template>`, `--timeout <s>`, `--write`, `--json`, `--no-prelude` | Alias discovery (spec §27, see [`@cavelang/shape`](../shape)): same-entity candidates from string/graph similarity as suggested `ALIAS` claims at review-band confidence (0.3–0.5). Prints pipeable CAVE text; `--write` appends stamped `@src:suggest/alias`; `--agent` runs an LLM judge over the candidates (the ingest/eval shell contract). Pairs with any recorded `ALIAS` history are never re-suggested. |
117
- | `sync [--db p] <source>` | `--as <label>`, `--into <label>`, `--dry-run`, `--no-record`, `--json`, `--no-prelude` | Store merge (spec §28, see [`@cavelang/sync`](../sync)): another CAVE store file — or `;@`-annotated canonical text, `-` for stdin — merges by row identity; present rows skip, re-runs merge nothing, effective merges append a `SYNCED-INTO` record (`--no-record` for checkouts, spec §28.6). |
118
- | `export [--db p]` | `--out <file>`, `--current`, `--tx`, `--max-sensitivity <level>`, `--no-prelude` | Sensitivity-scoped canonical CAVE text (spec §9.7) — default maximum `internal`; select `restricted` for complete portable history or a replica. `--current` compacts but never sanitizes permanent history (§9.6). `--tx` precedes every claim line with its `;@` transaction annotation (spec §28.4). Stdout by default; `--out` writes a file and reports the claim count. |
148
+ | `suggest-alias [--db p]` | `--min <s>`, `--limit <n>`, `--agent <template>`, `--timeout <s>`, `--write`, `--json`, `--no-prelude` | Alias discovery (spec §27, see [`@cavelang/shape`](../shape)): `--min` requires a finite score in 0..1 or a percentage and `--limit` a positive safe integer. Returns same-entity candidates from string/graph similarity as suggested `ALIAS` claims at review-band confidence (0.3–0.5). Prints pipeable CAVE text, reversing the undirected relation when necessary to preserve entity names; an unrepresentable pair reports an error. `--write` validates each fresh line against its proposed pair before appending stamped `@src:suggest/alias`; `--agent` runs an LLM judge over the candidates (the ingest/eval shell contract). Pairs with any recorded `ALIAS` history are never re-suggested; writes recheck both directions under the transaction reservation and skip reviewed pairs. `--json` returns an array; `--json --write` writes and returns `{ suggestions, appended }`, with the selected proposals and actual appended count. |
149
+ | `sync [--db p] <source>` | `--as <label>`, `--into <label>`, `--dry-run`, `--no-record`, `--json`, `--no-prelude` | Store merge (spec §28, see [`@cavelang/sync`](../sync)): another CAVE store file — or `;@`-annotated canonical text, `-` for stdin — merges by row identity; matching present rows skip, conflicting identities reject the source with a nonzero exit, re-runs merge nothing, effective merges append a `SYNCED-INTO` record (`--no-record` for checkouts, spec §28.6). |
150
+ | `export [--db p]` | `--out <file>`, `--current`, `--tx`, `--max-sensitivity <level>`, `--no-prelude` | Sensitivity-scoped canonical CAVE text (spec §9.7) — default maximum `internal`; select `restricted` for complete portable history or a replica. `--current` compacts but never sanitizes permanent history (§9.6). `--tx` precedes every claim line with its `;@` transaction annotation, including a JSON provenance payload when contexts cannot reconstruct stored dimensions (spec §28.4). Stdout by default; `--out` writes a file and reports the claim count. |
119
151
  | `report [--db p] [template…]` | `--out <file>`, `--aliases`, `--resolve`, `--as-of <t>`, `--at <t>`, `--max-sensitivity <level>`, `--no-prelude` | Render sensitivity-scoped cited Markdown from fenced and inline CAVE-Q templates (spec §9.7, §31, see [`@cavelang/view`](../view)). Every query uses the same audience, alias, resolution, transaction-time, and valid-time snapshot options. |
120
- | `serve [--db p]` | `--port <n>`, `--host <a>`, `--max-sensitivity <level>`, `--no-prelude` | The sensitivity-scoped human read surface (spec §9.7, §30, see [`@cavelang/view`](../view)): one static page whose counts, aliases, history, lineage, and search are computed only from visible rows. Strictly read-only (GET only), localhost by default. |
152
+ | `serve [--db p]` | `--port <n>`, `--host <a>`, `--max-sensitivity <level>`, `--no-prelude` | The sensitivity-scoped human read surface (spec §9.7, §30, see [`@cavelang/view`](../view)): one static page whose counts, aliases, history, lineage, and search are computed only from visible rows. Strictly read-only (GET/HEAD only), localhost by default. |
121
153
  | `mcp [--db p]` | `--read-only`, `--permissions <list>`, `--tools <list>`, `--hooks <file>`, `--no-prelude`, `--src <ctx>`, `--no-src` | Serve the engine as an MCP server on stdio (see [`@cavelang/mcp`](../mcp)) — static tools for version-matched help plus add/query/fuse/search/about/neighbors/reconstruct/derive/export/lint, and one generated `act_<name>` tool per current action. Permission classes separate `read`, ephemeral `evaluate`, durable `record`, and effect-capable `action`; `--read-only` keeps only read/evaluate. Permission, tool, and read-only scopes intersect. `--hooks` supplies reviewed out-of-band commands for action tools. Appends are stamped `@src:agent/<client-name>` (spec §9.5); `--src` replaces the stamp, `--no-src` disables it. |
122
- | `ingest [--db p] <globs/urls…>` | `--agent <template>`, `--stdout`, `--lenient`, `--plan`, `--dry-run`, `--json`, `--no-prelude` | LLM-driven ingestion of files and web pages (fetched and readability-extracted) through any headless agent (see [`@cavelang/ingest`](../ingest)): strict atomic staging by default; explicit lenient partial progress with a complete per-source manifest; isolated URL outcomes classified as retryable network/HTTP or permanent HTTP failures; batching, hybrid context, MCP or stdout agents, incremental retry digests, and `--plan` NDJSON for SDK drivers. |
154
+ | `ingest [--db p] <globs/urls…>` | `--agent <template>`, `--stdout`, `--lenient`, `--plan`, `--dry-run`, `--json`, `--no-prelude` | LLM-driven ingestion of files and web pages (fetched and readability-extracted) through any headless agent (see [`@cavelang/ingest`](../ingest)): strict atomic staging by default; explicit lenient partial progress with a complete per-source manifest; isolated URL outcomes classified as retryable network/HTTP or permanent HTTP failures; batching, hybrid context, MCP or stdout agents, incremental retry digests, and `--plan` NDJSON for SDK drivers. Execution `--json` cannot be combined with `--plan` or `--dry-run`. |
123
155
  | `eval <suite…>` | `--agent <template>`, `--judge <template>`, `--runs <n>`, `--stdout`, `--min <p>`, `--json`, `--no-prelude` | Golden-fixture extraction/query evals (see [`@cavelang/eval`](../eval)): N fresh-store runs against any agent, claim-key + value scoring with §9.5 actor-stamp normalization, CAVE-Q expectations, optional LLM judge, `--min` CI gate. |
124
156
  | `connect [<source>]` | `--map <file\|inline>`, `--key <field>`, `--sql <query>`, `--watch`, `--prune`, `--query <pattern>`, `--dry-run`, `--list`, `--no-prelude` | Deterministic structured ingestion (spec §9.8, §23, see [`@cavelang/connect`](../connect)): CSV/TSV/JSON/JSONL/SQLite/URL records through `?field` templates (a file, or inline as a comma-separated list of claim lines), `--sql` reshaping any tabular source through a temporary SQLite table first, physical source identity and CSV/TSV/JSONL line spans, per-record digests, `--watch`, `--prune`, query-time overlay. Without a source, the store's declared sources run (spec §23.4): `source/<name> HAS path: …` claims with `map`, `key`, `format`, `delimiter`, `table`, `sql`, and `records` attributes mirror the options, a `.cave` path needs no map, and paths resolve against the store's directory; `--list` prints them, `--name` selects one, `--query` overlays them all, `--watch` re-runs on any of their files. A CAVE text file used as `--db` follows its declared sources on every open. |
125
157
  | `reconstruct [--db p] <seed…>` | `--query <text>`, `--agent <template>`, `--steps <n>`, `--claims <n>`, `--timeout <s>`, `--trace`, `--no-prelude` | Active memory reconstruction from seed cues (spec §18, see [`@cavelang/loop`](../loop)): best-first traversal collecting related claims as canonical CAVE text; the heuristic policy by default, an LLM select/stop policy with `--agent`. |
126
- | `doctor [--db p]` | `--hooks <file>`, `--json` | Read-only runtime, package-layout, configuration, and store-health diagnostics. Missing optional configuration is advisory; unsupported runtimes, broken assets, malformed configured hooks, and unreadable or corrupt stores fail. Reports identify configuration sources but never expose paths, hook content, URLs, or environment values, so both human and `cave.doctor/v1` JSON output are safe to share. |
158
+ | `doctor [--db p]` | `--hooks <file>`, `--json` | Read-only runtime, package, configuration and store-health checks. See [Diagnosis](#diagnosis) for results, snapshot behavior and privacy. |
127
159
  | `demo` | | The cave-loop multi-hop recovery demo (§18). |
128
160
  | `version` | | Print the cave version. |
129
161
  | `help [command]` | | The overview, or one command's options and examples. |
130
162
 
163
+ File output from `export`, `report`, `generate` and `backup` cannot target the
164
+ source database or its SQLite `-wal`, `-shm` and `-journal` files. The check
165
+ includes database symlinks, existing file aliases and resolved output-parent
166
+ directories, including sidecars that SQLite has not created yet. Text stores
167
+ retain protection for their source file without reserving SQLite sidecar names.
168
+
131
169
  All query-time arguments share one UTC parser. For example,
132
170
  `--at 2026-07-02T12:00:00` and `--at 2026-07-02T12:00:00Z` select the same
133
171
  instant on every host; explicit numeric offsets such as `+02:00` are honored.
@@ -145,6 +183,91 @@ Shape declarations may add `#cardinality:one` or an attribute
145
183
  `#unit:<unit>` tag. `cave check` reports the observed count and normalized
146
184
  units when those constraints fail; declarations without either tag keep the
147
185
  compatible one-or-more presence check.
186
+ The text coverage summary rounds average confidence to a whole percent, using
187
+ `<1%` or `>99%` when rounding would otherwise imply zero or certainty.
188
+ `cave check --json` retains the numeric average; when no current positive
189
+ beliefs remain, the JSON average is null and the text omits it.
190
+ Health-report text appends findings iteratively, so large violation, stale,
191
+ review and alias-disagreement sections do not exceed JavaScript's
192
+ function-argument limit. A regression checks all 130,000 review candidates
193
+ and retains the successful exit status for advisory findings. Reports still
194
+ assemble in memory; this is not a finding-count or output-memory budget.
195
+ `cave resolve --policy` likewise calculates table width iteratively. Large
196
+ sets of source declarations retain complete, aligned policy rows without
197
+ exceeding JavaScript's function-argument limit; the policy and output remain
198
+ in memory.
199
+ Resolution text rounds reliability and effective confidence to one decimal
200
+ percent, using `<0.1%` and `>99.9%` when rounding would otherwise imply zero
201
+ or certainty. Exact zero and one remain `0%` and `100%`; JSON retains numbers.
202
+
203
+ ## Diagnosis
204
+
205
+ Use doctor to check an installation and store without repairing or migrating it:
206
+
207
+ ```sh
208
+ cave doctor --db knowledge.db
209
+ cave doctor --db knowledge.db \
210
+ --hooks hooks.json --json
211
+ ```
212
+
213
+ A normal diagnosis returns status 0 when no checks fail, including when warnings
214
+ remain, or status 1 when a check fails. Missing optional configuration is
215
+ advisory. Unsupported runtimes, broken package assets, malformed configured
216
+ hooks, and unreadable or corrupt stores fail. Read each failed check's remediation
217
+ before retrying; doctor does not perform the repair for you.
218
+
219
+ A readable schema-version-0 database without `cave_` or `idx_cave_` objects
220
+ is reported as uninitialized. Unrelated names such as `caveat` do not imply
221
+ a CAVE migration; existing CAVE prefixes are recognized without regard to case.
222
+
223
+ For current-schema SQLite stores, the database checks cover:
224
+
225
+ | Check | What it examines |
226
+ |---|---|
227
+ | `store.integrity` | SQLite integrity and foreign-key references. |
228
+ | `store.rows` | Canonical lowercase UUIDv7 row identity with `id = tx`; payload-column consistency; binary negation, importance and approximation flags; finite confidence in [0, 1]; positive finite sigma levels, with null retaining the legacy default. It also streams stored history through the row decoder to check authored values and their numeric caches, and rejects empty or non-text explicit provenance values. |
229
+ | `store.search` | Search entries match stored claims, without missing, duplicate, orphaned or stale entries. This is separate from SQLite integrity. |
230
+
231
+ The `store.rows` scan also recomputes every historical claim's key using its
232
+ stored contexts. A mismatch fails diagnosis even when a newer revision is
233
+ valid. Contexts are read through the claim index while history is streamed;
234
+ diagnosis does not collect all history or repair keys. Corrected keys and
235
+ contexts are checked again on the next invocation.
236
+ The scan also loads stored tags and checks canonical claim emission, so
237
+ unemittable terms, contexts or tags fail diagnosis before export or sync.
238
+ Malformed contents remain redacted and the database is left unchanged for
239
+ repair and retry.
240
+
241
+ Stored edge roles must be `WHEN`, `VIA`, `BECAUSE` or `QUALIFIES`. Unsupported
242
+ roles also fail `store.rows` without printing the role or changing the database;
243
+ diagnosis checks the corrected relationships again after repair.
244
+
245
+ Provenance validation covers actor, source, run and domain entries without
246
+ printing their values or claim identities. SQLite TEXT affinity alone permits
247
+ binary values, and SQLite integrity checks do not reject empty strings; these
248
+ therefore belong to the semantic row check. A failed check leaves the database
249
+ unchanged. Correct the affected data or restore a verified backup, then rerun
250
+ doctor before retrying annotated export.
251
+
252
+ SQLite diagnosis holds one read transaction across schema, integrity, row and
253
+ search checks, so the report describes one snapshot. A subsequent invocation sees
254
+ later commits. With rollback journaling, the read transaction can temporarily
255
+ block a writer's commit; closing the diagnostic connection releases its locks.
256
+
257
+ A database close failure adds `store.cleanup` while preserving completed checks.
258
+ For a successfully assembled text store, this retains its claim count and does
259
+ not mislabel cleanup failure as a parse or declared-source loading failure.
260
+ A temporary SQLite capability-probe close failure adds `runtime.sqlite.cleanup`
261
+ while retaining the capability result. Both are failures with redacted messages.
262
+
263
+ Human-readable and `cave.doctor/v1` JSON reports identify configuration sources
264
+ but omit paths, hook contents, URLs, claim contents and environment values,
265
+ including when a text store or declared source cannot load. The targeted checks
266
+ do not establish semantic correctness of every historical claim.
267
+
268
+ The programmatic `diagnose({ db, hooks })` API captures both options once before
269
+ inspection. Changing getters cannot alter the reported database configuration
270
+ source or switch hook files during diagnosis; a later call can use new options.
148
271
 
149
272
  ## Exact backup and portable interchange
150
273
 
@@ -156,6 +279,21 @@ cave backup --verify knowledge.snapshot.db --sha256 <recorded-hex>
156
279
  cave restore knowledge.snapshot.db --db restored.db --sha256 <recorded-hex>
157
280
  ```
158
281
 
282
+ Verify and restore the standalone snapshot produced by `cave backup`.
283
+ Backup verification checks SQLite integrity, schema and the supplied checksum.
284
+ It can preserve structurally valid rows with semantic errors, such as damaged
285
+ claim keys or empty provenance. Run `cave doctor --db restored.db` to diagnose
286
+ the restored copy before export or sync. Keeping the original snapshot allows
287
+ repair work on the copy without changing that recovery point.
288
+ Snapshots from schema version 1 through the current version remain recoverable.
289
+ Verification and restore preserve their bytes and schema version; the next
290
+ writable open migrates the restored copy, leaving the retained backup untouched.
291
+ Unversioned and newer schema formats are rejected.
292
+ Verification rejects sources with SQLite WAL, shared-memory or rollback-journal
293
+ sidecars, whose contents would not be covered by a checksum of the main file.
294
+ Backup and restore also refuse destination sidecars even with `--force`, and
295
+ restore cannot write into a sidecar path belonging to its source snapshot.
296
+
159
297
  Backup is an online, consistent SQLite snapshot safe with WAL and concurrent
160
298
  readers/writers. CAVE verifies and atomically publishes it. Stop all users of
161
299
  the destination before restore; a WAL/SHM/journal sidecar makes restore refuse rather
@@ -163,6 +301,45 @@ than guess. Failed creation or restore leaves the previous destination intact.
163
301
 
164
302
  For portable, reviewable CAVE text:
165
303
 
304
+ `export --out`, `generate --out` and `report --out` write and flush a temporary
305
+ file in the destination directory before atomically replacing the output.
306
+ Write, flush, file-close or rename failures leave an existing output intact.
307
+ Export decoding errors, including conflicting historical payload columns and
308
+ invalid confidence or sigma levels, return status 1 with the affected claim ID and no partial stdout.
309
+ Annotated export rejects stored claim keys that disagree with the claim and
310
+ its contexts, so replay cannot silently change the belief series associated
311
+ with a transaction. It also rejects empty or non-string stored provenance values
312
+ before producing a replay file. Existing output
313
+ files and database bytes remain unchanged, and absent output files stay absent.
314
+ Sensitivity filtering still applies before decoding: excluded malformed rows do
315
+ not prevent a narrower export. Repair the included row before retrying a complete
316
+ export.
317
+ Cleanup attempts both file closure and temporary-file removal. Multiple failures
318
+ are retained in operation order rather than allowing cleanup to hide the first
319
+ error. If the output did not exist, these publication failures leave it absent;
320
+ the same command can be retried after the filesystem failure is resolved.
321
+ If temporary-directory cleanup fails after replacement, the complete file
322
+ remains published, but the command returns status 1 without a success message.
323
+ The error explicitly identifies the published output and temporary directory,
324
+ and retains the cleanup failure as its cause. Inspect the complete output and
325
+ the named temporary directory before deciding whether another export is needed.
326
+ Existing permission bits
327
+ are retained; valid symlinks are followed without replacing the link, while
328
+ hard-link aliases retain the old file. Dangling symlinks and non-regular files
329
+ are refused. Replacement requires write access to the destination directory.
330
+ This protects against partial output writes; it does not promise persistence
331
+ of the directory rename across power loss. Shell redirection (`>`) retains the
332
+ shell's ordinary truncation behavior.
333
+
334
+ If `report` throws while generating a stored citation, it exits with status 1,
335
+ names the affected claim in stderr and emits no report to stdout. An existing
336
+ `--out` file stays intact and a new output path stays absent, including when
337
+ earlier queries in the template succeeded. Retry after resolving the evidence
338
+ failure. Ordinary template/query problems still produce diagnostic Markdown
339
+ and status 1; that complete diagnostic document can be written to `--out`.
340
+ Invalid report `--at` or `--as-of` options fail before reading templates or
341
+ opening the store and leave the output unchanged, even for a static template.
342
+
166
343
  ```
167
344
  $ cave export --db knowledge.db --max-sensitivity restricted --out backup.cave
168
345
  exported 812 claim(s) to backup.cave
@@ -192,8 +369,43 @@ accidental secret ingest, rotate it, stop sync, rebuild a reviewed safe store,
192
369
  then explicitly destroy or expire every affected copy with the relevant
193
370
  storage provider's confirmation.
194
371
 
372
+ `cave sync --json` emits a report on stdout for successful merges and rejected
373
+ claim/annotation content; a nonempty `problems` array also sets exit status 1.
374
+ Source-access, UTF-8 and database failures instead produce stderr diagnostics
375
+ and empty stdout with status 1. Check status and available stdout before parsing
376
+ JSON, including for dry runs. Correcting the source allows a fresh preview and
377
+ retry against the same target.
378
+ If final store closure fails after a report is produced, stdout retains that
379
+ JSON, stderr adds the cleanup diagnostic, and status is nonzero. A completed
380
+ merge may already be committed even when the command exits with a failure.
381
+
195
382
  Everything is testable without spawning: individual buffered commands expose
196
383
  `(argv) → { code, out, err }`, while `dispatch(argv, runtime)` exercises the
197
384
  same awaited path as the binary with injectable streams and an abort signal.
198
385
  `main.ts` only hands process arguments to `runCli` and assigns its final exit
199
386
  code.
387
+
388
+ Buffered commands that own a store wait for their work to finish, then attempt
389
+ store close once. A close failure preserves completed `out` and existing `err`,
390
+ appends a `store close failed` diagnostic, and changes a successful status to 1;
391
+ an existing nonzero status is retained. Operation errors become ordinary failure
392
+ output before cleanup, so a later close failure cannot hide them. This covers
393
+ ingestion, queries (including async source overlays), search, resolution,
394
+ derivation, actions, checks, backup, alias suggestions, sync, reports, export,
395
+ client generation and reconstruction. Async source or agent work settles before
396
+ its store closes. Completed writes, generated files and published snapshots are
397
+ not undone by final-close failure; query overlays still roll back their scratch
398
+ writes. A close attempt does not guarantee release when native close fails.
399
+ Within these owned-store wrappers, thrown values that cannot be printed use
400
+ `[unprintable thrown value]`. Formatting failures cannot skip the close attempt,
401
+ erase completed output, or hide a simultaneous cleanup failure. This applies
402
+ to synchronous commands and awaited source-query work.
403
+ The outer dispatcher uses the same safe formatting for unexpected exceptions.
404
+ Debug output captures a stack once; if reading or formatting it fails, the
405
+ dispatcher falls back to the message, then the unprintable-value placeholder.
406
+ Normal diagnostics do not read the stack. A formatting failure therefore cannot
407
+ replace the command's status-1 diagnostic with a rejected dispatch promise.
408
+ The command-level catches for backup, restore, alias suggestion and
409
+ reconstruction use the same placeholder for unreadable setup failures, including
410
+ file inspection before a store is owned. Direct programmatic calls retain their
411
+ ordinary `{ code, out, err }` failure result in those cases.
@@ -179,7 +179,8 @@ export const parse = (subject, body) => {
179
179
  const effectTexts = [];
180
180
  for (const segment of splitSegments(rightText)) {
181
181
  const { effect, problems: effectProblems } = parseEffect(segment, bound);
182
- problems.push(...effectProblems);
182
+ for (const problem of effectProblems)
183
+ problems.push(problem);
183
184
  if (effect !== undefined) {
184
185
  effects.push(effect);
185
186
  effectTexts.push(Rule.normalizeSegment(segment));
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,KAAK,EAAY,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAA;AAEvC,oFAAoF;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAA;AAEnC,6CAA6C;AAC7C,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAA;AAEtC,4EAA4E;AAC5E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE,CACpD,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,IAAI,EAAE,CAAA;AAEnE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAe,EAAsB,EAAE,CAChE,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1E,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IACrC,SAAS,CAAA;AAEb;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,0BAA0B,CAAA;AAqBrD,MAAM,eAAe,GAAG,CAAC,KAAc,EAAW,EAAE,CAClD,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAA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,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAElD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,KAAK,EAAE,KAAK,MAAM,KAAG,UAmBzD,CAAA"}
@@ -18,6 +18,7 @@
18
18
  * wins, whoever appended it.
19
19
  */
20
20
  import { Claim, Key, Value } from '@cavelang/core';
21
+ import { canonicalizeText } from '@cavelang/canonical';
21
22
  import { parseDocument } from '@cavelang/parser';
22
23
  import { Rule } from '@cavelang/cli/rules';
23
24
  import { Row } from '@cavelang/store';
@@ -40,20 +41,24 @@ const declarationKey = (subject, attribute) => Key.of(Claim.of({
40
41
  * decide whether a disabled declaration matters.
41
42
  */
42
43
  export const currentAttribute = (store, subject, attribute) => {
43
- let winner;
44
- for (const row of store.currentBeliefs()) {
45
- if (row.subject === subject && row.verb === 'HAS' && row.attribute === attribute &&
46
- (winner === undefined || winner.tx < row.tx)) {
47
- winner = row;
48
- }
49
- }
50
- return winner;
44
+ // The newest row across all series is necessarily current in its own series.
45
+ // Keep disabled rows in this contest: a newer retraction/negation must win.
46
+ return store.db.prepare(`SELECT * FROM cave_claim
47
+ WHERE subject = ? AND verb = 'HAS' AND attribute = ?
48
+ ORDER BY tx DESC LIMIT 1`).get(subject, attribute);
51
49
  };
52
50
  const enabled = (row) => row !== undefined && row.conf > 0 && row.negated === 0 && row.value_text !== null;
51
+ /** Decode enabled action metadata without coercing malformed SQLite values. */
52
+ const storedText = (row) => {
53
+ if (typeof row.value_text !== 'string') {
54
+ throw new TypeError(`stored action field ${JSON.stringify(row.attribute)} value_text must be text (claim ${JSON.stringify(row.id)})`);
55
+ }
56
+ return Row.parseValue(row.value_text).raw;
57
+ };
53
58
  /** Current positive action declaration rows, newest series winner per subject. */
54
- const currentActionRows = (store) => {
59
+ const currentActionRows = (rows) => {
55
60
  const bySubject = new Map();
56
- for (const row of store.currentBeliefs()) {
61
+ for (const row of rows) {
57
62
  if (row.verb !== 'HAS' || row.attribute !== Action.actionAttribute ||
58
63
  Action.actionName(row.subject) === undefined) {
59
64
  continue;
@@ -76,7 +81,7 @@ export const loadAction = (store, name) => {
76
81
  if (!enabled(row)) {
77
82
  return undefined;
78
83
  }
79
- const parsed = Action.parse(subject, Row.parseValue(row.value_text).raw);
84
+ const parsed = Action.parse(subject, storedText(row));
80
85
  if (!parsed.ok) {
81
86
  return { problems: parsed.problems };
82
87
  }
@@ -92,41 +97,48 @@ export const loadAction = (store, name) => {
92
97
  /** The hook name the action currently references, if any (§25.4). */
93
98
  export const currentHook = (store, subject) => {
94
99
  const row = currentAttribute(store, subject, Action.hookAttribute);
95
- return enabled(row) ? Row.parseValue(row.value_text).raw : undefined;
100
+ return enabled(row) ? storedText(row) : undefined;
96
101
  };
97
- /** Parameter doc — the comment of `action/<name>/<param> IS param` (§25.1). */
98
- const paramDoc = (store, subject, param) => {
99
- let winner;
100
- for (const row of store.currentBeliefs()) {
101
- if (row.subject === `${subject}/${param}` && row.verb === 'IS' && row.object === 'param' &&
102
- row.negated === 0 && row.conf > 0 && (winner === undefined || winner.tx < row.tx)) {
103
- winner = row;
102
+ /** Current positive actions of a store, in declaration order. */
103
+ export const listActions = (store) => {
104
+ const rows = store.currentBeliefs();
105
+ const docs = new Map();
106
+ const hooks = new Map();
107
+ for (const row of rows) {
108
+ if (row.verb === 'IS' && row.object === 'param' && row.negated === 0 && row.conf > 0) {
109
+ const seen = docs.get(row.subject);
110
+ if (seen === undefined || seen.tx < row.tx)
111
+ docs.set(row.subject, row);
112
+ }
113
+ if (row.verb === 'HAS' && row.attribute === Action.hookAttribute) {
114
+ const seen = hooks.get(row.subject);
115
+ if (seen === undefined || seen.tx < row.tx)
116
+ hooks.set(row.subject, row);
104
117
  }
105
118
  }
106
- return winner?.comment ?? undefined;
119
+ return currentActionRows(rows).map(row => {
120
+ const text = storedText(row);
121
+ const parsed = Action.parse(row.subject, text);
122
+ const params = parsed.ok ?
123
+ parsed.action.params.map(name => {
124
+ const doc = docs.get(`${row.subject}/${name}`)?.comment ?? undefined;
125
+ return { name, ...doc === undefined ? {} : { doc } };
126
+ }) :
127
+ [];
128
+ const hookRow = hooks.get(row.subject);
129
+ const hook = enabled(hookRow) ? storedText(hookRow) : undefined;
130
+ return {
131
+ subject: row.subject,
132
+ name: Action.actionName(row.subject),
133
+ text,
134
+ ...row.comment === null ? {} : { description: row.comment },
135
+ params,
136
+ ...hook === undefined ? {} : { hook },
137
+ ok: parsed.ok,
138
+ problems: parsed.ok ? [] : parsed.problems
139
+ };
140
+ });
107
141
  };
108
- /** Current positive actions of a store, in declaration order. */
109
- export const listActions = (store) => currentActionRows(store).map(row => {
110
- const text = Row.parseValue(row.value_text).raw;
111
- const parsed = Action.parse(row.subject, text);
112
- const params = parsed.ok ?
113
- parsed.action.params.map(name => {
114
- const doc = paramDoc(store, row.subject, name);
115
- return { name, ...doc === undefined ? {} : { doc } };
116
- }) :
117
- [];
118
- const hook = currentHook(store, row.subject);
119
- return {
120
- subject: row.subject,
121
- name: Action.actionName(row.subject),
122
- text,
123
- ...row.comment === null ? {} : { description: row.comment },
124
- params,
125
- ...hook === undefined ? {} : { hook },
126
- ok: parsed.ok,
127
- problems: parsed.ok ? [] : parsed.problems
128
- };
129
- });
130
142
  const indentOf = (line) => line.length - line.trimStart().length;
131
143
  const isStructural = (line) => {
132
144
  const body = line.trim();
@@ -169,6 +181,13 @@ export const declareActions = (store, text) => {
169
181
  const problems = [];
170
182
  const actions = [];
171
183
  const preludeLines = [];
184
+ const preludeSourceLines = [];
185
+ const addPrelude = (lines, at) => {
186
+ lines.forEach((line, index) => {
187
+ preludeLines.push(line);
188
+ preludeSourceLines.push(at + index);
189
+ });
190
+ };
172
191
  const declarations = [];
173
192
  // Top-level blocks: a structural unindented line plus what follows it.
174
193
  // A declaration's structural children would silently re-attach to the
@@ -180,7 +199,7 @@ export const declareActions = (store, text) => {
180
199
  blocks.push({ lines: [line], at: index + 1 });
181
200
  }
182
201
  else if (blocks.length === 0) {
183
- preludeLines.push(line);
202
+ addPrelude([line], index + 1);
184
203
  }
185
204
  else {
186
205
  blocks[blocks.length - 1].lines.push(line);
@@ -189,7 +208,7 @@ export const declareActions = (store, text) => {
189
208
  for (const block of blocks) {
190
209
  const declaration = asDeclaration(block.lines[0]);
191
210
  if (declaration === undefined) {
192
- preludeLines.push(...block.lines);
211
+ addPrelude(block.lines, block.at);
193
212
  continue;
194
213
  }
195
214
  if (block.lines.slice(1).some(isStructural)) {
@@ -197,17 +216,26 @@ export const declareActions = (store, text) => {
197
216
  continue;
198
217
  }
199
218
  declarations.push({ declaration, at: block.at });
200
- preludeLines.push(...block.lines.slice(1));
219
+ addPrelude(block.lines.slice(1), block.at + 1);
201
220
  }
202
221
  return store.transaction(() => {
222
+ store.registry();
203
223
  let prelude = 0;
204
224
  const preludeText = preludeLines.join('\n');
205
225
  if (preludeText.trim() !== '') {
226
+ // Validate even cached input: older versions cached failed preludes too.
227
+ const canonical = canonicalizeText(preludeText, store.registry());
228
+ if (canonical.problems.length > 0) {
229
+ for (const problem of canonical.problems)
230
+ problems.push({
231
+ ...problem, line: preludeSourceLines[problem.line - 1] ?? problem.line
232
+ });
233
+ return { declared: 0, unchanged: 0, prelude: 0, actions, problems };
234
+ }
206
235
  const digest = Rule.digestOf(preludeText);
207
236
  const known = store.currentBelief(declarationKey(preludeSubject, preludeDigestAttribute));
208
237
  if (known === undefined || known.conf <= 0 || known.value_text !== digest) {
209
- const result = store.ingest(preludeText, { source: 'cave-act' });
210
- problems.push(...result.problems);
238
+ const result = store.insertResult(canonical, { source: 'cave-act' });
211
239
  prelude = result.ids.length;
212
240
  store.ingest(`${preludeSubject} HAS ${preludeDigestAttribute}: ${digest} @${provenanceContext}`);
213
241
  }
@@ -217,7 +245,8 @@ export const declareActions = (store, text) => {
217
245
  for (const { declaration, at } of declarations) {
218
246
  const parsed = Action.parse(declaration.subject, declaration.body);
219
247
  if (!parsed.ok) {
220
- problems.push(...parsed.problems.map(message => ({ line: at, message })));
248
+ for (const message of parsed.problems)
249
+ problems.push({ line: at, message });
221
250
  continue;
222
251
  }
223
252
  const action = parsed.action;
@@ -250,12 +279,12 @@ export const declareActions = (store, text) => {
250
279
  */
251
280
  export const retractAction = (store, ref) => {
252
281
  const subject = Action.actionSubject(ref);
253
- const rows = store.currentBeliefs().filter(row => row.subject === subject && row.verb === 'HAS' && row.attribute === Action.actionAttribute &&
254
- row.negated === 0 && row.conf > 0);
255
- if (rows.length === 0) {
256
- return { ok: false, error: `no current action matches ${JSON.stringify(ref)}` };
257
- }
258
282
  return store.transaction(() => {
283
+ const rows = store.currentBeliefs().filter(row => row.subject === subject && row.verb === 'HAS' && row.attribute === Action.actionAttribute &&
284
+ row.negated === 0 && row.conf > 0);
285
+ if (rows.length === 0) {
286
+ return { ok: false, error: `no current action matches ${JSON.stringify(ref)}` };
287
+ }
259
288
  for (const row of rows) {
260
289
  store.insertResult({
261
290
  claims: [{ claim: { ...store.toClaim(row), conf: 0, raw: '', comment: 'retracted: cave act --retract' }, line: 0 }],