aontu 0.62.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 (356) hide show
  1. package/README.md +1 -1
  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 +1 -1
  8. package/dist/aontu.js +1 -79
  9. package/dist/aontu.js.map +1 -1
  10. package/dist/aontumodel.d.ts +4 -0
  11. package/dist/aontumodel.js +33 -0
  12. package/dist/aontumodel.js.map +1 -0
  13. package/dist/cli.js +101 -620
  14. package/dist/cli.js.map +1 -1
  15. package/dist/ctx.js +0 -48
  16. package/dist/ctx.js.map +1 -1
  17. package/dist/diff.js +0 -32
  18. package/dist/diff.js.map +1 -1
  19. package/dist/err.js +0 -40
  20. package/dist/err.js.map +1 -1
  21. package/dist/escape.js +0 -45
  22. package/dist/escape.js.map +1 -1
  23. package/dist/exactjson.d.ts +0 -35
  24. package/dist/exactjson.js +0 -131
  25. package/dist/exactjson.js.map +1 -1
  26. package/dist/format.js +13 -203
  27. package/dist/format.js.map +1 -1
  28. package/dist/grammar.d.ts +9 -0
  29. package/dist/grammar.js +54 -0
  30. package/dist/grammar.js.map +1 -0
  31. package/dist/graph.js +0 -26
  32. package/dist/graph.js.map +1 -1
  33. package/dist/hcanon.js +0 -82
  34. package/dist/hcanon.js.map +1 -1
  35. package/dist/helpdoc.js +1 -1
  36. package/dist/helpdoc.js.map +1 -1
  37. package/dist/hints.d.ts +0 -6
  38. package/dist/hints.js +54 -55
  39. package/dist/hints.js.map +1 -1
  40. package/dist/jsonschema.js +0 -114
  41. package/dist/jsonschema.js.map +1 -1
  42. package/dist/keyorder.d.ts +0 -7
  43. package/dist/keyorder.js +0 -41
  44. package/dist/keyorder.js.map +1 -1
  45. package/dist/lang.js +17 -915
  46. package/dist/lang.js.map +1 -1
  47. package/dist/lower.js +11 -61
  48. package/dist/lower.js.map +1 -1
  49. package/dist/lsp-server.js +0 -16
  50. package/dist/lsp-server.js.map +1 -1
  51. package/dist/lsp.d.ts +1 -1
  52. package/dist/lsp.js +12 -159
  53. package/dist/lsp.js.map +1 -1
  54. package/dist/mcp-server.js +0 -26
  55. package/dist/mcp-server.js.map +1 -1
  56. package/dist/mcp.js +0 -113
  57. package/dist/mcp.js.map +1 -1
  58. package/dist/mod-tool.js +0 -130
  59. package/dist/mod-tool.js.map +1 -1
  60. package/dist/mod.js +0 -162
  61. package/dist/mod.js.map +1 -1
  62. package/dist/patch.js +0 -217
  63. package/dist/patch.js.map +1 -1
  64. package/dist/provenance.js +0 -140
  65. package/dist/provenance.js.map +1 -1
  66. package/dist/query.js +0 -75
  67. package/dist/query.js.map +1 -1
  68. package/dist/reach.js +0 -43
  69. package/dist/reach.js.map +1 -1
  70. package/dist/relation.js +0 -61
  71. package/dist/relation.js.map +1 -1
  72. package/dist/render.js +20 -135
  73. package/dist/render.js.map +1 -1
  74. package/dist/report-sarif.d.ts +0 -11
  75. package/dist/report-sarif.js +0 -28
  76. package/dist/report-sarif.js.map +1 -1
  77. package/dist/sig.js +0 -35
  78. package/dist/sig.js.map +1 -1
  79. package/dist/sigdecl.js +1 -1
  80. package/dist/sigdecl.js.map +1 -1
  81. package/dist/siggate.js +0 -4
  82. package/dist/siggate.js.map +1 -1
  83. package/dist/site.js +3 -29
  84. package/dist/site.js.map +1 -1
  85. package/dist/subsume.d.ts +0 -10
  86. package/dist/subsume.js +0 -137
  87. package/dist/subsume.js.map +1 -1
  88. package/dist/template.d.ts +2 -1
  89. package/dist/template.js +58 -138
  90. package/dist/template.js.map +1 -1
  91. package/dist/trim.js +0 -41
  92. package/dist/trim.js.map +1 -1
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/dist/type.js.map +1 -1
  95. package/dist/unify.js +12 -242
  96. package/dist/unify.js.map +1 -1
  97. package/dist/utility.js +0 -22
  98. package/dist/utility.js.map +1 -1
  99. package/dist/val/AbnfFuncVal.d.ts +18 -0
  100. package/dist/val/AbnfFuncVal.js +132 -0
  101. package/dist/val/AbnfFuncVal.js.map +1 -0
  102. package/dist/val/AbsentVal.d.ts +11 -0
  103. package/dist/val/AbsentVal.js +30 -0
  104. package/dist/val/AbsentVal.js.map +1 -0
  105. package/dist/val/AggFuncVal.d.ts +10 -1
  106. package/dist/val/AggFuncVal.js +104 -116
  107. package/dist/val/AggFuncVal.js.map +1 -1
  108. package/dist/val/ArithFuncVal.js +0 -12
  109. package/dist/val/ArithFuncVal.js.map +1 -1
  110. package/dist/val/BagVal.js +1 -78
  111. package/dist/val/BagVal.js.map +1 -1
  112. package/dist/val/BigDecimalVal.js +0 -16
  113. package/dist/val/BigDecimalVal.js.map +1 -1
  114. package/dist/val/BigIntegerVal.js +0 -16
  115. package/dist/val/BigIntegerVal.js.map +1 -1
  116. package/dist/val/CloseFuncVal.js +0 -9
  117. package/dist/val/CloseFuncVal.js.map +1 -1
  118. package/dist/val/CmpFuncVal.js +2 -59
  119. package/dist/val/CmpFuncVal.js.map +1 -1
  120. package/dist/val/ConjunctVal.js +0 -29
  121. package/dist/val/ConjunctVal.js.map +1 -1
  122. package/dist/val/ConstraintVal.js +0 -500
  123. package/dist/val/ConstraintVal.js.map +1 -1
  124. package/dist/val/ContainerKindVal.js +0 -2
  125. package/dist/val/ContainerKindVal.js.map +1 -1
  126. package/dist/val/CopyFuncVal.js +0 -3
  127. package/dist/val/CopyFuncVal.js.map +1 -1
  128. package/dist/val/Decimal.js +0 -179
  129. package/dist/val/Decimal.js.map +1 -1
  130. package/dist/val/DeprecateFuncVal.js.map +1 -1
  131. package/dist/val/DisjunctVal.js +0 -152
  132. package/dist/val/DisjunctVal.js.map +1 -1
  133. package/dist/val/EachFuncVal.js +0 -3
  134. package/dist/val/EachFuncVal.js.map +1 -1
  135. package/dist/val/EmitFuncVal.d.ts +1 -1
  136. package/dist/val/EmitFuncVal.js +6 -119
  137. package/dist/val/EmitFuncVal.js.map +1 -1
  138. package/dist/val/ExpectVal.js +0 -62
  139. package/dist/val/ExpectVal.js.map +1 -1
  140. package/dist/val/FilterFuncVal.js +0 -25
  141. package/dist/val/FilterFuncVal.js.map +1 -1
  142. package/dist/val/FuncBaseVal.d.ts +1 -0
  143. package/dist/val/FuncBaseVal.js +7 -127
  144. package/dist/val/FuncBaseVal.js.map +1 -1
  145. package/dist/val/GraphAtomVal.js +0 -15
  146. package/dist/val/GraphAtomVal.js.map +1 -1
  147. package/dist/val/HideFuncVal.js +0 -13
  148. package/dist/val/HideFuncVal.js.map +1 -1
  149. package/dist/val/IntegerVal.js +0 -61
  150. package/dist/val/IntegerVal.js.map +1 -1
  151. package/dist/val/JunctionVal.js +0 -20
  152. package/dist/val/JunctionVal.js.map +1 -1
  153. package/dist/val/KeyFuncVal.js +0 -46
  154. package/dist/val/KeyFuncVal.js.map +1 -1
  155. package/dist/val/ListVal.js +0 -57
  156. package/dist/val/ListVal.js.map +1 -1
  157. package/dist/val/LowerFuncVal.js +0 -11
  158. package/dist/val/LowerFuncVal.js.map +1 -1
  159. package/dist/val/MapVal.js +0 -151
  160. package/dist/val/MapVal.js.map +1 -1
  161. package/dist/val/MatchFuncVal.js +0 -27
  162. package/dist/val/MatchFuncVal.js.map +1 -1
  163. package/dist/val/{FormFuncVal.d.ts → MaybeFuncVal.d.ts} +5 -5
  164. package/dist/val/MaybeFuncVal.js +50 -0
  165. package/dist/val/MaybeFuncVal.js.map +1 -0
  166. package/dist/val/MoveFuncVal.js +0 -18
  167. package/dist/val/MoveFuncVal.js.map +1 -1
  168. package/dist/val/NilVal.js +0 -60
  169. package/dist/val/NilVal.js.map +1 -1
  170. package/dist/val/NomFuncVal.js +8 -42
  171. package/dist/val/NomFuncVal.js.map +1 -1
  172. package/dist/val/NumberVal.js +0 -15
  173. package/dist/val/NumberVal.js.map +1 -1
  174. package/dist/val/OpBaseVal.d.ts +1 -0
  175. package/dist/val/OpBaseVal.js +3 -15
  176. package/dist/val/OpBaseVal.js.map +1 -1
  177. package/dist/val/PackFuncVal.js +0 -34
  178. package/dist/val/PackFuncVal.js.map +1 -1
  179. package/dist/val/PathFuncVal.js +0 -6
  180. package/dist/val/PathFuncVal.js.map +1 -1
  181. package/dist/val/PathVal.js +0 -41
  182. package/dist/val/PathVal.js.map +1 -1
  183. package/dist/val/PlaceVal.js +0 -25
  184. package/dist/val/PlaceVal.js.map +1 -1
  185. package/dist/val/PlusOpVal.d.ts +1 -7
  186. package/dist/val/PlusOpVal.js +13 -74
  187. package/dist/val/PlusOpVal.js.map +1 -1
  188. package/dist/val/PrefFuncVal.js +0 -1
  189. package/dist/val/PrefFuncVal.js.map +1 -1
  190. package/dist/val/PrefVal.js +0 -167
  191. package/dist/val/PrefVal.js.map +1 -1
  192. package/dist/val/RecurseVal.js +0 -55
  193. package/dist/val/RecurseVal.js.map +1 -1
  194. package/dist/val/RefVal.js +0 -282
  195. package/dist/val/RefVal.js.map +1 -1
  196. package/dist/val/ReferFuncVal.js +0 -232
  197. package/dist/val/ReferFuncVal.js.map +1 -1
  198. package/dist/val/ScalarKindVal.js +0 -49
  199. package/dist/val/ScalarKindVal.js.map +1 -1
  200. package/dist/val/ScalarVal.js +0 -11
  201. package/dist/val/ScalarVal.js.map +1 -1
  202. package/dist/val/StrFuncVal.js +0 -18
  203. package/dist/val/StrFuncVal.js.map +1 -1
  204. package/dist/val/SuperFuncVal.js +0 -32
  205. package/dist/val/SuperFuncVal.js.map +1 -1
  206. package/dist/val/TopVal.js +0 -1
  207. package/dist/val/TopVal.js.map +1 -1
  208. package/dist/val/TranslateFuncVal.js +1 -3
  209. package/dist/val/TranslateFuncVal.js.map +1 -1
  210. package/dist/val/UpperFuncVal.js +0 -11
  211. package/dist/val/UpperFuncVal.js.map +1 -1
  212. package/dist/val/Val.d.ts +1 -0
  213. package/dist/val/Val.js +2 -133
  214. package/dist/val/Val.js.map +1 -1
  215. package/dist/val/VarVal.js +0 -12
  216. package/dist/val/VarVal.js.map +1 -1
  217. package/dist/val/arith.js +0 -37
  218. package/dist/val/arith.js.map +1 -1
  219. package/dist/val/caserange.js +0 -61
  220. package/dist/val/caserange.js.map +1 -1
  221. package/dist/val/members.js +0 -6
  222. package/dist/val/members.js.map +1 -1
  223. package/dist/val/numcmp.js +0 -11
  224. package/dist/val/numcmp.js.map +1 -1
  225. package/dist/val/numkind.js +0 -145
  226. package/dist/val/numkind.js.map +1 -1
  227. package/dist/val/valutil.js +0 -16
  228. package/dist/val/valutil.js.map +1 -1
  229. package/dist/vet.js +0 -461
  230. package/dist/vet.js.map +1 -1
  231. package/dist/view.js +0 -414
  232. package/dist/view.js.map +1 -1
  233. package/dist/walk.js +0 -41
  234. package/dist/walk.js.map +1 -1
  235. package/grammar/aontu.abnf +8 -6
  236. package/grammar/aontu.gbnf +4 -4
  237. package/grammar/aontu.lark +4 -4
  238. package/grammar/aontu.tmLanguage.json +1 -1
  239. package/package.json +4 -2
  240. package/src/agentsmd.ts +0 -35
  241. package/src/alias.ts +0 -39
  242. package/src/allow.ts +1 -96
  243. package/src/aontu.ts +3 -110
  244. package/src/aontumodel.ts +32 -0
  245. package/src/cli.ts +113 -682
  246. package/src/ctx.ts +0 -103
  247. package/src/diff.ts +0 -40
  248. package/src/err.ts +0 -40
  249. package/src/escape.ts +0 -46
  250. package/src/exactjson.ts +0 -131
  251. package/src/format.ts +14 -257
  252. package/src/grammar.ts +72 -0
  253. package/src/graph.ts +0 -61
  254. package/src/hcanon.ts +0 -82
  255. package/src/helpdoc.ts +1 -1
  256. package/src/hints.ts +66 -57
  257. package/src/jsonschema.ts +0 -123
  258. package/src/keyorder.ts +0 -42
  259. package/src/lang.ts +19 -931
  260. package/src/lower.ts +12 -62
  261. package/src/lsp-server.ts +0 -16
  262. package/src/lsp.ts +12 -180
  263. package/src/mcp-server.ts +0 -31
  264. package/src/mcp.ts +0 -130
  265. package/src/mod-tool.ts +0 -158
  266. package/src/mod.ts +0 -178
  267. package/src/patch.ts +0 -232
  268. package/src/provenance.ts +0 -183
  269. package/src/query.ts +0 -84
  270. package/src/reach.ts +0 -53
  271. package/src/relation.ts +0 -84
  272. package/src/render.ts +20 -172
  273. package/src/report-sarif.ts +0 -48
  274. package/src/sig.ts +0 -35
  275. package/src/sigdecl.ts +1 -1
  276. package/src/siggate.ts +0 -30
  277. package/src/site.ts +3 -29
  278. package/src/subsume.ts +1 -161
  279. package/src/template.ts +69 -140
  280. package/src/trim.ts +0 -53
  281. package/src/type.ts +2 -45
  282. package/src/unify.ts +13 -251
  283. package/src/utility.ts +0 -31
  284. package/src/val/AbnfFuncVal.ts +181 -0
  285. package/src/val/AbsentVal.ts +54 -0
  286. package/src/val/AggFuncVal.ts +152 -188
  287. package/src/val/ArithFuncVal.ts +0 -20
  288. package/src/val/BagVal.ts +1 -78
  289. package/src/val/BigDecimalVal.ts +0 -16
  290. package/src/val/BigIntegerVal.ts +0 -16
  291. package/src/val/CloseFuncVal.ts +0 -9
  292. package/src/val/CmpFuncVal.ts +4 -166
  293. package/src/val/ConjunctVal.ts +0 -33
  294. package/src/val/ConstraintVal.ts +2 -537
  295. package/src/val/ContainerKindVal.ts +0 -18
  296. package/src/val/CopyFuncVal.ts +0 -5
  297. package/src/val/Decimal.ts +1 -185
  298. package/src/val/DeprecateFuncVal.ts +0 -10
  299. package/src/val/DisjunctVal.ts +0 -157
  300. package/src/val/EachFuncVal.ts +0 -40
  301. package/src/val/EmitFuncVal.ts +8 -208
  302. package/src/val/ExpectVal.ts +0 -62
  303. package/src/val/FilterFuncVal.ts +0 -55
  304. package/src/val/FuncBaseVal.ts +9 -130
  305. package/src/val/GraphAtomVal.ts +0 -42
  306. package/src/val/HideFuncVal.ts +0 -15
  307. package/src/val/IntegerVal.ts +0 -61
  308. package/src/val/JunctionVal.ts +0 -20
  309. package/src/val/KeyFuncVal.ts +0 -48
  310. package/src/val/ListVal.ts +0 -59
  311. package/src/val/LowerFuncVal.ts +0 -12
  312. package/src/val/MapVal.ts +0 -151
  313. package/src/val/MatchFuncVal.ts +0 -59
  314. package/src/val/MaybeFuncVal.ts +86 -0
  315. package/src/val/MoveFuncVal.ts +0 -20
  316. package/src/val/NilVal.ts +0 -60
  317. package/src/val/NomFuncVal.ts +8 -95
  318. package/src/val/NumberVal.ts +0 -16
  319. package/src/val/OpBaseVal.ts +4 -17
  320. package/src/val/PackFuncVal.ts +0 -63
  321. package/src/val/PathFuncVal.ts +0 -32
  322. package/src/val/PathVal.ts +0 -66
  323. package/src/val/PlaceVal.ts +0 -45
  324. package/src/val/PlusOpVal.ts +18 -75
  325. package/src/val/PrefFuncVal.ts +0 -1
  326. package/src/val/PrefVal.ts +0 -179
  327. package/src/val/RecurseVal.ts +0 -81
  328. package/src/val/RefVal.ts +1 -285
  329. package/src/val/ReferFuncVal.ts +0 -255
  330. package/src/val/ScalarKindVal.ts +0 -50
  331. package/src/val/ScalarVal.ts +0 -12
  332. package/src/val/StrFuncVal.ts +0 -44
  333. package/src/val/SuperFuncVal.ts +0 -42
  334. package/src/val/TopVal.ts +0 -1
  335. package/src/val/TranslateFuncVal.ts +1 -51
  336. package/src/val/UpperFuncVal.ts +0 -12
  337. package/src/val/Val.ts +3 -192
  338. package/src/val/VarVal.ts +0 -15
  339. package/src/val/arith.ts +0 -92
  340. package/src/val/caserange.ts +0 -62
  341. package/src/val/members.ts +0 -23
  342. package/src/val/numcmp.ts +1 -27
  343. package/src/val/numkind.ts +0 -149
  344. package/src/val/valutil.ts +0 -16
  345. package/src/vet.ts +1 -582
  346. package/src/view.ts +0 -507
  347. package/src/walk.ts +0 -41
  348. package/dist/std.d.ts +0 -3
  349. package/dist/std.js +0 -672
  350. package/dist/std.js.map +0 -1
  351. package/dist/val/FormFuncVal.js +0 -55
  352. package/dist/val/FormFuncVal.js.map +0 -1
  353. package/dist/val/NamerFuncVal.d.ts +0 -12
  354. package/dist/val/NamerFuncVal.js +0 -176
  355. package/dist/val/NamerFuncVal.js.map +0 -1
  356. package/src/std.ts +0 -683
