Skip to main content

@nudojs/core

The core package provides the Abs type system, operator semantics, and environment abstraction that power Nudo's abstract interpretation engine. There is a single type system — Abs: analysis, display, and projections (.d.ts / zod / guards) all consume Abs directly; there is no parallel IR.

Abs​

Abs is the type system — a computable value { shape, term?, pred?, conf }:

  • shape — the extensional carrier: what the value looks like (prim, obj, arr, …).
  • term — abstract value identity: lit (a concrete value), var (symbolic α like A1), or app (an application like (x + 2)). This is what makes constraints participate in algebra: x > 0 ⇒ x + 1 > 1.
  • pred — constraints relative to the term ((x + 2) > 3), or undefined when vacuously true.
  • conf — Confidence: "exact" | "path" | "widened" | "mock" | "partial" | "opaque".

Shape Kinds​

shape.kDescription
primPrimitive domain (number, string, boolean, bigint, symbol); a lit term makes it a concrete value
objObject with known slots — { value: Abs; optional?: boolean } per key
arrArray with one element Abs
tupleFixed length, one Abs per element
fnFunction value — param names, or paramTypes/returnType for signature-only functions
effEffect wrapper (promise / generator) around an inner Abs — rendered promise<inner>
brandNominal class instance (e.g. MemoryStore, Error)
sumUnion of member Abs
neverEmpty set (unreachable)
anyUnconstrained JS value union — default for unannotated entry params; developer refines
unknownInference failed / engine has no information — not the same as any; Nudo owns the fix

See Abs — any vs unknown.


Abs Constructors​

// primitives (domain, no term)
num(): Abs
str(): Abs
bool(): Abs

// literal values (prim shape + lit term)
numLit(value: number): Abs
strLit(value: string): Abs
boolLit(value: boolean): Abs

// objects: slots keyed by property name
obj(slots: Record<string, { value: Abs; optional?: boolean }>): Abs

// symbolic variables (parameters of an intensional signature)
anyVar(id: string, conf?): Abs
numVar(id: string, pred?, conf?): Abs

// constants
never: Abs // { shape: { k: "never" }, conf: "exact" }
// any / unknown are distinct product concepts:
// any — unconstrained (entry default when unannotated)
// unknown — inference failed (engine debt), conf typically partial/opaque
unknown: Abs // { shape: { k: "unknown" }, conf: "partial" }

// general constructor (pred=true is dropped)
abs(shape: Shape, term: Term | undefined, pred: Pred | undefined, conf: Confidence): Abs

// function values (impl: body AST, closure env, or a direct apply dispatcher)
absFunction(params: string[], impl: { body?: Node; async?: boolean; env?: AstEnv; apply?: (args: Abs[]) => Abs }): Abs

Terms and predicates are first-class too: lit(value) / v(id) build terms, eq/ne/lt/le/gt/ge, ptypeof, and/or/not build preds (pred.ts, term.ts).


Core Functions​

FunctionDescription
leqAbs(src, tgt, opts?)Assignability: can src flow into tgt? Returns { ok, reason? } — reason is the Nudo-style actual ⊭ expected evidence, not TS wording.
formatAbs(a, opts?)Human-readable one-liner: shape, = term, where pred, #conf.
formatShape(a)Shape-only rendering ({ host: "localhost", port: 8080 }, [2, 4, 6], promise<{…}>).
formatAbsMultiline(a, label?)Multi-line display (CLI inlay).
absToString(a) / shapeToString(s)Debug rendering including term=.
litValue(a)Extract the concrete literal value, if the Abs is exact.
confJoin(a, b)Join two confidences (the worse one wins).
checkSource(source, opts?)The CI gate: refinement/Pred implication over Abs — see Check.
runTranspiled / callTranspiledExportFull / analyzeFn(…)Abs-native evaluation entrypoints (evaluator).
generalizeFromAst(…)Intensional signature extraction — the intension: lines and A1 parameters.

Operator Semantics (Abs-native)​

Operators are algebraic on Abs. Arithmetic, comparison, unary, and spread live in:

WhereWhat
core/src/algebra/surface.tstypeofAbs, negAbs, notAbs, strictEqAbs (unary ops + strict equality)
core/src/algebra/arithmetic.tsBinary arithmetic (+ - * / %) and comparison, including union member-wise distribution
core/src/algebra/objects.tsObject spread (spread) and branch-merge join (joinAbs → joinObjects / joinFunctions)

The single evaluation engine is evaluator (core/algebra/exec: transpile → new Function with Abs values). eval-incapable sources fail closed to unknown / empty exports.


Template Strings​

String concatenation with at least one literal operand produces a template Abs — the known prefix/suffix is preserved as pred metadata, enabling precise startsWith / endsWith / includes.

createTemplateAbs(parts: Abs[]): Abs // e.g. [strLit("0x"), str()] — single-part or
// all-literal inputs collapse to the plain Abs
isTemplateLike(a: Abs): boolean

Numeric ranges are not a type wrapper in the algebra — a narrowed bound is a pred on the term (x >= 0 stores ge(x, lit(0))), which is what checkSource's implication gate reasons over.


Mock Helpers​

Type-safe mock builders shared by @nudo:mock expressions and env files — a MockHelper is a plain record whose value fields are Abs (the sole type system; analysis never reads a projection back). @nudojs/parser builds it from the @nudo:mock expression via parseNudoMockExpr; @nudojs/service's mockDirectivesToAbsSeeds turns it into Abs mock seeds:

type MockHelper = {
kind: "mock-helper";
returnValue?: Abs; // stub().returns(v)
resolvedValue?: Abs; // stub().resolves(v) — call returns Promise<v>
rejectedValue?: Abs; // stub().rejects(v) — call throws/rejects with v
onFirstCallValue?: Abs; // stub().onFirstCall(v)
onSecondCallValue?: Abs; // stub().onSecondCall(v)
withArgsCases?: { args: Abs[]; returnValue: Abs }[]; // stub().withArgs(...)
callsFakeImpl?: { params: string[]; body: Node; async?: boolean }; // stub().callsFake(fn) — call executes fn
};

function stub(): MockHelper;
function spy(): MockHelper;
function mock(): MockHelper;

stub, spy, and mock all return the same base helper and differ only in intent; behavior comes from the static builders attached to stub/spy — each returns a complete MockHelper (there is no instance chaining):

stub.returns(v: Abs): MockHelper
stub.resolves(v: Abs): MockHelper // call returns Promise<v>
stub.rejects(v: Abs): MockHelper // call rejects with v
stub.onFirstCall(v: Abs): MockHelper
stub.onSecondCall(v: Abs): MockHelper
stub.withArgs(...args: Abs[]): MockHelper
stub.callsFake(fn: { params: string[]; body: Node; async?: boolean }): MockHelper
spy.returns(v: Abs): MockHelper

In @nudo:mock expressions you write the sinon-style chain stub().… — the parser pattern-matches the whole chain and builds the equivalent MockHelper (the stub() call itself never runs):

/**
* @nudo:mock fetch = stub().resolves({ ok: true })
* @nudo:mock parse = stub().withArgs(string()).returns(number())
*/

