@nudojs/core 1.0.1 → 1.1.1

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.
@@ -0,0 +1,550 @@
1
+ import { I as InterfaceSource, a as InterfaceTierOpts, p as parseSource, C as CheckIssue } from './check-report-AtnAfY9U.js';
2
+ export { L as LeakBudget, b as LoadDepsFingerprint, d as defaultLeakBudget, e as exceedsBudget, c as extractAllLoadSpecs, l as leakIfNeeded, f as loadModuleDepsFingerprint, m as maybeLeak, n as normPath, r as resetLeakCounter, g as resolveDepPath, s as sidecarSpecsOf, t as termDepth, h as termNodes } from './check-report-AtnAfY9U.js';
3
+ import { A as Abs, T as Term, c as AstEnv } from './hof-types-tAeoYvzY.js';
4
+ export { $ as $tryDigestSoft, d as $tryMarkSoft, e as $tryReleaseSoft, E as ERROR_FAMILY, M as MayThrowEffect, f as errorTypeAbs, g as filterDeclaredThrows, h as filterGateThrows, i as filterIgnoredThrows, j as flushMayThrowEffects, k as formatThrowsAbs, l as getMayThrowCollector, m as isThrowsIgnored, n as mayThrowEffectsToAbs, o as orphanMayThrowEffects, p as popMayThrowFrame, q as pushMayThrowFrame, r as recordMayThrow, s as runWithMayThrowSession, t as setMayThrowCollector, u as throwAbsToKinds, v as throwsKindCovered } from './hof-types-tAeoYvzY.js';
5
+ import { File, Node } from '@babel/types';
6
+
7
+ /**
8
+ * 调用预算 + 截断观测(B 路径共享面)。
9
+ * 抽象求值对递归做展开而非不动点:参数类型每层变形(fac(n-1))时
10
+ * cycle key 不重复,必须靠深度/总调用数封顶。超限结果 conf=opaque。
11
+ */
12
+
13
+ declare const MAX_CALL_DEPTH = 64;
14
+ /** 与 B 命名调用(calls.ts MAX_B_TOTAL_CALLS)同阀:病态展开下 200k 级不可接受 */
15
+ declare const MAX_TOTAL_CALLS = 20000;
16
+ /** A2:预算/截断快照(check --json / health 上屏) */
17
+ type AbsBudgetStats = {
18
+ calls: number;
19
+ maxCalls: number;
20
+ forks: number;
21
+ maxForks: number;
22
+ callTruncated: boolean;
23
+ forkTruncated: boolean;
24
+ /** 任一预算截断 → true(结果可能已 widen 成 unknown) */
25
+ truncated: boolean;
26
+ };
27
+ declare function getAbsCallBudgetStats(): AbsBudgetStats;
28
+ /** 宿主入口(runTranspiled / callTranspiledExportFull / check)前重置 */
29
+ declare function resetAbsCallBudget(): void;
30
+ declare function stableCallId(obj: object): string;
31
+ /**
32
+ * 截断结果:分析无信息,conf=opaque。
33
+ * shape=unknown 表示「没有可计算面」,但 **不是** nudo:unknown-inference
34
+ * (那是真推导失败)——截断走 nudo:recursion-truncated / fork-truncated。
35
+ */
36
+ declare function truncatedAbs(): Abs;
37
+ /** 调用指纹:命名函数用 name+arg shapes;一等函数用对象身份。
38
+ * 实参可能是裸 JS 值(B run 里模块函数作实参)——不得裸读 shape。 */
39
+ declare function callBudgetKey(kind: string, id: string, args: unknown[]): string;
40
+ /** 记录被截断的递归(service 可映射为 nudo:recursion-truncated)。
41
+ * 返回先前 collector,便于嵌套 save/restore。 */
42
+ declare function setAbsTruncationCollector(collector: ((fnLabel: string) => void) | null): ((fnLabel: string) => void) | null;
43
+ declare function noteAbsTruncation(label: string): void;
44
+ /** 进入调用:超限/cycle 则不执行 body,返回 opaque */
45
+ declare function enterCall(key: string, label: string): boolean;
46
+ declare function exitCall(): void;
47
+ /**
48
+ * 为什么是「总次数」而不是「深度」:
49
+ * - 415d3ea 惰性化后单次 fork(集合 overlay / Φ 臂包裹)零堆分配、~0.15µs,
50
+ * **单次已经便宜**;病态输入(lodash `_baseFlatten`:递归×循环)炸的是
51
+ * **fork 次数本身**,不是嵌套深度——浅而宽的展开同样失控。
52
+ * - 与 MAX_TOTAL_CALLS 的分工:调用预算管「函数进入次数」(命名调用 /
53
+ * 递归展开),管不到 if/?:/&& 语义在 $fork 上的分支展开;两者独立计数、
54
+ * 独立封顶,任一超限都 fail-closed 成 unknown。
55
+ *
56
+ * 默认 5000:monorepo 语料(含 core/service 全量测试与 check 金门)下
57
+ * 正常函数远低于此;病态递归×循环能在秒级内兜住(对照 MAX_B_TOTAL_CALLS
58
+ * 从 200k 收到 20k 的先例)。可经 setBForkBudgetLimit / env NUDO_MAX_FORKS /
59
+ * package.json#nudo.analysis.maxForks 调节。
60
+ */
61
+ declare const MAX_B_TOTAL_FORKS = 5000;
62
+ /**
63
+ * 专用标签:fork 截断不是「某个递归函数被截断」,不能复用函数名 label
64
+ * (否则 check 会误报 nudo:recursion-truncated)。service/check 按此标签
65
+ * 映射为 `nudo:fork-truncated`(warning)。
66
+ */
67
+ declare const FORK_TRUNCATION_LABEL = "#fork-budget";
68
+ /**
69
+ * 宿主副作用未执行标签前缀:网络/定时器全局(fetch/setTimeout…)在分析期
70
+ * 不真实执行(Abs 实参喂原生实现会真发请求/真排定时器,且可能崩进程),
71
+ * fail-closed 为 unknown#opaque。专用前缀让 check 映射为
72
+ * `nudo:host-effect-blocked`,不复用「某函数被截断」文案。
73
+ */
74
+ declare const HOST_EFFECT_LABEL_PREFIX = "#host-effect:";
75
+ /** 宿主副作用未执行观测(service/LSP 映射 nudo:host-effect-blocked;与调用截断同 collector 管道) */
76
+ declare function noteHostEffectBlocked(name: string): void;
77
+ /** fork 超限观测(service/LSP 映射 nudo:fork-truncated;与调用截断同 collector 管道) */
78
+ declare function noteBForkTruncation(): void;
79
+ /**
80
+ * 调整 fork 总次数上限。约定:n ≥ 1 的有限整数才生效(向下取整);
81
+ * 非法值(0 / 负数 / NaN / Infinity / 非数)回默认 MAX_B_TOTAL_FORKS。
82
+ * 返回实际生效值。core 无 IO——env/package.json 由 service 读取后 set 进来。
83
+ */
84
+ declare function setBForkBudgetLimit(n: number): number;
85
+ declare function getBForkBudgetLimit(): number;
86
+ declare function getBForkCount(): number;
87
+ /** 宿主入口前重置 fork 计数(与 resetAbsCallBudget / resetBCallBudget 同口径) */
88
+ declare function resetBForkBudget(): void;
89
+ /** $fork 入口:超限放弃该分支(调用方返回 unknown = 最保守,安全)。 */
90
+ declare function bumpBForkBudget(): boolean;
91
+
92
+ declare function hashSource(s: string): string;
93
+ declare function resetHashSourceCache(): void;
94
+
95
+ /**
96
+ * Analysis-stable source key: strip trailing noise that cannot affect types.
97
+ * Keeps every line that may carry @nudo directives.
98
+ *
99
+ * Fast path: already-stable sources return the same string identity (O(1)
100
+ * compare in B-path / analysis caches when the caller reuses the buffer).
101
+ */
102
+ declare function stableAnalyzeKeySource(source: string): string;
103
+
104
+ /**
105
+ * per-function fingerprint: after-edit only dirty fn + callers miss L0.
106
+ *
107
+ * - own: function declaration slice (incl. leading comments / refine)
108
+ * - deps: transitively referenced sibling own hashes + non-fn top-level context
109
+ * - context change (import/class/const...) -> all miss (conservative)
110
+ *
111
+ * Multi-declarator `const a = fn, b = fn` yields one fingerprint per function;
112
+ * each own-slice is its own declarator (first also carries statement leading comments).
113
+ */
114
+
115
+ type FnFp = {
116
+ own: string;
117
+ deps: string;
118
+ nRefs: number;
119
+ };
120
+ declare function resetFnFpCache(): void;
121
+ type FnDeclInfo = {
122
+ name: string;
123
+ body: Node;
124
+ /** Function/arrow node (own-slice end; also scanned for sibling refs incl. defaults). */
125
+ fnNode: Node;
126
+ /** Declarator start when from a VariableDeclaration; else undefined. */
127
+ declaratorStart?: number;
128
+ /** First leading-comment start on this declarator (multi-decl refine/@nudo). */
129
+ declaratorLeadStart?: number;
130
+ };
131
+ /** Every top-level function binding in a declaration node (not just the first). */
132
+ declare function getFnNameAndBodies(decl: Node): FnDeclInfo[];
133
+ /** source -> (fnName -> own/deps); LRU */
134
+ declare function fnFingerprints(source: string, file: File): Map<string, FnFp>;
135
+ /** L0 source part: per-fn fingerprint when AST available; else full-file hash */
136
+ declare function generalizeSourceKeyPart(source: string, fnName: string, file?: File): string;
137
+ /**
138
+ * 无 refine、无模块语法、无兄弟调用、无任何调用表达式 → scanLiteralCalls 可整段跳过。
139
+ * 必须保守:`const x = f(-1)` / `if (f(-1))` / `require("x")` 都含 CallExpression,
140
+ * 只认顶层 ExpressionStatement 会漏报约束违规。
141
+ */
142
+ declare function canSkipLiteralCallScan(source: string, file: File): boolean;
143
+
144
+ /**
145
+ * 推导图(derivation trace)side-channel(design-refine-derivation §14.3#6 / §11 Phase 2)。
146
+ *
147
+ * 不叫 provenance:`setProvenanceTracking` 已被 evaluator 的 TypeValue origin map
148
+ * 占用。机制对齐 `setCallCollector` / `setAbsTruncationCollector` 先例——
149
+ * **不进 Abs payload**;B-path 核心 ops(`add` / `joinAbs`)上打点,
150
+ * 执行面天然覆盖。
151
+ *
152
+ * 设计原则:emit 打印的是推导图的投影,**禁止**事后从最终 Abs 反编译 shift 链。
153
+ * 本模块在 ops 层打点:数值常量加法 → shift 边;joinAbs → join 边。
154
+ * 根约束(手写契约参数)由宿主在入口 Abs 上打 root 标签。
155
+ */
156
+
157
+ /** 推导节点:边带调用位点 / +k / join;root 携带可打印的约束源表达式 */
158
+ type DerivationNode = {
159
+ id: number;
160
+ kind: "root" | "shift" | "join" | "opaque";
161
+ /** root:宿主给的可读约束表达式(`positive` / `number().gt(0)`) */
162
+ expr?: string;
163
+ /** root:跨文件 import 源(相对 specifier,相对 root 侧车目录) */
164
+ importFrom?: string;
165
+ /** root:import 绑定名(与 expr 一致时省略) */
166
+ importName?: string;
167
+ /** shift:数值偏移 */
168
+ offset?: number;
169
+ /** 父节点 id(root 无父) */
170
+ parents: number[];
171
+ };
172
+ /** 调用位点上的实参推导(供 emit 投影组合式) */
173
+ type ArgDerivation = {
174
+ node: DerivationNode;
175
+ /** 从该节点回溯到 root 的路径(含自身,root 在末尾) */
176
+ chain: DerivationNode[];
177
+ };
178
+ type Collector = (node: DerivationNode) => void;
179
+ /** 设置观察者(null 清除);缓冲照常累积 */
180
+ declare function setDerivationCollector(fn: Collector | null): void;
181
+ declare function hasDerivationSession(): boolean;
182
+ /** 开始一次推导会话(root 驱动下行求值前调用);与 end/abort 成对 */
183
+ declare function beginDerivationSession(): void;
184
+ /** 结束会话并取走全部节点(顺序 = 创建序) */
185
+ declare function endDerivationSession(): DerivationNode[];
186
+ /** 丢弃当前会话(求值失败时) */
187
+ declare function abortDerivationSession(): void;
188
+ /**
189
+ * 在入口 Abs 上打 root 标签:该值来自手写契约参数约束。
190
+ * expr 是可打印源(`positive`);importFrom 指向共享模板侧车。
191
+ */
192
+ declare function tagDerivationRoot(abs: Abs, meta: {
193
+ expr: string;
194
+ importFrom?: string;
195
+ importName?: string;
196
+ }): DerivationNode;
197
+ /** 读取 Abs 上的推导节点(无标签 → undefined) */
198
+ declare function getDerivation(abs: Abs): DerivationNode | undefined;
199
+ /** 手动把推导挂到结果 Abs(宿主在 analyzeFn 返回值上补标签时用) */
200
+ declare function setDerivation(abs: Abs, node: DerivationNode): void;
201
+ /** 从节点回溯 root 路径(含自身;环/缺失截断) */
202
+ declare function derivationChain(node: DerivationNode): DerivationNode[];
203
+ /**
204
+ * ops 层打点:`a + k`(k 为有限数值字面量)且 a 带推导 → 结果挂 shift 节点。
205
+ * 由 arithmetic.add 在返回前调用;无会话/无父标签时 no-op。
206
+ */
207
+ declare function noteDerivationAdd(a: Abs, b: Abs, result: Abs): void;
208
+ /**
209
+ * ops 层打点:join 结果挂 join 节点(任一侧有推导即可)。
210
+ * 工件聚合路径会经 join;check 分轨不依赖 join 节点。
211
+ */
212
+ declare function noteDerivationJoin(inputs: Abs[], result: Abs): void;
213
+ /**
214
+ * 把推导链投影为组合式(§2.4:写组合式,不展开)。
215
+ *
216
+ * 返回 prelude(`const x = positive.shift(1);`)+ expr(`x` / `x.shift(2)`)
217
+ * + 需要的 import。无 root 锚或链上出现 join/opaque → undefined(调用方
218
+ * 退回展开式投影或 not-projectable)。
219
+ */
220
+ declare function projectDerivationDsl(node: DerivationNode, localName: string): {
221
+ prelude: string[];
222
+ expr: string;
223
+ imports: Array<{
224
+ name: string;
225
+ from: string;
226
+ }>;
227
+ } | undefined;
228
+ /** 项结构调试用(测试断言) */
229
+ declare function termKey(t: Term | undefined): string;
230
+
231
+ /**
232
+ * Abs inlay hint:把无损约束内联到源码位置。
233
+ * 不是 TS 风格 type annotation 复读,而是 term/pred/conf 的计算结果。
234
+ *
235
+ * 参数侧只展示显式 `@nudo:contract` 契约(entryReqs)——
236
+ * 不从函数体 `if` 反推前置条件(那是控制流,不是对外契约)。
237
+ *
238
+ * A7(design-refine-derivation §8):default 走 symbolic + entryReqs;
239
+ * 与 CodeLens `● interface` 同源——interfaceTierOf 标注来源;
240
+ * implicit 导出的返回 inlay 标明 `derived`(展示档,非义务契约)。
241
+ */
242
+
243
+ type AbsInlay = {
244
+ /** 1-based 行号 */
245
+ line: number;
246
+ /** 0-based 列(label 插入点) */
247
+ character: number;
248
+ label: string;
249
+ kind: "type" | "parameter";
250
+ /** interface 档来源(与 CodeLens `● interface` 同源);非导出缺省 */
251
+ interfaceSource?: InterfaceSource;
252
+ /** true = 隐式推导展示(非义务契约),label 已带 `· derived` */
253
+ derived?: boolean;
254
+ };
255
+ type CollectAbsInlaysOpts = InterfaceTierOpts & {
256
+ loadModule?: (spec: string, fromFile: string) => string | undefined;
257
+ fromFile?: string;
258
+ };
259
+ /**
260
+ * 收集源码中函数签名的 Abs inlay:
261
+ * - 参数后:仅 `@nudo:contract` / 侧车显式契约(entryReqs)
262
+ * - `{` 前:返回计算形(`x | x * 2`),无 term 时退回 shape
263
+ * - interface 档:导出函数带 `interfaceSource`;implicit 返回标 `derived`
264
+ */
265
+ declare function collectAbsInlays(source: string, opts?: CollectAbsInlaysOpts): AbsInlay[];
266
+
267
+ /**
268
+ * Template string 拼接(代数侧)。
269
+ * 表示:prim(string) + refinement.meta.templateParts = Abs[]
270
+ * 与 core 的 createTemplate 对齐,使 `"x" + string + "!"` 得到 template refined。
271
+ *
272
+ * 本模块是模板语义的唯一真理源:前缀/后缀/固定文本/长度/匹配/名称渲染/
273
+ * 相邻合并/谓词判定等纯计算以「中性 part 视图」(TemplatePartView)暴露;
274
+ * Abs 方法表(methods.ts)只做薄适配。
275
+ */
276
+
277
+ type TemplateMeta = {
278
+ templateParts: Abs[];
279
+ };
280
+ /** 单个 part 的分类:固定文本,或抽象 part(携带展示文本) */
281
+ type TemplatePartDesc = {
282
+ fixed: string;
283
+ } | {
284
+ render: string;
285
+ };
286
+ /** 带原始 part 回引的视图:既喂语义计算,也用于重建合并结果 */
287
+ type TemplatePartView<P = unknown> = {
288
+ /** 固定文本;undefined = 抽象 part */
289
+ fixed: string | undefined;
290
+ /** 抽象 part 的展示文本(渲染 `${...}` 名时使用) */
291
+ render: string;
292
+ part: P;
293
+ };
294
+ declare function viewTemplateParts<P>(parts: P[], describe: (p: P) => TemplatePartDesc): TemplatePartView<P>[];
295
+ /** 前导固定文本(遇到首个抽象 part 停止) */
296
+ declare function knownPrefixOfViews(views: TemplatePartView[]): string;
297
+ /** 尾部固定文本(从末尾遇到首个抽象 part 停止) */
298
+ declare function knownSuffixOfViews(views: TemplatePartView[]): string;
299
+ /** 全部固定文本按序拼接(跨抽象 part) */
300
+ declare function allFixedTextOfViews(views: TemplatePartView[]): string;
301
+ /** 全部 part 均为固定文本时的精确总长;含抽象 part 则 undefined */
302
+ declare function fixedLengthOfViews(views: TemplatePartView[]): number | undefined;
303
+ /** 渲染 `` `lit${render}` `` 形态的模板名 */
304
+ declare function formatTemplateNameViews(views: TemplatePartView[]): string;
305
+ /** 相邻固定文本合并;rebuildFixed 以合并文本重建视图(含原始 part) */
306
+ declare function mergeAdjacentFixedViews<P>(views: TemplatePartView<P>[], rebuildFixed: (text: string) => TemplatePartView<P>): TemplatePartView<P>[];
307
+ /** 具体字符串是否匹配模板(Refinement.check 的判定语义) */
308
+ declare function templateMatchesValue(value: string, views: TemplatePartView[]): boolean;
309
+ /** 三值判定;Abs 方法表把 "unknown" 适配为 boolPrim */
310
+ type TemplatePredicateDecision = boolean | "unknown";
311
+ declare function decideStartsWith(prefix: string, search: string): TemplatePredicateDecision;
312
+ declare function decideEndsWith(suffix: string, search: string): TemplatePredicateDecision;
313
+ declare function decideIncludes(fixedText: string, search: string): TemplatePredicateDecision;
314
+ declare function absTemplateViews(parts: Abs[]): TemplatePartView<Abs>[];
315
+ /** 从 Abs 提取 template parts(已是 template 则展开,否则 [self]) */
316
+ declare function templatePartsOf(a: Abs): Abs[];
317
+ /**
318
+ * 构造 template Abs。
319
+ * - 全字面量 → exact lit
320
+ * - 单 string prim → prim
321
+ * - 否则 prim(string) + pred(name=template, meta.templateParts)
322
+ */
323
+ declare function createTemplateAbs(parts: Abs[]): Abs;
324
+ declare function isTemplateLike(a: Abs): boolean;
325
+ /** 字符串拼接:字面量折叠 + template parts 合并 */
326
+ declare function concatString(a: Abs, b: Abs): Abs;
327
+
328
+ /**
329
+ * 指称:Abs → 运行时谓词(设计 §2.7)。
330
+ * - 无 pred:按 shape 检查(typeof / 结构)
331
+ * - 有 pred:在 `term ↦ v` 下检查可判定的数值比较
332
+ * - sum:任一成员
333
+ */
334
+
335
+ /** Abs 上的运行时守卫表达式(JS boolean 布尔串) */
336
+ declare function denoteGuard(a: Abs, v: string): string;
337
+
338
+ /**
339
+ * 语言覆盖:class / new / instanceof / this / async await。
340
+ * brand 表示名义类;eff("promise") 表示异步效应。
341
+ *
342
+ * 方法体:ClassDef.methods 存 AST body,调用时在 this=receiver 下求值。
343
+ */
344
+
345
+ type MethodDef = {
346
+ name: string;
347
+ params: string[];
348
+ body: Node;
349
+ kind?: string;
350
+ async?: boolean;
351
+ };
352
+ type ClassDef = {
353
+ name: string;
354
+ instanceShape: Abs;
355
+ ctorParams: string[];
356
+ methods: Map<string, MethodDef>;
357
+ superClass?: string;
358
+ };
359
+ declare function defineClass(env: AstEnv, def: ClassDef): void;
360
+ declare function getClass(env: AstEnv, name: string): ClassDef | undefined;
361
+ /** 沿继承链找类 */
362
+ declare function getClassChain(env: AstEnv, name: string): ClassDef[];
363
+ /** new C(...) → brand 实例;并跑 constructor 以写入字段 */
364
+ declare function instantiateClass(env: AstEnv, className: string, args: Abs[], evalBody?: (fn: {
365
+ params: string[];
366
+ body: Node;
367
+ }, args: Abs[], thisVal: Abs, env: AstEnv) => Abs): Abs;
368
+ /** 读取当前 this 所属类的父类名 */
369
+ declare function superNameOf(env: AstEnv, className: string): string | undefined;
370
+ /** 品牌沿注册/内建层级上溯的父名序列(含自身;限深防环) */
371
+ declare function classChainNames(name: string, env?: AstEnv): string[];
372
+ declare function instanceOf(left: Abs, rightClassName: string, env?: AstEnv): Abs;
373
+ declare function projectBrand(self: Abs, key: string): Abs;
374
+ /** 在 brand 上查找方法定义(含继承) */
375
+ declare function lookupMethod(env: AstEnv, receiver: Abs, methodName: string): MethodDef | undefined;
376
+ /** 沿继承链查找方法,返回定义与所在类名 */
377
+ declare function lookupMethodWithOwner(env: AstEnv, receiver: Abs, methodName: string): {
378
+ def: MethodDef;
379
+ owner: string;
380
+ } | undefined;
381
+ /** super.method():从父类开始找(跳过当前类) */
382
+ declare function lookupSuperMethod(env: AstEnv, receiver: Abs, fromClass: string, methodName: string): {
383
+ def: MethodDef;
384
+ owner: string;
385
+ } | undefined;
386
+ declare function wrapPromise(inner: Abs): Abs;
387
+ declare function awaitAbs(v: Abs): Abs;
388
+ declare function coerceAsyncReturn(value: Abs): Abs;
389
+ /** 从 ClassMethod 列表构造 methods map + instance shape */
390
+ declare function classFromMethods(name: string, methods: MethodDef[], superClass?: string, superShape?: Abs): ClassDef;
391
+
392
+ /**
393
+ * 顶层函数清单:function 声明 + const 箭头/函数表达式(含 export 包装)
394
+ * + **导出 class 的实例方法**(C4.2,命名 `Class.method`)。
395
+ * P1:本地 `class Foo` 经 `export { Foo }` / `export { Foo as default }` /
396
+ * `export default Foo` 导出时同样登记实例方法。
397
+ *
398
+ * 从 scan.ts 拆出:纯 AST 清单,无调用图状态。
399
+ */
400
+
401
+ declare function listTopFunctions(source: string, file?: ReturnType<typeof parseSource>): string[];
402
+
403
+ /**
404
+ * T10b:跨文件注入调用点域证据 ⊄ 手写契约(nudo:interface-domain-exceeds)。
405
+ *
406
+ * 从 scan.ts 拆出的内聚段:只消费 externalCallRecords 注入的跨文件记录,
407
+ * 不做同文件调用点扫描(那是 scanLiteralCalls 的职责)。
408
+ */
409
+
410
+ /**
411
+ * 注入记录的最小结构面。Abs 为唯一真理源。
412
+ */
413
+ type InjectedDomainRecord = {
414
+ /** 无损参数 Abs(必填;domain 证据唯一来源) */
415
+ argAbs?: Abs[];
416
+ resultAbs?: Abs;
417
+ throwsAbs?: Abs;
418
+ };
419
+ type InjectedDomainEvidenceOpts = {
420
+ /** 被调函数形参名(位置序);契约按参数名对齐证据位 */
421
+ paramNames: string[];
422
+ loadModule?: (spec: string, fromFile: string) => string | undefined;
423
+ fromFile?: string;
424
+ /** 侧车 ambient 绑定开关(host 配置下传;默认 true) */
425
+ autoBind?: boolean;
426
+ /** 项目根:树外侧车不 ambient 绑定 */
427
+ projectDir?: string;
428
+ /** 报告定位:被调函数声明处。注入证据的 loc 在使用现场文件,不属于本文件 */
429
+ loc?: {
430
+ line: number;
431
+ column: number;
432
+ };
433
+ };
434
+ /**
435
+ * 跨文件注入的调用点域证据 vs 手写契约(设计稿 §3.3/§6 对账矩阵第一行)。
436
+ *
437
+ * 来源分流铁律:写在被分析文件里的调用点违例(含 scanLiteralCalls 的
438
+ * checkExternalCall 跨文件被调路径)维持 `nudo:constraint-violated` 原码
439
+ * 原语义——本函数**只**消费经 externalCallRecords 注入的跨文件记录(analyzer
440
+ * 消费区已做归属守卫),该路径此前不查契约,是纯增量。
441
+ *
442
+ * 证据门槛(§6):
443
+ * - 只有 plain literal 实参构成证据:union/unknown/primitive/refined 形态
444
+ * 无法归因到确定值,不参与。Abs 路径直接读 `litValue` + conf
445
+ * ∈ {exact, path}。
446
+ * - null 证据预过滤(T4 caveat:lit(null) 编码 prim undefined + eq(self,
447
+ * null),对任何约束恒不满足,不过滤必 FP);undefined/bigint/symbol
448
+ * 不在字面量证据域内,一并跳过;
449
+ * - resultType=never ∧ throws=never 是求值中断泄漏(analyzer 注入消费区
450
+ * 同款过滤;有 resultAbs/throwsAbs 时同口径)。CallRecord 上没有截断字段
451
+ * (查证于 evaluator.ts CallRecord 声明)——递归截断走
452
+ * nudo:recursion-truncated 诊断通道且只 widen 结果,不产生新字面量证据;
453
+ * - fn/shape/array 参数位 Phase 1 不执法(§3.3 HOF 豁免:
454
+ * literalMeetsConstraint 对这些形态恒 false,直接查必 FP)。
455
+ *
456
+ * 每函数每参数位最多一条 issue(多证据并列在 actual 里,去重)。
457
+ */
458
+ declare function checkInjectedDomainEvidence(fnName: string, source: string, records: InjectedDomainRecord[], opts: InjectedDomainEvidenceOpts): CheckIssue[];
459
+
460
+ /**
461
+ * 成员缺失诊断(B 路径 $invoke / 成员访问共用)。
462
+ * 无 $call / transpile 依赖,避免与 calls 循环。
463
+ *
464
+ * any vs unknown(design-cli-semantics §2–3):
465
+ * - any:无约束接收者 → 成员访问记入 throws 域(may-throw TypeError),结果保持 any
466
+ * - unknown:推导失败 → nudo:unknown-recv(引擎债),不得替代 L2 throws 建模
467
+ * - null/undefined:成员访问 hard-throw TypeError(§3.3 / design.md §4.5)
468
+ */
469
+
470
+ type BMemberDiag = {
471
+ kind: "method" | "property";
472
+ name: string;
473
+ /** 接收者 prim 类型名,或 "unknown" / "object"(C0.5 闭 shape 缺槽) */
474
+ receiver: string;
475
+ line?: number;
476
+ column?: number;
477
+ /** 调用点来源(provenance):实参字面量 loc 优先,否则最近 $callNamed loc */
478
+ origin?: {
479
+ line: number;
480
+ column: number;
481
+ };
482
+ /** 覆盖默认 no-method 码;C0.5 用 nudo:missing-slot */
483
+ code?: string;
484
+ };
485
+ /** 给实参 Abs 打 provenance(调用点参数字面量) */
486
+ declare function tagAbsOrigin(a: Abs, loc: {
487
+ line: number;
488
+ column: number;
489
+ }): void;
490
+ declare function getAbsOrigin(a: Abs | undefined): {
491
+ line: number;
492
+ column: number;
493
+ } | undefined;
494
+ /** 返回先前 collector,便于嵌套调用 save/restore */
495
+ declare function setMemberDiagCollector(c: ((d: BMemberDiag) => void) | null): ((d: BMemberDiag) => void) | null;
496
+ declare function pushCallLoc(loc: {
497
+ line: number;
498
+ column: number;
499
+ }): void;
500
+ declare function popCallLoc(): void;
501
+ declare function recordMemberDiag(d: BMemberDiag): void;
502
+ /**
503
+ * prim 接收者上的未知成员 → 诊断。
504
+ * 返回 true 表示确定缺失(number 上任意方法;string 上表外方法)。
505
+ */
506
+ declare function notePrimMemberMissing(recv: Abs | undefined, name: string, kind: "method" | "property", loc?: [number, number]): boolean;
507
+ /** null / undefined(term lit null/undefined;shape unknown 兜底) */
508
+ declare function isNullishAbs(a: Abs | undefined): boolean;
509
+ /**
510
+ * any(无约束)接收者上的成员访问 → may-throw TypeError。
511
+ * 结果保持 any(JS 语义:属性值仍无约束),不是 unknown(分析失败)。
512
+ */
513
+ declare function noteAnyMemberMayThrow(recv: Abs | undefined, name: string, kind: "method" | "property", loc?: [number, number]): boolean;
514
+ /**
515
+ * nullish 接收者上的成员访问 → hard may-throw TypeError(设计 §3.3)。
516
+ * 返回 true 表示已记入 throws 域;调用方可据此抛 NudoThrow。
517
+ */
518
+ declare function noteNullishMemberThrows(recv: Abs | undefined, name: string, kind: "method" | "property", loc?: [number, number]): boolean;
519
+ /**
520
+ * unknown 接收者上的成员访问 → unknown-recv(引擎债;与 any 的 throws 域分离)。
521
+ */
522
+ declare function noteUnknownMemberMissing(recv: Abs | undefined, name: string, kind: "method" | "property", loc?: [number, number]): boolean;
523
+ /** any 接收者成员访问的默认结果:any(不是 unknown) */
524
+ declare function anyMemberResult(): Abs;
525
+ /** 方法分派失败时的统一记账(prim / any / nullish / unknown) */
526
+ declare function noteMemberDispatchMiss(recv: Abs | undefined, name: string, kind: "method" | "property", loc?: [number, number]): void;
527
+ /** Object.prototype 上的恒有成员(`in` 判定 / 不可调用判定共用) */
528
+ declare const OBJECT_PROTO_NAMES: Set<string>;
529
+ /**
530
+ * 结构上确定不可调用的成员调用(B-path $invoke):
531
+ * - null-proto 对象:无 Object.prototype 可回退,缺失自有槽即确定缺失
532
+ * - 闭 exact 对象:slots 是精确键集,非 OP 名缺失即确定缺失(OP 名经
533
+ * Object.prototype 存在,未建模 → 保守不抛)
534
+ * - 槽存在但值是字面量(prim/null/undefined 非函数)→ 确定抛
535
+ * 保守边界:open 对象(spread/assign 产物)、非 exact conf(create(proto)
536
+ * 的 path 产物)、OP 原型名一律不判抛——避免假抛 false positive。
537
+ */
538
+ declare function definitelyUncallableMember(recv: Abs, name: string): boolean;
539
+ /** host(service analysisConfig)在 B-path 前设置;默认 false */
540
+ declare function setEvalMissingSlotEnabled(enabled: boolean): void;
541
+ declare function isEvalMissingSlotEnabled(): boolean;
542
+ /** per-analysis 作用域:body 内 flag 隔离,结束后自动恢复外层值 */
543
+ declare function runWithEvalMissingSlot<T>(enabled: boolean, body: () => T): T;
544
+ /**
545
+ * 闭对象 shape 上缺失字段且**求值真实走到**该读取 → `nudo:missing-slot`。
546
+ * 仅展示/草稿提示;不参与 handwritten check 义务(C0:禁止 body AST 预扫)。
547
+ */
548
+ declare function noteObjSlotMissing(recv: Abs | undefined, name: string, loc?: [number, number]): boolean;
549
+
550
+ export { type AbsBudgetStats, type AbsInlay, type ArgDerivation, type BMemberDiag, type ClassDef, type CollectAbsInlaysOpts, type DerivationNode, FORK_TRUNCATION_LABEL, type FnFp, HOST_EFFECT_LABEL_PREFIX, type InjectedDomainEvidenceOpts, type InjectedDomainRecord, MAX_B_TOTAL_FORKS, MAX_CALL_DEPTH, MAX_TOTAL_CALLS, type MethodDef, OBJECT_PROTO_NAMES, type TemplateMeta, type TemplatePartDesc, type TemplatePartView, type TemplatePredicateDecision, abortDerivationSession, absTemplateViews, allFixedTextOfViews, anyMemberResult, awaitAbs, beginDerivationSession, bumpBForkBudget, callBudgetKey, canSkipLiteralCallScan, checkInjectedDomainEvidence, classChainNames, classFromMethods, coerceAsyncReturn, collectAbsInlays, concatString, createTemplateAbs, decideEndsWith, decideIncludes, decideStartsWith, defineClass, definitelyUncallableMember, denoteGuard, derivationChain, endDerivationSession, enterCall, exitCall, fixedLengthOfViews, fnFingerprints, formatTemplateNameViews, generalizeSourceKeyPart, getAbsCallBudgetStats, getAbsOrigin, getBForkBudgetLimit, getBForkCount, getClass, getClassChain, getDerivation, getFnNameAndBodies, hasDerivationSession, hashSource, instanceOf, instantiateClass, isEvalMissingSlotEnabled, isNullishAbs, isTemplateLike, knownPrefixOfViews, knownSuffixOfViews, listTopFunctions, lookupMethod, lookupMethodWithOwner, lookupSuperMethod, mergeAdjacentFixedViews, noteAbsTruncation, noteAnyMemberMayThrow, noteBForkTruncation, noteDerivationAdd, noteDerivationJoin, noteHostEffectBlocked, noteMemberDispatchMiss, noteNullishMemberThrows, noteObjSlotMissing, notePrimMemberMissing, noteUnknownMemberMissing, popCallLoc, projectBrand, projectDerivationDsl, pushCallLoc, recordMemberDiag, resetAbsCallBudget, resetBForkBudget, resetFnFpCache, resetHashSourceCache, runWithEvalMissingSlot, setAbsTruncationCollector, setBForkBudgetLimit, setDerivation, setDerivationCollector, setEvalMissingSlotEnabled, setMemberDiagCollector, stableAnalyzeKeySource, stableCallId, superNameOf, tagAbsOrigin, tagDerivationRoot, templateMatchesValue, templatePartsOf, termKey, truncatedAbs, viewTemplateParts, wrapPromise };