package/src/mod.ts CHANGED
@@ -1,61 +1,24 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
 
3
- // MODULE IDENTITY AND LOCAL RESOLUTION (G6 phase 2,
4
- // docs/capability-review/g6-distribution.md).
5
- //
6
- // An import is still just `@"…"`; the string's SHAPE routes it, so the
7
- // grammar is untouched and every existing include keeps its exact
8
- // behaviour:
9
- //
10
- // service: @"corp.example/schemas/service@1"
11
- // frozen: @"corp.example/schemas/service@1#aon1-4vJemVYtWFR2mQeN…"
12
- // local: @"./fragment.aon" <- unchanged, not a module
13
- //
14
- // EVALUATION NEVER TOUCHES THE NETWORK. Resolution reads local stores
15
- // only: `aontu_meta/vendor/` beside the project's `mod.aon`, then a
16
- // content-addressed user cache keyed by canon-hash. Fetching is a
17
- // separate, explicit tool step, and a module that is in neither store
18
- // is an evaluation error that says so.
19
- //
20
- // TWO PINS, TWO ROLES. The lockfile's `oci` digest certifies that these
21
- // are the bytes the registry served; the `canon` hash certifies that
22
- // this is the MEANING that was reviewed. Only the second can be checked
23
- // locally without the registry, and it is the one this file checks: the
24
- // module is unified standalone and its canon-hash compared with the
25
- // pin. An inline `#aon1-…` fragment is the same check without a
26
- // lockfile — the degenerate mode for single-file and agent-sandbox use.
27
3
 
