aontu 0.52.1 → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (272) hide show
  1. package/README.md +88 -0
  2. package/bin/aontu-mcp.js +4 -0
  3. package/dist/agentsmd.d.ts +16 -0
  4. package/dist/agentsmd.js +107 -0
  5. package/dist/agentsmd.js.map +1 -0
  6. package/dist/aontu.d.ts +14 -3
  7. package/dist/aontu.js +96 -4
  8. package/dist/aontu.js.map +1 -1
  9. package/dist/cli.d.ts +44 -1
  10. package/dist/cli.js +2401 -44
  11. package/dist/cli.js.map +1 -1
  12. package/dist/ctx.d.ts +13 -0
  13. package/dist/ctx.js +43 -0
  14. package/dist/ctx.js.map +1 -1
  15. package/dist/diff.d.ts +22 -0
  16. package/dist/diff.js +141 -0
  17. package/dist/diff.js.map +1 -0
  18. package/dist/err.d.ts +3 -1
  19. package/dist/err.js +38 -7
  20. package/dist/err.js.map +1 -1
  21. package/dist/graph.d.ts +16 -0
  22. package/dist/graph.js +73 -0
  23. package/dist/graph.js.map +1 -0
  24. package/dist/hcanon.d.ts +3 -0
  25. package/dist/hcanon.js +146 -0
  26. package/dist/hcanon.js.map +1 -0
  27. package/dist/hints.js +167 -4
  28. package/dist/hints.js.map +1 -1
  29. package/dist/jsonschema.d.ts +20 -0
  30. package/dist/jsonschema.js +391 -0
  31. package/dist/jsonschema.js.map +1 -0
  32. package/dist/lang.js +512 -69
  33. package/dist/lang.js.map +1 -1
  34. package/dist/lsp.d.ts +9 -2
  35. package/dist/lsp.js +262 -47
  36. package/dist/lsp.js.map +1 -1
  37. package/dist/mcp-server.d.ts +20 -0
  38. package/dist/mcp-server.js +147 -0
  39. package/dist/mcp-server.js.map +1 -0
  40. package/dist/mcp.d.ts +42 -0
  41. package/dist/mcp.js +814 -0
  42. package/dist/mcp.js.map +1 -0
  43. package/dist/mod-tool.d.ts +58 -0
  44. package/dist/mod-tool.js +498 -0
  45. package/dist/mod-tool.js.map +1 -0
  46. package/dist/mod.d.ts +31 -0
  47. package/dist/mod.js +250 -0
  48. package/dist/mod.js.map +1 -0
  49. package/dist/patch.d.ts +44 -0
  50. package/dist/patch.js +506 -0
  51. package/dist/patch.js.map +1 -0
  52. package/dist/provenance.d.ts +40 -0
  53. package/dist/provenance.js +335 -0
  54. package/dist/provenance.js.map +1 -0
  55. package/dist/query.d.ts +27 -0
  56. package/dist/query.js +294 -0
  57. package/dist/query.js.map +1 -0
  58. package/dist/reach.d.ts +14 -0
  59. package/dist/reach.js +140 -0
  60. package/dist/reach.js.map +1 -0
  61. package/dist/relation.d.ts +19 -0
  62. package/dist/relation.js +305 -0
  63. package/dist/relation.js.map +1 -0
  64. package/dist/report-sarif.d.ts +14 -0
  65. package/dist/report-sarif.js +102 -0
  66. package/dist/report-sarif.js.map +1 -0
  67. package/dist/site.d.ts +4 -0
  68. package/dist/site.js +31 -0
  69. package/dist/site.js.map +1 -1
  70. package/dist/std.d.ts +1 -0
  71. package/dist/std.js +73 -0
  72. package/dist/std.js.map +1 -0
  73. package/dist/subsume.d.ts +39 -0
  74. package/dist/subsume.js +526 -0
  75. package/dist/subsume.js.map +1 -0
  76. package/dist/trim.d.ts +19 -0
  77. package/dist/trim.js +155 -0
  78. package/dist/trim.js.map +1 -0
  79. package/dist/tsconfig.tsbuildinfo +1 -1
  80. package/dist/type.d.ts +17 -1
  81. package/dist/type.js.map +1 -1
  82. package/dist/unify.d.ts +2 -1
  83. package/dist/unify.js +253 -36
  84. package/dist/unify.js.map +1 -1
  85. package/dist/utility.d.ts +9 -1
  86. package/dist/utility.js +122 -1
  87. package/dist/utility.js.map +1 -1
  88. package/dist/val/AggFuncVal.d.ts +33 -0
  89. package/dist/val/AggFuncVal.js +202 -0
  90. package/dist/val/AggFuncVal.js.map +1 -0
  91. package/dist/val/ArithFuncVal.d.ts +31 -0
  92. package/dist/val/ArithFuncVal.js +62 -0
  93. package/dist/val/ArithFuncVal.js.map +1 -0
  94. package/dist/val/BagVal.d.ts +5 -0
  95. package/dist/val/BagVal.js +96 -5
  96. package/dist/val/BagVal.js.map +1 -1
  97. package/dist/val/CloseFuncVal.js +9 -1
  98. package/dist/val/CloseFuncVal.js.map +1 -1
  99. package/dist/val/ConjunctVal.d.ts +1 -1
  100. package/dist/val/ConjunctVal.js +19 -0
  101. package/dist/val/ConjunctVal.js.map +1 -1
  102. package/dist/val/ConstraintVal.d.ts +7 -1
  103. package/dist/val/ConstraintVal.js +490 -40
  104. package/dist/val/ConstraintVal.js.map +1 -1
  105. package/dist/val/CopyFuncVal.d.ts +1 -2
  106. package/dist/val/CopyFuncVal.js +7 -0
  107. package/dist/val/CopyFuncVal.js.map +1 -1
  108. package/dist/val/Decimal.d.ts +1 -0
  109. package/dist/val/Decimal.js +13 -0
  110. package/dist/val/Decimal.js.map +1 -1
  111. package/dist/val/DeprecateFuncVal.d.ts +11 -0
  112. package/dist/val/DeprecateFuncVal.js +47 -0
  113. package/dist/val/DeprecateFuncVal.js.map +1 -0
  114. package/dist/val/DisjunctVal.js +130 -21
  115. package/dist/val/DisjunctVal.js.map +1 -1
  116. package/dist/val/EachFuncVal.d.ts +15 -0
  117. package/dist/val/EachFuncVal.js +75 -0
  118. package/dist/val/EachFuncVal.js.map +1 -0
  119. package/dist/val/ExpectVal.js +27 -4
  120. package/dist/val/ExpectVal.js.map +1 -1
  121. package/dist/val/FeatureVal.js +1 -1
  122. package/dist/val/FeatureVal.js.map +1 -1
  123. package/dist/val/FilterFuncVal.d.ts +15 -0
  124. package/dist/val/FilterFuncVal.js +91 -0
  125. package/dist/val/FilterFuncVal.js.map +1 -0
  126. package/dist/val/FuncBaseVal.d.ts +6 -1
  127. package/dist/val/FuncBaseVal.js +171 -1
  128. package/dist/val/FuncBaseVal.js.map +1 -1
  129. package/dist/val/HideFuncVal.js.map +1 -1
  130. package/dist/val/IdFuncVal.d.ts +13 -0
  131. package/dist/val/IdFuncVal.js +54 -0
  132. package/dist/val/IdFuncVal.js.map +1 -0
  133. package/dist/val/JunctionVal.js +7 -1
  134. package/dist/val/JunctionVal.js.map +1 -1
  135. package/dist/val/KeyFuncVal.d.ts +1 -1
  136. package/dist/val/KeyFuncVal.js +38 -30
  137. package/dist/val/KeyFuncVal.js.map +1 -1
  138. package/dist/val/ListVal.js +101 -14
  139. package/dist/val/ListVal.js.map +1 -1
  140. package/dist/val/LowerFuncVal.js.map +1 -1
  141. package/dist/val/MapVal.js +93 -8
  142. package/dist/val/MapVal.js.map +1 -1
  143. package/dist/val/MatchFuncVal.d.ts +15 -0
  144. package/dist/val/MatchFuncVal.js +107 -0
  145. package/dist/val/MatchFuncVal.js.map +1 -0
  146. package/dist/val/MoveFuncVal.js.map +1 -1
  147. package/dist/val/NilVal.js +24 -0
  148. package/dist/val/NilVal.js.map +1 -1
  149. package/dist/val/OpBaseVal.d.ts +1 -1
  150. package/dist/val/OpBaseVal.js +19 -1
  151. package/dist/val/OpBaseVal.js.map +1 -1
  152. package/dist/val/OpenFuncVal.js +4 -1
  153. package/dist/val/OpenFuncVal.js.map +1 -1
  154. package/dist/val/PackFuncVal.d.ts +15 -0
  155. package/dist/val/PackFuncVal.js +108 -0
  156. package/dist/val/PackFuncVal.js.map +1 -0
  157. package/dist/val/PathFuncVal.js.map +1 -1
  158. package/dist/val/PlaceVal.d.ts +13 -0
  159. package/dist/val/PlaceVal.js +131 -0
  160. package/dist/val/PlaceVal.js.map +1 -0
  161. package/dist/val/PlusOpVal.js +11 -2
  162. package/dist/val/PlusOpVal.js.map +1 -1
  163. package/dist/val/PrefFuncVal.js.map +1 -1
  164. package/dist/val/PrefVal.d.ts +2 -2
  165. package/dist/val/PrefVal.js +78 -23
  166. package/dist/val/PrefVal.js.map +1 -1
  167. package/dist/val/RefVal.d.ts +1 -1
  168. package/dist/val/RefVal.js +89 -7
  169. package/dist/val/RefVal.js.map +1 -1
  170. package/dist/val/ReferFuncVal.d.ts +36 -0
  171. package/dist/val/ReferFuncVal.js +303 -0
  172. package/dist/val/ReferFuncVal.js.map +1 -0
  173. package/dist/val/ScalarKindVal.d.ts +1 -2
  174. package/dist/val/ScalarKindVal.js +0 -11
  175. package/dist/val/ScalarKindVal.js.map +1 -1
  176. package/dist/val/TopVal.js.map +1 -1
  177. package/dist/val/TypeFuncVal.js.map +1 -1
  178. package/dist/val/UpperFuncVal.js.map +1 -1
  179. package/dist/val/Val.d.ts +8 -1
  180. package/dist/val/Val.js +150 -1
  181. package/dist/val/Val.js.map +1 -1
  182. package/dist/val/VarVal.js.map +1 -1
  183. package/dist/val/arith.d.ts +6 -0
  184. package/dist/val/arith.js +170 -0
  185. package/dist/val/arith.js.map +1 -0
  186. package/dist/vet.d.ts +45 -0
  187. package/dist/vet.js +776 -0
  188. package/dist/vet.js.map +1 -0
  189. package/dist/walk.d.ts +2 -0
  190. package/dist/walk.js +91 -0
  191. package/dist/walk.js.map +1 -0
  192. package/grammar/aontu.gbnf +130 -0
  193. package/grammar/aontu.lark +113 -0
  194. package/package.json +21 -6
  195. package/skill/SKILL.md +37 -0
  196. package/skill/error-codes.md +62 -0
  197. package/skill/examples.md +99 -0
  198. package/skill/grammar-card.md +57 -0
  199. package/src/agentsmd.ts +135 -0
  200. package/src/aontu.ts +135 -4
  201. package/src/cli.ts +2858 -71
  202. package/src/ctx.ts +73 -1
  203. package/src/diff.ts +196 -0
  204. package/src/err.ts +42 -7
  205. package/src/graph.ts +135 -0
  206. package/src/hcanon.ts +169 -0
  207. package/src/hints.ts +208 -4
  208. package/src/jsonschema.ts +511 -0
  209. package/src/lang.ts +570 -70
  210. package/src/lsp.ts +281 -48
  211. package/src/mcp-server.ts +187 -0
  212. package/src/mcp.ts +993 -0
  213. package/src/mod-tool.ts +679 -0
  214. package/src/mod.ts +344 -0
  215. package/src/patch.ts +624 -0
  216. package/src/provenance.ts +430 -0
  217. package/src/query.ts +379 -0
  218. package/src/reach.ts +184 -0
  219. package/src/relation.ts +395 -0
  220. package/src/report-sarif.ts +137 -0
  221. package/src/site.ts +36 -1
  222. package/src/std.ts +73 -0
  223. package/src/subsume.ts +690 -0
  224. package/src/trim.ts +195 -0
  225. package/src/tsconfig.json +10 -4
  226. package/src/type.ts +51 -2
  227. package/src/unify.ts +274 -36
  228. package/src/utility.ts +139 -1
  229. package/src/val/AggFuncVal.ts +319 -0
  230. package/src/val/ArithFuncVal.ts +108 -0
  231. package/src/val/BagVal.ts +101 -4
  232. package/src/val/CloseFuncVal.ts +9 -1
  233. package/src/val/ConjunctVal.ts +20 -0
  234. package/src/val/ConstraintVal.ts +542 -43
  235. package/src/val/CopyFuncVal.ts +7 -1
  236. package/src/val/Decimal.ts +15 -0
  237. package/src/val/DeprecateFuncVal.ts +84 -0
  238. package/src/val/DisjunctVal.ts +139 -28
  239. package/src/val/EachFuncVal.ts +133 -0
  240. package/src/val/ExpectVal.ts +28 -6
  241. package/src/val/FeatureVal.ts +1 -1
  242. package/src/val/FilterFuncVal.ts +154 -0
  243. package/src/val/FuncBaseVal.ts +192 -1
  244. package/src/val/HideFuncVal.ts +0 -2
  245. package/src/val/IdFuncVal.ts +91 -0
  246. package/src/val/JunctionVal.ts +7 -1
  247. package/src/val/KeyFuncVal.ts +39 -35
  248. package/src/val/ListVal.ts +108 -15
  249. package/src/val/LowerFuncVal.ts +0 -1
  250. package/src/val/MapVal.ts +99 -8
  251. package/src/val/MatchFuncVal.ts +176 -0
  252. package/src/val/MoveFuncVal.ts +0 -2
  253. package/src/val/NilVal.ts +25 -0
  254. package/src/val/OpBaseVal.ts +20 -1
  255. package/src/val/OpenFuncVal.ts +4 -2
  256. package/src/val/PackFuncVal.ts +175 -0
  257. package/src/val/PathFuncVal.ts +0 -1
  258. package/src/val/PlaceVal.ts +193 -0
  259. package/src/val/PlusOpVal.ts +11 -2
  260. package/src/val/PrefFuncVal.ts +0 -1
  261. package/src/val/PrefVal.ts +79 -36
  262. package/src/val/RefVal.ts +91 -8
  263. package/src/val/ReferFuncVal.ts +387 -0
  264. package/src/val/ScalarKindVal.ts +0 -13
  265. package/src/val/TopVal.ts +0 -1
  266. package/src/val/TypeFuncVal.ts +0 -2
  267. package/src/val/UpperFuncVal.ts +0 -1
  268. package/src/val/Val.ts +205 -2
  269. package/src/val/VarVal.ts +0 -1
  270. package/src/val/arith.ts +316 -0
  271. package/src/vet.ts +992 -0
  272. package/src/walk.ts +99 -0
