targeted-mutation 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +21 -0
  3. package/README.md +111 -2
  4. package/bin/tmt-compile.mjs +46 -0
  5. package/bin/tmt.mjs +117 -0
  6. package/build/typescript-syntax/LICENSE.txt +55 -0
  7. package/build/typescript-syntax/ThirdPartyNoticeText.txt +193 -0
  8. package/build/typescript-syntax/typescript-syntax.cjs +43 -0
  9. package/docs/analysis.md +218 -0
  10. package/docs/compiler.md +462 -0
  11. package/docs/development.md +61 -0
  12. package/docs/how-it-works.svg +188 -0
  13. package/docs/l1.md +94 -0
  14. package/docs/performance.md +647 -0
  15. package/docs/releasing.md +48 -0
  16. package/package.json +49 -4
  17. package/src/analysis.mjs +689 -0
  18. package/src/assertion-session.mjs +93 -0
  19. package/src/assertion-strength.mjs +795 -0
  20. package/src/builtin-mutations.mjs +755 -0
  21. package/src/builtin-switches.mjs +642 -0
  22. package/src/change-undone.mjs +524 -0
  23. package/src/cli-output.mjs +166 -0
  24. package/src/compiler-compat.cjs +108 -0
  25. package/src/compiler-maps.cjs +60 -0
  26. package/src/compiler-routes.cjs +391 -0
  27. package/src/compiler.cjs +98 -0
  28. package/src/compiler.mjs +1 -0
  29. package/src/conventional.mjs +172 -0
  30. package/src/displacement.mjs +19 -0
  31. package/src/extract.mjs +135 -0
  32. package/src/fallback-process.mjs +14 -0
  33. package/src/in-parallel.mjs +20 -0
  34. package/src/lean-replay.mjs +39 -0
  35. package/src/operator-analysis.mjs +123 -0
  36. package/src/playwright.mjs +139 -0
  37. package/src/probe-runtime.mjs +50 -0
  38. package/src/probe.mjs +170 -0
  39. package/src/prototype.mjs +230 -0
  40. package/src/regex-mutations.mjs +102 -0
  41. package/src/runner-process.mjs +59 -0
  42. package/src/runtime-binaries.mjs +50 -0
  43. package/src/scope.mjs +202 -0
  44. package/src/source-text.mjs +49 -0
  45. package/src/standard-plan.mjs +308 -0
  46. package/src/standard-runner.mjs +185 -0
  47. package/src/standard-session.mjs +362 -0
  48. package/src/standard-setup.mjs +20 -0
  49. package/src/targeted-gaps.mjs +85 -0
  50. package/src/threshold.mjs +185 -0
  51. package/src/trace-buffer.mjs +126 -0
  52. package/src/typescript-bindings.mjs +243 -0
  53. package/src/typescript-compiler.mjs +59 -0
  54. package/src/typescript-extraction.mjs +354 -0
  55. package/src/typescript-grammar.mjs +923 -0
  56. package/src/vitest-reporter.mjs +64 -0
  57. package/src/vitest.mjs +262 -0
  58. package/src/witness-analysis.mjs +234 -0
  59. package/src/witness-contracts.mjs +110 -0
  60. package/src/witness-discovery.mjs +239 -0
  61. package/src/witness-fixtures.mjs +148 -0
  62. package/src/witness-order.mjs +83 -0
  63. package/src/witness-rules.mjs +254 -0