28
4
  import { join as pathJoin, dirname as pathDirname } from 'node:path'
29
5
 
30
6
 
31
- // A module import, as the string spells it.
32
7
  export type ModuleRef = {
33
8
  // The module path WITHOUT the major: `corp.example/schemas/service`.
34
9
  path: string
35
- // The major version, from the `@N` suffix.
36
10
  major: number
37
11
  // The inline canon-hash pin, if the import froze one.
38
12
  hash?: string
39
13
  }
40
14
 
41
15
 
42
- // A file store the resolver can read. The engine passes its own `fs`
43
- // when the host injected one, so a sandboxed evaluation stays in the
44
- // filesystem the host gave it.
45
16
  export type ModuleFs = {
46
17
  existsSync: (p: string) => boolean
47
18
  readFileSync: (p: string, enc: string) => string
48
19
  }
49
20
 
50
21
 
51
- // A module path is DOMAIN-SHAPED — the first segment carries a dot,
52
- // which is what tells it apart from `./local.aon`, `pkg-name` and every
53
- // other spelling already in use — and carries the major version in the
54
- // path, CUE/Go-style, so two majors are two modules.
55
- //
56
- // The pattern is deliberately narrow: anything it does not match falls
57
- // through to the existing resolver chain unchanged, so no document that
58
- // worked before this phase can be routed somewhere new by it.
59
22
  const MODULE_RE =
