aontu 0.62.0 → 0.64.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 (373) hide show
  1. package/README.md +7 -7
  2. package/dist/agentsmd.js +0 -27
  3. package/dist/agentsmd.js.map +1 -1
  4. package/dist/alias.js.map +1 -1
  5. package/dist/allow.js +0 -92
  6. package/dist/allow.js.map +1 -1
  7. package/dist/aontu.d.ts +3 -3
  8. package/dist/aontu.js +4 -84
  9. package/dist/aontu.js.map +1 -1
  10. package/dist/aontumodel.d.ts +4 -0
  11. package/dist/aontumodel.js +27 -0
  12. package/dist/aontumodel.js.map +1 -0
  13. package/dist/casing.d.ts +5 -0
  14. package/dist/casing.js +90 -0
  15. package/dist/casing.js.map +1 -0
  16. package/dist/cli.d.ts +2 -2
  17. package/dist/cli.js +228 -935
  18. package/dist/cli.js.map +1 -1
  19. package/dist/ctx.js +0 -48
  20. package/dist/ctx.js.map +1 -1
  21. package/dist/diff.js +0 -32
  22. package/dist/diff.js.map +1 -1
  23. package/dist/err.js +0 -40
  24. package/dist/err.js.map +1 -1
  25. package/dist/escape.js +0 -45
  26. package/dist/escape.js.map +1 -1
  27. package/dist/exactjson.d.ts +0 -35
  28. package/dist/exactjson.js +0 -131
  29. package/dist/exactjson.js.map +1 -1
  30. package/dist/format.js +13 -203
  31. package/dist/format.js.map +1 -1
  32. package/dist/grammar.d.ts +9 -0
  33. package/dist/grammar.js +54 -0
  34. package/dist/grammar.js.map +1 -0
  35. package/dist/graph.js +0 -26
  36. package/dist/graph.js.map +1 -1
  37. package/dist/hcanon.js +0 -82
  38. package/dist/hcanon.js.map +1 -1
  39. package/dist/helpdoc.js +2 -2
  40. package/dist/helpdoc.js.map +1 -1
  41. package/dist/hints.d.ts +0 -6
  42. package/dist/hints.js +57 -55
  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 +17 -915
  50. package/dist/lang.js.map +1 -1
  51. package/dist/lsp-server.js +0 -16
  52. package/dist/lsp-server.js.map +1 -1
  53. package/dist/lsp.d.ts +1 -1
  54. package/dist/lsp.js +12 -159
  55. package/dist/lsp.js.map +1 -1
  56. package/dist/mcp-server.js +0 -26
  57. package/dist/mcp-server.js.map +1 -1
  58. package/dist/mcp.js +0 -149
  59. package/dist/mcp.js.map +1 -1
  60. package/dist/mod-tool.js +16 -131
  61. package/dist/mod-tool.js.map +1 -1
  62. package/dist/mod.js +0 -162
  63. package/dist/mod.js.map +1 -1
  64. package/dist/patch.js +0 -217
  65. package/dist/patch.js.map +1 -1
  66. package/dist/profile.d.ts +9 -0
  67. package/dist/profile.js +28 -0
  68. package/dist/profile.js.map +1 -0
  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.js +0 -61
  76. package/dist/relation.js.map +1 -1
  77. package/dist/report-sarif.d.ts +0 -11
  78. package/dist/report-sarif.js +0 -28
  79. package/dist/report-sarif.js.map +1 -1
  80. package/dist/sig.js +0 -35
  81. package/dist/sig.js.map +1 -1
  82. package/dist/sigdecl.js +1 -1
  83. package/dist/sigdecl.js.map +1 -1
  84. package/dist/siggate.js +0 -4
  85. package/dist/siggate.js.map +1 -1
  86. package/dist/site.js +3 -29
  87. package/dist/site.js.map +1 -1
  88. package/dist/subsume.d.ts +0 -10
  89. package/dist/subsume.js +0 -137
  90. package/dist/subsume.js.map +1 -1
  91. package/dist/template.d.ts +2 -1
  92. package/dist/template.js +58 -138
  93. package/dist/template.js.map +1 -1
  94. package/dist/trace.d.ts +21 -0
  95. package/dist/trace.js +107 -0
  96. package/dist/trace.js.map +1 -0
  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 +13 -248
  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 +2 -0
  125. package/dist/val/CmpFuncVal.js +49 -72
  126. package/dist/val/CmpFuncVal.js.map +1 -1
  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.js +0 -3
  141. package/dist/val/EachFuncVal.js.map +1 -1
  142. package/dist/val/EmitFuncVal.d.ts +1 -1
  143. package/dist/val/EmitFuncVal.js +6 -119
  144. package/dist/val/EmitFuncVal.js.map +1 -1
  145. package/dist/val/ExpectVal.js +0 -62
  146. package/dist/val/ExpectVal.js.map +1 -1
  147. package/dist/val/FilterFuncVal.js +0 -25
  148. package/dist/val/FilterFuncVal.js.map +1 -1
  149. package/dist/val/FuncBaseVal.d.ts +1 -0
  150. package/dist/val/FuncBaseVal.js +7 -127
  151. package/dist/val/FuncBaseVal.js.map +1 -1
  152. package/dist/val/GraphAtomVal.js +0 -15
  153. package/dist/val/GraphAtomVal.js.map +1 -1
  154. package/dist/val/HideFuncVal.js +0 -13
  155. package/dist/val/HideFuncVal.js.map +1 -1
  156. package/dist/val/IntegerVal.js +0 -61
  157. package/dist/val/IntegerVal.js.map +1 -1
  158. package/dist/val/JunctionVal.js +0 -20
  159. package/dist/val/JunctionVal.js.map +1 -1
  160. package/dist/val/KeyFuncVal.js +0 -46
  161. package/dist/val/KeyFuncVal.js.map +1 -1
  162. package/dist/val/ListVal.js +0 -57
  163. package/dist/val/ListVal.js.map +1 -1
  164. package/dist/val/LowerFuncVal.js +0 -11
  165. package/dist/val/LowerFuncVal.js.map +1 -1
  166. package/dist/val/MapVal.js +0 -151
  167. package/dist/val/MapVal.js.map +1 -1
  168. package/dist/val/MatchFuncVal.js +0 -27
  169. package/dist/val/MatchFuncVal.js.map +1 -1
  170. package/dist/val/{FormFuncVal.d.ts → MaybeFuncVal.d.ts} +5 -5
  171. package/dist/val/MaybeFuncVal.js +50 -0
  172. package/dist/val/MaybeFuncVal.js.map +1 -0
  173. package/dist/val/MoveFuncVal.js +0 -18
  174. package/dist/val/MoveFuncVal.js.map +1 -1
  175. package/dist/val/NilVal.js +0 -60
  176. package/dist/val/NilVal.js.map +1 -1
  177. package/dist/val/NomFuncVal.js +18 -54
  178. package/dist/val/NomFuncVal.js.map +1 -1
  179. package/dist/val/NumberVal.js +0 -15
  180. package/dist/val/NumberVal.js.map +1 -1
  181. package/dist/val/OpBaseVal.d.ts +1 -0
  182. package/dist/val/OpBaseVal.js +3 -15
  183. package/dist/val/OpBaseVal.js.map +1 -1
  184. package/dist/val/PackFuncVal.js +0 -34
  185. package/dist/val/PackFuncVal.js.map +1 -1
  186. package/dist/val/PathFuncVal.js +0 -6
  187. package/dist/val/PathFuncVal.js.map +1 -1
  188. package/dist/val/PathVal.js +0 -41
  189. package/dist/val/PathVal.js.map +1 -1
  190. package/dist/val/PlaceVal.js +0 -25
  191. package/dist/val/PlaceVal.js.map +1 -1
  192. package/dist/val/PlusOpVal.d.ts +1 -7
  193. package/dist/val/PlusOpVal.js +13 -74
  194. package/dist/val/PlusOpVal.js.map +1 -1
  195. package/dist/val/PrefFuncVal.js +0 -1
  196. package/dist/val/PrefFuncVal.js.map +1 -1
  197. package/dist/val/PrefVal.js +0 -167
  198. package/dist/val/PrefVal.js.map +1 -1
  199. package/dist/val/RecurseVal.js +0 -55
  200. package/dist/val/RecurseVal.js.map +1 -1
  201. package/dist/val/RefVal.js +0 -282
  202. package/dist/val/RefVal.js.map +1 -1
  203. package/dist/val/ReferFuncVal.js +3 -232
  204. package/dist/val/ReferFuncVal.js.map +1 -1
  205. package/dist/val/ScalarKindVal.js +0 -49
  206. package/dist/val/ScalarKindVal.js.map +1 -1
  207. package/dist/val/ScalarVal.js +0 -11
  208. package/dist/val/ScalarVal.js.map +1 -1
  209. package/dist/val/StrFuncVal.js +0 -18
  210. package/dist/val/StrFuncVal.js.map +1 -1
  211. package/dist/val/SuperFuncVal.js +0 -32
  212. package/dist/val/SuperFuncVal.js.map +1 -1
  213. package/dist/val/TopVal.js +0 -1
  214. package/dist/val/TopVal.js.map +1 -1
  215. package/dist/val/TranslateFuncVal.js +1 -3
  216. package/dist/val/TranslateFuncVal.js.map +1 -1
  217. package/dist/val/UpperFuncVal.js +0 -11
  218. package/dist/val/UpperFuncVal.js.map +1 -1
  219. package/dist/val/Val.d.ts +1 -0
  220. package/dist/val/Val.js +2 -133
  221. package/dist/val/Val.js.map +1 -1
  222. package/dist/val/VarVal.js +0 -12
  223. package/dist/val/VarVal.js.map +1 -1
  224. package/dist/val/arith.js +0 -37
  225. package/dist/val/arith.js.map +1 -1
  226. package/dist/val/caserange.js +0 -61
  227. package/dist/val/caserange.js.map +1 -1
  228. package/dist/val/members.js +0 -6
  229. package/dist/val/members.js.map +1 -1
  230. package/dist/val/numcmp.js +0 -11
  231. package/dist/val/numcmp.js.map +1 -1
  232. package/dist/val/numkind.js +0 -145
  233. package/dist/val/numkind.js.map +1 -1
  234. package/dist/val/valutil.js +0 -16
  235. package/dist/val/valutil.js.map +1 -1
  236. package/dist/vet.js +0 -461
  237. package/dist/vet.js.map +1 -1
  238. package/dist/view.js +0 -414
  239. package/dist/view.js.map +1 -1
  240. package/dist/walk.js +0 -41
  241. package/dist/walk.js.map +1 -1
  242. package/grammar/aontu.abnf +8 -6
  243. package/grammar/aontu.gbnf +4 -4
  244. package/grammar/aontu.lark +4 -4
  245. package/grammar/aontu.tmLanguage.json +1 -1
  246. package/package.json +4 -2
  247. package/skill/tasks.md +9 -7
  248. package/src/agentsmd.ts +0 -35
  249. package/src/alias.ts +0 -39
  250. package/src/allow.ts +1 -96
  251. package/src/aontu.ts +4 -116
  252. package/src/aontumodel.ts +26 -0
  253. package/src/casing.ts +95 -0
  254. package/src/cli.ts +258 -1024
  255. package/src/ctx.ts +0 -103
  256. package/src/diff.ts +0 -40
  257. package/src/err.ts +0 -40
  258. package/src/escape.ts +0 -46
  259. package/src/exactjson.ts +0 -131
  260. package/src/format.ts +14 -257
  261. package/src/grammar.ts +72 -0
  262. package/src/graph.ts +0 -61
  263. package/src/hcanon.ts +0 -82
  264. package/src/helpdoc.ts +2 -2
  265. package/src/hints.ts +69 -57
  266. package/src/jsonschema.ts +0 -123
  267. package/src/keyorder.ts +0 -42
  268. package/src/lang.ts +19 -931
  269. package/src/lsp-server.ts +0 -16
  270. package/src/lsp.ts +12 -180
  271. package/src/mcp-server.ts +0 -31
  272. package/src/mcp.ts +0 -169
  273. package/src/mod-tool.ts +18 -159
  274. package/src/mod.ts +0 -178
  275. package/src/patch.ts +0 -232
  276. package/src/profile.ts +42 -0
  277. package/src/provenance.ts +0 -183
  278. package/src/query.ts +0 -84
  279. package/src/reach.ts +0 -53
  280. package/src/relation.ts +0 -84
  281. package/src/report-sarif.ts +0 -48
  282. package/src/sig.ts +0 -35
  283. package/src/sigdecl.ts +1 -1
  284. package/src/siggate.ts +0 -30
  285. package/src/site.ts +3 -29
  286. package/src/subsume.ts +1 -161
  287. package/src/template.ts +69 -140
  288. package/src/trace.ts +157 -0
  289. package/src/trim.ts +0 -53
  290. package/src/type.ts +2 -45
  291. package/src/unify.ts +14 -257
  292. package/src/utility.ts +0 -31
  293. package/src/val/AbnfFuncVal.ts +181 -0
  294. package/src/val/AbsentVal.ts +54 -0
  295. package/src/val/AggFuncVal.ts +152 -188
  296. package/src/val/ArithFuncVal.ts +0 -20
  297. package/src/val/BagVal.ts +1 -78
  298. package/src/val/BigDecimalVal.ts +0 -16
  299. package/src/val/BigIntegerVal.ts +0 -16
  300. package/src/val/CloseFuncVal.ts +0 -9
  301. package/src/val/CmpFuncVal.ts +68 -184
  302. package/src/val/ConjunctVal.ts +0 -33
  303. package/src/val/ConstraintVal.ts +2 -537
  304. package/src/val/ContainerKindVal.ts +0 -18
  305. package/src/val/CopyFuncVal.ts +0 -5
  306. package/src/val/Decimal.ts +1 -185
  307. package/src/val/DeprecateFuncVal.ts +0 -10
  308. package/src/val/DisjunctVal.ts +0 -157
  309. package/src/val/EachFuncVal.ts +0 -40
  310. package/src/val/EmitFuncVal.ts +8 -208
  311. package/src/val/ExpectVal.ts +0 -62
  312. package/src/val/FilterFuncVal.ts +0 -55
  313. package/src/val/FuncBaseVal.ts +9 -130
  314. package/src/val/GraphAtomVal.ts +0 -42
  315. package/src/val/HideFuncVal.ts +0 -15
  316. package/src/val/IntegerVal.ts +0 -61
  317. package/src/val/JunctionVal.ts +0 -20
  318. package/src/val/KeyFuncVal.ts +0 -48
  319. package/src/val/ListVal.ts +0 -59
  320. package/src/val/LowerFuncVal.ts +0 -12
  321. package/src/val/MapVal.ts +0 -151
  322. package/src/val/MatchFuncVal.ts +0 -59
  323. package/src/val/MaybeFuncVal.ts +86 -0
  324. package/src/val/MoveFuncVal.ts +0 -20
  325. package/src/val/NilVal.ts +0 -60
  326. package/src/val/NomFuncVal.ts +10 -99
  327. package/src/val/NumberVal.ts +0 -16
  328. package/src/val/OpBaseVal.ts +4 -17
  329. package/src/val/PackFuncVal.ts +0 -63
  330. package/src/val/PathFuncVal.ts +0 -32
  331. package/src/val/PathVal.ts +0 -66
  332. package/src/val/PlaceVal.ts +0 -45
  333. package/src/val/PlusOpVal.ts +18 -75
  334. package/src/val/PrefFuncVal.ts +0 -1
  335. package/src/val/PrefVal.ts +0 -179
  336. package/src/val/RecurseVal.ts +0 -81
  337. package/src/val/RefVal.ts +1 -285
  338. package/src/val/ReferFuncVal.ts +4 -255
  339. package/src/val/ScalarKindVal.ts +0 -50
  340. package/src/val/ScalarVal.ts +0 -12
  341. package/src/val/StrFuncVal.ts +0 -44
  342. package/src/val/SuperFuncVal.ts +0 -42
  343. package/src/val/TopVal.ts +0 -1
  344. package/src/val/TranslateFuncVal.ts +1 -51
  345. package/src/val/UpperFuncVal.ts +0 -12
  346. package/src/val/Val.ts +3 -192
  347. package/src/val/VarVal.ts +0 -15
  348. package/src/val/arith.ts +0 -92
  349. package/src/val/caserange.ts +0 -62
  350. package/src/val/members.ts +0 -23
  351. package/src/val/numcmp.ts +1 -27
  352. package/src/val/numkind.ts +0 -149
  353. package/src/val/valutil.ts +0 -16
  354. package/src/vet.ts +1 -582
  355. package/src/view.ts +0 -507
  356. package/src/walk.ts +0 -41
  357. package/dist/lower.d.ts +0 -23
  358. package/dist/lower.js +0 -578
  359. package/dist/lower.js.map +0 -1
  360. package/dist/render.d.ts +0 -53
  361. package/dist/render.js +0 -547
  362. package/dist/render.js.map +0 -1
  363. package/dist/std.d.ts +0 -3
  364. package/dist/std.js +0 -672
  365. package/dist/std.js.map +0 -1
  366. package/dist/val/FormFuncVal.js +0 -55
  367. package/dist/val/FormFuncVal.js.map +0 -1
  368. package/dist/val/NamerFuncVal.d.ts +0 -12
  369. package/dist/val/NamerFuncVal.js +0 -176
  370. package/dist/val/NamerFuncVal.js.map +0 -1
  371. package/src/lower.ts +0 -636
  372. package/src/render.ts +0 -732
  373. package/src/std.ts +0 -683
