ultrafast-ops 0.2.1

ultrafast's op vocabulary: the op registry and param packing, built-in components, the machine-readable schema and the document check (CPU only)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
//! Machine-readable op vocabulary: every op's ports and params with types,
//! defaults and meaning. Agents read it (`ultrafast ops`, the live `ops` request)
//! and `ultrafast check` uses it to flag misspelled or mistyped params.

use serde_json::{Value, json};
use ultrafast_graph::{Document, Param};

/// (name, type, default, description)
type P = (&'static str, &'static str, &'static str, &'static str);

const PLACEMENT: &[P] = &[
    ("position", "vec2", "[0,0]", "where the anchor lands, px"),
    ("anchor", "vec2", "[0,0]", "pivot in the node's own space, px"),
    ("scale", "vec2|number", "[1,1]", "scale around the anchor"),
    ("rotation", "number", "0", "degrees, clockwise"),
];

const STROKE: &[P] = &[
    ("stroke", "number", "0", "stroke width px; 0 fills"),
    ("join", "enum(miter|round|bevel)", "miter", "stroke joins"),
    ("cap", "enum(butt|round|square)", "butt", "stroke caps"),
    ("dash", "number[]", "", "dash pattern [on, off, ...] px"),
    ("dash_offset", "number", "0", "dash phase px"),
];

struct OpSchema {
    name: &'static str,
    summary: &'static str,
    ports: &'static [&'static str],
    params: &'static [P],
    /// Shared param groups appended to `params`.
    extra: &'static [&'static [P]],
}

const GRADIENT: &[P] = &[
    ("kind", "enum(linear|radial|conic)", "linear", "gradient shape"),
    ("a", "color", "", "start color (with b: a two-stop gradient)"),
    ("b", "color", "", "end color"),
    (
        "stops",
        "text|number[]",
        "",
        "\"0:#ff0000, 1:#0000ff\" or [pos,r,g,b,a,...], up to 8",
    ),
    (
        "space",
        "enum(linear|srgb)",
        "linear",
        "interpolation space; srgb matches CSS/Figma",
    ),
    ("start", "vec2", "[0,0]", "linear: start point px"),
    ("end", "vec2", "[0,h]", "linear: end point px"),
    ("center", "vec2", "frame center", "radial/conic center px"),
    ("radius", "number", "max(w,h)/2", "radial radius px"),
    ("angle", "number", "0", "conic start angle, degrees"),
];

