aontu 0.52.1 → 0.53.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 (272) hide show
  1. package/README.md +88 -0
  2. package/bin/aontu-mcp.js +4 -0
  3. package/dist/agentsmd.d.ts +16 -0
  4. package/dist/agentsmd.js +107 -0
  5. package/dist/agentsmd.js.map +1 -0
  6. package/dist/aontu.d.ts +14 -3
  7. package/dist/aontu.js +96 -4
  8. package/dist/aontu.js.map +1 -1
  9. package/dist/cli.d.ts +44 -1
  10. package/dist/cli.js +2401 -44
  11. package/dist/cli.js.map +1 -1
  12. package/dist/ctx.d.ts +13 -0
  13. package/dist/ctx.js +43 -0
  14. package/dist/ctx.js.map +1 -1
  15. package/dist/diff.d.ts +22 -0
  16. package/dist/diff.js +141 -0
  17. package/dist/diff.js.map +1 -0
  18. package/dist/err.d.ts +3 -1
  19. package/dist/err.js +38 -7
  20. package/dist/err.js.map +1 -1
  21. package/dist/graph.d.ts +16 -0
  22. package/dist/graph.js +73 -0
  23. package/dist/graph.js.map +1 -0
  24. package/dist/hcanon.d.ts +3 -0
  25. package/dist/hcanon.js +146 -0
  26. package/dist/hcanon.js.map +1 -0
  27. package/dist/hints.js +167 -4
  28. package/dist/hints.js.map +1 -1
  29. package/dist/jsonschema.d.ts +20 -0
  30. package/dist/jsonschema.js +391 -0
  31. package/dist/jsonschema.js.map +1 -0
  32. package/dist/lang.js +512 -69
  33. package/dist/lang.js.map +1 -1
  34. package/dist/lsp.d.ts +9 -2
  35. package/dist/lsp.js +262 -47
  36. package/dist/lsp.js.map +1 -1
  37. package/dist/mcp-server.d.ts +20 -0
  38. package/dist/mcp-server.js +147 -0
  39. package/dist/mcp-server.js.map +1 -0
  40. package/dist/mcp.d.ts +42 -0
  41. package/dist/mcp.js +814 -0
  42. package/dist/mcp.js.map +1 -0
  43. package/dist/mod-tool.d.ts +58 -0
  44. package/dist/mod-tool.js +498 -0
  45. package/dist/mod-tool.js.map +1 -0
  46. package/dist/mod.d.ts +31 -0
  47. package/dist/mod.js +250 -0
  48. package/dist/mod.js.map +1 -0
  49. package/dist/patch.d.ts +44 -0
  50. package/dist/patch.js +506 -0
  51. package/dist/patch.js.map +1 -0
  52. package/dist/provenance.d.ts +40 -0
  53. package/dist/provenance.js +335 -0
  54. package/dist/provenance.js.map +1 -0
  55. package/dist/query.d.ts +27 -0
  56. package/dist/query.js +294 -0
  57. package/dist/query.js.map +1 -0
  58. package/dist/reach.d.ts +14 -0
  59. package/dist/reach.js +140 -0
  60. package/dist/reach.js.map +1 -0
  61. package/dist/relation.d.ts +19 -0
  62. package/dist/relation.js +305 -0
  63. package/dist/relation.js.map +1 -0
  64. package/dist/report-sarif.d.ts +14 -0
  65. package/dist/report-sarif.js +102 -0
  66. package/dist/report-sarif.js.map +1 -0
  67. package/dist/site.d.ts +4 -0
  68. package/dist/site.js +31 -0
  69. package/dist/site.js.map +1 -1
  70. package/dist/std.d.ts +1 -0
  71. package/dist/std.js +73 -0
  72. package/dist/std.js.map +1 -0
  73. package/dist/subsume.d.ts +39 -0
  74. package/dist/subsume.js +526 -0
  75. package/dist/subsume.js.map +1 -0
  76. package/dist/trim.d.ts +19 -0
  77. package/dist/trim.js +155 -0
  78. package/dist/trim.js.map +1 -0
  79. package/dist/tsconfig.tsbuildinfo +1 -1
  80. package/dist/type.d.ts +17 -1
  81. package/dist/type.js.map +1 -1
  82. package/dist/unify.d.ts +2 -1
  83. package/dist/unify.js +253 -36
  84. package/dist/unify.js.map +1 -1
  85. package/dist/utility.d.ts +9 -1
  86. package/dist/utility.js +122 -1
  87. package/dist/utility.js.map +1 -1
  88. package/dist/val/AggFuncVal.d.ts +33 -0
  89. package/dist/val/AggFuncVal.js +202 -0
  90. package/dist/val/AggFuncVal.js.map +1 -0
  91. package/dist/val/ArithFuncVal.d.ts +31 -0
  92. package/dist/val/ArithFuncVal.js +62 -0
  93. package/dist/val/ArithFuncVal.js.map +1 -0
  94. package/dist/val/BagVal.d.ts +5 -0
  95. package/dist/val/BagVal.js +96 -5
  96. package/dist/val/BagVal.js.map +1 -1
  97. package/dist/val/CloseFuncVal.js +9 -1
  98. package/dist/val/CloseFuncVal.js.map +1 -1
  99. package/dist/val/ConjunctVal.d.ts +1 -1
  100. package/dist/val/ConjunctVal.js +19 -0
  101. package/dist/val/ConjunctVal.js.map +1 -1
  102. package/dist/val/ConstraintVal.d.ts +7 -1
  103. package/dist/val/ConstraintVal.js +490 -40
  104. package/dist/val/ConstraintVal.js.map +1 -1
  105. package/dist/val/CopyFuncVal.d.ts +1 -2
  106. package/dist/val/CopyFuncVal.js +7 -0
  107. package/dist/val/CopyFuncVal.js.map +1 -1
  108. package/dist/val/Decimal.d.ts +1 -0
  109. package/dist/val/Decimal.js +13 -0
  110. package/dist/val/Decimal.js.map +1 -1
  111. package/dist/val/DeprecateFuncVal.d.ts +11 -0
  112. package/dist/val/DeprecateFuncVal.js +47 -0
  113. package/dist/val/DeprecateFuncVal.js.map +1 -0
  114. package/dist/val/DisjunctVal.js +130 -21
  115. package/dist/val/DisjunctVal.js.map +1 -1
  116. package/dist/val/EachFuncVal.d.ts +15 -0
  117. package/dist/val/EachFuncVal.js +75 -0
  118. package/dist/val/EachFuncVal.js.map +1 -0
  119. package/dist/val/ExpectVal.js +27 -4
  120. package/dist/val/ExpectVal.js.map +1 -1
  121. package/dist/val/FeatureVal.js +1 -1
  122. package/dist/val/FeatureVal.js.map +1 -1
  123. package/dist/val/FilterFuncVal.d.ts +15 -0
  124. package/dist/val/FilterFuncVal.js +91 -0
  125. package/dist/val/FilterFuncVal.js.map +1 -0
  126. package/dist/val/FuncBaseVal.d.ts +6 -1
  127. package/dist/val/FuncBaseVal.js +171 -1
  128. package/dist/val/FuncBaseVal.js.map +1 -1
  129. package/dist/val/HideFuncVal.js.map +1 -1
  130. package/dist/val/IdFuncVal.d.ts +13 -0
  131. package/dist/val/IdFuncVal.js +54 -0
  132. package/dist/val/IdFuncVal.js.map +1 -0
  133. package/dist/val/JunctionVal.js +7 -1
  134. package/dist/val/JunctionVal.js.map +1 -1
  135. package/dist/val/KeyFuncVal.d.ts +1 -1
  136. package/dist/val/KeyFuncVal.js +38 -30
  137. package/dist/val/KeyFuncVal.js.map +1 -1
  138. package/dist/val/ListVal.js +101 -14
  139. package/dist/val/ListVal.js.map +1 -1
  140. package/dist/val/LowerFuncVal.js.map +1 -1
  141. package/dist/val/MapVal.js +93 -8
  142. package/dist/val/MapVal.js.map +1 -1
  143. package/dist/val/MatchFuncVal.d.ts +15 -0
  144. package/dist/val/MatchFuncVal.js +107 -0
  145. package/dist/val/MatchFuncVal.js.map +1 -0
  146. package/dist/val/MoveFuncVal.js.map +1 -1
  147. package/dist/val/NilVal.js +24 -0
  148. package/dist/val/NilVal.js.map +1 -1
  149. package/dist/val/OpBaseVal.d.ts +1 -1
  150. package/dist/val/OpBaseVal.js +19 -1
  151. package/dist/val/OpBaseVal.js.map +1 -1
  152. package/dist/val/OpenFuncVal.js +4 -1
  153. package/dist/val/OpenFuncVal.js.map +1 -1
  154. package/dist/val/PackFuncVal.d.ts +15 -0
  155. package/dist/val/PackFuncVal.js +108 -0
  156. package/dist/val/PackFuncVal.js.map +1 -0
  157. package/dist/val/PathFuncVal.js.map +1 -1
  158. package/dist/val/PlaceVal.d.ts +13 -0
  159. package/dist/val/PlaceVal.js +131 -0
  160. package/dist/val/PlaceVal.js.map +1 -0
  161. package/dist/val/PlusOpVal.js +11 -2
  162. package/dist/val/PlusOpVal.js.map +1 -1
  163. package/dist/val/PrefFuncVal.js.map +1 -1
  164. package/dist/val/PrefVal.d.ts +2 -2
  165. package/dist/val/PrefVal.js +78 -23
  166. package/dist/val/PrefVal.js.map +1 -1
  167. package/dist/val/RefVal.d.ts +1 -1
  168. package/dist/val/RefVal.js +89 -7
  169. package/dist/val/RefVal.js.map +1 -1
  170. package/dist/val/ReferFuncVal.d.ts +36 -0
  171. package/dist/val/ReferFuncVal.js +303 -0
  172. package/dist/val/ReferFuncVal.js.map +1 -0
  173. package/dist/val/ScalarKindVal.d.ts +1 -2
  174. package/dist/val/ScalarKindVal.js +0 -11
  175. package/dist/val/ScalarKindVal.js.map +1 -1
  176. package/dist/val/TopVal.js.map +1 -1
  177. package/dist/val/TypeFuncVal.js.map +1 -1
  178. package/dist/val/UpperFuncVal.js.map +1 -1
  179. package/dist/val/Val.d.ts +8 -1
  180. package/dist/val/Val.js +150 -1
  181. package/dist/val/Val.js.map +1 -1
  182. package/dist/val/VarVal.js.map +1 -1
  183. package/dist/val/arith.d.ts +6 -0
  184. package/dist/val/arith.js +170 -0
  185. package/dist/val/arith.js.map +1 -0
  186. package/dist/vet.d.ts +45 -0
  187. package/dist/vet.js +776 -0
  188. package/dist/vet.js.map +1 -0
  189. package/dist/walk.d.ts +2 -0
  190. package/dist/walk.js +91 -0
  191. package/dist/walk.js.map +1 -0
  192. package/grammar/aontu.gbnf +130 -0
  193. package/grammar/aontu.lark +113 -0
  194. package/package.json +21 -6
  195. package/skill/SKILL.md +37 -0
  196. package/skill/error-codes.md +62 -0
  197. package/skill/examples.md +99 -0
  198. package/skill/grammar-card.md +57 -0
  199. package/src/agentsmd.ts +135 -0
  200. package/src/aontu.ts +135 -4
  201. package/src/cli.ts +2858 -71
  202. package/src/ctx.ts +73 -1
  203. package/src/diff.ts +196 -0
  204. package/src/err.ts +42 -7
  205. package/src/graph.ts +135 -0
  206. package/src/hcanon.ts +169 -0
  207. package/src/hints.ts +208 -4
  208. package/src/jsonschema.ts +511 -0
  209. package/src/lang.ts +570 -70
  210. package/src/lsp.ts +281 -48
  211. package/src/mcp-server.ts +187 -0
  212. package/src/mcp.ts +993 -0
  213. package/src/mod-tool.ts +679 -0
  214. package/src/mod.ts +344 -0
  215. package/src/patch.ts +624 -0
  216. package/src/provenance.ts +430 -0
  217. package/src/query.ts +379 -0
  218. package/src/reach.ts +184 -0
  219. package/src/relation.ts +395 -0
  220. package/src/report-sarif.ts +137 -0
  221. package/src/site.ts +36 -1
  222. package/src/std.ts +73 -0
  223. package/src/subsume.ts +690 -0
  224. package/src/trim.ts +195 -0
  225. package/src/tsconfig.json +10 -4
  226. package/src/type.ts +51 -2
  227. package/src/unify.ts +274 -36
  228. package/src/utility.ts +139 -1
  229. package/src/val/AggFuncVal.ts +319 -0
  230. package/src/val/ArithFuncVal.ts +108 -0
  231. package/src/val/BagVal.ts +101 -4
  232. package/src/val/CloseFuncVal.ts +9 -1
  233. package/src/val/ConjunctVal.ts +20 -0
  234. package/src/val/ConstraintVal.ts +542 -43
  235. package/src/val/CopyFuncVal.ts +7 -1
  236. package/src/val/Decimal.ts +15 -0
  237. package/src/val/DeprecateFuncVal.ts +84 -0
  238. package/src/val/DisjunctVal.ts +139 -28
  239. package/src/val/EachFuncVal.ts +133 -0
  240. package/src/val/ExpectVal.ts +28 -6
  241. package/src/val/FeatureVal.ts +1 -1
  242. package/src/val/FilterFuncVal.ts +154 -0
  243. package/src/val/FuncBaseVal.ts +192 -1
  244. package/src/val/HideFuncVal.ts +0 -2
  245. package/src/val/IdFuncVal.ts +91 -0
  246. package/src/val/JunctionVal.ts +7 -1
  247. package/src/val/KeyFuncVal.ts +39 -35
  248. package/src/val/ListVal.ts +108 -15
  249. package/src/val/LowerFuncVal.ts +0 -1
  250. package/src/val/MapVal.ts +99 -8
  251. package/src/val/MatchFuncVal.ts +176 -0
  252. package/src/val/MoveFuncVal.ts +0 -2
  253. package/src/val/NilVal.ts +25 -0
  254. package/src/val/OpBaseVal.ts +20 -1
  255. package/src/val/OpenFuncVal.ts +4 -2
  256. package/src/val/PackFuncVal.ts +175 -0
  257. package/src/val/PathFuncVal.ts +0 -1
  258. package/src/val/PlaceVal.ts +193 -0
  259. package/src/val/PlusOpVal.ts +11 -2
  260. package/src/val/PrefFuncVal.ts +0 -1
  261. package/src/val/PrefVal.ts +79 -36
  262. package/src/val/RefVal.ts +91 -8
  263. package/src/val/ReferFuncVal.ts +387 -0
  264. package/src/val/ScalarKindVal.ts +0 -13
  265. package/src/val/TopVal.ts +0 -1
  266. package/src/val/TypeFuncVal.ts +0 -2
  267. package/src/val/UpperFuncVal.ts +0 -1
  268. package/src/val/Val.ts +205 -2
  269. package/src/val/VarVal.ts +0 -1
  270. package/src/val/arith.ts +316 -0
  271. package/src/vet.ts +992 -0
  272. package/src/walk.ts +99 -0
