aontu 0.61.0 → 0.63.0

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 (371) hide show
  1. package/README.md +4 -4
  2. package/dist/agentsmd.d.ts +1 -0
  3. package/dist/agentsmd.js +7 -28
  4. package/dist/agentsmd.js.map +1 -1
  5. package/dist/alias.js.map +1 -1
  6. package/dist/allow.d.ts +23 -0
  7. package/dist/allow.js +138 -0
  8. package/dist/allow.js.map +1 -0
  9. package/dist/aontu.d.ts +4 -2
  10. package/dist/aontu.js +4 -80
  11. package/dist/aontu.js.map +1 -1
  12. package/dist/aontumodel.d.ts +4 -0
  13. package/dist/aontumodel.js +33 -0
  14. package/dist/aontumodel.js.map +1 -0
  15. package/dist/cli.d.ts +10 -1
  16. package/dist/cli.js +877 -479
  17. package/dist/cli.js.map +1 -1
  18. package/dist/ctx.js +0 -48
  19. package/dist/ctx.js.map +1 -1
  20. package/dist/diff.js +0 -32
  21. package/dist/diff.js.map +1 -1
  22. package/dist/err.js +0 -40
  23. package/dist/err.js.map +1 -1
  24. package/dist/escape.js +0 -45
  25. package/dist/escape.js.map +1 -1
  26. package/dist/exactjson.d.ts +0 -35
  27. package/dist/exactjson.js +0 -131
  28. package/dist/exactjson.js.map +1 -1
  29. package/dist/format.js +55 -189
  30. package/dist/format.js.map +1 -1
  31. package/dist/grammar.d.ts +9 -0
  32. package/dist/grammar.js +54 -0
  33. package/dist/grammar.js.map +1 -0
  34. package/dist/graph.js +0 -26
  35. package/dist/graph.js.map +1 -1
  36. package/dist/hcanon.js +0 -82
  37. package/dist/hcanon.js.map +1 -1
  38. package/dist/helpdoc.d.ts +16 -0
  39. package/dist/helpdoc.js +59 -0
  40. package/dist/helpdoc.js.map +1 -0
  41. package/dist/hints.d.ts +0 -6
  42. package/dist/hints.js +59 -47
  43. package/dist/hints.js.map +1 -1
  44. package/dist/jsonschema.js +0 -114
  45. package/dist/jsonschema.js.map +1 -1
  46. package/dist/keyorder.d.ts +0 -7
  47. package/dist/keyorder.js +0 -41
  48. package/dist/keyorder.js.map +1 -1
  49. package/dist/lang.js +32 -877
  50. package/dist/lang.js.map +1 -1
  51. package/dist/lower.d.ts +3 -0
  52. package/dist/lower.js +14 -61
  53. package/dist/lower.js.map +1 -1
  54. package/dist/lsp-server.js +0 -16
  55. package/dist/lsp-server.js.map +1 -1
  56. package/dist/lsp.d.ts +1 -1
  57. package/dist/lsp.js +12 -159
  58. package/dist/lsp.js.map +1 -1
  59. package/dist/mcp-server.js +0 -26
  60. package/dist/mcp-server.js.map +1 -1
  61. package/dist/mcp.js +0 -113
  62. package/dist/mcp.js.map +1 -1
  63. package/dist/mod-tool.js +0 -130
  64. package/dist/mod-tool.js.map +1 -1
  65. package/dist/mod.js +0 -162
  66. package/dist/mod.js.map +1 -1
  67. package/dist/patch.js +0 -217
  68. package/dist/patch.js.map +1 -1
  69. package/dist/provenance.js +0 -140
  70. package/dist/provenance.js.map +1 -1
  71. package/dist/query.js +0 -75
  72. package/dist/query.js.map +1 -1
  73. package/dist/reach.js +0 -43
  74. package/dist/reach.js.map +1 -1
  75. package/dist/relation.d.ts +2 -0
  76. package/dist/relation.js +3 -58
  77. package/dist/relation.js.map +1 -1
  78. package/dist/render.js +33 -143
  79. package/dist/render.js.map +1 -1
  80. package/dist/report-sarif.d.ts +0 -11
  81. package/dist/report-sarif.js +0 -28
  82. package/dist/report-sarif.js.map +1 -1
  83. package/dist/sig.js +0 -35
  84. package/dist/sig.js.map +1 -1
  85. package/dist/sigdecl.js +1 -1
  86. package/dist/sigdecl.js.map +1 -1
  87. package/dist/siggate.js +0 -4
  88. package/dist/siggate.js.map +1 -1
  89. package/dist/site.js +3 -29
  90. package/dist/site.js.map +1 -1
  91. package/dist/subsume.d.ts +0 -10
  92. package/dist/subsume.js +0 -137
  93. package/dist/subsume.js.map +1 -1
  94. package/dist/template.d.ts +2 -1
  95. package/dist/template.js +58 -138
  96. package/dist/template.js.map +1 -1
  97. package/dist/trim.js +0 -41
  98. package/dist/trim.js.map +1 -1
  99. package/dist/tsconfig.tsbuildinfo +1 -1
  100. package/dist/type.js.map +1 -1
  101. package/dist/unify.js +12 -242
  102. package/dist/unify.js.map +1 -1
  103. package/dist/utility.js +0 -22
  104. package/dist/utility.js.map +1 -1
  105. package/dist/val/AbnfFuncVal.d.ts +18 -0
  106. package/dist/val/AbnfFuncVal.js +132 -0
  107. package/dist/val/AbnfFuncVal.js.map +1 -0
  108. package/dist/val/AbsentVal.d.ts +11 -0
  109. package/dist/val/AbsentVal.js +30 -0
  110. package/dist/val/AbsentVal.js.map +1 -0
  111. package/dist/val/AggFuncVal.d.ts +10 -1
  112. package/dist/val/AggFuncVal.js +104 -116
  113. package/dist/val/AggFuncVal.js.map +1 -1
  114. package/dist/val/ArithFuncVal.js +0 -12
  115. package/dist/val/ArithFuncVal.js.map +1 -1
  116. package/dist/val/BagVal.js +1 -78
  117. package/dist/val/BagVal.js.map +1 -1
  118. package/dist/val/BigDecimalVal.js +0 -16
  119. package/dist/val/BigDecimalVal.js.map +1 -1
  120. package/dist/val/BigIntegerVal.js +0 -16
  121. package/dist/val/BigIntegerVal.js.map +1 -1
  122. package/dist/val/CloseFuncVal.js +0 -9
  123. package/dist/val/CloseFuncVal.js.map +1 -1
  124. package/dist/val/CmpFuncVal.d.ts +20 -0
  125. package/dist/val/CmpFuncVal.js +188 -0
  126. package/dist/val/CmpFuncVal.js.map +1 -0
  127. package/dist/val/ConjunctVal.js +0 -29
  128. package/dist/val/ConjunctVal.js.map +1 -1
  129. package/dist/val/ConstraintVal.js +0 -500
  130. package/dist/val/ConstraintVal.js.map +1 -1
  131. package/dist/val/ContainerKindVal.js +0 -2
  132. package/dist/val/ContainerKindVal.js.map +1 -1
  133. package/dist/val/CopyFuncVal.js +0 -3
  134. package/dist/val/CopyFuncVal.js.map +1 -1
  135. package/dist/val/Decimal.js +0 -179
  136. package/dist/val/Decimal.js.map +1 -1
  137. package/dist/val/DeprecateFuncVal.js.map +1 -1
  138. package/dist/val/DisjunctVal.js +0 -152
  139. package/dist/val/DisjunctVal.js.map +1 -1
  140. package/dist/val/EachFuncVal.d.ts +1 -2
  141. package/dist/val/EachFuncVal.js +12 -29
  142. package/dist/val/EachFuncVal.js.map +1 -1
  143. package/dist/val/EmitFuncVal.d.ts +1 -1
  144. package/dist/val/EmitFuncVal.js +6 -119
  145. package/dist/val/EmitFuncVal.js.map +1 -1
  146. package/dist/val/ExpectVal.js +0 -62
  147. package/dist/val/ExpectVal.js.map +1 -1
  148. package/dist/val/FilterFuncVal.js +0 -25
  149. package/dist/val/FilterFuncVal.js.map +1 -1
  150. package/dist/val/FuncBaseVal.d.ts +1 -0
  151. package/dist/val/FuncBaseVal.js +7 -127
  152. package/dist/val/FuncBaseVal.js.map +1 -1
  153. package/dist/val/GraphAtomVal.js +0 -15
  154. package/dist/val/GraphAtomVal.js.map +1 -1
  155. package/dist/val/HideFuncVal.js +0 -13
  156. package/dist/val/HideFuncVal.js.map +1 -1
  157. package/dist/val/IntegerVal.js +0 -61
  158. package/dist/val/IntegerVal.js.map +1 -1
  159. package/dist/val/JunctionVal.js +0 -20
  160. package/dist/val/JunctionVal.js.map +1 -1
  161. package/dist/val/KeyFuncVal.js +0 -46
  162. package/dist/val/KeyFuncVal.js.map +1 -1
  163. package/dist/val/ListVal.js +0 -57
  164. package/dist/val/ListVal.js.map +1 -1
  165. package/dist/val/LowerFuncVal.js +11 -6
  166. package/dist/val/LowerFuncVal.js.map +1 -1
  167. package/dist/val/MapVal.js +0 -151
  168. package/dist/val/MapVal.js.map +1 -1
  169. package/dist/val/MatchFuncVal.js +0 -27
  170. package/dist/val/MatchFuncVal.js.map +1 -1
  171. package/dist/val/{FormFuncVal.d.ts → MaybeFuncVal.d.ts} +5 -5
  172. package/dist/val/MaybeFuncVal.js +50 -0
  173. package/dist/val/MaybeFuncVal.js.map +1 -0
  174. package/dist/val/MoveFuncVal.js +0 -18
  175. package/dist/val/MoveFuncVal.js.map +1 -1
  176. package/dist/val/NilVal.js +2 -36
  177. package/dist/val/NilVal.js.map +1 -1
  178. package/dist/val/NomFuncVal.d.ts +12 -0
  179. package/dist/val/NomFuncVal.js +153 -0
  180. package/dist/val/NomFuncVal.js.map +1 -0
  181. package/dist/val/NumberVal.js +0 -15
  182. package/dist/val/NumberVal.js.map +1 -1
  183. package/dist/val/OpBaseVal.d.ts +1 -0
  184. package/dist/val/OpBaseVal.js +3 -15
  185. package/dist/val/OpBaseVal.js.map +1 -1
  186. package/dist/val/PackFuncVal.js +0 -34
  187. package/dist/val/PackFuncVal.js.map +1 -1
  188. package/dist/val/PathFuncVal.js +0 -6
  189. package/dist/val/PathFuncVal.js.map +1 -1
  190. package/dist/val/PathVal.js +0 -41
  191. package/dist/val/PathVal.js.map +1 -1
  192. package/dist/val/PlaceVal.js +0 -25
  193. package/dist/val/PlaceVal.js.map +1 -1
  194. package/dist/val/PlusOpVal.d.ts +1 -7
  195. package/dist/val/PlusOpVal.js +13 -74
  196. package/dist/val/PlusOpVal.js.map +1 -1
  197. package/dist/val/PrefFuncVal.js +0 -1
  198. package/dist/val/PrefFuncVal.js.map +1 -1
  199. package/dist/val/PrefVal.js +0 -167
  200. package/dist/val/PrefVal.js.map +1 -1
  201. package/dist/val/RecurseVal.js +0 -55
  202. package/dist/val/RecurseVal.js.map +1 -1
  203. package/dist/val/RefVal.js +0 -282
  204. package/dist/val/RefVal.js.map +1 -1
  205. package/dist/val/ReferFuncVal.js +0 -232
  206. package/dist/val/ReferFuncVal.js.map +1 -1
  207. package/dist/val/ScalarKindVal.js +0 -49
  208. package/dist/val/ScalarKindVal.js.map +1 -1
  209. package/dist/val/ScalarVal.js +0 -11
  210. package/dist/val/ScalarVal.js.map +1 -1
  211. package/dist/val/StrFuncVal.js +0 -18
  212. package/dist/val/StrFuncVal.js.map +1 -1
  213. package/dist/val/SuperFuncVal.js +0 -32
  214. package/dist/val/SuperFuncVal.js.map +1 -1
  215. package/dist/val/TopVal.js +0 -1
  216. package/dist/val/TopVal.js.map +1 -1
  217. package/dist/val/TranslateFuncVal.d.ts +12 -0
  218. package/dist/val/TranslateFuncVal.js +99 -0
  219. package/dist/val/TranslateFuncVal.js.map +1 -0
  220. package/dist/val/UpperFuncVal.js +11 -6
  221. package/dist/val/UpperFuncVal.js.map +1 -1
  222. package/dist/val/Val.d.ts +1 -0
  223. package/dist/val/Val.js +2 -133
  224. package/dist/val/Val.js.map +1 -1
  225. package/dist/val/VarVal.js +0 -12
  226. package/dist/val/VarVal.js.map +1 -1
  227. package/dist/val/arith.js +0 -37
  228. package/dist/val/arith.js.map +1 -1
  229. package/dist/val/caserange.d.ts +3 -0
  230. package/dist/val/caserange.js +49 -0
  231. package/dist/val/caserange.js.map +1 -0
  232. package/dist/val/members.js +0 -6
  233. package/dist/val/members.js.map +1 -1
  234. package/dist/val/numcmp.js +0 -11
  235. package/dist/val/numcmp.js.map +1 -1
  236. package/dist/val/numkind.js +0 -145
  237. package/dist/val/numkind.js.map +1 -1
  238. package/dist/val/valutil.js +0 -16
  239. package/dist/val/valutil.js.map +1 -1
  240. package/dist/vet.d.ts +12 -0
  241. package/dist/vet.js +159 -412
  242. package/dist/vet.js.map +1 -1
  243. package/dist/view.js +0 -414
  244. package/dist/view.js.map +1 -1
  245. package/dist/walk.js +0 -41
  246. package/dist/walk.js.map +1 -1
  247. package/grammar/aontu.abnf +9 -7
  248. package/grammar/aontu.gbnf +5 -5
  249. package/grammar/aontu.lark +5 -5
  250. package/grammar/aontu.tmLanguage.json +1 -1
  251. package/package.json +4 -2
  252. package/skill/SKILL.md +8 -0
  253. package/skill/init/check.sh +28 -0
  254. package/skill/init/data.aon +12 -0
  255. package/skill/init/model.aon +19 -0
  256. package/skill/tasks.md +151 -0
  257. package/src/agentsmd.ts +8 -32
  258. package/src/alias.ts +0 -39
  259. package/src/allow.ts +221 -0
  260. package/src/aontu.ts +10 -108
  261. package/src/aontumodel.ts +32 -0
  262. package/src/cli.ts +1009 -540
  263. package/src/ctx.ts +0 -103
  264. package/src/diff.ts +0 -40
  265. package/src/err.ts +0 -40
  266. package/src/escape.ts +0 -46
  267. package/src/exactjson.ts +0 -131
  268. package/src/format.ts +63 -234
  269. package/src/grammar.ts +72 -0
  270. package/src/graph.ts +0 -61
  271. package/src/hcanon.ts +0 -82
  272. package/src/helpdoc.ts +77 -0
  273. package/src/hints.ts +72 -49
  274. package/src/jsonschema.ts +0 -123
  275. package/src/keyorder.ts +0 -42
  276. package/src/lang.ts +39 -895
  277. package/src/lower.ts +15 -65
  278. package/src/lsp-server.ts +0 -16
  279. package/src/lsp.ts +12 -180
  280. package/src/mcp-server.ts +0 -31
  281. package/src/mcp.ts +0 -130
  282. package/src/mod-tool.ts +0 -158
  283. package/src/mod.ts +0 -178
  284. package/src/patch.ts +0 -232
  285. package/src/provenance.ts +0 -183
  286. package/src/query.ts +0 -84
  287. package/src/reach.ts +0 -53
  288. package/src/relation.ts +7 -71
  289. package/src/render.ts +33 -180
  290. package/src/report-sarif.ts +0 -48
  291. package/src/sig.ts +0 -35
  292. package/src/sigdecl.ts +1 -1
  293. package/src/siggate.ts +0 -30
  294. package/src/site.ts +3 -29
  295. package/src/subsume.ts +1 -161
  296. package/src/template.ts +69 -140
  297. package/src/trim.ts +0 -53
  298. package/src/type.ts +2 -45
  299. package/src/unify.ts +13 -251
  300. package/src/utility.ts +0 -31
  301. package/src/val/AbnfFuncVal.ts +181 -0
  302. package/src/val/AbsentVal.ts +54 -0
  303. package/src/val/AggFuncVal.ts +152 -188
  304. package/src/val/ArithFuncVal.ts +0 -20
  305. package/src/val/BagVal.ts +1 -78
  306. package/src/val/BigDecimalVal.ts +0 -16
  307. package/src/val/BigIntegerVal.ts +0 -16
  308. package/src/val/CloseFuncVal.ts +0 -9
  309. package/src/val/CmpFuncVal.ts +249 -0
  310. package/src/val/ConjunctVal.ts +0 -33
  311. package/src/val/ConstraintVal.ts +2 -537
  312. package/src/val/ContainerKindVal.ts +0 -18
  313. package/src/val/CopyFuncVal.ts +0 -5
  314. package/src/val/Decimal.ts +1 -185
  315. package/src/val/DeprecateFuncVal.ts +0 -10
  316. package/src/val/DisjunctVal.ts +0 -157
  317. package/src/val/EachFuncVal.ts +12 -53
  318. package/src/val/EmitFuncVal.ts +8 -208
  319. package/src/val/ExpectVal.ts +0 -62
  320. package/src/val/FilterFuncVal.ts +0 -55
  321. package/src/val/FuncBaseVal.ts +9 -130
  322. package/src/val/GraphAtomVal.ts +0 -42
  323. package/src/val/HideFuncVal.ts +0 -15
  324. package/src/val/IntegerVal.ts +0 -61
  325. package/src/val/JunctionVal.ts +0 -20
  326. package/src/val/KeyFuncVal.ts +0 -48
  327. package/src/val/ListVal.ts +0 -59
  328. package/src/val/LowerFuncVal.ts +12 -7
  329. package/src/val/MapVal.ts +0 -151
  330. package/src/val/MatchFuncVal.ts +0 -59
  331. package/src/val/MaybeFuncVal.ts +86 -0
  332. package/src/val/MoveFuncVal.ts +0 -20
  333. package/src/val/NilVal.ts +2 -36
  334. package/src/val/NomFuncVal.ts +200 -0
  335. package/src/val/NumberVal.ts +0 -16
  336. package/src/val/OpBaseVal.ts +4 -17
  337. package/src/val/PackFuncVal.ts +0 -63
  338. package/src/val/PathFuncVal.ts +0 -32
  339. package/src/val/PathVal.ts +0 -66
  340. package/src/val/PlaceVal.ts +0 -45
  341. package/src/val/PlusOpVal.ts +18 -75
  342. package/src/val/PrefFuncVal.ts +0 -1
  343. package/src/val/PrefVal.ts +0 -179
  344. package/src/val/RecurseVal.ts +0 -81
  345. package/src/val/RefVal.ts +1 -285
  346. package/src/val/ReferFuncVal.ts +0 -255
  347. package/src/val/ScalarKindVal.ts +0 -50
  348. package/src/val/ScalarVal.ts +0 -12
  349. package/src/val/StrFuncVal.ts +0 -44
  350. package/src/val/SuperFuncVal.ts +0 -42
  351. package/src/val/TopVal.ts +0 -1
  352. package/src/val/TranslateFuncVal.ts +132 -0
  353. package/src/val/UpperFuncVal.ts +12 -7
  354. package/src/val/Val.ts +3 -192
  355. package/src/val/VarVal.ts +0 -15
  356. package/src/val/arith.ts +0 -92
  357. package/src/val/caserange.ts +53 -0
  358. package/src/val/members.ts +0 -23
  359. package/src/val/numcmp.ts +1 -27
  360. package/src/val/numkind.ts +0 -149
  361. package/src/val/valutil.ts +0 -16
  362. package/src/vet.ts +209 -504
  363. package/src/view.ts +0 -507
  364. package/src/walk.ts +0 -41
  365. package/dist/std.d.ts +0 -3
  366. package/dist/std.js +0 -637
  367. package/dist/std.js.map +0 -1
  368. package/dist/val/FormFuncVal.js +0 -55
  369. package/dist/val/FormFuncVal.js.map +0 -1
  370. package/src/std.ts +0 -648
  371. package/src/val/FormFuncVal.ts +0 -119
