mustflow 2.116.1 → 2.116.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/package.json +1 -1
  2. package/templates/default/i18n.toml +72 -6
  3. package/templates/default/locales/en/.mustflow/skills/INDEX.md +37 -11
  4. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/SKILL.md +477 -0
  5. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-diagnostics-abi-linker-checklist.md +778 -0
  6. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-generators-properties-checklist.md +501 -0
  7. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/compiler-test-strategy-differential-checklist.md +498 -0
  8. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/debug-symbol-symbolication-checklist.md +412 -0
  9. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/ir-design-ssa-pass-pipeline-checklist.md +759 -0
  10. package/templates/default/locales/en/.mustflow/skills/compiler-engineering-review/references/miscompile-reduction-ir-checklist.md +434 -0
  11. package/templates/default/locales/en/.mustflow/skills/cross-platform-filesystem-safety/SKILL.md +55 -36
  12. package/templates/default/locales/en/.mustflow/skills/cross-platform-filesystem-safety/references/path-containment-handle-checklist.md +251 -0
  13. package/templates/default/locales/en/.mustflow/skills/file-upload-security-review/SKILL.md +133 -32
  14. package/templates/default/locales/en/.mustflow/skills/file-upload-security-review/references/file-upload-parser-ssrf-resource-checklist.md +306 -0
  15. package/templates/default/locales/en/.mustflow/skills/formal-verification-review/SKILL.md +310 -0
  16. package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-concurrency-model-checking-smt-checklist.md +457 -0
  17. package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-contracts-modeling-checklist.md +434 -0
  18. package/templates/default/locales/en/.mustflow/skills/formal-verification-review/references/formal-memory-bounds-ci-checklist.md +509 -0
  19. package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/SKILL.md +439 -0
  20. package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/references/fuzz-harness-campaign-checklist.md +379 -0
  21. package/templates/default/locales/en/.mustflow/skills/fuzz-harness-review/references/fuzz-oracle-triage-ci-checklist.md +307 -0
  22. package/templates/default/locales/en/.mustflow/skills/idempotency-integrity-review/SKILL.md +48 -28
  23. package/templates/default/locales/en/.mustflow/skills/idempotency-integrity-review/references/operation-ordering-stale-write-checklist.md +259 -0
  24. package/templates/default/locales/en/.mustflow/skills/input-boundary-validation-review/SKILL.md +329 -0
  25. package/templates/default/locales/en/.mustflow/skills/input-boundary-validation-review/references/input-boundary-security-checklist.md +319 -0
  26. package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/SKILL.md +306 -0
  27. package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/references/input-session-state-checklist.md +298 -0
  28. package/templates/default/locales/en/.mustflow/skills/input-event-synchronization-review/references/remote-input-transport-interaction-checklist.md +328 -0
  29. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/SKILL.md +353 -0
  30. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-diagnostics-recovery-checklist.md +267 -0
  31. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-execution-closure-performance-checklist.md +428 -0
  32. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-gc-verification-checklist.md +457 -0
  33. package/templates/default/locales/en/.mustflow/skills/interpreter-engineering-review/references/interpreter-semantics-runtime-checklist.md +391 -0
  34. package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/SKILL.md +294 -0
  35. package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/references/modal-loop-reentrancy-checklist.md +290 -0
  36. package/templates/default/locales/en/.mustflow/skills/modal-loop-reentrancy-review/references/nested-modal-state-lifetime-checklist.md +297 -0
  37. package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/SKILL.md +252 -0
  38. package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/dns-network-resolution-checklist.md +394 -0
  39. package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/language-symbol-resolution-checklist.md +282 -0
  40. package/templates/default/locales/en/.mustflow/skills/name-resolution-integrity-review/references/module-package-loader-resolution-checklist.md +352 -0
  41. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/SKILL.md +103 -17
  42. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/cst-ast-lowering-checklist.md +260 -0
  43. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/lexer-tokenization-checklist.md +397 -0
  44. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/tree-serialization-compatibility-checklist.md +164 -0
  45. package/templates/default/locales/en/.mustflow/skills/parser-engineering-review/references/tree-traversal-rewrite-checklist.md +209 -0
  46. package/templates/default/locales/en/.mustflow/skills/race-condition-review/SKILL.md +68 -11
  47. package/templates/default/locales/en/.mustflow/skills/race-condition-review/references/race-reproduction-memory-model-checklist.md +268 -0
  48. package/templates/default/locales/en/.mustflow/skills/routes.toml +151 -0
  49. package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/SKILL.md +343 -0
  50. package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/references/session-auth-stream-resume-checklist.md +413 -0
  51. package/templates/default/locales/en/.mustflow/skills/session-handoff-integrity-review/references/session-handoff-protocol-checklist.md +485 -0
  52. package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/SKILL.md +267 -0
  53. package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/references/admission-decision-recovery-checklist.md +308 -0
  54. package/templates/default/locales/en/.mustflow/skills/two-phase-transition-integrity-review/references/two-phase-transition-checklist.md +229 -0
  55. package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/SKILL.md +300 -0
  56. package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/references/ui-affinity-event-loop-checklist.md +277 -0
  57. package/templates/default/locales/en/.mustflow/skills/ui-dispatch-lifecycle-review/references/ui-dispatch-lifecycle-checklist.md +292 -0
  58. package/templates/default/manifest.toml +115 -1