package/src/trace.ts ADDED
@@ -0,0 +1,157 @@
1
+ /* Copyright (c) 2026 Richard Rodger, MIT License */
2
+
3
+
4
+ import type { Val } from './type'
5
+
6
+ import { Aontu } from './aontu'
7
+ import { cmpCodePoint } from './keyorder'
8
+ import { includeOpts } from './utility'
9
+ import { anchorAt, failureFinding } from './vet'
10
+ import { makeNilErr } from './err'
11
+
12
+ import type { IncludeOptions } from './utility'
13
+ import type { VetFinding } from './vet'
14
+
15
+
16
+ export type TraceOptions = IncludeOptions & {
17
+ path?: string
18
+ at?: string
19
+ }
20
+
21
+
22
+ export type TraceReport = {
23
+ verdict: 'ok' | 'error'
24
+ trace: TraceEntry[]
25
+ errors?: VetFinding[]
26
+ }
27
+
28
+
29
+ // WHAT A TRACE ENTRY CARRIES. The file it reached, the rule set that
30
+ // wrote it, and the model node the dispatch matched.
31
+ export type TraceEntry = {
32
+ at: string
33
+ file: string
34
+ node: string
35
+ rule: string
36
+ }
37
+
38
+
39
+ function walkVals(root: any, fn: (v: any, path: string[]) => void): void {
40
+ const walk = (v: any, path: string[]): void => {
41
+ fn(v, path)
42
+ if (true === v.isList && null != v.peg) {
43
+ for (let i = 0; i < v.peg.length; i++) {
44
+ walk(v.peg[i], [...path, String(i)])
45
+ }
46
+ }
47
+ else if (true === v.isMap && null != v.peg) {
48
+ for (const k of Object.keys(v.peg).sort(cmpCodePoint)) {
49
+ if (!v.aliasKeys?.includes(k)) {
50
+ walk(v.peg[k], [...path, k])
51
+ }
52
+ }
53
+ }
54
+ }
55
+ walk(root, [])
56
+ }
57
+
58
+
59
+ function addr(path: string[]): string {
60
+ return '$' + path.map((seg) => '.' + seg).join('')
61
+ }
62
+
63
+
64
+ function scalar(v: any): string | undefined {
65
+ return (true === v?.isScalar && 'string' === typeof v.peg) ? v.peg : undefined
66
+ }
67
+
68
+
69
+ function fileName(v: any): string | undefined {
70
+ if (true !== v?.isMap) {
71
+ return undefined
72
+ }
73
+ return 'File' === scalar(v.peg?.cmp) ? scalar(v.peg?.props?.peg?.name) :
74
+ undefined
75
+ }
76
+
77
+
78
+ // THE INNERMOST FILE WINS: the longest matching prefix, not the first.
79
+ function enclosing(files: { at: string, name: string }[],
80
+ path: string): string | undefined {
81
+ let best: string | undefined
82
+ let long = -1
83
+ for (const f of files) {
84
+ if ((path === f.at || path.startsWith(f.at + '.')) && f.at.length > long) {
85
+ best = f.name
86
+ long = f.at.length
87
+ }
88
+ }
89
+ return best
90
+ }
91
+
92
+
93
+ // Every piece a dispatch stamped, attributed to the file it reached.
94
+ // One pass: `walkVals` is depth-first in document order, so a file is
95
+ // always seen before the marks beneath it.
96
+ function traceTree(root: Val): TraceEntry[] {
97
+ const files: { at: string, name: string }[] = []
98
+ const marks: { at: string, mark: any }[] = []
99
+ walkVals(root, (v: any, path: string[]) => {
100
+ const name = fileName(v)
101
+ if (undefined !== name) {
102
+ files.push({ at: addr(path), name })
103
+ }
104
+ if (null != v.emitted) {
105
+ marks.push({ at: addr(path), mark: v.emitted })
106
+ }
107
+ })
108
+
109
+ const out: TraceEntry[] = []
110
+ for (const m of marks) {
111
+ const file = enclosing(files, m.at)
112
+ if (undefined === file) {
113
+ continue
114
+ }
115
+ out.push({ at: m.at, file, node: m.mark.node, rule: m.mark.rule })
116
+ }
117
+ return out
118
+ }
119
+
120
+
121
+ // THE MARKS ARE OPT-IN. `emit` stamps a piece only when the context
122
+ // carries a `reads` set, so the verb asks for one the way `render
123
+ // --trace` did.
124
+ function traceRun(src: string, options?: TraceOptions): TraceReport {
125
+ const opts = options ?? {}
126
+ const aontu = new Aontu(includeOpts(opts))
127
+ const actx = aontu.ctx({ collect: true, reads: new Set<string>() })
128
+ const root: any = aontu.unify(
129
+ src, { path: opts.path, collect: true }, actx)
130
+ if (0 < actx.err.length || true === root?.isNil) {
131
+ return {
132
+ verdict: 'error', trace: [],
133
+ errors: [failureFinding(actx, opts.path, root)],
134
+ }
135
+ }
136
+
137
+ let node: any = root
138
+ const at = opts.at ?? '$.out'
139
+ const found: any = anchorAt(root, at)
140
+ if (null == found) {
141
+ const nil: any = makeNilErr(actx, 'no_path', root, undefined, 'at')
142
+ actx.err.push(nil)
143
+ return {
144
+ verdict: 'error', trace: [],
145
+ errors: [failureFinding(actx, opts.path, root)],
146
+ }
147
+ }
148
+ node = found
149
+
150
+ return { verdict: 'ok', trace: traceTree(node) }
151
+ } /* node:coverage ignore next 6 */
152
+
153
+
154
+ export {
155
+ traceTree,
156
+ traceRun,
157
+ }
package/src/trim.ts CHANGED
@@ -1,26 +1,6 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
  import { includeOpts } from './utility'
