aontu 0.52.0 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/README.md +88 -0
  2. package/bin/aontu-mcp.js +4 -0
  3. package/dist/agentsmd.d.ts +16 -0
  4. package/dist/agentsmd.js +107 -0
  5. package/dist/agentsmd.js.map +1 -0
  6. package/dist/aontu.d.ts +14 -3
  7. package/dist/aontu.js +145 -4
  8. package/dist/aontu.js.map +1 -1
  9. package/dist/cli.d.ts +44 -1
  10. package/dist/cli.js +2401 -44
  11. package/dist/cli.js.map +1 -1
  12. package/dist/ctx.d.ts +16 -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 +48 -8
  20. package/dist/err.js.map +1 -1
  21. package/dist/graph.d.ts +16 -0
  22. package/dist/graph.js +73 -0
  23. package/dist/graph.js.map +1 -0
  24. package/dist/hcanon.d.ts +3 -0
  25. package/dist/hcanon.js +146 -0
  26. package/dist/hcanon.js.map +1 -0
  27. package/dist/hints.js +223 -5
  28. package/dist/hints.js.map +1 -1
  29. package/dist/jsonschema.d.ts +20 -0
  30. package/dist/jsonschema.js +391 -0
  31. package/dist/jsonschema.js.map +1 -0
  32. package/dist/lang.js +698 -35
  33. package/dist/lang.js.map +1 -1
  34. package/dist/lsp.d.ts +9 -2
  35. package/dist/lsp.js +262 -46
  36. package/dist/lsp.js.map +1 -1
  37. package/dist/mcp-server.d.ts +20 -0
  38. package/dist/mcp-server.js +147 -0
  39. package/dist/mcp-server.js.map +1 -0
  40. package/dist/mcp.d.ts +42 -0
  41. package/dist/mcp.js +814 -0
  42. package/dist/mcp.js.map +1 -0
  43. package/dist/mod-tool.d.ts +58 -0
  44. package/dist/mod-tool.js +498 -0
  45. package/dist/mod-tool.js.map +1 -0
  46. package/dist/mod.d.ts +31 -0
  47. package/dist/mod.js +250 -0
  48. package/dist/mod.js.map +1 -0
  49. package/dist/patch.d.ts +44 -0
  50. package/dist/patch.js +506 -0
  51. package/dist/patch.js.map +1 -0
  52. package/dist/provenance.d.ts +40 -0
  53. package/dist/provenance.js +335 -0
  54. package/dist/provenance.js.map +1 -0
  55. package/dist/query.d.ts +27 -0
  56. package/dist/query.js +294 -0
  57. package/dist/query.js.map +1 -0
  58. package/dist/reach.d.ts +14 -0
  59. package/dist/reach.js +140 -0
  60. package/dist/reach.js.map +1 -0
  61. package/dist/relation.d.ts +19 -0
  62. package/dist/relation.js +305 -0
  63. package/dist/relation.js.map +1 -0
  64. package/dist/report-sarif.d.ts +14 -0
  65. package/dist/report-sarif.js +102 -0
  66. package/dist/report-sarif.js.map +1 -0
  67. package/dist/site.d.ts +4 -0
  68. package/dist/site.js +31 -0
  69. package/dist/site.js.map +1 -1
  70. package/dist/std.d.ts +1 -0
  71. package/dist/std.js +73 -0
  72. package/dist/std.js.map +1 -0
  73. package/dist/subsume.d.ts +39 -0
  74. package/dist/subsume.js +526 -0
  75. package/dist/subsume.js.map +1 -0
  76. package/dist/trim.d.ts +19 -0
  77. package/dist/trim.js +155 -0
  78. package/dist/trim.js.map +1 -0
  79. package/dist/tsconfig.tsbuildinfo +1 -1
  80. package/dist/type.d.ts +17 -1
  81. package/dist/type.js.map +1 -1
  82. package/dist/unify.d.ts +3 -1
  83. package/dist/unify.js +287 -18
  84. package/dist/unify.js.map +1 -1
  85. package/dist/utility.d.ts +9 -1
  86. package/dist/utility.js +122 -1
  87. package/dist/utility.js.map +1 -1
  88. package/dist/val/AggFuncVal.d.ts +33 -0
  89. package/dist/val/AggFuncVal.js +202 -0
  90. package/dist/val/AggFuncVal.js.map +1 -0
  91. package/dist/val/ArithFuncVal.d.ts +31 -0
  92. package/dist/val/ArithFuncVal.js +62 -0
  93. package/dist/val/ArithFuncVal.js.map +1 -0
  94. package/dist/val/BagVal.d.ts +5 -0
  95. package/dist/val/BagVal.js +96 -5
  96. package/dist/val/BagVal.js.map +1 -1
  97. package/dist/val/CloseFuncVal.js +9 -1
  98. package/dist/val/CloseFuncVal.js.map +1 -1
  99. package/dist/val/ConjunctVal.d.ts +1 -1
  100. package/dist/val/ConjunctVal.js +19 -0
  101. package/dist/val/ConjunctVal.js.map +1 -1
  102. package/dist/val/ConstraintVal.d.ts +48 -1
  103. package/dist/val/ConstraintVal.js +1501 -110
  104. package/dist/val/ConstraintVal.js.map +1 -1
  105. package/dist/val/CopyFuncVal.d.ts +1 -2
  106. package/dist/val/CopyFuncVal.js +7 -0
  107. package/dist/val/CopyFuncVal.js.map +1 -1
  108. package/dist/val/Decimal.d.ts +1 -0
  109. package/dist/val/Decimal.js +13 -0
  110. package/dist/val/Decimal.js.map +1 -1
  111. package/dist/val/DeprecateFuncVal.d.ts +11 -0
  112. package/dist/val/DeprecateFuncVal.js +47 -0
  113. package/dist/val/DeprecateFuncVal.js.map +1 -0
  114. package/dist/val/DisjunctVal.js +130 -21
  115. package/dist/val/DisjunctVal.js.map +1 -1
  116. package/dist/val/EachFuncVal.d.ts +15 -0
  117. package/dist/val/EachFuncVal.js +75 -0
  118. package/dist/val/EachFuncVal.js.map +1 -0
  119. package/dist/val/ExpectVal.d.ts +1 -0
  120. package/dist/val/ExpectVal.js +41 -4
  121. package/dist/val/ExpectVal.js.map +1 -1
  122. package/dist/val/FeatureVal.js +1 -1
  123. package/dist/val/FeatureVal.js.map +1 -1
  124. package/dist/val/FilterFuncVal.d.ts +15 -0
  125. package/dist/val/FilterFuncVal.js +91 -0
  126. package/dist/val/FilterFuncVal.js.map +1 -0
  127. package/dist/val/FuncBaseVal.d.ts +6 -1
  128. package/dist/val/FuncBaseVal.js +178 -2
  129. package/dist/val/FuncBaseVal.js.map +1 -1
  130. package/dist/val/HideFuncVal.js.map +1 -1
  131. package/dist/val/IdFuncVal.d.ts +13 -0
  132. package/dist/val/IdFuncVal.js +54 -0
  133. package/dist/val/IdFuncVal.js.map +1 -0
  134. package/dist/val/JunctionVal.js +7 -1
  135. package/dist/val/JunctionVal.js.map +1 -1
  136. package/dist/val/KeyFuncVal.d.ts +1 -1
  137. package/dist/val/KeyFuncVal.js +38 -30
  138. package/dist/val/KeyFuncVal.js.map +1 -1
  139. package/dist/val/ListVal.js +117 -17
  140. package/dist/val/ListVal.js.map +1 -1
  141. package/dist/val/LowerFuncVal.js.map +1 -1
  142. package/dist/val/MapVal.js +102 -8
  143. package/dist/val/MapVal.js.map +1 -1
  144. package/dist/val/MatchFuncVal.d.ts +15 -0
  145. package/dist/val/MatchFuncVal.js +107 -0
  146. package/dist/val/MatchFuncVal.js.map +1 -0
  147. package/dist/val/MoveFuncVal.js.map +1 -1
  148. package/dist/val/NilVal.js +24 -0
  149. package/dist/val/NilVal.js.map +1 -1
  150. package/dist/val/OpBaseVal.d.ts +1 -1
  151. package/dist/val/OpBaseVal.js +24 -2
  152. package/dist/val/OpBaseVal.js.map +1 -1
  153. package/dist/val/OpenFuncVal.js +4 -1
  154. package/dist/val/OpenFuncVal.js.map +1 -1
  155. package/dist/val/PackFuncVal.d.ts +15 -0
  156. package/dist/val/PackFuncVal.js +108 -0
  157. package/dist/val/PackFuncVal.js.map +1 -0
  158. package/dist/val/PathFuncVal.js.map +1 -1
  159. package/dist/val/PlaceVal.d.ts +13 -0
  160. package/dist/val/PlaceVal.js +131 -0
  161. package/dist/val/PlaceVal.js.map +1 -0
  162. package/dist/val/PlusOpVal.js +11 -2
  163. package/dist/val/PlusOpVal.js.map +1 -1
  164. package/dist/val/PrefFuncVal.js.map +1 -1
  165. package/dist/val/PrefVal.d.ts +2 -2
  166. package/dist/val/PrefVal.js +78 -23
  167. package/dist/val/PrefVal.js.map +1 -1
  168. package/dist/val/RefVal.d.ts +1 -1
  169. package/dist/val/RefVal.js +158 -30
  170. package/dist/val/RefVal.js.map +1 -1
  171. package/dist/val/ReferFuncVal.d.ts +36 -0
  172. package/dist/val/ReferFuncVal.js +303 -0
  173. package/dist/val/ReferFuncVal.js.map +1 -0
  174. package/dist/val/ScalarKindVal.d.ts +1 -2
  175. package/dist/val/ScalarKindVal.js +0 -11
  176. package/dist/val/ScalarKindVal.js.map +1 -1
  177. package/dist/val/TopVal.js.map +1 -1
  178. package/dist/val/TypeFuncVal.js.map +1 -1
  179. package/dist/val/UpperFuncVal.js.map +1 -1
  180. package/dist/val/Val.d.ts +9 -2
  181. package/dist/val/Val.js +150 -4
  182. package/dist/val/Val.js.map +1 -1
  183. package/dist/val/VarVal.js.map +1 -1
  184. package/dist/val/arith.d.ts +6 -0
  185. package/dist/val/arith.js +170 -0
  186. package/dist/val/arith.js.map +1 -0
  187. package/dist/vet.d.ts +45 -0
  188. package/dist/vet.js +776 -0
  189. package/dist/vet.js.map +1 -0
  190. package/dist/walk.d.ts +2 -0
  191. package/dist/walk.js +91 -0
  192. package/dist/walk.js.map +1 -0
  193. package/grammar/aontu.gbnf +130 -0
  194. package/grammar/aontu.lark +113 -0
  195. package/package.json +30 -15
  196. package/skill/SKILL.md +37 -0
  197. package/skill/error-codes.md +62 -0
  198. package/skill/examples.md +99 -0
  199. package/skill/grammar-card.md +57 -0
  200. package/src/agentsmd.ts +135 -0
  201. package/src/aontu.ts +192 -4
  202. package/src/cli.ts +2858 -71
  203. package/src/ctx.ts +81 -0
  204. package/src/diff.ts +196 -0
  205. package/src/err.ts +52 -8
  206. package/src/graph.ts +135 -0
  207. package/src/hcanon.ts +169 -0
  208. package/src/hints.ts +271 -5
  209. package/src/jsonschema.ts +511 -0
  210. package/src/lang.ts +779 -37
  211. package/src/lsp.ts +281 -47
  212. package/src/mcp-server.ts +187 -0
  213. package/src/mcp.ts +993 -0
  214. package/src/mod-tool.ts +679 -0
  215. package/src/mod.ts +344 -0
  216. package/src/patch.ts +624 -0
  217. package/src/provenance.ts +430 -0
  218. package/src/query.ts +379 -0
  219. package/src/reach.ts +184 -0
  220. package/src/relation.ts +395 -0
  221. package/src/report-sarif.ts +137 -0
  222. package/src/site.ts +36 -1
  223. package/src/std.ts +73 -0
  224. package/src/subsume.ts +690 -0
  225. package/src/trim.ts +195 -0
  226. package/src/tsconfig.json +10 -4
  227. package/src/type.ts +51 -2
  228. package/src/unify.ts +311 -16
  229. package/src/utility.ts +139 -1
  230. package/src/val/AggFuncVal.ts +319 -0
  231. package/src/val/ArithFuncVal.ts +108 -0
  232. package/src/val/BagVal.ts +101 -4
  233. package/src/val/CloseFuncVal.ts +9 -1
  234. package/src/val/ConjunctVal.ts +20 -0
  235. package/src/val/ConstraintVal.ts +1699 -116
  236. package/src/val/CopyFuncVal.ts +7 -1
  237. package/src/val/Decimal.ts +15 -0
  238. package/src/val/DeprecateFuncVal.ts +84 -0
  239. package/src/val/DisjunctVal.ts +139 -28
  240. package/src/val/EachFuncVal.ts +133 -0
  241. package/src/val/ExpectVal.ts +43 -6
  242. package/src/val/FeatureVal.ts +1 -1
  243. package/src/val/FilterFuncVal.ts +154 -0
  244. package/src/val/FuncBaseVal.ts +200 -3
  245. package/src/val/HideFuncVal.ts +0 -2
  246. package/src/val/IdFuncVal.ts +91 -0
  247. package/src/val/JunctionVal.ts +7 -1
  248. package/src/val/KeyFuncVal.ts +39 -35
  249. package/src/val/ListVal.ts +125 -18
  250. package/src/val/LowerFuncVal.ts +0 -1
  251. package/src/val/MapVal.ts +110 -8
  252. package/src/val/MatchFuncVal.ts +176 -0
  253. package/src/val/MoveFuncVal.ts +0 -2
  254. package/src/val/NilVal.ts +25 -0
  255. package/src/val/OpBaseVal.ts +26 -3
  256. package/src/val/OpenFuncVal.ts +4 -2
  257. package/src/val/PackFuncVal.ts +175 -0
  258. package/src/val/PathFuncVal.ts +0 -1
  259. package/src/val/PlaceVal.ts +193 -0
  260. package/src/val/PlusOpVal.ts +11 -2
  261. package/src/val/PrefFuncVal.ts +0 -1
  262. package/src/val/PrefVal.ts +79 -36
  263. package/src/val/RefVal.ts +163 -30
  264. package/src/val/ReferFuncVal.ts +387 -0
  265. package/src/val/ScalarKindVal.ts +0 -13
  266. package/src/val/TopVal.ts +0 -1
  267. package/src/val/TypeFuncVal.ts +0 -2
  268. package/src/val/UpperFuncVal.ts +0 -1
  269. package/src/val/Val.ts +213 -3
  270. package/src/val/VarVal.ts +0 -1
  271. package/src/val/arith.ts +316 -0
  272. package/src/vet.ts +992 -0
  273. 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.spanValue = spanValue;