package/src/trim.ts ADDED
@@ -0,0 +1,195 @@
1
+ /* Copyright (c) 2025 Richard Rodger, MIT License */
2
+
3
+ // The trim reporter (G3 phase 6,
4
+ // docs/capability-review/g3-subsumption-evolution.md): report REDUNDANT
5
+ // map entries — entries whose removal leaves the evaluated result
6
+ // unchanged, the spread-implied case included — as paths. Report-only,
7
+ // deliberately: canon discards comments and layout, so REWRITING the
8
+ // file needs G7's format-preserving patch surface; trim ships as a
9
+ // reporter here and becomes an editor there.
10
+ //
11
+ // The test is EVALUATE-AND-COMPARE: for each candidate entry, re-parse
12
+ // the source, delete the entry from the parsed tree, evaluate, and
13
+ // compare canons. This subsumes the design's spread case — an entry a
14
+ // spread template re-supplies evaluates to the same canon without its
15
+ // explicit spelling — and is honest about everything the fixpoint can
16
+ // see (references, templates, duplicate-key merges), where a purely
17
+ // structural test would guess. A removal that ERRORS is not redundant:
18
+ // the entry is load-bearing.
19
+ //
20
+ // Parsed trees are single-use (docs/reference-api.md), so every probe
21
+ // is its own parse: one evaluation per candidate plus one for the
22
+ // baseline. A reporter can afford that; an editor loop belongs to G7.
23
+
24
+ import { Aontu } from './aontu'
25
+ import { failureFinding } from './vet'
26
+ import type { VetFinding } from './vet'
27
+ import type { TrustOptions } from './type'
28
+
29
+
30
+ export type TrimVerdict = 'clean' | 'redundant' | 'error'
31
+
32
+ export type TrimReport = {
33
+ verdict: TrimVerdict
34
+ redundant: string[]
35
+
36
+ // WHY the run could not be made, in the same finding shape vet
37
+ // reports in (the review's finding F). An `error` verdict used to
38
+ // arrive with an empty report -- something is wrong with the
39
+ // document, and nothing about what -- which is the one answer a
40
+ // repair loop cannot act on. Present ONLY on an `error` verdict, so
41
+ // a clean report stays exactly the two fields it always was.
42
+ errors?: VetFinding[]
43
+ }
44
+
45
+ export type TrimOptions = {
46
+ // Where the document CAME FROM, so a relative `@"file"` load inside
47
+ // it resolves from its own directory (vet's schemaPath precedent).
48
+ path?: string
49
+ // The include capability this document evaluates under (G5,
50
+ // docs/trust.md). vet's precedent: the verb passes the profile the
51
+ // caller asked for, and an absent option means today's default.
52
+ trust?: TrustOptions
53
+ }
54
+
55
+
56
+ function pathText(path: string[]): string {
57
+ return '$' + (0 < path.length ? '.' + path.join('.') : '')
58
+ }
59
+
60
+
61
+ // Every (map, key) pair in a PARSED tree, parent-first. Candidates come
62
+ // from the parse rather than the evaluation: an entry the fixpoint
63
+ // erases or rewrites still has to be addressable for deletion. The
64
+ // non-Val guard is for a bag's raw peg entries, which degenerate
65
+ // parses can leave behind. Exported (with deleteAt and evalCanon) for
66
+ // the direct unit tests (ADR-002, ts/test/coverage3.test.ts): the
67
+ // defensive arms are unreachable through trimCheck, whose candidates
68
+ // come from an identical parse.
69
+ export function candidates(v: any, path: string[], out: string[][]): void {
70
+ if (null == v || true !== v.isVal) {
71
+ return
72
+ }
73
+ if (true === v.isMap && null != v.peg) {
74
+ for (const k of Object.keys(v.peg)) {
75
+ out.push([...path, k])
76
+ candidates(v.peg[k], [...path, k], out)
77
+ }
78
+ }
79
+ else if (true === v.isList && null != v.peg) {
80
+ // List ELEMENTS are not candidates: removing one shifts every
81
+ // later index, which is a different document, not the same one
82
+ // minus a redundancy. Entries of maps INSIDE lists still are.
83
+ for (const k of Object.keys(v.peg)) {
84
+ candidates(v.peg[k], [...path, k], out)
85
+ }
86
+ }
87
+ }
88
+
89
+
90
+ // Delete the entry at path from a parsed tree. False when the path
91
+ // does not address a map entry (which cannot happen for a candidate
92
+ // enumerated from an identical parse, but the walk stays honest).
93
+ export function deleteAt(root: any, path: string[]): boolean {
94
+ let node: any = root
95
+ for (const seg of path.slice(0, -1)) {
96
+ if ((true === node?.isMap || true === node?.isList) && null != node.peg) {
97
+ node = node.peg[seg]
98
+ }
99
+ else {
100
+ return false
101
+ }
102
+ }
103
+ const key = path[path.length - 1]
104
+ if (true !== node?.isMap || null == node.peg ||
105
+ !Object.prototype.hasOwnProperty.call(node.peg, key)) {
106
+ return false
107
+ }
108
+ delete node.peg[key]
109
+ // Always an array on a parsed bag (BagVal initialises it).
110
+ node.optionalKeys = node.optionalKeys.filter((k: string) => k !== key)
111
+ return true
112
+ }
113
+
114
+
115
+ // One evaluation: parse (deleting the entry at delPath, when given),
116
+ // unify under collect, and answer the canon — or undefined when the
117
+ // source does not stand up, which for the baseline is the caller's
118
+ // error verdict and for a probe means "load-bearing".
119
+ export function evalCanon(
120
+ src: string, opts: TrimOptions, delPath?: string[],
121
+ sink?: { ctx?: any, failed?: any }): string | undefined {
122
+ const aontu = new Aontu(
123
+ null == opts.trust ? undefined : { trust: opts.trust })
124
+ const ctx = aontu.ctx({ collect: true })
125
+ const parseOpts = null == opts.path ? undefined : { path: opts.path }
126
+ // WHY the run failed, for the one caller that reports it. The
127
+ // BASELINE run passes a sink and a probe does not: a probe's failure
128
+ // means "load-bearing", which is an answer rather than a fault, and
129
+ // reporting it would bury the one real finding under one entry's
130
+ // worth of noise per candidate.
131
+ const fail = (failed?: any): undefined => {
132
+ if (null != sink) {
133
+ sink.ctx = ctx
134
+ // The failing ROOT travels with the context: a nil root can
135
+ // arrive with an EMPTY error list (`&: id(root)`), and the
136
+ // finding is built from it then (use-cases/BUGS.md §43).
137
+ sink.failed = failed
138
+ }
139
+ return undefined
140
+ }
141
+ const parsed: any = aontu.parse(src, parseOpts, ctx)
142
+ if (0 < ctx.err.length || null == parsed) {
143
+ return fail()
144
+ }
145
+ if (null != delPath && !deleteAt(parsed, delPath)) {
146
+ return undefined
147
+ }
148
+ const v: any = aontu.unify(parsed, parseOpts, ctx)
149
+ if (0 < ctx.err.length || true === v?.isNil) {
150
+ return fail(v)
151
+ }
152
+ return v.canon
153
+ }
154
+
155
+
156
+ // The whole reporter: the baseline canon, then one probe per candidate
157
+ // entry, parent-first — and a child of a redundant parent is SKIPPED,
158
+ // because "remove the whole entry" already covers it and reporting
159
+ // both would tell the author to delete the same text twice.
160
+ export function trimCheck(src: string, opts?: TrimOptions): TrimReport {
161
+ const options = opts ?? {}
162
+
163
+ const sink: { ctx?: any, failed?: any } = {}
164
+ const baseline = evalCanon(src, options, undefined, sink)
165
+ if (undefined === baseline) {
166
+ return {
167
+ verdict: 'error',
168
+ redundant: [],
169
+ errors: [failureFinding(sink.ctx, options.path, sink.failed)],
170
+ }
171
+ }
172
+
173
+ const aontu = new Aontu()
174
+ const ctx = aontu.ctx({ collect: true })
175
+ const parseOpts = null == options.path ? undefined : { path: options.path }
176
+ const parsed: any = aontu.parse(src, parseOpts, ctx)
177
+ const paths: string[][] = []
178
+ candidates(parsed, [], paths)
179
+
180
+ const redundant: string[] = []
181
+ for (const path of paths) {
182
+ const parent = pathText(path.slice(0, -1))
183
+ if (redundant.some((r) => r === parent || parent.startsWith(r + '.'))) {
184
+ continue
185
+ }
186
+ if (baseline === evalCanon(src, options, path)) {
187
+ redundant.push(pathText(path))
188
+ }
189
+ }
190
+
191
+ return {
192
+ verdict: 0 === redundant.length ? 'clean' : 'redundant',
193
+ redundant,
194
+ }
195
+ }
package/src/tsconfig.json CHANGED
@@ -3,15 +3,21 @@
3
3
  "esModuleInterop": true,