package/dist/lang.js CHANGED
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Site = exports.Lang = void 0;
5
5
  // import { performance } from 'node:perf_hooks'
6
+ // Named imports, not `import * as`: the namespace form makes tsc emit
7
+ // the __importStar downlevel helper, whose branches no supported Node
8
+ // takes (the same rule cli.ts records). Aliased because `Path` is
9
+ // already the @tabnas/path plugin below.
10
+ const node_fs_1 = require("node:fs");
11
+ const node_path_1 = require("node:path");
6
12
  const jsonic_1 = require("@tabnas/jsonic");
7
13
  const debug_1 = require("@tabnas/debug");
8
14
  const multisource_1 = require("@tabnas/multisource");
@@ -10,6 +16,8 @@ const multisource_1 = require("@tabnas/multisource");
10
16
  const file_1 = require("@tabnas/multisource/resolver/file");
11
17
  const pkg_1 = require("@tabnas/multisource/resolver/pkg");
12
18
  const mem_1 = require("@tabnas/multisource/resolver/mem");
19
+ const std_1 = require("./std");
20
+ const mod_1 = require("./mod");
13
21
  const expr_1 = require("@tabnas/expr");
14
22
  const path_1 = require("@tabnas/path");
15
23
  const type_1 = require("./type");
@@ -41,6 +49,16 @@ const CopyFuncVal_1 = require("./val/CopyFuncVal");
41
49
  const KeyFuncVal_1 = require("./val/KeyFuncVal");
