aontu 0.52.1 → 0.54.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 (310) 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 +15 -3
  7. package/dist/aontu.js +126 -5
  8. package/dist/aontu.js.map +1 -1
  9. package/dist/cli.d.ts +45 -1
  10. package/dist/cli.js +2845 -69
  11. package/dist/cli.js.map +1 -1
  12. package/dist/ctx.d.ts +18 -0
  13. package/dist/ctx.js +44 -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 +45 -8
  20. package/dist/err.js.map +1 -1
  21. package/dist/graph.d.ts +13 -0
  22. package/dist/graph.js +110 -0
  23. package/dist/graph.js.map +1 -0
  24. package/dist/hcanon.d.ts +3 -0
  25. package/dist/hcanon.js +145 -0
  26. package/dist/hcanon.js.map +1 -0
  27. package/dist/hints.js +235 -8
  28. package/dist/hints.js.map +1 -1
  29. package/dist/jsonschema.d.ts +20 -0
  30. package/dist/jsonschema.js +425 -0
  31. package/dist/jsonschema.js.map +1 -0
  32. package/dist/lang.js +955 -110
  33. package/dist/lang.js.map +1 -1
  34. package/dist/lsp.d.ts +9 -2
  35. package/dist/lsp.js +343 -48
  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 +941 -0
  42. package/dist/mcp.js.map +1 -0
  43. package/dist/mod-tool.d.ts +58 -0
  44. package/dist/mod-tool.js +532 -0
  45. package/dist/mod-tool.js.map +1 -0
  46. package/dist/mod.d.ts +35 -0
  47. package/dist/mod.js +345 -0
  48. package/dist/mod.js.map +1 -0
  49. package/dist/patch.d.ts +49 -0
  50. package/dist/patch.js +506 -0
  51. package/dist/patch.js.map +1 -0
  52. package/dist/provenance.d.ts +41 -0
  53. package/dist/provenance.js +336 -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 +15 -0
  59. package/dist/reach.js +168 -0
  60. package/dist/reach.js.map +1 -0
  61. package/dist/relation.d.ts +23 -0
  62. package/dist/relation.js +230 -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/sig.d.ts +25 -0
  68. package/dist/sig.js +277 -0
  69. package/dist/sig.js.map +1 -0
  70. package/dist/sigdecl.d.ts +2 -0
  71. package/dist/sigdecl.js +11 -0
  72. package/dist/sigdecl.js.map +1 -0
  73. package/dist/siggate.d.ts +4 -0
  74. package/dist/siggate.js +90 -0
  75. package/dist/siggate.js.map +1 -0
  76. package/dist/site.d.ts +4 -0
  77. package/dist/site.js +31 -0
  78. package/dist/site.js.map +1 -1
  79. package/dist/std.d.ts +1 -0
  80. package/dist/std.js +129 -0
  81. package/dist/std.js.map +1 -0
  82. package/dist/subsume.d.ts +39 -0
  83. package/dist/subsume.js +573 -0
  84. package/dist/subsume.js.map +1 -0
  85. package/dist/trim.d.ts +19 -0
  86. package/dist/trim.js +155 -0
  87. package/dist/trim.js.map +1 -0
  88. package/dist/tsconfig.tsbuildinfo +1 -1
  89. package/dist/type.d.ts +17 -1
  90. package/dist/type.js.map +1 -1
  91. package/dist/unify.d.ts +2 -1
  92. package/dist/unify.js +234 -38
  93. package/dist/unify.js.map +1 -1
  94. package/dist/utility.d.ts +8 -1
  95. package/dist/utility.js +68 -1
  96. package/dist/utility.js.map +1 -1
  97. package/dist/val/AggFuncVal.d.ts +44 -0
  98. package/dist/val/AggFuncVal.js +364 -0
  99. package/dist/val/AggFuncVal.js.map +1 -0
  100. package/dist/val/ArithFuncVal.d.ts +31 -0
  101. package/dist/val/ArithFuncVal.js +62 -0
  102. package/dist/val/ArithFuncVal.js.map +1 -0
  103. package/dist/val/BagVal.d.ts +7 -0
  104. package/dist/val/BagVal.js +150 -11
  105. package/dist/val/BagVal.js.map +1 -1
  106. package/dist/val/CloseFuncVal.js +9 -1
  107. package/dist/val/CloseFuncVal.js.map +1 -1
  108. package/dist/val/ConjunctVal.d.ts +1 -1
  109. package/dist/val/ConjunctVal.js +19 -0
  110. package/dist/val/ConjunctVal.js.map +1 -1
  111. package/dist/val/ConstraintVal.d.ts +7 -1
  112. package/dist/val/ConstraintVal.js +523 -45
  113. package/dist/val/ConstraintVal.js.map +1 -1
  114. package/dist/val/ContainerKindVal.d.ts +35 -0
  115. package/dist/val/ContainerKindVal.js +99 -0
  116. package/dist/val/ContainerKindVal.js.map +1 -0
  117. package/dist/val/CopyFuncVal.d.ts +1 -2
  118. package/dist/val/CopyFuncVal.js.map +1 -1
  119. package/dist/val/Decimal.d.ts +1 -0
  120. package/dist/val/Decimal.js +13 -0
  121. package/dist/val/Decimal.js.map +1 -1
  122. package/dist/val/DeprecateFuncVal.d.ts +11 -0
  123. package/dist/val/DeprecateFuncVal.js +47 -0
  124. package/dist/val/DeprecateFuncVal.js.map +1 -0
  125. package/dist/val/DisjunctVal.d.ts +1 -2
  126. package/dist/val/DisjunctVal.js +269 -53
  127. package/dist/val/DisjunctVal.js.map +1 -1
  128. package/dist/val/EachFuncVal.d.ts +15 -0
  129. package/dist/val/EachFuncVal.js +75 -0
  130. package/dist/val/EachFuncVal.js.map +1 -0
  131. package/dist/val/ExpectVal.js +62 -4
  132. package/dist/val/ExpectVal.js.map +1 -1
  133. package/dist/val/FeatureVal.js +1 -1
  134. package/dist/val/FeatureVal.js.map +1 -1
  135. package/dist/val/FilterFuncVal.d.ts +15 -0
  136. package/dist/val/FilterFuncVal.js +91 -0
  137. package/dist/val/FilterFuncVal.js.map +1 -0
  138. package/dist/val/FuncBaseVal.d.ts +7 -1
  139. package/dist/val/FuncBaseVal.js +183 -2
  140. package/dist/val/FuncBaseVal.js.map +1 -1
  141. package/dist/val/GraphAtomVal.d.ts +39 -0
  142. package/dist/val/GraphAtomVal.js +184 -0
  143. package/dist/val/GraphAtomVal.js.map +1 -0
  144. package/dist/val/HideFuncVal.js.map +1 -1
  145. package/dist/val/JunctionVal.js +24 -1
  146. package/dist/val/JunctionVal.js.map +1 -1
  147. package/dist/val/KeyFuncVal.d.ts +1 -1
  148. package/dist/val/KeyFuncVal.js +38 -30
  149. package/dist/val/KeyFuncVal.js.map +1 -1
  150. package/dist/val/ListVal.js +94 -14
  151. package/dist/val/ListVal.js.map +1 -1
  152. package/dist/val/LowerFuncVal.js.map +1 -1
  153. package/dist/val/MapVal.d.ts +1 -0
  154. package/dist/val/MapVal.js +146 -14
  155. package/dist/val/MapVal.js.map +1 -1
  156. package/dist/val/MatchFuncVal.d.ts +15 -0
  157. package/dist/val/MatchFuncVal.js +107 -0
  158. package/dist/val/MatchFuncVal.js.map +1 -0
  159. package/dist/val/MoveFuncVal.js.map +1 -1
  160. package/dist/val/NilVal.js +24 -0
  161. package/dist/val/NilVal.js.map +1 -1
  162. package/dist/val/OpBaseVal.d.ts +1 -1
  163. package/dist/val/OpBaseVal.js +19 -1
  164. package/dist/val/OpBaseVal.js.map +1 -1
  165. package/dist/val/OpenFuncVal.js +4 -1
  166. package/dist/val/OpenFuncVal.js.map +1 -1
  167. package/dist/val/PackFuncVal.d.ts +15 -0
  168. package/dist/val/PackFuncVal.js +108 -0
  169. package/dist/val/PackFuncVal.js.map +1 -0
  170. package/dist/val/PathFuncVal.d.ts +2 -2
  171. package/dist/val/PathFuncVal.js +75 -16
  172. package/dist/val/PathFuncVal.js.map +1 -1
  173. package/dist/val/PathVal.d.ts +25 -0
  174. package/dist/val/PathVal.js +150 -0
  175. package/dist/val/PathVal.js.map +1 -0
  176. package/dist/val/PlaceVal.d.ts +13 -0
  177. package/dist/val/PlaceVal.js +131 -0
  178. package/dist/val/PlaceVal.js.map +1 -0
  179. package/dist/val/PlusOpVal.d.ts +2 -1
  180. package/dist/val/PlusOpVal.js +61 -37
  181. package/dist/val/PlusOpVal.js.map +1 -1
  182. package/dist/val/PrefFuncVal.js.map +1 -1
  183. package/dist/val/PrefVal.d.ts +4 -2
  184. package/dist/val/PrefVal.js +223 -41
  185. package/dist/val/PrefVal.js.map +1 -1
  186. package/dist/val/RecurseVal.d.ts +19 -0
  187. package/dist/val/RecurseVal.js +217 -0
  188. package/dist/val/RecurseVal.js.map +1 -0
  189. package/dist/val/RefVal.d.ts +3 -2
  190. package/dist/val/RefVal.js +181 -66
  191. package/dist/val/RefVal.js.map +1 -1
  192. package/dist/val/ReferFuncVal.d.ts +59 -0
  193. package/dist/val/ReferFuncVal.js +604 -0
  194. package/dist/val/ReferFuncVal.js.map +1 -0
  195. package/dist/val/ScalarKindVal.d.ts +4 -3
  196. package/dist/val/ScalarKindVal.js +12 -12
  197. package/dist/val/ScalarKindVal.js.map +1 -1
  198. package/dist/val/SuperFuncVal.d.ts +4 -2
  199. package/dist/val/SuperFuncVal.js +118 -14
  200. package/dist/val/SuperFuncVal.js.map +1 -1
  201. package/dist/val/TopVal.d.ts +1 -1
  202. package/dist/val/TopVal.js.map +1 -1
  203. package/dist/val/TypeFuncVal.js.map +1 -1
  204. package/dist/val/UpperFuncVal.js.map +1 -1
  205. package/dist/val/Val.d.ts +7 -1
  206. package/dist/val/Val.js +170 -2
  207. package/dist/val/Val.js.map +1 -1
  208. package/dist/val/VarVal.js.map +1 -1
  209. package/dist/val/arith.d.ts +6 -0
  210. package/dist/val/arith.js +173 -0
  211. package/dist/val/arith.js.map +1 -0
  212. package/dist/vet.d.ts +45 -0
  213. package/dist/vet.js +802 -0
  214. package/dist/vet.js.map +1 -0
  215. package/dist/view.d.ts +85 -0
  216. package/dist/view.js +1948 -0
  217. package/dist/view.js.map +1 -0
  218. package/dist/walk.d.ts +2 -0
  219. package/dist/walk.js +91 -0
  220. package/dist/walk.js.map +1 -0
  221. package/grammar/aontu.gbnf +138 -0
  222. package/grammar/aontu.lark +118 -0
  223. package/grammar/aontu.tmLanguage.json +184 -0
  224. package/package.json +30 -8
  225. package/skill/SKILL.md +37 -0
  226. package/skill/error-codes.md +62 -0
  227. package/skill/examples.md +99 -0
  228. package/skill/grammar-card.md +56 -0
  229. package/src/agentsmd.ts +135 -0
  230. package/src/aontu.ts +166 -5
  231. package/src/cli.ts +3324 -72
  232. package/src/ctx.ts +93 -1
  233. package/src/diff.ts +198 -0
  234. package/src/err.ts +50 -8
  235. package/src/graph.ts +185 -0
  236. package/src/hcanon.ts +167 -0
  237. package/src/hints.ts +291 -8
  238. package/src/jsonschema.ts +552 -0
  239. package/src/lang.ts +1049 -110
  240. package/src/lsp.ts +351 -49
  241. package/src/mcp-server.ts +187 -0
  242. package/src/mcp.ts +1130 -0
  243. package/src/mod-tool.ts +718 -0
  244. package/src/mod.ts +453 -0
  245. package/src/patch.ts +628 -0
  246. package/src/provenance.ts +437 -0
  247. package/src/query.ts +381 -0
  248. package/src/reach.ts +213 -0
  249. package/src/relation.ts +298 -0
  250. package/src/report-sarif.ts +137 -0
  251. package/src/sig.ts +345 -0
  252. package/src/sigdecl.ts +11 -0
  253. package/src/siggate.ts +144 -0
  254. package/src/site.ts +36 -1
  255. package/src/std.ts +131 -0
  256. package/src/subsume.ts +739 -0
  257. package/src/trim.ts +195 -0
  258. package/src/tsconfig.json +10 -4
  259. package/src/type.ts +51 -2
  260. package/src/unify.ts +253 -38
  261. package/src/utility.ts +79 -1
  262. package/src/val/AggFuncVal.ts +546 -0
  263. package/src/val/ArithFuncVal.ts +108 -0
  264. package/src/val/BagVal.ts +158 -12
  265. package/src/val/CloseFuncVal.ts +9 -1
  266. package/src/val/ConjunctVal.ts +20 -0
  267. package/src/val/ConstraintVal.ts +576 -48
  268. package/src/val/ContainerKindVal.ts +158 -0
  269. package/src/val/CopyFuncVal.ts +0 -1
  270. package/src/val/Decimal.ts +15 -0
  271. package/src/val/DeprecateFuncVal.ts +84 -0
  272. package/src/val/DisjunctVal.ts +282 -59
  273. package/src/val/EachFuncVal.ts +133 -0
  274. package/src/val/ExpectVal.ts +65 -8
  275. package/src/val/FeatureVal.ts +1 -1
  276. package/src/val/FilterFuncVal.ts +154 -0
  277. package/src/val/FuncBaseVal.ts +206 -2
  278. package/src/val/GraphAtomVal.ts +264 -0
  279. package/src/val/HideFuncVal.ts +0 -2
  280. package/src/val/JunctionVal.ts +24 -1
  281. package/src/val/KeyFuncVal.ts +39 -35
  282. package/src/val/ListVal.ts +101 -15
  283. package/src/val/LowerFuncVal.ts +0 -1
  284. package/src/val/MapVal.ts +153 -14
  285. package/src/val/MatchFuncVal.ts +176 -0
  286. package/src/val/MoveFuncVal.ts +0 -2
  287. package/src/val/NilVal.ts +25 -0
  288. package/src/val/OpBaseVal.ts +20 -1
  289. package/src/val/OpenFuncVal.ts +4 -2
  290. package/src/val/PackFuncVal.ts +175 -0
  291. package/src/val/PathFuncVal.ts +107 -20
  292. package/src/val/PathVal.ts +221 -0
  293. package/src/val/PlaceVal.ts +193 -0
  294. package/src/val/PlusOpVal.ts +67 -39
  295. package/src/val/PrefFuncVal.ts +0 -1
  296. package/src/val/PrefVal.ts +251 -60
  297. package/src/val/RecurseVal.ts +285 -0
  298. package/src/val/RefVal.ts +183 -78
  299. package/src/val/ReferFuncVal.ts +732 -0
  300. package/src/val/ScalarKindVal.ts +12 -13
  301. package/src/val/SuperFuncVal.ts +137 -13
  302. package/src/val/TopVal.ts +1 -2
  303. package/src/val/TypeFuncVal.ts +0 -2
  304. package/src/val/UpperFuncVal.ts +0 -1
  305. package/src/val/Val.ts +216 -4
  306. package/src/val/VarVal.ts +0 -1
  307. package/src/val/arith.ts +319 -0
  308. package/src/vet.ts +1025 -0
  309. package/src/view.ts +2563 -0
  310. package/src/walk.ts +99 -0