4
4
  "module": "nodenext",
5
5
  "noEmitOnError": true,
6
- "outDir":"../dist",
7
- "rootDir":".",
6
+ "noFallthroughCasesInSwitch": true,
7
+ "noImplicitReturns": true,
8
+ "noUnusedLocals": true,
9
+ "noUnusedParameters": true,
10
+ "outDir": "../dist",
11
+ "rootDir": ".",
8
12
  "resolveJsonModule": true,
9
13
  "sourceMap": true,
10
14
  "strict": true,
11
15
  "target": "es2021",
12
16
  "declaration": true,
13
17
  "declarationDir": "../dist",
14
- "types": ["node"]
18
+ "types": [
19
+ "node"
20
+ ],
21
+ "composite": true
15
22
  }
16
23
  }
17
-
package/src/type.ts CHANGED
@@ -6,7 +6,6 @@ import * as Fs from 'node:fs'
6
6
 
7
7
  import { Resolver } from '@tabnas/multisource'
8
8
 
9
- import { AontuContext } from './ctx'
10
9
  import { Val, DONE, SPREAD } from './val/Val'
11
10
  import type { ValMark, ValSpec } from './val/Val'
12
11
 
@@ -15,6 +14,44 @@ type FST = typeof Fs
15
14
 
16
15
 
