@scriptc/compiler 0.0.9 → 0.0.10
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.
- package/dist/backend/emission/emit-exprs.js +136 -12
- package/dist/backend/emission/emit-exprs.js.map +1 -1
- package/dist/backend/emission/emit-walkers.js +29 -2
- package/dist/backend/emission/emit-walkers.js.map +1 -1
- package/dist/backend/llvm/dyn.d.ts +1 -0
- package/dist/backend/llvm/dyn.js +83 -1
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +151 -9
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/diagnostics/diagnostic.d.ts +21 -7
- package/dist/diagnostics/diagnostic.js +35 -16
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/diagnostics/render.js +8 -0
- package/dist/diagnostics/render.js.map +1 -1
- package/dist/frontend/lowering/lib-boundary.js +11 -1
- package/dist/frontend/lowering/lib-boundary.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +13 -0
- package/dist/frontend/lowering/lower-builtins.js +146 -1
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +41 -0
- package/dist/frontend/lowering/lower-calls.js +524 -10
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.d.ts +17 -0
- package/dist/frontend/lowering/lower-containers.js +193 -10
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-dgram.js +92 -17
- package/dist/frontend/lowering/lower-dgram.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +179 -10
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.js +33 -2
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.d.ts +25 -11
- package/dist/frontend/lowering/lower-namespaces.js +50 -15
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.js +211 -4
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +1 -5
- package/dist/frontend/lowering/lower-stmts.js +216 -7
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.js +65 -4
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +36 -1
- package/dist/frontend/lowering/lowerer.js +106 -3
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/types.d.ts +13 -0
- package/dist/frontend/types.js +84 -7
- package/dist/frontend/types.js.map +1 -1
- package/dist/index.js +20 -8
- package/dist/index.js.map +1 -1
- package/dist/ir/nodes.d.ts +99 -5
- package/dist/ir/nodes.js +44 -3
- package/dist/ir/nodes.js.map +1 -1
- package/dist/ir/validate.js +53 -3
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/fence-eval.d.ts +77 -0
- package/dist/library/fence-eval.js +385 -0
- package/dist/library/fence-eval.js.map +1 -0
- package/dist/library/profile.d.ts +11 -1
- package/dist/library/profile.js +102 -18
- package/dist/library/profile.js.map +1 -1
- package/package.json +2 -2
- package/surface-manifest.json +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type SurfaceEntryKind } from "../coverage/surface-manifest.js";
|
|
2
|
+
import { type ScrDiagnostic } from "../diagnostics/diagnostic.js";
|
|
3
|
+
import type { IrModule } from "../ir/nodes.js";
|
|
4
|
+
/** One raw fence declaration as the profile spelled it (validated for
|
|
5
|
+
* shape by the loader; resolved here against the manifest). */
|
|
6
|
+
export interface LibraryFenceDecl {
|
|
7
|
+
/** JSON path for exact-path refusals: `determinism.fences[2]`. */
|
|
8
|
+
path: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
prefix?: string;
|
|
11
|
+
teaching?: string;
|
|
12
|
+
remediation?: string;
|
|
13
|
+
}
|
|
14
|
+
/** The IR facts that witness one surface's reach in the compiled graph.
|
|
15
|
+
* A surface is reached exactly when any listed fact appears. */
|
|
16
|
+
interface SurfaceDetector {
|
|
17
|
+
libFns?: readonly string[];
|
|
18
|
+
strMethods?: readonly string[];
|
|
19
|
+
arrMethods?: readonly string[];
|
|
20
|
+
mapMethods?: readonly string[];
|
|
21
|
+
setMethods?: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
/** One manifest entry a fence covers, resolved and load-validated. */
|
|
24
|
+
export interface FencedSurface {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
kind: SurfaceEntryKind;
|
|
28
|
+
/** The diagnostic code the manifest entry carries (every non-static
|
|
29
|
+
* entry has one) — the code whose refusal the fence teaching rides. */
|
|
30
|
+
code?: string;
|
|
31
|
+
/** Present exactly when the entry is static (it compiles, so the fence
|
|
32
|
+
* must deny it): the reach witness. Absent = the surface already
|
|
33
|
+
* refuses with `code` and the fence changes only the message. */
|
|
34
|
+
detector?: SurfaceDetector;
|
|
35
|
+
}
|
|
36
|
+
export interface ResolvedLibraryFence {
|
|
37
|
+
/** The declared selector, for messages: `id 'stdlib.math.random'` or
|
|
38
|
+
* `prefix 'node-builtin.fs.'`. */
|
|
39
|
+
declared: string;
|
|
40
|
+
teaching?: string;
|
|
41
|
+
remediation?: string;
|
|
42
|
+
surfaces: readonly FencedSurface[];
|
|
43
|
+
}
|
|
44
|
+
/** Resolve the profile's fence declarations against this compiler
|
|
45
|
+
* release's surface manifest. Every failure returns the exact-path detail
|
|
46
|
+
* the loader wraps as SC4001. Selector strictness is RATIFIED: an id or
|
|
47
|
+
* prefix matching nothing refuses; a covered static entry no detector can
|
|
48
|
+
* police refuses (loudly, never silently inert). Compile-time-folded
|
|
49
|
+
* constants refuse as `id` fences (the message says why) and are exempt
|
|
50
|
+
* under a `prefix` — the family sweep stays usable, and the fold means
|
|
51
|
+
* there is genuinely nothing at runtime to deny. */
|
|
52
|
+
export declare function resolveLibraryFences(decls: readonly LibraryFenceDecl[]): {
|
|
53
|
+
ok: true;
|
|
54
|
+
fences: ResolvedLibraryFence[];
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
detail: string;
|
|
58
|
+
};
|
|
59
|
+
/** The structural slice of LibraryProfile the fence machinery reads —
|
|
60
|
+
* kept structural so this module never value-imports the loader. */
|
|
61
|
+
export interface FenceProfileView {
|
|
62
|
+
name: string;
|
|
63
|
+
teachings: Readonly<Record<string, string>>;
|
|
64
|
+
fences: readonly ResolvedLibraryFence[];
|
|
65
|
+
}
|
|
66
|
+
/** Evaluate the profile's fences against the COMPILED module graph: every
|
|
67
|
+
* fenced static surface the graph reaches refuses as SC4008, anchored at
|
|
68
|
+
* the reaching construct, the fence's teaching attached as the attributed
|
|
69
|
+
* note. Unreached fences add nothing; a profile whose fences carry no
|
|
70
|
+
* detector-backed surface skips the walk entirely. */
|
|
71
|
+
export declare function evaluateLibraryFences(mod: IrModule, profile: FenceProfileView): ScrDiagnostic[];
|
|
72
|
+
/** Attach the profile's teaching text to every library-mode refusal it
|
|
73
|
+
* names — by code, by manifest id, or through a fence — as the visibly
|
|
74
|
+
* attributed `note`. Diagnostics already carrying a note (SC4008 threads
|
|
75
|
+
* its fence's teaching at mint time) pass through unchanged. */
|
|
76
|
+
export declare function decorateLibraryRefusals(diagnostics: ScrDiagnostic[], profile: FenceProfileView): ScrDiagnostic[];
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/* Ask-5 determinism fences + the generalized teaching decoration.
|
|
2
|
+
*
|
|
3
|
+
* The profile's `determinism.fences` array denies surfaces BY SURFACE-
|
|
4
|
+
* MANIFEST ID (coverage/surface-manifest.ts — the compiler's one stable
|
|
5
|
+
* surface taxonomy; no new vocabulary). Resolution happens at profile
|
|
6
|
+
* load, against the manifest generated from this compiler's own tables:
|
|
7
|
+
*
|
|
8
|
+
* - an `id` names exactly one manifest entry; a `prefix` fences every
|
|
9
|
+
* entry it string-prefixes. An id or prefix matching NOTHING refuses
|
|
10
|
+
* loudly at load (ratified): fences pin to a compiler release's
|
|
11
|
+
* manifest, and a silently-inert fence is a footgun, so there is no
|
|
12
|
+
* forward-compatible acceptance of unknown selectors.
|
|
13
|
+
* - a fenced entry the static tier refuses anyway (status not "static")
|
|
14
|
+
* needs no new machinery: the surface's own refusal fires, and the
|
|
15
|
+
* fence's teaching rides it as the attributed note (spec §1: "changes
|
|
16
|
+
* only the message").
|
|
17
|
+
* - a fenced STATIC entry is policed against the COMPILED module graph:
|
|
18
|
+
* the emit pass lowers only reachability-discovered bodies, so the
|
|
19
|
+
* module IR *is* the reached graph — the same ground the sidecar's
|
|
20
|
+
* `deterministic` attestation stands on (ir/nodes.ts's
|
|
21
|
+
* moduleLibNondeterministicSurface). Fence evaluation reuses that
|
|
22
|
+
* posture with one generic walk collecting the reached surface facts
|
|
23
|
+
* (libCall spellings, str/arr/map/set intrinsic methods); each fenced
|
|
24
|
+
* entry then answers by table-derived detector. Unreached fences cost
|
|
25
|
+
* exactly this one walk — and no walk at all when no fence declares a
|
|
26
|
+
* detector-backed surface.
|
|
27
|
+
* - a fenced static entry with NO honest detector refuses at load,
|
|
28
|
+
* never accepted-and-ignored. Two families are named specifically:
|
|
29
|
+
* compile-time-folded constants (os.EOL, path.sep — the artifact
|
|
30
|
+
* performs no runtime read a fence could deny) and desugared surfaces
|
|
31
|
+
* (array map/filter/forEach and friends lower to plain loops with no
|
|
32
|
+
* distinct trace).
|
|
33
|
+
*
|
|
34
|
+
* Detectors derive MECHANICALLY from the same lowering tables the
|
|
35
|
+
* manifest projects from (frontend/lowering/surfaces.ts), so a table row
|
|
36
|
+
* added later grows the fenceable surface without hand maintenance. Two
|
|
37
|
+
* aliased-lowering facts are inherited from the tables and deliberate:
|
|
38
|
+
* string trimLeft/trimRight share trimStart/trimEnd's IR method, and
|
|
39
|
+
* querystring decode/encode share parse/stringify's libCall — fencing one
|
|
40
|
+
* spelling fences the operation.
|
|
41
|
+
*
|
|
42
|
+
* decorateLibraryRefusals is the generalized teaching rider (spec §2):
|
|
43
|
+
* profile text attaches to ANY library-mode refusal by diagnostic code
|
|
44
|
+
* (the ratified SC4004/SC4005 rider's keys, "async" shared-key fallback
|
|
45
|
+
* included), by manifest id (matched against the refusal's code plus the
|
|
46
|
+
* entry's surface name in the message; diagnostic-fence entries match on
|
|
47
|
+
* code alone — the entry IS the code family), or by a fence entry
|
|
48
|
+
* covering the refused surface. The text renders as the diagnostic's
|
|
49
|
+
* `note`, always prefixed with the profile's name — the tool's message
|
|
50
|
+
* stays the tool's. */
|
|
51
|
+
import { generateSurfaceManifest } from "../coverage/surface-manifest.js";
|
|
52
|
+
import { libFenceDiag } from "../diagnostics/diagnostic.js";
|
|
53
|
+
import { BUILTIN_MODULE_CONSTS, BUILTIN_MODULE_FNS, STATIC_MATH_FNS, STR_METHODS, } from "../frontend/lowering/surfaces.js";
|
|
54
|
+
import { compilerReleaseVersion } from "./sidecar.js";
|
|
55
|
+
let taxonomy = null;
|
|
56
|
+
function builtinRootId(mod) {
|
|
57
|
+
return `node-builtin.${mod.split("/").join(".")}`;
|
|
58
|
+
}
|
|
59
|
+
function fenceTaxonomy() {
|
|
60
|
+
if (taxonomy !== null)
|
|
61
|
+
return taxonomy;
|
|
62
|
+
const manifest = generateSurfaceManifest(compilerReleaseVersion());
|
|
63
|
+
const byId = new Map(manifest.entries.map((e) => [e.id, e]));
|
|
64
|
+
const builtinFns = new Map();
|
|
65
|
+
const builtinRoots = new Map();
|
|
66
|
+
const foldedIds = new Set();
|
|
67
|
+
for (const [mod, members] of Object.entries(BUILTIN_MODULE_FNS)) {
|
|
68
|
+
const root = new Set();
|
|
69
|
+
for (const [member, entry] of Object.entries(members)) {
|
|
70
|
+
if (entry === undefined)
|
|
71
|
+
continue;
|
|
72
|
+
const fns = new Set([entry.fn]);
|
|
73
|
+
// The bare-path and url tables rebind per TARGET platform
|
|
74
|
+
// (builtinModuleFnsOf): a fence on the bare id covers both flavors.
|
|
75
|
+
if (mod === "path") {
|
|
76
|
+
const w = BUILTIN_MODULE_FNS["path/win32"]?.[member];
|
|
77
|
+
if (w !== undefined)
|
|
78
|
+
fns.add(w.fn);
|
|
79
|
+
}
|
|
80
|
+
if (mod === "url" && member === "pathToFileURL")
|
|
81
|
+
fns.add("url.pathToFileURLWin32");
|
|
82
|
+
builtinFns.set(`${builtinRootId(mod)}.${member}`, [...fns]);
|
|
83
|
+
for (const f of fns)
|
|
84
|
+
root.add(f);
|
|
85
|
+
}
|
|
86
|
+
if (root.size > 0)
|
|
87
|
+
builtinRoots.set(builtinRootId(mod), [...root]);
|
|
88
|
+
}
|
|
89
|
+
for (const [mod, members] of Object.entries(BUILTIN_MODULE_CONSTS)) {
|
|
90
|
+
for (const member of Object.keys(members))
|
|
91
|
+
foldedIds.add(`${builtinRootId(mod)}.${member}`);
|
|
92
|
+
}
|
|
93
|
+
taxonomy = { byId, ids: manifest.entries.map((e) => e.id), builtinFns, builtinRoots, foldedIds };
|
|
94
|
+
return taxonomy;
|
|
95
|
+
}
|
|
96
|
+
/* ── classification: what policing a static entry means ───────────────── */
|
|
97
|
+
/** Array methods with a distinct IR trace (arrIntrinsic methods). `push`
|
|
98
|
+
* includes the spread spelling — `a.push(...xs)` lowers to pushSpread and
|
|
99
|
+
* is the same surface. The rest of ARRAY_METHODS desugars to plain loops. */
|
|
100
|
+
const ARR_DETECTABLE = {
|
|
101
|
+
push: ["push", "pushSpread"],
|
|
102
|
+
pop: ["pop"],
|
|
103
|
+
indexOf: ["indexOf"],
|
|
104
|
+
includes: ["includes"],
|
|
105
|
+
join: ["join"],
|
|
106
|
+
slice: ["slice"],
|
|
107
|
+
};
|
|
108
|
+
const MAP_DETECTABLE = new Set(["get", "set", "has", "delete", "clear"]);
|
|
109
|
+
const SET_DETECTABLE = new Set(["add", "has", "delete", "clear"]);
|
|
110
|
+
const DESUGARED_WHY = "it desugars at compile time into plain loops over iteration primitives, so the compiled graph carries no distinct trace to police";
|
|
111
|
+
function classifySurface(entry, tax) {
|
|
112
|
+
// Non-static entries already refuse with their own code wherever they
|
|
113
|
+
// are reached — the fence's teaching rides that refusal.
|
|
114
|
+
if (entry.status !== "static")
|
|
115
|
+
return { kind: "refusal" };
|
|
116
|
+
if (tax.foldedIds.has(entry.id)) {
|
|
117
|
+
return {
|
|
118
|
+
kind: "unfenceable",
|
|
119
|
+
why: "reads of it fold to a per-binary constant at compile time — the artifact performs no runtime read a fence could deny",
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const builtinFns = tax.builtinFns.get(entry.id);
|
|
123
|
+
if (builtinFns !== undefined)
|
|
124
|
+
return { kind: "detector", detector: { libFns: builtinFns } };
|
|
125
|
+
const rootFns = tax.builtinRoots.get(entry.id);
|
|
126
|
+
if (rootFns !== undefined)
|
|
127
|
+
return { kind: "detector", detector: { libFns: rootFns } };
|
|
128
|
+
const [, family, member] = entry.id.split(".");
|
|
129
|
+
if (entry.id.startsWith("stdlib.") && family !== undefined && member !== undefined) {
|
|
130
|
+
if (family === "math") {
|
|
131
|
+
const fn = Object.hasOwn(STATIC_MATH_FNS, member) ? STATIC_MATH_FNS[member] : undefined;
|
|
132
|
+
if (fn !== undefined)
|
|
133
|
+
return { kind: "detector", detector: { libFns: [fn.fn] } };
|
|
134
|
+
}
|
|
135
|
+
if (family === "string") {
|
|
136
|
+
const m = Object.hasOwn(STR_METHODS, member) ? STR_METHODS[member] : undefined;
|
|
137
|
+
if (m !== undefined)
|
|
138
|
+
return { kind: "detector", detector: { strMethods: [m.method] } };
|
|
139
|
+
}
|
|
140
|
+
if (family === "array") {
|
|
141
|
+
const methods = Object.hasOwn(ARR_DETECTABLE, member) ? ARR_DETECTABLE[member] : undefined;
|
|
142
|
+
if (methods !== undefined)
|
|
143
|
+
return { kind: "detector", detector: { arrMethods: methods } };
|
|
144
|
+
return { kind: "unfenceable", why: DESUGARED_WHY };
|
|
145
|
+
}
|
|
146
|
+
if (family === "map") {
|
|
147
|
+
if (MAP_DETECTABLE.has(member))
|
|
148
|
+
return { kind: "detector", detector: { mapMethods: [member] } };
|
|
149
|
+
return { kind: "unfenceable", why: DESUGARED_WHY };
|
|
150
|
+
}
|
|
151
|
+
if (family === "set") {
|
|
152
|
+
if (SET_DETECTABLE.has(member))
|
|
153
|
+
return { kind: "detector", detector: { setMethods: [member] } };
|
|
154
|
+
return { kind: "unfenceable", why: DESUGARED_WHY };
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (entry.id.startsWith("syntax.")) {
|
|
158
|
+
return {
|
|
159
|
+
kind: "unfenceable",
|
|
160
|
+
why: "it lowers to the same IR as its expanded spelling, so the compiled graph carries no distinct trace to police",
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (entry.id.startsWith("node-builtin.")) {
|
|
164
|
+
return {
|
|
165
|
+
kind: "unfenceable",
|
|
166
|
+
why: "its lowered surface leaves no tabled per-call trace at this compiler release — fence the member entries the manifest projects instead",
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
return { kind: "unfenceable", why: "no fence detector exists for it at this compiler release" };
|
|
170
|
+
}
|
|
171
|
+
/* ── load-time resolution ──────────────────────────────────────────────── */
|
|
172
|
+
/** Resolve the profile's fence declarations against this compiler
|
|
173
|
+
* release's surface manifest. Every failure returns the exact-path detail
|
|
174
|
+
* the loader wraps as SC4001. Selector strictness is RATIFIED: an id or
|
|
175
|
+
* prefix matching nothing refuses; a covered static entry no detector can
|
|
176
|
+
* police refuses (loudly, never silently inert). Compile-time-folded
|
|
177
|
+
* constants refuse as `id` fences (the message says why) and are exempt
|
|
178
|
+
* under a `prefix` — the family sweep stays usable, and the fold means
|
|
179
|
+
* there is genuinely nothing at runtime to deny. */
|
|
180
|
+
export function resolveLibraryFences(decls) {
|
|
181
|
+
const tax = fenceTaxonomy();
|
|
182
|
+
const fences = [];
|
|
183
|
+
for (const d of decls) {
|
|
184
|
+
const surfaces = [];
|
|
185
|
+
const keep = (entry, cls) => {
|
|
186
|
+
surfaces.push({
|
|
187
|
+
id: entry.id,
|
|
188
|
+
name: entry.name,
|
|
189
|
+
kind: entry.kind,
|
|
190
|
+
...(entry.code !== undefined ? { code: entry.code } : {}),
|
|
191
|
+
...(cls.kind === "detector" ? { detector: cls.detector } : {}),
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
if (d.id !== undefined) {
|
|
195
|
+
const entry = tax.byId.get(d.id);
|
|
196
|
+
if (entry === undefined) {
|
|
197
|
+
return {
|
|
198
|
+
ok: false,
|
|
199
|
+
detail: `'${d.path}.id' names no entry in this compiler release's surface manifest ('${d.id}') — ` +
|
|
200
|
+
`fences pin to the release's manifest ids (the package ships surface-manifest.json), and an unknown id is refused, never accepted as inert`,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const cls = classifySurface(entry, tax);
|
|
204
|
+
if (cls.kind === "unfenceable") {
|
|
205
|
+
return { ok: false, detail: `'${d.path}.id' names '${d.id}', which cannot be fenced: ${cls.why}` };
|
|
206
|
+
}
|
|
207
|
+
keep(entry, cls);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const covered = tax.ids.filter((id) => id.startsWith(d.prefix));
|
|
211
|
+
if (covered.length === 0) {
|
|
212
|
+
return {
|
|
213
|
+
ok: false,
|
|
214
|
+
detail: `'${d.path}.prefix' matches no entry in this compiler release's surface manifest ('${d.prefix}') — ` +
|
|
215
|
+
`fences pin to the release's manifest ids (the package ships surface-manifest.json), and an unknown prefix is refused, never accepted as inert`,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
for (const id of covered) {
|
|
219
|
+
const entry = tax.byId.get(id);
|
|
220
|
+
const cls = classifySurface(entry, tax);
|
|
221
|
+
if (cls.kind === "unfenceable") {
|
|
222
|
+
if (tax.foldedIds.has(id))
|
|
223
|
+
continue; // the fold IS the exemption — see above
|
|
224
|
+
return { ok: false, detail: `'${d.path}.prefix' ('${d.prefix}') covers '${id}', which cannot be fenced: ${cls.why}` };
|
|
225
|
+
}
|
|
226
|
+
keep(entry, cls);
|
|
227
|
+
}
|
|
228
|
+
if (surfaces.length === 0) {
|
|
229
|
+
return {
|
|
230
|
+
ok: false,
|
|
231
|
+
detail: `'${d.path}.prefix' ('${d.prefix}') covers only compile-time-folded constants — there is nothing at runtime for the fence to deny`,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
fences.push({
|
|
236
|
+
declared: d.id !== undefined ? `id '${d.id}'` : `prefix '${d.prefix}'`,
|
|
237
|
+
...(d.teaching !== undefined ? { teaching: d.teaching } : {}),
|
|
238
|
+
...(d.remediation !== undefined ? { remediation: d.remediation } : {}),
|
|
239
|
+
surfaces,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return { ok: true, fences };
|
|
243
|
+
}
|
|
244
|
+
/** One generic walk over the compiled module (the moduleLibAsyncSurface
|
|
245
|
+
* shape: nearest enclosing `loc` tracked so refusals anchor at the
|
|
246
|
+
* reaching construct), collecting every reached surface fact the fence
|
|
247
|
+
* detectors speak. First location per fact wins. */
|
|
248
|
+
function collectReachedSurfaces(mod) {
|
|
249
|
+
const reached = {
|
|
250
|
+
libFns: new Map(),
|
|
251
|
+
strMethods: new Map(),
|
|
252
|
+
arrMethods: new Map(),
|
|
253
|
+
mapMethods: new Map(),
|
|
254
|
+
setMethods: new Map(),
|
|
255
|
+
};
|
|
256
|
+
const note = (map, key, loc) => {
|
|
257
|
+
if (!map.has(key))
|
|
258
|
+
map.set(key, loc);
|
|
259
|
+
};
|
|
260
|
+
const entryLoc = { file: mod.sourceFile, start: 0, end: 0 };
|
|
261
|
+
const visit = (v, loc) => {
|
|
262
|
+
if (v === null || typeof v !== "object")
|
|
263
|
+
return;
|
|
264
|
+
if (Array.isArray(v)) {
|
|
265
|
+
for (const item of v)
|
|
266
|
+
visit(item, loc);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const node = v;
|
|
270
|
+
const here = node.loc ?? loc;
|
|
271
|
+
if (typeof node.kind === "string") {
|
|
272
|
+
if (node.kind === "libCall" && typeof node.fn === "string")
|
|
273
|
+
note(reached.libFns, node.fn, here);
|
|
274
|
+
else if (typeof node.method === "string") {
|
|
275
|
+
if (node.kind === "strIntrinsic")
|
|
276
|
+
note(reached.strMethods, node.method, here);
|
|
277
|
+
else if (node.kind === "arrIntrinsic")
|
|
278
|
+
note(reached.arrMethods, node.method, here);
|
|
279
|
+
else if (node.kind === "mapIntrinsic")
|
|
280
|
+
note(reached.mapMethods, node.method, here);
|
|
281
|
+
else if (node.kind === "setIntrinsic")
|
|
282
|
+
note(reached.setMethods, node.method, here);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
for (const key of Object.keys(v))
|
|
286
|
+
visit(v[key], here);
|
|
287
|
+
};
|
|
288
|
+
visit(mod, entryLoc);
|
|
289
|
+
return reached;
|
|
290
|
+
}
|
|
291
|
+
function detectorHit(reached, det) {
|
|
292
|
+
const scan = (facts, keys) => {
|
|
293
|
+
for (const k of keys ?? []) {
|
|
294
|
+
const loc = facts.get(k);
|
|
295
|
+
if (loc !== undefined)
|
|
296
|
+
return loc;
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
};
|
|
300
|
+
return (scan(reached.libFns, det.libFns) ??
|
|
301
|
+
scan(reached.strMethods, det.strMethods) ??
|
|
302
|
+
scan(reached.arrMethods, det.arrMethods) ??
|
|
303
|
+
scan(reached.mapMethods, det.mapMethods) ??
|
|
304
|
+
scan(reached.setMethods, det.setMethods));
|
|
305
|
+
}
|
|
306
|
+
/** Evaluate the profile's fences against the COMPILED module graph: every
|
|
307
|
+
* fenced static surface the graph reaches refuses as SC4008, anchored at
|
|
308
|
+
* the reaching construct, the fence's teaching attached as the attributed
|
|
309
|
+
* note. Unreached fences add nothing; a profile whose fences carry no
|
|
310
|
+
* detector-backed surface skips the walk entirely. */
|
|
311
|
+
export function evaluateLibraryFences(mod, profile) {
|
|
312
|
+
if (!profile.fences.some((f) => f.surfaces.some((s) => s.detector !== undefined)))
|
|
313
|
+
return [];
|
|
314
|
+
const reached = collectReachedSurfaces(mod);
|
|
315
|
+
const diags = [];
|
|
316
|
+
const seen = new Set();
|
|
317
|
+
for (const fence of profile.fences) {
|
|
318
|
+
for (const s of fence.surfaces) {
|
|
319
|
+
if (s.detector === undefined || seen.has(s.id))
|
|
320
|
+
continue;
|
|
321
|
+
const loc = detectorHit(reached, s.detector);
|
|
322
|
+
if (loc === null)
|
|
323
|
+
continue;
|
|
324
|
+
seen.add(s.id);
|
|
325
|
+
diags.push(libFenceDiag(profile.name, s.id, s.name, loc, s.code, fence.teaching));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return diags;
|
|
329
|
+
}
|
|
330
|
+
/* ── the generalized teaching rider ────────────────────────────────────── */
|
|
331
|
+
function surfaceMatchesDiag(surface, diag) {
|
|
332
|
+
if (surface.code === undefined || surface.code !== diag.code)
|
|
333
|
+
return false;
|
|
334
|
+
// A diagnostic-fence entry IS the code family; member entries must also
|
|
335
|
+
// appear by name in the refusal's message (SC2020/SC2012 refusals spell
|
|
336
|
+
// the surface exactly as the manifest names it).
|
|
337
|
+
return surface.kind === "diagnostic-fence" || diag.message.includes(surface.name);
|
|
338
|
+
}
|
|
339
|
+
function teachingForRefusal(profile, diag) {
|
|
340
|
+
// 1. Code-keyed teachings — the ratified SC4004/SC4005 rider's keys,
|
|
341
|
+
// "async" shared-key fallback included (profile.ts's profileTeaching
|
|
342
|
+
// rule, restated here to keep the import graph acyclic).
|
|
343
|
+
const direct = profile.teachings[diag.code] ??
|
|
344
|
+
(diag.code === "SC4004" || diag.code === "SC4005" ? profile.teachings["async"] : undefined);
|
|
345
|
+
if (direct !== undefined)
|
|
346
|
+
return direct;
|
|
347
|
+
// 2. Manifest-id-keyed teachings (dotted keys — embedder refusal-code
|
|
348
|
+
// tokens never carry dots; an id key resolves against the taxonomy and
|
|
349
|
+
// attaches where that surface's refusal fired).
|
|
350
|
+
for (const [key, text] of Object.entries(profile.teachings)) {
|
|
351
|
+
if (!key.includes("."))
|
|
352
|
+
continue;
|
|
353
|
+
const entry = fenceTaxonomy().byId.get(key);
|
|
354
|
+
if (entry !== undefined && surfaceMatchesDiag(entry, diag))
|
|
355
|
+
return text;
|
|
356
|
+
}
|
|
357
|
+
// 3. A fence covering the refused surface: the teaching rides the
|
|
358
|
+
// surface's own refusal (the non-static half of fence coverage).
|
|
359
|
+
for (const fence of profile.fences) {
|
|
360
|
+
if (fence.teaching === undefined)
|
|
361
|
+
continue;
|
|
362
|
+
for (const s of fence.surfaces) {
|
|
363
|
+
if (surfaceMatchesDiag(s, diag))
|
|
364
|
+
return fence.teaching;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
return undefined;
|
|
368
|
+
}
|
|
369
|
+
/** Attach the profile's teaching text to every library-mode refusal it
|
|
370
|
+
* names — by code, by manifest id, or through a fence — as the visibly
|
|
371
|
+
* attributed `note`. Diagnostics already carrying a note (SC4008 threads
|
|
372
|
+
* its fence's teaching at mint time) pass through unchanged. */
|
|
373
|
+
export function decorateLibraryRefusals(diagnostics, profile) {
|
|
374
|
+
if (Object.keys(profile.teachings).length === 0 && profile.fences.length === 0)
|
|
375
|
+
return diagnostics;
|
|
376
|
+
return diagnostics.map((d) => {
|
|
377
|
+
if (d.note !== undefined)
|
|
378
|
+
return d;
|
|
379
|
+
const teaching = teachingForRefusal(profile, d);
|
|
380
|
+
if (teaching === undefined)
|
|
381
|
+
return d;
|
|
382
|
+
return { ...d, note: `from the '${profile.name}' profile: ${teaching}` };
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
//# sourceMappingURL=fence-eval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fence-eval.js","sourceRoot":"","sources":["../../src/library/fence-eval.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAiDuB;AACvB,OAAO,EAAE,uBAAuB,EAAoD,MAAM,iCAAiC,CAAC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S,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,WAAW,CAAC;IACnG,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC3B,IAAI,CAAC,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QACnC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAChD,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QACrC,OAAO,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,aAAa,OAAO,CAAC,IAAI,cAAc,QAAQ,EAAE,EAAE,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ScrDiagnostic } from "../diagnostics/diagnostic.js";
|
|
2
|
+
import { type ResolvedLibraryFence } from "./fence-eval.js";
|
|
2
3
|
/** Marshalling classes legal in PARAMETER position (v1). */
|
|
3
4
|
export declare const LIB_PARAM_CLASSES: readonly ["f64", "bool", "string", "bytes", "u8", "u32", "i32"];
|
|
4
5
|
/** Marshalling classes legal in RETURN position (v1): the value classes
|
|
@@ -82,6 +83,11 @@ export interface LibraryProfile {
|
|
|
82
83
|
* field is absent from the assembled bytes when the profile supplies
|
|
83
84
|
* none. Same reserved-byte validation as `teachings`. */
|
|
84
85
|
remediations: Readonly<Record<string, string>>;
|
|
86
|
+
/** The ask-5 determinism fences, resolved at load against this compiler
|
|
87
|
+
* release's surface manifest (fence-eval.ts): unknown ids/prefixes and
|
|
88
|
+
* unpoliceable static entries refused SC4001, never accepted as inert.
|
|
89
|
+
* Empty when the profile declares none. */
|
|
90
|
+
fences: readonly ResolvedLibraryFence[];
|
|
85
91
|
}
|
|
86
92
|
/** Parse + validate a profile file. Returns the profile or the SC4001
|
|
87
93
|
* diagnostics (one per problem found before parsing had to stop). */
|
|
@@ -98,5 +104,9 @@ export declare function loadLibraryProfile(profilePath: string): {
|
|
|
98
104
|
export declare function profileTeaching(profile: LibraryProfile, code: string): string | undefined;
|
|
99
105
|
/** The profile's remediation text for one code — the structured
|
|
100
106
|
* trap-teaching message's optional fourth field. No shared-key fallback:
|
|
101
|
-
* a remediation names one code's fix.
|
|
107
|
+
* a remediation names one code's fix. A fence entry's `remediation` feeds
|
|
108
|
+
* the same lookup through the codes its covered manifest entries carry
|
|
109
|
+
* (spec §3: "a remediation in a fence entry or a `remediations` map" —
|
|
110
|
+
* one data source for the field that already exists); an explicit map key
|
|
111
|
+
* wins over a fence's, and the first declared fence wins among fences. */
|
|
102
112
|
export declare function profileRemediation(profile: LibraryProfile, code: string): string | undefined;
|