42
50
  const TypeFuncVal_1 = require("./val/TypeFuncVal");
43
51
  const HideFuncVal_1 = require("./val/HideFuncVal");
52
+ const DeprecateFuncVal_1 = require("./val/DeprecateFuncVal");
53
+ const IdFuncVal_1 = require("./val/IdFuncVal");
54
+ const ReferFuncVal_1 = require("./val/ReferFuncVal");
55
+ const PackFuncVal_1 = require("./val/PackFuncVal");
56
+ const EachFuncVal_1 = require("./val/EachFuncVal");
57
+ const FilterFuncVal_1 = require("./val/FilterFuncVal");
58
+ const MatchFuncVal_1 = require("./val/MatchFuncVal");
59
+ const ArithFuncVal_1 = require("./val/ArithFuncVal");
60
+ const AggFuncVal_1 = require("./val/AggFuncVal");
61
+ const PlaceVal_1 = require("./val/PlaceVal");
44
62
  const MoveFuncVal_1 = require("./val/MoveFuncVal");
45
63
  const PathFuncVal_1 = require("./val/PathFuncVal");
46
64
  const PrefFuncVal_1 = require("./val/PrefFuncVal");
@@ -201,6 +219,16 @@ let AontuJsonic = function AontuLang(jsonic) {
201
219
  v.site.row = null == r.o0 ? -1 : r.o0.rI;
202
220
  v.site.col = null == r.o0 ? -1 : r.o0.cI;
203
221
  v.site.url = ctx.meta.multisource ? ctx.meta.multisource.path : '';
222
+ // The source text, from the SAME token the row and column above
223
+ // come from. jsonic has carried it all along; not reading it is
224
+ // what left a site uneditable (ts/src/site.ts).
225
+ //
226
+ // A TOKEN WITH NO TEXT IS NO SPAN, in both ports, and the extent is
227
+ // DERIVED from the text rather than read from the token's own `len`
228
+ // — so the Go twin, whose token has no len field, computes the
229
+ // identical number with utf16Len and nothing has to be kept in step.
230
+ v.site.src = null == r.o0 ? '' : r.o0.src;
231
+ v.site.len = '' === v.site.src ? -1 : v.site.src.length;
204
232
  // A keyed rule always carries a path array; a keyless one has none.
205
233
  v.path = r.k ? [...r.k.path] : [];
206
234
  return v;
@@ -264,6 +292,12 @@ help isolate the syntax error.`,
264
292
  },
265
293
  // TODO: FIX: need a TOP instance to hold path
266
294
  'top': { val: () => (0, top_1.top)() },
295
+ // G8 phase 3: the placeholder. A BARE `_` is the hole; `"_"`
296
+ // quoted, and any longer bare word containing it, stay text.
297
+ // Reserving it is a breaking change, pinned by place.tsv.
298
+ '_': {
299
+ val: (r, ctx) => addsite(new PlaceVal_1.PlaceVal({}), r, ctx)
300
+ },
267
301
  }
268
302
  },
269
303
  map: {
@@ -330,6 +364,57 @@ help isolate the syntax error.`,
330
364
  // reported with the author's own message, never simplified and
331
365
  // never consulted for emptiness or subsumption.
332
366
  must: ConstraintVal_1.MustConstraintVal,
367
+ // G3 phase 4: the deprecation mark. Unification-transparent; the
368
+ // record rides the result (Val.deprecation) and canon renders the
369
+ // call back (canonRiders).
370
+ deprecate: DeprecateFuncVal_1.DeprecateFuncVal,
371
+ // G4 phase 1: the identity mark. Written as a conjunct
372
+ // (`id(svc/auth) & {…}`), it resolves to the unit carrying the
373
+ // name, and every node in one evaluation with that name is
374
+ // unified with every other.
375
+ id: IdFuncVal_1.IdFuncVal,
376
+ // G4 phase 2: the checked, typed, LINK-shaped reference. A
377
+ // constraint on a string field: the string must be an entity
378
+ // address, the address must resolve, and the optional argument
379
+ // flows INTO the target. The field keeps the string.
380
+ refer: ReferFuncVal_1.ReferFuncVal,
381
+ // G8 phase 1: the generation combinators. `pack` makes one keyed
382
+ // child per child of its data, `each` one list element; both clone
383
+ // their template per destination exactly as a spread does, and both
384
+ // wait for the model to settle before they fire (the staging rule,
385
+ // G8 phase 0).
386
+ pack: PackFuncVal_1.PackFuncVal,
387
+ each: EachFuncVal_1.EachFuncVal,
388
+ // G8 phase 2: selection. `filter` keeps the children of a bag that
389
+ // unify with a condition; `match` picks the first arm whose
390
+ // pattern the scrutinee unifies with. Both select by
391
+ // UNIFIABILITY, tried in trial mode, so neither adds a predicate
392
+ // language to the one the lattice already is.
393
+ filter: FilterFuncVal_1.FilterFuncVal,
394
+ match: MatchFuncVal_1.MatchFuncVal,
395
+ // The arithmetic family (the review's finding I). Maths beyond `+`
396
+ // arrives as FUNCTIONS — `-` `*` `/` `%` stay reserved — and the
397
+ // family is numeric where the operator is polymorphic, which is
398
+ // what makes `add` more than a second spelling of `+`: it refuses
399
+ // the string concatenation that silently answers `"500m" + "500m"`.
400
+ // Every rule they obey is in ts/src/val/arith.ts.
401
+ add: ArithFuncVal_1.AddFuncVal,
402
+ sub: ArithFuncVal_1.SubFuncVal,
403
+ mul: ArithFuncVal_1.MulFuncVal,
404
+ div: ArithFuncVal_1.DivFuncVal,
405
+ mod: ArithFuncVal_1.ModFuncVal,
406
+ rem: ArithFuncVal_1.RemFuncVal,
407
+ // Aggregation over a finite, settled bag (the review's finding I).
408
+ // `least` and `greatest` rather than min and max, which are already
409
+ // the atoms for a lower and an upper BOUND -- an aggregate over a
410
+ // set and a bound on a value must not share a spelling.
411
+ sum: AggFuncVal_1.SumFuncVal,
412
+ least: AggFuncVal_1.LeastFuncVal,
413
+ greatest: AggFuncVal_1.GreatestFuncVal,
414
+ // Projection, which is what lets the aggregates reach a bag of
415
+ // RECORDS: `sum(pick($.lines, amountCents))`. Not a clever `each`
416
+ // template -- `each` MEETS each child, and a meet cannot select.
417
+ pick: AggFuncVal_1.PickFuncVal,
333
418
  };