package/src/query.ts CHANGED
@@ -1,32 +1,6 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
  import { includeOpts } from './utility'
3
3
 
4
- // THE QUERY SURFACE (G7 phase 1,
5
- // docs/capability-review/g7-machine-access.md): select one node of an
6
- // evaluated document by path and render it — the slice an agent asks
7
- // for, instead of the whole file as one JSON blob.
8
- //
9
- // Evaluation is still GLOBAL. Unification has no partial mode to sell:
10
- // the whole document is evaluated and then one node is selected. What
11
- // `get` buys is the SIZE OF THE ANSWER, not the cost of producing it.
12
- //
13
- // The three projections are lattice ABSTRACTIONS, and each is defined
14
- // so that the view it prints is a valid Aontu document that SUBSUMES
15
- // the truth — generalisation, never distortion:
16
- //
17
- // - `types` replaces every concrete leaf with its own kind, using
18
- // the lattice's own superior() rather than a table of this file's
19
- // opinions: {"replicas":3} becomes {"replicas":integer}.
20
- // - `depth n` keeps structure to depth n and renders every elided
21
- // subtree as `top` — "no further information at this tier".
22
- // - `keys` is `depth 1` degenerated to a listing.
23
- //
24
- // That property is not a promise here: every projection row of
25
- // test/spec/query.tsv asserts subsume(view, truth) == 'subsumes' in
26
- // both runners, which G3 made mechanically checkable.
27
- //
28
- // Projections are NOT canonical form and are never fed to G6's hash,
29
- // which is why they are named views rather than spellings of --canon.
30
4
 