3
3
 
4
- // The trim reporter (G3 phase 6,
5
- // docs/capability-review/g3-subsumption-evolution.md): report REDUNDANT
6
- // map entries — entries whose removal leaves the evaluated result
7
- // unchanged, the spread-implied case included — as paths. Report-only,
8
- // deliberately: canon discards comments and layout, so REWRITING the
9
- // file needs G7's format-preserving patch surface; trim ships as a
10
- // reporter here and becomes an editor there.
11
- //
12
- // The test is EVALUATE-AND-COMPARE: for each candidate entry, re-parse
13
- // the source, delete the entry from the parsed tree, evaluate, and
14
- // compare canons. This subsumes the design's spread case — an entry a
15
- // spread template re-supplies evaluates to the same canon without its
16
- // explicit spelling — and is honest about everything the fixpoint can
17
- // see (references, templates, duplicate-key merges), where a purely
18
- // structural test would guess. A removal that ERRORS is not redundant:
19
- // the entry is load-bearing.
20
- //
21
- // Parsed trees are single-use (docs/reference-api.md), so every probe
22
- // is its own parse: one evaluation per candidate plus one for the
23
- // baseline. A reporter can afford that; an editor loop belongs to G7.
24
4
 
25
5
  import { Aontu } from './aontu'
26
6
  import { failureFinding } from './vet'