334
419
  // A dangling operator (`a:1|`, `a:$`, `a:*` at end of input) leaves
335
420
  // null/undefined unfilled terms. Junction ops drop them (so `a:1&`
@@ -338,6 +423,106 @@ help isolate the syntax error.`,
338
423
  // resolve value" error (the Go port mirrors this in lang.go).
339
424
  const dropUnfilled = (terms) => terms.filter((t) => null != t);
340
425
  const incompleteNil = (r, ctx) => addsite(new NilVal_1.NilVal({ why: 'incomplete_expression' }), r, ctx);
426
+ // Build a call from a NAME and the argument terms as the author
427
+ // wrote them. Shared by the `func(...)` handler and by the pipe,
428
+ // which is the same call with one more argument on the front — so
429
+ // the arity check, the comma-group rule and the raw-value conversion
430
+ // are stated once and both spellings get all three.
431
+ const buildCall = (r, ctx, fname, argterms) => {
432
+ const funcval = funcMap[fname];
433
+ // Arity is known for every built-in, so a surplus or missing
434
+ // argument is a mistake in the SOURCE, refused here where the
435
+ // author can see it (issue #51). It was previously left to each
436
+ // function to notice or not: the two ports disagreed on `upper()`
437
+ // and on `close()`, and `min(1,2)` noticed nothing at all -- it
438
+ // built a constraint that merely refused to generate later, with a
439
+ // message about the map rather than about the call.
440
+ //
441
+ // Counted BEFORE the rawToVal pass below, which is what makes the
442
+ // count possible: a comma group arrives as a RAW array and a
443
+ // written list literal as a ListVal, and rawToVal turns the first
444
+ // into the second.
445
+ const arity = funcArity[fname];
446
+ if (null != arity) {
447
+ const got = writtenArgCount(argterms);
448
+ if (got < arity[0] || (-1 !== arity[1] && got > arity[1])) {
449
+ // details is assigned AFTER construction: the NilVal
450
+ // constructor does not read it from its spec (only NilVal.make
451
+ // does), so passing it in the spec left the hint's
452
+ // {func}/{want}/{got} placeholders un-injected and printed
453
+ // literally.
454
+ const nil = new NilVal_1.NilVal({ why: 'func_arity' });
455
+ nil.details = {
456
+ func: fname,
457
+ want: arityText(arity[0], arity[1]),
458
+ got: '' + got,
459
+ };
460
+ // The CALL AS WRITTEN rides the refusal (G8 phase 4): a pipe
461
+ // rebuilds `x |> upper()` as `upper(x)`, and the arity it fails
462
+ // on here is the arity of a call one argument short of the one
463
+ // the author actually wrote.
464
+ nil._callname = fname;
465
+ nil._callterms = argterms;
466
+ return addsite(nil, r, ctx);
467
+ }
468
+ }
469
+ // rawToVal EVERY argument. A degenerate expression can hand this
470
+ // handler raw parse values rather than Vals -- `pref(1-3)` arrives
471
+ // as the plain numbers 1 and -3 -- and a func's peg is unified
472
+ // element by element, so a raw one reached `arg.unify(...)` and
473
+ // threw. The unifier's catch-all turned that into an `internal`
474
+ // verdict: a crash reported as a unification result (issue #49).
475
+ // The Go port has always converted here (asVal in evaluate).
476
+ // A comma group is ONE raw-array term (see writtenArgCount).
477
+ // For a function whose arguments are distinct POSITIONS —
478
+ // deprecate's value and record, pack's and each's data and template
479
+ // — the group is expanded back into them here, while a written list
480
+ // literal, already a ListVal, stays one argument. The constraint
481
+ // atoms make the same move in their own constructor (atomArgs,
482
+ // ConstraintVal.ts), which is why they are not in this set:
483
+ // `neq(1,2)` is one argument LIST, not two positions, and expanding
484
+ // it here would take the list away from the code that reads it.
485
+ let terms = argterms;
486
+ if (true === POSITIONAL_ARG_FUNCS[fname] && 1 === terms.length &&
487
+ Array.isArray(terms[0])) {
488
+ terms = terms[0];
489
+ }
490
+ const args = terms.map(rawToVal);
491
+ const val = null == funcval ?
492
+ new NilVal_1.NilVal({ why: 'unknown_function' }) :
493
+ new funcval({ peg: args });
494
+ // The call as written, for the pipe to rebuild from. Parse-time
495
+ // only: nothing downstream reads it, and a clone does not carry it.
496
+ //
497
+ // NOT on a constraint atom that BUILT: an atom with its argument
498
+ // list complete is a residual, not a call waiting for a subject,
499
+ // and `1 |> neq(2,3)` is asking for `1 & neq(2,3)` -- which is
500
+ // what `&` is for. (An atom the arity check REFUSED still carries
501
+ // it, on the nil above: `1 |> min()` is `min(1)`, and that is a
502
+ // call waiting for a subject.) The Go port cannot rebuild a built
503
+ // atom at all -- its residual keeps no atom name -- so this is
504
+ // also what keeps the two ports answering the same thing.
505
+ if (true !== val.isConstraint) {
506
+ val._callname = fname;
507
+ val._callterms = argterms;
508
+ }
509
+ return val;
510
+ };
511
+ // The argument terms `f(...)` would have been written with, had the
512
+ // piped value been written into it. A comma group is one raw-array
513
+ // term: for a POSITIONAL function the group is separate arguments,
514
+ // so the piped value joins them; for a constraint atom the group IS
515
+ // the argument list, so the piped value joins the list instead.
516
+ const pipeTerms = (call, val) => {
517
+ const written = call._callterms;
518
+ const group = 1 === written.length && Array.isArray(written[0]) ?
519
+ written[0] : written;
520
+ if (0 === group.length) {
521
+ return [val];
522
+ }
523
+ return true === POSITIONAL_ARG_FUNCS[call._callname] ?
524
+ [val, ...group] : [[val, ...group]];
525
+ };
341
526
  let opmap = {
342
527
  'conjunct-infix': (r, ctx, _op, terms) => addsite(new ConjunctVal_1.ConjunctVal({ peg: dropUnfilled(terms) }), r, ctx),
343
528
  'disjunct-infix': (r, ctx, _op, terms) => addsite(new DisjunctVal_1.DisjunctVal({ peg: dropUnfilled(terms) }), r, ctx),
@@ -408,54 +593,42 @@ help isolate the syntax error.`,
408
593
  return incompleteNil(r, ctx);