@@ -0,0 +1,188 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1120 716" width="1120" height="716" role="img" aria-label="How targeted-mutation works">
2
+ <defs>
3
+ <style>
4
+ .title { font-family: 'Virgil', 'Segoe Print', 'Bradley Hand', 'Chalkboard SE', cursive, sans-serif; font-size: 24px; font-weight: 700; }
5
+ .subtitle { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 13.5px; }
6
+ .heading { font-family: 'Virgil', 'Segoe Print', 'Bradley Hand', 'Chalkboard SE', cursive, sans-serif; font-size: 16.5px; font-weight: 700; }
7
+ .body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 12.5px; }
8
+ .code { font-family: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace; font-size: 11.5px; }
9
+ .edge-label { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 11.5px; font-weight: 600; }
10
+ </style>
11
+ </defs>
12
+
13
+ <!-- Clean card background so the diagram is crisp in both GitHub light and dark themes -->
14
+ <rect x="0" y="0" width="1120" height="716" rx="16" fill="#ffffff"/>
15
+ <rect x="1" y="1" width="1118" height="714" rx="15" fill="none" stroke="#e9ecef" stroke-width="1.5"/>
16
+
17
+ <!-- Header -->
18
+ <text x="40" y="42" class="title" fill="#1e293b">How targeted-mutation works</text>
19
+ <text x="40" y="64" class="subtitle" fill="#64748b">Watch real runtime values -&gt; synthesize the closest unpinned edits -&gt; report actionable test gaps</text>
20
+
21
+ <!-- Step 0: Source + Test Suite -->
22
+ <rect x="43.0" y="118.0" width="230.0" height="82.0" rx="12" fill="#000000" opacity="0.045"/>
23
+ <rect x="39.5" y="114.7" width="230.0" height="82.0" rx="12" fill="#f8f9fa"/>
24
+ <path d="M 52.3 114.4 Q 155.5 115.2 258.7 114.8 Q 271.0 114.3 271.2 126.8 Q 270.2 155.6 270.7 184.5 Q 271.1 196.5 258.7 197.0 Q 155.5 196.4 52.3 196.5 Q 40.2 196.2 39.6 184.5 Q 40.0 155.6 40.6 126.8 Q 40.3 115.0 52.3 114.3" fill="none" stroke="#495057" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" opacity="0.95"/>
25
+ <path d="M 52.8 112.8 Q 155.0 113.5 257.2 112.9 Q 269.2 113.7 269.6 125.1 Q 270.5 154.6 269.6 184.1 Q 269.1 196.1 257.2 196.4 Q 155.0 196.6 52.8 196.1 Q 41.4 195.6 40.7 184.1 Q 41.0 154.6 40.1 125.1 Q 41.2 113.5 52.8 113.8" fill="none" stroke="#495057" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.55"/>
26
+ <text x="155.0" y="144.0" text-anchor="middle" class="heading" fill="#212529">Source + Test Suite</text>
27
+ <text x="155.0" y="168.0" text-anchor="middle" class="code" fill="#495057">src/*.ts + test/*.test.ts</text>
28
+ <text x="155.0" y="185.0" text-anchor="middle" class="body" fill="#343a40">Vitest 4 or Playwright</text>
29
+
30
+ <!-- Arrow: Source -> Baseline -->
31
+ <path d="M 269.6 155.3 Q 303.0 155.1 335.5 154.5" fill="none" stroke="#495057" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
32
+ <path d="M 269.8 154.9 Q 303.0 154.7 335.8 154.7" fill="none" stroke="#495057" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
33
+ <path d="M 336.0 155.0 Q 331.7 157.5 327.4 160.0" fill="none" stroke="#495057" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
34
+ <path d="M 336.0 155.0 Q 331.6 157.5 327.4 160.0" fill="none" stroke="#495057" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
35
+ <path d="M 336.0 155.0 Q 331.8 152.5 327.4 150.0" fill="none" stroke="#495057" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
36
+ <path d="M 336.0 155.0 Q 331.8 152.5 327.4 150.0" fill="none" stroke="#495057" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
37
+
38
+ <!-- Step 1: Baseline Run with Value Probes -->
39
+ <rect x="341.0" y="118.0" width="410.0" height="82.0" rx="12" fill="#000000" opacity="0.045"/>
40
+ <rect x="337.3" y="113.4" width="410.0" height="82.0" rx="12" fill="#e7f5ff"/>
41
+ <path d="M 350.0 115.1 Q 542.9 113.3 735.9 115.0 Q 748.2 113.9 748.0 126.4 Q 747.8 154.9 747.9 183.4 Q 748.2 194.9 735.9 194.9 Q 542.9 194.4 350.0 196.0 Q 338.2 195.4 338.4 183.4 Q 337.9 154.9 338.0 126.4 Q 338.4 114.3 350.0 114.6" fill="none" stroke="#1971c2" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" opacity="0.95"/>
42
+ <path d="M 350.7 114.3 Q 543.8 113.7 736.9 115.2 Q 748.6 114.5 748.4 126.8 Q 748.1 155.7 748.5 184.6 Q 748.4 196.2 736.9 197.0 Q 543.8 196.2 350.7 197.1 Q 338.5 196.0 338.5 184.6 Q 339.8 155.7 338.2 126.8 Q 338.8 115.0 350.7 114.3" fill="none" stroke="#1971c2" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.55"/>
43
+ <text x="543.0" y="142.0" text-anchor="middle" class="heading" fill="#1864ab">1. Baseline Run with Value Probes</text>
44
+ <text x="543.0" y="165.0" text-anchor="middle" class="body" fill="#1c4f7a">Runs your passing suite once with probes enabled.</text>
45
+ <text x="543.0" y="182.0" text-anchor="middle" class="body" fill="#1c4f7a">Records (lhs, rhs) operands &amp; per-test edit agreement.</text>
46
+
47
+ <!-- Side Track: diff and sub-hunk undo (Top-Right) -->
48
+ <rect x="803.0" y="118.0" width="280.0" height="128.0" rx="12" fill="#000000" opacity="0.045"/>
49
+ <rect x="800.0" y="113.3" width="280.0" height="128.0" rx="12" fill="#f1f3f5"/>
50
+ <path d="M 812.6 115.3 Q 940.0 114.3 1067.5 114.3 Q 1079.1 114.6 1079.8 126.9 Q 1079.5 178.7 1079.3 230.5 Q 1079.0 242.2 1067.5 241.9 Q 940.0 242.3 812.6 242.3 Q 800.1 242.2 801.2 230.5 Q 800.2 178.7 800.3 126.9 Q 800.3 114.9 812.6 114.3" fill="none" stroke="#495057" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" opacity="0.95" stroke-dasharray="6 4"/>
51
+ <path d="M 812.1 112.9 Q 940.4 113.5 1068.7 113.4 Q 1080.9 112.8 1080.0 125.3 Q 1080.2 177.3 1080.2 229.3 Q 1080.9 241.5 1068.7 241.6 Q 940.4 242.0 812.1 240.8 Q 800.1 241.3 800.6 229.3 Q 800.8 177.3 800.2 125.3 Q 800.2 113.8 812.1 113.1" fill="none" stroke="#495057" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.55" stroke-dasharray="6 4"/>
52
+ <text x="940.0" y="140.0" text-anchor="middle" class="heading" fill="#343a40">Optional: Diff &amp; Sub-Hunk Undo</text>
53
+ <text x="940.0" y="160.0" text-anchor="middle" class="code" fill="#495057">--since REV --undo-changes</text>
54
+ <text x="940.0" y="177.0" text-anchor="middle" class="body" fill="#343a40">Reverts each Git hunk &amp; AST sub-hunk</text>
55
+ <text x="940.0" y="194.0" text-anchor="middle" class="body" fill="#343a40">(added &amp;&amp;/|| terms, added object props)</text>
56
+ <text x="940.0" y="211.0" text-anchor="middle" class="code" fill="#c92a2a">-&gt; UNTESTED CHANGE</text>
57
+ <path d="M 155.0 113.9 Q 154.9 101.9 155.0 90.1" fill="none" stroke="#868e96" stroke-width="1.9" stroke-linecap="round" opacity="1" stroke-dasharray="5 4"/>
58
+ <path d="M 155.0 114.1 Q 155.1 102.3 154.9 89.9" fill="none" stroke="#868e96" stroke-width="1.6" stroke-linecap="round" opacity="0.65" stroke-dasharray="5 4"/>
59
+ <path d="M 154.1 89.8 Q 548.9 90.4 940.6 90.5" fill="none" stroke="#868e96" stroke-width="1.9" stroke-linecap="round" opacity="1" stroke-dasharray="5 4"/>
60
+ <path d="M 155.9 90.0 Q 548.1 90.6 939.1 90.5" fill="none" stroke="#868e96" stroke-width="1.6" stroke-linecap="round" opacity="0.65" stroke-dasharray="5 4"/>
61
+ <path d="M 940.1 90.1 Q 939.9 101.3 939.9 112.0" fill="none" stroke="#868e96" stroke-width="1.9" stroke-linecap="round" opacity="1" stroke-dasharray="5 4"/>
62
+ <path d="M 939.9 90.1 Q 939.9 100.9 940.1 112.0" fill="none" stroke="#868e96" stroke-width="1.6" stroke-linecap="round" opacity="0.65" stroke-dasharray="5 4"/>
63
+ <path d="M 940.0 112.0 Q 937.5 107.6 935.0 103.3" fill="none" stroke="#868e96" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
64
+ <path d="M 940.0 112.0 Q 937.5 107.6 935.0 103.3" fill="none" stroke="#868e96" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
65
+ <path d="M 940.0 112.0 Q 942.5 107.7 945.0 103.3" fill="none" stroke="#868e96" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
66
+ <path d="M 940.0 112.0 Q 942.4 107.7 945.0 103.3" fill="none" stroke="#868e96" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
67
+ <rect x="492.6" y="82.0" width="110.8" height="17" rx="4" fill="#ffffff" opacity="0.92"/>
68
+ <text x="548.0" y="94.0" text-anchor="middle" class="edge-label" fill="#868e96">git diff hunks</text>
69
+
70
+ <!-- Arrows: Baseline -> Track A (Comparison / Lean) and Track B (20 Value-Aware Rules) -->
71
+ <path d="M 440.7 196.3 Q 329.1 222.9 216.9 247.9" fill="none" stroke="#6741d9" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
72
+ <path d="M 440.7 195.1 Q 329.3 221.7 217.6 248.5" fill="none" stroke="#6741d9" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
73
+ <path d="M 217.0 248.0 Q 220.7 244.6 224.3 241.2" fill="none" stroke="#6741d9" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
74
+ <path d="M 217.0 248.0 Q 220.6 244.6 224.3 241.2" fill="none" stroke="#6741d9" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
75
+ <path d="M 217.0 248.0 Q 221.9 249.4 226.6 250.9" fill="none" stroke="#6741d9" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
76
+ <path d="M 217.0 248.0 Q 221.8 249.4 226.6 250.9" fill="none" stroke="#6741d9" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
77
+ <rect x="242.4" y="210.0" width="125.2" height="17" rx="4" fill="#ffffff" opacity="0.92"/>
78
+ <text x="305.0" y="222.0" text-anchor="middle" class="edge-label" fill="#6741d9">comparison sites</text>
79
+ <path d="M 620.3 195.8 Q 608.5 222.6 596.7 248.3" fill="none" stroke="#0ca678" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
80
+ <path d="M 619.7 195.9 Q 608.6 222.6 596.9 248.3" fill="none" stroke="#0ca678" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
81
+ <path d="M 597.0 248.0 Q 596.4 243.0 595.9 238.1" fill="none" stroke="#0ca678" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
82
+ <path d="M 597.0 248.0 Q 596.5 243.0 596.0 238.1" fill="none" stroke="#0ca678" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
83
+ <path d="M 597.0 248.0 Q 601.0 245.1 605.1 242.1" fill="none" stroke="#0ca678" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
84
+ <path d="M 597.0 248.0 Q 601.0 245.0 605.1 242.1" fill="none" stroke="#0ca678" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
85
+ <rect x="589.8" y="211.0" width="132.4" height="17" rx="4" fill="#ffffff" opacity="0.92"/>
86
+ <text x="656.0" y="223.0" text-anchor="middle" class="edge-label" fill="#0ca678">20 semantic rules</text>
87
+
88
+ <!-- Track A: Comparison Sites + Lean 4 -->
89
+ <rect x="43.0" y="254.0" width="355.0" height="132.0" rx="12" fill="#000000" opacity="0.045"/>
90
+ <rect x="39.8" y="249.9" width="355.0" height="132.0" rx="12" fill="#f3f0ff"/>
91
+ <path d="M 52.9 249.8 Q 218.2 250.0 383.5 249.9 Q 395.5 249.8 396.0 262.0 Q 395.1 315.9 396.1 369.8 Q 395.2 382.0 383.5 382.1 Q 218.2 381.8 52.9 381.5 Q 40.6 382.2 40.6 369.8 Q 40.6 315.9 40.7 262.0 Q 41.1 249.6 52.9 250.3" fill="none" stroke="#6741d9" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" opacity="0.95"/>
92
+ <path d="M 52.6 250.7 Q 218.2 249.6 383.9 250.1 Q 396.4 249.8 396.3 262.4 Q 394.7 315.7 395.7 369.0 Q 396.3 381.2 383.9 380.9 Q 218.2 379.8 52.6 381.3 Q 40.4 381.4 41.3 369.0 Q 41.4 315.7 40.9 262.4 Q 40.8 250.6 52.6 250.0" fill="none" stroke="#6741d9" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.55"/>
93
+ <text x="217.0" y="277.0" text-anchor="middle" class="heading" fill="#5f3dc4">Lean 4 Solver (tmt-decide)</text>
94
+ <text x="217.0" y="300.0" text-anchor="middle" class="body" fill="#3b2c68">Computes exact feasible [lo, hi] intervals for:</text>
95
+ <text x="217.0" y="318.0" text-anchor="middle" class="code" fill="#5f3dc4">constant-RHS &amp; variable-RHS margins</text>
96
+ <text x="217.0" y="336.0" text-anchor="middle" class="body" fill="#3b2c68">Synthesizes nearest open edit (age &gt;= 17, rhs - 1)</text>
97
+ <text x="217.0" y="354.0" text-anchor="middle" class="body" fill="#3b2c68">With --deterministic: proves safe replay skips</text>
98
+
99
+ <!-- Track B: 20 Value-Aware Rules -->
100
+ <rect x="423.0" y="254.0" width="355.0" height="132.0" rx="12" fill="#000000" opacity="0.045"/>
101
+ <rect x="420.5" y="250.5" width="355.0" height="132.0" rx="12" fill="#e6fcf5"/>
102
+ <path d="M 431.1 250.1 Q 597.4 249.7 763.7 250.2 Q 776.2 249.7 775.4 261.9 Q 775.6 316.4 775.7 370.9 Q 775.7 382.8 763.7 383.6 Q 597.4 382.6 431.1 382.8 Q 418.6 382.4 418.9 370.9 Q 418.4 316.4 419.6 261.9 Q 418.8 250.0 431.1 250.1" fill="none" stroke="#0ca678" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" opacity="0.95"/>
103
+ <path d="M 431.5 249.5 Q 597.6 248.9 763.8 249.2 Q 776.0 249.9 775.6 261.5 Q 776.8 315.9 775.8 370.3 Q 775.4 382.1 763.8 382.5 Q 597.6 381.5 431.5 381.9 Q 419.6 381.7 418.9 370.3 Q 419.5 315.9 418.9 261.5 Q 419.2 249.8 431.5 250.1" fill="none" stroke="#0ca678" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.55"/>
104
+ <text x="597.0" y="277.0" text-anchor="middle" class="heading" fill="#087f5b">20 Value-Aware Targeted Rules</text>
105
+ <text x="597.0" y="300.0" text-anchor="middle" class="body" fill="#125442">spread-property-drop, startsWith-&gt;includes, replaceAll</text>
106
+ <text x="597.0" y="318.0" text-anchor="middle" class="body" fill="#125442">clamp-bound, literal-set-prune, merge-precedence,</text>
107
+ <text x="597.0" y="336.0" text-anchor="middle" class="body" fill="#125442">??/||, ==/=== null, Math, sequence ends, finally cleanup</text>
108
+ <text x="597.0" y="354.0" text-anchor="middle" class="code" fill="#087f5b">Records "agreed" vs "differed in T" per test</text>
109
+
110
+ <!-- Arrows: Track A & Track B -> Vitest Worker Session -->
111
+ <path d="M 216.8 381.4 Q 267.8 406.0 320.7 428.0" fill="none" stroke="#6741d9" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
112
+ <path d="M 217.7 381.7 Q 269.0 403.7 320.6 427.2" fill="none" stroke="#6741d9" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
113
+ <path d="M 320.0 428.0 Q 315.1 428.6 310.0 429.0" fill="none" stroke="#6741d9" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
114
+ <path d="M 320.0 428.0 Q 315.1 428.6 310.0 429.0" fill="none" stroke="#6741d9" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
115
+ <path d="M 320.0 428.0 Q 317.0 424.0 314.1 419.9" fill="none" stroke="#6741d9" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
116
+ <path d="M 320.0 428.0 Q 317.0 423.9 314.1 419.9" fill="none" stroke="#6741d9" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
117
+ <path d="M 596.4 382.5 Q 547.5 403.9 499.9 428.0" fill="none" stroke="#0ca678" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
118
+ <path d="M 597.0 382.4 Q 549.9 405.3 500.0 427.3" fill="none" stroke="#0ca678" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
119
+ <path d="M 500.0 428.0 Q 502.9 423.9 505.7 419.8" fill="none" stroke="#0ca678" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
120
+ <path d="M 500.0 428.0 Q 502.8 423.9 505.7 419.8" fill="none" stroke="#0ca678" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
121
+ <path d="M 500.0 428.0 Q 505.0 428.4 509.9 428.8" fill="none" stroke="#0ca678" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
122
+ <path d="M 500.0 428.0 Q 505.0 428.3 509.9 428.8" fill="none" stroke="#0ca678" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
123
+
124
+ <!-- Step 2: Vitest 4 Worker Session -->
125
+ <rect x="138.0" y="434.0" width="550.0" height="82.0" rx="12" fill="#000000" opacity="0.045"/>
126
+ <rect x="134.3" y="429.2" width="550.0" height="82.0" rx="12" fill="#fff9db"/>
127
+ <path d="M 148.0 429.9 Q 410.8 429.6 673.7 430.6 Q 686.1 429.7 685.1 442.0 Q 685.5 470.7 685.2 499.4 Q 685.4 511.8 673.7 511.7 Q 410.8 510.2 148.0 511.9 Q 135.5 511.4 136.3 499.4 Q 135.8 470.7 136.1 442.0 Q 135.9 429.7 148.0 429.7" fill="none" stroke="#e67700" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" opacity="0.95"/>
128
+ <path d="M 147.7 430.1 Q 410.1 429.1 672.4 429.5 Q 684.9 429.9 684.6 441.5 Q 684.2 470.5 684.8 499.4 Q 684.1 510.9 672.4 511.1 Q 410.1 510.3 147.7 511.6 Q 135.6 511.6 136.2 499.4 Q 136.1 470.5 136.3 441.5 Q 135.2 429.7 147.7 428.9" fill="none" stroke="#e67700" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.55"/>
129
+ <text x="410.0" y="458.0" text-anchor="middle" class="heading" fill="#d9480f">2. Switched Vitest 4 Worker Session</text>
130
+ <text x="410.0" y="480.0" text-anchor="middle" class="body" fill="#6c4200">Runs only tests that reach each edit via in-worker runtime switches.</text>
131
+ <text x="410.0" y="497.0" text-anchor="middle" class="body" fill="#6c4200">Immediate post-trial control run catches state leaks (auto-fallback to fresh run).</text>
132
+
133
+ <!-- Arrows: Session -> 3 Outcomes -->
134
+ <path d="M 239.9 511.8 Q 196.8 535.7 154.4 560.3" fill="none" stroke="#2f9e44" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
135
+ <path d="M 240.1 512.6 Q 197.6 536.4 154.7 559.8" fill="none" stroke="#2f9e44" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
136
+ <path d="M 155.0 560.0 Q 157.6 555.6 160.1 551.4" fill="none" stroke="#2f9e44" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
137
+ <path d="M 155.0 560.0 Q 157.5 555.8 160.0 551.4" fill="none" stroke="#2f9e44" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
138
+ <path d="M 155.0 560.0 Q 160.1 560.0 165.0 560.1" fill="none" stroke="#2f9e44" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
139
+ <path d="M 155.0 560.0 Q 160.0 560.0 165.0 560.1" fill="none" stroke="#2f9e44" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
140
+ <rect x="134.0" y="525.0" width="82.0" height="17" rx="4" fill="#ffffff" opacity="0.92"/>
141
+ <text x="175.0" y="537.0" text-anchor="middle" class="edge-label" fill="#2f9e44">test fails</text>
142
+ <path d="M 410.0 512.2 Q 441.1 535.4 472.5 559.7" fill="none" stroke="#e03131" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
143
+ <path d="M 409.8 511.8 Q 440.6 535.5 471.9 559.9" fill="none" stroke="#e03131" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
144
+ <path d="M 472.0 560.0 Q 467.1 559.3 462.1 558.6" fill="none" stroke="#e03131" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
145
+ <path d="M 472.0 560.0 Q 467.1 559.3 462.1 558.7" fill="none" stroke="#e03131" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
146
+ <path d="M 472.0 560.0 Q 470.1 555.4 468.2 550.7" fill="none" stroke="#e03131" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
147
+ <path d="M 472.0 560.0 Q 470.0 555.3 468.2 550.8" fill="none" stroke="#e03131" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
148
+ <rect x="333.8" y="525.0" width="132.4" height="17" rx="4" fill="#ffffff" opacity="0.92"/>
149
+ <text x="400.0" y="537.0" text-anchor="middle" class="edge-label" fill="#e03131">all pass + agreed</text>
150
+ <path d="M 579.8 512.3 Q 720.5 535.8 859.2 559.9" fill="none" stroke="#d9480f" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
151
+ <path d="M 579.8 511.7 Q 720.5 535.6 860.2 560.0" fill="none" stroke="#d9480f" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
152
+ <path d="M 860.0 560.0 Q 855.3 561.8 850.6 563.5" fill="none" stroke="#d9480f" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
153
+ <path d="M 860.0 560.0 Q 855.4 561.7 850.6 563.5" fill="none" stroke="#d9480f" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
154
+ <path d="M 860.0 560.0 Q 856.1 556.9 852.3 553.6" fill="none" stroke="#d9480f" stroke-width="1.9" stroke-linecap="round" opacity="1"/>
155
+ <path d="M 860.0 560.0 Q 856.2 556.7 852.3 553.6" fill="none" stroke="#d9480f" stroke-width="1.6" stroke-linecap="round" opacity="0.65"/>
156
+ <rect x="653.6" y="525.0" width="182.8" height="17" rx="4" fill="#ffffff" opacity="0.92"/>
157
+ <text x="745.0" y="537.0" text-anchor="middle" class="edge-label" fill="#d9480f">all pass + differed in T</text>
158
+
159
+ <!-- Outcome 1: killed -->
160
+ <rect x="43.0" y="566.0" width="225.0" height="118.0" rx="12" fill="#000000" opacity="0.045"/>
161
+ <rect x="40.3" y="562.0" width="225.0" height="118.0" rx="12" fill="#ebfbee"/>
162
+ <path d="M 51.8 562.5 Q 152.3 562.5 252.9 562.0 Q 264.6 562.5 264.5 574.3 Q 264.4 621.2 264.9 668.1 Q 264.4 679.6 252.9 679.4 Q 152.3 679.1 51.8 680.6 Q 39.7 680.0 39.3 668.1 Q 39.3 621.2 40.0 574.3 Q 39.6 562.1 51.8 562.6" fill="none" stroke="#2f9e44" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" opacity="0.95"/>
163
+ <path d="M 51.1 563.1 Q 152.5 564.0 253.8 562.7 Q 266.4 563.4 265.8 574.9 Q 266.1 621.1 266.1 667.3 Q 265.8 679.3 253.8 678.6 Q 152.5 679.6 51.1 678.9 Q 38.6 678.9 39.7 667.3 Q 38.1 621.1 39.5 574.9 Q 39.2 563.3 51.1 562.7" fill="none" stroke="#2f9e44" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.55"/>
164
+ <text x="152.0" y="590.0" text-anchor="middle" class="heading" fill="#2b8a3e">killed</text>
165
+ <text x="152.0" y="615.0" text-anchor="middle" class="body" fill="#21572c">At least one test failed.</text>
166
+ <text x="152.0" y="633.0" text-anchor="middle" class="body" fill="#21572c">Your suite already</text>
167
+ <text x="152.0" y="651.0" text-anchor="middle" class="body" fill="#21572c">distinguishes this edit.</text>
168
+
169
+ <!-- Outcome 2: INPUT GAP -->
170
+ <rect x="293.0" y="566.0" width="365.0" height="118.0" rx="12" fill="#000000" opacity="0.045"/>
171
+ <rect x="290.4" y="562.2" width="365.0" height="118.0" rx="12" fill="#fff5f5"/>
172
+ <path d="M 302.6 561.5 Q 473.3 560.5 644.0 561.7 Q 656.3 561.0 656.1 573.2 Q 656.2 620.6 655.5 668.0 Q 655.8 680.0 644.0 680.6 Q 473.3 679.0 302.6 680.0 Q 290.5 679.6 290.7 668.0 Q 289.8 620.6 290.0 573.2 Q 290.8 561.0 302.6 561.6" fill="none" stroke="#e03131" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" opacity="0.95"/>
173
+ <path d="M 301.8 561.8 Q 472.9 563.0 644.0 562.4 Q 655.6 561.5 656.1 573.7 Q 654.7 620.8 656.7 667.9 Q 655.7 680.5 644.0 679.5 Q 472.9 681.1 301.8 679.8 Q 289.7 679.7 290.4 667.9 Q 290.0 620.8 289.7 573.7 Q 290.3 562.2 301.8 561.0" fill="none" stroke="#e03131" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.55"/>
174
+ <text x="472.0" y="590.0" text-anchor="middle" class="heading" fill="#c92a2a">INPUT GAP (missing case)</text>
175
+ <text x="472.0" y="613.0" text-anchor="middle" class="body" fill="#691b1b">Edit agreed on every observed evaluation.</text>
176
+ <text x="472.0" y="631.0" text-anchor="middle" class="body" fill="#691b1b">Names the exact missing input or boundary:</text>
177
+ <text x="472.0" y="649.0" text-anchor="middle" class="code" fill="#a61e4d">expect(isAdult(18)).toBe(true)</text>
178
+
179
+ <!-- Outcome 3: ASSERTION GAP -->
180
+ <rect x="683.0" y="566.0" width="400.0" height="118.0" rx="12" fill="#000000" opacity="0.045"/>
181
+ <rect x="680.5" y="562.2" width="400.0" height="118.0" rx="12" fill="#fff4e6"/>
182
+ <path d="M 691.9 561.7 Q 879.5 562.4 1067.1 562.7 Q 1079.5 561.6 1079.8 574.1 Q 1080.3 621.2 1079.8 668.4 Q 1078.7 680.4 1067.1 680.8 Q 879.5 679.6 691.9 680.0 Q 680.2 680.1 680.4 668.4 Q 680.5 621.2 679.6 574.1 Q 679.8 562.6 691.9 562.5" fill="none" stroke="#d9480f" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round" opacity="0.95"/>
183
+ <path d="M 691.4 561.8 Q 879.3 560.9 1067.2 560.8 Q 1079.6 561.4 1079.8 573.5 Q 1078.7 620.8 1078.9 668.2 Q 1079.5 679.9 1067.2 680.7 Q 879.3 678.8 691.4 680.7 Q 679.7 679.8 678.7 668.2 Q 678.2 620.8 679.4 573.5 Q 679.6 561.8 691.4 560.9" fill="none" stroke="#d9480f" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.55"/>
184
+ <text x="880.0" y="590.0" text-anchor="middle" class="heading" fill="#d9480f">ASSERTION GAP (weak test)</text>
185
+ <text x="880.0" y="613.0" text-anchor="middle" class="body" fill="#6e2b07">Edit produced a different value in test T, yet T passed.</text>
186
+ <text x="880.0" y="631.0" text-anchor="middle" class="body" fill="#6e2b07">With --suggest-assertions, narrows to changed field:</text>
187
+ <text x="880.0" y="649.0" text-anchor="middle" class="code" fill="#b53a08">expect(res.fee).toBe(600)</text>
188
+ </svg>
package/docs/l1.md ADDED
@@ -0,0 +1,94 @@
1
+ # L1 grammar and candidate contract
2
+
3
+ The native grammar recognizes a bounded subset of TypeScript modules, a restricted control program, and a limited set of TSX initializers. Lexical rules operate on UTF-8 with ASCII identifiers and punctuation. The grammar below illustrates the control and JSX subset used by the reference model and initial native entry points. The module and expression extensions are described below it.
4
+
5
+ ```text
6
+ file ::= trivia (declaration ";"? | control statement* | var-init ";" statement*)? trivia EOF
7
+ declaration ::= "export"? "const" identifier "=" (parameter "=>" result | result)
8
+ parameter ::= "(" identifier ":" "number" ")"
9
+ result ::= comparison | element
10
+ comparison ::= atom (operator atom)?
11
+ atom ::= (identifier | "this") ("." property)* | decimal | "(" comparison ")"
12
+ operator ::= "<" | "<=" | ">" | ">="
13
+ element ::= "<" jsx-name attribute* "/" ">"
14
+ attribute ::= jsx-name "=" (jsx-string | "{" comparison "}")
15
+ control ::= "if" "(" comparison ")" block ("else" block)?
16
+ | "while" "(" comparison ")" block
17
+ | "do" block "while" "(" comparison ")" ";"?
18
+ | "for" "(" (("let" | "var") identifier "=" comparison)? ";" comparison? ";" update? ")" block
19
+ block ::= "{" statement* "}"
20
+ statement ::= control | update ";" | ";"
21
+ var-init ::= "var" identifier "=" comparison
22
+ update ::= identifier ("++" | "--")
23
+ ```
24
+
25
+ The ordinary lexical mode skips spaces, tabs, LF, CR, CRLF, U+2028, U+2029, and UTF-8 line and block comments. A hashbang at byte zero uses the same line terminators and preserves original byte positions. A line break, including one in a block comment, is forbidden between the parameter's closing parenthesis and the arrow. Identifiers have the ASCII structure of JavaScript identifiers without escapes and exclude reserved words. Declaration and parameter names also exclude `eval` and `arguments`. JSX names allow hyphens after the first character and have no reserved-word restriction. An unsigned decimal is an ASCII digit sequence with no leading zero except the literal zero. JSX attribute strings have matching single or double quotes and may contain UTF-8, including comparison punctuation. JSX tag delimiters use the tag whitespace rules. Tokens around opening-tag attributes accept ordinary whitespace and comments. In an attribute expression the ordinary lexical mode resumes.
26
+
27
+ Property names after a dot use ASCII identifier characters and may be reserved words. Prefix and postfix update expressions use the simple assignment-target rules. A postfix update permits no line break before the operator. A `var` loop initializer is allowed in a standalone file-scope control program. Classic loop heads admit bounded expression lists and typed `let` or `const` binding lists, including nested patterns. A simple `var` initializer is supported in a function. Loop bindings use a nested scope and are restored when the loop ends. The `var` reader accepts simple typed or initialized bindings. The bounded native route delegates a function that mixes `var` with potentially conflicting lexical declarations. Collection loops use `let` or `const` with an identifier or a bounded nested binding pattern. A switch can contain case tests, a single optional default clause, and a shared lexical scope. Unlabelled `break` requires an enclosing loop or switch. Unlabelled `continue` requires an enclosing loop. Both permissions reset at a function boundary. Try, catch, and finally bodies are explicit blocks. A catch can have no binding, a named binding, or a bounded nested binding pattern.
28
+
29
+ The module grammar accepts side-effect, named, default, and namespace imports and type-only default and named imports. Dynamic `import()` accepts a specifier and optional options expression. The `import.meta` expression is available throughout a module. Variables can bind simple names or nested object and array patterns, with array elisions, simple defaults and a final named rest binding. Simple mutable declarations can use a definite assignment marker with a type annotation. Default exports support assignment expressions and named or anonymous function and class declarations. A default export can appear once per module. Name tables distinguish module types from values and reserve both namespaces for imports and classes. Plain and type-only star and named re-exports accept a quoted source. Named re-exports support ASCII aliases, including `default`. Empty export lists are supported. Nonempty local export lists delegate for forward resolution. Simple `declare const`, `declare let` and `declare var` bindings require annotations. Nested function declarations, named and anonymous function expressions, and ordinary and async object methods share the bounded function-body parser. Named functions support optional typed parameters and default expressions. Functions can contain local type aliases, including the single statement of a control body. Function and arrow parameter lists admit a simple rest binding in the final slot. Await expressions and `for await…of` are available in modules and async bodies, with a fresh permission at every function boundary.
30
+
31
+ Class declarations can use bounded type parameters, a simple qualified base, and an implements list. The fast path reads uninitialized and initialized fields, and supported ordinary, static, async, accessor, generator and constructor methods. ASCII identifier method names, including override and access-modified methods, can have adjacent typed overload signatures followed by an implementation with the same name and modifiers. A constructor may have adjacent typed signatures before its single implementation. Default exports can declare an abstract class, and typed constructor parameter properties can infer their type from an initializer. Adjacent named default function overloads with the same name and async modifier consume a single export and require a matching implementation. Methods can access `super` properties and derived constructors can call `super`. Arrows inherit these permissions. Ordinary functions reset them.
32
+
33
+ ASCII private fields, methods and ordinary dot accesses participate in the native grammar. The parser records a bounded log of class scopes, declarations and accesses, including references that precede their declaration. Validation checks duplicates and lexical ownership before candidate publication. A full log has 255 events. Private brand checks, optional private chains, and private accessors delegate.
34
+
35
+ Explicit script mode also uses the expanded statement sequence, including CommonJS assignments and dynamic imports. An initial exact `"use strict"` or `'use strict'` directive with an explicit semicolon or a recognized automatic semicolon boundary enables nested function declarations in explicit blocks inside functions. Static imports, exports and import meta syntax retain their module requirements. The reader supports ordinary and const TypeScript enum declarations with bounded member initializers.
36
+
37
+ Generator declarations, default exports, and generator methods of classes and object literals can use the existing `yield` statement and delegated `yield*` grammar. The yield permission belongs to the generator body. Nested ordinary functions reset it. Ambient generator declarations, bodyless generator signatures, and generator constructors delegate.
38
+
39
+ Destructuring defaults can use the bounded expression parser, including qualified members, calls, class expressions and comparisons. Variable slots stay reserved while a default is parsed. Collection loop heads accept a simple existing identifier and a simple function-local `var` when the existing binding-mode restrictions are met. Plain and type-only star re-exports can use an ASCII namespace alias. Conditional tuple constraints accept direct `infer` elements with their own `extends` bounds.
40
+
41
+ Named module-level abstract classes and ambient classes admit typed bodyless members. Ambient classes can declare constructor signatures. Simple decimal member names are accepted in classes and object types. Computed class fields, class methods and binding keys admit identifiers, qualified identifier chains and unescaped quoted strings of ASCII identifier characters. Module classes admit ordinary optional typed signatures, including generic signatures, and declaration-only typed fields with `declare` first. Required and optional declaration fields may use supported property names and access, static or readonly modifiers. Flat parenthesized object assignment patterns can write to existing simple names and dotted members, including members rooted at `this`. The read-only pattern lookahead leaves ordinary object expressions on the existing expression path. A noncomputed object literal key in colon form can set the prototype once per object. Constructor calls support `this`, parenthesized operands and a computed index in a qualified target. A closing call parenthesis can resolve a less-than operator followed by a trailing argument comma. The regex reader accepts selected category and identifier-property escapes and bounded code-point escapes in Unicode mode. Ordinary functions, class methods and field initializers admit `new.target`; arrows inherit that context.
42
+
43
+ The type grammar accepts named and qualified references, nested type arguments, numeric, string and template literal types, bounded conditional types with inferred names, arrays, labeled, rest and optional generic tuple elements, indexed access, grouped and function types, and object types with computed and ordinary properties, typed indexes, call signatures, constructor signatures and generic methods. Type aliases, interfaces, and named functions can use bounded type parameter lists with constraints and defaults. Interfaces accept canonical in and out variance modifiers, including in out. Object types support identifier getter signatures with empty parameters, and typed signatures may end with a single-name object binding. Interfaces accept bounded lists of qualified base references. Quoted ambient modules accept bodies containing plain or exported interfaces, which may merge. Function-like result positions admit type predicates and assertion signatures. A typed leading `this` parameter has no runtime binding. Type operators include `keyof` and qualified `typeof` queries. A quoted module specifier is supported in import types.
44
+
45
+ The expression parser uses precedence for comparisons, relational `in` and `instanceof`, arithmetic, equality, bitwise and logical operators, shifts, conditionals, and assignments. Assignments associate to the right and allow a postfix non-null assertion on a supported target, including a simple name, member, or computed target. Other supported forms include selected unary operators, `delete` on member and optional-chain expressions, strings, bounded numeric literals, template substitutions, calls, qualified constructors, sparse arrays, spreads, and computed names for object properties and methods. String values and template segments support fixed-width hexadecimal and Unicode escapes, bounded Unicode code points, and escaped line endings. Tagged templates retain the full tag and template span, including tags followed by a line break. The reader preserves raw escape spellings and parses substitutions. Calls with attached type arguments use read-only lookahead before the call parser consumes arguments. Named and qualified constructors may omit the argument list at a closing delimiter or end of input. A line break can also end the construction before a supported declaration, loop, or dotted member statement. Generic instantiation expressions may end at a statement or expression delimiter. Member, index and call chains can use optional access. Nullish coalescing requires parentheses when mixed with `&&` or `||`. Arrow functions support type parameters, typed parameters with simple defaults, bounded nested binding patterns, return annotations, and expression or block bodies. In TSX the generic head must have a comma, constraint or default to distinguish it from an opening tag. TypeScript `as` and `satisfies` operators and postfix non-null assertions require no preceding line break. Unsupported angle bracket forms, including generic tags, and unsupported operators decline the entire file.
46
+
47
+ The regex literal reader supports character classes and ranges, basic escapes including `\0` without a following decimal digit, numeric references to captures already opened, balanced capturing and noncapturing groups, ASCII named captures, lookarounds, alternation, quantifiers, and distinct `d`, `g`, `i`, `m`, `s`, `u`, and `y` flags. Raw BMP scalars can occur as atoms or range endpoints. Character classes can also contain isolated fixed-width surrogate escapes. Adjacent Unicode escape pairs remain delegated. Range ordering uses the decoded values. Raw line separators, astral scalars and the `v` flag delegate. Outside character classes, the non-Unicode grammar supports `\:`, a bare `]`, and a bare `{` when the next byte is outside the decimal digit range. These forms require legacy regex mode. The flat scanner uses a loop in generated C. Group nesting is bounded at 32 and counted quantifiers use at most six decimal digits. Unrecognized regex forms delegate with the rest of the source.
48
+
49
+ TSX uses the expression parser for self-closing and paired elements, fragments, and nested JSX. Attribute values can be quoted, braced or nested JSX, and openings can use boolean and spread attributes. Inside children, raw text uses JSX lexical rules and braces return to ordinary expression parsing. Tag closures must match the opening name. A direct disjunction in a `disabled` attribute delegates to preserve the focused logical rewrite.
50
+
51
+ Constrained infer types are supported inside template type interpolations and object property annotations. A type signature can end with a typed object parameter containing up to sixteen plain shorthand bindings. Quoted property names accept fixed non-ASCII Unicode escapes. A TypeScript default export can assert the type of an object literal followed by a semicolon or the end of the source. Escaped ASCII spellings that could affect special property names are delegated.
52
+
53
+ The module grammar records up to 512 top-level bindings and up to 512 bindings across the currently open function and block scopes, including parameters. A third region tracks up to 512 export names separately. Individual lists retain their own bounds. Speculative parameter and collection heads use scratch entries above the active scope. Arrow blocks share the statement parser's recursion budget, and closing a block restores the caller's active names. Duplicate or oversized bindings decline the entire module. If both recognizers decline an input, no partial candidates are published.
54
+
55
+ Direct script and module `var` declarations use the same binding table as lexical declarations, including conflict checks. A leading script var enters the expanded statement reader first so an automatic semicolon after a long initializer does not trigger a full reparse. The restricted control reader is still available for its root control forms. Module mode alone enables static imports and exports and module-level await. Ordinary block and module statement lists can declare initialized resources with `using`; async contexts also support `await using`. Resource declarations share the lexical binding checks and admit identifier names. Direct switch clauses and script top levels stay on the compatibility path for these declarations. The module reader also accepts a terminal TypeScript `export = expression` following imports and declarations with no registered named or default export. In script functions a recognized raw strict directive, or inherited strict context, enables exact function-local var scoping. The expanded parser can defer up to 64 local export lists and checks their unresolved names against the completed module bindings. A function using both declaration kinds triggers a second parse with an exact log of up to 512 live names. On block exit the parser checks that block’s lexical names against its own and descendant `var` declarations. It passes hoisted names to the enclosing block and reclaims the closed lexical names. Nested functions own independent suffixes. Adjacent local overload signatures share the value binding of a matching implementation. A type-only module namespace can merge with an interface of the same name, and a function block can declare a local interface. A type-only namespace can contain up to eight levels of exported type-only namespaces. Each level sees a separate binding range and releases its member names after its closing brace. Declaration-only namespaces can export simple names already bound in the module, and plain exported interfaces can reopen an existing plain exported interface. Ambient enums accept numeric initializers. A global augmentation can declare a typed `var` without an initializer or an ambient function with at most one typed parameter and a return annotation. Modules mixing those two ambient member families use compatibility so their names can be checked together. A duplicate or incomplete scope delegates before it can publish comparison candidates.
56
+
57
+ The fast path accepts at most 1,048,576 source bytes, bounds expression and control recursion, and publishes up to 4,096 candidates. The addon starts with room for 64 candidates below 16 KiB and 128 candidates at larger input sizes before using its existing heap retry. Near the recursive stack limit, an uninterrupted run of singleton array wrappers can be read in flat passes. The reported depth still includes those wrappers and structures within the innermost array. Byte spans are half-open and relative to the original file. A comparison candidate contains the rule version, original operator, replacement operator, operator span, and both operand spans including syntactic parentheses. Candidates appear in source order of operator start, including nested comparisons. EOF must be reached before publishing the candidate buffer.
58
+
59
+ The versioned boundary rule is `comparison-boundary/v1`. Each of the four operators maps to the same strictness family with the equality bit toggled. Scope restrictions and UTF-8 validation precede the recognizer. The AST-free result is reported as `path: "fast"`.
60
+
61
+ After finding a module value-name collision, the native parser checks whether the full source is a sequence of simple `const` and `let` declarations with exactly one duplicate. The classifier supplies the first and repeated name spans in UTF-8 bytes once it reaches the end of the file. The compatibility parser handles other collisions, declarations and initializers. A native duplicate reports `path: "diagnostic"` and `reason: "duplicate-lexical"`.
62
+
63
+ When the Pulse parser declines a file, the normal build uses TypeScript's source parser and checks early syntax errors such as invalid assignment targets and duplicate bindings. It converts UTF-16 AST spans to UTF-8 bytes and reports a successful compatibility parse as `path: "fallback"` with `fallback: "typescript"`. A source error discards all candidates for that file. The compatibility diagnostics use their own wording and parser recovery.
64
+
65
+ The `--low-only` build compiles only the checked-in KaRaMeL C sources and the Node-API adapter. It can run `extract` in a checkout without npm dependencies. It reports a refusal for syntax outside the native grammar or over a resource limit.
66
+
67
+ Packaged installs use a generated syntax-only build of the pinned TypeScript compiler for compatibility parsing, threshold syntax and probe module classification. `npm run build:typescript-syntax` prepares it in a source checkout. The generator checks the upstream compiler digest, retains the declarations reachable from the extraction API and the required initializers, and copies the upstream license and notices. The package also installs the full compiler for witness and analysis APIs. A missing, incompatible or failing syntax build uses the full compiler. Once loaded, the full compiler serves these syntax consumers as well. Worker requests run in an isolated child process with a 16 MiB parser stack and use a dedicated pipe for the completed result. An ordinary caller retries through the same process if the parser exhausts its call stack. Exhausting the isolated resources raises a parser execution error.
68
+
69
+ Analysis maps ordered candidate byte offsets to UTF-16 line and column positions in one pass. The native scan uses 16-byte NEON or SSE2 blocks for ASCII without line endings. The scalar path handles other bytes and platforms. A verified Pulse byte reader recognizes U+2028 and U+2029 for both the grammar and the position scan.
70
+
71
+ ## Verification and measurements
72
+
73
+ `TmtReference.fst` parses lexer outputs into a complete AST for the declaration grammar with simple operands. Its compact interpretation computes operand spans and ordered candidates without expression trees. F★ checks equality of the two interpretations for every token sequence in that model, including failure, and checks acceptance for all ASTs admitted by the independently written bounded grammar predicate and printer. The verified Pulse routines used by the native parser implement bounds-checked reads, maximal character-class scans, operator recognition, and indexed candidate writes. These contracts start with a live input buffer of the supplied length and an allocated output buffer of the supplied capacity. The control and member syntax participates in the native safety contract. Its candidate equivalence is checked against Yuku by the extraction audit.
74
+
75
+ `TmtPulseParser.fst` implements the actual AST-free native grammar, recursive descent, lexical modes and EOF handling. Its extracted C runs in the ordinary Node-API entry point. F★ and Pulse check termination, buffer ownership, bounded accesses, the candidate count on success, complete initialization of the published prefix, consumption of the entire input buffer on success, and zero published candidates on failure. The lexical duplicate classifier also verifies complete input consumption and ordered, nonempty spans within the source. The C adapter supplies distinct buffers and their real lengths. A typechecked example evaluates the reference on the exact TSX token sequence and checks the candidate span and rejection of a malformed suffix.
76
+
77
+ `native_operator_backpatch` connects the byte-level operator scanner and the production comparison emitter to the reference interpretation of a comparison. Given correct child candidates, operand spans and a reserved slot, it proves the output slice equals the reference candidate list including byte spans and order. The correspondence between the full byte-level parser and the F★ reference token model still requires proof of these premises throughout parsing and tokenization. Buffer allocation, UTF-8 validation, C compilation, and Node-API marshalling remain in the trusted execution boundary. `candidateBytes` measures candidate heap allocations in the native adapter. The fixed stack allocation and JavaScript output objects have separate storage. The AST counter is zero by construction for this native parser.
78
+
79
+ The [corpus audits](performance.md) use full TypeScript and Yuku as development references for ordered candidate fields and source acceptance with the comparison and JSX logical rules. They compare the full diagnostic record for native duplicate declarations and invalid encoding.
80
+
81
+ ## Pulse native parser
82
+
83
+ `TmtPulseMemory.fst` separates the read-only fractional borrow of source bytes, the initialized binding table and candidate storage. Read-only grammar functions require only the source borrow and preserve the caller’s separate workspace through a polymorphic frame. The candidate writer owns slots through a Pulse mask and can write into uninitialized storage. It marks each slot after storing a candidate. The workspace invariant links every mark to an initialized slot. The parser clears the marks before its expanded retry and checks every slot below the final count. The exported parser ensures the prefix is initialized before the C adapter copies it. `TmtPulseScan.fst` proves the endpoint of the maximal byte-class scan and preserves the source. The other primitives prove exact byte, line-separator, comparison-token and candidate-slot behavior. The C adapter supplies a fresh initialized binding table and the real source and output lengths for each call.
84
+
85
+ F★ checks the grammar's existing mutually recursive termination measures. Grammar functions return Pulse `stt` computations. The sequencing helpers preserve each call in the extracted program, including writes whose result is discarded. F★ 2026.11.15 extracts the verified program through Custard `KrmlC` and KaRaMeL. KaRaMeL lowers source-length tail recursion to C loops. The native regression matrix checks in-limit and over-limit files in fresh processes.
86
+
87
+ The build can specialize the bounded comment and string scans with NEON on AArch64 and SSE2 on x86-64. The build checks the fingerprints of all three complete scalar functions before lowering. The accelerated loop reads 16 bytes only when both the input and its fuel permit it, then resumes scalar processing at the first possible sentinel or at the end of the block. The checked-in generated C is the scalar reference for proof regeneration. Tests compare the compiled SIMD and scalar results at every byte value and lane and at source boundaries. The SIMD primitive is part of the trusted native build boundary.
88
+
89
+ ```sh
90
+ FSTAR_EXE=/path/to/fstar.exe KARAMEL_EXE=/path/to/krml sh scripts/verify-fstar.sh
91
+ npm run build:native -- --pgo
92
+ ```
93
+
94
+ The build and runtime package compile the checked-in C. The [performance measurements](performance.md) describe the corpus comparison with the former Low★ parser.