17
16
 
17
+ // The trust profile (G5, docs/trust.md): what an evaluation may read,
18
+ // and how much work it may do. Trust is a property of the EVALUATION,
19
+ // not the document -- a .aon file cannot request more capability -- and
20
+ // the profile adds zero language syntax.
21
+ //
22
+ // The include capability:
23
+ // 'none' @"..." is always denied
24
+ // { mem: {...} } a virtual file set only; nothing else resolves
25
+ // { root: '/dir' } real files, realpath-confined below root;
26
+ // no package resolution
27
+ // 'system' the full memory -> file -> package chain
28
+ // (today's default, and the unconfined posture)
29
+ //
30
+ // Budgets are integer counts of engine events -- never wall-clock, which
31
+ // would make identical inputs fail differently across machines (the
32
+ // exact nondeterminism docs/trust.md forbids). The defaults are the
33
+ // shared spec-visible constants pinned by test/spec/budget.tsv.
34
+ type TrustInclude =
35
+ | 'none'
36
+ | 'system'
37
+ | { mem: Record<string, string> }
38
+ | { root: string }
39
+
40
+ // Only the budgets BOTH ports can honour are profile surface: passes
41
+ // and depth. The per-pair revisit bound (999) stays a TS-internal
42
+ // constant — the Go dispatcher has no revisit counter (it is
43
+ // depth-guarded), and a knob one port cannot implement would break the
44
+ // parity contract (ADR-001) by construction.
45
+ type TrustBudget = {
46
+ passes?: number // fixpoint passes (default 9)
47
+ depth?: number // structural recursion depth (default 1000)
48
+ }
49
+
50
+ type TrustOptions = {
51
+ include?: TrustInclude
52
+ budget?: TrustBudget
53
+ }
54
+
18
55
  type AontuOptions = {
19
56
  src?: string // Source text.
20
57
  print?: number // Print debug verbosity
@@ -30,6 +67,15 @@ type AontuOptions = {
30
67
  collect?: boolean // Collect errors into an errs property, rather than throw them.
31
68
  err?: any[]
32
69
  explain?: any[]
70
+ trust?: TrustOptions // Trust profile (G5, docs/trust.md)
71
+
72
+ // The staged-flip warning window (G5 phase 6, CLI only): under the
73
+ // default 'system' capability the CLI supplies these, and the
74
+ // resolver calls trustWarn for every resolution that escapes
75
+ // trustWarnRoot or goes through package resolution — naming the flag
76
+ // a future default will require. Not a stable embedding API.
77
+ trustWarn?: (kind: 'escape' | 'pkg', path: string) => void
78
+ trustWarnRoot?: string
33
79
  }
34
80
 
35
81
 
@@ -50,7 +96,7 @@ type ValList = Val[]
50
96
  type ErrContext = {
51
97
  src?: string,
52
98
  fs?: FST
53
- } /* node:coverage ignore next 20 */
99
+ } /* node:coverage ignore next 24 */
54
100
 
55
101
  export type {
56
102
  Val,
@@ -61,6 +107,9 @@ export type {
61
107
  AontuOptions,
62
108
  ErrContext,
63
109
  FST,
110
+ TrustInclude,
111
+ TrustBudget,
112
+ TrustOptions,
64
113
  }
65
114
 
66
115
  export {