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/jsonschema.ts CHANGED
@@ -1,34 +1,6 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
  import { includeOpts } from './utility'
3
3
 
4
- // JSON SCHEMA EXPORT (the review's finding I / SUPPORT.md act 2).
5
- //
6
- // "JSON Schema's decisive 2026 advantage is not its validator ecosystem
7
- // -- it is that every major LLM provider's structured-output API
8
- // natively constrains generation to JSON Schema." Without an export,
9
- // Aontu cannot ride that path and then apply `vet` as the semantic gate
10
- // -- the hybrid an enterprise would actually deploy -- and an MCP tool's
11
- // `inputSchema`, which the protocol REQUIRES to be JSON Schema, cannot
12
- // be derived from an Aontu tool model at all (use case 09's interop
13
- // wall).
14
- //
15
- // THE MAPPING IS LOSSY, AND SAYS SO PER CONSTRUCT. That is the whole
16
- // design. Aontu's constraint algebra maps cleanly onto JSON Schema's
17
- // core -- bounds, patterns, lengths, enums, required and closed -- and
18
- // then stops: an evaluate-only `must()` is opaque by construction, an
19
- // exact `0d` leaf has no JSON type that preserves it, a cross-field
20
- // reference is not a property constraint at all, and `unique(k)` has no
21
- // JSON Schema spelling. A converter that dropped those silently would
22
- // hand its caller a schema that ADMITS MORE than the model does, which
23
- // is the failure mode this whole language exists to refuse. So every
24
- // loss is reported with its path, its construct and its reason, and
25
- // `--strict` turns the report into a refusal.
26
- //
27
- // It exports the UNIFIED value, not the parse: what a document MEANS is
28
- // what a consumer should be constrained to, and the meaning is what the
29
- // fixpoint produced.
30
- //
31
- // Draft 2020-12, because that is what the structured-output APIs read.
32
4
 
33
5
  import { Aontu } from './aontu'
34
6
  import { makeNilErr } from './err'
