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