@@ -0,0 +1,428 @@
1
+ # Interpreter Execution, Closures, and Performance Checklist
2
+
3
+ Use this checklist when choosing AST execution or bytecode, resolving bindings, implementing frames
4
+ and closures, caching executable code, debugging, profiling, or optimizing an interpreter.
5
+
6
+ ## Contents
7
+
8
+ 1. [Engine selection](#engine-selection)
9
+ 2. [AST execution contract](#ast-execution-contract)
10
+ 3. [Bytecode contract](#bytecode-contract)
11
+ 4. [AST and bytecode differential](#ast-and-bytecode-differential)
12
+ 5. [Name resolution](#name-resolution)
13
+ 6. [Frame and slot layout](#frame-and-slot-layout)
14
+ 7. [Closures and upvalues](#closures-and-upvalues)
15
+ 8. [Initialization, recursion, and modules](#initialization-recursion-and-modules)
16
+ 9. [Suspension and debugging](#suspension-and-debugging)
17
+ 10. [Compiled-code caches](#compiled-code-caches)
18
+ 11. [Performance measurement](#performance-measurement)
19
+ 12. [Lookup, boxing, and allocation](#lookup-boxing-and-allocation)
20
+ 13. [Dispatch and specialization](#dispatch-and-specialization)
21
+ 14. [Native-boundary performance](#native-boundary-performance)
22
+ 15. [Memory and GC retention](#memory-and-gc-retention)
23
+ 16. [Failure matrix](#failure-matrix)
24
+ 17. [Invariants](#invariants)
25
+ 18. [Skill handoffs](#skill-handoffs)
26
+
27
+ ## Engine selection
28
+
29
+ Choose from workload and semantic maturity rather than code size or fashion.
30
+
31
+ | Signal | AST execution tends to fit | Bytecode tends to fit |
32
+ | --- | --- | --- |
33
+ | Semantic change rate | Rules and syntax change frequently. | Semantics and lowering are stable enough to version. |
34
+ | Execution reuse | Program runs once or briefly. | Same code executes repeatedly or for a long time. |
35
+ | Startup budget | Compile cost dominates. | Cache or reuse amortizes compile cost. |
36
+ | Control complexity | Simple calls and structured flow. | Exceptions, cleanup, generators, coroutines, suspension. |
37
+ | Debugger needs | Source-shaped prototype inspection. | Stable instruction pointer and source map. |
38
+ | Resource accounting | Node charging is sufficiently precise. | Instruction and operand costs need finer control. |
39
+ | Code size and locality | Small executable trees. | Compact sequential code and constant pools matter. |
40
+ | Future optimization | Local evaluator cleanup. | Specialization or tiering has measured justification. |
41
+
42
+ Do not assume bytecode is faster. A VM with boxed instruction objects, hash-map locals, fragmented
43
+ storage, and a costly dispatch loop can be slower than a compact executable AST. Do not keep AST and
44
+ bytecode simultaneously unless debugging, deoptimization, tooling, or cache policy justifies the
45
+ memory.
46
+
47
+ ## AST execution contract
48
+
49
+ An executable AST should differ from raw parser output when needed:
50
+
51
+ - names resolved to binding metadata;
52
+ - constants and literal values normalized;
53
+ - source ranges preserved;
54
+ - evaluation order explicit;
55
+ - control and cleanup targets annotated;
56
+ - free variables and captures computed;
57
+ - semantic rejection completed before hot execution;
58
+ - repetitive syntax sugar lowered to a smaller execution vocabulary;
59
+ - runtime node shapes compact and immutable where possible.
60
+
61
+ Avoid one heavyweight host object per trivial node when memory or traversal cost matters. Separate
62
+ rare metadata into side tables if measurement supports it, but keep source and debugger mapping
63
+ stable.
64
+
65
+ Do not use host recursion beyond the guest recursion contract. Deep guest expressions or calls need
66
+ an explicit bound or iterative execution path where host stack overflow would bypass guest errors.
67
+
68
+ ## Bytecode contract
69
+
70
+ Specify:
71
+
72
+ - instruction set and semantic version;
73
+ - stack, register, accumulator, or hybrid execution model;
74
+ - opcode and operand widths;
75
+ - constant and symbol pools;
76
+ - local, upvalue, module, global, builtin, and dynamic access instructions;
77
+ - stack-height or register-liveness invariants;
78
+ - jump target and handler table encoding;
79
+ - return, throw, cleanup, yield, suspend, and resume representation;
80
+ - native call and capability operands;
81
+ - source map and debugger stepping boundaries;
82
+ - instruction and size verification;
83
+ - budget cost and variable-size surcharges;
84
+ - serialization format and cache compatibility;
85
+ - unknown opcode and corrupted artifact behavior.
86
+
87
+ Bytecode should eliminate repeated semantic work, not merely rename AST nodes. Compact contiguous
88
+ representation, resolved slots, explicit instruction pointer, stable frames, and verification are
89
+ the useful boundaries.
90
+
91
+ Test malformed bytecode independently from source compilation. Reject truncated operands, invalid
92
+ indices, stack underflow or mismatch, bad jumps, handler overlap, impossible completion state,
93
+ unknown opcode, schema mismatch, and unsupported native symbols before execution.
94
+
95
+ ## AST and bytecode differential
96
+
97
+ Run one semantic corpus through both engines during migration or dual-engine support. Compare:
98
+
99
+ - guest value and identity relations;
100
+ - ordered mutation and host-effect trace;
101
+ - completion kind and payload;
102
+ - exception, cleanup, cancellation, and budget terminal point;
103
+ - source location and guest stack;
104
+ - final bindings and object observations;
105
+ - deterministic service consumption;
106
+ - native calls and capability decisions;
107
+ - debugger stops or coverage regions where promised.
108
+
109
+ Cover side-effecting operands, nested completion, closure mutation, module cycles, recursion,
110
+ exceptions in cleanup, suspension, async native completion, and budget exhaustion. A value-only
111
+ comparison can miss reordered effects, different cleanup, or source-location drift.
112
+
113
+ Use the semantic contract or independent model as authority. If both engines implement the same
114
+ wrong lowering, agreement is not proof.
115
+
116
+ ## Name resolution
117
+
118
+ Resolver output should classify each binding:
119
+
120
+ - local slot;
121
+ - captured or upvalue cell;
122
+ - parameter;
123
+ - module or import cell;
124
+ - global slot;
125
+ - builtin or native symbol;
126
+ - explicitly dynamic binding if the language supports it;
127
+ - invalid, ambiguous, or uninitialized reference.
128
+
129
+ Record declaration source, scope depth, slot or cell identity, mutability, initialization rule,
130
+ capture status, export or import status, and debug name.
131
+
132
+ Resolve reads and writes through the same binding identity. A resolved assignment writes its slot or
133
+ cell; it must not restart a string-name search and accidentally select a nearer dynamic environment.
134
+
135
+ Test shadowing, declaration before use, declaration versus initialization, duplicate declarations,
136
+ recursive and mutually recursive definitions, imports, pattern bindings, catch bindings, loop
137
+ variables, class or object scopes, and explicitly dynamic features.
138
+
139
+ ## Frame and slot layout
140
+
141
+ Define:
142
+
143
+ - parameter slots;
144
+ - local slots and lexical live ranges;
145
+ - temporary and operand slots;
146
+ - completion and handler state;
147
+ - return and receiver positions;
148
+ - captured-slot promotion;
149
+ - slot reuse and clearing;
150
+ - debugger-visible names and values;
151
+ - GC root map;
152
+ - suspended-frame storage;
153
+ - frame generation and stale callback protection.
154
+
155
+ Use array or compact indexed storage for statically resolved bindings. Keep strings for debugging
156
+ and reflection rather than hot access. Slot reuse must respect overlapping lexical lifetimes,
157
+ captured values, debugger inspection, exceptions, and suspension.
158
+
159
+ Clear dead references when the guest semantics and debugger contract permit it so frame slots do not
160
+ retain large object graphs.
161
+
162
+ ## Closures and upvalues
163
+
164
+ Keep lexical and dynamic relationships separate. A closure captures the environment at definition,
165
+ not the frame that later calls it.
166
+
167
+ For each free binding, define:
168
+
169
+ - value or reference capture;
170
+ - mutable shared cell semantics;
171
+ - upvalue index and owning function;
172
+ - open state pointing to a live frame slot;
173
+ - closed state pointing to a heap cell;
174
+ - one-cell deduplication for multiple closures capturing the same binding;
175
+ - close order on return, throw, cancellation, or unwind;
176
+ - GC roots and weak or strong native references;
177
+ - serialization or non-serializability;
178
+ - debugger display and hot-reload behavior.
179
+
180
+ Do not capture the whole environment when only a few variables are free. Whole-environment capture
181
+ retains unrelated temporaries, native handles, buffers, and object graphs.
182
+
183
+ Test sibling closures sharing mutation, nested captures, capture after slot reuse, recursive closure,
184
+ closure returned after frame exit, exception during closure construction, cancellation while open,
185
+ generator suspension, and debugger retention.
186
+
187
+ ## Initialization, recursion, and modules
188
+
189
+ Separate binding existence from initialized value. Use a dedicated uninitialized sentinel or state,
190
+ not the guest null-like value.
191
+
192
+ For recursion:
193
+
194
+ 1. declare binding identity and slot or cell;
195
+ 2. mark it uninitialized;
196
+ 3. construct the function or module value with access to the binding;
197
+ 4. publish the initialized value;
198
+ 5. reject reads that occur before the permitted initialization point.
199
+
200
+ For mutually recursive declarations, define the declaration group and initialization order.
201
+
202
+ For loop captures, specify whether one binding is shared across iterations or a new binding is
203
+ created per iteration. Implement the declared rule at binding creation, not as a closure special case.
204
+
205
+ For modules, specify copied versus live bindings, initialization phases, cycles, partial namespace
206
+ visibility, failure caching, re-execution, unload, hot reload, and references retained by closures or
207
+ native code.
208
+
209
+ ## Suspension and debugging
210
+
211
+ Generators, coroutines, async functions, and resumable exceptions require explicit execution state:
212
+
213
+ - instruction or node position;
214
+ - frame slots and operand state;
215
+ - open upvalues;
216
+ - handler and cleanup stack;
217
+ - pending completion;
218
+ - budget and cancellation state;
219
+ - execution generation;
220
+ - source map and debugger state;
221
+ - native await or callback identity.
222
+
223
+ Do not rely on an opaque host call stack when the guest computation must suspend, serialize, move,
224
+ inspect, or resume independently.
225
+
226
+ Debugger contracts should define:
227
+
228
+ - breakpoint binding and source generation;
229
+ - line, statement, expression, or instruction stop granularity;
230
+ - step into, over, and out behavior;
231
+ - hidden or synthetic instruction policy;
232
+ - guest stack and local or captured value inspection;
233
+ - optimized or dead binding display;
234
+ - native frame representation;
235
+ - hot-reload compatibility and stale breakpoint behavior.
236
+
237
+ Coverage and profiler sampling should use the same source provenance vocabulary while remaining
238
+ separate evidence products.
239
+
240
+ ## Compiled-code caches
241
+
242
+ Cache identity should include all semantic inputs:
243
+
244
+ - source content or immutable source identity;
245
+ - language and semantic version;
246
+ - parser, resolver, compiler, and bytecode schema version;
247
+ - compile options and feature flags;
248
+ - native API and symbol version;
249
+ - module and import dependency identities;
250
+ - target runtime or value representation assumptions;
251
+ - deterministic service or policy version when compilation depends on it;
252
+ - source-map format;
253
+ - capability or sandbox mode when encoded into code.
254
+
255
+ Validate artifact header, size, checksums or hashes, indices, opcodes, stack or register invariants,
256
+ native symbol availability, and source-map consistency before execution.
257
+
258
+ On mismatch, recompile or return a typed incompatibility. Do not silently run stale code because
259
+ the path, module name, or cache key remained stable.
260
+
261
+ Separate memory cache, module cache, and persistent serialized cache. Define eviction, lifetime,
262
+ tenant isolation, concurrency, atomic promotion, partial write, rollback, and cache-poisoning behavior.
263
+
264
+ ## Performance measurement
265
+
266
+ Measure representative workloads by phase:
267
+
268
+ - source load, parse, resolve, semantic validation, and compile;
269
+ - cache lookup, validation, deserialize, and relink;
270
+ - instruction or node dispatch;
271
+ - local, upvalue, module, global, and property access;
272
+ - dynamic operator resolution;
273
+ - function and native calls;
274
+ - allocation volume and live heap;
275
+ - GC count, pause, and total time;
276
+ - string and collection operations;
277
+ - source mapping, debugger, coverage, and profiling overhead;
278
+ - startup, steady state, and tail latency.
279
+
280
+ Record operation counts with time. A faster benchmark that executed less guest work, disabled
281
+ budgets, skipped source maps, or changed native effects is invalid.
282
+
283
+ Profile the actual service mix. A synthetic arithmetic loop does not represent a runtime dominated
284
+ by property access, JSON conversion, regex, templates, or host calls.
285
+
286
+ ## Lookup, boxing, and allocation
287
+
288
+ Prioritize measured waste:
289
+
290
+ - replace repeated name hashing and parent-environment walks with resolved slots and cells;
291
+ - avoid allocating wrapper result objects for normal evaluation;
292
+ - keep common primitive values compact or unboxed where safe;
293
+ - bound small-value caches and interning to trusted finite domains;
294
+ - avoid retaining slices or tokens that pin large obsolete source buffers;
295
+ - use builders, ropes, or chunk lists for repeated string concatenation;
296
+ - reuse bounded temporary argument or operand storage when reentrancy and concurrency permit;
297
+ - capture only free variables;
298
+ - clear dead slots and caches that retain guest objects;
299
+ - batch host calls instead of crossing the native boundary per element.
300
+
301
+ Do not optimize allocation by reusing mutable objects across guest identities or concurrent sessions.
302
+
303
+ ## Dispatch and specialization
304
+
305
+ Possible optimizations include:
306
+
307
+ - compact fixed or variable-width bytecode;
308
+ - direct or table-driven dispatch where the host permits it;
309
+ - superinstructions for measured opcode sequences;
310
+ - monomorphic or bounded polymorphic inline caches;
311
+ - specialized opcodes guarded by value tags or object shape;
312
+ - shape or hidden-class property offsets;
313
+ - quickening with reversible fallback;
314
+ - tail-call handling where the language specifies it;
315
+ - tiering or JIT only after simpler bottlenecks are measured.
316
+
317
+ Every cache or specialization needs:
318
+
319
+ - operation-site identity;
320
+ - observed semantic kinds, storage tags, shape, policy, or native symbol guard;
321
+ - every relevant class, prototype, metatable, protocol, operator table, or metaobject generation;
322
+ - miss and megamorphic fallback;
323
+ - mutation and invalidation rule;
324
+ - concurrency ownership;
325
+ - source and debugger behavior;
326
+ - budget accounting;
327
+ - deoptimization or generic recovery where applicable.
328
+
329
+ Do not specialize away guest overflow, coercion, exception, capability, or evaluation-order rules.
330
+ If metaobjects can change at runtime, a type-pair cache without a generation or dependency guard can
331
+ execute obsolete language semantics after a method is added, removed, or replaced.
332
+
333
+ ## Native-boundary performance
334
+
335
+ Measure separately:
336
+
337
+ - guest-to-host argument conversion;
338
+ - host-to-guest result conversion;
339
+ - capability and policy checks;
340
+ - thread or event-loop marshaling;
341
+ - reflection or dynamic lookup;
342
+ - handle table access;
343
+ - callback and reentry setup;
344
+ - async continuation registration;
345
+ - error translation;
346
+ - budget and logging overhead;
347
+ - actual host operation.
348
+
349
+ Prefer coarse-grained bulk APIs, generated or cached call stubs, handles or proxies for large host
350
+ objects, and explicit ownership. Do not remove validation, capability, rooting, cancellation, or
351
+ thread checks to improve a microbenchmark.
352
+
353
+ If native calls dominate, changing AST dispatch to bytecode may not materially improve total time.
354
+
355
+ ## Memory and GC retention
356
+
357
+ Map roots and retention paths through:
358
+
359
+ - active and suspended frames;
360
+ - open and closed upvalues;
361
+ - globals and module cells;
362
+ - native handles and callbacks;
363
+ - debugger snapshots and watch expressions;
364
+ - error objects and stack traces;
365
+ - compiled-code and constant pools;
366
+ - source maps and source buffers;
367
+ - intern and symbol tables;
368
+ - inline caches and object shapes;
369
+ - pending async continuations;
370
+ - profiler and coverage state.
371
+
372
+ Test closure release, module unload or replacement, callback deregistration, debugger detach, cache
373
+ eviction, canceled suspension, native-handle finalization, and cyclic guest-native graphs.
374
+
375
+ Reference counting alone cannot collect cycles unless the runtime adds cycle detection or another
376
+ ownership rule. Tracing GC still needs correct roots and barriers.
377
+
378
+ Use [Interpreter GC and Verification Checklist](interpreter-gc-verification-checklist.md) for root
379
+ APIs, allocating safepoints, staged construction, store barriers, moving handles, remembered sets,
380
+ ephemerons, finalizers, reference-count reentrancy, external resources, heap stress, and semantic
381
+ oracle design.
382
+
383
+ ## Failure matrix
384
+
385
+ | Failure | Required behavior |
386
+ | --- | --- |
387
+ | AST and bytecode disagree. | Preserve first semantic divergence and follow the language contract. |
388
+ | Bytecode cache schema is old. | Reject and rebuild; never reinterpret. |
389
+ | Slot is reused while captured. | Resolver or frame verifier prevents aliasing. |
390
+ | Two closures capture one mutable local. | They share one cell. |
391
+ | Frame exits by throw. | Every open upvalue closes and cleanup remains ordered. |
392
+ | Loop closure sees wrong iteration. | Binding-creation fixture exposes the declared rule. |
393
+ | Module cycle reads before initialization. | Dedicated uninitialized state produces the specified result. |
394
+ | Suspended callback resumes old execution generation. | Stale completion is rejected. |
395
+ | Inline cache guard misses. | Generic path preserves semantics and updates within policy. |
396
+ | Untrusted strings fill intern table. | Interning policy stays bounded. |
397
+ | Debugger detaches. | Retained frames and objects return to baseline. |
398
+ | Native calls dominate profile. | Optimization targets the boundary, not dispatch folklore. |
399
+
400
+ ## Invariants
401
+
402
+ - Engine selection follows measured workload and semantic maturity.
403
+ - Bytecode contains resolved execution information and passes verification before running.
404
+ - Resolved reads and writes use one binding identity.
405
+ - Lexical scope never follows caller frames accidentally.
406
+ - One captured mutable binding has one shared cell.
407
+ - Every frame exit closes owned upvalues exactly once.
408
+ - Uninitialized state is distinct from every guest value.
409
+ - Cached code binds every semantic and native dependency that can change execution.
410
+ - Optimization guards have a correct generic fallback and invalidation rule.
411
+ - Dynamic dispatch caches include every mutable semantic dependency and its generation.
412
+ - Performance evidence preserves guest work, budgets, source mapping, and native effects.
413
+ - GC roots and retention paths cover closures, modules, natives, debugger, caches, and suspension.
414
+
415
+ ## Skill handoffs
416
+
417
+ - Use `interpreter-engineering-review` for engine selection, resolver, bytecode, closures, caches,
418
+ debugger, profiling, and runtime performance.
419
+ - Use `compiler-engineering-review` when bytecode lowering becomes a compiler transform with
420
+ stage-local verification or optimization.
421
+ - Use `parser-engineering-review` for lexer, grammar, CST, AST construction, and parser recovery.
422
+ - Use `fuzz-harness-review` for harness, instrumentation, corpus, campaign, sanitizer, and generic
423
+ artifact lifecycle.
424
+ - Use `memory-lifetime-review` for GC, root, host-handle, callback, and retained-object defects.
425
+ - Use `cache-integrity-review` for persistent compiled-code cache truth, isolation, invalidation,
426
+ and failure behavior.
427
+ - Use `performance-hot-path-review` or the repository's narrower performance skill when a measured
428
+ production workload extends beyond interpreter internals.