60
23
  /^([a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)+(?:\/[A-Za-z0-9._-]+)*)@(\d+)(?:#(aon1-[A-Za-z0-9_-]+))?$/
61
24
 
@@ -73,33 +36,10 @@ export function parseModuleRef(spec: string): ModuleRef | undefined {
73
36
  }
74
37
 
75
38
 
76
- // SHAPE IS NOT VALIDITY, and the gap between them was a hole. MODULE_RE
77
- // answers "does this string route to the module resolver" -- a
78
- // ROUTING predicate, and it must stay one, because anything it rejects
79
- // falls through to the file leg and a stricter pattern would silently
80
- // re-route documents that work today. But its element class
81
- // `[A-Za-z0-9._-]` admits `..`, and `moduleDir` joins elements with
82
- // pathJoin, which CLEANS `..` rather than refusing it:
83
- //
84
- // moduleDir('/store/aontu_meta/vendor', 'corp.example/../../etc/passwd@1')
85
- // -> /store/etc/passwd@1
86
- //
87
- // `mod vendor` then copied a tree THERE, outside the project entirely,
88
- // and reported `verdict: ok`. So validity is a separate question asked
89
- // separately, after the shape matched, and asked at every site that
90
- // turns a module path into a directory.
91
- //
92
- // The rules are Go's (golang.org/x/mod/module.CheckPath), for the
93
- // reason Go has them: a module path becomes a real directory on every
94
- // platform the toolchain runs on, so it must be a legal one everywhere.
95
39
  export const MODULE_MAX_PATH = 512
96
40
  export const MODULE_MAX_ELEMS = 32
97
41
 
98
42
 
99
- // Windows refuses these as file names whatever the extension, so a
100
- // module path containing one cannot be materialised there at all. The
101
- // check is on the element up to its first dot, which is where Windows
102
- // stops looking too.
103
43
  const RESERVED_ELEMS = new Set([
104
44
  'con', 'prn', 'aux', 'nul',
105
45
  'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9',
@@ -107,9 +47,6 @@ const RESERVED_ELEMS = new Set([
107
47
  ])
108
48
 
109
49
 
110
- // Why a module path may not be used as a directory, or undefined when
111
- // it may. The reason is user-facing: it goes in the refusal, because a
112
- // path refused without saying which rule it broke is a puzzle.
113
50
  export function validateModulePath(path: string): string | undefined {
114
51
  if (MODULE_MAX_PATH < path.length) {
115
52
  return 'longer than ' + MODULE_MAX_PATH + ' characters'
@@ -124,10 +61,6 @@ export function validateModulePath(path: string): string | undefined {
124
61
  if ('' === elem) {
125
62
  return 'an element is empty'
126
63
  }
127
- // This one rule kills `.` and `..` -- the traversal -- along with
128
- // `.hidden` and `trailing.`, exactly as Go's does. Stating it as
129
- // the rule rather than as "no `..`" is deliberate: a check that
130
- // named the two dangerous spellings would miss the next one.
131
64
  if (elem.startsWith('.') || elem.endsWith('.')) {
132
65
  return 'an element begins or ends with "."'
133
66
  }
@@ -140,46 +73,16 @@ export function validateModulePath(path: string): string | undefined {
140
73
  }
141
74
 
142
75
 
143
- // An element as it is spelled ON DISK. Uppercase is escaped to
144
- // `!`+lowercase, Go's rule (go.dev/ref/mod, module proxy protocol) and
145
- // for Go's reason: `github.com/Alice/Widgets` and
146
- // `github.com/alice/widgets` are two module identities and, on macOS
147
- // and Windows, ONE directory -- so without this the second module
148
- // fetched silently clobbers the first, and an unpinned import resolves
149
- // to whichever won.
150
- //
151
- // The WRITTEN path stays the identity; only the directory is escaped.
152
76
  function escapeElem(elem: string): string {
153
77
  return elem.replace(/[A-Z]/g, (c) => '!' + c.toLowerCase())
154
78
  }
155
79
 
156
80
 
157
- // The directory a module's files live in, under a store root.
158
- //
159
- // Callers must have validated the path (validateModulePath); this
160
- // function cannot refuse, because it answers a location rather than a
161
- // question, and every caller has a refusal shape of its own.
162
81
  export function moduleDir(store: string, ref: ModuleRef): string {
163
82
  return pathJoin(store, ...ref.path.split('/').map(escapeElem)) + '@' + ref.major
164
83
  }
165
84
 
166
85
 
167
- // EVERY project root at or above `from`, innermost first — a project
168
- // root being a directory holding a `mod.aon`. This used to answer with
169
- // the NEAREST one alone, and the plural is the fix, because a
170
- // VENDORED MODULE IS A PROJECT INSIDE A PROJECT. A module in
171
- // `aontu_meta/vendor/` carries its own `mod.aon`, which stopped the upward
172
- // walk there, so a nested import resolved against the vendored
173
- // module's own directory: a tree with no `aontu_meta/vendor/` of its own, and
174
- // therefore a `module not fetched` for a dependency sitting flat
175
- // beside it in the CONSUMER's vendor tree — the only layout `mod
176
- // vendor` produces (use-cases/BUGS.md §31).
177
- //
178
- // The consumer's stores are searched after the module's own, so a
179
- // module that vendors its dependencies nested still wins for its own
180
- // tree, and one that does not falls through to the consumer that
181
- // vendored it. The last element is `from` itself when nothing above it
182
- // declares a module, which is the single-file inline-pin mode.
183
86
  export function projectRoots(from: string, fs: ModuleFs): string[] {
184
87
  const roots: string[] = []
185
88
  let dir = from
@@ -196,18 +99,6 @@ export function projectRoots(from: string, fs: ModuleFs): string[] {
196
99
  }
197
100
 
198
101
 
199
- // The lockfile's pin for one import, or undefined.
200
- //
201
- // `mod-lock.aon` is machine-written CANONICAL Aontu, and canonical
202
- // Aontu whose leaves are scalars IS JSON — which is why reading it here
203
- // needs no evaluator, and why a hand-edited lockfile that is no longer
204
- // canonical simply does not parse. It is generated; the file says so.
205
- // The lockfile's JSON: its canonical line, with the generated-file
206
- // header stripped. The file is AONTU, so it may carry `#` comments —
207
- // and the header `aontu mod tidy` writes says not to edit it, which is
208
- // worth more than the two lines it costs to skip. Everything below the
209
- // comments is the canonical map, and canonical Aontu whose leaves are
210
- // scalars is JSON.
211
102
  export function lockJson(text: string): string {
212
103
  return text
213
104
  .split('\n')
@@ -216,38 +107,11 @@ export function lockJson(text: string): string {
216
107
  }
217
108
 
218
109
 
219
- // The user cache: `$XDG_CACHE_HOME/aontu/mod` unless the host names
220
- // another, else the platform's own cache location. A host with nowhere
221
- // to put one has no cache, which is a miss rather than a failure. One
222
- // rule, in one place: the resolver reads this cache during evaluation
223
- // and `aontu mod` writes into it, and two spellings of "where the cache
224
- // is" is one bug.
225
110
  export function modCacheDir(): string | undefined {
226
111
  return modCacheDirFor(process.platform, process.env)
227
112
  }
228
113
 
229
114
 
230
- // That rule with the platform and the environment PASSED IN, so the
231
- // Windows arm can be exercised off Windows — the only way a rule about
232
- // a platform nobody here runs gets tested at all. The Go port splits
233
- // the same way (modCacheDirFor, go/aontu.go).
234
- //
235
- // THE ORDER IS EXPLICIT BEFORE IMPLICIT, and LOCALAPPDATA is LAST.
236
- // XDG_CACHE_HOME is the override and wins everywhere, Windows included:
237
- // a caller who names a cache directory means it. HOME comes next and is
238
- // also honoured on Windows, where it is not standard but IS set by Git
239
- // Bash and by most development shells — a user who has one expects
240
- // their tools to agree about where home is.
241
- //
242
- // LOCALAPPDATA is the PLATFORM DEFAULT beneath both, which is the whole
243
- // addition: Windows sets neither XDG_CACHE_HOME nor HOME by default —
244
- // it supplies USERPROFILE and LOCALAPPDATA, and LOCALAPPDATA is what a
245
- // cache directory means there — so a rule that knew only the first two
246
- // left every Windows user with NO cache. Putting it ABOVE HOME was the
247
- // first attempt and was wrong: it made an explicitly set HOME
248
- // unreachable on Windows, which broke the existing fallback test the
249
- // moment CI ran it. A platform default that overrides what the
250
- // environment was told is not a default.
251
115
  export function modCacheDirFor(
252
116
  platform: string,
253
117
  env: Record<string, string | undefined>,
@@ -290,24 +154,10 @@ export function lockHash(root: string, ref: ModuleRef, fs: ModuleFs):
290
154
  }
291
155
 
292
156
 
293
- // What a module resolution needs from the engine: evaluate a source
294
- // standalone and answer both what it MEANS (the generated value, for
295
- // reading a module file's own metadata) and what its meaning HASHES to
296
- // (for the integrity check). Injected rather than imported, because
297
- // this is EVALUATION — the very thing this file is called from the
298
- // middle of — and a module resolver that imported the evaluator would
299
- // close a cycle around the whole language.
300
157
  export type ModuleEval =
301
158
  (src: string, path: string) => { gen: any, hash: string }
302
159
 
303
160
 
304
- // How deep module verification may nest before it is refused. A module
305
- // is verified by EVALUATING it, and that evaluation resolves the
306
- // module's own imports -- so a vendor tree that leads back to itself
307
- // (a symlink is enough) would recurse until the host's stack gave out,
308
- // and a verdict that depends on the host's stack size is exactly what
309
- // the determinism clause forbids (docs/trust.md, and the same argument
310
- // unify_cycle rests on). Sixteen is far above any real vendor nesting.
311
161
  export const MODULE_MAX_DEPTH = 16
312
162
 
313
163
 
@@ -316,10 +166,6 @@ export type ModuleOptions = {
316
166
  // only when the expected hash is known, which is what "content
317
167
  // addressed" means: without a pin there is no address.
318
168
  cache?: string
319
- // The standalone evaluator, for reading module files and for the
320
- // integrity check. Always present: Aontu injects it (ts/src/aontu.ts)
321
- // because only the class that evaluates can answer what a module
322
- // MEANS, and the resolver runs inside a parse that class started.
323
169
  eval: ModuleEval
324
170
  // How many module verifications deep this evaluation already is.
325
171
  depth?: number
@@ -333,23 +179,11 @@ export type ModuleFound = {
333
179
  }
334
180
 
335
181
 
336
- // EVERY code `resolveModule` can refuse with. The list lives HERE,
337
- // beside the refusals themselves, because the parse layer has to
338
- // recognise them to turn the throw into a parse-stage nil
339
- // (ts/src/lang.ts) -- and when that list was written out longhand
340
- // there, adding a fourth code left it unhandled and the refusal
341
- // surfaced as `unexpected error` instead of the message it carries.
342
- // The Go port has no such list (recordModErr takes any code), which is
343
- // why only this side could drift.
344
182
  export const MODULE_REFUSAL_CODES: ReadonlySet<string> = new Set([
345
183
  'module_path', 'module_missing', 'module_integrity', 'module_depth',
346
184
  ])
347
185
 
348
186
 
349
- // A refusal that carries its code to the parse layer, exactly as a
350
- // denied include does (makeModelResolver's `deny`): the resolver
351
- // THROWS, so a bare-member module import cannot vanish in the merge and
352
- // leave a plausible, silently-partial document.
353
187
  function refuse(code: string, message: string): never {
354
188
  const err: any = new Error(message)
355
189
  err.code = code
@@ -364,11 +198,6 @@ export function resolveModule(
364
198
  fs: ModuleFs,
365
199
  options: ModuleOptions,
366
200
  ): ModuleFound {
367
- // THE PATH IS CHECKED BEFORE ANYTHING IS BUILT FROM IT. This is
368
- // first because it is a question about the REQUEST, not about the
369
- // state of the machine: a path that cannot legally be a directory is
370
- // refused identically whether or not the module is present, and
371
- // whether or not the depth bound is near.
372
201
  const badpath = validateModulePath(ref.path)
373
202
  if (undefined !== badpath) {
374
203
  refuse('module_path',
@@ -401,9 +230,6 @@ export function resolveModule(
401
230
 
402
231
  const dir = stores.find((d) => fs.existsSync(pathJoin(d, 'mod.aon')))
403
232
  if (undefined === dir) {
404
- // The wording is the contract (docs/capability-review/
405
- // g6-distribution.md): it names the module AND the step that fixes
406
- // it, because an agent reading this error is the audience.
407
233
  refuse('module_missing',
408
234
  'module not fetched: ' + ref.path + '@' + ref.major +
409
235
  ' (run: aontu mod get)')
@@ -439,10 +265,6 @@ export function resolveModule(
439
265
  }
440
266
 
441
267
 
442
- // The `mod.main` a module file declares, or the default entry name.
443
- // The module file is ORDINARY AONTU, read by the language itself — the
444
- // toolchain dogfooding its own evaluator rather than pattern-matching
445
- // its own syntax with a regexp.
446
268
  function moduleMain(file: string, fs: ModuleFs, options: ModuleOptions): string {
447
269
  const gen: any = options.eval(fs.readFileSync(file, 'utf8'), file).gen
448
270
  const main = gen?.mod?.main