withArgs matches arguments positionally (a conservative approximation of sinon's deep match) and takes precedence over the global returnValue in a longer chain; callsFake(fn) resolves to the fake function value itself so calls execute it with the real arguments — the same mechanism as an inline arrow-function mock.


Environment​

Environment manages variable bindings (name → Abs) with lexical scoping.

createEnvironment(parent?, bindings?)
  • parent — Optional parent Environment for scope chain.
  • bindings — Optional Map<string, Abs> for initial bindings (default: new Map()).

Environment Methods​

MethodDescription
lookup(name)Get the Abs bound to name; walks parent chain; returns the unknown Abs if missing.
bind(name, value)Set binding in this env; returns env for chaining.
update(name, value)Update existing binding in this env or parent; returns boolean success.
extend(bindings)Create child env with new bindings (plain Record<string, Abs>).
fork()Create an empty child env sharing this scope chain — used for branch forking.
has(name)Check if name is bound (this env or parent).
snapshot()Deep copy of env (for branch forking).
getOwnBindings()Get Record<string, Abs> for bindings in this env only.

Export inventory​

Generated by node scripts/gen-api-docs.mjs from package export surfaces (PUBLIC_API.md / src/index.ts) — do not edit this block (or regenerate via pnpm run docs:gen). Summaries quote the source JSDoc first sentence as-is — CJK text means the symbol's doc is not yet English, and — means no JSDoc at all. Each row's name carries a stable anchor #slug (the lowercased symbol name).

Product-face inventory from packages/core/PUBLIC_API.md §2, grouped by subsection: type system core (§2.1) and exec runtime (§2.2, the $op family). Remaining non-$op names re-exported from src/index.ts are folded into the collapsible list below. Host machinery lives on @nudojs/core/internal and is intentionally out of scope.

Type system core (§2.1)​

NameKindSummarySignature
absfnAbs constructors / facesabs( shape: Shape, term: Term | undefined, pred: Pred | undefined, conf: Confidence, ): Abs
AbstypeAbs = shape × term × pred × conf; LiteralValue 含 bigintAbs = { shape: Shape; term?: Term; pred?: Pred; conf: Confidence; pathNote?: string; facets?: AbsFacets; }
AbsApplyNoThrowtypeno-throw apply face: narrow signature for impls that return bare Abs; absOnly peels the abs facet off AbsApplyReturn (test/host convenience, drops throws)AbsApplyNoThrow = Abs
AbsApplyNoThrowFntypeno-throw apply face: narrow signature for impls that return bare Abs; absOnly peels the abs facet off AbsApplyReturn (test/host convenience, drops throws)AbsApplyNoThrowFn = (args: Abs[], thisVal?: Abs) => AbsApplyNoThrow
AbsApplyResulttypeevaluator execution (analyze mode); callTranspiledExportApply is the only apply-wrap of callTranspiledExportFull (throws channel, H1); construct AbsApplyResult only via makeAbsApplyResult (brand)AbsApplyResult = { abs: Abs; throws: Abs; readonly applyResult: true; }
absOnlyfnno-throw apply face: narrow signature for impls that return bare Abs; absOnly peels the abs facet off AbsApplyReturn (test/host convenience, drops throws)absOnly(r: AbsApplyReturn): AbsApplyNoThrow
absToSchemaSourceconstone-way projections—
absToTSTypeconstone-way projections—
AnalysisExplanationtypeunknown / any origin explanation (observation-only side channel — ABS-02)AnalysisExplanation = { fn?: string; reason: UnknownReason; detail: string; suggestion?: string; }
andfn@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)and(...preds: Pred[]): Pred
andCfn@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)andC( ...cs: (NudoConstraint | ConstraintBuilder)[] ): ConstraintBuilder
anyfnAbs constructors / facesany(): ConstraintBuilder
anyAbsconstAbs constructors / facesconst anyAbs
anyVarfnAbs constructors / facesanyVar(id: string, conf: Confidence = "path"): Abs
appconstterm / shape buildersconst app
arrayfnterm / shape buildersarray( item: NudoConstraint | ConstraintBuilder | number | string | boolean | null | undefined, ...rest: unknown[] ): ConstraintBuilder
bigintLitfnliteral Abs; litValue → LitValueResult tagged (`{ok:true,value}\bigintLit(value: bigint): Abs
bindconst@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)—
BinderTabletypecontract checking (binder scope = one constraint tree; unbound refs fail closed)—
boolfnAbs constructors / facesbool(): Abs
booleanfn@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)boolean(): ConstraintBuilder
boolLitfnliteral Abs; litValue → LitValueResult tagged (`{ok:true,value}\boolLit(value: boolean): Abs
buildUnknownExplanationsfnunknown / any origin explanation (observation-only side channel — ABS-02)buildUnknownExplanations(input: ExplainInput): AnalysisExplanation[]
callTranspiledExportfnevaluator execution (analyze mode); callTranspiledExportApply is the only apply-wrap of callTranspiledExportFull (throws channel, H1); construct AbsApplyResult only via makeAbsApplyResult (brand)callTranspiledExport( exports: Record<string, unknown>, name: string, args: Abs[], ): Abs
callTranspiledExportApplyfnevaluator execution (analyze mode); callTranspiledExportApply is the only apply-wrap of callTranspiledExportFull (throws channel, H1); construct AbsApplyResult only via makeAbsApplyResult (brand)callTranspiledExportApply( exports: Record<string, unknown> | (() => Record<string, unknown>), name: string, )
callTranspiledExportFullfnevaluator execution (analyze mode); callTranspiledExportApply is the only apply-wrap of callTranspiledExportFull (throws channel, H1); construct AbsApplyResult only via makeAbsApplyResult (brand)callTranspiledExportFull( exports: Record<string, unknown>, name: string, args: Abs[], opts?: { phi?: Phi; shareArgs?: boolean; preferLocal?: boolean; thisArg?: Abs }, ): TranspiledCallResult
CaseTagtypesingle-source @nudo: directive grammar (see docs/design/directive-scope.md)CaseTag = { name: string; argsText: string; expectedText?: string; expectedIssue?: string; tagOffset: number; }
checkArgfncontract checking (binder scope = one constraint tree; unbound refs fail closed)checkArg( arg: Abs, expect: Pred | undefined, phi: Phi = pTrue, ): Diagnostic | undefined
checkCallfncontract checking (binder scope = one constraint tree; unbound refs fail closed)checkCall( source: string, fnName: string, args: Abs[], phi: Phi = pTrue, ): Diagnostic[]
CheckJsontypenudo check gateCheckJson = { version: 1; file: string; ok: boolean; summary: CheckReport["summary"]; signatures: Array<{ name: string; params: string[];...
CheckOptionstypecheck options; from?: readonly AbsCallRecord[] = cross-file call-site evidence (CLI --from) fed into the nudo:contract-drift judgment (optional field — no new export)—
CheckReporttypenudo check gateCheckReport = { file: string; issues: CheckIssue[]; ok: boolean; signatures: NudoSig[]; summary: { errors: number; warnings: number; info...
checkSourcefnnudo check gatecheckSource( filePath: string, source: string, phi: Phi = pTrue, opts: CheckOptions = {}, ): CheckReport
collectBindersconstcontract checking (binder scope = one constraint tree; unbound refs fail closed)—
collectUnboundRefsconstcontract checking (binder scope = one constraint tree; unbound refs fail closed)—
ConfidencetypeAbs = shape × term × pred × conf; LiteralValue 含 bigintConfidence = "exact" | "path" | "widened" | "mock" | "partial" | "opaque"
confJoinfnassignability / joinconfJoin(a: Confidence, b: Confidence): Confidence
ConstraintBuildertype@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)ConstraintBuilder = NudoConstraint & { gt(n: number): ConstraintBuilder; ge(n: number): ConstraintBuilder; lt(n: number): ConstraintBuild...
ContractTierInfotypecontract tiersContractTierInfo = { source: ContractSource; display?: string; sidecarPath?: string; sidecarLine?: number; }
contractTierOffncontract tierscontractTierOf( source: string, fnName: string, fromFile: string, opts: ContractTierOpts = {}, ): ContractTierInfo | undefined
createEnvironmentfnenv host surfacecreateEnvironment( parent?: Environment, bindings: Map<string, Abs> = new Map(), ): Environment
effectiveContractfncontract tierseffectiveContract( source: string, fnName: string, opts: EffectiveContractOpts = {}, ): EffectiveContract | undefined
EffectiveContracttypecontract tiersEffectiveContract = { fnName: string; params: Array<{ param: string; constraint: NudoConstraint; display?: string }>; returns?: { constra...
Environmenttypeenv host surfaceEnvironment = { lookup(name: string): Abs; bind(name: string, value: Abs): Environment; update(name: string, value: Abs): boolean; extend...
evalExprAbsfnAbs-native expression evalevalExprAbs( expr: import("@babel/types").Expression, bindings: Record<string, Abs> = {}, ): Abs
extractFileEnvNamesconstsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)—
extractMockModuleRecordsfnsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)extractMockModuleRecords(source: string, filename?: string): MockModuleRecord[]
extractNudoImportRecordsfnsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)extractNudoImportRecords(source: string, filename?: string): NudoImportRecord[]
extractRefinesFromSourcefnrefinement gateextractRefinesFromSource( source: string, fnName: string, opts: RefineResolveOpts = {}, ): RefineEntry[]
findFnDirectiveScopefnG2 directive scope binding (nearest AST Function, incl. nested / class method)findFnDirectiveScope( file: File, fnName: string, ): FnDirectiveScope | undefined
fnfnterm / shape buildersfn( params: Record<string, NudoConstraint | ConstraintBuilder | number | string | boolean | null | undefined>, returns?: NudoConstraint | ConstraintBuilder | number | string | boolean | null | undefined, opts?: { throws?: NudoConstraint | ConstraintBuilder | number | string | boolean | null | undefined }, ): ConstraintBuilder
fnDirectiveCommentLinesfnG2 directive scope binding (nearest AST Function, incl. nested / class method)fnDirectiveCommentLines(source: string, fnName: string): string[]
FnDirectiveScopetypeG2 directive scope binding (nearest AST Function, incl. nested / class method)FnDirectiveScope = { name: string; node: Node; commentTexts: string[]; commentLines: string[]; commentStartLines: number[]; startLine: nu...
fnOffnterm / shape buildersfnOf(params: string[], name?: string): Abs
formatAbsfnextensional rendering (one-way)formatAbs(a: Abs, opts: FormatOptions = {}): string
formatCheckReportfnextensional rendering (one-way)formatCheckReport(r: CheckReport, opts: { verbose?: boolean } = {}): string
formatConstraintfnextensional rendering (one-way)formatConstraint(c: NudoConstraint): string
formatShapefnextensional rendering (one-way)formatShape( a: Abs, opts?: { maxDepth?: number; showLits?: boolean; pretty?: boolean }, ): string
formatUnknownExplanationsfnunknown / any origin explanation (observation-only side channel — ABS-02)formatUnknownExplanations( explanations: readonly AnalysisExplanation[], ): string
generalizeFromAstfnsymbolic α generalization; TypeParam.bounds = optional simple bounds per formal (ABS-14 PR2 additive, write-only)generalizeFromAst( fnName: string, source: string, opts: { budget?: LeakBudget; label?: string; refine?: EffectiveContractOpts; file?: ReturnType<typeof babelParse>; depsFp?: LoadDepsFingerprint; sidecarFp?: string; modules?: Record<string, AbsModuleExports | Record<string, unknown>>; inject?: RunTranspiledOptions; } = {}, ): PolyFn | undefined
getParseSourceCacheSizefnBabel parse + memogetParseSourceCacheSize(): number
instantiateConstraintfncontract checking (binder scope = one constraint tree; unbound refs fail closed)instantiateConstraint( c: NudoConstraint, paramName: string, depth: number = LAZY_TEMPLATE_DEPTH, binders?: BinderTable, ): Pred
isAbsApplyResultfnevaluator execution (analyze mode); callTranspiledExportApply is the only apply-wrap of callTranspiledExportFull (throws channel, H1); construct AbsApplyResult only via makeAbsApplyResult (brand)isAbsApplyResult(v: AbsApplyReturn): v
isExactLitfnliteral Abs; litValue → LitValueResult tagged (`{ok:true,value}\isExactLit(a: Abs): boolean
joinAbsfnassignability / joinjoinAbs(a: Abs, b: Abs): Abs
joinValuesfnassignability / joinjoinValues(a: Abs, b: Abs): Abs
leqAbsfnassignability / joinleqAbs( src: Abs, tgt: Abs, opts: { phi?: Phi; env?: AstEnv } = {}, ): LeqResult
listFnDirectiveScopesfnG2 directive scope binding (nearest AST Function, incl. nested / class method)listFnDirectiveScopes(file: File): FnDirectiveScope[]
litconstterm / shape buildersconst lit
litCfn@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)litC(v: import("./term.ts").LiteralValue): ConstraintBuilder
LiteralValuetypeAbs = shape × term × pred × conf; LiteralValue 含 bigintLiteralValue = string | number | boolean | bigint | null | undefined
litValuefnliteral Abs; litValue → LitValueResult tagged (`{ok:true,value}\litValue(a: Abs): LitValueResult
LitValueResulttypeAbs = shape × term × pred × conf; LiteralValue 含 bigintLitValueResult = | { ok: true; value: LiteralValue } | { ok: false }
makeAbsApplyResultfnevaluator execution (analyze mode); callTranspiledExportApply is the only apply-wrap of callTranspiledExportFull (throws channel, H1); construct AbsApplyResult only via makeAbsApplyResult (brand)makeAbsApplyResult(abs: Abs, throws: Abs): AbsApplyResult
makeSumfnterm / shape buildersmakeSum(a: Abs, b: Abs): Abs
mockfntest mock helpersmock(): MockHelper
MockHelpertypetest mock helpersMockHelper = { kind: "mock-helper"; returnValue?: Abs; resolvedValue?: Abs; rejectedValue?: Abs; onFirstCallValue?: Abs; onSecondCallValu...
MockModuleRecordtypesingle-source @nudo: directive grammar (see docs/design/directive-scope.md)MockModuleRecord = { source: string; names?: string[]; fromPath: string; }
neverconstAbs constructors / facesconst never
NudoConstrainttypecontract checking (binder scope = one constraint tree; unbound refs fail closed)NudoConstraint = { readonly __nudoConstraint: true; readonly prim?: PrimName; readonly preds: Pred[]; readonly fields?: Record<string, Nu...
NudoImportRecordtypesingle-source @nudo: directive grammar (see docs/design/directive-scope.md)NudoImportRecord = { names: string[]; importedOfLocal: Record<string, string>; spec: string; }
numfnAbs constructors / facesnum(): Abs
numberfn@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)number(): ConstraintBuilder
numLitfnliteral Abs; litValue → LitValueResult tagged (`{ok:true,value}\numLit(value: number): Abs
objfnterm / shape buildersobj( slots: Record<string, { value: Abs; optional?: boolean }>, ): Abs
ObjShapetypeAbs = shape × term × pred × conf; LiteralValue 含 bigintObjShape = { k: "obj"; slots: Record<string, Slot>; index?: { key: Abs; value: Abs }; open?: boolean; }
parseEnvPayloadfnsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)parseEnvPayload(payload: string): string[]
parseMockModulePayloadfnsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)parseMockModulePayload(payload: string): MockModuleRecord | undefined
parseNudoImportPayloadfnsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)parseNudoImportPayload( payload: string, ): NudoImportRecord
parseSourcefnBabel parse + memoparseSource( source: string, opts?: { errorRecovery?: boolean; keepTs?: boolean; filename?: string }, ): File
PhitypeAbs = shape × term × pred × conf; LiteralValue 含 bigintPhi = Pred
PredtypeAbs = shape × term × pred × conf; LiteralValue 含 bigintPred = | { op: "true" } | { op: "false" } | { op: "eq"; a: Term; b: Term } | { op: "ne"; a: Term; b: Term } | { op: "lt"; a: Term; b: Ter...
projectAbsToSchemaconstone-way projections—
refconst@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)—
refineAbsForRelTruefnrefinement gaterefineAbsForRelTrue( a: Abs, op: "gt" | "ge" | "lt" | "le", k: number, ): Abs
relconst@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)—
resetParseSourceCachefnBabel parse + memoresetParseSourceCache(): void
resolveRefChainconstcontract checking (binder scope = one constraint tree; unbound refs fail closed)—
runTranspiledfnevaluator execution (analyze mode); callTranspiledExportApply is the only apply-wrap of callTranspiledExportFull (throws channel, H1); construct AbsApplyResult only via makeAbsApplyResult (brand)runTranspiled( source: string, opts: RunTranspiledOptions = {}, ): Record<string, unknown>
scanBudgetDeclfnsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)scanBudgetDecl( lines: string[], )
scanCaseTagsfnsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)scanCaseTags(text: string): CaseTag[]
scanContractSegmentsfnsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)scanContractSegments(lines: string[]): string[]
scanThrowsDeclfnsingle-source @nudo: directive grammar (see docs/design/directive-scope.md)scanThrowsDecl(lines: string[]): string | undefined
serializeCheckJsonfnnudo check gateserializeCheckJson(r: CheckReport): CheckJson
serializeCheckJsonMultifnnudo check gateserializeCheckJsonMulti(reports: CheckJson[]): CheckJsonMulti
shapefnterm / shape buildersshape( fields: Record< string, NudoConstraint | ConstraintBuilder | number | string | boolean | null | undefined >, ): ConstraintBuilder
ShapetypeAbs = shape × term × pred × conf; LiteralValue 含 bigintShape = | { k: "never" } | { k: "any" } | { k: "unknown" } | { k: "prim"; type: PrimName } | { k: "obj"; slots: Record<string, { value: A...
SlottypeAbs = shape × term × pred × conf; LiteralValue 含 bigintSlot = { value: Abs; optional?: boolean; readonly?: boolean; internal?: boolean; inherited?: boolean; symbolKey?: boolean; }
spyfntest mock helpersspy(): MockHelper
strfnAbs constructors / facesstr(): Abs
stringfn@nudo:contract builder grammar (structural conjunction: shape∧shape / array∧array / union∧union / fn∧fn — ABS-11)string(): ConstraintBuilder
stripTypesfnAST TS-stripping helperstripTypes<T extends Node>(ast: T, source?: string, opts?: StripOptions): T
strLitfnliteral Abs; litValue → LitValueResult tagged (`{ok:true,value}\strLit(value: string): Abs
stubfntest mock helpersstub(): MockHelper
TermtypeAbs = shape × term × pred × conf; LiteralValue 含 bigintTerm = | { op: "lit"; value: LiteralValue } | { op: "var"; id: string } | { op: "app"; fn: string; args: Term[] }
TranspiledCallResulttypeevaluator execution (analyze mode); callTranspiledExportApply is the only apply-wrap of callTranspiledExportFull (throws channel, H1); construct AbsApplyResult only via makeAbsApplyResult (brand)TranspiledCallResult = { result: Abs; throws: Abs; }
unionfnterm / shape buildersunion( ...cs: (NudoConstraint | ConstraintBuilder | number | string | boolean | null | undefined)[] ): ConstraintBuilder
unknownconstAbs constructors / facesconst unknown
UnknownReasontypeunknown / any origin explanation (observation-only side channel — ABS-02)UnknownReason = | "budget" | "missing-env" | "unsupported" | "eval-failure" | "no-contract" | "explicit-any" | "inference-failure"
vconstterm / shape buildersconst v

Exec runtime ($op, §2.2)​

NameKindSummarySignature
$addfnoperator runtime$add(a: Abs, b: Abs): Abs
$argumentsfnarray runtime$arguments(items: ArrayLike<unknown>): Abs
$arrfnarray runtime$arr(items: Abs[]): Abs
$arrMutContainerfnarray runtime$arrMutContainer(arr: Abs, method: string, args: Abs[]): Abs
$arrRestfnobject / member runtime$arrRest(a: Abs, start: number): Abs
$arrWithHolesfnarray runtime$arrWithHoles(items: Abs[], holes: number[]): Abs
$assignRecordfncall-site recording for analyze$assignRecord( name: string, prev: Abs | undefined, next: Abs, line: number, column: number, conditional: boolean, paramBinding?: boolean, ): void
$asyncfnasync / generator$async(thunk: () => Abs): Abs
$awaitfnasync / generator$await(v: Abs): Abs
$callNamedfncall-site recording for analyze$callNamed( name: string, fn: unknown, args: Abs[], loc?: [number, number], argLocs?: Array<[number, number] | null | undefined>, ): Abs
$catchValfncontrol-signal / throw$catchVal(e: unknown): Abs
$classExprfnvalue / class runtime$classExpr(name?: string): Abs
$concatfnobject / member runtime$concat(a: Abs, b: Abs): Abs
$copyfnarray runtime$copy(a: Abs, memo?: WeakMap<object, Abs>): Abs
$delfnobject / member runtime$del: (o: Abs, key: Abs) => Abs
$elemsfnobject / member runtime$elems(a: Abs): Abs[]
$eqfnoperator runtime$eq(a: Abs, b: Abs): Abs
$fnValfnvalue / class runtime$fnVal( params: string[], impl: (...args: Abs[]) => Abs, opts?: { bindThis?: boolean; ctor?: boolean; padArgs?: boolean; length?: number; effectFree?: boolean; closed?: boolean; kind?: string; fnKind?: "function" | "async" | "generator" | "async-generator"; optionalParams?: boolean[]; emptyBody?: boolean }, ): Abs
$forfncontrol-flow lowering$for( init: Abs, test: (s: Abs) => Abs, step: (s: Abs) => Abs, body: (s: Abs) => Abs, maxIters: number = DEFAULT_MAX_LOOP_ITERS, opts?: { pack?: () => Abs; unpack?: (s: Abs) => void; label?: string; loopVar?: () => Abs; }, ): Abs
$forkfncontrol-flow lowering$fork(test: Abs, consequent: () => Abs, alternate?: () => Abs): Abs
$gefnoperator runtime$ge(a: Abs, b: Abs): Abs
$genfnasync / generator$gen(body: () => Abs, asyncMode = false, hooks?: GenSuspendHooks): Abs
$getfnobject / member runtime$get: ( o: Abs, key: string, opts?: Parameters<typeof $getInner>[2], receiver?: Parameters<typeof $getInner>[3], ) => ReturnType<typeof $getInner>
$idxfnarray runtime$idx: (a: Abs, i: Abs, opts?: { silent?: boolean }) => Abs
$idxSetfnarray runtime$idxSet: ( o: Abs, i: Abs, v: Abs, ) => ReturnType<typeof $idxSetInner>
$infnvalue / class runtime$in: (key: Abs, o: Abs) => Abs
$instanceoffnvalue / class runtime$instanceof(left: Abs, rightName: string, rightVal?: Abs): Abs
$joinfnoperator runtime$join(a: Abs, b: Abs): Abs
$lenfnarray runtime$len(a: Abs, opts?: { silent?: boolean }): Abs
$litfnvalue / class runtime$lit(v: unknown): Abs
$loopBreakfncontrol-signal / throw$loopBreak(label?: string): never
$loopContinuefncontrol-signal / throw$loopContinue(label?: string): never
$loopReturnfncontrol-signal / throw$loopReturn(v: Abs): never
$narrowMemberEqconstguard-arm narrowing (relation facts / non-NaN-gated complements / typeof / discriminant / nullish)—
$narrowTypeOfconstguard-arm narrowing (relation facts / non-NaN-gated complements / typeof / discriminant / nullish)—
$negfnoperator runtime$neg(a: Abs): Abs
$notfnoperator runtime$not(a: Abs): Abs
$nullishTestfncontrol-flow lowering$nullishTest(v: Abs): Abs
$objfnobject / member runtime$obj(slots: Record<string, Abs>): Abs
$objRestfnobject / member runtime$objRest(o: Abs, keys: Array<string | Abs>): Abs
$powfnoperator runtime$pow(a: Abs, b: Abs): Abs
$rawThisfnvalue / class runtime$rawThis(v: unknown): Abs
$recordBindingfncall-site recording for analyze$recordBinding(name: string, value: unknown): void
$refineNotNaNconstguard-arm narrowing (relation facts / non-NaN-gated complements / typeof / discriminant / nullish)—
$refineRelconstguard-arm narrowing (relation facts / non-NaN-gated complements / typeof / discriminant / nullish)—
$refineRelComplementconstguard-arm narrowing (relation facts / non-NaN-gated complements / typeof / discriminant / nullish)—
$removeMemberNullishconstguard-arm narrowing (relation facts / non-NaN-gated complements / typeof / discriminant / nullish)—
$removeNullconstguard-arm narrowing (relation facts / non-NaN-gated complements / typeof / discriminant / nullish)—
$removeNullishconstguard-arm narrowing (relation facts / non-NaN-gated complements / typeof / discriminant / nullish)—
$removeUndefinedconstguard-arm narrowing (relation facts / non-NaN-gated complements / typeof / discriminant / nullish)—
$setfnobject / member runtime$set: ( o: Abs, key: string, value: Abs, opts?: Parameters<typeof $setInner>[3], ) => ReturnType<typeof $setInner>
$spreadfnobject / member runtime$spread(a: Abs, b: Abs): Abs
$switchfncontrol-flow lowering$switch( disc: Abs, cases: Array<{ test: Abs; run: () => Abs }>, dflt?: () => Abs, ): Abs
$throwfncontrol-signal / throw$throw(v: Abs): never
$tplconstobject / member runtime—
$typeoffnoperator runtime$typeof(a: Abs): Abs
$whileSeqfncontrol-flow lowering$whileSeq( test: () => Abs, body: () => void, maxIters: number = DEFAULT_MAX_LOOP_ITERS, opts?: { pack?: () => Abs; unpack?: (s: Abs) => void; label?: string; }, ): void
$yieldfnasync / generator$yield( v: Abs, tryCtx = 0, finals: readonly (() => void)[] = [], ): Abs
$yieldStarconstasync / generator—
asAbsValfnvalue / class runtimeasAbsVal(v: unknown): Abs
EvalCallRecordtypecall-site recording for analyzeEvalCallRecord = { fnName: string; args: Abs[]; result: Abs; callLoc?: { line: number; column: number }; threw: boolean; depth?: number; }
fillTuplefnarray runtimefillTuple( shape: { k: "tuple"; elements: Abs[]; holes?: number[] } | { k: "arr"; element: Abs }, vals: Abs[], arr: Abs, ): Abs
foldRequireSpecArgfnstatic folding helpersfoldRequireSpecArg(arg: unknown): string | undefined
foldStaticStringExprfnstatic folding helpersfoldStaticStringExpr(node: unknown): string | undefined
isArrMutatorfnarray runtimeisArrMutator(name: string): boolean
NudoLoopSignaltypecontrol-signal / throwNudoLoopSignal extends Error { readonly kind: "break" | "continue"; readonly label: string | undefined; readonly abstract: boolean; const...
NudoReturntypecontrol-signal / throwNudoReturn extends Error { readonly absValue: Abs; constructor(absValue: Abs) { super("nudo:return"); this.name = "NudoReturn"; this.absV...
NudoThrowtypecontrol-signal / throw—
runtimeImportOffnJS AST → $op programruntimeImportOf(runtime: string): string
setEvalCallCollectorfncall-site recording for analyzesetEvalCallCollector( collector: ((r: EvalCallRecord) => void) | null, )
transpileBodyNodefnJS AST → $op programtranspileBodyNode(node: Node, opts: TranspileOptions): string
transpileExpressionfnJS AST → $op programtranspileExpression(expr: Expression, opts: TranspileOptions = {}): string
transpileFilefnJS AST → $op programtranspileFile(file: File, opts: TranspileOptions = {}): string
TranspileOptionstypeJS AST → $op program—
transpileSourcefnJS AST → $op programtranspileSource(source: string, opts: TranspileOptions = {}): string
Additional exports from src/index.ts (334)
NameKindSummarySignature
AbsApplyReturntypeapply 可返回裸 Abs(无 throws)或带 throws 通道的 AbsApplyResultAbsApplyReturn = Abs | AbsApplyResult
AbsAssignRecordtypeAbs 域赋值记录(eval 通道 $assignRecord 的同形投影)AbsAssignRecord = { name: string; prev?: Abs; next: Abs; line?: number; column?: number; conditional?: boolean; paramBinding?: boolean; }
AbsCallRecordtypeAbs 域调用记录(eval 通道 EvalCallRecord 的同形投影)AbsCallRecord = { fnName: string; args: Abs[]; result: Abs; callLoc?: { line: number; column: number }; threw?: boolean; }
AbsFnImpltype—AbsFnImpl = { params: string[]; body?: Node; async?: boolean; env?: AstEnv; kind?: string; fnKind?: "function" | "async" | "generator" | ...
absFunctionfn造一个带实现的 Abs 函数值absFunction( params: string[], impl: Omit<AbsFnImpl, "params">, opts?: { name?: string; paramTypes?: Abs[]; returnType?: Abs; slots?: Record<string, { value: Abs; optional?: boolean; readonly?: boolean }>; conf?: Confidence; ctor?: boolean; length?: number; }, ): Abs
AbsModuleExportstype—AbsModuleExports = { named: Record<string, Abs>; default?: Abs; evaluated?: boolean; cjsMain?: boolean; interopDefault?: boolean; }
absShapeKeyfn结构键的最小面(join 去重 / 槽相等 / env 声明去重共用)。absShapeKey(a: Abs, seen: Set<object> = new Set()): string
AbsSigImpltypeAbs 原生 env/builtin 实现(evaluator 优先)AbsSigImpl = (args: Abs[], thisVal?: Abs) => Abs | undefined
absToConstraintfnAbs → 契约;不可表达 → undefined。absToConstraint( a: Abs, budget: ProjectionBudget = new ProjectionBudget(), ): NudoConstraint | undefined
absToStringfn—absToString(a: Abs): string
actionsForIssuefn诊断码 → 结构化动作(AI1);未知码给 info 提示actionsForIssue(i: { code: string; expected?: string; suggestion?: string; fn?: string; reason?: string; }): CheckAction[]
addfn—add(a: Abs, b: Abs, phi: Phi = pTrue): Abs
applyCallbackAbsfn—applyCallbackAbs( cb: Abs | { type: string }, args: Abs[], env: unknown, phi: unknown, budget: unknown, thisVal?: Abs, ): Abs
applyCallbackValuefn通用回调实参调用(exec/class invokeArrMethod 与 builtins Array.from 共用): 原始 JS 函数直调(展开实参);Abs fn 走 applyCallbackAbs(sum 分发/宿主)。applyCallbackValue( fn: unknown, args: Abs[], env: unknown, phi: unknown, budget: unknown, thisVal?: Abs, ): Abs
asAbsfn从 map/filter/reduce 回调实参里取出 Abs(Identifier 已绑定或直接 Abs)asAbs(v: unknown): Abs | undefined
assignSourceSlotsfn—assignSourceSlots(src: Abs): Record<string, { value: Abs }> | undefined
assumeFiniteconst显式有限证据:t 为有限数(非 NaN/±Inf),开启线性环化简const assumeFinite
AstEnvtype——
attachFnImplfn—attachFnImpl(a: Abs, impl: AbsFnImpl): void
beginCollectionForkfn—beginCollectionFork(): void
bindImportsfn把 import 说明符绑定进 env(宿主已求值依赖)bindImports( node: ImportDeclaration, env: AstEnv, modules: Record<string, AbsModuleExports>, ): void
bindingsOffnrun 表的顶层绑定表: - 顶层 const/let($recordBinding 通道,Abs 值); - 私有顶层函数声明(宿主 JS 函数;与 ANALYSIS_SLOTS 同源,导出面同名 可枚举键不重复登记——导出函数只走导出表)。bindingsOf(run: Record<string, unknown>): Map<string, unknown> | undefined
bitandAbsfn& —— ToInt32 两侧后按位与bitandAbs(a: Abs, b: Abs): Abs
bitnotAbsfn~ —— ToInt32 后按位取反(bigint 无符号截断)bitnotAbs(a: Abs): Abs
bitorAbsfn| —— ToInt32 两侧后按位或bitorAbs(a: Abs, b: Abs): Abs
bitxorAbsfn^ —— ToInt32 两侧后按位异或bitxorAbs(a: Abs, b: Abs): Abs
buildArgsFromAssumefn按 assume 集合构造实参:被 assume 的参数给带约束的符号,其余 any (design-cli-semantics §2:入口无约束 = any,不是 unknown)。buildArgsFromAssume( source: string, fnName: string, assumeIds: Set<string>, bounds?: ReadonlyMap<string, Pred>, ): Abs[]
builtinCtorAbsfn—builtinCtorAbs(name: string): Abs
builtinCtorNameOffnAbs 侧内建构造器身份(与宿主构造器名对齐)builtinCtorNameOf(v: unknown): string | undefined
callAbsMethodfn调用 Abs 方法。返回 undefined = 未接管(调用方走其它路径)。callAbsMethod( recv: Abs, name: string, args: Abs[], ): Abs | undefined
callAtFunctionBoundaryfn函数调用边界:callee 的 loop/early-return 不得冒泡成 caller 结果。callAtFunctionBoundary<T>(body: () => T): T
canonicalArrayIndexfnES 规范数组下标(无前导零、< 2^32-1);非规范键返回 undefinedcanonicalArrayIndex(v: unknown): number | undefined
CheckActiontype结构化修复动作(AI1;稳定枚举,只增不改语义)CheckAction = { kind: "draft" | "relax" | "callsite" | "assume" | "mock" | "emit" | "ignore-throws" | "info"; command?: string; label: st...
CheckIssuetype—CheckIssue = Diagnostic & { fn?: string; line?: number; column?: number; actual?: string; expected?: string; reason?: "cycle" | "depth" |...
CheckJsonMultitype多文件 check --json 信封(CI / monorepo)。单文件仍输出裸 CheckJson。CheckJsonMulti = { version: 1; kind: "multi"; ok: boolean; summary: CheckReport["summary"] & { files: number; budgetTruncated?: boolean }...
clearBClassesfn—clearBClasses(): void
clearCollectionTablesfn—clearCollectionTables(): void
clearStaleTermPredfn调用方已直接改 shape 时的 term/pred 清理clearStaleTermPred(v: Abs): void
cmpfn比较:返回 boolean Abs;若双字面量则 exactcmp( op: "lt" | "le" | "gt" | "ge" | "eq" | "ne", a: Abs, b: Abs, phi: Phi = pTrue, ): Abs
collectAbsExportsfn从已求值 env + AST 收集 ESM 导出。collectAbsExports( file: File, env: AstEnv, modules?: Record<string, AbsModuleExports>, ): AbsModuleExports
collectAbsFreeVarsfn公开:收集 Abs 自由 term 变元(dts 泛型投影 / α 作用域判定复用 L2 基建)。collectAbsFreeVars(a: Abs): Set<string>
collectionElementJoinfn元素联合(for-of / Array.from);无表 → unknown。collectionElementJoin(c: Abs): Abs
collectionExactLenfn确切条目数:Set 无 maybeAbsent / Map 无 shadow+maybeAbsent 时返回长度; 否则 undefined(for-of 不得假装有界)。collectionExactLen(c: Abs): number | undefined
CONSTRAINT_BUILDER_NAMESconst构建器表面名(供文法正则 / 测试枚举;顺序即表定义顺序)const CONSTRAINT_BUILDER_NAMES
CONSTRAINT_BUILDERSconst约束构建器表面名表(单一真源):case 实参文法、mock 类型表达式识别与 侧车注入共用的名字 → 实现映射。键名是 *.nudo.js / 指令里的用户写法 (lit/and 而非内部的 litC/andC)。const CONSTRAINT_BUILDERS
CONSTRAINT_CHAIN_METHOD_NAMESconst链式方法名表(单一真源):builder(...).method(...) 链上允许的方法。const CONSTRAINT_CHAIN_METHOD_NAMES
CONSTRAINT_EXPR_REconst约束表达式头:name( 形态。由 CONSTRAINT_BUILDER_NAMES 生成—— 名单只在 CONSTRAINT_BUILDERS 一处维护。const CONSTRAINT_EXPR_RE
constraintAdmitsNullishfn契约域是否包含 nullish(null / undefined)。constraintAdmitsNullish( c: NudoConstraint, seen?: Set<object>, ): boolean
constraintToEntryAbsfn契约 → 函数入口 param Abs(infer/hover 用)。constraintToEntryAbs( c: NudoConstraint, paramName: string, depth: number = LAZY_TEMPLATE_DEPTH, binders?: BinderTable, ): Abs
CONTRACT_SOURCE_ABBRconst档位源缩写:handwritten=hw / generated=gen / implicit=impconst CONTRACT_SOURCE_ABBR
ContractDiagtypecontract 推导诊断(severity 由消费方按 code 定档,形状对齐 Issue 子集)ContractDiag = { code: string; message: string; file?: string; line?: number; column?: number; }
contractDiagCountfn当前诊断累计序号(since 锚:工具面只排干自身探测产生的增量)contractDiagCount(): number
contractParamNameSetfn侧车契约可绑定的参数名全集contractParamNameSet(formals: FormalParam[]): Set<string>
ContractSourcetype有效契约来源:手写(源码 refine ∪ 侧车手写绑定)> 生成段 > 隐式ContractSource = "handwritten" | "generated" | "implicit"
contractSourceOffncontractTierOf 的来源投影;非导出 → undefinedcontractSourceOf( source: string, fnName: string, fromFile: string, opts: ContractTierOpts = {}, ): ContractSource | undefined
ContractTierOptstype—ContractTierOpts = EffectiveContractOpts
ctorArgDefinitelyInvalidfn构造器实参确定非法(原生 TypeError 域): - 非可迭代字面量(number/boolean/symbol/bigint、闭对象字面量、symbol 字面量)→ 四个集合构造器都抛 - Map/WeakMap 条目必须是对象(IsObject):prim 条目(含字符串实参的 每个字符、tuple/Set 元素)与 nullish 字面量条目 → TypeError (Bug 8:null/undefined/symbol 字面量挂 shape unknown + lit term, 旧 primEntry 只查 prim 形态 → 漏抛) - WeakMap 键 = Get(entry, "0") 须可弱持有(classifyCanBeHeldWeakly 同 口径):零/一元组、闭对象/fn/无 0 槽 brand 条目键 undefined、prim/ nullish 键 → TypeError(Bug 8:旧口径只查 ≥2 元组首元素 prim) - WeakSet 元素须可弱持有:prim/nullish 字面量元素(含字符串字符)→ TypeError;symbol 元素合法(node 实测 new WeakSet([Symbol()]) 不抛) - Bug 8 gate 面:抽象外层 iterable(any/unknown/开放 obj/fn/其它 brand) 可能非可迭代、抽象元素(含抽象字符串实参的字符臂)可能非 entry/ 非弱键 → recordMayThrow(三个分派点共用本判定,集中记录)ctorArgDefinitelyInvalid( name: "Map" | "Set" | "WeakMap" | "WeakSet", iterable: Abs | undefined, ): boolean
ctorNameOfRecvfn接收者 → 原型链 constructor 名(.constructor 折叠)。ctorNameOfRecv(recv: Abs): string | undefined
currentExecPhifn—currentExecPhi(): Phi
DEFAULT_MAX_LOOP_ITERSconst循环展开上限(leaf)—— 从 control.ts 拆出,打断 control ↔ containers 环。const DEFAULT_MAX_LOOP_ITERS
definitelyNotNullishShapefn该 shape 在 JS 上一定不是 null/undefineddefinitelyNotNullishShape(s: Shape): boolean
derefConstraintfn解一层 lazy:调用 thunk 一次、校验产物是约束、toPlainConstraint 归一化, 并按 thunk 记忆化(重复 deref 同一闭包 → 同一对象)。derefConstraint(c: NudoConstraint): NudoConstraint
Diagnostictype—Diagnostic = { severity: "error" | "warning" | "info"; code: string; message: string; suggestion?: string; fn?: string; argIndex?: number; }
divfn除法:字面量折叠;除以正/负常数时按单调性推界。div(a: Abs, b: Abs, phi: Phi = pTrue, assume?: Phi): Abs
drainPromiseMicrosfn—drainPromiseMicros(): void
EffectiveContractOptstype—EffectiveContractOpts = RefineResolveOpts & { autoBind?: boolean | ((sidecarPath: string) => boolean); projectDir?: string; }
emptyEnvfn空求值环境(分析宿主用:不带任何绑定)emptyEnv(): AstEnv
emptyPhiconst—const emptyPhi
endCollectionForkfn—endCollectionFork(arms: Array<ArmOverlay | undefined | null>): void
enterPromiseExecutorScopefn—enterPromiseExecutorScope(): void
eqconst—const eq
errorBrandAbsfnError brand:shape 带 name/message(字面量 message 保精确)。errorBrandAbs(name: string, args: Abs[]): Abs
EvalAbsAssignRecordtypeB 赋值记录(与 ast-records.ts AbsAssignRecord 同形;structuralAssignIssues 消费)EvalAbsAssignRecord = { name: string; prev: Abs | undefined; next: Abs; line?: number; column?: number; conditional?: boolean; paramBindi...
evalArrayStaticfnArray.isArray / Array.from / Array.ofevalArrayStatic(name: string, args: Abs[]): Abs | undefined
evalBuiltinInstanceMethodfnbrand 实例方法(Date/RegExp/Map/Set/Error 家族/装箱拆箱后的 prim 面在外层)evalBuiltinInstanceMethod( brandName: string, method: string, recv: Abs, args: Abs[], ): Abs | undefined
evalBuiltinNewfnnew X(...)evalBuiltinNew(className: string, args: Abs[]): Abs | undefined
EvalClassSpectype——
evalDateCtorfn—evalDateCtor(args: Abs[]): Abs
evalDateMethodfn—evalDateMethod(name: string, recv: Abs, args: Abs[]): Abs | undefined
evalDateStaticfn—evalDateStatic(name: string, args: Abs[]): Abs | undefined
EvalFallbacktypeevaluator 回落事件(观测单一埋点)。EvalFallback = { reason: string; message: string; loc?: { line: number; column: number }; origin?: "module" | "host" | "engine"; gateFata...
evalGlobalFnfn—evalGlobalFn(name: string, args: Abs[]): Abs | undefined
evalJsonMethodfnJSON.parse / stringify:字面量实参真执行折叠;失败硬抛(catch 可吸收)evalJsonMethod(name: string, args: Abs[]): Abs | undefined
evalMathMethodfn—evalMathMethod(name: string, args: Abs[]): Abs | undefined
evalNamespaceCallfn命名空间静态分派。Bug 311:thisVal = 静态方法值的 this 绑定(成员读出的 静态方法被单独调用时的接收者,如 Promise.resolve.call(null, 1)); 缺席 = 直接命名空间调用(this ≡ 命名空间构造器,合法)。evalNamespaceCall( ns: string, method: string, args: Abs[], thisVal?: Abs, ): Abs | undefined
evalNumberStaticfnNumber.isInteger / isNaN / parseFloat 等evalNumberStatic(name: string, args: Abs[]): Abs | undefined
evalObjectMethodfn—evalObjectMethod(name: string, args: Abs[]): Abs | undefined
evalObjectProtoMethodfnObject.prototype 方法语义(evaluator $invoke 与 Object.prototype.X.call 共用)。evalObjectProtoMethod( name: string, thisVal: Abs, args: Abs[], ): Abs | undefined
EvalPosRecordtype位置级 Abs 记录(hover 重放插桩 $nodoPos 消费): (1-based 行, 0-based 列) → 该位置表达式求值态 AbsEvalPosRecord = { line: number; column: number; abs: Abs; }
evalPromiseCtorfnnew Promise(executor):调用 executor(resolve, reject),收集 resolve 实参作为 promise inner。原生只认第一次 settle——顺序双 resolve 取第一次;执行器内 $fork 分叉时各臂 settle 值 join(路径敏感,不得 first-wins 假精确)。evalPromiseCtor(args: Abs[]): Abs
evalPromiseMethodfnthen/catch/finally:可映射回调 → 新 inner;做不到诚实 promise<unknown>evalPromiseMethod( name: string, recv: Abs, args: Abs[], ): Abs | undefined
evalPromiseStaticfnBug 311:Promise 静态派发。thisVal = 静态方法值的 this 绑定(成员读出 的静态方法被单独调用时的接收者);缺席 = 直接命名空间调用(this ≡ Promise 构造器,合法)。非构造器接收者按原生抛 TypeError。evalPromiseStatic( name: string, args: Abs[], thisVal?: Abs, ): Abs | undefined
evalRegExpCtorfn—evalRegExpCtor(args: Abs[]): Abs
evalRegExpMethodfn—evalRegExpMethod(name: string, recv: Abs, args: Abs[]): Abs | undefined
evalStringStaticfnString.fromCharCode / String.fromCodePoint: - fromCharCode:全部字面量 → 按 ToUint16 折成精确字符串(含越界/非整数/ 数字字符串);symbol 字面量 → TypeError(ToNumber 抛);任一抽象实参 → 抽象 string(不假精确) - fromCodePoint(Bug 38):字面量过 ToNumber 后 IsValidCodePoint 校验 (node v26 实测:非整数/NaN/±∞/<0/>0x10FFFF → RangeError "Invalid code point";null/""/false → 0 合法;"65" → 65;surrogate 0xD800 合法); symbol/bigint 的 ToNumber → TypeError(fromCodePoint(1n) 原生抛,区别 于 fromCharCode 的 ToUint16 面——bigint ToString 合法但 ToNumber 抛); 抽象实参 → may RangeError(+ symbol 载体 may TypeError)+ str("path")evalStringStatic(name: string, args: Abs[]): Abs | undefined
evalSymbolCtorfn全局 Symbol([desc])($callNamed 身份校验后派发)evalSymbolCtor(args: Abs[]): Abs
evictCheckSourceMemoForPathsfn*.nudo.js 变更后定向逐出依赖它的整文件 check 缓存。查找与索引同走 stablePathKeyevictCheckSourceMemoForPaths(paths: string[]): number
evictGeneralizeMemoForPathsfnLSP/宿主:*.nudo.js 变更后按路径定向逐出依赖它的 L0 条目。evictGeneralizeMemoForPaths(paths: string[]): number
execNudoModulefn执行 *.nudo.js(真实 JS + 我们的构建器)。import/export 由 Babel 语句级 改写:多行 named import、注释/字符串里的同形文本不误伤;相对 .nudo 递归 求值;环 → throw NudoSidecarError。结果进 exec 缓存(依赖闭包内容指纹键)。execNudoModule(src: string, opts?: RefineResolveOpts): Record<string, unknown>
ExplainInputtype结构化输入(只取观察面已有字段;结构性类型避免与 check 模块成环)ExplainInput = { signatures: ReadonlyArray<{ name: string; paramTypes?: readonly string[]; display?: string; detail?: string; conf?: stri...
extractBalancedParensfn平衡括号摘取(字符串感知;\ 不是转义——与 case 实参原样 slice 一致)。extractBalancedParens(text: string, startIdx: number): string | null
extractDeclaredThrowsfn申报式抛错(declare throws — L2 豁免): 与 refine 同扫函数前注释块(D6=G2 同一 scope 绑定)。extractDeclaredThrows( source: string, fnName: string, ): string[]
extractFnfn—extractFn( source: string, fnName: string, fileAst?: ReturnType<typeof babelParse>, )
extractFnBudgetfn函数级预算旋钮(#64 P4): 与 @nudo:throws 同路径扫函数前注释块(D6=G2 同一 scope 绑定)。extractFnBudget( source: string, fnName: string, )
extractNudoImportsfn@nudo:import 命名/namespace 导入(D5=F1:文法在 directive-scan 单源)。extractNudoImports(source: string, filename?: string): NamedImport[]
extractRefineReturnFromSourcefn解析 @nudo:contract return positive → 返回契约。extractRefineReturnFromSource( source: string, fnName: string, opts: RefineResolveOpts = {}, )
ExtStatetype—ExtState = "nonext" | "sealed" | "frozen"
extStateOffn—extStateOf(o: Abs): ExtState | undefined
falseConstraintfn—falseConstraint(c: Abs): Pred | undefined
FnAbstype—FnAbs = Abs & { shape: { k: "fn"; params: string[]; name?: string; paramTypes?: Abs[]; returnType?: Abs; }; }
fnConstraintToEntryReqsfnfn 约束 → 逐参约束表(contract 推导 / 入口签名消费)。fnConstraintToEntryReqs( c: NudoConstraint, ): Array<{ param: string; constraint: NudoConstraint }>
FormalParamtypeC4.1:函数形参表面(contract surface)—— 侧车 fn({…}) / @nudo:contract 参数名与求值形参的对齐基线。FormalParam = | { kind: "id"; name: string; index: number; tsType?: string; optional?: boolean; } | { kind: "default"; name: string; inde...
formalParamDisplayNamesfn求值/签名用形参名(与 analyzer extractParamNames / dts 对齐)formalParamDisplayNames(formals: FormalParam[]): string[]
formalParamsFromNodesfn—formalParamsFromNodes( params: AstParam[] | undefined | null, source?: string, ): FormalParam[]
formalParamSignatureNamesfn签名展示名(C4.1 #64):解构形参渲染为 { grade, findings }, 不落回求值占位 _p0——否则读签名的人以为没有契约。formalParamSignatureNames(formals: FormalParam[]): string[]
formatAbsMultilinefn多行展示,CLI 用formatAbsMultiline(a: Abs, label?: string): string
formatContractTierLinefnCodeLens / hover 首行标题(design-refine-derivation §8):● contract / hw|gen|imp。formatContractTierLine(source: ContractSource, active = true): string
formatDiagnosticsfn—formatDiagnostics(diags: Diagnostic[]): string
formatEffectiveContractDisplayfnEffectiveContract → 契约展示串(与 CLI contract 打印同口径,不含函数名)formatEffectiveContractDisplay(eff: EffectiveContract): string
formatGithubAnnotationsfnGitHub Actions 行内注解(PR Files changed 红/黄标)。formatGithubAnnotations( r: CheckReport, opts: { workspaceRoot?: string } = {}, ): string
formatGitlabCodeQualityfnGitLab Code Quality 报告数组(--gitlab;可写 gl-code-quality-report.json)formatGitlabCodeQuality( r: CheckReport, opts: { workspaceRoot?: string } = {}, ): GitlabCodeQualityIssue[]
FormatOptionstype—FormatOptions = { showTerm?: boolean; showPred?: boolean; indent?: string; }
formatShapeSlotfnfn/arr 槽位:shape + 非 lit term(禁止在 format 里内联复制 term 逻辑)formatShapeSlot(a: Abs): string
geconst—const ge
generatedExportNamesfn侧车源码的生成段导出名:export 之前(跳过紧邻的 import 链与被 export 引用的 const 链)的注释行是 nudo 自己的 @generated 标记 → 该名为 generated。组合式下行段(§5.3)形态为 import + @generated 头 + prelude + export;callsite 段则是头紧贴 export。隔了其他代码行 / 无标记 / re-export 列表均不算。generatedExportNames(sidecarSrc: string): Set<string>
geNumfn—geNum(term: Term, n: number): Pred
getAbsPropertyfn属性读取:template/string.length 等getAbsProperty(recv: Abs, name: string): Abs | undefined
getEvalCallCollectorfn—getEvalCallCollector()
getEvalClassfn—getEvalClass(name: string): EvalClassSpec | undefined
getFnImplfn—getFnImpl(a: Abs): AbsFnImpl | undefined
getGeneralizeMemoSizefn—getGeneralizeMemoSize(): number
getImplicationOraclefn—getImplicationOracle(): ImplicationOracle | undefined
getPropFlagsfn—getPropFlags(o: Abs): Map<string, PropFlags> | undefined
getSlotfn自有槽位读取。slots 是普通对象,直接 slots[key] 会让 __proto__ / toString / valueOf 等键命中 Object.prototype 原型链,得到既非 slot 又 truthy 的原生值(历史 bug 模式,已两次复发)。所有跨来源 key 的槽位 读取必须走这里。getSlot<S extends { value: Abs }>( slots: Record<string, S>, key: string, ): S | undefined
getTermfn字段访问项:u.idgetTerm(obj: Term, key: string): Term
GitlabCodeQualityIssuetype—GitlabCodeQualityIssue = { description: string; check_name: string; fingerprint: string; severity: "major" | "minor" | "info" | "blocker"...
gtconst—const gt
gtNumfn便捷:数字下界gtNum(term: Term, n: number): Pred
HofSitetype——
hostBuiltinCtorNamefn宿主全局构造器身份(Number === (42).constructor 折叠用)hostBuiltinCtorName(v: unknown): string | undefined
hostFnCtorFacetfn宿主 JS 函数的可构造性(Bug 9):generator/async/async-generator 声明、 箭头、内建方法不可 new;bind 产物取决于目标(未知)。hostFnCtorFacet(v: Function): boolean | undefined
ImplicationOracletype外部蕴含 oracle(可选 SMT 等)。内建判定证不出时调用。ImplicationOracle = (phi: Phi, pred: Pred) => boolean | undefined
impliesfn简单蕴含:在区间/线性/字面量/typeof 可判定范围内判断 Φ ⊢ predimplies(phi: Phi, pred: Pred): boolean
instantiateReturnfnrelation-only / isRelFn 的应用:按 paramTypes 做 α 替换得到 returnType。instantiateReturn(fn: Abs, args: Abs[]): Abs
isAbsValfn—isAbsVal(v: unknown): v
isBigPrimfn—isBigPrim(a: Abs): boolean
isCjsMainRunfnrun 表是否来自 CJS module.exports = X 重赋值形态(供桥接层标 cjsMain)。isCjsMainRun(run: Record<string, unknown>): boolean
isDefinitelyFalsefn—isDefinitelyFalse(a: Abs): boolean
isDefinitelyTruefn—isDefinitelyTrue(a: Abs): boolean
isErrorCtorNamefn—isErrorCtorName(name: string | undefined): boolean
isIntFlagfnbuilder 与纯数据形态统一的 int 标志读取:纯数据看 int === true, builder(int 是链式方法)查 WeakSet。toPlainConstraint 归一化后只剩前者。isIntFlag(c: NudoConstraint): boolean
isMapAbsfn—isMapAbs(a: Abs | undefined): boolean
isNodeModulesPathconst——
isNudoBreakfn—isNudoBreak(e: unknown, label?: string): e
isNudoConstraintfn—isNudoConstraint(x: unknown): x
isNudoContinuefn—isNudoContinue(e: unknown, label?: string): e
isNudoReturnfn—isNudoReturn(e: unknown): e
isNudoThrowconst——
isNullishLitAbsfn仅当 term 确为 lit null/undefined 时为 true;非 lit 的 litValue===undefined 不得当 nullishisNullishLitAbs(a: Abs): boolean
isNullProtoObjfn—isNullProtoObj(o: Abs): boolean
isNumPrimfn—isNumPrim(a: Abs): boolean
isObjfn—isObj(a: Abs): a
isObjectProtoBrandfn—isObjectProtoBrand(a: Abs | undefined): boolean
isRelFnfn「有可用外延签名」判定:唯一权威定义。isRelFn(a: Abs | undefined | null): boolean
isSetAbsfn—isSetAbs(a: Abs | undefined): boolean
isStrPrimfn—isStrPrim(a: Abs): boolean
isSymbolAbsconst—const isSymbolAbs
joinFunctionsfn函数 join:签名并(重载),禁止 (A|C)→(B|D)。joinFunctions(a: Abs, b: Abs): Abs
joinObjectsfn对象 join:默认积之和(sum),不自动折 optional。joinObjects(a: Abs, b: Abs): Abs
joinThenProjectfn工件聚合投影(设计 §4.2:先 Abs join 折叠再投影)。joinThenProject(absList: Abs[]): NudoConstraint | undefined
lazyfnlazy(() => constraint):自引用约束模板(issue #120)。lazy( thunk: () => NudoConstraint | ConstraintBuilder, ): ConstraintBuilder
leconst—const le
leavePromiseExecutorScopefn—leavePromiseExecutorScope(settledArms: number[]): boolean
lenTermfn长度项:length(u)lenTerm(t: Term): Term
leNumfn—leNum(term: Term, n: number): Pred
LeqResulttype—LeqResult = { ok: boolean; reason?: string; }
listFunctionNamesfn列出源码中的顶层入口名。listFunctionNames(source: string): string[]
literalMeetsConstraintfn字面量 lv 是否落在约束 c 表达的域内(保守:判不了 → false)。literalMeetsConstraint( lv: LiteralValue, c: NudoConstraint, seen?: Set<object>, ): boolean
litTruthfnJS 真值:字面量按 Boolean(v);对象形恒真;不可判 → undefinedlitTruth(a: Abs): boolean | undefined
localNamedExportsfn源文件本地导出名表(侧车自动绑定边界): - ESM:export function/const/let/var/class 与本地 export { x } / export { local as exported }(按导出名绑定); - export default function add / const add = …; export default add: 按本地名 add 绑定(侧车可 export const add = fn(…)); 同时登记 "default",供侧车 export default fn(…) 对齐; - CJS(C4.3):module.exports = { a, b }、module.exports.a = …、 exports.a = …、module.exports = localFn(登记 localFn 名)。localNamedExports(source: string, filename?: string): Set<string>
locateContractParamfn契约参数名 → 形参定位。locateContractParam( formals: FormalParam[], contractName: string, )
lookupObjAccessorfn对象字面量访问器查询(供 $get/$set/$spread/Object.assign 共用)lookupObjAccessor( o: Abs, key: string, )
looseEqAbsfn宽松相等 ==(C2.3):双 lit 走 Abstract Equality;否则回落严格相等判定。looseEqAbs(a: Abs, b: Abs): boolean | undefined
ltconst—const lt
ltNumfn—ltNum(term: Term, n: number): Pred
makeArrayCtorAbsfn—makeArrayCtorAbs(args: Abs[]): Abs
makeMapAbsfn—makeMapAbs(iterable?: Abs): Abs
makeSetAbsfn—makeSetAbs(iterable?: Abs): Abs
makeSymbolAbsfnSymbol([description]):非具体 unique symbol(prim type=symbol,无 term)。makeSymbolAbs(descArg?: Abs): Abs
mapClearEntriesfnMap#clear:清空条目;fork 下仍走 overlaymapClearEntries(mapAbs: Abs): Abs
mapDeleteEntryfnMap#delete:fork overlay 内移除字面量键;未知 key 仅标 shadow 不确定。mapDeleteEntry(mapAbs: Abs, key: Abs | undefined): Abs
mapElementFallbackfnmap 元素投影:body 在符号实参上跑出 unknown 时, 用 shape.returnType 槽,conf 由调用方按 path/partial 处理。mapElementFallback( cbAbs: Abs | undefined, elem: Abs, out: Abs, ): Abs
mapEntriesAbsfnMap 迭代条目:JS for (const [k,v] of map) / Array.from(map) 产出 [key, value] 元组 Abs。字面量 key 精确;shadow 写入 key 为 unknown。mapEntriesAbs(mapAbs: Abs): Abs[]
mapGetEntryfnMap#get:命中字面量/身份 key → 精确;miss / 未知 key / maybeAbsent / shadow 并 undefinedmapGetEntry(mapAbs: Abs, key: Abs | undefined): Abs
mapHasEntryfnMap#has:字面量 miss 折 exact false 时,get 必须是 undefined(不可再并 value)mapHasEntry(mapAbs: Abs, key: Abs | undefined): Abs
mapSetEntryfnMap#set:fork 内写 overlay;否则原地。返回同一 Abs(JS 可变语义)mapSetEntry(mapAbs: Abs, key: Abs | undefined, value: Abs): Abs
mapSizeAbsfn—mapSizeAbs(mapAbs: Abs): Abs
mapValuesAbsfnMap#values:宿主按插入序产出(BUG-260);shadow 写入键未知 → 末尾mapValuesAbs(mapAbs: Abs): Abs[]
markExtStatefn—markExtState(o: Abs, s: ExtState): Abs
markNullProtoObjfn—markNullProtoObj(o: Abs): Abs
markPureFnfn标记纯函数(@nudo:pure):调用结果可按实参记忆化markPureFn(target: object, name: string): void
matchRelIdentLitfn从 Identifier 在比较中的位置解析「对哪个变量、用哪个关系」。matchRelIdentLit( test: unknown, )
MAX_EVAL_CALL_DEPTHconstB 命名调用深度上限——与 A 路径同值(@nudo:budget 可逐函数抬高)const MAX_EVAL_CALL_DEPTH
MAX_EVAL_TOTAL_CALLSconstB 命名调用总调用上限——与 A 路径同值(递归×循环×分支展开的规模阀)const MAX_EVAL_TOTAL_CALLS
mergeCollectionArmsfn合并 fork 各臂 overlay → 全局表(由 endCollectionFork 实现)。mergeCollectionArms(arms: Array<ArmOverlay | undefined | null>): void
migrateInvariantsfn写路径产生新副本时迁移不变性侧表(同 migrateAccessors 模式)。migrateInvariants(from: Abs, to: Abs): void
migrateNullProtofn同一对象的不可变更新($set/$del)迁移 nullProto 标记migrateNullProto(from: Abs, to: Abs): Abs
modfn取模:字面量折叠;x % k(k 为有限非零字面量)仅当被除数有限时 结果界在 (−|k|, |k|)。整数模可收紧到 [0, k),此处先做保守实数界。mod(a: Abs, b: Abs, phi: Phi = pTrue): Abs
mulfn乘法:字面量直接求值;×正数同向缩放;×负数翻转不等式;×0 归零mul(a: Abs, b: Abs, phi: Phi = pTrue): Abs
NamedImporttype/// @nudo:import { delay, percent } from "./delay.nudo.js"NamedImport = { names: string[]; spec: string }
namespaceAbsOffn命名空间 Abs(import * as ns / export * as ns / CJS require 绑定): open + path——导出收集可能不全(CJS 收集失败等),缺失成员是分析 视图不完整,不得按「运行时缺失」判定(不可调用判定会假抛 TypeError)。namespaceAbsOf(mod: AbsModuleExports): Abs
namespaceNameOffn—namespaceNameOf(v: unknown): string | undefined
neconst—const ne
negAbsfn一元负号:字面量折叠(含 ToNumber 强制);符号数翻转不等式negAbs(a: Abs, _phi: Phi = pTrue): Abs
negatePredfn逻辑否定(De Morgan):¬(A∧B)=¬A∨¬B;¬(A∨B)=¬A∧¬B;双重否定消去。negatePred(p: Pred): Pred
notfn—not(p: Pred): Pred
notAbsfn逻辑非notAbs(a: Abs): Abs
noteCollectionWritefn—noteCollectionWrite(id: object): void
noteEvalCallRecordfn成员/方法调用点打点($invoke 等;无收集器时 no-op)。不进 $callNamed 预算。noteEvalCallRecord(r: EvalCallRecord): void
noteEvalFallbackfn记录一次 B 回落(body-fn / tryRunTranspiled / call 边界兜底共用)。noteEvalFallback( e: unknown, origin: EvalFallbackOrigin = "module", opts?: { loadFailure?: boolean }, ): void
notePromiseExecutorForkfn$fork 在 executor 内发生时打点(多臂 resolve 需 join,不得 first-wins 假精确)notePromiseExecutorFork(): void
NudoFieldtype—NudoField = { constraint: NudoConstraint; optional?: boolean; }
NudoFnConstrainttypefn(params, returns?, { throws?NudoFnConstraint = { params: Record<string, NudoConstraint>; returns?: NudoConstraint; throws?: NudoConstraint; }
NudoSidecarErrorfn侧车模块错误:code ∈ nudo:contract-cycle | nudo:contract-loadNudoSidecarError extends Error { readonly code: string; constructor(code: string, message: string) { super(message); this.name = "NudoSid...
NudoSigtype无损函数签名(类型即计算)NudoSig = { name: string; params: string[]; paramTypes?: string[]; abs: Abs; display: string; detail: string; conf: Confidence; throws?: ...
NudoUnsupportedErrorfn转译器无法正确 lowering 的构造:抛此错误(替代静默降级注释)。NudoUnsupportedError extends Error { readonly reason: string; readonly loc?: { line: number; column: number }; constructor( reason: strin...
nullablefnnullable(c):允许 null / undefined 的约束(nullish 显式化)。nullable( c: NudoConstraint | ConstraintBuilder | number | string | boolean, ): ConstraintBuilder
numVarfn带项的符号数,例如参数 xnumVar(id: string, pred?: Pred, conf: Confidence = "path"): Abs
OBJECT_PROTO_METHOD_NAMESconst—const OBJECT_PROTO_METHOD_NAMES
objectProtoBrandfnObject.prototype 单例($get(Object, "prototype") 与 host Object.prototype 共用)。objectProtoBrand(): Abs
objectProtoMethodAbsfnObject.prototype.X 一等函数(bindThis:call/apply 把 receiver 注入首参)objectProtoMethodAbs(name: string): Abs
objOffn—objOf( slots: Record<string, Slot>, opts?: { index?: { key: Abs; value: Abs }; open?: boolean }, ): Abs
omitfnomit(c, keys):shape 去字段;非 shape throw(lazy 包装先解一层)。omit( c: NudoConstraint | ConstraintBuilder, keys: string[], ): ConstraintBuilder
orfn—or(...preds: Pred[]): Pred
partialfnpartial(c):shape 全字段变可选;非 shape throw(lazy 包装先解一层)。partial(c: NudoConstraint | ConstraintBuilder): ConstraintBuilder
pFalseconst—const pFalse
phiAndconst—const phiAnd
pickfnpick(c, keys):shape 子形状(不存在的 key 忽略);非 shape throw(lazy 包装先解一层)。pick( c: NudoConstraint | ConstraintBuilder, keys: string[], ): ConstraintBuilder
PolyFntype—PolyFn = { name: string; params: string[]; typeParams: TypeParam[]; instantiate: (args: Abs[], phi?: Phi) => Abs; symbolic: Abs; display:...
popCollectionArmfn—popCollectionArm(): ArmOverlay | undefined
powAbsfn—— 幂(右结合由 AST 保证);负指数 bigint 原生 RangeError → 不可折叠powAbs(a: Abs, b: Abs): Abs
predEqualsfn—predEquals(a: Pred, b: Pred): boolean
predToStringfn—predToString(p: Pred): string
predVarsfn收集 pred 中出现的自由变量predVars(p: Pred): Set<string>
PrimNametype—PrimName = "number" | "string" | "boolean" | "bigint" | "symbol"
primToTypeoffnabs prim 标签 → typeof 标签(恒等嵌入)。abs prim 仍是 PrimName 子集。primToTypeof(p: PrimName): TypeofName
projectFlatMapResultfnflatMap 统一结果:展开后的元素 join 成 arr(γ)。projectFlatMapResult( arrConf: Confidence, mapped: Abs[], ): Abs
propertyKeyOffnES ToPropertyKey 的折叠:null→"null"、undefined→"undefined"、 true/false→"true"/"false"、number/bigint/string → String(v)(ToString)。propertyKeyOf(a: Abs | undefined): string | undefined
PropFlagstype—PropFlags = { writable?: boolean; enumerable?: boolean; configurable?: boolean; }
protoBrandAbsfn—protoBrandAbs(ctorName: string): Abs
protoOfRecvfnObject.getPrototypeOf 的具体原型投影(constructor 链可解)。protoOfRecv(a: Abs): Abs
pTrueconst—const pTrue
ptypeofconst—const ptypeof
pureFnNameOffn读纯函数标记(Abs impl 或对象属性 _memoize)pureFnNameOf(fn: unknown): string | undefined
pushCollectionArmfn—pushCollectionArm(): void
pushLoopExitfn—pushLoopExit(v: Abs): void
pushThrowExitfn—pushThrowExit(v: Abs): void
queuePromiseMicrofn—queuePromiseMicro(task: () => void): void
RefineDiagtyperefine 侧车加载诊断(severity 由消费方按 code 定档,形状对齐 Issue 子集)RefineDiag = { code: string; message: string; file?: string; line?: number; column?: number; }
refineDiagCountfn当前诊断累计序号(since 锚)refineDiagCount(): number
RefineEntrytype同时保留原始 NudoConstraint(shape 字段检查用)。RefineEntry = { param: string; pred: Pred; constraint: NudoConstraint; name?: string; }
RefineResolveOptstype—RefineResolveOpts = { loadModule?: (spec: string, fromFile: string) => string | undefined; fromFile?: string; }
refineToIndexedFullfnrefine 参数 → 带约束模板的下标表(shape 检查用)refineToIndexedFull( source: string, fnName: string, paramNames: string[], opts: RefineResolveOpts = {}, ): Array<[number, RefineEntry]>
regexBrandAbsFromfnRegExp brand:source/flags/lastIndex + 7 标志 getter 进 slots (evaluator evalRegExpCtor / $regex 共用;槽构造收敛于 regexpBrandSlots)regexBrandAbsFrom(pattern: string, flags: string): Abs
registerEvalClassfn注册类规格(裸名主键 + epoch 碰撞记录——BUG-026/172 注释群)。registerEvalClass(spec: EvalClassSpec): void
relationFingerprintfnrelationFn 稳定 fingerprint(同签名共享,见 §3.3 已知限制)。relationFingerprint( paramTypes: Abs[], returnType: Abs, ): string
relationFnfn无 body、纯关系的 fn Abs。params 仅记 arity。relationFn( paramTypes: Abs[], returnType: Abs, opts?: { params?: string[]; conf?: Confidence; fingerprint?: string; inferFrom?: { fromVar: string; via: "arr" | "promise"; inferVar: string }; condFallback?: Abs; throws?: Abs; }, ): Abs
RelSourcetype——
requiredFnArityfnRequired arity from fn param labels — skips rest (...) and optional (?).requiredFnArity(params: readonly string[] | undefined): number
resetCheckSourceMemofn—resetCheckSourceMemo(): void
resetEvalCallBudgetfn宿主入口前强制清零(测试 / 显式 API)。执行入口请用 enterEvalCallBudgetSession。resetEvalCallBudget(): void
resetGeneralizeMemofn—resetGeneralizeMemo(): void
resetNudoModuleExecCachefn—resetNudoModuleExecCache(): void
resetSidecarLoadFailureCachefn与 resetNudoModuleExecCache 同口径:分析会话/测试间清空失败去重表resetSidecarLoadFailureCache(): void
RUNTIME_IMPORT_REconst——
RunTranspiledOptionstype—RunTranspiledOptions = { modules?: Record<string, AbsModuleExports | Record<string, unknown>>; maxLoopIters?: number; mode?: "exec" | "an...
runTranspiledOptionsMemoKeyfninject/modules 内容指纹(memo 键)。对象身份对「每次新建同内容」 的 CLI 注入不稳——同一语义的 inject 跨 checkSource 调用会 miss 缓存。runTranspiledOptionsMemoKey( opts: RunTranspiledOptions | undefined, ): string
runWithLoopExitsfn函数求值作用域:收集抽象分支上的 early-return / throw 值;try 标记栈同边界runWithLoopExits<T>(body: () => T): T
scanCaseArgSpansfncase 实参区间(供其它标签做遮罩)scanCaseArgSpans(text: string)
SELFconst模板占位项;instantiate 时换成真实参数名const SELF
setAddEntryfnSet#add:fork 内写 overlay;返回同一 AbssetAddEntry(setAbs: Abs, value: Abs): Abs
setApplyCallbackHostfnevaluator 宿主 exec/call.ts 加载时注册(副作用)。setApplyCallbackHost(fn: ApplyCallbackHost): void
setClearEntriesfnSet#clearsetClearEntries(setAbs: Abs): Abs
setContractDiagCollectorfn设置诊断观察者(null 清除);缓冲照常累积,takeContractDiags 取走setContractDiagCollector( fn: ((d: ContractDiag) => void) | null, ): void
setDeleteEntryfnSet#delete:按字面量/身份元素移除;fork overlay 内生效。setDeleteEntry(setAbs: Abs, value: Abs): Abs
setElementsAbsfn—setElementsAbs(setAbs: Abs): Abs[]
setEvalAssignCollectorfn返回先前 collector,便于嵌套调用 save/restore(禁止 finally 置 null 砸外层)setEvalAssignCollector( collector: ((r: EvalAbsAssignRecord) => void) | null, )
setEvalBindingSinkfn—setEvalBindingSink(sink: Map<string, unknown> | null): void
setEvalFallbackCollectorfn—setEvalFallbackCollector( collector: ((f: EvalFallback) => void) | null, ): void
setHasEntryfn—setHasEntry(setAbs: Abs, value: Abs): Abs
setImplicationOraclefn—setImplicationOracle(fn: ImplicationOracle | undefined): void
setPosCollectorfn返回先前 collector,便于嵌套调用 save/restore(禁止 finally 置 null 砸外层)setPosCollector( collector: ((r: EvalPosRecord) => void) | null, )
setPropFlagsfn—setPropFlags(o: Abs, key: string, f: PropFlags): void
setRefineDiagCollectorfn设置诊断观察者(null 清除);缓冲照常累积,takeRefineDiags 取走setRefineDiagCollector(fn: ((d: RefineDiag) => void) | null): void
setSizeAbsfn—setSizeAbs(setAbs: Abs): Abs
shapeOfTermfn从 term 反推 prim shapeshapeOfTerm(t: Term): Shape
shapeOnlyFnfn仅写 shape 槽(E 路径 / §5.2 提升产物);禁止 attachFnImplshapeOnlyFn( paramTypes: Abs[], returnType: Abs, opts?: { params?: string[]; conf?: Confidence }, ): Abs
shapeToStringfn—shapeToString(s: Shape): string
shlAbsfn<< —— 左移(rhs ToUint32 & 31;bigint 不限位宽)shlAbs(a: Abs, b: Abs): Abs
shrAbsfn>> —— 算术右移(rhs ToUint32 & 31;bigint 不限位宽)shrAbs(a: Abs, b: Abs): Abs
sidecarClosureFingerprintfn侧车及递归 .nudo 依赖闭包的内容指纹:${hashSource(侧车)}|路径=hash,…。sidecarClosureFingerprint( fromFile: string, opts: EffectiveContractOpts, ): string | undefined
sidecarPathOfconst——
simplifyTermfn常量折叠 + 简单代数化简simplifyTerm(t: Term): Term
snapshotAbsfndeep-ish copy for snapshot(新对象,不是 env.vars 同一引用)snapshotAbs(a: Abs): Abs
spreadfnspread:base ⊕ over(右侧覆盖,不是 join) 未出现在 over 的 key 保留 base;over 的 key 覆盖。spread(base: Abs, over: Abs): Abs
strictEqAbsfn严格相等(Abs):双字面量折叠;nullish 与 definitely-not-nullish → false。strictEqAbs(a: Abs, b: Abs): boolean | undefined
stringOfSymbolfnString(sym) → SymbolDescriptiveString(原生不抛;隐式 ToString 才抛)stringOfSymbol(a: Abs): Abs
subfn减法:a - b = a + (-b),数值上做单调性sub(a: Abs, b: Abs, phi: Phi = pTrue, assume?: Phi): Abs
substAbsfnα 替换:map 的 key 是 term var id,value 是替换 Abs。substAbs(a: Abs, map: ReadonlyMap<string, Abs>): Abs
substPredfn把 pred 里的 Term 用 subst 替换(用于 bound 变量重命名等)substPred(p: Pred, subst: (t: Term) => Term): Pred
substPredAbsfnpred 三条规则: 1.substPredAbs( p: Pred, map: ReadonlyMap<string, Abs>, )
symbolDescriptionAbsconst——
symbolIdOfconst——
takeContractDiagsfn取走已收集的诊断(收集即清空)takeContractDiags(): ContractDiag[]
takeContractDiagsSincefn只取走 seq > since 的诊断(清空仅限增量)——LSP 长驻进程里 lens/打印/ emit 工具用它排干自身探测产生的诊断,不窃取在途 validateText 待消费 的契约诊断(全量 take 曾在 await 窗口偷走 checkSource 的待收诊断)。takeContractDiagsSince(since: number): ContractDiag[]
takeLoopExitsfn—takeLoopExits(): Abs[]
takeRefineDiagsfn取走已收集的诊断(收集即清空)takeRefineDiags(): RefineDiag[]
takeRefineDiagsSincefn只取走 seq > since 的增量(工具面防窃取在途诊断;全量 take 的 since 版)takeRefineDiagsSince(since: number): RefineDiag[]
takeThrowExitsfn—takeThrowExits(): Abs[]
termEqualsfn—termEquals(a: Term, b: Term): boolean
termToStringfn—termToString(t: Term): string
throwConstraintToKindsfnfn(..., { throws }) / throws 约束 → 申报的 throws 类型名。throwConstraintToKinds( c: NudoConstraint | undefined, ): string[]
toNumberAbsfn一元 + —— ToNumber 折叠;bigint(含抽象 prim)原生恒抛 TypeError → 硬抛toNumberAbs(a: Abs): Abs
trueConstraintfn从比较结果 Abs 提取「若为真」的额外约束(供 if 使用)trueConstraint(c: Abs): Pred | undefined
tryMakeRegexAbsfnnew RegExp(pattern, flags) 字面量真构造验证($new 与 evalRegExpCtor 共用): - 无参 → /(?:)/(原生 source 归一) - symbol pattern/flags → 确定 TypeError(ToString 抛;shape 判定——Symbol() 无 lit 项,原先的 lit 分支内检查是死代码,Bug 29/52) - 非法 pattern / 非法 flags(含 number/null/boolean flags 的 ToString) → SyntaxError;合法 → 精确 brand(source/flags 取真构造结果) - 抽象 pattern/flags → undefined(调用方保守)+ 档位打点(见各分支): obj/fn/brand/sum/any → may TypeError(自定义 coercer 可能产 Symbol); 抽象 prim string pattern → ToString total(非法 pattern 的 SyntaxError 面不计);抽象 prim string flags → may SyntaxError;抽象 prim number/bool/bigint flags → ToString 恒非法 flags → 确定 SyntaxError (node 实测 new RegExp('a', 1n) → SyntaxError)tryMakeRegexAbs(args: Abs[]): Abs | undefined
tryRunTranspiledfn—tryRunTranspiled( source: string, opts: RunTranspiledOptions = {}, ): Record<string, unknown> | undefined
TYPEOF_NAMESconsttypeof 标签全集(否定展开用;顺序稳定)const TYPEOF_NAMES
typeofAbsfnJS typeof:结果域永远是 stringtypeofAbs(a: Abs): Abs
TypeofNametypeJS typeof 完整结果域(8 标签)。Pred 的 typeof 节点用此域。TypeofName = | "undefined" | "object" | "boolean" | "number" | "bigint" | "string" | "symbol" | "function"
TypeParamtype—TypeParam = { id: string; value: Abs; bounds?: readonly import("./pred.ts").Pred[]; }
undefAbsfnundefined 值的统一 Abs 表示(forEach/find 等)undefAbs(): Abs
ushrAbsfn>>> —— 逻辑右移(rhs ToUint32 & 31;bigint 无此运算符 → 不可折叠)ushrAbs(a: Abs, b: Abs): Abs
withExecPhifn—withExecPhi<T>(p: Phi, body: () => T): T
withVarfn—withVar(env: AstEnv, name: string, value: Abs): AstEnv