@@ -54,9 +26,6 @@ export type SchemaLoss = {
54
26
  export type SchemaVerdict = 'ok' | 'lossy' | 'error'
55
27
 
56
28
  export type SchemaReport = {
57
- // `ok` everything carried; `lossy` the schema is a WEAKER statement
58
- // than the model; `error` the document does not stand up and there is
59
- // nothing to export.
60
29
  verdict: SchemaVerdict
61
30
  // The JSON Schema document. Empty object on `error`.
62
31
  schema: any
@@ -68,18 +37,12 @@ export type SchemaReport = {
68
37
  }
69
38
 
70
39
  export type SchemaOptions = {
71
- // The subtree to export, as a path -- the same anchor `vet --at`
72
- // takes, and parsed by the same walk, so `--at spec` means what it
73
- // means everywhere else.
74
40
  at?: string
75
41
  // Where the document came from, so a relative `@"file"` resolves from
76
42
  // its own directory.
77
43
  path?: string
78
44
  trust?: TrustOptions
79
45
 
80
- // Extensions additionally read as text (the CLI's `--text-ext`).
81
- // Rides beside `trust` because it is the other half of what an
82
- // include may read.
83
46
  textExt?: string[]
84
47
  }
85
48
 
@@ -102,11 +65,6 @@ function lose(ctx: Ctx, path: string[], construct: string, reason: string) {
102
65
  }
103
66
 
104
67
 
105
- // The JSON type for a kind marker, by the marker CLASS's name -- the
106
- // same load-bearing name canon renders (ScalarKindVal). `number` and
107
- // its four leaves all become JSON's two numeric types; the exactness of
108
- // `biginteger`/`bigdecimal` has no JSON type at all, which is a loss the
109
- // caller is told about rather than a silent widening.
110
68
  const KIND_TYPE: Record<string, string> = {
111
69
  String: 'string',
112
70
  Boolean: 'boolean',
@@ -115,17 +73,10 @@ const KIND_TYPE: Record<string, string> = {
115
73
  Float: 'number',
116
74
  BigDecimal: 'number',
117
75
  Number: 'number',
118
- // A path value is its address string at the JSON boundary
119
- // (docs/design/PATHS.0.md), so the projection says `string` -- the
120
- // same lossy-projection rule the exact numeric leaves follow.
121
76
  Path: 'string',
122
77
  }
123
78
 
124
79
 
125
- // The JSON value of a concrete scalar, for `const`, `enum` and
126
- // `default`. An exact leaf renders through its own digits rather than
127
- // through binary64 -- and is reported as a loss where it is emitted,
128
- // because JSON's number has no exactness to receive it.
129
80
  function scalarJson(v: any): any {
130
81
  if (v.isBigInteger) {
131
82
  return Number(v.peg)
@@ -149,9 +100,6 @@ function scalarType(v: any): string {
149
100
  }
150
101
 
151
102
 
152
- // The constraint residual's atoms, onto JSON Schema's keywords. The
153
- // three that map exactly (bounds, pattern, count) go across; the two
154
- // that cannot (`must`, `unique(k)`) are reported.
155
103
  function fromConstraint(ctx: Ctx, path: string[], c: any): any {
156
104
  const out: any = {}
157
105
 
@@ -165,9 +113,6 @@ function fromConstraint(ctx: Ctx, path: string[], c: any): any {
165
113
  out.type = 'number'
166
114
  }
167
115
 
168
- // Bounds. An OPEN endpoint is JSON Schema's exclusive form, which is
169
- // a keyword of its own in 2020-12 rather than the boolean flag draft-4
170
- // used.
171
116
  if (null != c.lo) {
172
117
  out[c.lo.open ? 'exclusiveMinimum' : 'minimum'] = scalarJson(c.lo.v)
173
118
  }
@@ -181,11 +126,6 @@ function fromConstraint(ctx: Ctx, path: string[], c: any): any {
181
126
  out.not = { enum: c.neqs.map(scalarJson) }
182
127
  }
183
128
 
184
- // Patterns. Aontu DEFINES its portable subset (`re`'s abbreviations
185
- // mean the same in both ports); every member of that subset is also
186
- // an ECMA-262 regular expression, which is what JSON Schema's
187
- // `pattern` is read as, so this crosses without translation. More
188
- // than one pattern needs `allOf`: `pattern` is a single keyword.
189
129
  if (1 === c.res.length) {
190
130
  out.pattern = c.res[0].src
191
131
  }
@@ -193,10 +133,6 @@ function fromConstraint(ctx: Ctx, path: string[], c: any): any {
193
133
  out.allOf = c.res.map((r: any) => ({ pattern: r.src }))
194
134
  }
195
135
 
196
- // A COUNT is a length or a size depending on what is counted, and the
197
- // residual does not always know which. Where the domain says string,
198
- // it is minLength/maxLength; otherwise the container keywords, since
199
- // a count atom on a container is what `length` overwhelmingly means.
200
136
  if (null != c.count) {
201
137
  const lo = null == c.count.lo ? undefined : scalarJson(c.count.lo.v)
202
138
  const hi = null == c.count.hi ? undefined : scalarJson(c.count.hi.v)
@@ -236,28 +172,6 @@ function fromConstraint(ctx: Ctx, path: string[], c: any): any {
236
172
  }
237
173
 
238
174
 
239
- // The exporter proper. Every arm answers a schema; the ones that cannot
240
- // answer honestly report a loss and fall back to `{}`, which admits
241
- // anything -- the safe direction for a document that will be checked
242
- // again by `vet`, and the direction the loss report exists to make
243
- // visible.
244
- // NO DEFENSIVE GUARD ON `v`. Every caller walks a bag's own children
245
- // and a bag holds Vals, so a non-Val here is not a degenerate input,
246
- // it is a bug in this file -- and an unreachable `if` is a branch arm
247
- // the ADR-002 gate counts and no `node:coverage ignore` suppresses
248
- // (the marker drops LINES, not branches). Go's twin keeps its `nil ==
249
- // v` arm because a missing map key there yields a typed nil rather
250
- // than an absent property.
251
- // DEPRECATION IS AN ANNOTATION, and 2020-12 has one: `deprecated`.
252
- // The export used to drop the whole record in SILENCE -- no keyword,
253
- // and no loss line even under --strict -- which is the one thing the
254
- // verb's own contract says it never does (use-cases/BUGS.md §56).
255
- //
256
- // The boolean crosses faithfully. The record's STRINGS (msg, use,
257
- // since) have no home in 2020-12, so they are reported as a loss
258
- // rather than invented into `description`: this exporter emits no
259
- // `description` anywhere, and quietly making it mean "deprecation
260
- // note" would be a mapping a consumer cannot undo.
261
175
  function fromVal(ctx: Ctx, path: string[], v: any): any {
262
176
  const out = fromValInner(ctx, path, v)
263
177
 
@@ -278,18 +192,10 @@ function fromVal(ctx: Ctx, path: string[], v: any): any {
278
192
  }
279
193
 
280
194
 
281
- // The record's text keys -- the ones with nothing to carry them.
282
- // `DEPRECATION_KEYS` in DeprecateFuncVal.ts is the authority on what a
283
- // record may hold; this is that list, and a key added there without a
284
- // JSON Schema home belongs here too.
285
195
  const DEPRECATION_TEXT = ['msg', 'use', 'since']
286
196
 
287
197
 
288
198
  function fromValInner(ctx: Ctx, path: string[], v: any): any {
289
- // A preference is its inner value plus a DEFAULT. JSON Schema's
290
- // `default` is annotation rather than constraint -- it does not
291
- // validate -- which is exactly what a preference is when something
292
- // else supplies the value.
293
199
  if (true === v.isPref) {
294
200
  const inner = fromVal(ctx, path, v.peg)
295
201
  const gen = generated(v.peg)
@@ -304,12 +210,6 @@ function fromValInner(ctx: Ctx, path: string[], v: any): any {
304
210
  return fromConstraint(ctx, path, v)
305
211
  }
306
212
 
307
- // A SIZING RESIDUE is a container and its own sizing atom, kept
308
- // together because more members could still change the atom's reading
309
- // (use-cases/BUGS.md §16). Both halves are exportable and both must
310
- // be: the container gives the shape, the atom gives `uniqueItems` and
311
- // the length keywords, and a walk that saw only "a conjunct" would
312
- // report the whole field as unresolved and admit anything.
313
213
  const residue = sizingResidue(v)
314
214
  if (undefined !== residue) {
315
215
  return {
@@ -334,10 +234,6 @@ function fromValInner(ctx: Ctx, path: string[], v: any): any {
334
234
  'this leaf exists for cannot be carried; the schema says ' +
335
235
  '"' + t + '" and a consumer may round')
336
236
  }
337
- // KIND_TYPE is TOTAL over the kinds a marker can carry, so there is
338
- // no miss to fall back from -- and a fallback that cannot be taken
339
- // is a branch arm the coverage gate counts. Go's twin keeps its
340
- // empty-map arm, which its own ignore mechanism can carry.
341
237
  return { type: t }
342
238
  }
343
239
 
@@ -358,9 +254,6 @@ function fromValInner(ctx: Ctx, path: string[], v: any): any {
358
254
  return { const: scalarJson(v), type: scalarType(v) }
359
255
  }
360
256
 
361
- // Everything else is residue: a reference that did not resolve, a
362
- // function or operator still waiting, a nil. None of them is a
363
- // property constraint, and guessing one would be inventing a promise.
364
257
  lose(ctx, path, residueName(v),
365
258
  'this is not a value yet, so there is nothing to constrain a ' +
366
259
  'consumer to; the schema admits anything here')
@@ -380,10 +273,6 @@ function residueName(v: any): string {
380
273
  // generate. Used for `default` and for `enum` members: both are VALUES
381
274
  // in the schema, so a member that is itself a shape has none to give.
382
275
  function generated(v: any): any {
383
- // No try/catch: a collecting context RECORDS a failed generation on
384
- // itself instead of throwing, which is the whole point of the mode.
385
- // Neither `vet` nor the Go twin (`schemaGenerated`) wraps this
386
- // either, and an untakeable catch is a branch arm the gate counts.
387
276
  const a0 = new Aontu()
388
277
  const ctx = a0.ctx({ collect: true })
389
278
  const out = v.gen(ctx)
@@ -391,10 +280,6 @@ function generated(v: any): any {
391
280
  }
392
281
 
393
282
 
394
- // A disjunction of CONCRETE members is an enum -- the shape a
395
- // structured-output API constrains best. Anything else is `anyOf`. A
396
- // preferred member contributes the `default` either way, which is how
397
- // `*"a"|"b"|"c"` reaches a provider as a defaulted enum.
398
283
  function fromDisjunct(ctx: Ctx, path: string[], v: any): any {
399
284
  const members: any[] = v.peg
400
285
  let def: any = undefined
@@ -492,8 +377,6 @@ function fromList(ctx: Ctx, path: string[], v: any): any {
492
377
  return out
493
378
  }
494
379
 
495
- // A written list literal is a TUPLE: position by position, and no
496
- // more. 2020-12 spells that `prefixItems` plus `items: false`.
497
380
  return {
498
381
  type: 'array',
499
382
  prefixItems: els.map((el: any, i: number) =>
@@ -509,12 +392,6 @@ export function jsonSchema(src: string, options?: SchemaOptions): SchemaReport {
509
392
  const opts = options ?? {}
510
393
  const aontu = new Aontu(includeOpts(opts))
511
394
 
512
- // COLLECT MODE, so a syntax error arrives on the context rather than
513
- // as a throw -- the same failure Go's `parseEntry` hands back as an
514
- // error, reached by the branch below. No try/catch here for the same
515
- // reason `vet` has none: the mode exists so the failure can be
516
- // reported rather than escape, and a catch that cannot be entered is
517
- // a branch arm the ADR-002 gate counts.
518
395
  const actx = aontu.ctx({ collect: true })
519
396
  const root: any = aontu.unify(src, { path: opts.path, collect: true }, actx)
520
397
 
package/src/keyorder.ts CHANGED
@@ -1,47 +1,7 @@
1
1
  /* Copyright (c) 2025 Richard Rodger, MIT License */
2
2
 
3
- /*
4
- * THE ONE MAP-KEY ORDER, shared by every site that emits keys.
5
- *
6
- * Map key order is not meaningful in unification, so both ports sort to
7
- * make output independent of insertion and unification order. The order
8
- * they sort into has to be the SAME order, and it was not.
9
- *
10
- * JavaScript compares strings by UTF-16 CODE UNIT. An astral character is
11
- * stored as a surrogate pair beginning D800-DBFF, so `<` puts it BEFORE
12
- * every character in U+E000-U+FFFF -- ahead of the private use area, of
13
- * U+FFFD, of U+FFFF. Go sorts map keys as UTF-8 bytes, which is code
14
- * POINT order, so it puts the astral character last. The two agree on
15
- * everything below U+D800 and disagree above U+DFFF, which is why this
16
- * survived: the shared suite had no key above the BMP at all, and three
17
- * separate comments in the tree asserted the ports already agreed.
18
- *
19
- * CODE POINT ORDER WINS, and not merely because Go had it. Go's
20
- * `generate()` returns a native map, so a consumer's own `json.Marshal`
21
- * sorts byte-wise no matter what this engine chooses -- picking UTF-16
22
- * order would leave the TypeScript output disagreeing with what a Go
23
- * consumer produces from the same document.
24
- *
25
- * NOT Buffer.compare, which would be the obvious shortcut. A lone
26
- * surrogate has no valid UTF-8 encoding, so Buffer.from replaces it with
27
- * U+FFFD and two DISTINCT keys compare equal -- reintroducing exactly the
28
- * insertion-order dependence the sort exists to remove. Iterating code
29
- * points keeps distinct keys distinct.
30
- */
31
3
 
32
-
33
- /**
34
- * Compare two map keys by Unicode CODE POINT.
35
- *
36
- * `String.prototype[Symbol.iterator]` yields whole code points, pairing
37
- * surrogates, so this is a plain lexicographic compare of code point
38
- * sequences -- the order Go's UTF-8 byte sort produces.
39
- */
40
4
  function cmpCodePoint(a: string, b: string): number {
41
- // Fast path: identical strings, and the common all-BMP case where the
42
- // two orders coincide, still walk the iterator -- but the loop exits at
43
- // the first differing code point, so it is one pass over the shared
44
- // prefix rather than any conversion or allocation.
45
5
  const ai = a[Symbol.iterator]()
46
6
  const bi = b[Symbol.iterator]()
47
7
 
@@ -49,8 +9,6 @@ function cmpCodePoint(a: string, b: string): number {
49
9
  const x = ai.next()
50
10
  const y = bi.next()
51
11
 
52
- // A prefix sorts before the string it is a prefix of, and two equal
53
- // strings compare 0 -- the same rule a byte compare gives.
54
12
  if (x.done) {
55
13
  return y.done ? 0 : -1
56
14
  }