409
594
  return addsite(val, r, ctx);
410
595
  },
596
+ // THE PIPE `|>` (G8 phase 4): parse-time sugar and nothing else.
597
+ // `x |> f(a)` IS `f(x, a)` -- the piped value goes in as the FIRST
598
+ // argument, Elixir-style, because every Aontu call is data-first
599
+ // already (`close(x)`, `pack(data, tmpl)`) and a pipe must read the
600
+ // way the calls it replaces read. It never reaches a Val: by the
601
+ // time the tree exists the call is an ordinary call, which is why
602
+ // canon can never emit the token and the two ports' canon stay
603
+ // byte-identical without either knowing about it.
604
+ 'pipe-infix': (r, ctx, _op, terms) => {
605
+ const val = terms[0];
606
+ const call = terms[1];
607
+ if (null == val || null == call)
608
+ return incompleteNil(r, ctx);
609
+ // The right-hand side is a CALL: either one the func handler
610
+ // already built, or one it refused for an arity the pipe is about
611
+ // to satisfy. Both carry what they were written as.
612
+ if (null != call._callname) {
613
+ return buildCall(r, ctx, call._callname, pipeTerms(call, val));
614
+ }
615
+ // ... or a bare NAME, which is the whole point of the short
616
+ // spelling: `x |> upper` is `upper(x)`. A bare word has already
617
+ // become a string VALUE by the time an infix operator sees it, so
618
+ // this is where a string becomes a call.
619
+ if (true === call?.isScalar && 'string' === typeof call.peg &&
620
+ null != funcMap[call.peg]) {
621
+ return buildCall(r, ctx, call.peg, [val]);
622
+ }
623
+ // Anything else is not a call, and a pipe into a non-call is a
624
+ // mistake in the source rather than a value.
625
+ return addsite(new NilVal_1.NilVal({ why: 'pipe_target' }), r, ctx);
626
+ },
411
627
  'func-paren': (r, ctx, _op, terms) => {
412
628
  let val = terms[1];
413
629
  const fname = terms[0];
414
630
  if ('' !== fname) {
415
- const funcval = funcMap[fname];
416
- // Arity is known for every built-in, so a surplus or missing
417
- // argument is a mistake in the SOURCE, refused here where the
418
- // author can see it (issue #51). It was previously left to each
419
- // function to notice or not: the two ports disagreed on `upper()`
420
- // and on `close()`, and `min(1,2)` noticed nothing at all -- it
421
- // built a constraint that merely refused to generate later, with
422
- // a message about the map rather than about the call.
423
- //
424
- // Counted BEFORE the rawToVal pass below, which is what makes the
425
- // count possible: a comma group arrives as a RAW array and a
426
- // written list literal as a ListVal, and rawToVal turns the first
427
- // into the second.
428
- const arity = funcArity[fname];
429
- if (null != arity) {
430
- const got = writtenArgCount(terms.slice(1));
431
- if (got < arity[0] || (-1 !== arity[1] && got > arity[1])) {
432
- // details is assigned AFTER construction: the NilVal
433
- // constructor does not read it from its spec (only
434
- // NilVal.make does), so passing it in the spec left the
435
- // hint's {func}/{want}/{got} placeholders un-injected and
436
- // printed literally.
437
- const nil = new NilVal_1.NilVal({ why: 'func_arity' });
438
- nil.details = {
439
- func: fname,
440
- want: arityText(arity[0], arity[1]),
441
- got: '' + got,
442
- };
443
- return addsite(nil, r, ctx);
444
- }
445
- }
446
- // rawToVal EVERY argument. A degenerate expression can hand this
447
- // handler raw parse values rather than Vals -- `pref(1-3)` arrives
448
- // as the plain numbers 1 and -3 -- and a func's peg is unified
449
- // element by element, so a raw one reached `arg.unify(...)` and
450
- // threw. The unifier's catch-all turned that into an `internal`
451
- // verdict: a crash reported as a unification result (issue #49).
452
- // The Go port has always converted here (asVal in evaluate).
453
- const args = terms.slice(1).map(rawToVal);
454
- val = null == funcval ?
455
- new NilVal_1.NilVal({ why: 'unknown_function' }) :
456
- new funcval({
457
- peg: args
458
- });
631
+ val = buildCall(r, ctx, fname, terms.slice(1));
459
632
  }
460
633
  // `a:()` — grouping parens with nothing inside.
461
634
  if (null == val)
@@ -478,6 +651,13 @@ help isolate the syntax error.`,
478
651
  'disjunct': {
479
652
  infix: true, src: '|', left: 14_000_000, right: 15_000_000
480
653
  },
654
+ // G8 phase 4: the pipe. LOOSEST of all the infix operators, so
655
+ // `a & b |> f` pipes the whole meet and not just `b` -- a pipe
656
+ // reads as "and then", which is a statement about everything to
657
+ // its left. Kept in lock-step with the op table in go/lang.go.
658
+ 'pipe-infix': {
659
+ infix: true, src: '|>', left: 12_000_000, right: 13_000_000
660
+ },
481
661
  'plus-infix': {
482
662
  src: '+',
483
663
  infix: true,
@@ -658,6 +838,13 @@ help isolate the syntax error.`,
658
838
  valnode.site.row = st.rI;
659
839
  valnode.site.col = st.cI;
660
840
  valnode.site.url = ctx.meta.multisource && ctx.meta.multisource.path;
841
+ // No `?? ''` and no empty-text arm here: this branch runs only
842
+ // for a rule that HAS an open token, and a token that opens a
843
+ // value always carries text — the coverage gate refuses both
844
+ // guards as dead. The unset case is the one above, where r.o0
845
+ // itself can be absent.
846
+ valnode.site.src = st.src;
847
+ valnode.site.len = st.src.length;
661
848
  }