@@ -34,12 +14,6 @@ export type TrimReport = {
34
14
  verdict: TrimVerdict
35
15
  redundant: string[]
36
16
 
37
- // WHY the run could not be made, in the same finding shape vet
38
- // reports in (the review's finding F). An `error` verdict used to
39
- // arrive with an empty report -- something is wrong with the
40
- // document, and nothing about what -- which is the one answer a
41
- // repair loop cannot act on. Present ONLY on an `error` verdict, so
42
- // a clean report stays exactly the two fields it always was.
43
17
  errors?: VetFinding[]
44
18
  }
45
19
 
@@ -47,14 +21,8 @@ export type TrimOptions = {
47
21
  // Where the document CAME FROM, so a relative `@"file"` load inside
48
22
  // it resolves from its own directory (vet's schemaPath precedent).
49
23
  path?: string
50
- // The include capability this document evaluates under (G5,
51
- // docs/trust.md). vet's precedent: the verb passes the profile the
52
- // caller asked for, and an absent option means today's default.
53
24
  trust?: TrustOptions
54
25
 
55
- // Extensions additionally read as text (the CLI's `--text-ext`).
56
- // Rides beside `trust` because it is the other half of what an
57
- // include may read.
58
26
  textExt?: string[]
59
27
  }
60
28
 
