1#!/usr/bin/env python3
2"""Generate compatibility.md from live Rust engine sources and real Fusion .comp corpora.
3
4Stdlib-only Python 3 script. Run from anywhere:
5 python3 scripts/gen_compatibility.py
6"""
7
8from __future__ import annotations
9
10import argparse
11import json
12import math
13import re
14import sys
15from collections import Counter
16from dataclasses import dataclass
17from pathlib import Path
18from typing import Any, Dict, List, Optional, Sequence, Set, Tuple
19
20REPO_ROOT = Path(__file__).resolve().parent.parent
21EVAL_RS = REPO_ROOT / "crates" / "engine" / "src" / "eval" / "mod.rs"
22EVAL_DIR_LABEL = "crates/engine/src/eval/"
23SCENE3D_DIR_LABEL = "crates/engine/src/scene3d/"
24SCENE3D_RS = REPO_ROOT / "crates" / "engine" / "src" / "scene3d" / "collect.rs"
25COMP_RS = REPO_ROOT / "crates" / "model" / "src" / "comp.rs"
26ADD_TOOL_RS = REPO_ROOT / "crates" / "app" / "src" / "add_tool.rs"
27SCHEMAS_RS = REPO_ROOT / "crates" / "app" / "src" / "inspector" / "schemas.rs"
28PROBES_PY = REPO_ROOT / "scripts" / "fusion_probes.py"
29LEDGER_JSON = REPO_ROOT / "scripts" / "accuracy_ledger.json"
30DEFAULT_OUTPUT = REPO_ROOT / "compatibility.md"
31
32ACTIVE_CORPUS_DIR = Path("/Volumes/Project/trees/fusion")
33ARCHIVE_CORPUS_DIR = REPO_ROOT / "private" / "samples"
34SHALE_ISSUES_URL = "https://shale.paperclover.net/fission/issues"
35
36
37@dataclass(frozen=True)
38class ToolMeta:
39 name: str
40 category: str
41 probe: str
42 mae: str
43 notes: str
44 aliases: Tuple[str, ...] = ()
45 badge: str = "" # "", "stochastic" (🎲), "diverging" (⚠️ Diverging), "ceiling" (⚠️)
46
47
48# Supported tools intentionally absent from the Add Tool launcher: created by other
49# tools or by grouping, or a duplicate spelling of a listed tool.
50ADD_TOOL_EXCLUDED: Set[str] = {
51 "PolylineStroke", # created by Paint
52 "Multistroke", # created by Paint
53 "MacroOperator", # created by grouping
54 "GroupOperator", # created by grouping
55 "Fuse.Switch", # Switch covers it
56}
57
58CATEGORIES: Sequence[str] = (
59 "Generators",
60 "Compositing & Blending",
61 "Color & Depth",
62 "Keying",
63 "Blur, Sharpen & Glow",
64 "Transform, Warp & Framing",
65 "Masks",
66 "2D Vector Shapes",
67 "Particles",
68 "3D Pipeline",
69 "Time, Routing & Utility",
70)
71
72# Structured metadata for every supported Flow tool.
73# Notes strictly state what is missing, diverging, or holding a tool back from 100%;
74# complete tools with no caveats use "—".
75# Any tool discovered in eval/ or scene3d/ that is missing here will be
76# flagged automatically so compatibility.md never drifts stale.
77TOOL_METADATA: Sequence[ToolMeta] = (
78 # Generators
79 ToolMeta("Background", "Generators", "`tier1_d`", "0.0%", "—"),
80 ToolMeta("FastNoise", "Generators", "`noise_text`", "0.0%", "—"),
81 ToolMeta("Plasma", "Generators", "`tier1_c`", "0.1%–0.2%", "Minor phase/gradient rounding on high-frequency rings."),
82 ToolMeta("TextPlus", "Generators", "`text`, `noise_text`", "0.2%–0.8%", "Subpixel glyph AA/shaping differs from Fusion's platform font engine.", badge="ceiling"),
83 ToolMeta("MultiText", "Generators", "Unit tests", "0.2%–0.8%", "Subpixel glyph AA/shaping differs from Fusion's platform font engine.", badge="ceiling"),
84 ToolMeta("Loader", "Generators", "All suites", "0.0%", "—"),
85 ToolMeta("MediaIn", "Generators", "Unit tests", "0.0%", "—"),
86 ToolMeta("DaySky", "Generators", "Unit tests", "0.4%–1.1%", "Minor twilight/horizon atmospheric scattering differences."),
87 ToolMeta("Mandel", "Generators", "Unit tests", "0.0%–0.2%", "—"),
88 ToolMeta("Fuse.CheckerPieceGenerator", "Generators", "Unit tests", "0.0%", "—"),
89 ToolMeta("Fuse.HexagonTiles", "Generators", "Unit tests", "0.0%", "—"),
90 ToolMeta("Fuse.Hexagon", "Generators", "Unit tests", "0.0%–0.2%", "—"),
91 ToolMeta("Fuse.Lightning", "Generators", "Unit tests", "Stochastic", "Procedural branch PRNG seed differs from Lua Fuse.", badge="stochastic"),
92 ToolMeta("Fuse.VORONOI_DIAGRAM", "Generators", "Unit tests", "0.0%–0.2%", "—"),
93
94 # Compositing & Blending
95 ToolMeta("Merge", "Compositing & Blending", "`merge`", "0.0%", "—"),
96 ToolMeta("MultiMerge", "Compositing & Blending", "Unit tests", "0.0%–0.3%", "—", aliases=("Fuse.MultiMerge",)),
97 ToolMeta("Dissolve", "Compositing & Blending", "`tier1_b`", "0.0%–0.1%", "—"),
98 ToolMeta("Fuse.Wipe", "Compositing & Blending", "Unit tests", "0.0%–0.2%", "—"),
99 ToolMeta("Paint", "Compositing & Blending", "Unit tests", "0.0%–1.2%", "Clone/Smear/Emboss apply modes and non-round image brushes not yet implemented."),
100 ToolMeta("PolylineStroke", "Compositing & Blending", "Unit tests", "0.0%–0.3%", "Rendered only inside `Paint` / `PaintMask`."),
101 ToolMeta("Multistroke", "Compositing & Blending", "Unit tests", "0.1%–1.2%", "Rendered only inside `Paint` / `PaintMask`."),
102 ToolMeta("Shadow", "Compositing & Blending", "`tier1_b`", "0.1%–0.4%", "—"),
103
104 # Color & Depth
105 ToolMeta("BrightnessContrast", "Color & Depth", "`color_ops`, `tier1_d`", "0.0%–0.1%", "—"),
106 ToolMeta("ColorCorrector", "Color & Depth", "`vortex_cc`, Suite comps", "0.0%–0.2%", "Histogram/Match/Suppress tabs not implemented."),
107 ToolMeta("ColorGain", "Color & Depth", "`color_ops`, `noise_text`", "0.0%", "—"),
108 ToolMeta("ColorCurves", "Color & Depth", "Suite comps", "0.0%–0.1%", "—"),
109 ToolMeta("HueCurves", "Color & Depth", "`tier1_a`", "0.1%–0.5%", "—"),
110 ToolMeta("GamutConvert", "Color & Depth", "Suite comps", "0.0%–0.2%", "—"),
111 ToolMeta("AcesTransform", "Color & Depth", "Unit tests", "0.0%–0.4%", "—"),
112 ToolMeta("ColorSpace", "Color & Depth", "Unit tests", "0.0%–0.2%", "—"),
113 ToolMeta("ColorMatrix", "Color & Depth", "Unit tests", "0.0%", "—"),
114 ToolMeta("CustomColorMatrix", "Color & Depth", "Unit tests", "0.0%", "—"),
115 ToolMeta("SetCanvasColor", "Color & Depth", "Unit tests", "0.0%", "—"),
116 ToolMeta("ChromaticAdaptation", "Color & Depth", "Unit tests", "0.0%–0.2%", "—"),
117 ToolMeta("ColorSpaceTransform", "Color & Depth", "Unit tests", "0.0%–0.4%", "—"),
118 ToolMeta("GamutLimiter", "Color & Depth", "Unit tests", "0.0%–0.2%", "—"),
119 ToolMeta("GamutMapping", "Color & Depth", "Unit tests", "0.0%–0.3%", "—"),
120 ToolMeta("FilmLookCreator", "Color & Depth", "Unit tests", "0.1%–0.5%", "—"),
121 ToolMeta("OCIOCDLTransform", "Color & Depth", "Unit tests", "0.0%", "—"),
122 ToolMeta("OCIOColorSpace", "Color & Depth", "Unit tests", "0.0%–0.4%", "Uses built-in color space matrices; external OCIO config files / `Look` not yet loaded."),
123 ToolMeta("OCIODisplay", "Color & Depth", "Unit tests", "0.0%–0.4%", "Uses built-in display transforms; external OCIO config files not yet loaded."),
124 ToolMeta("OCIOFileTransform", "Color & Depth", "Unit tests", "0.0%–0.2%", "CLF files apply first CDL/LUT node."),
125 ToolMeta("Swizzler", "Color & Depth", "Unit tests", "0.0%", "—"),
126 ToolMeta("CineonLog", "Color & Depth", "Unit tests", "0.0%–0.2%", "—"),
127 ToolMeta("LightTrim", "Color & Depth", "Unit tests", "0.0%", "—"),
128 ToolMeta("FileLUT", "Color & Depth", "Unit tests", "0.0%–0.2%", "—"),
129 ToolMeta("Fuse.LUTCubeCreator", "Color & Depth", "Unit tests", "0.0%", "—", aliases=("LUTCubeCreator",)),
130 ToolMeta("Fuse.LUTCubeApply", "Color & Depth", "Unit tests", "0.0%–0.2%", "—", aliases=("LUTCubeApply",)),
131 ToolMeta("Fuse.LUTCubeAnalyzer", "Color & Depth", "Unit tests", "0.0%", "—", aliases=("LUTCubeAnalyzer",)),
132 ToolMeta("WhiteBalance", "Color & Depth", "Unit tests", "0.0%–0.2%", "—"),
133 ToolMeta("AutoGain", "Color & Depth", "Unit tests", "0.0%–0.2%", "—"),
134 ToolMeta("ColorBalance", "Color & Depth", "Unit tests", "0.0%–0.2%", "—"),
135 ToolMeta("SoftClip", "Color & Depth", "Unit tests", "0.0%", "—"),
136 ToolMeta("InvertColor", "Color & Depth", "Suite comps", "0.0%", "—"),
137 ToolMeta("AlphaMultiply", "Color & Depth", "Snow Globe probe", "0.0%–0.2%", "—"),
138 ToolMeta("AlphaDivide", "Color & Depth", "Snow Globe probe", "0.0%–0.9%", "Minor precision difference near zero alpha."),
139 ToolMeta("PseudoColor", "Color & Depth", "Snow Globe probe", "0.4%–0.6%", "—"),
140 ToolMeta("ChannelBoolean", "Color & Depth", "`color_ops`", "0.0%–0.7%", "Unused auxiliary extra-channel slots and missing Coverage mask stripes differ."),
141 ToolMeta("ChangeDepth", "Color & Depth", "`tier1_d`", "0.0%–0.1%", "Random dither PRNG seed differs; collapsed to `Rgba8Unorm` in `Fast` mode."),
142 ToolMeta("Fuse.Colorize", "Color & Depth", "Suite comps", "0.1%–0.5%", "—"),
143
144 # Keying
145 ToolMeta("LumaKeyer", "Keying", "Suite comps", "0.1%–0.4%", "—"),
146 ToolMeta("UltraKeyer", "Keying", "`ultrakey`, `tier1_a`", "0.0%–0.4%", "Minor matte contract/expand fringe differences."),
147 ToolMeta("DeltaKeyer", "Keying", "Unit tests", "0.1%", "—"),
148 ToolMeta("DifferenceKeyer", "Keying", "Snow Globe probe", "0.1%–0.5%", "—"),
149 ToolMeta("ChromaKeyer", "Keying", "Snow Globe probe", "0.1%–0.6%", "—"),
150 ToolMeta("CleanPLate", "Keying", "Snow Globe probe", "0.1%–0.6%", "—", aliases=("CleanPlate",)),
151 ToolMeta("MatteControl", "Keying", "Unit tests", "0.1%–0.4%", "—"),
152 ToolMeta("Fuse.Cryptomatte", "Keying", "Unit tests", "0.0%", "—", aliases=("Cryptomatte",)),
153
154 # Blur, Sharpen & Glow
155 ToolMeta("Blur", "Blur, Sharpen & Glow", "`blur`, `tier1_d`", "0.0%–0.2%", "Downsampled in `Fast` mode; minor Box border rounding."),
156 ToolMeta("Defocus", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.4%", "—"),
157 ToolMeta("DepthBlur", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.5%", "—"),
158 ToolMeta("Fog", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.4%", "—"),
159 ToolMeta("VolumeFog", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.5%", "—"),
160 ToolMeta("SSAO", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.5%", "—"),
161 ToolMeta("Shader", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.5%", "—"),
162 ToolMeta("ChromaticAberrationRemoval", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.4%", "—"),
163 ToolMeta("Highlight", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.5%", "—"),
164 ToolMeta("HotSpot", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.5%", "—"),
165 ToolMeta("RankFilter", "Blur, Sharpen & Glow", "Unit tests", "0.0%–0.3%", "—"),
166 ToolMeta("Sharpen", "Blur, Sharpen & Glow", "`tier1_a`", "0.1%–0.3%", "Minor kernel radius rounding vs Fusion."),
167 ToolMeta("UnsharpMask", "Blur, Sharpen & Glow", "Unit tests", "0.0%–0.2%", "—"),
168 ToolMeta("Filter", "Blur, Sharpen & Glow", "`tier1_a`", "0.1%–0.3%", "Minor kernel normalization differences on non-default filter types."),
169 ToolMeta("CustomFilter", "Blur, Sharpen & Glow", "Unit tests", "0.0%–0.2%", "—"),
170 ToolMeta("CreateBumpMap", "Blur, Sharpen & Glow", "Unit tests", "0.0%–0.3%", "—"),
171 ToolMeta("CreateReliefMap", "Blur, Sharpen & Glow", "Unit tests", "0.0%–0.4%", "—"),
172 ToolMeta("TV", "Blur, Sharpen & Glow", "Unit tests", "Stochastic", "Scanline noise PRNG seed differs from Fusion.", badge="stochastic"),
173 ToolMeta("VariBlur", "Blur, Sharpen & Glow", "Suite comps", "0.2%–0.8%", "—"),
174 ToolMeta("DirectionalBlur", "Blur, Sharpen & Glow", "`blur`", "0.1%–0.5%", "—"),
175 ToolMeta("Glow", "Blur, Sharpen & Glow", "`glow`", "0.0%–0.5%", "Fusion reads uninitialized memory stripes on missing Coverage mask (`MaskChannel=7`)."),
176 ToolMeta("SoftGlow", "Blur, Sharpen & Glow", "`glow`", "0.0%–0.2%", "—"),
177 ToolMeta("Fuse.XGlow", "Blur, Sharpen & Glow", "Suite comps", "0.2%–0.8%", "Octave-capped in `Fast` mode."),
178 ToolMeta("ErodeDilate", "Blur, Sharpen & Glow", "`blur`", "0.0%–0.3%", "—"),
179 ToolMeta("VectorMotionBlur", "Blur, Sharpen & Glow", "Unit tests", "0.0%", "—"),
180 ToolMeta("RemoveNoise", "Blur, Sharpen & Glow", "Unit tests", "0.5%", "—"),
181 ToolMeta("VectorDenoise", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.5%", "—"),
182 ToolMeta("Fuse.OCLRays", "Blur, Sharpen & Glow", "Unit tests", "0.1%–0.5%", "—"),
183 ToolMeta("FilmGrain", "Blur, Sharpen & Glow", "`tier1_c`", "Stochastic", "Per-frame PRNG seed differs from Fusion.", badge="stochastic"),
184 ToolMeta("Grain", "Blur, Sharpen & Glow", "Unit tests", "Stochastic", "Per-frame PRNG seed differs from Fusion.", badge="stochastic"),
185 ToolMeta("Fuse.Outline", "Blur, Sharpen & Glow", "Suite comps", "0.1%–0.5%", "—"),
186 ToolMeta("Fuse.XfChroma", "Blur, Sharpen & Glow", "Suite comps", "0.1%–0.5%", "—"),
187 ToolMeta("Fuse.AlphaWeightedNoise", "Blur, Sharpen & Glow", "Unit tests", "Stochastic", "Per-pixel PRNG seed differs from Lua `math.random`.", badge="stochastic"),
188 ToolMeta("Fuse.Crystallize", "Blur, Sharpen & Glow", "Unit tests", "0.0%", "—"),
189
190 # Transform, Warp & Framing
191 ToolMeta("Transform", "Transform, Warp & Framing", "`xf`", "0.0%–0.3%", "—"),
192 ToolMeta("CameraShake", "Transform, Warp & Framing", "`tier1_c`", "0.1%–0.5%", "Minor filter-method resampling differences."),
193 ToolMeta("CornerPositioner", "Transform, Warp & Framing", "`tier1_b`", "0.1%–0.4%", "Minor perspective filter resampling differences."),
194 ToolMeta("PerspectivePositioner", "Transform, Warp & Framing", "Unit tests", "0.2%–0.4%", "Minor resampling differences; Fusion Coverage mask stripes differ on `MaskChannel=7`."),
195 ToolMeta("GridWarp", "Transform, Warp & Framing", "Unit tests", "0.4%–1.2%", "Magnet/Subdivision UI helpers not implemented."),
196 ToolMeta("CoordSpace", "Transform, Warp & Framing", "Unit tests", "0.0%–0.2%", "—"),
197 ToolMeta("Distort", "Transform, Warp & Framing", "Unit tests", "0.1%–0.4%", "—"),
198 ToolMeta("Texture", "Transform, Warp & Framing", "Unit tests", "0.0%–0.2%", "—"),
199 ToolMeta("VectorWarp", "Transform, Warp & Framing", "Unit tests", "0.1%–0.4%", "—"),
200 ToolMeta("LensDistort", "Transform, Warp & Framing", "Unit tests", "0.1%–0.4%", "—"),
201 ToolMeta("DVE", "Transform, Warp & Framing", "`tier1_b`", "0.1%–0.4%", "Minor 3D perspective edge AA differences."),
202 ToolMeta("Displace", "Transform, Warp & Framing", "`displace`, `displace_wave`", "0.0%–0.5%", "Minor refraction edge/filter differences."),
203 ToolMeta("Vortex", "Transform, Warp & Framing", "`vortex_cc`", "0.0%–0.4%", "Minor swirl boundary resampling differences."),
204 ToolMeta("Drip", "Transform, Warp & Framing", "Unit tests", "0.0%–0.7%", "High-frequency ripple phase rounding differs."),
205 ToolMeta("Dent", "Transform, Warp & Framing", "Unit tests", "0.0%–0.4%", "Minor radial falloff curve differences on non-default types."),
206 ToolMeta("Fuse.Duplicate", "Transform, Warp & Framing", "`archive_3d`", "0.0%–0.4%", "—"),
207 ToolMeta("Fuse.KScope", "Transform, Warp & Framing", "Unit tests", "0.0%", "—"),
208 ToolMeta("Scale", "Transform, Warp & Framing", "Suite comps", "0.0%–0.2%", "Minor non-default filter window differences."),
209 ToolMeta("BetterResize", "Transform, Warp & Framing", "Suite comps", "0.0%–0.2%", "Minor non-default filter window differences."),
210 ToolMeta("Crop", "Transform, Warp & Framing", "Suite comps", "0.0%–0.1%", "—"),
211 ToolMeta("Letterbox", "Transform, Warp & Framing", "Unit tests", "0.0%–0.2%", "—"),
212 ToolMeta("SetDomain", "Transform, Warp & Framing", "`tier1_d`", "0.0%–0.2%", "Minor `Adjust` mode DoD clamping differences."),
213
214 # Masks
215 ToolMeta("AutoMatte", "Masks", "Unit tests", "Native", "Fission-native 1-click AI matte node (SAM 2 + MatAnyone 2 / VideoMaMa + GPU hair-safe decontamination)."),
216 ToolMeta("MagicMask", "Masks", "Unit tests", "Diverging", "Diverging Implementation — uses Fission's `AutoMatte` segmentation + GPU hair-safe decontamination instead of Fusion's legacy stroke model.", badge="diverging"),
217 ToolMeta("EllipseMask", "Masks", "`mask`, `mask_softedge`", "0.0%–0.2%", "—"),
218 ToolMeta("RectangleMask", "Masks", "`mask`, `mask_softedge`", "0.0%–0.2%", "—"),
219 ToolMeta("TriangleMask", "Masks", "Unit tests", "0.0%–0.2%", "—"),
220 ToolMeta("PolylineMask", "Masks", "`mask_softedge`, Suite comps", "0.1%–0.4%", "—"),
221 ToolMeta("BSplineMask", "Masks", "Unit tests", "0.1%–0.4%", "—"),
222 ToolMeta("MultiPoly", "Masks", "Unit tests", "0.1%–0.4%", "—"),
223 ToolMeta("RangesMask", "Masks", "Unit tests", "0.0%–0.3%", "—"),
224 ToolMeta("VolumeMask", "Masks", "Unit tests", "0.1%–0.4%", "—"),
225 ToolMeta("TeapotMask", "Masks", "Unit tests", "0.1%–0.4%", "—"),
226 ToolMeta("BitmapMask", "Masks", "`mask_softedge`", "0.0%", "—"),
227 ToolMeta("WandMask", "Masks", "`archive_3d`", "0.0%–0.3%", "—"),
228 ToolMeta("PaintMask", "Masks", "Unit tests", "0.1%–0.4%", "Non-round brush shapes not implemented."),
229
230 # 2D Vector Shapes
231 ToolMeta("sRender", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
232 ToolMeta("sNGon", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
233 ToolMeta("sStar", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
234 ToolMeta("sRectangle", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
235 ToolMeta("sEllipse", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
236 ToolMeta("sPolygon", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
237 ToolMeta("sBSpline", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
238 ToolMeta("sText", "2D Vector Shapes", "Unit tests", "0.2%–0.6%", "Subpixel glyph AA/shaping differs from Fusion's platform font engine.", badge="ceiling"),
239 ToolMeta("sChangeStyle", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
240 ToolMeta("sGrid", "2D Vector Shapes", "Unit tests", "0.0%–0.1%", "—"),
241 ToolMeta("sMerge", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
242 ToolMeta("sTransform", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
243 ToolMeta("sDuplicate", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
244 ToolMeta("sJitter", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
245 ToolMeta("sExpand", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
246 ToolMeta("sOffset", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
247 ToolMeta("sBoolean", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
248 ToolMeta("sOutline", "2D Vector Shapes", "Unit tests", "0.0%", "—"),
249
250 # Particles
251 ToolMeta("pRender", "Particles", "Unit tests", "Stochastic", "2D mode only (no 3D particle renderer); PRNG seed differs.", badge="stochastic"),
252 ToolMeta("pEmitter", "Particles", "Unit tests", "Stochastic", "PRNG seed differs; cold starts >600 frames window-simulate.", badge="stochastic"),
253 ToolMeta("pPointForce", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
254 ToolMeta("pDirectionalForce", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
255 ToolMeta("pTurbulence", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
256 ToolMeta("pDrag", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", aliases=("pFriction",), badge="stochastic"),
257 ToolMeta("pKill", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
258 ToolMeta("pMerge", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
259 ToolMeta("pBounce", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
260 ToolMeta("pVortex", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
261 ToolMeta("pFlock", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
262 ToolMeta("pSpawn", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
263 ToolMeta("pChangeStyle", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
264 ToolMeta("pGradientForce", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
265 ToolMeta("pAvoid", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
266 ToolMeta("pCustom", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
267 ToolMeta("pCustomForce", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
268 ToolMeta("pFollow", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
269 ToolMeta("pImageEmitter", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
270 ToolMeta("pTangentForce", "Particles", "Unit tests", "Stochastic", "PRNG seed differs.", badge="stochastic"),
271
272 # 3D Pipeline
273 ToolMeta("Renderer3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.4%", "`Rgba8` target only (no float HDR 3D target yet); directional/spot shadow maps pending (`#46`)."),
274 ToolMeta("Camera3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.4%", "Depth-of-field / stereo not implemented."),
275 ToolMeta("Merge3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.4%", "Minor GPU rasterizer edge/lighting differences."),
276 ToolMeta("Transform3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.6%", "Minor rotation-order / rasterizer edge differences."),
277 ToolMeta("ImagePlane3D", "3D Pipeline", "`cam3d`", "0.1%–0.8%", "Minor visibility/shading differences vs OpenGL renderer."),
278 ToolMeta("Shape3D", "3D Pipeline", "`cam3d`, `cam3d_fov`", "0.1%–0.4%", "—"),
279 ToolMeta("Cube3D", "3D Pipeline", "Unit tests", "0.1%–0.4%", "—"),
280 ToolMeta("SurfaceFBXMesh", "3D Pipeline", "Unit tests", "Static", "Static mesh only (no skeletal skinning or morph animation)."),
281 ToolMeta("Text3D", "3D Pipeline", "`archive_3d`", "1.5%", "Bevels not implemented."),
282 ToolMeta("LightAmbient", "3D Pipeline", "Suite comps", "0.1%–0.4%", "—"),
283 ToolMeta("LightDirectional", "3D Pipeline", "Suite comps", "0.1%–0.4%", "Up to 4 directional lights per scene; shadow maps pending (`#46`)."),
284 ToolMeta("LightPoint", "3D Pipeline", "`archive_3d`", "0.1%–0.8%", "—"),
285 ToolMeta("LightSpot", "3D Pipeline", "`archive_3d`", "0.1%–0.8%", "Spot shadow maps pending (`#46`)."),
286 ToolMeta("LightDome", "3D Pipeline", "Unit tests", "0.1%–0.8%", "Textured dome maps approximated as uniform environment illumination."),
287 ToolMeta("MtlBlinn", "3D Pipeline", "`archive_3d`", "0.1%–0.5%", "Minor transmittance/specular highlight differences."),
288 ToolMeta("MtlCookTorrance", "3D Pipeline", "`archive_3d`", "0.5%–1.5%", "Refractive index / rough microfacet lobe differs slightly from Fusion OpenGL."),
289 ToolMeta("MtlPhong", "3D Pipeline", "`archive_3d`", "0.1%–0.7%", "Minor transparent diffuse alpha blending differences."),
290 ToolMeta("MtlWard", "3D Pipeline", "Unit tests", "0.1%–0.6%", "—"),
291 ToolMeta("MtlReflect", "3D Pipeline", "Unit tests", "0.1%–0.6%", "—"),
292 ToolMeta("MtlChanBool", "3D Pipeline", "Unit tests", "0.0%–0.3%", "—"),
293 ToolMeta("MtlMerge3D", "3D Pipeline", "Unit tests", "0.1%–0.5%", "—"),
294 ToolMeta("MtlPBRUber", "3D Pipeline", "Unit tests", "0.1%–0.5%", "—"),
295 ToolMeta("MtlStereoMix3D", "3D Pipeline", "Unit tests", "0.0%", "Evaluates primary eye material (mono renderer)."),
296 ToolMeta("SphereMap", "3D Pipeline", "Unit tests", "0.1%–0.5%", "—"),
297 ToolMeta("CubeMap", "3D Pipeline", "Unit tests", "0.1%–0.4%", "—"),
298 ToolMeta("FalloffOperator", "3D Pipeline", "Unit tests", "0.1%–0.6%", "—"),
299 ToolMeta("FastNoiseTexture3D", "3D Pipeline", "Unit tests", "0.1%–0.6%", "—"),
300 ToolMeta("TexCatcher", "3D Pipeline", "Unit tests", "0.1%–0.4%", "—"),
301 ToolMeta("TexGradient", "3D Pipeline", "Unit tests", "0.1%–0.4%", "—"),
302 ToolMeta("Fog3D", "3D Pipeline", "Unit tests", "0.1%–0.4%", "—"),
303 ToolMeta("Locator3D", "3D Pipeline", "Unit tests", "0.0%", "—"),
304 ToolMeta("Ribbon3D", "3D Pipeline", "Unit tests", "0.1%–0.5%", "—"),
305 ToolMeta("Triangulate3D", "3D Pipeline", "Unit tests", "0.0%", "—"),
306 ToolMeta("Weld3D", "3D Pipeline", "Unit tests", "0.0%–0.3%", "—"),
307 ToolMeta("UVMap", "3D Pipeline", "Unit tests", "0.1%–0.4%", "—"),
308 ToolMeta("Texture2DOperator", "3D Pipeline", "`archive_3d`", "0.0%–0.7%", "Minor wrap/filter edge differences."),
309 ToolMeta("TextureTransformOperator", "3D Pipeline", "Unit tests", "0.0%–0.4%", "Minor UV rotation-order resampling differences."),
310 ToolMeta("BumpMap", "3D Pipeline", "Unit tests", "0.1%–0.8%", "Minor tangent-space normal clamping differences."),
311 ToolMeta("ReplaceMaterial3D", "3D Pipeline", "`archive_3d`", "0.0%–0.4%", "—"),
312 ToolMeta("Override3D", "3D Pipeline", "`archive_3d`", "0.0%–0.2%", "Wireframe/material-ID exclusion edge cases pending."),
313 ToolMeta("Duplicate3D", "3D Pipeline", "`archive_3d`", "Stochastic", "Stochastic jitter PRNG seed differs from Fusion.", badge="stochastic"),
314 ToolMeta("Replicate3D", "3D Pipeline", "Unit tests", "0.1%–0.5%", "—"),
315 ToolMeta("Bender3D", "3D Pipeline", "Unit tests", "0.1%–0.5%", "—"),
316 ToolMeta("ReplaceNormals3D", "3D Pipeline", "`archive_3d`", "0.0%–0.4%", "—"),
317 ToolMeta("Displace3D", "3D Pipeline", "`archive_3d`", "0.2%–1.5%", "Minor vertex displacement normal recomputation differences."),
318
319 # Time, Routing & Utility
320 ToolMeta("Saver", "Time, Routing & Utility", "All suites", "0.0%", "Export supports PNG sequences, HDR OpenEXR (`f16`/`f32`), and MP4/ProRes4444."),
321 ToolMeta("MediaOut", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
322 ToolMeta("AutoDomain", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
323 ToolMeta("Fuse.FrameAverage", "Time, Routing & Utility", "Unit tests", "0.0%–0.2%", "Bounded-lookback temporal averaging window."),
324 ToolMeta("Dimension.OpticalFlow", "Time, Routing & Utility", "Unit tests", "0.1%", "—", aliases=("OpticalFlow",)),
325 ToolMeta("Dimension.CopyAux", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
326 ToolMeta("Dimension.RepairFrame", "Time, Routing & Utility", "Unit tests", "0.1%–0.5%", "—", aliases=("RepairFrame",)),
327 ToolMeta("Dimension.SmoothMotion", "Time, Routing & Utility", "Unit tests", "0.1%–0.4%", "—", aliases=("SmoothMotion",)),
328 ToolMeta("Dimension.Tween", "Time, Routing & Utility", "Unit tests", "0.1%–0.5%", "—", aliases=("Tween",)),
329 ToolMeta("PropagateDepth", "Time, Routing & Utility", "Unit tests", "0.1%–0.4%", "—", aliases=("Dimension.PropagateDepth",)),
330 ToolMeta("VectorTransform", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
331 ToolMeta("ZtoWorldPos", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
332 ToolMeta("LayerMuxer", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
333 ToolMeta("LayerRegex", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
334 ToolMeta("LayerRemover", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
335 ToolMeta("Fuse.FLS_CopyMetadata", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
336 ToolMeta("Fuse.SetMetaDataTC", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
337 ToolMeta("Fields", "Time, Routing & Utility", "Unit tests", "0.0%–0.2%", "—"),
338 ToolMeta("KeyStretcher", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
339 ToolMeta("Dummy", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
340 ToolMeta("TimeStretcher", "Time, Routing & Utility", "Suite comps", "0.0%–0.2%", "—"),
341 ToolMeta("TimeSpeed", "Time, Routing & Utility", "Suite comps", "0.0%", "—"),
342 ToolMeta("Trails", "Time, Routing & Utility", "Unit tests", "0.1%–0.5%", "Bounded-lookback temporal window (no stateful infinite feedback)."),
343 ToolMeta("Fuse.Linger", "Time, Routing & Utility", "Unit tests", "0.1%–0.4%", "Bounded-lookback temporal window."),
344 ToolMeta("Fuse.Null", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
345 ToolMeta("Fuse.SetMetaData", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
346 ToolMeta("Switch", "Time, Routing & Utility", "Suite comps", "0.0%", "—"),
347 ToolMeta("Fuse.Switch", "Time, Routing & Utility", "Suite comps", "0.0%", "—"),
348 ToolMeta("Fuse.SwitchElse", "Time, Routing & Utility", "Unit tests", "0.0%", "—"),
349 ToolMeta("PipeRouter", "Time, Routing & Utility", "Suite comps", "0.0%", "—"),
350 ToolMeta("Fuse.Wireless", "Time, Routing & Utility", "Suite comps", "0.0%", "—"),
351 ToolMeta("Tracker", "Time, Routing & Utility", "Suite comps", "0.0%", "—"),
352 ToolMeta("SurfaceTracker", "Time, Routing & Utility", "Suite comps", "0.1%–0.5%", "—"),
353 ToolMeta("Dimension.PlanarTracker", "Time, Routing & Utility", "Unit tests", "0.0%", "—", aliases=("PlanarTracker",)),
354 ToolMeta("Dimension.PlanarTransform", "Transform, Warp & Framing", "Unit tests", "0.0%", "—", aliases=("PlanarTransform",)),
355 ToolMeta("MacroOperator", "Time, Routing & Utility", "Suite comps", "0.0%", "Internal subgraph is read-only in interactive Flow."),
356 ToolMeta("GroupOperator", "Time, Routing & Utility", "Suite comps", "0.0%", "Internal subgraph is read-only in interactive Flow."),
357 ToolMeta("Custom", "Time, Routing & Utility", "Suite comps", "0.0%–1.8%", "11/12 frames are 100.0%; Fusion reads uninitialized memory stripes on missing Coverage mask (`MaskChannel=7`).", badge="ceiling"),
358 ToolMeta("Note", "Time, Routing & Utility", "—", "N/A", "Non-rendering Flow annotation.", aliases=("StickyNote",)),
359 ToolMeta("Underlay", "Time, Routing & Utility", "—", "N/A", "Non-rendering Flow backdrop.", ),
360)
361
362
363@dataclass(frozen=True)
364class ModifierMeta:
365 display_name: str
366 classes: Tuple[str, ...]
367 probe: str
368 notes: str
369
370
371MODIFIER_METADATA: Sequence[ModifierMeta] = (
372 ModifierMeta("`BezierSpline`", ("BezierSpline",), "All suites", "Cubic Bezier / linear / `StepIn` / `StepOut` keyframes, animated `StyledText`, and animated `Polyline` point splines."),
373 ModifierMeta("`LUTBezier`", ("LUTBezier",), "`tier1_a`", "Curve lookup splines used standalone and nested inside `ColorCurves` / `HueCurves`."),
374 ModifierMeta("`PolyPath` / `Path`", ("PolyPath", "Path"), "Suite comps", "2D motion-path polyline evaluation with animated `Displacement` spline."),
375 ModifierMeta("`Shake`", ("Shake",), "`tier1_c`", "Procedural multi-octave noise modifier (`Source = X / Y / Value / Position`) with spline & expression inputs."),
376 ModifierMeta("`Expression`", ("Expression",), "Unit tests", "Standalone Fusion `Expression` modifier (`NumberExpression`, `PointExpressionX`/`Y`, `n1..n9`/`p1..p9` inputs, math DSL + Lua fallback)."),
377 ModifierMeta("`StyledTextCLS`", ("StyledTextCLS", "CharacterLevelStyling"), "Suite comps", "Per-character `TextPlus` styling overrides (font, size, color, kerning, opacity)."),
378 ModifierMeta("`TrackerModifier`", ("TrackerModifier",), "Suite comps", "Resolves baked tracker path aliases (`Track1TrackerPath`, etc.) into 2D `PolyPath` coordinates."),
379 ModifierMeta("Lua Expressions", (), "Suite comps", "Inline `Expression = \"...\"` evaluation (`time`, `comp.RenderStart`/`End`, node input references, math/trig/clamp/ternary)."),
380)
381
382
383@dataclass(frozen=True)
384class UnsupportedMeta:
385 name: str
386 behavior: str
387 issue: Optional[int] = None
388
389
390# Curated notes for prominent real-world unsupported / OFX / Resolve tools.
391UNSUPPORTED_NOTES: Sequence[UnsupportedMeta] = (
392 UnsupportedMeta("SurfaceAlembicMesh", "Preserved lossless on save; passes through main input in Flow."),
393)
394
395
396def parse_eval_rs(path: Path) -> Set[str]:
397 """Extract all supported tool class names from eval_node_inner in eval/mod.rs."""
398 text = path.read_text(encoding="utf-8")
399 m = re.search(r"fn eval_node_inner\b.*?(?=\n fn |\n\})", text, re.S)
400 if not m:
401 raise RuntimeError(f"Could not locate eval_node_inner in {path}")
402 body = m.group(0)
403 tools: Set[str] = set()
404 for mm in re.finditer(r"matches!\(\s*node\.kind\.as_str\(\),\s*([^)]+)\)", body, re.S):
405 tools.update(re.findall(r'"([^"]+)"', mm.group(1)))
406 for mm in re.finditer(r'node\.kind\s*==\s*"([^"]+)"', body):
407 tools.add(mm.group(1))
408 mm = re.search(r"match node\.kind\.as_str\(\)\s*\{(.*?)\n\s*other =>", body, re.S)
409 if not mm:
410 raise RuntimeError(f"Could not locate main match in eval_node_inner in {path}")
411 for arm in re.finditer(r'((?:"[^"]+"\s*(?:\|\s*)?)+)=>', mm.group(1), re.S):
412 tools.update(re.findall(r'"([^"]+)"', arm.group(1)))
413 return tools
414
415
416def _top_level_match_arms(text: str, header: str) -> Set[str]:
417 """String literals in the arm patterns of the first `match` whose header regex matches.
418
419 Tracks brace depth instead of source indentation, so arms are found at any nesting.
420 """
421 m = re.search(header, text, re.S)
422 if not m:
423 raise RuntimeError(f"Could not locate match header /{header}/")
424 names: Set[str] = set()
425 depth = 1
426 pattern = ""
427 for line in text[m.end():].splitlines():
428 code = re.sub(r'"(?:[^"\\]|\\.)*"', '""', line)
429 if depth == 1:
430 pattern += line + "\n"
431 if "=>" in line:
432 names.update(re.findall(r'"([^"]+)"', pattern.split("=>", 1)[0]))
433 pattern = ""
434 depth += code.count("{") - code.count("}")
435 if depth <= 0:
436 break
437 if depth > 1:
438 pattern = ""
439 return names
440
441
442def parse_scene3d_rs(path: Path) -> Set[str]:
443 """Extract supported 3D tool class names from the scene collection and material-resolution matches."""
444 text = path.read_text(encoding="utf-8")
445 return _top_level_match_arms(text, r"match node\.kind\.as_str\(\)\s*\{") | _top_level_match_arms(
446 text, r"fn resolve_material_inner\b.*?match n\.kind\.as_str\(\)\s*\{"
447 )
448
449
450def parse_is_supported_tool(path: Path) -> Set[str]:
451 """Return every class name accepted by `is_supported_tool` in comp.rs."""
452 text = path.read_text(encoding="utf-8")
453 m = re.search(r"fn is_supported_tool\b.*?matches!\(\s*kind,(.*?)\n \)", text, re.S)
454 if not m:
455 raise RuntimeError(f"Could not locate is_supported_tool in {path}")
456 return set(re.findall(r'"([^"]+)"', re.sub(r"//[^\n]*", "", m.group(1))))
457
458
459def parse_add_tool_catalog(path: Path) -> Set[str]:
460 """Return every `kind` listed in TOOL_CATALOG of add_tool.rs."""
461 return set(re.findall(r'ToolEntry\s*\{\s*kind:\s*"([^"]+)"', path.read_text(encoding="utf-8")))
462
463
464def parse_curated_tool_kinds(path: Path) -> Set[str]:
465 """Return every tool kind listed in CURATED_TOOL_KINDS of inspector/schemas.rs."""
466 text = path.read_text(encoding="utf-8")
467 m = re.search(r"const CURATED_TOOL_KINDS:\s*&\[&str\]\s*=\s*&\[(.*?)\];", text, re.S)
468 if not m:
469 raise RuntimeError(f"Could not locate CURATED_TOOL_KINDS in {path}")
470 return set(re.findall(r'"([^"]+)"', re.sub(r"//[^\n]*", "", m.group(1))))
471
472
473def parse_comp_rs_modifiers(path: Path) -> Tuple[List[str], Set[str]]:
474 """Return (declared MODIFIER_TYPES, implemented modifier classes in parse_tools_table)."""
475 texts = [path.read_text(encoding="utf-8")]
476 load_rs = path.with_name("comp") / "load.rs"
477 if load_rs.exists():
478 texts.append(load_rs.read_text(encoding="utf-8"))
479 combined = "\n".join(texts)
480 mc = re.search(r"const MODIFIER_TYPES:\s*&\[&str\]\s*=\s*&\[(.*?)\];", combined, re.S)
481 declared = re.findall(r'"([^"]+)"', mc.group(1)) if mc else []
482 declared_set = set(declared)
483 mp = re.search(r"fn parse_tools_table\b.*", combined, re.S)
484 implemented: Set[str] = set()
485 if mp:
486 for mm in re.finditer(r'kind\s*==\s*"([^"]+)"', mp.group(0)):
487 if mm.group(1) in declared_set:
488 implemented.add(mm.group(1))
489 return declared, implemented
490
491
492def parse_probe_suites(path: Path) -> Set[str]:
493 """Extract registered probe suite names from scripts/fusion_probes.py."""
494 if not path.exists():
495 return set()
496 text = path.read_text(encoding="utf-8")
497 m = re.search(r"builders\s*=\s*\{(.*?)\}", text, re.S)
498 if not m:
499 return set()
500 return set(re.findall(r'"([^"]+)"\s*:', m.group(1)))
501
502
503TOOL_RE = re.compile(
504 r'^(\t+)(?:\["[^"]+"\]|[A-Za-z_][A-Za-z0-9_]*)\s*=\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\{'
505)
506TOOLS_BLOCK_RE = re.compile(r"^(\t+)Tools\s*=\s*(?:ordered\(\)\s*)?\{")
507
508
509def count_tool_classes(text: str) -> Counter[str]:
510 """Count tool classes in every `Tools` block, including those nested in Macro/Group operators."""
511 counts: Counter[str] = Counter()
512 block_indents: List[int] = [] # tab depth of each open Tools block
513 for line in text.splitlines():
514 stripped = line.lstrip("\t")
515 depth = len(line) - len(stripped)
516 if block_indents and depth <= block_indents[-1] and stripped.startswith("}"):
517 block_indents.pop()
518 continue
519 if block_indents and depth == block_indents[-1] + 1:
520 tm = TOOL_RE.match(line)
521 if tm:
522 counts[tm.group(2)] += 1
523 continue
524 if TOOLS_BLOCK_RE.match(line):
525 block_indents.append(depth)
526 return counts
527
528
529def scan_comp_corpus(root: Path) -> Optional[Tuple[int, Counter[str]]]:
530 """Tool-class counts over all *.comp files under root."""
531 if not root.exists():
532 return None
533 comp_files = sorted(root.rglob("*.comp"))
534 if not comp_files:
535 return None
536 counts: Counter[str] = Counter()
537 for path in comp_files:
538 try:
539 counts += count_tool_classes(path.read_text(encoding="utf-8", errors="replace"))
540 except OSError:
541 continue
542 return len(comp_files), counts
543
544
545def format_usage(
546 names: Sequence[str],
547 active: Optional[Tuple[int, Counter[str]]],
548 archive: Optional[Tuple[int, Counter[str]]],
549) -> str:
550 if active is None and archive is None:
551 return "—"
552 a_str = str(sum(active[1][n] for n in names)) if active is not None else "—"
553 b_str = str(sum(archive[1][n] for n in names)) if archive is not None else "—"
554 return f"{a_str} / {b_str}"
555
556
557def format_coverage(
558 corpus: Optional[Tuple[int, Counter[str]]],
559 supported_classes: Set[str],
560 fallback_label: str,
561) -> str:
562 if corpus is None:
563 return fallback_label
564 n_files, counts = corpus
565 total = sum(counts.values())
566 if total == 0:
567 return f"0.0% (0 nodes across {n_files} comps)"
568 covered = sum(v for k, v in counts.items() if k in supported_classes)
569 pct = 100.0 * covered / total
570 return f"**{pct:.1f}%** ({covered:,} / {total:,} nodes across {n_files} `.comp` files)"
571
572
573def load_ledger(path: Path) -> Dict[str, Any]:
574 """Fuzzed accuracy ledger written by scripts/fuzz_node.py; empty when never run."""
575 return json.loads(path.read_text(encoding="utf-8")) if path.exists() else {}
576
577
578def format_accuracy(pct: float, *, exact: bool = False) -> str:
579 """Format an accuracy percentage, rounding DOWN and only awarding ✅ 100% on literal 100%."""
580 if exact and pct >= 100.0:
581 return "✅ 100%"
582 if pct >= 99.9:
583 floored = min(99.99, math.floor(pct * 100.0 + 1e-9) / 100.0)
584 return f"{floored:.2f}%"
585 floored = math.floor(pct * 10.0 + 1e-9) / 10.0
586 return f"{floored:.1f}%"
587
588
589def format_tool_accuracy(meta: ToolMeta, entry: Optional[Dict[str, Any]]) -> str:
590 """Format a tool's Accuracy cell, applying stochastic (🎲), diverging (⚠️), or ceiling (⚠️) badges."""
591 if meta.badge == "diverging":
592 return "⚠️ Diverging"
593 if meta.badge == "stochastic":
594 if entry is not None:
595 return f"🎲 {format_accuracy(entry['mean_accuracy'], exact=False)}"
596 return "🎲"
597 if meta.badge == "ceiling":
598 if entry is not None:
599 return f"⚠️ {format_accuracy(entry['mean_accuracy'], exact=False)}"
600 return f"⚠️ {legacy_accuracy(meta.mae)}"
601 if entry is not None:
602 has_known_gap = bool(meta.notes and meta.notes != "—")
603 is_exact = (
604 entry["mean_accuracy"] >= 100.0
605 and entry["min_accuracy"] >= 100.0
606 and not has_known_gap
607 )
608 return format_accuracy(entry["mean_accuracy"], exact=is_exact)
609 return legacy_accuracy(meta.mae)
610
611
612def legacy_accuracy(mae: str) -> str:
613 """Estimated `100% - MAE%` for tools not yet in accuracy_ledger.json (never awards ✅ 100%)."""
614 nums = [float(n) for n in re.findall(r"\d+(?:\.\d+)?", mae)]
615 if not nums or "%" not in mae:
616 return mae
617 best_str = format_accuracy(100.0 - min(nums), exact=False)
618 worst_str = format_accuracy(100.0 - max(nums), exact=False)
619 if best_str == worst_str:
620 return f"~{best_str}"
621 return f"~{worst_str}–{best_str}"
622
623
624def build_markdown(
625 eval_tools: Set[str],
626 scene3d_tools: Set[str],
627 impl_modifiers: Set[str],
628 comp_supported: Set[str],
629 catalog_kinds: Set[str],
630 curated_kinds: Set[str],
631 probe_suites: Set[str],
632 active_corpus: Optional[Tuple[int, Counter[str]]],
633 archive_corpus: Optional[Tuple[int, Counter[str]]],
634 ledger: Dict[str, Any],
635) -> Tuple[str, List[str]]:
636 """Build compatibility.md text and return (markdown, warnings)."""
637 warnings: List[str] = []
638
639 # Validate probe suite names referenced in metadata
640 if probe_suites:
641 for meta in TOOL_METADATA:
642 for suite in re.findall(r"`([a-z0-9_]+)`", meta.probe):
643 if suite not in probe_suites:
644 warnings.append(f"Tool {meta.name} references unknown probe suite '{suite}'")
645 for mmeta in MODIFIER_METADATA:
646 for suite in re.findall(r"`([a-z0-9_]+)`", mmeta.probe):
647 if suite not in probe_suites:
648 warnings.append(f"Modifier {mmeta.display_name} references unknown probe suite '{suite}'")
649
650 live_engine_tools = eval_tools | scene3d_tools
651 meta_by_name: Dict[str, ToolMeta] = {m.name: m for m in TOOL_METADATA}
652 meta_all_names: Set[str] = set(meta_by_name.keys())
653 for m in TOOL_METADATA:
654 meta_all_names.update(m.aliases)
655 non_render_tools = {"Note", "Underlay"}
656
657 # Detect drift: tools in eval/ or scene3d/ not in TOOL_METADATA
658 uncategorized = sorted(live_engine_tools - meta_all_names)
659 for name in uncategorized:
660 warnings.append(f"Uncategorized tool found in engine source: {name}")
661
662 # Detect stale metadata: tools in TOOL_METADATA no longer in engine source (excluding Note/Underlay)
663 stale = sorted((set(meta_by_name.keys()) - non_render_tools) - live_engine_tools)
664 for name in stale:
665 warnings.append(f"Stale tool in metadata not found in {EVAL_DIR_LABEL} or {SCENE3D_DIR_LABEL}: {name}")
666
667 # Detect uncategorized modifiers
668 known_mod_classes: Set[str] = set()
669 for mm in MODIFIER_METADATA:
670 known_mod_classes.update(mm.classes)
671 uncategorized_mods = sorted(impl_modifiers - known_mod_classes)
672 for name in uncategorized_mods:
673 warnings.append(f"Uncategorized modifier found in comp.rs: {name}")
674
675 # is_supported_tool() must accept exactly the metadata classes (plus modifier classes).
676 for name in sorted(comp_supported - meta_all_names - known_mod_classes):
677 warnings.append(f"is_supported_tool accepts {name} but TOOL_METADATA has no entry")
678 for name in sorted(((live_engine_tools | non_render_tools) & set(meta_by_name)) - comp_supported):
679 warnings.append(f"is_supported_tool rejects {name} although the engine evaluates it")
680
681 # Add Tool launcher must offer every user-creatable supported tool and nothing unsupported.
682 for name in sorted(set(meta_by_name) - ADD_TOOL_EXCLUDED - catalog_kinds):
683 warnings.append(f"add_tool.rs TOOL_CATALOG is missing {name}")
684 for name in sorted(catalog_kinds - comp_supported):
685 warnings.append(f"add_tool.rs TOOL_CATALOG lists {name} which is not supported")
686 for name in sorted(catalog_kinds & ADD_TOOL_EXCLUDED):
687 warnings.append(f"add_tool.rs TOOL_CATALOG lists {name} which ADD_TOOL_EXCLUDED omits")
688
689 # Inspector curated schemas must only reference supported tools in TOOL_METADATA.
690 for name in sorted(curated_kinds - comp_supported):
691 warnings.append(f"inspector/schemas.rs CURATED_TOOL_KINDS lists {name} which is not in is_supported_tool()")
692 for name in sorted(curated_kinds - meta_all_names):
693 warnings.append(f"inspector/schemas.rs CURATED_TOOL_KINDS lists {name} which is not in TOOL_METADATA")
694
695 all_supported_tools = live_engine_tools | non_render_tools
696 all_supported_classes = all_supported_tools | impl_modifiers
697
698 lines: List[str] = []
699 lines.append("<!-- Auto-generated by scripts/gen_compatibility.py. Do not edit by hand. -->")
700 lines.append("")
701 lines.append("# Fusion 21.1 Compatibility")
702 lines.append("")
703 lines.append(
704 f"Fission currently supports **{len(all_supported_tools)}** built-in tool types across 2D/3D compositing "
705 "plus a native **Lua + GPU-accelerated DCTL Fuse runtime** for external `.fuse` plugins. "
706 "This document tracks parity with Blackmagic Fusion Studio 21.1. "
707 "The main metric, **accuracy**, is the inverse of the image's "
708 "[mean absolute error](https://en.wikipedia.org/wiki/Mean_absolute_error), "
709 "meaning `100%` accuracy means the pixels are all identical. "
710 "For details, see [`scripts/fuzz_node.py`](scripts/fuzz_node.py)."
711 )
712 lines.append("")
713
714 # Top summary table
715 lines.append("## Summary")
716 lines.append("")
717 lines.append("| Metric | Value |")
718 lines.append("| --- | --- |")
719 lines.append(f"| **Supported Tools** | **{len(all_supported_tools)}** |")
720 lines.append(f"| **Modifiers & Animation** | **{len(MODIFIER_METADATA)}** |")
721 fuzzed = {n: e for n, e in ledger.get("tools", {}).items() if n in live_engine_tools}
722 if fuzzed:
723 mean = sum(e["mean_accuracy"] for e in fuzzed.values()) / len(fuzzed)
724 all_exact = all(e["mean_accuracy"] >= 100.0 and e["min_accuracy"] >= 100.0 for e in fuzzed.values())
725 supported_tools_cell = f"**{format_accuracy(mean, exact=all_exact)}**"
726 else:
727 supported_tools_cell = "_Not measured_"
728 exact_100_count = 0
729 over_999_count = 0
730 for m in TOOL_METADATA:
731 if m.name not in live_engine_tools and m.name not in non_render_tools:
732 continue
733 entry = fuzzed.get(m.name)
734 acc_cell = format_tool_accuracy(m, entry)
735 if acc_cell == "✅ 100%":
736 exact_100_count += 1
737 if entry is not None and entry["mean_accuracy"] > 99.9 and m.badge not in ("diverging", "stochastic"):
738 over_999_count += 1
739 paper = ledger.get("paper_clover")
740 if paper:
741 paper_exact = paper["mean_accuracy"] >= 100.0 and paper.get("min_accuracy", 0.0) >= 100.0
742 paper_cell = f"**{format_accuracy(paper['mean_accuracy'], exact=paper_exact)}**"
743 else:
744 paper_cell = "_Not measured_"
745 # Denominators queried directly from stock Fusion Render Node 21.1 (`fu:GetRegList()` visible CT_Tool)
746 # and WeSuckLess/Reactor (`Atoms/**/*.fuse`, 2026-12-01).
747 fusion_builtin_total = 378
748 non_stock_builtin = {
749 "AutoMatte",
750 "ColorMatrix", "ColorBalance", "sOffset",
751 "LUTCubeCreator", "LUTCubeApply", "LUTCubeAnalyzer",
752 "RepairFrame", "SmoothMotion", "Tween", "Dimension.PropagateDepth",
753 "GroupOperator", "MacroOperator", "PipeRouter", "InvertColor",
754 "PolylineStroke", "Multistroke", "OpticalFlow", "PlanarTracker", "PlanarTransform", "pDrag",
755 "Fuse.AlphaWeightedNoise", "Fuse.CheckerPieceGenerator", "Fuse.Colorize",
756 "Fuse.Cryptomatte", "Fuse.Crystallize", "Fuse.Hexagon", "Fuse.HexagonTiles",
757 "Fuse.KScope", "Fuse.Lightning", "Fuse.Linger", "Fuse.MultiMerge", "Fuse.Null",
758 "Fuse.OCLRays", "Fuse.Outline", "Fuse.SetMetaData", "Fuse.Switch", "Fuse.SwitchElse",
759 "Fuse.VORONOI_DIAGRAM", "Fuse.Wipe", "Fuse.XGlow", "Fuse.XfChroma",
760 }
761 builtin_supported = len(all_supported_tools - non_stock_builtin)
762 builtin_pct = 100.0 * builtin_supported / fusion_builtin_total
763 reactor_fuses_total = 1031
764 reactor_supported = sorted(
765 t for t in (
766 "Fuse.XGlow", "Fuse.Cryptomatte", "Fuse.XfChroma", "Fuse.Switch", "Fuse.SwitchElse",
767 "Fuse.HexagonTiles", "Fuse.Hexagon", "Fuse.Lightning", "Fuse.VORONOI_DIAGRAM",
768 "Fuse.Wipe", "Fuse.Null", "Fuse.SetMetaData", "Fuse.Linger", "Fuse.OCLRays",
769 "Fuse.MultiMerge",
770 )
771 if t in all_supported_tools
772 )
773 reactor_pct = 100.0 * len(reactor_supported) / reactor_fuses_total
774
775 lines.append(f"| **Accuracy across [paper clover](https://paperclover.net)'s compositions** | {paper_cell} |")
776 lines.append(f"| **Supported Tool Accuracy** | {supported_tools_cell} |")
777 lines.append(f"| **Supported Tools with 100% Accuracy** | **{exact_100_count}** |")
778 lines.append(f"| **Supported Tools with >99.9% Accuracy** | **{over_999_count}** |")
779 lines.append(f"| **Coverage of Fusion's Built-in Tools** | **{builtin_pct:.1f}%** |")
780 lines.append(f"| **Native Reactor Fuse Implementations** | **{reactor_pct:.1f}%** (+ dynamic Lua/DCTL runtime) |")
781 lines.append("")
782 lines.append("### Key")
783 lines.append("")
784 lines.append("- `✅ 100%` — Literal `100%` pixel-exact match against Blackmagic Fusion Studio 21.1 across every fuzzed frame, with no known unimplemented paths. Anything `< 100%` (or with known ways to differ) is rounded down (capped at `99.99%`).")
785 lines.append("- `~` — Estimated from unit tests or Snow Globe probes (not yet measured in `scripts/accuracy_ledger.json`).")
786 lines.append("- `🎲` — Stochastic / PRNG-driven (statistically and visually matched; Fusion's internal random seed is irreproducible).")
787 lines.append("- `⚠️` — Diverging implementation (intentionally uses a different algorithm or UX from Fusion) or a practical parity ceiling noted in **Notes**.")
788 lines.append("")
789
790 # Categorized tool tables
791 for cat in CATEGORIES:
792 cat_tools = [m for m in TOOL_METADATA if m.category == cat and (m.name in live_engine_tools or m.name in non_render_tools)]
793 if not cat_tools:
794 continue
795 lines.append(f"## {cat}")
796 lines.append("")
797 if cat == "3D Pipeline":
798 lines.append(
799 "Each 3D tool's accuracy is measured by rendering it inside a lit `Merge3D` + `Camera3D` + `Renderer3D` "
800 "(`RendererOpenGL`) scene while varying that tool's own parameters. `Renderer3D` accuracy varies "
801 "`Renderer3D`'s own settings (lighting, shadows, overscan, etc.) on a fixed 3D scene, whereas each "
802 "shape, light, camera, and material row varies that specific tool's inputs."
803 )
804 lines.append("")
805 lines.append("| Tool | Accuracy | Notes |")
806 lines.append("| --- | --- | --- |")
807 for m in cat_tools:
808 acc_cell = format_tool_accuracy(m, fuzzed.get(m.name))
809 lines.append(f"| `{m.name}` | {acc_cell} | {m.notes or '—'} |")
810 lines.append("")
811
812 # Drift-detection table if any new tools appeared in Rust sources
813 if uncategorized:
814 lines.append("## Uncategorized (New in Engine)")
815 lines.append("")
816 lines.append("> [!WARNING]")
817 lines.append(f"> The following tools were found in `{EVAL_DIR_LABEL}` / `{SCENE3D_DIR_LABEL}` but are not yet listed in `TOOL_METADATA` in `scripts/gen_compatibility.py`.")
818 lines.append("")
819 lines.append("| Tool |")
820 lines.append("| --- |")
821 for name in uncategorized:
822 lines.append(f"| `{name}` |")
823 lines.append("")
824
825 # Modifiers & Animation table
826 lines.append("## Modifiers & Animation")
827 lines.append("")
828 lines.append("| Modifier / System | Notes |")
829 lines.append("| --- | --- |")
830 for mm in MODIFIER_METADATA:
831 lines.append(f"| {mm.display_name} | {mm.notes} |")
832 for name in uncategorized_mods:
833 lines.append(f"| `{name}` | _Uncategorized modifier detected in `comp.rs`._ |")
834 lines.append("")
835
836 # Preserved & Passthrough (Roundtrip-Safe) section
837 lines.append("## Preserved & Passthrough (Roundtrip-Safe)")
838 lines.append("")
839 lines.append(
840 "Unlike Blackmagic Fusion — which unlinks missing OFX or Resolve-only plugins when opening a `.comp` — "
841 "**Fission preserves all unknown and unsupported tools losslessly** (every parameter, custom input, binary blob, "
842 "position, and upstream/downstream wire is retained verbatim on save) and **passes through their main input** "
843 "during Flow evaluation so downstream compositing stays connected."
844 )
845 lines.append("")
846
847 lines.append("| Tool Class | Issue | Notes |")
848 lines.append("| --- | --- | --- |")
849 for meta in UNSUPPORTED_NOTES:
850 issue_str = f"[#{meta.issue}]({SHALE_ISSUES_URL}/{meta.issue})" if meta.issue else "—"
851 lines.append(f"| `{meta.name}` | {issue_str} | {meta.behavior} |")
852 lines.append("")
853
854 lines.append("---")
855 lines.append("")
856 lines.append(
857 f"For tracked gaps, known parity edge cases, and roadmap items, see "
858 f"[shale.paperclover.net/fission/issues]({SHALE_ISSUES_URL})."
859 )
860 lines.append("")
861
862 return "\n".join(lines), warnings
863
864
865def main() -> int:
866 parser = argparse.ArgumentParser(description="Generate compatibility.md from live engine sources.")
867 parser.add_argument("-o", "--output", type=Path, default=DEFAULT_OUTPUT, help="Output markdown path.")
868 parser.add_argument("--active-dir", type=Path, default=ACTIVE_CORPUS_DIR, help="Active Fusion .comp directory.")
869 parser.add_argument("--archive-dir", type=Path, default=ARCHIVE_CORPUS_DIR, help="Archive Fusion .comp directory.")
870 parser.add_argument("--strict", action="store_true", help="Exit non-zero on any registry drift: engine vs TOOL_METADATA vs is_supported_tool vs add_tool.rs vs inspector/schemas.rs.")
871 parser.add_argument("--check", action="store_true", help="Check if compatibility.md is up to date without rewriting it; exit non-zero if out of date.")
872 args = parser.parse_args()
873
874 eval_tools = parse_eval_rs(EVAL_RS)
875 scene3d_tools = parse_scene3d_rs(SCENE3D_RS)
876 _, impl_modifiers = parse_comp_rs_modifiers(COMP_RS)
877 probe_suites = parse_probe_suites(PROBES_PY)
878
879 active_corpus = scan_comp_corpus(args.active_dir)
880 archive_corpus = scan_comp_corpus(args.archive_dir)
881
882 md, warnings = build_markdown(
883 eval_tools=eval_tools,
884 scene3d_tools=scene3d_tools,
885 impl_modifiers=impl_modifiers,
886 comp_supported=parse_is_supported_tool(COMP_RS),
887 catalog_kinds=parse_add_tool_catalog(ADD_TOOL_RS),
888 curated_kinds=parse_curated_tool_kinds(SCHEMAS_RS),
889 probe_suites=probe_suites,
890 active_corpus=active_corpus,
891 archive_corpus=archive_corpus,
892 ledger=load_ledger(LEDGER_JSON),
893 )
894
895 out_of_date = False
896 if args.check:
897 existing = args.output.read_text(encoding="utf-8") if args.output.exists() else None
898 if existing == md:
899 print(f"{args.output} is up to date ({len(md.splitlines())} lines)")
900 else:
901 out_of_date = True
902 print(f"{args.output} is out of date; run python3 scripts/gen_compatibility.py to update.", file=sys.stderr)
903 else:
904 args.output.write_text(md, encoding="utf-8")
905 print(f"Wrote {args.output} ({len(md.splitlines())} lines)")
906 if active_corpus is not None:
907 print(f" Active corpus: {active_corpus[0]} comps, {sum(active_corpus[1].values()):,} entries")
908 else:
909 print(f" Active corpus: skipped ({args.active_dir} not found)")
910 if archive_corpus is not None:
911 print(f" Archive corpus: {archive_corpus[0]} comps, {sum(archive_corpus[1].values()):,} entries")
912 else:
913 print(f" Archive corpus: skipped ({args.archive_dir} not found)")
914
915 for w in warnings:
916 print(f"WARNING: {w}", file=sys.stderr)
917
918 if (args.strict and warnings) or out_of_date:
919 return 1
920 return 0
921
922
923if __name__ == "__main__":
924 raise SystemExit(main())