662
849
  // else { ERROR? }
663
850
  r.node = valnode;
@@ -940,18 +1127,37 @@ help isolate the syntax error.`,
940
1127
  return rs;
941
1128
  });
942
1129
  };
943
- // SECURITY: the default resolver reads any file/package the process can
944
- // reach — @"path" follows relative paths (`@"../../etc/passwd"`) and
945
- // symlinks with no containment check, and @"pkg" can require() arbitrary
946
- // installed modules. This is intentional for the CLI, but it means a
947
- // `.aon` source can read referenced files; the LSP uses this same
948
- // resolver, so treat opening an untrusted source as running it. Pass a
949
- // confined `options.resolver` to restrict reads in less-trusted contexts.
1130
+ // SECURITY: under the DEFAULT ('system') include capability this
1131
+ // resolver reads any file/package the process can reach — @"path"
1132
+ // follows relative paths (`@"../../etc/passwd"`) and symlinks, and
1133
+ // @"pkg" can require() arbitrary installed modules — so treat opening
1134
+ // an untrusted source as running it. The trust profile (G5,
1135
+ // docs/trust.md) is the confinement surface: `trust.include` of
1136
+ // 'none', `{ mem }` or `{ root }` restricts what `@"..."` may resolve,
1137
+ // and a denied resolution is a deterministic parse-stage
1138
+ // `include_denied` error.
950
1139
  function makeModelResolver(options) {
951
1140
  const useRequire = options.require || require;
952
- let memResolver = (0, mem_1.makeMemResolver)({
953
- ...(options.resolver?.mem || {})
954
- });
1141
+ const capability = options.trust?.include ?? 'system';
1142
+ const memCapability = 'object' === typeof capability && null != capability.mem;
1143
+ const rootDir = 'object' === typeof capability &&
1144
+ 'string' === typeof capability.root
1145
+ ? (0, node_path_1.resolve)(capability.root) : undefined;
1146
+ // Under the mem capability the CAPABILITY's file set is the whole
1147
+ // world; otherwise the host-injected `options.resolver.mem` entries
1148
+ // remain available under every capability but 'none' — they are
1149
+ // host-provided, not document-requested, so confining them would
1150
+ // confine the host against itself.
1151
+ // THE BUNDLED VOCABULARY (G4 phase 4, ts/src/std.ts) rides the
1152
+ // memory leg: served from the engine itself, so it needs neither the
1153
+ // filesystem nor package resolution and is available under every
1154
+ // capability but `none` — which denies every include outright, that
1155
+ // being what `none` means. Host entries and the capability's own set
1156
+ // WIN over it: a caller that supplies its own `std/system` gets the
1157
+ // one it supplied.
1158
+ let memResolver = (0, mem_1.makeMemResolver)(memCapability
1159
+ ? { ...capability.mem }
1160
+ : { ...(options.resolver?.mem || {}) });
955
1161
  // TODO: make this consistent with other resolvers
956
1162
  let fileResolver = (0, file_1.makeFileResolver)((spec) => {
957
1163
  return 'string' === typeof spec ? spec : spec?.peg;
@@ -960,6 +1166,91 @@ function makeModelResolver(options) {
960
1166
  require: useRequire,
961
1167
  ...(options.resolver?.pkg || {})
962
1168
  });
1169
+ // Confinement is realpath-then-prefix-check (docs/trust.md): the
1170
+ // RESOLVED file's real path must sit below the root's real path, so a
1171
+ // symlink inside the root pointing outside it is an escape, not a
1172
+ // loophole. A path realpath cannot resolve falls back to the lexical
1173
+ // form — the comparison is then against what the resolver actually
1174
+ // read.
1175
+ // Real fs, deliberately: `options.fs` is not a sandbox (it feeds
1176
+ // parse text; the file leg reads through its own channel), so the
1177
+ // containment check must see the same filesystem that leg read from.
1178
+ // A path that does not (fully) exist cannot be realpath'd whole, and
1179
+ // falling back to the LEXICAL form compares apples to oranges when
1180
+ // the root itself sits behind a symlink -- on macOS a root under
1181
+ // /var realpaths to /private/var, so a merely-missing file inside it
1182
+ // reads as an escape. Realpath the deepest EXISTING ancestor and
1183
+ // re-attach the rest, so both sides of the check are in real
1184
+ // coordinates. (The MCP server's own confinement carries the twin of
1185
+ // this rule; its CI failure is what found the shape.)
1186
+ const realpath = (p) => {
1187
+ try {
1188
+ return (0, node_fs_1.realpathSync)(p);
1189
+ }
1190
+ catch {
1191
+ const parent = (0, node_path_1.dirname)(p);
1192
+ if (parent === p) {
1193
+ return p;
1194
+ }
1195
+ return (0, node_path_1.join)(realpath(parent), (0, node_path_1.basename)(p));
1196
+ }
1197
+ };
1198
+ const outsideRoot = (root, full) => {
1199
+ const rootReal = realpath(root);
1200
+ const fullReal = realpath(full);
1201
+ return fullReal !== rootReal && !fullReal.startsWith(rootReal + node_path_1.sep);
1202
+ };
1203
+ // A denial THROWS with the code; Lang.parse converts it to the
1204
+ // parse-stage `include_denied` nil (the same shape a syntax failure
1205
+ // takes). Raising beats injecting a nil value: a bare-member include
1206
+ // (`@"denied.aon"` at the top of a file) MERGES into the enclosing
1207
+ // map, and a nil contributes no keys, so an injected denial would
1208
+ // vanish and leave a plausible, silently-partial document.
1209
+ const deny = (path) => {
1210
+ // Only 'none' and 'root' can deny: the mem capability's misses are
1211
+ // not-found (its set is the whole world), so there is no third arm.
1212
+ const capname = 'none' === capability ? 'none' : 'root:' + rootDir;
1213
+ const err = new Error('include denied: ' + path + ' (capability: ' + capname + ')');
1214
+ err.code = 'include_denied';
1215
+ throw err;
1216
+ };
1217
+ // The user cache: whatever the host named, else the platform rule
1218
+ // (`modCacheDir`, ts/src/mod.ts) the tooling writes by.
1219
+ const modCache = (opts) => {
1220
+ const named = opts.mod?.cache;
1221
+ return 'string' === typeof named ? named : (0, mod_1.modCacheDir)();
1222
+ };
1223
+ // The directory an include is being resolved FROM: the source that
1224
+ // holds it, or the entry path when the source is a string. Same base
1225
+ // the file leg computes (resolvePathSpec in @tabnas/multisource).
1226
+ const dirOf = (p) => null == p || '' === p ? (0, node_path_1.resolve)('.') : (0, node_path_1.dirname)((0, node_path_1.resolve)(p));
1227
+ // The module store reader: the host's filesystem when one was
1228
+ // injected, so a sandboxed evaluation stays in the filesystem the
1229
+ // host gave it.
1230
+ const modFs = (ctx) => {
1231
+ const hostfs = ctx?.meta?.fs;
1232
+ return null == hostfs ? { existsSync: node_fs_1.existsSync, readFileSync: node_fs_1.readFileSync } : {
1233
+ existsSync: (p) => {
1234
+ try {
1235
+ hostfs.statSync(p);
1236
+ return true;
1237
+ }
1238
+ catch {
1239
+ return false;
1240
+ }
1241
+ },
1242
+ readFileSync: (p, enc) => hostfs.readFileSync(p, enc),
1243
+ };
1244
+ };
1245
+ // The manifest sink rides the parse meta (Lang.parse seeds it, the
1246
+ // multisource plugin's child-meta spread carries it to every nested
1247
+ // include), so the recorded closure covers the whole include tree.
1248
+ const record = (ctx, path, cap) => {
1249
+ const manifest = ctx?.meta?.aontu?.manifest;
1250
+ if (Array.isArray(manifest)) {
1251
+ manifest.push({ path, capability: cap });
1252
+ }
1253
+ };
963
1254
  return function ModelResolver(spec, popts, rule, ctx, jsonic) {
964
1255
  // The aontu val rule's ac has already wrapped every raw string node
965
1256
  // as a StringVal, so spec is a Val here (or a raw object from a
@@ -970,22 +1261,99 @@ function makeModelResolver(options) {
970
1261
  if (null == path || '' === path) {
971
1262
  return { found: false, path: '' + (path ?? ''), search: [] };
972
1263
  }
1264
+ if ('none' === capability) {
1265
+ deny(path);
1266
+ }
1267
+ // THE BUNDLED VOCABULARY (G4 phase 4, ts/src/std.ts): served from
1268
+ // the engine itself, so it needs neither the filesystem nor package
1269
+ // resolution and is available under every capability but `none` —
1270
+ // checked just above, that being what `none` means. Matched against
1271
+ // the name the author WROTE, before the memory leg, so the kind is
1272
+ // stated rather than guessed from an extension the bare name does
1273
+ // not have.
1274
+ const std = std_1.STD_SOURCES[path];
1275
+ if (null != std) {
1276
+ record(ctx, path, 'std');
1277
+ return { found: true, path, full: path, kind: 'aon', src: std, search: [] };
1278
+ }
973
1279
  let search = [];
974
1280
  let res = memResolver(path, popts, rule, ctx, jsonic);
975
1281
  res.path = path;
976
1282
  if (res.found) {
1283
+ record(ctx, res.full ?? path, 'mem');
1284
+ return res;
1285
+ }
1286
+ // THE MODULE LEG (G6 phase 2, ts/src/mod.ts): memory -> MODULE ->
1287
+ // filesystem -> package. Memory stays FIRST so a sandbox and the
1288
+ // spec suite can stub a module path without touching disk; a path
1289
+ // that is not module-shaped falls straight through, so no existing
1290
+ // include can be routed somewhere new by this.
1291
+ const modref = memCapability ? undefined : (0, mod_1.parseModuleRef)(path);
1292
+ if (null != modref) {
1293
+ const msmeta = ctx?.meta?.multisource;
1294
+ const from = dirOf(null != msmeta?.path ? msmeta.path : popts?.path);
1295
+ const found = (0, mod_1.resolveModule)(modref, from, modFs(ctx), {
1296
+ // The user cache lives outside any confinement root, so it is
1297
+ // consulted only when nothing confines this evaluation. A
1298
+ // rooted profile sees the project's own `aon_vendor/` and
1299
+ // nothing else, which is what `root` means.
1300
+ ...(null == rootDir ? { cache: modCache(options) } : {}),
1301
+ eval: options.mod?.eval,
1302
+ depth: options.mod?.depth,
1303
+ });
1304
+ if (null != rootDir && outsideRoot(rootDir, found.full)) {
1305
+ deny(path);
1306
+ }
1307
+ record(ctx, found.full, 'mod');
1308
+ return {
1309
+ found: true, path, full: found.full,
1310
+ kind: 'aon', src: found.src, search: [],
1311
+ };
1312
+ }
1313
+ if (memCapability) {
1314
+ // A miss in the declared virtual set is NOT-FOUND, not denial:
1315
+ // the allowed mechanism ran and missed. Denial is reserved for a
1316
+ // capability refusing a mechanism outright.
1317
+ res.search = search.concat(res.search);
977
1318
  return res;
978
1319
  }
979
1320
  search = search.concat(res.search);
980
1321
  res = fileResolver(path, popts, rule, ctx, jsonic);
981
1322
  res.path = path;
982
1323
  if (res.found) {
1324
+ // `res.full` asserted non-null: a FOUND file resolution always
1325
+ // carries the absolute path it read (and the pkg leg below is the
1326
+ // same), so a runtime fallback arm would be dead code.
1327
+ const full = res.full;
1328
+ if (null != rootDir && outsideRoot(rootDir, full)) {
1329
+ deny(path);
1330
+ }
1331
+ // The warning window for the staged default flip (G5 phase 6):
1332
+ // under 'system', the CLI supplies trustWarn and the entry root,
1333
+ // and every resolution escaping that root names the flag a future
1334
+ // default will require.
1335
+ if (null == rootDir && null != options.trustWarn &&
1336
+ null != options.trustWarnRoot &&
1337
+ outsideRoot(options.trustWarnRoot, full)) {
1338
+ options.trustWarn('escape', full);
1339
+ }
1340
+ record(ctx, full, 'file');
983
1341
  return res;
984
1342
  }
985
1343
  search = search.concat(res.search);
1344
+ if (null != rootDir) {
1345
+ // Package resolution is not part of the root capability; the
1346
+ // miss stands as not-found with the searched paths listed.
1347
+ res.search = search;
1348
+ return res;
1349
+ }
986
1350
  res = pkgResolver(path, popts, rule, ctx, jsonic);
987
1351
  res.path = path;
988
1352
  if (res.found) {
1353
+ if (null != options.trustWarn) {
1354
+ options.trustWarn('pkg', res.full);
1355
+ }
1356
+ record(ctx, res.full, 'pkg');
989
1357
  return res;
990
1358
  }
991
1359
  res.search = search.concat(res.search);
@@ -993,16 +1361,29 @@ function makeModelResolver(options) {
993
1361
  };
994
1362
  }
995
1363
  // funcArity is the permitted WRITTEN argument count of each built-in, as
1364
+ // The functions whose comma-separated arguments are distinct POSITIONS
1365
+ // rather than one argument list. See the func-paren handler above: this
1366
+ // is the set whose comma group is expanded back into separate `peg`
1367
+ // entries.
1368
+ const POSITIONAL_ARG_FUNCS = {
1369
+ deprecate: true, pack: true, each: true, filter: true, match: true,
1370
+ // Arithmetic takes two OPERANDS, and an operand is a position: `sub`
1371
+ // is not commutative, so `sub(a, b)` reaching the engine as one
1372
+ // two-element list would lose which is which.
1373
+ add: true, sub: true, mul: true, div: true, mod: true, rem: true,
1374
+ // The bag and the key are distinct positions.
1375
+ pick: true,
1376
+ };
996
1377
  // [min, max]; a max of -1 is unbounded. Every name in funcMap has an
997
1378
  // entry, and the arity is a property of the language rather than of
998
1379
  // either port -- go/func.go carries the same table.
999
1380
  //
1000
- // Nearly everything takes exactly one. The four exceptions earn their
1001
- // place: key() names how many levels UP the path to read, defaulting to
1002
- // the parent when omitted, neq takes a whole set of exclusions,
1003
- // unique() is a property of the container rather than a comparison
1004
- // against anything, so there is nothing for it to take, and must()
1005
- // takes a check AND the author's message for when it fails.
1381
+ // Nearly everything takes exactly one. The exceptions earn their place:
1382
+ // key() names how many levels UP the path to read, defaulting to the
1383
+ // parent when omitted, neq takes a whole set of exclusions, unique()
1384
+ // takes none (a property of the container) or a PROJECTOR key, must()
1385
+ // takes a check AND the author's message for when it fails, and the
1386
+ // arithmetic family takes two operands.
1006
1387
  const funcArity = {
1007
1388
  upper: [1, 1], lower: [1, 1], copy: [1, 1], pref: [1, 1],
1008
1389
  super: [1, 1], type: [1, 1], hide: [1, 1], close: [1, 1],
@@ -1010,9 +1391,30 @@ const funcArity = {
1010
1391
  min: [1, 1], max: [1, 1], above: [1, 1], below: [1, 1], re: [1, 1],
1011
1392
  length: [1, 1],
1012
1393
  key: [0, 1],
1013
- unique: [0, 0],
1394
+ // THE ONE ARGUMENT IS A PROJECTOR: `unique(port)` says no two
1395
+ // members share a `port`. The arity was reserved for it (finding I).
1396
+ unique: [0, 1],
1014
1397
  neq: [1, -1],
1015
1398
  must: [2, 2],
1399
+ deprecate: [1, 2],
1400
+ id: [1, 1],
1401
+ refer: [0, 1],
1402
+ pack: [2, 2],
1403
+ each: [1, 2],
1404
+ filter: [2, 2],
1405
+ // The scrutinee, then pattern/result pairs, then an optional
1406
+ // default: three arguments at least, and any number above that.
1407
+ match: [3, -1],
1408
+ // Two operands, always. Arithmetic has no variadic reading that is
1409
+ // not a fold, and a fold is the recursion this language refuses.
1410
+ add: [2, 2], sub: [2, 2], mul: [2, 2],
1411
+ div: [2, 2], mod: [2, 2], rem: [2, 2],
1412
+ // One bag. The operation is fixed, so there is nothing else to pass:
1413
+ // a fold's second argument is a FUNCTION, and this language has none
1414
+ // to give it.
1415
+ sum: [1, 1], least: [1, 1], greatest: [1, 1],
1416
+ // The bag, and the key to take from each of its children.
1417
+ pick: [2, 2],
1016
1418
  };
1017
1419
  // writtenArgCount counts the arguments as the AUTHOR wrote them.
1018
1420
  //
@@ -1043,11 +1445,13 @@ function arityText(lo, hi) {
1043
1445
  return 'one or more arguments';
1044
1446
  }
1045
1447
  if (lo !== hi) {
1046
- return 'no arguments or one';
1047
- }
1048
- if (0 === hi) {
1049
- return 'no arguments';
1448
+ return 0 === lo ? 'no arguments or one' : 'one argument or two';
1050
1449
  }
1450
+ // NO {0,0} ARM. `unique` was the only built-in taking none, and its
1451
+ // one argument is now the projector the arity was reserved for
1452
+ // (finding I), so a phrasing for a count no entry carries would be
1453
+ // untested prose pretending to be tested -- the rule this function's
1454
+ // header states. The arm returns with the table, if one ever does.
1051
1455
  if (2 === hi) {
1052
1456
  return 'exactly two arguments';
1053
1457
  }
@@ -1152,7 +1556,13 @@ class Lang {
1152
1556
  multisource: {
1153
1557
  path: opts?.path ?? this.opts.path,
1154
1558
  deps: (opts && opts.deps) || undefined
1155
- }
1559
+ },
1560
+ // The include-manifest sink (G5, docs/trust.md): the resolver
1561
+ // records every resolved include here, and the plugin's
1562
+ // child-meta spread carries the same array to nested includes.
1563
+ aontu: {
1564
+ manifest: opts?.manifest,
1565
+ },
1156
1566
  };
1157
1567
  if (null != opts?.idcount) {
1158
1568
  this.idcount = opts.idcount;
@@ -1174,16 +1584,49 @@ class Lang {
1174
1584
  }
1175
1585
  }
1176
1586
  catch (e) {
1177
- if (e instanceof jsonic_1.JsonicError || 'JsonicError' === e.constructor.name) {
1587
+ if ('include_denied' === e?.code ||
1588
+ 'module_missing' === e?.code || 'module_integrity' === e?.code ||
1589
+ 'module_depth' === e?.code) {
1590
+ // A denied include (trust profile, G5): the resolver throws so
1591
+ // a bare-member include cannot vanish in the merge, and the
1592
+ // code survives here as the parse-stage nil the registry
1593
+ // pins (errcodes.tsv: include_denied, class parse).
1594
+ // A denied include (G5) and a module that is missing or fails
1595
+ // its pin (G6 phase 2) are refused the same way, for the same
1596
+ // reason: the resolver THROWS so a bare-member include cannot
1597
+ // vanish in the merge, and the code survives here as the
1598
+ // parse-stage nil the registry pins (errcodes.tsv).
1178
1599
  val = new NilVal_1.NilVal({
1179
1600
  why: 'parse',
1180
1601
  err: new NilVal_1.NilVal({
1181
- why: 'syntax',
1182
- msg: e.message + opCharHint(src),
1602
+ why: e.code,
1603
+ msg: e.message,
1183
1604
  err: e,
1184
1605
  })
1185
1606
  });
1186
1607
  }
1608
+ else if (e instanceof jsonic_1.JsonicError || 'JsonicError' === e.constructor.name) {
1609
+ const syntax = new NilVal_1.NilVal({
1610
+ why: 'syntax',
1611
+ msg: e.message + opCharHint(src),
1612
+ err: e,
1613
+ });
1614
+ // THE POSITION TRAVELS WITH IT. The parser knows exactly where
1615
+ // it stopped -- it draws a caret there -- and the rendered
1616
+ // message carried the only copy, so `vet --format json`
1617
+ // reported row -1, col -1 for a document whose fault the human
1618
+ // renderer located to the character. A machine-readable report
1619
+ // that says "somewhere in this file" is the one a repair loop
1620
+ // can do nothing with. Both numbers are already 1-based here,
1621
+ // which is the base a site uses (go/lang.go does the same).
1622
+ if ('number' === typeof e.lineNumber) {
1623
+ syntax.site.row = e.lineNumber;
1624
+ }
1625
+ if ('number' === typeof e.columnNumber) {
1626
+ syntax.site.col = e.columnNumber;
1627
+ }
1628
+ val = new NilVal_1.NilVal({ why: 'parse', err: syntax });
1629
+ }
1187
1630
  else {
1188
1631
  throw e;
1189
1632
  }