31
5
  import { Aontu } from './aontu'
32
6
  import type { TrustOptions } from './type'
@@ -49,13 +23,6 @@ export type QueryOptions = {
49
23
  // it resolves from its own directory (vet's schemaPath precedent).
50
24
  path?: string
51
25
 
52
- // The trust profile this run evaluates under (G5, docs/trust.md).
53
- // The source arrives from a caller, so the caller must be able to
54
- // say what it may reach: without this the include chain is the
55
- // default one, and `@"../../etc/passwd.aon"` reads whatever the
56
- // process can. (`@"x.js"` no longer executes -- ADR-012 refuses the
57
- // extension -- but reading is enough.) A server passes
58
- // `{include:'none'}`.
59
26
  trust?: TrustOptions
60
27
 
61
28
  // Extensions additionally read as text (the CLI's `--text-ext`).
@@ -67,8 +34,6 @@ export type QueryOptions = {
67
34
  export type QueryReport = {
68
35
  ok: boolean
69
36
  out: string
70
- // Empty when ok. G2's finding shape, deliberately: `get` invents no
71
- // error format (G7's own rule).
72
37
  findings: VetFinding[]
73
38
  }
74
39
 
@@ -76,10 +41,6 @@ export type QueryReport = {
76
41
  const TOP = 'top'
77
42
 
78
43
 
79
- // The nearest key at the parent of a path that named nothing, by a
80
- // plain edit distance over the sibling names — the "did you mean"
81
- // half of the no_path contract. Undefined when nothing is close
82
- // enough to be worth suggesting.
83
44
  export function nearestKey(
84
45
  want: string, have: string[]): string | undefined {
85
46
  let best: string | undefined
@@ -135,20 +96,12 @@ function pathText(path: string): string {
135
96
  }
136
97
 
137
98
 
138
- // The projection walk, exported for the direct unit tests (ADR-002,
139
- // ts/test/coverage3.test.ts): a junction member that is itself a
140
- // junction of more than one term keeps its parens, and no SOURCE
141
- // reaches that arm because norm flattens junctions at unification.
142
99
  export function projectFor(
143
100
  v: any, view: QueryView, depth: number): string {
144
101
  return project(v, view, depth)
145
102
  }
146
103
 
147
104
 
148
- // The canon-shaped views. One walk, two knobs: `types` generalises
149
- // each leaf through the lattice, `depth` elides below its level. Bags
150
- // recurse (their canon getters would render children through plain
151
- // canon, which neither knob can reach); everything else is a leaf.
152
105
  function project(v: any, view: QueryView, depth: number): string {
153
106
  if (depth <= 0) {
154
107
  return TOP
@@ -173,10 +126,6 @@ function project(v: any, view: QueryView, depth: number): string {
173
126
  keys.map((k) => project(v.peg[k], view, depth - 1)).join(',') +
174
127
  ']'
175
128
  }
176
- // Junctions and prefs are TRANSPARENT: not a structural tier (so
177
- // they do not spend a level of depth) but not a leaf either (so
178
- // `*8080|integer` generalises to `*integer|integer` rather than
179
- // collapsing to `top` and throwing the alternatives away).
180
129
  if (true === v?.isPref) {
181
130
  return '*' + project(v.peg, view, depth)
182
131
  }
@@ -188,12 +137,6 @@ function project(v: any, view: QueryView, depth: number): string {
188
137
  .join(true === v.isConjunct ? '&' : '|')
189
138
  }
190
139
 
191
- // A LEAF. Under `types` a CONCRETE scalar lifts to its own kind —
192
- // superior() is the lattice's answer, so the view subsumes the truth
193
- // by construction and not by this file's good intentions. Everything
194
- // else is already an abstraction (a kind marker, a constraint, an
195
- // unresolved reference) and is left alone: lifting `integer` to
196
- // `number` would generalise a shape view that was already a shape.
197
140
  return 'types' === view && true === v?.isScalar ? v.superior().canon : v.canon
198
141
  }
199
142
 
@@ -227,17 +170,7 @@ function finding(
227
170
  }
228
171
 
229
172
 
230
- // A document that does not stand up has no node to select. The
231
- // engine's own first error IS the report: the query surface adds
232
- // nothing to a diagnosis the evaluator already made. The path is the
233
- // DOCUMENT — what failed is the whole thing standing up, not the node
234
- // the caller asked about, which may never have existed.
235
173
  export function evalFailure(ctx: any): VetFinding {
236
- // ctx.err is never empty at a call site: every failure that reaches
237
- // one collected an error first — a parse that did not stand up, a
238
- // root that came back nil. Not coalesced, on the vet siteOf
239
- // precedent: an impossible state should fail loudly rather than be
240
- // quietly papered over with a made-up code.
241
174
  const err: any = ctx.err[0]
242
175
  return finding(err.why, '$', err.msg)
243
176
  }
@@ -292,12 +225,6 @@ export function get(
292
225
  }
293
226
 
294
227
  if ('json' === view) {
295
- // GENERATION CAN FAIL WHERE UNIFICATION DID NOT: `k: integer` is a
296
- // perfectly good unified document and not a concrete value, so the
297
- // json view of it is an error, exactly as `aontu file.aon` on the
298
- // same document is. Under `collect` the failure lands on the
299
- // context rather than throwing, so it has to be read back — the Go
300
- // port's Gen returns it as an error and the two must agree.
301
228
  const before = ctx.err.length
302
229
  const gen = node.gen(ctx)
303
230
  if (before < ctx.err.length) {
@@ -331,13 +258,6 @@ export type WhyReport = {
331
258
  }
332
259
 
333
260
 
334
- // WHY does the value at this path hold? Evaluate with the provenance
335
- // recorder on, select the node, and answer the ordered contributions
336
- // that met there — the positive twin of G2's error report.
337
- //
338
- // Two evaluations are NOT needed: the recorder rides the one run this
339
- // call makes. What it costs is site materialisation and one map entry
340
- // per path met, which an instrumented run pays knowingly.
341
261
  export function why(
342
262
  src: string, path: string, opts?: QueryOptions): WhyReport {
343
263
  const options = opts ?? {}
@@ -346,10 +266,6 @@ export function why(
346
266
  const ctx = aontu.ctx({ collect: true, prov })
347
267
  const parseOpts = null == options.path ? undefined : { path: options.path }
348
268
 
349
- // Parse and unify SEPARATELY, so the parsed tree can be stamped
350
- // before the fixpoint runs: a contribution is a value the author
351
- // wrote, and after unification there is no longer any way to tell
352
- // one from a value the engine minted on the way.
353
269
  const parsed: any = aontu.parse(src, parseOpts, ctx)
354
270
  if (0 < ctx.err.length || null == parsed) {
355
271
  return { ok: false, findings: [evalFailure(ctx)] }
package/src/reach.ts CHANGED
@@ -1,33 +1,6 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
  import { includeOpts } from './utility'
3
3
 
4
- // REACHABILITY OVER THE LINK GRAPH (the review's finding J,
5
- // use-cases/REVIEW.md): "ship a transitive `reaches(a, b)` check verb".
6
- //
7
- // `relations` answers questions about the edge set as a whole --- is it
8
- // acyclic, does every edge have its inverse, is every far end what the
9
- // relation says it is. This answers the question that needs the CLOSURE
10
- // rather than the edges: does anything `a` depends on, at any remove,
11
- // end up at `b`? That is the shape of every blast-radius question an
12
- // operator asks ("if the billing database goes, what falls over?") and
13
- // every containment question a policy asks ("nothing in the public tier
14
- // may reach the ledger"), and neither can be expressed by looking one
15
- // edge at a time.
16
- //
17
- // It is a VERB and not a constraint, for the same reason acyclicity is
18
- // (docs/reference-language.md, "Declared relations"): reachability is
19
- // global and non-monotone. One more edge can make an unreachable pair
20
- // reachable, so a lattice citizen asserting non-reachability could be
21
- // true and then false, and the lattice guarantee is that more
22
- // information never falsifies what has already been observed.
23
- //
24
- // TRANSITIVE, NOT REFLEXIVE-TRANSITIVE: `reaches(a, a)` is true only
25
- // when a path of one or more edges returns to `a`, which is the useful
26
- // answer (it says the graph has a cycle through `a`) rather than the
27
- // vacuous one.
28
- //
29
- // The Go twin is go/reach.go; what the two ports must agree on --- the
30
- // verdict and the path --- is test/spec/reach.tsv.
31
4
 
32
5
  import { Aontu } from './aontu'
33
6
  import { failureFinding } from './vet'
@@ -42,15 +15,8 @@ export type ReachVerdict = 'reaches' | 'unreachable' | 'error'
42
15
  export type ReachReport = {
43
16
  verdict: ReachVerdict
44
17
 
45
- // The path found, as `$.dotted` node paths from the source to the
46
- // destination, both included. Present ONLY on `reaches`: a path is
47
- // the evidence for the answer, and there is no evidence for a
48
- // negative one.
49
18
  path?: string[]
50
19
 
51
- // WHY the graph could not be looked at, in vet's finding shape (the
52
- // review's finding F): a document that does not stand up, or an
53
- // endpoint that names no node. Present ONLY on `error`.
54
20
  errors?: VetFinding[]
55
21
  }
56
22
 
@@ -62,9 +28,6 @@ export type ReachOptions = {
62
28
  // docs/trust.md).
63
29
  trust?: TrustOptions
64
30
 
65
- // Extensions additionally read as text (the CLI's `--text-ext`).
66
- // Rides beside `trust` because it is the other half of what an
67
- // include may read.
68
31
  textExt?: string[]
69
32
  // Follow only edges under this relation. Absent means follow every
70
33
  // edge, which is the whole graph and the commoner question.
@@ -72,10 +35,6 @@ export type ReachOptions = {
72
35
  }
73
36
 
74
37
 
75
- // The segments a `$.dotted` endpoint spells, or undefined when it is
76
- // not one. Reachability is between TREE POSITIONS (ADR-014), so an
77
- // endpoint is a path and nothing else --- the same spelling the report
78
- // prints back.
79
38
  export function parseNodePath(s: string): string[] | undefined {
80
39
  if ('$' === s) {
81
40
  return []
@@ -88,9 +47,6 @@ export function parseNodePath(s: string): string[] | undefined {
88
47
  }
89
48
 
90
49
 
91
- // Whether a path names a node of the evaluated tree. An endpoint that
92
- // exists but has no edges is a perfectly good question with the answer
93
- // `unreachable`; only one that names NOTHING is an error.
94
50
  function nodeAt(root: any, path: string[]): boolean {
95
51
  let node: any = root
96
52
  for (const seg of path) {
@@ -112,10 +68,6 @@ function endpointFinding(name: string, known: string[]): VetFinding {
112
68
  class: 'reference',
113
69
  severity: 'error',
114
70
  path: '$',
115
- // NOT "unreachable". An endpoint that names no node is a question
116
- // the document cannot answer, and answering it `no` would report a
117
- // typo as a fact about the model --- the fail-open shape this
118
- // review exists to retire.
119
71
  message: `${name} names no node in this document.`,
120
72
  sites: [],
121
73
  ...(0 === known.length ? {} : {
@@ -182,11 +134,6 @@ export function reachCheck(
182
134
  list.sort(cmpCodePoint)
183
135
  }
184
136
 
185
- // BREADTH-FIRST, so the path reported is a SHORTEST one --- the
186
- // evidence an operator wants is the tightest chain, not whichever the
187
- // walk happened to find first --- and, with the successors sorted, a
188
- // determined one: among shortest paths, the first in code-point order
189
- // at the first step that distinguishes them.
190
137
  const prev = new Map<string, string>()
191
138
  const seen = new Set<string>()
192
139
  let front: string[] = [from]
package/src/relation.ts CHANGED
@@ -1,29 +1,6 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
  import { includeOpts } from './utility'
3
3
 
4
- // RELATION GRAPH VERDICTS (RELATIONS.0.md §3.3, replacing the G4
5
- // phase 5 magic-key pass): acyclicity and inverse consistency over
6
- // the edge set, DECLARED by the graph atoms -- `acyclic()` and
7
- // `inverse(name)` conjoined at the field whose key is the predicate
8
- // -- and decided AFTER unification, never by it.
9
- //
10
- // Why not in the lattice. Both properties are GLOBAL and NON-MONOTONE:
11
- // an acyclic graph becomes cyclic when one more edge unifies in, and an
12
- // inverse that is present becomes absent when the far side is narrowed.
13
- // The lattice guarantee is that more information never falsifies what
14
- // has been observed, so a constraint that could be true and then false
15
- // is not a constraint the lattice may hold. These are facts about the
16
- // finished model, so the atoms only REGISTER during unification
17
- // (GraphAtomVal.register, onto ctx._reldecls), and the verdict lands
18
- // at GENERATION -- the sizing atoms' model -- where no more
19
- // information can arrive. The `relations` verb reports the same
20
- // verdict from the same declarations: one decision, two surfaces.
21
- //
22
- // The old declaration channel -- a `relations:` key at the document
23
- // root, read by name -- is GONE, discharging ADR-010's grandfather
24
- // clause: the engine no longer knows any spellable key. The target
25
- // half of the old declaration is `rel(t)`'s flow at the site, which
26
- // checks by unifying rather than by a report-layer probe.
27
4
 
28
5
  import { Aontu } from './aontu'
29
6
  import { failureFinding } from './vet'
@@ -40,13 +17,9 @@ export type RelationVerdict = 'pass' | 'fail' | 'error'
40
17
 
41
18
  export type RelationFinding = {
42
19
  code: string
43
- // The relation the finding is about.
44
20
  relation: string
45
21
  // Where the offending edge is written, as a `$.dotted.path`.
46
22
  at: string
47
- // For a cycle, the node paths it runs through, in the order the walk
48
- // found them, closing back on the first. For a missing inverse, the
49
- // two ends and the relation that should have mirrored it.
50
23
  detail: string[]
51
24
  }
52
25
 
@@ -54,35 +27,26 @@ export type RelationReport = {
54
27
  verdict: RelationVerdict
55
28
  findings: RelationFinding[]
56
29
 
57
- // WHY the graph could not be looked at, in the same finding shape
58
- // vet reports in (the review's finding F). `findings` is about the
59
- // GRAPH and stays that way; a document that does not stand up has no
60
- // graph to have findings about, and an `error` verdict used to
61
- // arrive with an empty list -- something is wrong, and nothing about
62
- // what. Present ONLY on an `error` verdict.
63
30
  errors?: VetFinding[]
31
+
32
+ declared?: number
64
33
  }
65
34
 
66
35
  export type RelationOptions = {
67
36
  // Where the document CAME FROM, so a relative `@"file"` load inside
68
37
  // it resolves from its own directory (trimCheck's precedent).
69
38
  path?: string
70
- // The include capability this document evaluates under (G5,
71
- // docs/trust.md). vet's precedent: the verb passes the profile the
72
- // caller asked for, and an absent option means today's default.
73
39
  trust?: TrustOptions
74
40
 
75
41
  // Extensions additionally read as text (the CLI's `--text-ext`).
76
42
  // Rides beside `trust` because it is the other half of what an
77
43
  // include may read.
78
44
  textExt?: string[]
45
+
46
+ count?: boolean
79
47
  }
80
48
 
81
49
 
82
- // The first cycle reachable from `start`, as the node paths it runs
83
- // through, or undefined. Depth-first with the path as the stack, and
84
- // the successors visited in sorted order, so the cycle a report names
85
- // is the same one in both ports.
86
50
  function findCycle(
87
51
  start: string,
88
52
  succ: Map<string, string[]>,
@@ -116,16 +80,11 @@ function findCycle(
116
80
  }
117
81
 
118
82
 
119
- // The verdict itself, pure over what the evaluation produced: the
120
- // registered declarations and the edge set. Shared by the generation
121
- // hook (relationErrors) and the `relations` verb, so the two surfaces
122
- // cannot disagree.
123
83
  export function relationFindings(
124
84
  decls: Map<string, RelDecl>, graph: Graph
125
85
  ): RelationFinding[] {
126
86
  const findings: RelationFinding[] = []
127
87
 
128
- // The edge set, indexed the two ways the checks read it.
129
88
  const byRelation = new Map<string, Edge[]>()
130
89
  const pairs = new Set<string>()
131
90
  for (const e of graph.edges) {
@@ -201,11 +160,6 @@ export function relationFindings(
201
160
  }
202
161
  }
203
162
 
204
- // SORTED, because a report is read by a machine that diffs it: by the
205
- // position the offending edge is written at, then by code, then by
206
- // the detail (two inverse declarations on one predicate can flag one
207
- // edge twice). The sort is STABLE and the predicates were iterated
208
- // in sorted order, so what order remains is fixed anyway.
209
163
  findings.sort((a, b) =>
210
164
  cmpCodePoint(a.at, b.at) || cmpCodePoint(a.code, b.code)
211
165
  || cmpCodePoint(a.detail.join(' '), b.detail.join(' ')))
@@ -214,11 +168,6 @@ export function relationFindings(
214
168
  }
215
169
 
216
170
 
217
- // The generation hook (Aontu.generate, between unification success
218
- // and value generation): each finding becomes a LOCATED evaluation
219
- // error at the offending edge, exactly as an unmet sizing atom
220
- // refuses at generation. Findings name node paths and positions the
221
- // document spelled, so the walk to the site cannot miss.
222
171
  export function relationErrors(ctx: any, root: any): void {
223
172
  const decls: Map<string, RelDecl> = ctx._reldecls
224
173
  if (0 === decls.size) {
@@ -236,11 +185,6 @@ export function relationErrors(ctx: any, root: any): void {
236
185
  }
237
186
  node = node?.peg?.[seg]
238
187
  }
239
- // No unwrap AFTER the walk: a finding's `at` names an edge
240
- // element, and an edge's element is a string -- an atom-wrapped
241
- // element mints no edge in the first place (the graph visit
242
- // descends atoms only at field values), so the walk cannot end on
243
- // an atom.
244
188
  ctx.adderr(makeNilErr(ctx, f.code, node, undefined, 'relate', {
245
189
  relation: f.relation,
246
190
  detail: f.detail.join(' -> '),
@@ -271,20 +215,11 @@ export function relationCheck(
271
215
  }
272
216
 
273
217
  const decls: Map<string, RelDecl> = (ctx as any)._reldecls
218
+ const counted = true === options.count ? { declared: decls.size } : {}
274
219
  if (0 === decls.size) {
275
- return { verdict: 'pass', findings: [] }
220
+ return { verdict: 'pass', findings: [], ...counted }
276
221
  }
277
222
 
278
- // NOR IS A DOCUMENT THAT CANNOT BE GENERATED. Unification can
279
- // succeed over a tree that still holds an unsettled disjunction --
280
- // more than one alternative admitted, which `disjunct_no_gen`
281
- // refuses at generation -- and the graph walk cannot read inside
282
- // one: the links in every alternative are invisible, so a mirror
283
- // the document plainly writes is missing from the edge set and
284
- // `inverse(n)` calls it missing. Generation is therefore asked
285
- // FIRST, on a collecting context of its own, and what it says is
286
- // the answer. Generation is what the atoms' verdict lands at, so
287
- // this is the same order the engine itself now runs in.
288
223
  const gctx = ctx.clone({ err: [], collect: true })
289
224
  root.gen(gctx)
290
225
  if (0 < gctx.err.length) {
@@ -299,5 +234,6 @@ export function relationCheck(
299
234
  return {
300
235
  verdict: 0 === findings.length ? 'pass' : 'fail',
301
236
  findings,
237
+ ...counted,
302
238
  }
303
239
  }