const SCHEMAS: &[OpSchema] = &[
    OpSchema {
        name: "solid",
        summary: "flat color",
        ports: &[],
        params: &[("color", "color", "#000000", "fill color")],
        extra: &[],
    },
    OpSchema {
        name: "gradient",
        summary: "linear, radial or conic gradient",
        ports: &[],
        params: GRADIENT,
        extra: &[],
    },
    OpSchema {
        name: "shape",
        summary: "analytic rectangle / rounded rect / ellipse (SDF, antialiased)",
        ports: &[],
        params: &[
            ("kind", "enum(rect|ellipse|circle)", "rect", "shape"),
            ("color", "color", "#ffffff", "fill (or stroke) color"),
            ("center", "vec2", "frame center", "center px"),
            ("size", "vec2", "[w/4,w/4]", "width and height px"),
            ("radius", "number", "0", "corner radius px"),
            ("rotation", "number", "0", "degrees"),
            (
                "scale",
                "number|vec2",
                "1",
                "scale about the center (size, corners and stroke)",
            ),
            ("opacity", "number", "1", "0..1, fades the shape"),
            ("stroke", "number", "0", "outline width px; 0 fills"),
            ("softness", "number", "1", "edge softness in output pixels"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "checker",
        summary: "checkerboard",
        ports: &[],
        params: &[
            ("a", "color", "#333333", "first cell"),
            ("b", "color", "#666666", "second cell"),
            ("size", "number", "32", "cell px"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "noise",
        summary: "fractal simplex noise between two colors",
        ports: &[],
        params: &[
            ("a", "color", "#000000", "low color"),
            ("b", "color", "#ffffff", "high color"),
            ("scale", "vec2|number", "[200,200]", "px per noise cell"),
            ("offset", "vec2", "[0,0]", "pan px"),
            ("evolution", "number", "0", "third noise dimension; animate it"),
            ("octaves", "number", "4", "1..8"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "image",
        summary: "still image or image sequence",
        ports: &[],
        params: &[
            (
                "src",
                "text",
                "",
                "file path relative to the document; {frame} / {frame:05} for sequences",
            ),
            (
                "fit",
                "enum(contain|cover|fill|none)",
                "contain",
                "placement in the frame, or in `rect` (cover there by default); only fill stretches",
            ),
            (
                "rect",
                "vec4",
                "",
                "[x,y,w,h] px box the picture goes in, by `fit`; it keeps its aspect ratio",
            ),
            ("opacity", "number", "1", "0..1"),
            (
                "space",
                "enum(linear|srgb)",
                "linear",
                "interpolation space when scaled; srgb filters the encoded values as browsers do",
            ),
            ("fps", "number", "document fps", "sequence frame rate"),
            ("first_frame", "number", "0", "sequence frame number at local time 0"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "video",
        summary: "video clip, hardware decoded",
        ports: &[],
        params: &[
            ("src", "text", "", "file path"),
            (
                "fit",
                "enum(contain|cover|fill|none)",
                "contain",
                "placement in the frame, or in `rect` (cover there by default); only fill stretches",
            ),
            (
                "rect",
                "vec4",
                "",
                "[x,y,w,h] px box the footage goes in, by `fit`; it keeps its aspect ratio",
            ),
            ("opacity", "number", "1", "0..1"),
            (
                "space",
                "enum(linear|srgb)",
                "linear",
                "interpolation space when scaled; srgb filters the encoded values as browsers do",
            ),
            ("start", "number", "0", "source seconds at local time 0"),
            ("speed", "number", "1", "playback rate"),
            (
                "loop",
                "bool",
                "false",
                "wrap at the clip's end (else hold the last frame)",
            ),
            (
                "time",
                "number",
                "",
                "explicit source time (animate for time remapping)",
            ),
        ],
        extra: &[],
    },
    OpSchema {
        name: "path",
        summary: "vector path (SVG data or preset), GPU exact-coverage raster",
        ports: &[],
        params: &[
            (
                "to",
                "text",
                "",
                "SVG path data to morph toward; several separated by | to morph through each in turn",
            ),
            (
                "morph",
                "number",
                "0",
                "0 = this path, 1 = `to` (with several targets, 2 = the second, ...); animate it",
            ),
            ("d", "text", "", "SVG path data"),
            (
                "kind",
                "enum(star|polygon|circle|line|polyline|polygon_points)",
                "",
                "preset instead of d",
            ),
            ("center", "vec2", "frame center", "preset center"),
            ("radius", "number", "h/4", "preset radius"),
            ("sides", "number", "5 / 6", "star points / polygon sides"),
            ("inner_radius", "number", "0.45 r", "star inner radius"),
            (
                "points",
                "number[]",
                "",
                "flat [x0,y0,x1,y1,...] for line/polyline/polygon_points",
            ),
            ("color", "color", "#ffffff", "paint"),
            (
                "opacity",
                "number",
                "1",
                "0..1, fades the whole node (animate for fades)",
            ),
            ("fill_rule", "enum(nonzero|evenodd)", "nonzero", "fill rule"),
            ("trim_start", "number", "0", "0..1 of length"),
            ("trim_end", "number", "1", "0..1 of length (animate for draw-on)"),
        ],
        extra: &[STROKE, PLACEMENT],
    },
    OpSchema {
        name: "text",
        summary: "shaped text, GPU exact-coverage raster",
        ports: &[],
        params: &[
            (
                "text",
                "text",
                "",
                "content; \\n breaks lines; *word* is emphasis (em_ params), [words]{color=#ffd23f highlight=#ff4d6d} styles a span",
            ),
            ("font", "text", "Helvetica Neue", "family name or font file path"),
            ("weight", "number", "400", "100..900"),
            ("style", "enum(normal|italic)", "normal", "style"),
            ("size", "number", "64", "px"),
            ("color", "color", "#ffffff", "paint"),
            (
                "opacity",
                "number",
                "1",
                "0..1, fades the whole node (animate for fades)",
            ),
            (
                "align",
                "enum(left|center|right)",
                "left",
                "horizontal anchor of each line",
            ),
            (
                "valign",
                "enum(top|middle|baseline|bottom)",
                "top",
                "vertical anchor of the block",
            ),
            ("width", "number", "", "wrap width px"),
            ("line_height", "number", "1.2", "multiple of size"),
            ("tracking", "number", "0", "extra px between glyphs"),
            ("features", "text", "", "OpenType features, e.g. \"liga=0,ss01\""),
            (
                "variations",
                "text",
                "",
                "variable-font axes, e.g. \"wdth=80, opsz=144\" (weight drives wght; opsz follows size unless set)",
            ),
            (
                "axis_<tag>",
                "number",
                "axis default",
                "one variable-font axis, animatable: axis_wdth, axis_SOFT",
            ),
            (
                "stagger",
                "number",
                "0",
                "seconds between glyphs for the glyph_* animators",
            ),
            (
                "stagger_order",
                "enum(forward|reverse|center|random)",
                "forward",
                "which glyphs go first",
            ),
            (
                "glyph_offset",
                "vec2",
                "[0,0]",
                "per-glyph offset px, keyed in glyph time (t - stagger * order)",
            ),
            (
                "glyph_scale",
                "vec2",
                "[1,1]",
                "per-glyph scale about the glyph's center, glyph time",
            ),
            (
                "glyph_rotation",
                "number",
                "0",
                "per-glyph rotation degrees, glyph time",
            ),
            ("glyph_opacity", "number", "1", "per-glyph opacity, glyph time"),
            ("reveal", "number", "all", "glyphs visible (fractional fades)"),
            ("reveal_softness", "number", "1", "glyphs the reveal fade spans"),
            ("reveal_offset", "vec2", "[0,0]", "offset of not-yet-revealed glyphs px"),
            ("fill_rule", "enum(nonzero|evenodd)", "nonzero", "fill rule"),
            (
                "skim",
                "bool",
                "false",
                "glanced at, not read (code, data labels): ultrafast review skips its reading-time check",
            ),
            (
                "markup",
                "bool",
                "true",
                "parse inline styling in text: *emphasis* and [words]{color=#ffd23f weight=800 font=\"ultrafast:serif\" style=italic size=80 highlight=#ff4d6d underline=4 underline_color=#fff rise=10 draw=1}",
            ),
            ("em_color", "color", "text color", "color of *emphasis*"),
            (
                "em_font",
                "text",
                "font",
                "face of *emphasis* (e.g. ultrafast:serif for a serif accent)",
            ),
            ("em_weight", "number", "weight", "weight of *emphasis*"),
            (
                "em_style",
                "enum(normal|italic)",
                "italic when no em_ param is set",
                "style of *emphasis* (italic is synthesized for faces without one)",
            ),
            ("em_size", "number", "size", "size px of *emphasis*"),
            ("em_highlight", "color", "none", "marker box behind *emphasis*"),
            ("em_underline", "number", "0", "underline thickness px under *emphasis*"),
            ("em_underline_color", "color", "em_color", "underline color"),
            ("em_rise", "number", "0", "baseline shift px of *emphasis* (up)"),
            (
                "em_draw",
                "number",
                "1",
                "share of the emphasis highlights and underlines drawn, 0..1, one stroke across lines in reading order (animate it)",
            ),
            (
                "on_path",
                "text",
                "",
                "SVG path data the text follows (closed paths wrap: circular badges); align picks start, middle or end",
            ),
            (
                "path_offset",
                "number",
                "0",
                "px along the path; animate it to run text along",
            ),
            (
                "number",
                "number",
                "",
                "show this value instead of text (animate it: counters)",
            ),
            ("decimals", "number", "0", "digits after the point for number"),
            ("thousands", "text", ",", "group separator for number (\"\" for none)"),
            ("prefix", "text", "", "before number, e.g. $"),
            ("suffix", "text", "", "after number, e.g. % or k"),
            (
                "scramble",
                "number",
                "",
                "decoding text: animate 0 (all random) to 1 (the text)",
            ),
            (
                "scramble_chars",
                "text",
                "A-Z, 0-9, symbols",
                "characters the undecoded ones cycle through",
            ),
        ],
        extra: &[STROKE, PLACEMENT],
    },
    OpSchema {
        name: "shader",
        summary: "agent-written Slang: float4 shade(float2 pos, float px)",
        ports: &["in0", "in1", "in2", "in3"],
        params: &[
            (
                "resolution",
                "number",
                "1",
                "render at this fraction of the frame size and upscale (soft, costly looks; write shaders with pos/size())",
            ),
            (
                "code",
                "text",
                "",
                "Slang source defining shade(); `static const` tables of 64+ numbers are read from the params (editing their values compiles nothing)",
            ),
            ("u", "number[]", "", "up to 16 values, param(i)"),
            ("u0", "number", "", "u0..u15 individually (animatable)"),
            (
                "motion_blur",
                "bool",
                "false",
                "true: the format's motion blur samples its clock and animated u values (a shader that moves things); otherwise it holds at the frame's time",
            ),
        ],
        extra: &[],
    },
    OpSchema {
        name: "opacity",
        summary: "multiply alpha",
        ports: &["source"],
        params: &[("opacity", "number", "1", "0..1")],
        extra: &[],
    },
    OpSchema {
        name: "over",
        summary: "fg over bg (Porter-Duff)",
        ports: &["fg", "bg"],
        params: &[
            ("opacity", "number", "1", "fg opacity"),
            ("space", "enum(linear|srgb)", "linear", "blend space"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "blend",
        summary: "blend modes (W3C)",
        ports: &["fg", "bg"],
        params: &[
            (
                "mode",
                "enum(normal|multiply|screen|overlay|darken|lighten|color_dodge|color_burn|hard_light|soft_light|difference|exclusion|hue|saturation|color|luminosity|add|subtract|divide)",
                "normal",
                "mode",
            ),
            ("opacity", "number", "1", "fg opacity"),
            ("space", "enum(linear|srgb)", "linear", "blend space"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "composite",
        summary: "Porter-Duff operators",
        ports: &["fg", "bg"],
        params: &[("operator", "enum(in|out|atop|xor|plus|over)", "over", "operator")],
        extra: &[],
    },
    OpSchema {
        name: "mask",
        summary: "track matte",
        ports: &["source", "matte"],
        params: &[(
            "mode",
            "enum(alpha|alpha_inverted|luma|luma_inverted)",
            "alpha",
            "matte channel",
        )],
        extra: &[],
    },
    OpSchema {
        name: "mix",
        summary: "crossfade",
        ports: &["a", "b"],
        params: &[("t", "number", "0.5", "0 = a, 1 = b")],
        extra: &[],
    },
    OpSchema {
        name: "adjust",
        summary: "exposure, contrast, saturation, hue, brightness, gamma",
        ports: &["source"],
        params: &[
            ("exposure", "number", "0", "stops (linear light)"),
            ("contrast", "number", "1", "around mid grey"),
            ("saturation", "number", "1", "0 = grey"),
            ("hue", "number", "0", "degrees"),
            ("brightness", "number", "0", "offset"),
            ("gamma", "number", "1", "gamma"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "levels",
        summary: "input/output levels with gamma",
        ports: &["source"],
        params: &[
            ("in_black", "number", "0", ""),
            ("in_white", "number", "1", ""),
            ("gamma", "number", "1", ""),
            ("out_black", "number", "0", ""),
            ("out_white", "number", "1", ""),
        ],
        extra: &[],
    },
    OpSchema {
        name: "color_matrix",
        summary: "4x5 matrix on straight linear RGBA",
        ports: &["source"],
        params: &[("matrix", "number[]", "identity", "20 numbers, row-major")],
        extra: &[],
    },
    OpSchema {
        name: "lut",
        summary: "3D LUT color grade (.cube)",
        ports: &["source"],
        params: &[
            ("src", "text", "", ".cube file (3D LUT)"),
            ("amount", "number", "1", "0..1 mix with the ungraded image"),
            (
                "space",
                "enum(srgb|linear)",
                "srgb",
                "what the LUT expects as input (most grading LUTs: srgb)",
            ),
        ],
        extra: &[],
    },
    OpSchema {
        name: "invert",
        summary: "invert colors",
        ports: &["source"],
        params: &[("amount", "number", "1", "0..1")],
        extra: &[],
    },
    OpSchema {
        name: "tint",
        summary: "map luminance between two colors",
        ports: &["source"],
        params: &[
            ("dark", "color", "#000000", "shadows"),
            ("light", "color", "#ffffff", "highlights"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "threshold",
        summary: "luminance threshold",
        ports: &["source"],
        params: &[("level", "number", "0.5", ""), ("softness", "number", "0.01", "")],
        extra: &[],
    },
    OpSchema {
        name: "crop",
        summary: "keep a rectangle",
        ports: &["source"],
        params: &[
            ("rect", "vec4", "frame", "[x,y,w,h] px"),
            ("softness", "number", "1", "edge px"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "transform",
        summary: "2D transform (absorbed into paths/text for sharpness)",
        ports: &["source"],
        params: &[
            ("position", "vec2", "frame center", "where the anchor lands"),
            ("anchor", "vec2", "frame center", "pivot"),
            ("scale", "vec2|number", "[1,1]", "scale"),
            ("rotation", "number", "0", "degrees"),
            ("skew", "number", "0", "degrees"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "corner_pin",
        summary: "perspective: map the frame (or source_rect) to four corners",
        ports: &["source"],
        params: &[
            ("corners", "number[]", "frame corners", "[tl, tr, br, bl] as 8 numbers"),
            ("source_rect", "vec4", "frame", "[x,y,w,h] of the source mapped"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "wave",
        summary: "sine displacement",
        ports: &["source"],
        params: &[
            ("amplitude", "number", "10", "px"),
            ("wavelength", "number", "100", "px"),
            ("phase", "number", "0", "degrees"),
            ("direction", "number", "0", "degrees"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "twirl",
        summary: "swirl around a center",
        ports: &["source"],
        params: &[
            ("center", "vec2", "frame center", ""),
            ("radius", "number", "min(w,h)/2", ""),
            ("angle", "number", "90", "degrees"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "tile",
        summary: "repeat a region",
        ports: &["source"],
        params: &[("origin", "vec2", "[0,0]", ""), ("size", "vec2", "frame", "")],
        extra: &[],
    },
    OpSchema {
        name: "displace",
        summary: "displace source by a map's red/green",
        ports: &["source", "map"],
        params: &[("amount", "vec2", "[20,20]", "px")],
        extra: &[],
    },
    OpSchema {
        name: "blur",
        summary: "gaussian blur",
        ports: &["source"],
        params: &[("radius", "number", "8", "sigma px")],
        extra: &[],
    },
    OpSchema {
        name: "mesh",
        summary: "3D mesh (scene object for render3d)",
        ports: &["texture"],
        params: &[
            (
                "primitive",
                "enum(cube|plane|sphere|cylinder|cone|torus|text|path)",
                "cube",
                "unit-sized primitive, or extruded text / SVG path",
            ),
            ("text", "text", "", "primitive text: content"),
            ("font", "text", "Helvetica Neue", "primitive text: family or file"),
            ("weight", "number", "400", "primitive text: weight"),
            ("style", "enum(normal|italic)", "normal", "primitive text: style"),
            ("size", "number", "1", "primitive text: size in world units"),
            (
                "align",
                "enum(left|center|right)",
                "center",
                "primitive text: alignment",
            ),
            (
                "tracking",
                "number",
                "0",
                "primitive text: extra spacing (px at 100 px/unit)",
            ),
            ("line_height", "number", "1.2", "primitive text: multiple of size"),
            ("d", "text", "", "primitive path: SVG path data"),
            ("units", "number", "100", "primitive path: path px per world unit"),
            ("depth", "number", "0.25", "extrusion depth, world units"),
            (
                "bevel",
                "number",
                "0",
                "text/path: 45-degree chamfer on both rims, world units",
            ),
            ("src", "text", "", ".gltf/.glb file instead of a primitive"),
            ("segments", "number", "32", "tessellation"),
            ("position", "vec3", "[0,0,0]", ""),
            ("rotation", "vec3", "[0,0,0]", "degrees, X then Y then Z"),
            ("scale", "vec3|number", "[1,1,1]", ""),
            ("color", "color", "#cccccc", "base color"),
            ("metallic", "number", "0", "0..1"),
            ("roughness", "number", "0.5", "0..1"),
            ("emissive", "color", "#000000", "emitted light"),
            (
                "transmission",
                "number",
                "0",
                "glass: 0..1 of the scene behind seen through it (refracted)",
            ),
            (
                "ior",
                "number",
                "1.45",
                "glass: index of refraction (water 1.33, glass 1.5, diamond 2.4)",
            ),
            (
                "thickness",
                "number",
                "0.5",
                "glass: how far refracted rays travel inside, world units (more bends more)",
            ),
            ("dispersion", "number", "0", "glass: color splitting (try 1..2)"),
            ("opacity", "number", "1", "0..1"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "light",
        summary: "3D light (scene object)",
        ports: &[],
        params: &[
            ("kind", "enum(directional|point)", "directional", ""),
            ("direction", "vec3", "[0.4,0.8,0.6]", "toward the light (directional)"),
            ("position", "vec3", "[0,2,2]", "point light position"),
            ("color", "color", "#ffffff", ""),
            ("intensity", "number", "3", ""),
        ],
        extra: &[],
    },
    OpSchema {
        name: "camera",
        summary: "3D camera (scene object)",
        ports: &[],
        params: &[
            ("position", "vec3", "[0,0,5]", ""),
            (
                "orbit",
                "vec3",
                "",
                "[azimuth, elevation, distance] around target (overrides position)",
            ),
            ("target", "vec3", "[0,0,0]", ""),
            ("up", "vec3", "[0,1,0]", ""),
            ("fov", "number", "45", "vertical, degrees"),
            ("near", "number", "0.1", ""),
            ("far", "number", "1000", ""),
        ],
        extra: &[],
    },
    OpSchema {
        name: "render3d",
        summary: "renders connected meshes/lights/camera (any port names; camera on `camera`)",
        ports: &["*"],
        params: &[
            ("ambient", "number", "0.35", "hemisphere light intensity"),
            ("sky", "color", "#e6f2ff", "ambient from above"),
            ("ground", "color", "#5a4d47", "ambient from below"),
            ("background", "color", "transparent", "clear color"),
            (
                "shadows",
                "bool",
                "true",
                "the first directional light casts a shadow map",
            ),
            ("shadow_strength", "number", "0.85", "0 = no darkening, 1 = full"),
            (
                "shadow_bias",
                "number",
                "1",
                "depth bias in shadow-map texels (raise if surfaces self-shadow)",
            ),
            (
                "environment_intensity",
                "number",
                "1",
                "scale of the image on the `environment` port (equirectangular; lights and reflects)",
            ),
            (
                "environment_rotation",
                "number",
                "0",
                "turns the environment around +y, degrees",
            ),
            (
                "fog",
                "vec2",
                "",
                "[start, end] distance from the camera where surfaces fade into fog_color",
            ),
            ("fog_color", "color", "background", "fog color"),
            (
                "aperture",
                "number",
                "0",
                "depth of field: blur radius px far from focus (0 = off)",
            ),
            (
                "focus",
                "number",
                "camera to target",
                "depth of field: in-focus distance, world units",
            ),
        ],
        extra: &[],
    },
    OpSchema {
        name: "swarm",
        summary: "particles that assemble into text (or a path) and scatter: progress 0..1",
        ports: &[],
        params: &[
            ("text", "text", "", "what the particles form (or `d`)"),
            (
                "d",
                "text",
                "",
                "SVG path data to form instead of text (offset by position)",
            ),
            ("font", "text", "Helvetica Neue", "font family or file"),
            ("weight", "number", "400", "font weight"),
            ("style", "enum(normal|italic)", "normal", "font style"),
            ("tracking", "number", "0", "extra px between glyphs"),
            ("variations", "text", "", "variable-font axes, as on text"),
            (
                "axis_<tag>",
                "number",
                "axis default",
                "one variable-font axis, as on text",
            ),
            ("size", "number", "64", "text size px"),
            ("position", "vec2", "[0,0]", "text position (as `text`)"),
            ("align", "enum(left|center|right)", "left", "text alignment"),
            (
                "valign",
                "enum(top|middle|baseline|bottom)",
                "top",
                "vertical alignment",
            ),
            ("count", "number", "4000", "particles"),
            ("progress", "number", "1", "0 scattered, 1 formed; animate it"),
            (
                "stagger",
                "number",
                "0.5",
                "spread of arrival times (fraction of progress)",
            ),
            ("scatter", "number", "700", "how far particles start from home, px"),
            ("origin", "vec2", "", "start every particle from this point instead"),
            ("turbulence", "number", "40", "drift amplitude while away from home, px"),
            ("particle_size", "vec2", "[2,3]", "size scattered and formed, px"),
            ("color", "color", "#ffffff", "color when formed"),
            ("color_scatter", "color", "color", "color when scattered"),
            ("shimmer", "number", "0", "0..1 twinkle"),
            ("stretch", "number", "0", "streak along travel while moving"),
            ("seed", "number", "1", "random seed"),
            ("blend", "enum(over|add)", "over", "how particles combine"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "particles",
        summary: "deterministic particle system (closed form: scrub anywhere), drawn as sprites",
        ports: &["sprite"],
        params: &[
            ("seed", "number", "1", "random seed"),
            ("rate", "number", "60", "particles emitted per second"),
            ("max", "number", "5000", "cap on particles alive"),
            ("life", "vec2", "[1.5,2.5]", "lifetime range, s"),
            ("position", "vec2", "[960,540]", "emitter center px"),
            ("emitter_size", "vec2", "[0,0]", "emitter rectangle px"),
            ("direction", "number", "-90", "degrees (-90 = up)"),
            ("spread", "number", "30", "cone angle, degrees"),
            ("speed", "vec2", "[200,400]", "initial speed range, px/s"),
            ("gravity", "vec2", "[0,300]", "px/s^2"),
            ("drag", "number", "0", "linear drag, 1/s"),
            ("size", "vec2", "[8,2]", "size at birth and death, px"),
            ("size_jitter", "number", "0.3", "0..1 random size reduction"),
            ("spin", "vec2", "[0,0]", "rotation speed range, deg/s"),
            ("color_start", "color", "#ffffff", "color at birth"),
            ("color_end", "color", "color_start", "color at death"),
            ("fade_in", "number", "0.1", "fraction of life fading in"),
            ("fade_out", "number", "0.3", "fraction of life fading out"),
            (
                "shape",
                "enum(circle|square|spark|sprite)",
                "circle",
                "sprite uses the `sprite` input",
            ),
            ("stretch", "number", "0", "spark stretch along velocity"),
            ("blend", "enum(over|add)", "over", "how particles combine"),
            ("emit_start", "number", "0", "emission start, s (negative pre-warms)"),
            ("emit_end", "number", "forever", "emission end, s"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "fluid",
        summary: "ink/smoke simulation: `dye` pours color in, `stir` pushes it around; stepped once per frame (exact on export, seekable)",
        ports: &["dye", "stir"],
        params: &[
            (
                "start",
                "number",
                "0",
                "local time the simulation starts (blank before)",
            ),
            (
                "emit",
                "number",
                "6",
                "how fast `dye` replaces the fluid where it is, per s",
            ),
            ("dissipation", "number", "0.15", "dye fade per s"),
            ("velocity_dissipation", "number", "0.4", "motion fade per s"),
            (
                "vorticity",
                "number",
                "4",
                "keeps eddies curling (0 = silky, 10+ = churning)",
            ),
            (
                "turbulence",
                "number",
                "0",
                "curl-noise stirring, px/s^2 (try 400..3000)",
            ),
            ("turbulence_scale", "number", "260", "size of the noise eddies, px"),
            ("wind", "vec2", "[0,0]", "drift of everything, px/s"),
            ("buoyancy", "number", "0", "dye rises (smoke), px/s^2 per unit alpha"),
            ("stir", "number", "2500", "push away from the edges of the `stir` image"),
            ("swirl", "number", "0", "spin around the edges of the `stir` image"),
            ("resolution", "number", "0.25", "velocity grid, fraction of the frame"),
            ("dye_resolution", "number", "0.5", "dye grid, fraction of the frame"),
            (
                "pressure_iterations",
                "number",
                "24",
                "incompressibility solver iterations",
            ),
            ("substeps", "number", "1", "steps per frame (1..8)"),
            ("seed", "number", "1", "turbulence pattern"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "feedback",
        summary: "agent Slang stepped once per frame on its own previous result: float4 update(float2 pos, float px) with prev(pos), input(i,pos), dt(), step_index()",
        ports: &["in0", "in1", "in2", "in3"],
        params: &[
            ("code", "text", "", "Slang source defining update()"),
            (
                "start",
                "number",
                "0",
                "local time the simulation starts (blank before)",
            ),
            ("resolution", "number", "1", "state grid, fraction of the frame"),
            ("substeps", "number", "1", "updates per frame (1..64)"),
            ("u", "number[]", "", "up to 16 values, param(i)"),
            ("u0", "number", "", "u0..u15 individually (animatable)"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "raymarch",
        summary: "3D as a signed-distance scene marched per pixel: write float2 map(float3 p) -> (distance, material id); soft shadows, occlusion, a reflection bounce, environment and antialiasing come with it",
        ports: &["in0", "in1", "in2", "in3"],
        params: &[
            (
                "scene",
                "text",
                "",
                "Slang: float2 map(float3 p) (+ optional void material(float id, float3 p, float3 n, inout float3 albedo, inout float metallic, inout float roughness)); helpers sdSphere, sdBox, sdCylinder, sdTorus, sdCapsule, sdBand, sdPlane, smin, opU, rotX/Y/Z, fbm3, knob(i), layerDistance + extrude (any ultrafast layer as a 3D solid), presetMaterial (ids 0 matte, 1 brass, 2 polished brass, 3 steel, 4 gold, 5 copper, 6 black lacquer, 7 ceramic, 8 rubber, 9 clear glass, 10 chrome; metallic < 0 makes glass); input(i, px) reads in0..in3",
            ),
            (
                "orbit",
                "vec3",
                "[30,20,8]",
                "camera [azimuth, elevation, distance] around target, degrees and world units",
            ),
            ("target", "vec3", "[0,0,0]", "what the camera looks at"),
            ("fov", "number", "35", "vertical, degrees"),
            ("light", "vec3", "[-4,5,4]", "point light position (casts soft shadows)"),
            ("light_color", "color", "#fff2e0", "light color"),
            ("light_intensity", "number", "40", "inverse-square intensity"),
            (
                "environment",
                "enum(studio|room|night|sky|lightbox|horizon)",
                "studio",
                "what reflections and ambient light see (lightbox: bars of light, made for glass and chrome)",
            ),
            (
                "background",
                "text",
                "environment",
                "environment, transparent (to composite over 2D), or a color",
            ),
            (
                "background_level",
                "number",
                "0.35",
                "brightness of an environment background",
            ),
            ("exposure", "number", "1", "before tone mapping"),
            ("samples", "number", "2", "rays per pixel (1..8), jittered"),
            (
                "bounce",
                "bool",
                "true",
                "trace one reflection bounce for glossy surfaces",
            ),
            (
                "ior",
                "number",
                "1.5",
                "glass index of refraction (materials with metallic < 0, preset 9)",
            ),
            ("dispersion", "number", "1", "glass color splitting (0 none, 2 strong)"),
            ("max_distance", "number", "80", "rays stop here"),
            (
                "k0",
                "number",
                "",
                "k0..k4: free knobs read as knob(0..4) in the scene (animatable)",
            ),
            ("resolution", "number", "1", "render scale"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "transition",
        summary: "from shot `a` to shot `b` over `duration` s starting `at`: only a renders before, only b after",
        ports: &["a", "b"],
        params: &[
            (
                "kind",
                "enum(crossfade|dip|wipe|push|slide|iris|zoom|dissolve|glitch|blur)",
                "crossfade",
                "how: dip goes through `color`; wipe/push/slide move along `direction`; iris opens from `center`; dissolve burns through noise",
            ),
            ("at", "number", "0", "start, seconds"),
            ("duration", "number", "0.8", "seconds"),
            ("direction", "number", "0", "degrees: 0 moves rightward, 90 downward"),
            ("softness", "number", "per kind", "edge softness (blur: strength)"),
            (
                "color",
                "color",
                "#000000",
                "dip color; wipe and dissolve edge glow color (dissolve: ember #ff9a4a)",
            ),
            ("glow", "number", "0 (dissolve 2)", "edge glow strength"),
            ("center", "vec2", "frame center", "iris and zoom center px"),
            ("grain", "number", "160", "dissolve noise size px"),
            (
                "ease",
                "text|number[]",
                "per kind",
                "progress easing: a name (in_out_cubic) or [x1, y1, x2, y2]",
            ),
        ],
        extra: &[],
    },
    OpSchema {
        name: "block",
        summary: "a ready-made animated block in one house style: title, lower_third, quote, stat, chapter, end_card, and charts: bar_chart, line_chart, donut (place it in time with a timing offset)",
        ports: &[],
        params: &[
            (
                "kind",
                "enum(title|lower_third|quote|stat|chapter|end_card|bar_chart|line_chart|donut)",
                "title",
                "which block",
            ),
            (
                "title",
                "text",
                "",
                "title / chapter / end_card / charts (above the chart)",
            ),
            ("kicker", "text", "", "title, charts: small line above"),
            ("subtitle", "text", "", "title: line below"),
            ("number", "text", "", "chapter: its number, e.g. 01"),
            ("name", "text", "", "lower_third"),
            ("role", "text", "", "lower_third"),
            ("quote", "text", "", "quote"),
            ("author", "text", "", "quote"),
            ("value", "number", "0", "stat: counts up to it"),
            ("prefix", "text", "", "stat, bar and line values"),
            ("suffix", "text", "", "stat, bar and line values"),
            ("decimals", "number", "0", "stat, bar and line values"),
            ("label", "text", "", "stat"),
            ("tagline", "text", "", "end_card"),
            ("cta", "text", "", "end_card: a pill button"),
            ("logo", "text", "", "end_card: SVG file"),
            ("values", "number[]", "", "charts: the data, e.g. [24, 31, 58, 265]"),
            (
                "labels",
                "text",
                "",
                "charts: one per value, comma separated (or | when labels hold commas)",
            ),
            (
                "highlight",
                "number",
                "bar, donut: the largest; line: the last",
                "charts: index of the value set in the accent and called out (-1: none)",
            ),
            ("height", "number", "34% of the height", "charts: plot height px"),
            (
                "max",
                "number",
                "largest value",
                "bar, line: the value at the top of the plot",
            ),
            ("min", "number", "0 or the smallest", "line: the value at the baseline"),
            (
                "color",
                "color",
                "muted (line: accent)",
                "bar: other bars; line: the line",
            ),
            ("area", "bool", "true", "line: fill under the line"),
            ("draw_time", "number", "1.6", "line: seconds the line takes to draw"),
            (
                "colors",
                "text",
                "accent, then a palette",
                "donut: segment colors, comma separated",
            ),
            ("radius", "number", "fits the plot", "donut: outer radius px"),
            ("thickness", "number", "30% of radius", "donut: ring thickness px"),
            (
                "number_font",
                "text",
                "ultrafast:wide",
                "stat, donut: the big number's face",
            ),
            (
                "duration",
                "number",
                "3.5 (lower_third 4, quote 5, chapter 2.5, charts 5)",
                "seconds before it exits (end_card stays)",
            ),
            ("ink", "color", "#f6f3ee", "type color"),
            ("muted", "color", "ink at 72%", "secondary type"),
            ("accent", "color", "#ff5c7a", "rules, bars, quote mark, pill"),
            ("display_font", "text", "ultrafast:display", "headline face"),
            ("text_font", "text", "ultrafast:sans", "body face"),
            ("mono_font", "text", "ultrafast:mono", "labels"),
            ("align", "enum(left|center)", "left", "alignment (end_card is centered)"),
            (
                "position",
                "vec2",
                "per kind",
                "title/quote/stat: top of the block; lower_third: bottom-left; end_card: center",
            ),
            ("width", "number", "80% of the width", "wrap width px"),
            ("scale", "number", "1", "size multiplier (sizes follow the frame)"),
            ("opacity", "number", "1", "0..1"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "lottie",
        summary: "a Lottie (Bodymovin) animation as editable ultrafast nodes: shape layers become paths with Lottie's keyframes, transforms stay vector; loops by default",
        ports: &[],
        params: &[
            ("src", "text", "", "Lottie .json file"),
            ("size", "vec2|number", "the animation's size", "fit it into this box px"),
            ("loop", "bool", "true", "repeat over its duration"),
            ("position", "vec2", "[0,0]", "where its top-left (or anchor) lands px"),
            ("anchor", "vec2", "[0,0]", "pivot px in its fitted space"),
            ("scale", "vec2|number", "[1,1]", "scale"),
            ("rotation", "number", "0", "degrees"),
            ("opacity", "number", "1", "0..1"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "code",
        summary: "source code in a panel: syntax-highlighted, optionally typed on with a caret, line numbers, highlighted lines, window chrome",
        ports: &[],
        params: &[
            (
                "code",
                "text",
                "",
                "the source (\\n between lines; tabs become 4 spaces)",
            ),
            (
                "language",
                "enum(rust|python|js|ts|json|bash|go|swift|c|cpp|slang|sql|css|html|text)",
                "text",
                "how to color it",
            ),
            (
                "theme",
                "enum(ultrafast|paper|mono)",
                "ultrafast",
                "colors (paper is light)",
            ),
            ("title", "text", "", "file name in the title bar"),
            ("window", "bool", "true", "title bar with three dots"),
            ("background", "bool", "true", "the panel and its shadow"),
            ("line_numbers", "bool", "true", "gutter numbers"),
            ("highlight", "text", "", "lines to mark, e.g. \"3\" or \"2,5-7\""),
            ("highlight_at", "number", "0", "when the marked lines light up"),
            (
                "type_speed",
                "number",
                "0",
                "characters per second typed on (0: all shown)",
            ),
            ("at", "number", "0", "when typing starts"),
            ("caret", "bool", "true", "a blinking caret while and after typing"),
            ("font", "text", "ultrafast:mono", "a monospaced face"),
            ("size", "number", "30 at 1080p", "px"),
            ("line_height", "number", "1.55", "multiple of size"),
            ("padding", "number", "1.4 x size", "px inside the panel"),
            ("radius", "number", "0.55 x size", "panel corner radius px"),
            ("width", "number", "fits the longest line", "panel width px"),
            ("position", "vec2", "centered", "top-left of the panel"),
            ("opacity", "number", "1", "0..1"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "stack",
        summary: "lays its inputs (in0, in1, ...: text, path, shape, svg or stack) out in a column or row by their measured bounds",
        ports: &[
            "in0", "in1", "in2", "in3", "in4", "in5", "in6", "in7", "in8", "in9", "in10", "in11", "in12", "in13",
            "in14", "in15",
        ],
        params: &[
            ("direction", "enum(column|row)", "column", "stack downward or rightward"),
            (
                "at",
                "number",
                "0",
                "seconds at which children are measured (when their entrances have landed)",
            ),
            ("gap", "number", "24", "px between children"),
            ("align", "enum(start|center|end)", "start", "children across the stack"),
            ("position", "vec2", "[0,0]", "where the block's anchor goes"),
            (
                "anchor",
                "enum(top_left|top|top_right|left|center|right|bottom_left|bottom|bottom_right)",
                "top_left",
                "which point of the block sits at position",
            ),
        ],
        extra: &[],
    },
    OpSchema {
        name: "clip_camera",
        summary: "video framed on its speaker: faces are tracked from the footage (or given), then a follow camera with dead zone and eased pans, cuts on shots and speaker changes, scope zoom, protect mode (blurred cover behind the contained frame)",
        ports: &[],
        params: &[
            ("src", "text", "", "source video"),
            (
                "faces",
                "text",
                "tracked from src",
                "face tracks, inline as JSON text or a file: {sourceWidth, sourceHeight, fps, frames: [{frame, faces: [{id, x, y, w, h, talk, focus}]}], shots: [{startFrame, endFrame, protect, cinematicScope}]}; omit it and the clip's faces, who is talking and its cuts are tracked from the footage (`ultrafast faces` writes the same)",
            ),
            ("start", "number", "0", "source seconds where the clip begins"),
            ("duration", "number", "document duration", "clip seconds"),
            ("tuning", "text", "", "camera tuning overrides as JSON"),
            ("opacity", "number", "1", "0..1"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "captions",
        summary: "animated captions from word timings (karaoke, pop, reveal): pages laid out to fit, every word its own text node",
        ports: &[],
        params: &[
            ("src", "text", "", "transcript: Whisper/word JSON, .srt or .vtt"),
            (
                "words",
                "text",
                "",
                "inline instead: lines of `start end word`, SRT text or JSON",
            ),
            (
                "style",
                "enum(karaoke|pop|reveal|plain)",
                "karaoke",
                "karaoke lights the spoken word; pop pops each word on; reveal fades them on",
            ),
            ("font", "text", "Helvetica Neue", "family or file"),
            ("size", "number", "6.5% of the short side", "px"),
            ("weight", "number", "800", "100..900"),
            ("color", "color", "#ffffff", "words not yet spoken"),
            ("highlight", "color", "#ffd23f", "the word being spoken"),
            ("spoken", "color", "color", "words already spoken"),
            (
                "highlight_background",
                "color",
                "",
                "a rounded pill behind the spoken word",
            ),
            ("background", "color", "", "a rounded box behind each page"),
            ("uppercase", "bool", "false", "set in capitals"),
            ("tracking", "number", "0", "extra px between glyphs"),
            ("width", "number", "82% of the width", "line width px"),
            ("max_lines", "number", "2", "lines per page"),
            ("line_height", "number", "1.18", "multiple of size"),
            (
                "position",
                "vec2",
                "[w/2, 0.72 h]",
                "center of the caption block (moved into `safe` if it would cross it)",
            ),
            ("align", "enum(left|center|right)", "center", "line alignment"),
            (
                "safe",
                "enum(auto|social|margin|none)",
                "auto",
                "area pages stay inside: auto is clear of the social apps' buttons and captions on a vertical frame (what `review --safe social` checks) and a 4% margin otherwise; none places them exactly at position",
            ),
            ("linger", "number", "0.6", "seconds a page stays after its last word"),
            ("opacity", "number", "1", "0..1"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "svg",
        summary: "an SVG file (logo, icon, illustration) as vector paths: fills, strokes, gradients, text as outlines; `ultrafast import-svg` gives the same as editable nodes",
        ports: &[],
        params: &[
            ("src", "text", "", ".svg file (relative to the document)"),
            (
                "size",
                "vec2|number",
                "the SVG's own size",
                "fit inside [w, h] px, keeping its aspect",
            ),
            ("position", "vec2", "[0,0]", "where the anchor lands, px"),
            ("anchor", "vec2", "[0,0]", "pivot in the artwork's px (after size)"),
            (
                "scale",
                "vec2|number",
                "[1,1]",
                "scale around the anchor (stays vector-sharp)",
            ),
            ("rotation", "number", "0", "degrees, clockwise"),
            ("opacity", "number", "1", "0..1"),
        ],
        extra: &[],
    },
    OpSchema {
        name: "audio",
        summary: "sound mixed into exports",
        ports: &[],
        params: &[
            ("src", "text", "", "any media file with audio"),
            ("start", "number", "0", "source seconds playing at local time `from`"),
            ("gain", "number", "1", "linear, animatable"),
            (
                "from",
                "number",
                "0",
                "local seconds the sound starts at (silent before)",
            ),
            (
                "duration",
                "number",
                "0",
                "seconds it plays from `from` (0: until the source ends)",
            ),
            (
                "rate",
                "number",
                "1",
                "playback speed with the pitch kept (time stretched)",
            ),
        ],
        extra: &[],
    },
];

fn find(op: &str) -> Option<&'static OpSchema> {
    SCHEMAS.iter().find(|s| s.name == op)
}

/// Params whose animation changes how a node looks without moving anything
/// on screen (opacities, colors, grades, light levels): motion blur does
/// not sample them.
pub fn moves_nothing(op: &str, param: &str) -> bool {
    match (op, param) {
        (_, "opacity" | "glyph_opacity") | ("adjust" | "levels", _) | ("lut" | "invert", "amount") => true,
        ("light", "intensity") | ("render3d", "ambient") | ("raymarch", "light_intensity" | "exposure") => true,
        _ => find(op).is_some_and(|s| {
            s.params
                .iter()
                .chain(s.extra.iter().flat_map(|e| e.iter()))
                .any(|p| p.0 == param && p.1 == "color")
        }),
    }
}

fn all_params(s: &OpSchema) -> impl Iterator<Item = &'static P> {
    s.params.iter().chain(s.extra.iter().flat_map(|g| g.iter()))
}

/// The full vocabulary as JSON.
pub fn vocabulary() -> Value {
    let mut ops: Vec<Value> = SCHEMAS
        .iter()
        .map(|s| {
            json!({
                "op": s.name,
                "summary": s.summary,
                "ports": s.ports,
                "params": all_params(s).map(|(n, ty, d, desc)| json!({ "name": n, "type": ty, "default": d, "doc": desc })).collect::<Vec<_>>(),
            })
        })
        .collect();
    for (name, c) in crate::builtins::components() {
        ops.push(json!({
            "op": name,
            "summary": crate::builtins::summary(name),
            "ports": c.inputs,
            "params": c
                .params
                .iter()
                .map(|(k, v)| {
                    let v = serde_json::to_value(v).unwrap();
                    // A builtin's params are its defaults; their form says the type.
                    let ty = match &v {
                        Value::Number(_) => "number",
                        Value::Bool(_) => "bool",
                        Value::String(s) if s.starts_with('#') => "color",
                        Value::String(_) => "text",
                        Value::Array(a) if a.len() == 2 => "vec2",
                        Value::Array(_) => "vector",
                        _ => "animated",
                    };
                    let default = match &v {
                        Value::String(s) => s.clone(),
                        other => other.to_string(),
                    };
                    json!({ "name": k, "type": ty, "default": default })
                })
                .collect::<Vec<_>>(),
        }));
    }
    json!(ops)
}

/// A problem found by [`check`].
#[derive(Debug, Clone)]
pub struct Issue {
    pub node: String,
    pub severity: &'static str,
    pub message: String,
}

/// Static checks agents can run before rendering: unknown ops, misspelled
/// params (with suggestions), wrong value shapes, missing inputs, unused
/// nodes.
pub fn check(doc: &Document) -> Vec<Issue> {
    let mut out = Vec::new();
    let mut issue = |node: &str, severity: &'static str, message: String| {
        out.push(Issue {
            node: node.to_string(),
            severity,
            message,
        });
    };
    let mut graphs: Vec<(String, &std::collections::BTreeMap<String, ultrafast_graph::Node>)> =
        vec![(String::new(), &doc.nodes)];
    for (name, c) in &doc.components {
        graphs.push((format!("{name}/"), &c.nodes));
    }
    for (prefix, nodes) in graphs {
        for (id, node) in nodes {
            let path = format!("{prefix}{id}");
            let component = doc.components.get(&node.op).or_else(|| {
                crate::builtins::components()
                    .iter()
                    .find(|(n, _)| *n == node.op)
                    .map(|(_, c)| c)
            });
            if let Some(c) = component {
                for k in node.params.keys() {
                    if !c.params.contains_key(k) {
                        issue(&path, "warning", format!("component `{}` has no param `{k}`", node.op));
                    }
                }
                for p in node.inputs.keys() {
                    if !c.inputs.contains(p) {
                        issue(&path, "warning", format!("component `{}` has no input `{p}`", node.op));
                    }
                }
                continue;
            }
            let Some(schema) = find(&node.op) else {
                issue(&path, "error", format!("unknown op `{}`", node.op));
                continue;
            };
            for (k, v) in &node.params {
                if prefix.is_empty() || !matches!(v, Param::Text(s) if s.starts_with('$')) {
                    let known = all_params(schema).find(|p| {
                        p.0 == k
                            || (k.starts_with('u') && p.0 == "u0" && k[1..].parse::<u8>().is_ok_and(|i| i < 16))
                            || (k.starts_with('k') && p.0 == "k0" && k[1..].parse::<u8>().is_ok_and(|i| i < 5))
                            || (k.starts_with("axis_") && p.0 == "axis_<tag>" && (6..=9).contains(&k.len()))
                    });
                    match known {
                        None => {
                            let hint = all_params(schema)
                                .map(|p| p.0)
                                .min_by_key(|n| edit_distance(n, k))
                                .filter(|n| edit_distance(n, k) <= 3)
                                .map(|n| format!(" (did you mean `{n}`?)"))
                                .unwrap_or_default();
                            issue(
                                &path,
                                "warning",
                                format!("`{}` has no param `{k}`{hint}; it is ignored", node.op),
                            );
                        }
                        Some(p) => {
                            if let Param::Expr { expr } = v {
                                for e in expr.errors() {
                                    issue(&path, "error", format!("param `{k}`: {e}"));
                                }
                            }
                            if let Some(msg) = type_mismatch(p.1, v) {
                                issue(&path, "warning", format!("param `{k}`: {msg}"));
                            }
                        }
                    }
                }
            }
            if schema.ports != ["*"] {
                for p in node.inputs.keys() {
                    if !schema.ports.contains(&p.as_str()) {
                        issue(
                            &path,
                            "warning",
                            format!("`{}` has no input `{p}` (ports: {:?})", node.op, schema.ports),
                        );
                    }
                }
                let optional = matches!(
                    node.op.as_str(),
                    "shader" | "raymarch" | "mesh" | "particles" | "fluid" | "feedback" | "stack"
                );
                for p in schema.ports {
                    if !optional && !node.inputs.contains_key(*p) {
                        issue(&path, "error", format!("missing input `{p}`"));
                    }
                }
            }
        }
    }
    if let Ok(order) = doc.reachable_topo_order() {
        for id in doc.nodes.keys() {
            let used_elsewhere = doc.nodes.get(id).is_some_and(|n| n.op == "audio");
            if !order.contains(id) && !used_elsewhere {
                issue(id, "info", "not reachable from the output (not rendered)".into());
            }
        }
        // A timed effect (a crop, a mask, a transform...) passes its source
        // through untouched outside its window: if the source shows longer
        // than the effect, that is the uncropped, unmasked source on screen.
        // When each node can reach the screen (a hull): everything at the
        // output; a transition shows `a` only until it ends and `b` only
        // from when it starts.
        let mut reach: std::collections::HashMap<&str, (f64, f64)> = std::collections::HashMap::new();
        reach.insert(doc.output.as_str(), (0.0, doc.format.duration));
        let num = |n: &ultrafast_graph::Node, k: &str, d: f64| match n.params.get(k) {
            Some(Param::Number(v)) => *v,
            _ => d,
        };
        for id in order.iter().rev() {
            let Some(&(ra, rb)) = reach.get(id.as_str()) else {
                continue;
            };
            let node = &doc.nodes[id];
            // A timed node shows its inputs only inside its window, except the
            // one it passes through outside it.
            let window = node.timing.filter(|t| t.has_window()).map(|t| {
                (
                    t.in_point.unwrap_or(f64::NEG_INFINITY),
                    t.out_point.unwrap_or(f64::INFINITY),
                )
            });
            let through = through_port(doc, id, node);
            for (port, src) in &node.inputs {
                let (mut a, mut b) = (ra, rb);
                if let Some((wa, wb)) = window
                    && through.as_deref() != Some(port.as_str())
                {
                    a = a.max(wa);
                    b = b.min(wb);
                }
                if node.op == "transition" {
                    let at = num(node, "at", 0.0);
                    let end = at + num(node, "duration", 0.8);
                    if port == "a" {
                        b = b.min(end);
                    } else if port == "b" {
                        a = a.max(at);
                    }
                }
                if a < b {
                    let e = reach.entry(src.as_str()).or_insert((a, b));
                    *e = (e.0.min(a), e.1.max(b));
                }
            }
        }
        for id in &order {
            let node = &doc.nodes[id];
            let Some(w) = node.timing.filter(|t| t.has_window()) else {
                continue;
            };
            // Only effects that bound, place or hide their source leak when
            // they pass it through: a timed blur or grade is meant to apply
            // for a moment and leave the picture as it was.
            if !matches!(
                node.op.as_str(),
                "crop" | "mask" | "transform" | "corner_pin" | "opacity" | "tile" | "wave" | "twirl" | "displace"
            ) {
                continue;
            }
            let Some(port) = through_port(doc, id, node) else {
                continue;
            };
            let Some(src) = node.inputs.get(&port) else { continue };
            let (a, b) = visible(doc, src, 0);
            let (wa, wb) = (
                w.in_point.unwrap_or(f64::NEG_INFINITY),
                w.out_point.unwrap_or(f64::INFINITY),
            );
            // Leaks only where the effect reaches the screen.
            let (ra, rb) = reach
                .get(id.as_str())
                .copied()
                .unwrap_or((f64::NEG_INFINITY, f64::INFINITY));
            let (a, b) = (a.max(ra), b.min(rb));
            let before = a < wa - 1e-6 && a < b;
            let after = b > wb + 1e-6 && a < b;
            if before || after {
                issue(
                    id,
                    "warning",
                    format!(
                        "outside its window ({}) `{id}` passes `{src}` through as it is, and `{src}` shows {}: give `{src}` the same window, or time a composite above both",
                        span(wa, wb),
                        span(a, b)
                    ),
                );
            }
        }
    }
    out
}

/// The input a node shows unchanged outside its timing window: an op's pass
/// through port, or `source` for a component instance that takes one (an
/// effect: its inner nodes go inactive and pass their sources on).
fn through_port(doc: &Document, id: &str, n: &ultrafast_graph::Node) -> Option<String> {
    let component =
        doc.components.contains_key(&n.op) || crate::builtins::components().iter().any(|(name, _)| *name == n.op);
    if component {
        return n.inputs.contains_key("source").then(|| "source".to_string());
    }
    let def = crate::ops::resolve(id, n).ok()?;
    let ports = crate::ops::connected_ports(def, id, n).ok()?;
    let k = crate::ops::passthrough(def, ports.len())?;
    ports.get(k).cloned()
}

/// When a node can show anything: its own window for a generator, its
/// inputs' for effects and composites (a window on those narrows nothing:
/// outside it they pass an input through). Hulls, not exact sets.
fn visible(doc: &Document, id: &str, depth: usize) -> (f64, f64) {
    let all = (f64::NEG_INFINITY, f64::INFINITY);
    let Some(n) = doc.nodes.get(id) else { return all };
    // Generators that read images (a particle sprite, a raymarch texture,
    // 3D) show only in their own window, whatever their inputs do.
    let generator = matches!(
        n.op.as_str(),
        "particles" | "raymarch" | "render3d" | "swarm" | "fluid" | "feedback"
    );
    let own = n
        .timing
        .filter(|t| t.has_window())
        .map(|t| {
            (
                t.in_point.unwrap_or(f64::NEG_INFINITY),
                t.out_point.unwrap_or(f64::INFINITY),
            )
        })
        .unwrap_or(all);
    if n.inputs.is_empty() || generator || depth > 64 {
        return own;
    }
    // A mask (not inverted) shows only where and when its matte does.
    let inverted = matches!(n.params.get("mode"), Some(Param::Text(m)) if m.ends_with("inverted"));
    if n.op == "mask" && !inverted {
        let empty = (f64::INFINITY, f64::NEG_INFINITY);
        let src = n
            .inputs
            .get("source")
            .map(|s| visible(doc, s, depth + 1))
            .unwrap_or(empty);
        let matte = n
            .inputs
            .get("matte")
            .map(|s| visible(doc, s, depth + 1))
            .unwrap_or(empty);
        let inside = (src.0.max(matte.0).max(own.0), src.1.min(matte.1).min(own.1));
        let mut hull = if inside.0 < inside.1 { inside } else { empty };
        // Outside its own window it passes the source through.
        let film = (0.0, doc.format.duration);
        for (a, b) in [(src.0, src.1.min(own.0)), (src.0.max(own.1), src.1)] {
            let (a, b) = (a.max(film.0), b.min(film.1));
            if a < b {
                hull = (hull.0.min(a), hull.1.max(b));
            }
        }
        return hull;
    }
    if n.op == "transition" {
        let num = |k: &str, d: f64| match n.params.get(k) {
            Some(Param::Number(v)) => *v,
            _ => d,
        };
        let at = num("at", 0.0);
        let end = at + num("duration", 0.8);
        let a = n
            .inputs
            .get("a")
            .map(|s| visible(doc, s, depth + 1))
            .unwrap_or((f64::INFINITY, f64::NEG_INFINITY));
        let b = n
            .inputs
            .get("b")
            .map(|s| visible(doc, s, depth + 1))
            .unwrap_or((f64::INFINITY, f64::NEG_INFINITY));
        let a = (a.0, a.1.min(end));
        let b = (b.0.max(at), b.1);
        return (a.0.min(b.0), a.1.max(b.1));
    }
    // With a window, inputs show only inside it, except the one the node
    // passes through outside it.
    let through = n
        .timing
        .filter(|t| t.has_window())
        .and_then(|_| through_port(doc, id, n));
    let windowed = n.timing.is_some_and(|t| t.has_window());
    let mut hull = (f64::INFINITY, f64::NEG_INFINITY);
    for (port, src) in &n.inputs {
        let (mut a, mut b) = visible(doc, src, depth + 1);
        if windowed && through.as_deref() != Some(port.as_str()) {
            a = a.max(own.0);
            b = b.min(own.1);
        }
        if a < b {
            hull = (hull.0.min(a), hull.1.max(b));
        }
    }
    hull
}

fn span(a: f64, b: f64) -> String {
    let t = |v: f64, open: &str| {
        if v.is_finite() {
            format!("{v:.2} s")
        } else {
            open.to_string()
        }
    };
    format!("{} to {}", t(a, "the start"), t(b, "the end"))
}

fn type_mismatch(ty: &str, v: &Param) -> Option<String> {
    let numeric = !matches!(v, Param::Text(_) | Param::Bool(_));
    let len = match v {
        Param::Number(_) => Some(1),
        Param::Vector(x) => Some(x.len()),
        Param::Animated { keys, .. } => keys.first().map(|k| k.v.len()),
        // Drivers: their value's shape at t = 0.
        p => p.eval(0.0).map(|x| x.len()),
    };
    let ok = match ty {
        "color" => matches!(v, Param::Text(s) if s.starts_with('#')) || matches!(len, Some(3 | 4)),
        "number" => len == Some(1),
        // Scalars broadcast to vectors.
        "vec2" => matches!(len, Some(1 | 2)),
        "vec3" => matches!(len, Some(1 | 3)),
        "vec4" => matches!(len, Some(1 | 4)),
        "vec2|number" => matches!(len, Some(1 | 2)),
        "vec3|number" => matches!(len, Some(1 | 3)),
        "number[]" => numeric,
        "text" => matches!(v, Param::Text(_)),
        "text|number[]" => matches!(v, Param::Text(_)) || numeric,
        "bool" => matches!(v, Param::Bool(_)),
        t if t.starts_with("enum(") => match v {
            Param::Text(s) => t[5..t.len() - 1].split('|').any(|o| o == s),
            _ => false,
        },
        _ => true,
    };
    (!ok).then(|| format!("expected {ty}, got {}", serde_json::to_string(v).unwrap_or_default()))
}

fn edit_distance(a: &str, b: &str) -> usize {
    let (a, b): (Vec<char>, Vec<char>) = (a.chars().collect(), b.chars().collect());
    let mut prev: Vec<usize> = (0..=b.len()).collect();
    for i in 1..=a.len() {
        let mut cur = vec![i; b.len() + 1];
        for j in 1..=b.len() {
            cur[j] = (prev[j] + 1)
                .min(cur[j - 1] + 1)
                .min(prev[j - 1] + (a[i - 1] != b[j - 1]) as usize);
        }
        prev = cur;
    }
    prev[b.len()]
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn every_op_has_a_schema() {
        for d in crate::ops::OPS {
            assert!(find(d.name).is_some(), "no schema for {}", d.name);
        }
    }

    #[test]
    fn check_flags_an_effect_that_would_pass_its_source_through() {
        // The crop is on for 1..2 s but the video under it shows the whole
        // film: before and after, the uncropped picture would be on screen.
        let doc = Document::from_json(
            r##"{"version":1,"format":{"width":64,"height":64,"fps":30,"duration":3},"output":"o",
            "nodes":{"bg":{"op":"solid"},"pic":{"op":"checker"},
                     "cut":{"op":"crop","params":{"rect":[0,0,32,32]},"inputs":{"source":"pic"},"timing":{"in":1,"out":2}},
                     "o":{"op":"over","inputs":{"fg":"cut","bg":"bg"}}}}"##,
        )
        .unwrap();
        let found = check(&doc);
        assert!(
            found
                .iter()
                .any(|i| i.node == "cut" && i.severity == "warning" && i.message.contains("passes `pic` through")),
            "{found:?}"
        );
        // Given the same window, the picture cannot leak.
        let mut doc = doc;
        doc.nodes.get_mut("pic").unwrap().timing = doc.nodes["cut"].timing;
        assert!(!check(&doc).iter().any(|i| i.severity == "warning"));
    }

    #[test]
    fn check_flags_typos_and_shapes() {
        let doc = Document::from_json(
            r##"{"version":1,"format":{"width":8,"height":8,"fps":30,"duration":1},"output":"s",
            "nodes":{"s":{"op":"shape","params":{"colour":"#ff0000","radius":[1,2],"kind":"triangle"}},
                     "x":{"op":"sparkle"}}}"##,
        )
        .unwrap();
        let issues = check(&doc);
        let text: Vec<String> = issues.iter().map(|i| format!("{}: {}", i.node, i.message)).collect();
        assert!(
            text.iter()
                .any(|t| t.contains("colour") && t.contains("did you mean `color`")),
            "{text:?}"
        );
        assert!(text.iter().any(|t| t.contains("param `radius`")), "{text:?}");
        assert!(text.iter().any(|t| t.contains("param `kind`")), "{text:?}");
        assert!(text.iter().any(|t| t.contains("unknown op `sparkle`")), "{text:?}");
    }
}