10
+ exports.patch = patch;
11
+ // OVERLAY PATCH (G7 phase 5,
12
+ // docs/capability-review/g7-machine-access.md): change a document by
13
+ // APPENDING to an overlay, not by rewriting the file.
14
+ //
15
+ // This is the stage that needs no rewriter. An overlay entry is just
16
+ // another conjunct, and unification is order-independent, so appending
17
+ // `services: auth: owner: "identity-2"` to a second file and
18
+ // evaluating both is exactly the same value as writing it into the
19
+ // first — with no parsing of the target, no comment or layout damage,
20
+ // and nothing to preserve. The spec pins that equivalence rather than
21
+ // asserting it.
22
+ //
23
+ // What an overlay CANNOT do is change a PINNED value: the lattice
24
+ // refuses 5 against 3, and the report says so with the pinning site,
25
+ // which `why` then locates. That left the loop "set → conflict → why →
26
+ // edit the pinning site" with its last step manual — and since the
27
+ // commonest vet failure of all is "the data pins the wrong value",
28
+ // `set` was unable to repair the very case it existed for.
29
+ //
30
+ // IN-PLACE REPLACE (`--in-place`) closes that. The G7 design deferred
31
+ // it behind two prerequisites: an evaluated-path → contributing-span
32
+ // map, and a comment-and-layout-preserving CST. The first now exists —
33
+ // `why` is that map, and sites carry `len` and `src` since a site was
34
+ // given an extent. The second turns out NOT to be needed for the case
35
+ // that matters, and the reason is worth stating: a CST is what you need
36
+ // to RE-SERIALISE a document, and a targeted span splice serialises
37
+ // nothing. It replaces `len` code units at one offset and leaves every
38
+ // other byte — every comment, every blank line, every alignment space —
39
+ // exactly as the author left it, because it never looks at them.
40
+ //
41
+ // What makes the splice safe rather than merely plausible is that the
42
+ // site carries `src`, the text it claims to cover. The span is VERIFIED
43
+ // against it before a byte is written, so the corrupting arithmetic
44
+ // this repository has already shipped once — `port: 0x1F` reporting
45
+ // canon `"31"` at column 7, and `(col, canon.length)` writing
46
+ // `port: 5x1F` — cannot be reached: `0x1F` is four code units and says
47
+ // so, and if the text at the span is anything else the edit is refused
48
+ // rather than guessed.
49
+ //
50
+ // Replace is never WORSE than append. Where the value is not a single
51
+ // editable literal in this overlay — a spread template governing other
52
+ // keys, a reference whose site is the `$` and not the target, two
53
+ // statements pinning the same path, a literal in an included file — the
54
+ // splice is refused and the assignment is APPENDED exactly as it would
55
+ // have been without the flag, plus one `warning` finding naming the
56
+ // case and the site it came from. Warnings never move a verdict, so
57
+ // `--in-place` cannot turn a run that would have succeeded into one
58
+ // that fails; it can only rewrite where rewriting is safe, and explain
59
+ // itself where it is not.
60
+ //
61
+ // The verdict is G2's, unchanged: `vet(entry, overlay)` already asks
62
+ // exactly the right question — does this document hold against that
63
+ // truth, and if not, where — so `set` adds a writer, not a report.
64
+ const vet_1 = require("./vet");
65
+ const query_1 = require("./query");
66
+ const aontu_1 = require("./aontu");
67
+ // An assignment is `<path>=<value>`, split at the FIRST `=`: a path
68
+ // segment is a name, and the value is arbitrary Aontu source, which
69
+ // may itself contain `=` (`a: min(1)` does not, but a string can).
70
+ function parseAssignment(text) {
71
+ const eq = text.indexOf('=');
72
+ if (eq < 1) {
73
+ return undefined;
74
+ }
75
+ const path = text.slice(0, eq).trim();
76
+ const value = text.slice(eq + 1).trim();
77
+ if ('' === value || 0 === (0, query_1.pathParts)(path).length) {
78
+ return undefined;
79
+ }
80
+ return { path, value };
81
+ }
82
+ // The path-flattened conjunct one assignment becomes:
83
+ // `$.a.b = 1` is `"a": "b": 1`. Keys are QUOTED — a segment may be a
84
+ // word the grammar spells otherwise (`if`), a number, or a name with
85
+ // a space in it, and quoting one key is the same value as writing it
86
+ // bare.
87
+ function overlayLine(path, value) {
88
+ return (0, query_1.pathParts)(path).map((p) => JSON.stringify(p)).join(': ') +
89
+ ': ' + value;
90
+ }
91
+ // The character offset of a 1-based (row, col) in `src`, or -1 when the
92
+ // text has no such position. Columns are UTF-16 code units, which is
93
+ // what a site carries and what a JavaScript string index already is —
94
+ // so this is the inverse of the site arithmetic, not a reinterpretation
95
+ // of it (go/patch.go converts to a byte offset, because Go strings are
96
+ // bytes; both address the same character).
97
+ function offsetAt(src, row, col) {
98
+ if (row < 1 || col < 1) {
99
+ return -1;
100
+ }
101
+ let off = 0;
102
+ for (let r = 1; r < row; r++) {
103
+ const nl = src.indexOf('\n', off);
104
+ if (nl < 0) {
105
+ return -1;
106
+ }
107
+ off = nl + 1;
108
+ }
109
+ const at = off + (col - 1);
110
+ return at <= src.length ? at : -1;
111
+ }
112
+ // The text a site covers, or undefined when the site does not describe
113
+ // a position in this text at all.
114
+ function spanAt(src, site) {
115
+ const off = offsetAt(src, site.row, site.col);
116
+ return off < 0 ? undefined : src.slice(off, off + site.len);
117
+ }
118
+ // DOES THE TEXT AT THIS SITE SAY WHAT THE SITE CLAIMS IT SAYS?
119
+ //
120
+ // The last check before a splice, and the one that makes the write
121
+ // PROVABLE rather than argued. Exported so it can be exercised with a
122
+ // site the engine would never produce — an out-of-range position, a
123
+ // span over different text — which is the only way to test a guard whose
124
+ // whole purpose is to catch a state the rest of the code says cannot
125
+ // happen. (go/patch.go has the twin, tested the same way.)
126
+ function spanHolds(src, site, expect) {
127
+ // THE SITE'S OWN LENGTH IS PART OF ITS CLAIM, and is checked before
128
+ // the text is. A site whose `len` disagrees with the text it says it
129
+ // covers CONTRADICTS ITSELF, which is exactly the state this guard
130
+ // exists to catch — and a zero-length span would otherwise compare
131
+ // equal against nothing and then splice nothing, INSERTING the new
132
+ // value rather than replacing anything.
133
+ //
134
+ // Both ports compare in UTF-16 code units, which is what a site's
135
+ // `len` counts. That is free here and is not in Go, where a string is
136
+ // bytes (go/patch.go converts).
137
+ if ('' === expect || site.len !== expect.length) {
138
+ return false;
139
+ }
140
+ return spanAt(src, site) === expect;
141
+ }
142
+ // WHY IS THE VALUE AT THIS PATH WHAT IT IS, and is exactly one of the
143
+ // answers a literal this overlay can edit in place?
144
+ //
145
+ // The four refusals below are not defensive padding; each is a real
146
+ // document shape that the probe corpus produced, and each would corrupt
147
+ // something different if the splice ran anyway:
148
+ //
149
+ // - a SPREAD contribution's site is inside the template, which
150
+ // governs every other key too, so rewriting it there changes keys
151
+ // the author did not name;
152
+ // - a REFERENCE's site is the `$` that starts the path and has length
153
+ // 1, so splicing over it writes the new value INTO the path
154
+ // expression (`$.base` becomes `5.base`) — and the value the author
155
+ // wants changed lives at the target anyway;
156
+ // - TWO literals at one path (a duplicate key, two files merged) give
157
+ // no single place to edit, and picking either silently is picking
158
+ // for the author;
159
+ // - a literal in an INCLUDED file is editable, but not by
160
+ // `--overlay <this file>`: the write would land in a document the
161
+ // caller did not name.
162
+ //
163
+ // A PREFERENCE is not refused here for the same reason it is not
164
+ // replaced: appending already overrides a default correctly, so the
165
+ // caller loses nothing by falling through to it.
166
+ function editableLiteral(overlaySrc, path, overlayPath) {
167
+ // THE AUTHORITY IS THE OVERLAY TEXT ALONE, WITH INCLUDES DENIED.
168
+ //
169
+ // The splice happens in the text this function was handed, so what it
170
+ // has to establish is that the contribution is IN that text — and the
171
+ // site's `file` cannot establish it. Two ways it fails: a caller of
172
+ // the library API need not pass `overlayPath`, leaving nothing to
173
+ // compare against; and the Go port names the ENTRY document for an
174
+ // included value anyway (issue #66), so the comparison is the overlay
175
+ // against itself. Either way an included literal's (row, col, len,
176
+ // src) can COINCIDE with different text at the same coordinates here
177
+ // — an include holding `a: 42` at 1:4 and an overlay holding `x: 42`
178
+ // at 1:4 — and the span verification cannot tell them apart, because
179
+ // the text really does match. The splice then rewrites `x` while
180
+ // reporting a replacement of `$.a`, in both ports.
181
+ //
182
+ // Denying includes removes the ambiguity at its source rather than
183
+ // detecting it: what resolves is what this text says by itself. An
184
+ // overlay that loads other documents therefore cannot be edited in
185
+ // place at all — the conservative answer, and the assignment still
186
+ // appends. It costs nothing in the shape `set` is for, an overlay it
187
+ // owns and appends to, and it does not depend on file attribution, so
188
+ // both ports agree without waiting on #66.
189
+ const alone = (0, query_1.why)(overlaySrc, path, {
190
+ trust: { include: 'none' },
191
+ ...(null == overlayPath ? {} : { path: overlayPath }),
192
+ });
193
+ if (true !== alone.ok || null == alone.record) {
194
+ // Nothing here BY ITSELF. Two very different reasons, and they earn
195
+ // different answers: the path may simply not be in this overlay, in
196
+ // which case appending is the whole of the answer and nothing has
197
+ // gone wrong — or it may be here only because something was loaded,
198
+ // which is the case above and has to say so.
199
+ const withLoads = (0, query_1.why)(overlaySrc, path, null == overlayPath ? undefined : { path: overlayPath });
200
+ if (true !== withLoads.ok || null == withLoads.record) {
201
+ return { site: undefined, finding: undefined };
202
+ }
203
+ return {
204
+ site: undefined,
205
+ finding: notEditable('patch_not_editable', path, 'this path resolves only once the overlay loads another ' +
206
+ 'document, so no literal here can be shown to be the one to ' +
207
+ 'edit; run set with the document that writes it as the overlay', withLoads.record.conjuncts),
208
+ };
209
+ }
210
+ const record = alone.record;
211
+ // No `?? []`: WhyRecord.conjuncts is a non-optional array and the
212
+ // record's own presence was just established, so a fallback here
213
+ // would claim a possibility the type does not have — and the
214
+ // coverage gate says so, an arm nothing can take.
215
+ const conjuncts = record.conjuncts;
216
+ // A VALUE REACHED THROUGH A REFERENCE IS NOT THIS PATH'S TO EDIT.
217
+ // Provenance travels through clones now, so `n: $.base` against
218
+ // `base: 7` reports the literal `7` -- correctly, and at the site
219
+ // where it was written, which is `base`'s line and not `n`'s. A
220
+ // splice there would rewrite the REFERENT: every other reader of
221
+ // `$.base` changes with it, and the path the caller named does not
222
+ // move at all. The reference is what stands here, so the reference
223
+ // is what has to be edited, wherever it points.
224
+ const refs = conjuncts.filter((c) => 'ref' === c.role);
225
+ if (0 < refs.length) {
226
+ return {
227
+ site: undefined,
228
+ finding: notEditable('patch_not_editable', path, 'the value here is reached through a reference (ref), so the ' +
229
+ 'literal below belongs to the path it points at; edit where it ' +
230
+ 'comes from', refs),
231
+ };
232
+ }
233
+ const literals = conjuncts.filter((c) => 'literal' === c.role);
234
+ if (1 < literals.length) {
235
+ return {
236
+ site: undefined,
237
+ finding: notEditable('patch_ambiguous', path, 'two or more statements pin this path, so there is no single ' +
238
+ 'place to edit; the sites below are all of them', literals),
239
+ };
240
+ }
241
+ // Only indirect contributions. A pref is the benign case — append
242
+ // overrides a default — so it earns no finding; the others do.
243
+ if (0 === literals.length) {
244
+ const indirect = conjuncts.filter((c) => 'pref' !== c.role);
245
+ if (0 === indirect.length) {
246
+ return { site: undefined, finding: undefined };
247
+ }
248
+ return {
249
+ site: undefined,
250
+ finding: notEditable('patch_not_editable', path, 'the value here is not written as a literal (' +
251
+ indirect.map((c) => c.role).join(', ') +
252
+ '), so there is no literal to rewrite; edit where it comes from', indirect),
253
+ };
254
+ }
255
+ const one = literals[0];
256
+ // THE SPAN MUST CHECK OUT, and this is one condition rather than two.
257
+ //
258
+ // A first draft tested "no extent" separately from "the text
259
+ // disagrees", which read as two guards and was really one question
260
+ // asked twice — with the second half unreachable, since denying
261
+ // includes means the site comes from evaluating THIS TEXT with
262
+ // nothing loaded, so its coordinates describe this text by
263
+ // construction. Merged, the question is reachable through the case
264
+ // that has no extent at all (`x: hello |> upper` synthesises a call
265
+ // the parser never sited), so the check is exercised rather than
266
+ // argued for — and `spanHolds` is exported and tested against sites
267
+ // the engine would never produce, which is the only way to reach the
268
+ // half that remains theoretical.
269
+ //
270
+ // It is load-bearing either way: a contribution with no `src` would
271
+ // otherwise splice ZERO characters, INSERTING the new value into the
272
+ // middle of a line instead of replacing anything.
273
+ if (!spanHolds(overlaySrc, one.site, one.src)) {
274
+ return {
275
+ site: undefined,
276
+ finding: notEditable('patch_span_mismatch', path, 'the overlay does not hold ' + JSON.stringify(one.src) + ' at ' +
277
+ one.site.row + ':' + one.site.col + ' (len ' + one.site.len +
278
+ '), so the span cannot be verified before writing', [one]),
279
+ };
280
+ }
281
+ // DOES THE SPAN MEAN THE WHOLE CONTRIBUTION?
282
+ //
283
+ // This is the check that `role === 'literal'` looks like it makes and
284
+ // does not. A site names the TOKEN it points at, so a COMPOUND value
285
+ // reports its OPENING token while its canon is the whole thing:
286
+ // `min(1)` is a literal-role contribution whose src is `min`, `1+2`
287
+ // reports `1`, `$.k+1` reports `$`, `{b:1}` reports `{` and `[1,2]`
288
+ // reports `[`. Splicing over any of those writes the new value INTO
289
+ // the expression — `a: 5(1)`, `a: 5+2`, `a: 5.k+1` — which is the
290
+ // same class of corruption as the canon-length arithmetic, reached by
291
+ // a different route.
292
+ //
293
+ // Rather than enumerate the shapes (a list is a thing to be
294
+ // incomplete about), ASK THE ENGINE: parse `src` on its own and
295
+ // require the value it means to be the value the contribution
296
+ // contributed. That is exactly the property a splice needs — this
297
+ // text, alone, is this value — and it is decided by the same unifier
298
+ // that produced the contribution, so it cannot drift from it.
299
+ //
300
+ // It also gets the interesting case right without special-casing it:
301
+ // `0x1F` canons to `31`, which is not its own spelling, but IS the
302
+ // contribution's canon, so a hex literal is editable while `min` is
303
+ // not.
304
+ const span = spanValue(one.src);
305
+ if (null == span || span.canon !== one.canon) {
306
+ return {
307
+ site: undefined,
308
+ finding: notEditable('patch_not_editable', path, 'the site names ' + JSON.stringify(one.src) + ', which is the ' +
309
+ 'opening token of ' + one.canon + ' rather than the whole of ' +
310
+ 'it; rewriting that span would edit the expression, not the ' +
311
+ 'value', [one]),
312
+ };
313
+ }
314
+ // AN ABSTRACT CONTRIBUTION IS NOT A PIN. `a: integer` and
315
+ // `a: above(0)` state a constraint, and appending already narrows
316
+ // them — that is the one case the status report notes `set` could
317
+ // always repair. Replacing them would silently DISCARD a constraint
318
+ // the author wrote, to no benefit, so this falls through to append.
319
+ if (true !== span.concrete) {
320
+ return {
321
+ site: undefined,
322
+ finding: notEditable('patch_not_editable', path, one.canon + ' is a constraint here, not a pinned value; ' +
323
+ 'appending narrows it without discarding what it says', [one]),
324
+ };
325
+ }
326
+ return {
327
+ site: {
328
+ col: one.site.col,
329
+ file: one.site.file,
330
+ from: one.src,
331
+ path,
332
+ row: one.site.row,
333
+ to: '',
334
+ },
335
+ finding: undefined,
336
+ };
337
+ }
338
+ // What does this source text mean ON ITS OWN, and is it a value rather
339
+ // than a constraint? Undefined when it does not stand alone at all
340
+ // (`$` from a path, an unbalanced `{`).
341
+ //
342
+ // The wrapper key is arbitrary and the document it makes is thrown
343
+ // away; what is wanted is the unifier's own reading of the fragment.
344
+ function spanValue(src) {
345
+ // NO COLLECTING CONTEXT: `unify` THROWS on a source it cannot read,
346
+ // so a ctx.err check here is a branch nothing can reach — the catch
347
+ // below is the only path a bad fragment takes. (A first draft had
348
+ // both, and the coverage gate called the pair what it was.) What the
349
+ // nil test still earns is the fragment that PARSES and means nothing:
350
+ // `$` is a path with no target, and answers a nil rather than
351
+ // throwing.
352
+ let canon;
353
+ try {
354
+ const root = new aontu_1.Aontu().unify('v: ' + src);
355
+ const node = root?.peg?.['v'];
356
+ if (null == node || true === node.isNil) {
357
+ return undefined;
358
+ }
359
+ canon = node.canon;
360
+ }
361
+ catch (e) {
362
+ return undefined;
363
+ }
364
+ // Generability is the concreteness test, and it is the engine's own:
365
+ // a kind, a constraint and an unresolved disjunction all refuse to
366
+ // generate, which is precisely the line this needs drawn.
367
+ try {
368
+ new aontu_1.Aontu().generate('v: ' + src);
369
+ }
370
+ catch (e) {
371
+ return { canon, concrete: false };
372
+ }
373
+ return { canon, concrete: true };
374
+ }
375
+ // A refusal to replace, as a WARNING: the assignment still appends, so
376
+ // nothing about the run got worse and the verdict must not move
377
+ // (ts/src/vet.ts, "warnings never touch the verdict"). What the finding
378
+ // adds is the reason, which is the whole value of asking for --in-place
379
+ // over plain set.
380
+ function notEditable(code, path, why, from) {
381
+ return {
382
+ code,
383
+ class: 'patch_span_mismatch' === code ? 'internal' : '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,"file":"patch.js","sourceRoot":"","sources":["../src/patch.ts"],"names":[],"mappings":";AAAA,oDAAoD;;;;;;;;;AAEpD,6BAA6B;AAC7B,qEAAqE;AACrE,sDAAsD;AACtD,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,6DAA6D;AAC7D,mEAAmE;AACnE,sEAAsE;AACtE,sEAAsE;AACtE,gBAAgB;AAChB,EAAE;AACF,kEAAkE;AAClE,qEAAqE;AACrE,uEAAuE;AACvE,mEAAmE;AACnE,mEAAmE;AACnE,2DAA2D;AAC3D,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,uEAAuE;AACvE,sEAAsE;AACtE,sEAAsE;AACtE,wEAAwE;AACxE,oEAAoE;AACpE,uEAAuE;AACvE,wEAAwE;AACxE,iEAAiE;AACjE,EAAE;AACF,sEAAsE;AACtE,wEAAwE;AACxE,oEAAoE;AACpE,oEAAoE;AACpE,8DAA8D;AAC9D,uEAAuE;AACvE,uEAAuE;AACvE,uBAAuB;AACvB,EAAE;AACF,sEAAsE;AACtE,uEAAuE;AACvE,kEAAkE;AAClE,wEAAwE;AACxE,uEAAuE;AACvE,oEAAoE;AACpE,oEAAoE;AACpE,oEAAoE;AACpE,uEAAuE;AACvE,0BAA0B;AAC1B,EAAE;AACF,qEAAqE;AACrE,oEAAoE;AACpE,mEAAmE;AAEnE,+BAA2B;AAG3B,mCAAwC;AAExC,mCAA+B;AAkD/B,oEAAoE;AACpE,oEAAoE;AACpE,mEAAmE;AACnE,yBACE,IAAY;IACZ,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAC5B,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;QACX,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,C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AAU,CACjB,GAAW,EAAE,KAAgD;IAE7D,IAAI,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,40 @@
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
+ };
14
+ export type WhyRecord = {
15
+ conjuncts: WhyConjunct[];
16
+ path: string;
17
+ value: string;
18
+ };
19
+ export declare const FROM_SPREAD = "_fromSpread";
20
+ export declare const WRITTEN = "_written";
21
+ export declare const INNER_OF = "_innerOf";
22
+ export declare function markSpread(v: any, seen?: Set<any>): void;
23
+ type Contribution = WhyConjunct & {
24
+ id: number;
25
+ };
26
+ type PathRecord = {
27
+ conjuncts: Contribution[];
28
+ made: Set<number>;
29
+ seen: Set<number>;
30
+ };
31
+ export declare class Provenance {
32
+ paths: Map<string, PathRecord>;
33
+ containers: Map<number, any>;
34
+ writtenFrom(v: any): void;
35
+ record(path: string[], a: any, b: any, out: any): void;
36
+ private contribute;
37
+ stands(path: string[], v: any): void;
38
+ at(path: string[]): WhyConjunct[];
39
+ }
40
+ export {};