@@ -64,14 +32,6 @@ function pathText(path: string[]): string {
64
32
  }
65
33
 
66
34
 
67
- // Every (map, key) pair in a PARSED tree, parent-first. Candidates come
68
- // from the parse rather than the evaluation: an entry the fixpoint
69
- // erases or rewrites still has to be addressable for deletion. The
70
- // non-Val guard is for a bag's raw peg entries, which degenerate
71
- // parses can leave behind. Exported (with deleteAt and evalCanon) for
72
- // the direct unit tests (ADR-002, ts/test/coverage3.test.ts): the
73
- // defensive arms are unreachable through trimCheck, whose candidates
74
- // come from an identical parse.
75
35
  export function candidates(v: any, path: string[], out: string[][]): void {
76
36
  if (null == v || true !== v.isVal) {
77
37
  return
@@ -118,21 +78,12 @@ export function deleteAt(root: any, path: string[]): boolean {
118
78
  }
119
79
 
120
80
 
121
- // One evaluation: parse (deleting the entry at delPath, when given),
122
- // unify under collect, and answer the canon — or undefined when the
123
- // source does not stand up, which for the baseline is the caller's
124
- // error verdict and for a probe means "load-bearing".
125
81
  export function evalCanon(
126
82
  src: string, opts: TrimOptions, delPath?: string[],
127
83
  sink?: { ctx?: any, failed?: any }): string | undefined {
128
84
  const aontu = new Aontu(includeOpts(opts))
129
85
  const ctx = aontu.ctx({ collect: true })
130
86
  const parseOpts = null == opts.path ? undefined : { path: opts.path }
131
- // WHY the run failed, for the one caller that reports it. The
132
- // BASELINE run passes a sink and a probe does not: a probe's failure
133
- // means "load-bearing", which is an answer rather than a fault, and
134
- // reporting it would bury the one real finding under one entry's
135
- // worth of noise per candidate.
136
87
  const fail = (failed?: any): undefined => {
137
88
  if (null != sink) {
138
89
  sink.ctx = ctx
@@ -158,10 +109,6 @@ export function evalCanon(
158
109
  }
159
110
 
160
111
 
161
- // The whole reporter: the baseline canon, then one probe per candidate
162
- // entry, parent-first — and a child of a redundant parent is SKIPPED,
163
- // because "remove the whole entry" already covers it and reporting
164
- // both would tell the author to delete the same text twice.
165
112
  export function trimCheck(src: string, opts?: TrimOptions): TrimReport {
166
113
  const options = opts ?? {}
167
114
 
package/src/type.ts CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  import * as Fs from 'node:fs'
4
4
 
5
- // TODO: refactor these out
6
5
 
7
6
  import { Resolver } from '@tabnas/multisource'
8
7
 
@@ -13,35 +12,12 @@ import type { ValMark, ValSpec } from './val/Val'
13
12
  type FST = typeof Fs
14
13
 
15
14
 
16
-
17
- // The trust profile (G5, docs/trust.md): what an evaluation may read,
18
- // and how much work it may do. Trust is a property of the EVALUATION,
19
- // not the document -- a .aon file cannot request more capability -- and
20
- // the profile adds zero language syntax.
21
- //
22
- // The include capability:
23
- // 'none' @"..." is always denied
24
- // { mem: {...} } a virtual file set only; nothing else resolves
25
- // { root: '/dir' } real files, realpath-confined below root;
26
- // no package resolution
27
- // 'system' the full memory -> file -> package chain
28
- // (today's default, and the unconfined posture)
29
- //
30
- // Budgets are integer counts of engine events -- never wall-clock, which
31
- // would make identical inputs fail differently across machines (the
32
- // exact nondeterminism docs/trust.md forbids). The defaults are the
33
- // shared spec-visible constants pinned by test/spec/budget.tsv.
34
15
  type TrustInclude =
35
16
  | 'none'
36
17
  | 'system'
37
18
  | { mem: Record<string, string> }
38
19
  | { root: string }
39
20
 
40
- // Only the budgets BOTH ports can honour are profile surface: passes
41
- // and depth. The per-pair revisit bound (999) stays a TS-internal
42
- // constant — the Go dispatcher has no revisit counter (it is
43
- // depth-guarded), and a knob one port cannot implement would break the
44
- // parity contract (ADR-001) by construction.
45
21
  type TrustBudget = {
46
22
  passes?: number // fixpoint passes (default 9)
47
23
  depth?: number // structural recursion depth (default 1000)
@@ -53,21 +29,14 @@ type TrustOptions = {
53
29
  }
54
30
 
55
31
  type AontuOptions = {
56
- src?: string // Source text.
32
+ src?: string
57
33
  print?: number // Print debug verbosity
58
- resolver?: Resolver // Source resolver
34
+ resolver?: Resolver
59
35
  base?: string // Base path for resolver
60
36
  path?: string // Path of entry file
61
37
  debug?: boolean
62
38
  trace?: boolean
63
39
  fs?: FST
64
- // errfs READS FOR THE ERROR RENDERER ONLY, never for resolution.
65
- // A frame excerpts the file its arrow names, which means reading
66
- // that file -- but handing the same reader to `fs` would change
67
- // which leg the include RESOLVER takes (its file leg reads through
68
- // the host filesystem when one is given, so a package hit can
69
- // become a file hit), and a diagnostic must not move the boundary
70
- // it is describing.
71
40
  errfs?: FST
72
41
  deps?: any
73
42
  log?: any
@@ -77,19 +46,8 @@ type AontuOptions = {
77
46
  explain?: any[]
78
47
  trust?: TrustOptions // Trust profile (G5, docs/trust.md)
79
48
 
80
- // EXTENSIONS ADDITIONALLY READ AS TEXT, without their dots. `.txt`
81
- // is read as text with no option at all; this widens that set for a
82
- // host that keeps its prose in `.md`, its queries in `.sql`, or its
83
- // templates under some name only it knows. The file's bytes become
84
- // one string scalar -- no parser is chosen for it, which is what
85
- // makes widening the set safe to offer.
86
49
  textExt?: string[]
87
50
 
88
- // The staged-flip warning window (G5 phase 6, CLI only): under the
89
- // default 'system' capability the CLI supplies these, and the
90
- // resolver calls trustWarn for every resolution that escapes
91
- // trustWarnRoot or goes through package resolution — naming the flag
92
- // a future default will require. Not a stable embedding API.
93
51
  trustWarn?: (kind: 'escape' | 'pkg', path: string) => void
94
52
  trustWarnRoot?: string
95
53
  }
@@ -108,7 +66,6 @@ type ValMap = { [key: string]: Val }
108
66
  type ValList = Val[]
109
67
 
110
68
 
111
-
112
69
  type ErrContext = {
113
70
  src?: string,
114
71
  fs?: FST,