package/dist/patch.js ADDED
@@ -0,0 +1,506 @@
1
+ "use strict";
2
+ /* Copyright (c) 2025 Richard Rodger, MIT License */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.parseAssignment = parseAssignment;
5
+ exports.overlayLine = overlayLine;
6
+ exports.offsetAt = offsetAt;
7
+ exports.spanAt = spanAt;
8
+ exports.spanHolds = spanHolds;
9
+ exports.verifiedSite = verifiedSite;
10
+ exports.spanValue = spanValue;
11
+ exports.patch = patch;
12
+ // OVERLAY PATCH (G7 phase 5,
13
+ // docs/capability-review/g7-machine-access.md): change a document by
14
+ // APPENDING to an overlay, not by rewriting the file.
15
+ //
16
+ // This is the stage that needs no rewriter. An overlay entry is just
17
+ // another conjunct, and unification is order-independent, so appending
18
+ // `services: auth: owner: "identity-2"` to a second file and
19
+ // evaluating both is exactly the same value as writing it into the
20
+ // first — with no parsing of the target, no comment or layout damage,
21
+ // and nothing to preserve. The spec pins that equivalence rather than
22
+ // asserting it.
23
+ //
24
+ // What an overlay CANNOT do is change a PINNED value: the lattice
25
+ // refuses 5 against 3, and the report says so with the pinning site,
26
+ // which `why` then locates. That left the loop "set → conflict → why →
27
+ // edit the pinning site" with its last step manual — and since the
28
+ // commonest vet failure of all is "the data pins the wrong value",
29
+ // `set` was unable to repair the very case it existed for.
30
+ //
31
+ // IN-PLACE REPLACE (`--in-place`) closes that. The G7 design deferred
32
+ // it behind two prerequisites: an evaluated-path → contributing-span
33
+ // map, and a comment-and-layout-preserving CST. The first now exists —
34
+ // `why` is that map, and sites carry `len` and `src` since a site was
35
+ // given an extent. The second turns out NOT to be needed for the case
36
+ // that matters, and the reason is worth stating: a CST is what you need
37
+ // to RE-SERIALISE a document, and a targeted span splice serialises
38
+ // nothing. It replaces `len` code units at one offset and leaves every
39
+ // other byte — every comment, every blank line, every alignment space —
40
+ // exactly as the author left it, because it never looks at them.
41
+ //
42
+ // What makes the splice safe rather than merely plausible is that the
43
+ // site carries `src`, the text it claims to cover. The span is VERIFIED
44
+ // against it before a byte is written, so the corrupting arithmetic
45
+ // this repository has already shipped once — `port: 0x1F` reporting
46
+ // canon `"31"` at column 7, and `(col, canon.length)` writing
47
+ // `port: 5x1F` — cannot be reached: `0x1F` is four code units and says
48
+ // so, and if the text at the span is anything else the edit is refused
49
+ // rather than guessed.
50
+ //
51
+ // Replace is never WORSE than append. Where the value is not a single
52
+ // editable literal in this overlay — a spread template governing other
53
+ // keys, a reference whose site is the `$` and not the target, two
54
+ // statements pinning the same path, a literal in an included file — the
55
+ // splice is refused and the assignment is APPENDED exactly as it would
56
+ // have been without the flag, plus one `warning` finding naming the
57
+ // case and the site it came from. Warnings never move a verdict, so
58
+ // `--in-place` cannot turn a run that would have succeeded into one
59
+ // that fails; it can only rewrite where rewriting is safe, and explain
60
+ // itself where it is not.
61
+ //
62
+ // The verdict is G2's, unchanged: `vet(entry, overlay)` already asks
63
+ // exactly the right question — does this document hold against that
64
+ // truth, and if not, where — so `set` adds a writer, not a report.
65
+ const vet_1 = require("./vet");
66
+ const query_1 = require("./query");
67
+ const aontu_1 = require("./aontu");
68
+ // An assignment is `<path>=<value>`, split at the FIRST `=`: a path
69
+ // segment is a name, and the value is arbitrary Aontu source, which
70
+ // may itself contain `=` (`a: min(1)` does not, but a string can).
71
+ function parseAssignment(text) {
72
+ const eq = text.indexOf('=');
73
+ if (eq < 1) {
74
+ return undefined;
75
+ }
76
+ const path = text.slice(0, eq).trim();
77
+ const value = text.slice(eq + 1).trim();
78
+ if ('' === value || 0 === (0, query_1.pathParts)(path).length) {
79
+ return undefined;
80
+ }
81
+ return { path, value };
82
+ }
83
+ // The path-flattened conjunct one assignment becomes:
84
+ // `$.a.b = 1` is `"a": "b": 1`. Keys are QUOTED — a segment may be a
85
+ // word the grammar spells otherwise (`if`), a number, or a name with
86
+ // a space in it, and quoting one key is the same value as writing it
87
+ // bare.
88
+ function overlayLine(path, value) {
89
+ return (0, query_1.pathParts)(path).map((p) => JSON.stringify(p)).join(': ') +
90
+ ': ' + value;
91
+ }
92
+ // The character offset of a 1-based (row, col) in `src`, or -1 when the
93
+ // text has no such position. Columns are UTF-16 code units, which is
94
+ // what a site carries and what a JavaScript string index already is —
95
+ // so this is the inverse of the site arithmetic, not a reinterpretation
96
+ // of it (go/patch.go converts to a byte offset, because Go strings are
97
+ // bytes; both address the same character).
98
+ function offsetAt(src, row, col) {
99
+ if (row < 1 || col < 1) {
100
+ return -1;
101
+ }
102
+ let off = 0;
103
+ for (let r = 1; r < row; r++) {
104
+ const nl = src.indexOf('\n', off);
105
+ if (nl < 0) {
106
+ return -1;
107
+ }
108
+ off = nl + 1;
109
+ }
110
+ const at = off + (col - 1);
111
+ return at <= src.length ? at : -1;
112
+ }
113
+ // The text a site covers, or undefined when the site does not describe
114
+ // a position in this text at all.
115
+ function spanAt(src, site) {
116
+ const off = offsetAt(src, site.row, site.col);
117
+ return off < 0 ? undefined : src.slice(off, off + site.len);
118
+ }
119
+ // DOES THE TEXT AT THIS SITE SAY WHAT THE SITE CLAIMS IT SAYS?
120
+ //
121
+ // The last check before a splice, and the one that makes the write
122
+ // PROVABLE rather than argued. Exported so it can be exercised with a
123
+ // site the engine would never produce — an out-of-range position, a
124
+ // span over different text — which is the only way to test a guard whose
125
+ // whole purpose is to catch a state the rest of the code says cannot
126
+ // happen. (go/patch.go has the twin, tested the same way.)
127
+ function spanHolds(src, site, expect) {
128
+ // THE SITE'S OWN LENGTH IS PART OF ITS CLAIM, and is checked before
129
+ // the text is. A site whose `len` disagrees with the text it says it
130
+ // covers CONTRADICTS ITSELF, which is exactly the state this guard
131
+ // exists to catch — and a zero-length span would otherwise compare
132
+ // equal against nothing and then splice nothing, INSERTING the new
133
+ // value rather than replacing anything.
134
+ //
135
+ // Both ports compare in UTF-16 code units, which is what a site's
136
+ // `len` counts. That is free here and is not in Go, where a string is
137
+ // bytes (go/patch.go converts).
138
+ if ('' === expect || site.len !== expect.length) {
139
+ return false;
140
+ }
141
+ return spanAt(src, site) === expect;
142
+ }
143
+ // WHY IS THE VALUE AT THIS PATH WHAT IT IS, and is exactly one of the
144
+ // answers a literal this overlay can edit in place?
145
+ //
146
+ // The four refusals below are not defensive padding; each is a real
147
+ // document shape that the probe corpus produced, and each would corrupt
148
+ // something different if the splice ran anyway:
149
+ //
150
+ // - a SPREAD contribution's site is inside the template, which
151
+ // governs every other key too, so rewriting it there changes keys
152
+ // the author did not name;
153
+ // - a REFERENCE's site is the `$` that starts the path and has length
154
+ // 1, so splicing over it writes the new value INTO the path
155
+ // expression (`$.base` becomes `5.base`) — and the value the author
156
+ // wants changed lives at the target anyway;
157
+ // - TWO literals at one path (a duplicate key, two files merged) give
158
+ // no single place to edit, and picking either silently is picking
159
+ // for the author;
160
+ // - a literal in an INCLUDED file is editable, but not by
161
+ // `--overlay <this file>`: the write would land in a document the
162
+ // caller did not name.
163
+ //
164
+ // A PREFERENCE is not refused here for the same reason it is not
165
+ // replaced: appending already overrides a default correctly, so the
166
+ // caller loses nothing by falling through to it.
167
+ function editableLiteral(overlaySrc, path, overlayPath) {
168
+ // THE AUTHORITY IS THE OVERLAY TEXT ALONE, WITH INCLUDES DENIED.
169
+ //
170
+ // The splice happens in the text this function was handed, so what it
171
+ // has to establish is that the contribution is IN that text — and the
172
+ // site's `file` cannot establish it. Two ways it fails: a caller of
173
+ // the library API need not pass `overlayPath`, leaving nothing to
174
+ // compare against; and the Go port names the ENTRY document for an
175
+ // included value anyway (issue #66), so the comparison is the overlay
176
+ // against itself. Either way an included literal's (row, col, len,
177
+ // src) can COINCIDE with different text at the same coordinates here
178
+ // — an include holding `a: 42` at 1:4 and an overlay holding `x: 42`
179
+ // at 1:4 — and the span verification cannot tell them apart, because
180
+ // the text really does match. The splice then rewrites `x` while
181
+ // reporting a replacement of `$.a`, in both ports.
182
+ //
183
+ // Denying includes removes the ambiguity at its source rather than
184
+ // detecting it: what resolves is what this text says by itself. An
185
+ // overlay that loads other documents therefore cannot be edited in
186
+ // place at all — the conservative answer, and the assignment still
187
+ // appends. It costs nothing in the shape `set` is for, an overlay it
188
+ // owns and appends to, and it does not depend on file attribution, so
189
+ // both ports agree without waiting on #66.
190
+ const alone = (0, query_1.why)(overlaySrc, path, {
191
+ trust: { include: 'none' },
192
+ ...(null == overlayPath ? {} : { path: overlayPath }),
193
+ });
194
+ if (true !== alone.ok || null == alone.record) {
195
+ // Nothing here BY ITSELF. Two very different reasons, and they earn
196
+ // different answers: the path may simply not be in this overlay, in
197
+ // which case appending is the whole of the answer and nothing has
198
+ // gone wrong — or it may be here only because something was loaded,
199
+ // which is the case above and has to say so.
200
+ const withLoads = (0, query_1.why)(overlaySrc, path, null == overlayPath ? undefined : { path: overlayPath });
201
+ if (true !== withLoads.ok || null == withLoads.record) {
202
+ return { site: undefined, finding: undefined };
203
+ }
204
+ return {
205
+ site: undefined,
206
+ finding: notEditable('patch_not_editable', path, 'this path resolves only once the overlay loads another ' +
207
+ 'document, so no literal here can be shown to be the one to ' +
208
+ 'edit; run set with the document that writes it as the overlay', withLoads.record.conjuncts),
209
+ };
210
+ }
211
+ const record = alone.record;
212
+ // No `?? []`: WhyRecord.conjuncts is a non-optional array and the
213
+ // record's own presence was just established, so a fallback here
214
+ // would claim a possibility the type does not have — and the
215
+ // coverage gate says so, an arm nothing can take.
216
+ const conjuncts = record.conjuncts;
217
+ // A VALUE REACHED THROUGH A REFERENCE IS NOT THIS PATH'S TO EDIT.
218
+ // Provenance travels through clones now, so `n: $.base` against
219
+ // `base: 7` reports the literal `7` -- correctly, and at the site
220
+ // where it was written, which is `base`'s line and not `n`'s. A
221
+ // splice there would rewrite the REFERENT: every other reader of
222
+ // `$.base` changes with it, and the path the caller named does not
223
+ // move at all. The reference is what stands here, so the reference
224
+ // is what has to be edited, wherever it points.
225
+ const refs = conjuncts.filter((c) => 'ref' === c.role);
226
+ if (0 < refs.length) {
227
+ return {
228
+ site: undefined,
229
+ finding: notEditable('patch_not_editable', path, 'the value here is reached through a reference (ref), so the ' +
230
+ 'literal below belongs to the path it points at; edit where it ' +
231
+ 'comes from', refs),
232
+ };
233
+ }
234
+ const literals = conjuncts.filter((c) => 'literal' === c.role);
235
+ if (1 < literals.length) {
236
+ return {
237
+ site: undefined,
238
+ finding: notEditable('patch_ambiguous', path, 'two or more statements pin this path, so there is no single ' +
239
+ 'place to edit; the sites below are all of them', literals),
240
+ };
241
+ }
242
+ // Only indirect contributions. A pref is the benign case — append
243
+ // overrides a default — so it earns no finding; the others do.
244
+ if (0 === literals.length) {
245
+ const indirect = conjuncts.filter((c) => 'pref' !== c.role);
246
+ if (0 === indirect.length) {
247
+ return { site: undefined, finding: undefined };
248
+ }
249
+ return {
250
+ site: undefined,
251
+ finding: notEditable('patch_not_editable', path, 'the value here is not written as a literal (' +
252
+ indirect.map((c) => c.role).join(', ') +
253
+ '), so there is no literal to rewrite; edit where it comes from', indirect),
254
+ };
255
+ }
256
+ return verifiedSite(overlaySrc, path, literals[0]);
257
+ }
258
+ // THE SPAN MUST CHECK OUT before anything splices. The refusal arm is
259
+ // unreachable through `patch` since ADR-018: the pipe (`x: hello |>
260
+ // upper`) was the one spelling that synthesised a contribution the
261
+ // parser never sited, and denying includes means every WRITTEN
262
+ // contribution's coordinates describe this text by construction. The
263
+ // verification is kept rather than deleted — splicing without it would
264
+ // corrupt the file (a contribution with no `src` would splice ZERO
265
+ // characters, INSERTING the new value into the middle of a line) — and
266
+ // this last step is its own exported seam so the refusal can be tested
267
+ // directly, against conjuncts the engine would never produce, on the
268
+ // same footing as `spanHolds` itself.
269
+ function verifiedSite(overlaySrc, path, one) {
270
+ if (!spanHolds(overlaySrc, one.site, one.src)) {
271
+ const finding = notEditable('patch_span_mismatch', path, 'the overlay does not hold ' + JSON.stringify(one.src) + ' at ' +
272
+ one.site.row + ':' + one.site.col + ' (len ' + one.site.len +
273
+ '), so the span cannot be verified before writing', [one]);
274
+ // The one internal-class refusal: a recorded span failing to check
275
+ // out is the engine's fault, never the document's.
276
+ finding.class = 'internal';
277
+ return { site: undefined, finding };
278
+ }
279
+ // DOES THE SPAN MEAN THE WHOLE CONTRIBUTION?
280
+ //
281
+ // This is the check that `role === 'literal'` looks like it makes and
282
+ // does not. A site names the TOKEN it points at, so a COMPOUND value
283
+ // reports its OPENING token while its canon is the whole thing:
284
+ // `min(1)` is a literal-role contribution whose src is `min`, `1+2`
285
+ // reports `1`, `$.k+1` reports `$`, `{b:1}` reports `{` and `[1,2]`
286
+ // reports `[`. Splicing over any of those writes the new value INTO
287
+ // the expression — `a: 5(1)`, `a: 5+2`, `a: 5.k+1` — which is the
288
+ // same class of corruption as the canon-length arithmetic, reached by
289
+ // a different route.
290
+ //
291
+ // Rather than enumerate the shapes (a list is a thing to be
292
+ // incomplete about), ASK THE ENGINE: parse `src` on its own and
293
+ // require the value it means to be the value the contribution
294
+ // contributed. That is exactly the property a splice needs — this
295
+ // text, alone, is this value — and it is decided by the same unifier
296
+ // that produced the contribution, so it cannot drift from it.
297
+ //
298
+ // It also gets the interesting case right without special-casing it:
299
+ // `0x1F` canons to `31`, which is not its own spelling, but IS the
300
+ // contribution's canon, so a hex literal is editable while `min` is
301
+ // not.
302
+ const span = spanValue(one.src);
303
+ if (null == span || span.canon !== one.canon) {
304
+ return {
305
+ site: undefined,
306
+ finding: notEditable('patch_not_editable', path, 'the site names ' + JSON.stringify(one.src) + ', which is the ' +
307
+ 'opening token of ' + one.canon + ' rather than the whole of ' +
308
+ 'it; rewriting that span would edit the expression, not the ' +
309
+ 'value', [one]),
310
+ };
311
+ }
312
+ // AN ABSTRACT CONTRIBUTION IS NOT A PIN. `a: integer` and
313
+ // `a: above(0)` state a constraint, and appending already narrows
314
+ // them — that is the one case the status report notes `set` could
315
+ // always repair. Replacing them would silently DISCARD a constraint
316
+ // the author wrote, to no benefit, so this falls through to append.
317
+ if (true !== span.concrete) {
318
+ return {
319
+ site: undefined,
320
+ finding: notEditable('patch_not_editable', path, one.canon + ' is a constraint here, not a pinned value; ' +
321
+ 'appending narrows it without discarding what it says', [one]),
322
+ };
323
+ }
324
+ return {
325
+ site: {
326
+ col: one.site.col,
327
+ file: one.site.file,
328
+ from: one.src,
329
+ path,
330
+ row: one.site.row,
331
+ to: '',
332
+ },
333
+ finding: undefined,
334
+ };
335
+ }
336
+ // What does this source text mean ON ITS OWN, and is it a value rather
337
+ // than a constraint? Undefined when it does not stand alone at all
338
+ // (`$` from a path, an unbalanced `{`).
339
+ //
340
+ // The wrapper key is arbitrary and the document it makes is thrown
341
+ // away; what is wanted is the unifier's own reading of the fragment.
342
+ function spanValue(src) {
343
+ // NO COLLECTING CONTEXT: `unify` THROWS on a source it cannot read,
344
+ // so a ctx.err check here is a branch nothing can reach — the catch
345
+ // below is the only path a bad fragment takes. (A first draft had
346
+ // both, and the coverage gate called the pair what it was.) What the
347
+ // nil test still earns is the fragment that PARSES and means nothing:
348
+ // `$` is a path with no target, and answers a nil rather than
349
+ // throwing.
350
+ let canon;
351
+ try {
352
+ const root = new aontu_1.Aontu().unify('v: ' + src);
353
+ const node = root?.peg?.['v'];
354
+ if (null == node || true === node.isNil) {
355
+ return undefined;
356
+ }
357
+ canon = node.canon;
358
+ }
359
+ catch (e) {
360
+ return undefined;
361
+ }
362
+ // Generability is the concreteness test, and it is the engine's own:
363
+ // a kind, a constraint and an unresolved disjunction all refuse to
364
+ // generate, which is precisely the line this needs drawn.
365
+ try {
366
+ new aontu_1.Aontu().generate('v: ' + src);
367
+ }
368
+ catch (e) {
369
+ return { canon, concrete: false };
370
+ }
371
+ return { canon, concrete: true };
372
+ }
373
+ // A refusal to replace, as a WARNING: the assignment still appends, so
374
+ // nothing about the run got worse and the verdict must not move
375
+ // (ts/src/vet.ts, "warnings never touch the verdict"). What the finding
376
+ // adds is the reason, which is the whole value of asking for --in-place
377
+ // over plain set.
378
+ function notEditable(code, path, why, from) {
379
+ return {
380
+ code,
381
+ // Always `reference`; the one internal-class refusal
382
+ // (patch_span_mismatch) overrides at its call site.
383
+ class: 'reference',
384
+ severity: 'warning',
385
+ path,
386
+ // No separate `note`: the renderer prints both, and a note that
387
+ // restates its own message is noise wearing a second label.
388
+ message: 'cannot rewrite ' + path + ' in place: ' + why,
389
+ sites: from.map((c) => ({
390
+ file: c.site.file,
391
+ row: c.site.row,
392
+ col: c.site.col,
393
+ len: c.site.len,
394
+ src: c.src,
395
+ role: 'data',
396
+ value: c.canon,
397
+ })),
398
+ };
399
+ }
400
+ // Append the assignments to the overlay and answer what the result
401
+ // holds. The report's verdict is the vet verdict of the ENTRY against
402
+ // the new overlay: `valid` when it holds and is concrete, `incomplete`
403
+ // when nothing contradicts but the truth is not yet satisfied,
404
+ // `invalid` when the overlay contradicts a pinned value, `error` when
405
+ // the entry itself does not stand up.
406
+ function patch(entrySrc, overlaySrc, assignments, opts) {
407
+ const options = opts ?? {};
408
+ const appended = [];
409
+ const replaced = [];
410
+ const notes = [];
411
+ // Each pending edit as (offset, length, text). Collected first and
412
+ // applied last, back to front: a splice shifts every offset after it,
413
+ // and recomputing them per edit is a way to be subtly wrong for free.
414
+ const edits = [];
415
+ for (const text of assignments) {
416
+ const a = parseAssignment(text);
417
+ if (null == a) {
418
+ return {
419
+ overlay: overlaySrc,
420
+ appended: [],
421
+ replaced: [],
422
+ verdict: 'error',
423
+ findings: [{
424
+ code: 'patch_assignment',
425
+ class: 'parse',
426
+ severity: 'error',
427
+ path: '$',
428
+ message: `Not a <path>=<value> assignment: ${text}`,
429
+ sites: [],
430
+ }],
431
+ };
432
+ }
433
+ if (true === options.inPlace) {
434
+ const found = editableLiteral(overlaySrc, a.path, options.overlayPath);
435
+ if (null != found.finding) {
436
+ notes.push(found.finding);
437
+ }
438
+ if (null != found.site) {
439
+ // Two assignments naming the same path would splice the same
440
+ // span twice. The second is the one the author wrote last, so
441
+ // it wins — and the first is dropped rather than layered.
442
+ const at = offsetAt(overlaySrc, found.site.row, found.site.col);
443
+ const dup = edits.findIndex((e) => e.at === at);
444
+ const edit = { at, len: found.site.from.length, to: a.value };
445
+ if (dup < 0) {
446
+ edits.push(edit);
447
+ replaced.push({ ...found.site, to: a.value });
448
+ }
449
+ else {
450
+ edits[dup] = edit;
451
+ replaced[dup] = { ...found.site, to: a.value };
452
+ }
453
+ continue;
454
+ }
455
+ }
456
+ appended.push(overlayLine(a.path, a.value));
457
+ }
458
+ const overlay = joinOverlay(applyEdits(overlaySrc, edits), appended);
459
+ // The file names ride as URLs as well as base paths, so a finding
460
+ // names the entry and the overlay rather than vet's generic
461
+ // `schema`/`data` labels — with two documents that both belong to
462
+ // the caller, "which file" is the whole question.
463
+ const report = (0, vet_1.vet)(entrySrc, overlay, {
464
+ trust: options.trust,
465
+ schemaPath: options.entryPath,
466
+ dataPath: options.overlayPath,
467
+ schemaUrl: options.entryPath,
468
+ dataUrl: options.overlayPath,
469
+ });
470
+ return {
471
+ overlay,
472
+ appended,
473
+ replaced,
474
+ verdict: report.verdict,
475
+ // The refusals come FIRST: they explain why the run took the shape
476
+ // it did, and a reader who stops after the first finding should
477
+ // read that rather than a conflict it predicted.
478
+ findings: notes.concat(report.findings),
479
+ };
480
+ }
481
+ // Apply the collected splices back to front, so an earlier edit's
482
+ // offset is never invalidated by a later one having already run.
483
+ function applyEdits(src, edits) {
484
+ if (0 === edits.length) {
485
+ return src;
486
+ }
487
+ let out = src;
488
+ for (const e of [...edits].sort((x, y) => y.at - x.at)) {
489
+ out = out.slice(0, e.at) + e.to + out.slice(e.at + e.len);
490
+ }
491
+ return out;
492
+ }
493
+ // One line per assignment, after whatever the overlay already said. A
494
+ // trailing newline is kept when the file had one and added when it
495
+ // did not: a file that does not end in a newline is still a file, and
496
+ // appending to it must not join two entries into one line.
497
+ function joinOverlay(overlaySrc, appended) {
498
+ if (0 === appended.length) {
499
+ return overlaySrc;
500
+ }
501
+ const head = '' === overlaySrc || overlaySrc.endsWith('\n')
502
+ ? overlaySrc
503
+ : overlaySrc + '\n';
504
+ return head + appended.join('\n') + '\n';
505
+ }
506
+ //# sourceMappingURL=patch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO,GAAG,CAAA;IACZ,CAAC;IACD,IAAI,GAAG,GAAG,GAAG,CAAA;IACb,KAAK,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QACvD,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAA;IAC3D,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAGD,sEAAsE;AACtE,mEAAmE;AACnE,sEAAsE;AACtE,2DAA2D;AAC3D,SAAS,WAAW,CAAC,UAAkB,EAAE,QAAkB;IACzD,IAAI,CAAC,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,UAAU,CAAA;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,EAAE,KAAK,UAAU,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC;QACzD,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,UAAU,GAAG,IAAI,CAAA;IACrB,OAAO,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAC1C,CAAC"}
@@ -0,0 +1,41 @@
1
+ export type WhyRole = 'literal' | 'spread' | 'ref' | 'pref';
2
+ export type WhySite = {
3
+ col: number;
4
+ file: string;
5
+ len: number;
6
+ row: number;
7
+ };
8
+ export type WhyConjunct = {
9
+ canon: string;
10
+ role: WhyRole;
11
+ site: WhySite;
12
+ src: string;
13
+ rank?: number;
14
+ };
15
+ export type WhyRecord = {
16
+ conjuncts: WhyConjunct[];
17
+ path: string;
18
+ value: string;
19
+ };
20
+ export declare const FROM_SPREAD = "_fromSpread";
21
+ export declare const WRITTEN = "_written";
22
+ export declare const INNER_OF = "_innerOf";
23
+ export declare function markSpread(v: any, seen?: Set<any>): void;
24
+ type Contribution = WhyConjunct & {
25
+ id: number;
26
+ };
27
+ type PathRecord = {
28
+ conjuncts: Contribution[];
29
+ made: Set<number>;
30
+ seen: Set<number>;
31
+ };
32
+ export declare class Provenance {
33
+ paths: Map<string, PathRecord>;
34
+ containers: Map<number, any>;
35
+ writtenFrom(v: any): void;
36
+ record(path: string[], a: any, b: any, out: any): void;
37
+ private contribute;
38
+ stands(path: string[], v: any): void;
39
+ at(path: string[]): WhyConjunct[];
40
+ }
41
+ export {};