File size: 111,266 Bytes
2e1a095
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d5a99d
2e1a095
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d5a99d
2e1a095
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d5a99d
2e1a095
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import argparse
import json
import re
from dataclasses import asdict, dataclass
from pathlib import Path


ROOT_DIR = Path(__file__).resolve().parent.parent
DEFAULT_REPORT = ROOT_DIR / "outputs" / "research-watchlist.md"
DEFAULT_RECOMMENDATION_REPORT = ROOT_DIR / "outputs" / "recommended-free-stack.md"
DEFAULT_DECISION_CARD_JSON = ROOT_DIR / "outputs" / "recommended-decision-card.json"
DEFAULT_DECISION_CARD_REPORT = ROOT_DIR / "outputs" / "recommended-decision-card.md"


@dataclass(frozen=True)
class Candidate:
    name: str
    kind: str
    role: str
    status: str
    license: str
    source: str
    hardware: str
    why: str
    next_step: str
    command: str


PERMISSIVE_LICENSE_MARKERS = ("apache-2.0", "mit", "openrail", "open paddleocr ecosystem")
BENCHMARK_ONLY_LICENSE_MARKERS = (
    "cc-by-nc",
    "non-commercial",
    "llama",
    "gemma",
    "check model card",
    "not established",
    "fair non-commercial",
)
DEFAULT_SAFE_STATUSES = {"wired default local voice", "wired optional sidecar"}


def is_license_default_safe(candidate: Candidate) -> bool:
    license_text = candidate.license.lower()
    if "apache-2.0 for specialized msa" in license_text:
        return True
    if any(marker in license_text for marker in BENCHMARK_ONLY_LICENSE_MARKERS):
        return False
    return any(marker in license_text for marker in PERMISSIVE_LICENSE_MARKERS)


def is_production_default_safe(candidate: Candidate) -> bool:
    status_text = candidate.status.lower()
    if "not " in status_text or "caution" in status_text or "correction can alter" in status_text:
        return False
    return candidate.status in DEFAULT_SAFE_STATUSES and is_license_default_safe(candidate)


def license_policy_violations(candidates: list[Candidate]) -> list[str]:
    violations: list[str] = []
    for candidate in candidates:
        if candidate.status in DEFAULT_SAFE_STATUSES and not is_license_default_safe(candidate):
            violations.append(
                f"{candidate.name} is marked {candidate.status!r} but has benchmark-only license {candidate.license!r}"
            )
        if (
            not is_production_default_safe(candidate)
            and "default" in candidate.next_step.lower()
            and not any(marker in candidate.next_step.lower() for marker in ["keep", "do not", "unless"])
        ):
            violations.append(f"{candidate.name} benchmark guidance may imply default promotion too early")
    return violations


CANDIDATES = [
    Candidate(
        name="QARI-OCR 0.4",
        kind="ocr",
        role="Arabic-book OCR upgrade",
        status="wired optional sidecar",
        license="Apache-2.0",
        source="https://huggingface.co/NAMAA-Space/Qari-OCR-0.4.0-VL-4B-Instruct",
        hardware="GPU or strong CPU worker; 4B VLM",
        why="Directly trained for Arabic OCR on Islamic books and Arabic manuscripts.",
        next_step="Install the sidecar or build the worker with INSTALL_QARI_OCR=1, then benchmark against arabic-max/arabic/arabic-qwen-ocr/katib-ocr/paddleocr/tesseract on the 5-page sample.",
        command=(
            "python scripts\\benchmark_ocr.py C:\\path\\to\\book-best-5-pages.pdf "
            "--page-limit 1 --engines arabic-max arabic arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract"
        ),
    ),
    Candidate(
        name="QARI-OCR 0.4 GGUF",
        kind="ocr",
        role="portable QARI packaging benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0 via QARI 0.4 model card; confirm GGUF packaging metadata before production",
        source="https://huggingface.co/marwan-osama/Qari-OCR-0.4.0-VL-4B-Instruct-GGUF",
        hardware="strong worker or local llama.cpp/GGUF runner; QARI 0.4 packaging",
        why="A newer GGUF packaging of QARI-OCR 0.4 could make the strongest Arabic-book OCR candidate easier to test in portable runtimes, but it must prove identical or better text quality and acceptable memory/runtime before app wiring.",
        next_step="Benchmark the GGUF package externally on the same exported Arabic pages against the wired QARI sidecar, KATIB, Arabic-Qwen, Baseer, PaddleOCR, and Tesseract before considering a llama.cpp-style worker path.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate qari-gguf=outputs\\external-ocr-sample\\qari-gguf.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="PaddleOCR-VL-1.6",
        kind="ocr",
        role="general document parser upgrade",
        status="wired optional sidecar",
        license="Apache-2.0",
        source="https://huggingface.co/PaddlePaddle/PaddleOCR-VL-1.6",
        hardware="strong worker; 0.9B document VLM",
        why="Fresh Apache-2.0 PaddleOCR document parser release with a June 2026 paper signal; the model card claims SOTA document parsing/text performance and the license file is Apache-2.0, but Arabic-book quality still needs same-page scoring.",
        next_step="Build with INSTALL_PADDLEOCR_VL=1 only after the smaller Arabic OCR stack is not clean enough, then benchmark the same 5-page Arabic sample before any full-book run.",
        command=(
            "python scripts\\benchmark_ocr.py C:\\path\\to\\book-best-5-pages.pdf "
            "--page-limit 1 --engines arabic-max arabic arabic-qwen-ocr katib-ocr qari-ocr paddleocr paddleocr-vl tesseract"
        ),
    ),
    Candidate(
        name="oi-OCR",
        kind="ocr",
        role="Arabic-capable document parser benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/oi-uae/oi-OCR",
        hardware="strong worker or external benchmark; PDF/document parser",
        why="Apache-2.0 document parser tagged for English/Arabic PDF OCR and layout extraction, with April 2026 ParseBench claims; promising for structured Arabic PDFs but not Arabic-book-specific.",
        next_step="Export the same selected Arabic page images and compare its Markdown/text output against QARI/KATIB/Arabic-Qwen/PaddleOCR/Tesseract before considering any wiring.",
        command="python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf --out-dir outputs\\external-ocr-sample",
    ),
    Candidate(
        name="NuExtract3",
        kind="ocr",
        role="multilingual document-to-Markdown OCR benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/numind/NuExtract3",
        hardware="GPU/large worker; 4B Qwen3.5 VLM, vLLM path recommended",
        why="Apache-2.0 4B document understanding model for OCR, document-to-Markdown, tables, forms, invoices, contracts, and multilingual documents. It is not Arabic-book-specific, so compare it externally on the same page images before considering any worker wiring.",
        next_step="Use document-to-Markdown/content mode on the exported page images and score the resulting Arabic text against QARI/KATIB/Arabic-Qwen/Baseer/PaddleOCR/Tesseract before promotion.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate nuextract3=outputs\\external-ocr-sample\\nuextract3.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Qianfan-OCR",
        kind="ocr",
        role="large multilingual document-intelligence OCR benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/baidu/Qianfan-OCR",
        hardware="GPU/large worker; 5B BF16 VLM, no hosted inference provider",
        why=(
            "Apache-2.0 unified end-to-end document OCR/VLM with multilingual/document-intelligence tags "
            "and strong general document benchmark claims. It is not Arabic-book-specific and is heavier "
            "than the normal free worker path."
        ),
        next_step=(
            "Benchmark externally only after QARI/KATIB/Arabic-Qwen/Baseer/PaddleOCR are not clean enough; "
            "score it on the same exported Arabic book pages before considering any worker wiring."
        ),
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "# Run baidu/Qianfan-OCR externally on the same page images, then save merged text as "
            "outputs\\external-ocr-sample\\qianfan-ocr.txt.\n"
            "python scripts\\score_external_ocr.py --candidate qianfan-ocr=outputs\\external-ocr-sample\\qianfan-ocr.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Chandra OCR 2",
        kind="ocr",
        role="multilingual structured document OCR benchmark",
        status="not default; OpenRAIL weights and GPU-heavy",
        license="Apache-2.0 code; modified OpenRAIL-M model weights",
        source="https://github.com/datalab-to/chandra",
        hardware="GPU/large worker; 4B OCR model, vLLM path recommended",
        why="Recent Chandra 2 release supports Arabic among 90+ languages and reports strong structured document OCR/layout performance, but the weights are modified OpenRAIL-M and it is not Arabic-book-specific.",
        next_step="Benchmark externally on the same exported page images for hard layouts, tables, forms, or mixed-language pages; keep QARI/KATIB/Arabic-Qwen/Baseer first for Arabic books unless Chandra wins same-page scoring and the license/runtime fit.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "chandra outputs\\external-ocr-sample\\images outputs\\external-ocr-sample\\chandra --method hf\n"
            "python scripts\\score_external_ocr.py --candidate chandra=outputs\\external-ocr-sample\\chandra.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="dots.ocr",
        kind="ocr",
        role="compact multilingual document-layout OCR benchmark",
        status="not wired; benchmark externally first",
        license="MIT",
        source="https://huggingface.co/rednote-hilab/dots.ocr",
        hardware="GPU/strong worker; compact 1.7B document parser, vLLM path recommended",
        why="MIT multilingual document parser that unifies layout detection and content recognition with reading-order, table, and formula support. It is not Arabic-book-specific, but it is worth scoring on difficult Arabic layouts because public sources mention Arabic/low-resource multilingual OCR.",
        next_step="Run externally on the same exported Arabic page images and score the resulting text against QARI/KATIB/Arabic-Qwen/Baseer/PaddleOCR/Tesseract before considering any worker wiring.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate dots-ocr=outputs\\external-ocr-sample\\dots-ocr.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="olmOCR Arabic LoRA v2",
        kind="ocr",
        role="full-page Arabic manuscript OCR benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0 adapter; confirm base model license/runtime before production",
        source="https://huggingface.co/hastyle/olmOCR-arabic-lora-v2",
        hardware="GPU/large worker; 7B olmOCR/Qwen2.5-VL base plus LoRA adapter",
        why="Apache-2.0 Arabic manuscript OCR LoRA trained on full-page manuscript images, which makes it relevant when line-cropping is impractical; still too heavy for the default free family worker.",
        next_step="Run externally on the same exported full-page manuscript images and compare against Ketaba, QARI, HAFITH/Glimpse line workflows, Kraken/eScriptorium, and the wired Arabic OCR baseline before considering any sidecar work.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-manuscript.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "# Run hastyle/olmOCR-arabic-lora-v2 with allenai/olmOCR-2-7B-1025 on the exported full-page images, "
            "then save merged text as outputs\\external-ocr-sample\\olmocr-arabic-lora.txt.\n"
            "python scripts\\score_external_ocr.py --candidate olmocr-arabic-lora=outputs\\external-ocr-sample\\olmocr-arabic-lora.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Arabic Large Nougat",
        kind="ocr",
        role="Arabic book page OCR-to-Markdown benchmark",
        status="not default; GPL-3.0 and benchmark externally first",
        license="GPL-3.0",
        source="https://huggingface.co/MohamedRashad/arabic-large-nougat",
        hardware="GPU/strong worker; 0.4B VisionEncoderDecoder/Nougat-style model",
        why="Arabic-specific OCR model for converting Arabic book page images into structured text/Markdown. It is lighter than many VLM OCR options and directly relevant to book pages, but GPL-3.0 keeps it out of the default public hosted worker.",
        next_step="Run externally on the same exported Arabic book page images and compare Markdown/text output against QARI, KATIB, Arabic-Qwen, Baseer, PaddleOCR, Tesseract, and the other external OCR benchmarks before considering any separate license-aware workflow.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "# Run MohamedRashad/arabic-large-nougat externally on the exported page images, "
            "then save merged text/Markdown as outputs\\external-ocr-sample\\arabic-large-nougat.txt.\n"
            "python scripts\\score_external_ocr.py --candidate arabic-large-nougat=outputs\\external-ocr-sample\\arabic-large-nougat.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="DocTR Arabic FAST/PARSEQ",
        kind="ocr",
        role="classic Arabic OCR detector/recognizer benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0 detector; recognition card lacks clear metadata, confirm before production",
        source="https://huggingface.co/madskills/doctr-fast_base-arabic",
        hardware="CPU/GPU worker; DocTR detector plus Arabic PARSEQ recognizer",
        why="Apache-2.0 Arabic FAST text detector designed to pair with an Arabic PARSEQ recognizer; useful as a non-VLM Arabic OCR benchmark when large document VLMs are too heavy.",
        next_step="Benchmark externally on the same exported Arabic page images and promote only if the recognition model license is confirmed and it beats PaddleOCR/Tesseract/EasyOCR on book text ordering and word preservation.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\score_external_ocr.py --candidate doctr-arabic=outputs\\external-ocr-sample\\doctr-arabic.txt "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Kraken/eScriptorium Arabic script",
        kind="ocr",
        role="open-source historical Arabic-script OCR benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0 engine; model license depends on selected Kraken model",
        source="https://kraken.re/main/index.html",
        hardware="CPU/GPU external benchmark; best with line segmentation and Arabic-script models",
        why="Kraken is an open-source ATR/OCR system optimized for historical and non-Latin scripts. eScriptorium builds on Kraken for manuscript and archival OCR, including Arabic-script workflows, so it is useful when book scans look more like historical print or manuscripts than modern PDFs.",
        next_step="Export the same selected page images, run Kraken/eScriptorium with an Arabic-script recognition model or line-cropped workflow, then score the resulting text against the wired Arabic OCR stack before considering any sidecar work.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "kraken -i outputs\\external-ocr-sample\\images\\page-0001.png outputs\\external-ocr-sample\\kraken-page-0001.txt "
            "segment ocr -m C:\\path\\to\\arabic-script-kraken-model.mlmodel\n"
            "python scripts\\score_external_ocr.py --candidate kraken=outputs\\external-ocr-sample\\kraken.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Kairawan/Qalamus manuscript OCR",
        kind="ocr",
        role="free Arabic manuscript OCR service signal",
        status="not wired; service-only benchmark signal",
        license="free web service; engine/package license not established",
        source="https://kairawan.org/",
        hardware="external web service; not a reusable local worker package",
        why=(
            "Kairawan is a 2026 Arabic and Islamic manuscript index that offers free automatic "
            "Arabic transcription where rights allow, and related public pages mention Qalamus as the "
            "manuscript HTR/OCR engine. This is useful evidence that Arabic manuscript OCR is improving, "
            "but it is not a drop-in free software dependency for this Vercel plus worker app."
        ),
        next_step=(
            "Use only as an external comparison when the source PDF is manuscript-like; do not wire it "
            "into the app unless a reusable open engine, API terms, privacy story, and same-page scoring "
            "beat QARI/KATIB/Kraken/HAFITH on the selected sample."
        ),
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-manuscript.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "# If Kairawan/Qalamus output is available for the same pages, save it as "
            "outputs\\external-ocr-sample\\kairawan-qalamus.txt.\n"
            "python scripts\\score_external_ocr.py --candidate kairawan-qalamus=outputs\\external-ocr-sample\\kairawan-qalamus.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="GLM-OCR Arabic/French documents",
        kind="ocr",
        role="Arabic administrative/document OCR benchmark",
        status="not wired; benchmark externally first",
        license="check model card/base license before production use",
        source="https://huggingface.co/maloukafer/GLM-OCR-finetuned-documents",
        hardware="GPU/strong worker; GLM-OCR LoRA fine-tune",
        why="Recent GLM-OCR LoRA fine-tune on thousands of manually annotated Arabic and French scanned documents; useful for forms, receipts, newspapers, and official documents, but not Arabic-book-specific.",
        next_step="Benchmark externally for administrative/form-like Arabic PDFs and compare against Arabic-GLM-OCR-v2, QARI, KATIB, Baseer, PaddleOCR, and Tesseract before wiring.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\score_external_ocr.py --candidate glm-docs=outputs\\external-ocr-sample\\glm-docs.txt "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="mimoha Arabic OCR",
        kind="ocr",
        role="minimal Arabic OCR model-card watchlist",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/mimoha/ocr",
        hardware="external benchmark; sparse card and no inference provider",
        why="Apache-2.0 Arabic OCR model card says it extracts Arabic text from images, but the public card is sparse and references a Mistral OCR-style API path rather than a detailed local runner.",
        next_step="Keep as a low-priority external benchmark only; test on exported page images if the stronger Arabic OCR candidates fail or if a clean local runner becomes available.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\score_external_ocr.py --candidate mimoha-ocr=outputs\\external-ocr-sample\\mimoha-ocr.txt "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="KATIB 0.8B",
        kind="ocr",
        role="light Arabic-trained OCR VLM",
        status="wired optional sidecar",
        license="Apache-2.0",
        source="https://huggingface.co/oddadmix/Katib-Qwen3.5-0.8B-0.1",
        hardware="smaller worker than QARI; 0.8B VLM",
        why="Fine-tuned specifically for Arabic OCR, including printed and handwritten text, while being much smaller than QARI 4B.",
        next_step="Install the sidecar or build the worker with INSTALL_KATIB_OCR=1, then benchmark against arabic-max/arabic/arabic-qwen-ocr/qari-ocr/paddleocr/tesseract on the 5-page sample.",
        command=(
            "python scripts\\benchmark_ocr.py C:\\path\\to\\book-best-5-pages.pdf "
            "--page-limit 1 --engines arabic-max arabic arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract"
        ),
    ),
    Candidate(
        name="Arabic-GLM-OCR-v2",
        kind="ocr",
        role="recent Arabic OCR VLM sidecar",
        status="wired optional sidecar",
        license="Apache-2.0",
        source="https://huggingface.co/sherif1313/Arabic-GLM-OCR-v2",
        hardware="strong worker; GLM-OCR fine-tune",
        why="Recent Arabic OCR model card claims strong Arabic document extraction and noise reduction; it is wired as an optional sidecar so it can be scored against QARI/KATIB/Arabic-Qwen/Baseer on the target book pages.",
        next_step="Install the sidecar or build the worker with INSTALL_ARABIC_GLM_OCR=1, then benchmark it on the same 5-page sample before any full-book run.",
        command=(
            ".\\scripts\\setup_arabic_glm_ocr.ps1\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic arabic-glm-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract"
        ),
    ),
    Candidate(
        name="Arabic-Qwen3.5-OCR-v4",
        kind="ocr",
        role="small Arabic OCR VLM sidecar",
        status="wired optional sidecar",
        license="Apache-2.0",
        source="https://huggingface.co/sherif1313/Arabic-Qwen3.5-OCR-v4",
        hardware="strong worker; 0.9B OCR VLM",
        why="Recent Arabic OCR model card claims Arabic printed, handwritten, classical, and diacritic handling in a smaller 0.9B model.",
        next_step="Install the sidecar or build the worker with INSTALL_ARABIC_QWEN_OCR=1, then benchmark against arabic-max/arabic/katib-ocr/qari-ocr/paddleocr/tesseract on the 5-page sample.",
        command=(
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract"
        ),
    ),
    Candidate(
        name="aNS Qwen3-VL Arabic OCR v3",
        kind="ocr",
        role="fresh Qwen3-VL Arabic OCR benchmark candidate",
        status="not wired; benchmark externally first",
        license="check model card/base license before production use",
        source="https://huggingface.co/aNS2024/qwen3-vl-arabic-ocr-v3",
        hardware="GPU/strong worker; Qwen3-VL-2B fine-tune",
        why="Fresh Hugging Face Arabic OCR fine-tune from Qwen3-VL-2B; the public card shows no inference provider and sparse OCR evaluation detail, so it should be scored on the same selected Arabic pages before any app wiring.",
        next_step="Export the same 5-page Arabic sample images, run this model externally, and promote only if it beats QARI/KATIB/Arabic-Qwen/Baseer on faithful Arabic text, reading order, runtime, and license fit.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\score_external_ocr.py --candidate ans-qwen3-vl-arabic-ocr-v3=outputs\\external-ocr-sample\\ans-qwen3-vl-arabic-ocr-v3.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md "
            "--write-json outputs\\external-ocr-sample\\external-ocr-score.json\n"
            "python scripts\\model_promotion_gate.py --candidate-name \"aNS Qwen3-VL Arabic OCR v3\" "
            "--kind ocr --license \"check model card/base license before production use\" "
            "--score-json outputs\\external-ocr-sample\\external-ocr-score.json --same-sample "
            "--runtime-ok --privacy-ok --human-reviewed --write-report outputs\\external-ocr-sample\\ocr-promotion-gate.md"
        ),
    ),
    Candidate(
        name="Waraqon v3 Arabic OCR HTML Qari",
        kind="ocr",
        role="Qari-family structured HTML OCR benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/FatimahEmadEldin/Waraqon-v3-Arabic-OCR-HTML-Qari",
        hardware="GPU/strong worker; Qwen2-VL/Qari LoRA path",
        why="Apache-2.0 Qari-family fine-tune for Arabic OCR with HTML structure, trained on a Qari 0.3 markdown/HTML-style dataset. It may help complex pages, but audiobook generation needs faithful continuous Arabic text, so same-page text scoring is required before any app wiring.",
        next_step="Export the same selected Arabic page images, run Waraqon externally, strip or normalize HTML to readable Arabic text, and promote only if text order, word preservation, runtime, and license fit beat QARI/KATIB/Arabic-Qwen/Baseer.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "# Run FatimahEmadEldin/Waraqon-v3-Arabic-OCR-HTML-Qari externally on the same page images, "
            "then save normalized readable text as outputs\\external-ocr-sample\\waraqon-v3.txt.\n"
            "python scripts\\score_external_ocr.py --candidate waraqon-v3=outputs\\external-ocr-sample\\waraqon-v3.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md "
            "--write-json outputs\\external-ocr-sample\\external-ocr-score.json\n"
            "python scripts\\model_promotion_gate.py --candidate-name \"Waraqon v3 Arabic OCR HTML Qari\" "
            "--kind ocr --license \"Apache-2.0\" --score-json outputs\\external-ocr-sample\\external-ocr-score.json "
            "--same-sample --runtime-ok --privacy-ok --human-reviewed --write-report outputs\\external-ocr-sample\\ocr-promotion-gate.md"
        ),
    ),
    Candidate(
        name="DeepSeek-OCR-2",
        kind="ocr",
        role="latest general document OCR VLM benchmark candidate",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/deepseek-ai/DeepSeek-OCR-2",
        hardware="GPU/large worker; 3B DeepSeek OCR VLM",
        why="Official 2026 DeepSeek OCR successor with Apache-2.0 licensing, vLLM/SGLang guidance, and public document OCR benchmark results; not Arabic-specific, so score it on the target Arabic book pages before promotion.",
        next_step="Benchmark externally on the same exported page images and promote only if it beats QARI/KATIB/Arabic-Qwen/Baseer while the worker can handle 3B VLM inference.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate deepseek-ocr-2=outputs\\external-ocr-sample\\deepseek-ocr-2.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="DeepSeek Arabic OCR v6",
        kind="ocr",
        role="DeepSeek-OCR Arabic benchmark candidate",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/melsiddieg/deepseek_ocr_arabic_v6",
        hardware="GPU/large worker; 3B DeepSeek-OCR fine-tune",
        why="Newer Apache-2.0 Arabic-labeled DeepSeek-OCR fine-tune than v4/v5, but the model card has sparse evaluation detail and no hosted inference provider, so keep it as an external same-page benchmark.",
        next_step="Benchmark externally on the same exported page images and promote only if it beats the wired Arabic OCR stack on the target pages.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate deepseek-ar-v6=outputs\\external-ocr-sample\\deepseek-ar-v6.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Loay Arabic-OCR-DeepSeek-OCR-2",
        kind="ocr",
        role="Arabic DeepSeek-OCR-2 layout benchmark candidate",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/loay/Arabic-OCR-DeepSeek-OCR-2",
        hardware="GPU/large worker; 3B DeepSeek-OCR-2 fine-tune",
        why="Recent Apache-2.0 merged DeepSeek-OCR-2 Arabic fine-tune aimed at high-precision OCR and structural layout analysis from Arabic images; promising for pages where layout preservation matters, but it is still 3B-class and must beat the Arabic-specific QARI/KATIB/Arabic-Qwen/Baseer stack on the same book pages.",
        next_step="Benchmark externally on the same exported Arabic page images and promote only if it beats QARI/KATIB/Arabic-Qwen/Baseer without hallucinating or reordering text and the worker can handle 3B VLM inference.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate loay-deepseek-ocr-2=outputs\\external-ocr-sample\\loay-deepseek-ocr-2.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Arabic-English handwritten OCR v3",
        kind="ocr",
        role="handwriting/manuscript OCR benchmark candidate",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/sherif1313/Arabic-English-handwritten-OCR-v3",
        hardware="strong worker; Qwen2.5-VL 3B-class model, 7.5GB model assets",
        why="Apache-2.0 Arabic/English handwritten OCR model with model-card claims for handwritten and manuscript pages; useful when the PDF has marginal notes, handwriting, or older script that the book OCR stack misses.",
        next_step="Benchmark externally on the same exported page images and promote only if it beats QARI/KATIB/Arabic-Qwen/Baseer on the target handwriting or manuscript pages.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate handwritten-v3=outputs\\external-ocr-sample\\handwritten-v3.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Arabic handwritten OCR 4-bit Qwen2.5-VL",
        kind="ocr",
        role="lighter quantized handwriting/manuscript OCR benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/sherif1313/Arabic-handwritten-OCR-4bit-Qwen2.5-VL-3B-v3",
        hardware="strong worker; 4-bit Qwen2.5-VL 3B-class model, about 2.44GB model assets",
        why="Apache-2.0 4-bit Arabic handwritten OCR checkpoint that is much smaller than the full Arabic-English handwritten OCR model; useful when handwriting or manuscript pages matter and a free worker cannot handle the larger checkpoint.",
        next_step="Benchmark externally on the same exported handwriting/manuscript page images and promote only if it beats the wired Arabic OCR stack without introducing hallucinated or reordered text.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate handwritten-4bit=outputs\\external-ocr-sample\\handwritten-4bit.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="NAKBA Arabic manuscript line OCR baseline",
        kind="ocr",
        role="Arabic manuscript line-transcription benchmark",
        status="not wired; benchmark externally first",
        license="check model card/base license before production use",
        source="https://huggingface.co/U4RASD/ar-ms-baseline",
        hardware="large GPU/strong worker; Qwen3-VL-8B LoRA baseline, H100 used in reported evaluation",
        why="NAKBA NLP 2026 shared-task baseline for Arabic manuscript line transcription, with reported CER/WER on released line-image tests; useful only when the source PDF has manuscript or memoir-style handwritten line images.",
        next_step="Keep external and line-level only unless a preprocessing step crops pages into lines; compare with handwritten-v3 and handwritten-4bit on the same manuscript images before any wiring.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-manuscript.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\score_external_ocr.py --candidate nakba-ms-line=outputs\\external-ocr-sample\\nakba-ms-line.txt "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="HAFITH",
        kind="ocr",
        role="historical Arabic manuscript line OCR benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/mdnaseif/hafith",
        hardware="GPU/strong worker likely; 642M line OCR model with line segmentation required",
        why="Apache-2.0 Arabic-native OCR model for historical manuscript line recognition with 5.10% CER claims, but it operates on pre-segmented text lines rather than full PDF pages.",
        next_step="Use only when a scanned book looks like historical print or manuscript pages; crop pages into text lines first, then compare HAFITH line output against Kraken/eScriptorium, NAKBA line OCR, and the wired OCR baseline.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "# Crop selected pages into text-line images before running mdnaseif/hafith, then save the merged line text as "
            "outputs\\external-ocr-sample\\hafith.txt.\n"
            "python scripts\\score_external_ocr.py --candidate hafith=outputs\\external-ocr-sample\\hafith.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Glimpse RTL OCR",
        kind="ocr",
        role="Arabic/Persian RTL text-line OCR benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/surfiniaburger/unsloth_finetune_ocr_arabic",
        hardware="GPU/strong worker likely; 1B text-line VLM fine-tune",
        why="Apache-2.0 Arabic/Persian RTL text-line OCR model fine-tuned from an ERNIE/PaddleOCR-VL path with 6.97% CER claims on unseen RTL text lines, but it is line-level rather than a full-page PDF OCR default.",
        next_step="Use only after selected PDF pages are cropped into Arabic/Persian text-line images; compare against HAFITH, NAKBA line OCR, Qwen3-VL Persian/Arabic line OCR, Kraken/eScriptorium, and the wired OCR baseline.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "# Crop selected pages into text-line images before running surfiniaburger/unsloth_finetune_ocr_arabic, then save the merged line text as "
            "outputs\\external-ocr-sample\\glimpse-rtl.txt.\n"
            "python scripts\\score_external_ocr.py --candidate glimpse-rtl=outputs\\external-ocr-sample\\glimpse-rtl.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Arabic OCR Qwen2.5-VL GGUF",
        kind="ocr",
        role="QariOCR-trained Arabic/English GGUF OCR benchmark",
        status="not wired; benchmark externally first",
        license="check model card/base license before production use",
        source="https://huggingface.co/mo1998/arabic-ocr-qwen2.5-vl",
        hardware="large GPU/strong worker; Qwen2.5-VL 7B-class GGUF/Unsloth path",
        why="Arabic/English OCR fine-tune trained on QariOCR v0.3 mixed data and aimed at scanned books, religious texts, handwritten forms, and mixed-language documents; useful as an external GGUF-style comparison against QARI 0.4 and the wired Arabic OCR stack.",
        next_step="Benchmark externally on the same exported page images, confirm license fit, and promote only if it beats QARI/KATIB/Arabic-Qwen/Baseer on the target pages while the worker can handle 7B-class inference.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate qwen25-gguf=outputs\\external-ocr-sample\\qwen25-gguf.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Qwen3-VL Persian/Arabic line OCR",
        kind="ocr",
        role="line-level Persian/Arabic OCR benchmark candidate",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/mohajesmaeili/Qwen3-VL-2B-Persian-Arabic-Ocr-v1.0",
        hardware="strong worker; Qwen3-VL 2B line-level OCR model",
        why="Apache-2.0 Qwen3-VL 2B fine-tune for Persian/Arabic text-line OCR; interesting for cropped line images, but its model card says it was trained on individual text lines and is not designed for full-page OCR.",
        next_step="Keep external unless a preprocessing/layout step crops Arabic book pages into lines; benchmark only on exported/cropped line images and compare against the full-page Arabic OCR stack before any wiring.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\score_external_ocr.py --candidate qwen3-line-ocr=outputs\\external-ocr-sample\\qwen3-line-ocr.txt "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Loay Arabic-OCR-Qwen2.5-VL-7B",
        kind="ocr",
        role="large Arabic OCR VLM benchmark candidate",
        status="not wired; benchmark externally first",
        license="Apache-2.0 via Qwen2.5-VL base, confirm model-card license before production",
        source="https://huggingface.co/loay/Arabic-OCR-Qwen2.5-VL-7B-Vision",
        hardware="large GPU/strong worker; Qwen2.5-VL 7B fine-tune",
        why="Arabic OCR VLM fine-tuned from Qwen2.5-VL-7B for OCR on Arabic text from images; useful as a high-capacity comparison when smaller Arabic OCR sidecars fail.",
        next_step="Benchmark externally on the same exported page images and promote only if it beats QARI/KATIB/Arabic-Qwen/Baseer while the worker can handle 7B-class runtime.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate loay-qwen25=outputs\\external-ocr-sample\\loay-qwen25.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="DIMI Arabic OCR v2",
        kind="ocr",
        role="large Arabic OCR LoRA benchmark candidate",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/AhmedZaky1/DIMI-Arabic-OCR-V2",
        hardware="large GPU/strong worker; Qwen2.5-VL 7B LoRA with 4-bit option",
        why="Recent Arabic OCR model card reports improved diacritics handling, printed-document extraction, and lower WER/CER than its v1 model, but it is 7B-class and needs external scoring on the target book pages.",
        next_step="Benchmark externally on the same exported page images and promote only if it beats the wired Arabic OCR sidecars while the worker can handle the 7B LoRA runtime.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic arabic-glm-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate dimi-v2=outputs\\external-ocr-sample\\dimi-v2.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="AtlasOCR",
        kind="ocr",
        role="Darija/Moroccan Arabic OCR watchlist",
        status="not wired; benchmark externally first",
        license="check model card before production use",
        source="https://huggingface.co/atlasia/AtlasOCR",
        hardware="strong worker; Qwen2.5-VL 3B fine-tune",
        why="First open-source Darija OCR model; useful if the PDFs contain Moroccan Arabic or Darija rather than standard printed MSA.",
        next_step="Benchmark only for Darija/Moroccan content, and confirm licensing before any production wiring.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\score_external_ocr.py --candidate atlasocr=outputs\\external-ocr-sample\\atlasocr.txt "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Ketaba-OCR LoRA",
        kind="ocr",
        role="Arabic manuscript OCR benchmark candidate",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/HassanB4/Ketaba-OCR-LoRA",
        hardware="strong worker; Qwen2.5-VL-3B base plus LoRA adapter",
        why="Arabic manuscript benchmark winner candidate with reported low character error rate, useful when book/manuscript scans defeat the wired OCR stack.",
        next_step="Benchmark externally on one or two page images before considering a sidecar because it needs a separate base VLM plus adapter setup.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate ketaba=outputs\\external-ocr-sample\\ketaba.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Qari-OCR-LoRA",
        kind="ocr",
        role="Arabic manuscript OCR secondary QARI-family benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/HassanB4/Qari-OCR-LoRA",
        hardware="strong worker; QARI/Qwen2-VL-family base plus LoRA adapter",
        why="Apache-2.0 experimental QARI-family LoRA from the NakbaNLP 2026 Arabic manuscript OCR task; useful as a secondary manuscript benchmark after Ketaba because its own model card says Ketaba was the primary winning submission.",
        next_step="Benchmark externally on the same manuscript-like page images only after QARI 0.4, Ketaba, KATIB, and the wired OCR stack have been scored.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-manuscript.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate qari-ocr-lora=outputs\\external-ocr-sample\\qari-ocr-lora.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Tawkeed OCR",
        kind="ocr",
        role="Arabic-first OCR sidecar",
        status="wired optional sidecar",
        license="Apache-2.0",
        source="https://huggingface.co/tawkeed-sa/tawkeed-ocr",
        hardware="strong worker or edge/GPU test; QARI v0.3 2B fork",
        why="Arabic-first OCR model forked from QARI-OCR v0.3 and fine-tuned for Arabic documents, handwriting, and scene text; useful to test when QARI 0.4 is too heavy or when edge-style deployment matters.",
        next_step="Install the sidecar or build the worker with INSTALL_TAWKEED_OCR=1, then benchmark against QARI 0.4, KATIB, Arabic-Qwen, Baseer, and Tesseract on the same 5-page sample.",
        command=(
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic tawkeed-ocr arabic-qwen-ocr katib-ocr qari-ocr baseer-ocr paddleocr tesseract"
        ),
    ),
    Candidate(
        name="Falcon-OCR",
        kind="ocr",
        role="compact document OCR VLM watchlist",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/tiiuae/Falcon-OCR",
        hardware="strong worker; 300M document VLM",
        why="Smaller Apache-2.0 document OCR VLM that may be useful when VLM OCR is needed but larger parsers are too heavy.",
        next_step="Run an external one-page image benchmark and compare cleaned Arabic word count, quality score, and reading order against QARI, Arabic-Qwen, and Tesseract.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract --json > "
            "outputs\\external-ocr-sample\\wired-ocr-baseline.json\n"
            "python scripts\\score_external_ocr.py --candidate falcon=outputs\\external-ocr-sample\\falcon.txt "
            "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="Baseer OCR V1.0",
        kind="ocr",
        role="Arabic legal/complex document OCR sidecar",
        status="wired optional sidecar",
        license="Apache-2.0",
        source="https://huggingface.co/AbdoTarek/Baseer-OCR-V1.0",
        hardware="strong worker; Qwen2-VL 2B fine-tune",
        why="Arabic-specific VLM OCR for complex legal documents, multi-column layouts, stamps, tables, and handwritten/printed Arabic.",
        next_step="Install the sidecar or build the worker with INSTALL_BASEER_OCR=1, then benchmark against arabic-max/arabic/arabic-qwen-ocr/katib-ocr/qari-ocr/paddleocr/tesseract on the 5-page sample.",
        command=(
            ".\\scripts\\setup_baseer_ocr.ps1\n"
            "python scripts\\benchmark_ocr.py test_pdfs\\book-best-5-pages.pdf --page-limit 5 "
            "--engines arabic-max arabic baseer-ocr arabic-qwen-ocr katib-ocr qari-ocr paddleocr tesseract"
        ),
    ),
    Candidate(
        name="Raqim post-OCR correction",
        kind="ocr",
        role="Arabic OCR correction research caution",
        status="not wired; correction can alter source text",
        license="open-access paper; implementation/license not established for this app",
        source="https://www.sciencedirect.com/science/article/pii/S187705092600058X",
        hardware="depends on correction model; dictionary plus LLM workflow",
        why="2026 research reports Arabic OCR correction gains by combining dictionary-based correction and LLMs, but correction may rewrite exact book/religious wording, so it should not run automatically before TTS.",
        next_step="Keep as a manual review/research idea only. If used later, expose it as an explicit reviewed correction mode, never as the default reading path.",
        command="python scripts\\dry_run_pdf.py C:\\path\\to\\arabic-book.pdf --include-speech-text --speech-sample-chars 1200",
    ),
    Candidate(
        name="Arabic Legal Documents OCR 1.0",
        kind="ocr",
        role="legal/structured Arabic OCR benchmark candidate",
        status="not default; Gemma license and domain-specific",
        license="Gemma license",
        source="https://huggingface.co/bakrianoo/arabic-legal-documents-ocr-1.0",
        hardware="GPU/large worker; Gemma-3-4B-IT VLM fine-tune",
        why="Recent Arabic legal-document OCR VLM optimized for low-quality scanned Arabic legal documents and structured extraction; useful only when the target PDF is legal/structured rather than a normal book.",
        next_step="Benchmark externally on exported page images only for legal or form-like Arabic PDFs; keep it out of the default family audiobook stack because it is Gemma-licensed and domain-specific.",
        command=(
            "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
            "--out-dir outputs\\external-ocr-sample\n"
            "python scripts\\score_external_ocr.py --candidate legal-docs-ocr=outputs\\external-ocr-sample\\legal-docs-ocr.txt "
            "--write-report outputs\\external-ocr-sample\\external-ocr-score.md"
        ),
    ),
    Candidate(
        name="SILMA TTS",
        kind="tts",
        role="default Arabic neural voice",
        status="wired default local voice",
        license="MIT code, Apache-2.0 model weights",
        source="https://huggingface.co/silma-ai/silma-tts",
        hardware="CPU worker practical baseline",
        why="Arabic-focused Fusha/MSA voice with normalization and tashkeel options.",
        next_step="Keep as the first listen-test voice for every book sample.",
        command="python scripts\\benchmark_voices.py --voices silma-local espeak-ar-clear --write-report outputs\\voice-benchmark-report.md",
    ),
    Candidate(
        name="Habibi-TTS MSA",
        kind="tts",
        role="optional Arabic MSA voice comparison",
        status="wired optional sidecar",
        license="Apache-2.0 for specialized MSA; other variants may be non-commercial",
        source="https://github.com/SWivid/Habibi-TTS",
        hardware="CPU/GPU worker depending on model/runtime",
        why="Arabic-specific 2026 TTS family worth comparing against SILMA on MSA passages.",
        next_step="Install the optional sidecar and listen against the same cleaned OCR sample.",
        command="python scripts\\benchmark_voices.py --voices silma-local habibi-msa espeak-ar-clear --write-report outputs\\voice-benchmark-report.md",
    ),
    Candidate(
        name="Mishkala Tashkeel",
        kind="tts",
        role="Arabic pronunciation preprocessor benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/flokymind/mishkala",
        hardware="CPU/worker practical; 12.5M diacritization model",
        why="Lightweight Apache-2.0 Arabic diacritization model with model-card DER claims; useful to test whether adding tashkeel improves SILMA, Habibi, Supertonic, or eSpeak pronunciation on the exact book text.",
        next_step="Benchmark on the same cleaned speech sample before wiring. Promote only if listening tests improve pronunciation without changing meaning or adding distracting/incorrect harakat.",
        command=(
            "python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf "
            "--env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample\n"
            "# Then diacritize outputs\\external-tts-sample\\arabic-tts-sample.txt with flokymind/mishkala "
            "and listen-test the same text with SILMA/Habibi/Supertonic before enabling any automatic path."
        ),
    ),
    Candidate(
        name="Tashkeel-350M",
        kind="tts",
        role="larger Arabic pronunciation preprocessor benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/Etherll/Tashkeel-350M",
        hardware="GPU/strong worker likely; 350M Arabic diacritization model",
        why="Apache-2.0 Arabic diacritization model that is much larger than Mishkala. It may improve pronunciation for some voices, but larger tashkeel models can still add wrong harakat, so compare by listening before production use.",
        next_step="Export the same cleaned Arabic TTS sample, create a Tashkeel-350M diacritized copy, synthesize plain/Mishkala/Tashkeel-350M with the same voice, and score meaning preservation plus long-listen comfort.",
        command=(
            "python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env "
            "--out-dir outputs\\external-tts-sample\n"
            "# Then diacritize outputs\\external-tts-sample\\arabic-tts-sample.txt with Etherll/Tashkeel-350M and "
            "score it with scripts\\score_tts_preprocessor.py before enabling any automatic path."
        ),
    ),
    Candidate(
        name="Mushkil",
        kind="tts",
        role="AraT5V2 Arabic pronunciation preprocessor benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/riotu-lab/mushkil",
        hardware="GPU/strong worker likely; AraT5V2 Arabic diacritization model",
        why="Apache-2.0 AraT5V2 Arabic diacritization model. It belongs in the same pronunciation-preprocessor benchmark lane as Mishkala and Tashkeel-350M, but automatic harakat can still change perceived meaning or comfort.",
        next_step="Export the same cleaned Arabic TTS sample, create a Mushkil-diacritized copy, synthesize plain/Mishkala/Tashkeel-350M/Mushkil with the same voice, and score meaning preservation plus long-listen comfort.",
        command=(
            "python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env "
            "--out-dir outputs\\external-tts-sample\n"
            "# Then diacritize outputs\\external-tts-sample\\arabic-tts-sample.txt with riotu-lab/mushkil and "
            "score it with scripts\\score_tts_preprocessor.py before enabling any automatic path."
        ),
    ),
    Candidate(
        name="Thaka KSAA-2026 speech diacritization",
        kind="tts",
        role="Arabic diacritization research signal",
        status="research signal only; no deployable model yet",
        license="CC BY 4.0 paper; implementation/model license not established",
        source="https://arxiv.org/abs/2605.25928",
        hardware="not applicable until code/weights are released; paper describes CATT-Whisper ensemble inference",
        why="Late-May 2026 winning KSAA shared-task system for Arabic speech dictation diacritization. It is useful evidence that acoustic-plus-text diacritization can improve Arabic pronunciation work, but it is not a plug-in free model for this PDF-to-audio app.",
        next_step="Track for released code/weights or a permissive checkpoint. Until then, keep website preprocessing limited to same-sample Mishkala/Tashkeel-350M/Mushkil listening tests and meaning-preservation scoring.",
        command=(
            "python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env "
            "--out-dir outputs\\external-tts-sample\n"
            "# Do not wire Thaka automatically; use the paper as a benchmark signal until a permissive implementation exists."
        ),
    ),
    Candidate(
        name="3arab-TTS 500M",
        kind="tts",
        role="new Arabic-only voice benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/sherif1313/3arab-TTS-500M-v1",
        hardware="GPU/strong worker likely; 500M Arabic RF-DiT model",
        why="Very recent Arabic-only Apache-2.0 TTS model trained on Arabic speech datasets; promising enough to benchmark against SILMA/Habibi before any app wiring.",
        next_step="Export the same cleaned Arabic text used for SILMA/Habibi, then compare base and VoiceDesign variants for audiobook comfort, stability, and long-form pacing.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="KaniTTS Arabic",
        kind="tts",
        role="high-speed Arabic voice benchmark",
        status="not wired; benchmark externally first",
        license="model card says Apache-2.0, but Hugging Face metadata reports lfm1.0; confirm before production",
        source="https://huggingface.co/nineninesix/kani-tts-400m-ar",
        hardware="GPU/strong worker likely; 400M model, reported low latency with vLLM",
        why="Recent Arabic-only TTS model with high-speed claims; promising for faster audiobook generation, but current Hugging Face metadata reports lfm1.0 while the card text says Apache-2.0.",
        next_step="Export the same cleaned Arabic sample used for SILMA/Habibi, then benchmark naturalness, skipped words, pacing, runtime, and license fit before considering app wiring.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Emirati VITS Male",
        kind="tts",
        role="Gulf/Emirati Arabic voice benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/vadimbelsky/emirati-vits-male-1.0",
        hardware="GPU/NeMo runtime; 22.05 kHz VITS voice",
        why="Apache-2.0 bilingual Emirati Arabic/English VITS voice that may be useful for Gulf dialect material, but dialectal tuning makes it a comparison candidate rather than the default MSA book voice.",
        next_step="Benchmark only when the target PDF benefits from Emirati/Gulf pronunciation; keep SILMA/Habibi ahead for MSA books unless listening tests say otherwise.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="VoxCPM2",
        kind="tts",
        role="strong-worker multilingual voice watchlist",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/openbmb/VoxCPM2",
        hardware="GPU/large worker; 2B model, about 8GB VRAM guidance",
        why="Apache-2.0 multilingual TTS with Arabic support, 48 kHz output, and voice design/cloning.",
        next_step="Benchmark externally with the same cleaned Arabic sample before deciding whether it is worth integrating.",
        command="python scripts\\dry_run_pdf.py C:\\path\\to\\arabic-book.pdf --include-speech-text --speech-sample-chars 1200",
    ),
    Candidate(
        name="Voxtral TTS",
        kind="tts",
        role="non-commercial Arabic-capable strong-worker voice watchlist",
        status="not default; non-commercial and GPU-heavy",
        license="CC-BY-NC-4.0",
        source="https://huggingface.co/mistralai/Voxtral-4B-TTS-2603",
        hardware="GPU/large worker; 4B BF16 model, 16GB+ GPU guidance",
        why="Mistral's open-weight TTS model lists Arabic among 9 supported languages and has strong latency/quality claims, but the model card says it inherits CC-BY-NC-4.0 and recommends a large GPU setup.",
        next_step="Benchmark only as a personal/non-commercial strong-worker comparison using the same cleaned Arabic sample; do not wire it as the default public/free website voice.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="OmniVoice",
        kind="tts",
        role="priority permissive strong-worker voice benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/k2-fsa/OmniVoice",
        hardware="GPU/large worker; 0.6B model",
        why="Apache-2.0 zero-shot TTS with 646-language coverage, Arabic included, high current usage, and published 2026 OmniVoice evidence; benchmark it before heavier or license-unclear voices when a stronger worker is available.",
        next_step="Export the same cleaned Arabic text used for SILMA/Habibi and compare Arabic naturalness, speed, and setup complexity before wiring it into the app.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="OmniVoice Arabic LoRA",
        kind="tts",
        role="Arabic adapter for OmniVoice benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/vivooglobal/omnivoice-lora-ar",
        hardware="GPU/large worker; OmniVoice plus LoRA adapter",
        why="Arabic LoRA adapter for OmniVoice intended to improve zero-shot Arabic voice cloning quality.",
        next_step="Benchmark only after the base OmniVoice command is working, using the exact same cleaned Arabic sample and reference audio.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Arabic-text-to-speech OmniVoice",
        kind="tts",
        role="Arabic-focused OmniVoice packaging benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/bilalRHCH/Arabic-text-to-speech",
        hardware="GPU/large worker; OmniVoice 0.6B packaging with Arabic-focused model card",
        why="Apache-2.0 Arabic-labeled OmniVoice package with 646-language OmniVoice support and a demo Space signal; useful as a same-sample Arabic voice benchmark, but still not proven for long MSA audiobook passages.",
        next_step="Export the same cleaned Arabic sample used for SILMA/Habibi and compare naturalness, skipped words, repetition, runtime, and setup complexity before any app wiring.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Lahgtna OmniVoice v2",
        kind="tts",
        role="Arabic dialect OmniVoice benchmark",
        status="not wired; benchmark externally first",
        license="license not declared on model card",
        source="https://huggingface.co/oddadmix/lahgtna-omnivoice-v2",
        hardware="GPU/large worker; OmniVoice 0.6B fine-tune",
        why="New Arabic dialect TTS model based on OmniVoice, with broad Arabic dialect tags and diacritics support; promising for conversational dialect audio but not the MSA book default.",
        next_step="Benchmark externally only when dialect pronunciation matters, confirm licensing before production, and keep SILMA/Habibi ahead for MSA books until listening tests prove otherwise.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="TADA multilingual TTS",
        kind="tts",
        role="strong-worker off-script-resistant voice benchmark",
        status="not default; Llama 3.2 license and GPU-heavy",
        license="Llama 3.2 license",
        source="https://huggingface.co/HumeAI/tada-3b-ml",
        hardware="GPU/large worker; 3B-class multilingual model plus language aligners",
        why="Free/open-weight multilingual TTS with Arabic support and a text-acoustic alignment design meant to reduce skipped or invented words, which matters for long book narration, but its Hugging Face metadata reports the Llama 3.2 license rather than Apache-2.0.",
        next_step="Export the same cleaned Arabic sample and benchmark with language='ar' only if the Llama 3.2 license is acceptable; keep SILMA/Habibi ahead for the permissive default.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Lahgtna Chatterbox",
        kind="tts",
        role="Arabic dialect TTS benchmark",
        status="not wired; benchmark externally first",
        license="MIT",
        source="https://huggingface.co/oddadmix/lahgtna-chatterbox-v1",
        hardware="GPU recommended; Chatterbox multilingual base",
        why="MIT Arabic dialect TTS model covering multiple dialect tags; promising when conversational dialect pronunciation matters more than MSA audiobook narration.",
        next_step="Export the same cleaned Arabic text and listen for repetition/stability before considering app wiring.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="NAMAA-Saudi-TTS",
        kind="tts",
        role="Saudi Arabic Chatterbox dialect benchmark",
        status="not wired; benchmark externally first",
        license="MIT",
        source="https://huggingface.co/NAMAA-Space/NAMAA-Saudi-TTS",
        hardware="GPU recommended; 0.5B Chatterbox Multilingual fine-tune",
        why="MIT-licensed Saudi Arabic TTS model built on Chatterbox Multilingual; useful for Saudi/Gulf dialect material, but its model card says it targets everyday Saudi speech rather than MSA books.",
        next_step="Benchmark only when Saudi dialect pronunciation fits the target PDF; keep SILMA/Habibi first for MSA books and compare against Saudi Arabic Qwen3-TTS and Emirati voices before wiring.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="NAMAA-Egyptian-TTS",
        kind="tts",
        role="Egyptian Arabic Chatterbox dialect benchmark",
        status="not wired; benchmark externally first",
        license="MIT",
        source="https://huggingface.co/NAMAA-Space/NAMAA-Egyptian-TTS",
        hardware="GPU recommended; 0.5B Chatterbox Multilingual fine-tune",
        why="MIT-licensed NAMAA Egyptian Arabic TTS model built on Chatterbox Multilingual with local/hosted inference examples and a live demo, but its card says it targets everyday Egyptian speech rather than MSA books and notes number/pronunciation limitations.",
        next_step="Benchmark only for Egyptian/dialectal PDFs using the same cleaned Arabic sample; keep SILMA/Habibi first for MSA books and compare against Egyptian Arabic Chatterbox, NileTTS-XTTS, and Egyptian Arabic Qwen3-TTS before any wiring.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Saudi Chatterbox fine-tune",
        kind="tts",
        role="Saudi Arabic Chatterbox dialect benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/FatimahEmadEldin/saudi-tts-chatterbox-finetuned",
        hardware="GPU recommended; Chatterbox Multilingual T3 fine-tune",
        why="Apache-2.0 Saudi Arabic Chatterbox Multilingual fine-tune trained on Saudi podcast and number-normalized speech data; useful as a same-family comparison against NAMAA-Saudi-TTS.",
        next_step="Benchmark only for Saudi/Gulf dialect fit using the same cleaned Arabic sample; keep SILMA/Habibi first for MSA books and compare against NAMAA-Saudi-TTS, Saudi Qwen3-TTS, and Emirati voices before wiring.",
        command=(
            "python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf "
            "--env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample\n"
            "python -c \"# Load ChatterboxMultilingualTTS, apply FatimahEmadEldin/saudi-tts-chatterbox-finetuned "
            "T3 weights, synthesize outputs\\external-tts-sample\\arabic-tts-sample.txt, language_id='ar'\""
        ),
    ),
    Candidate(
        name="Saudi TTS",
        kind="tts",
        role="Saudi Arabic dialect TTS benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/AhmedEladl/saudi-tts",
        hardware="GPU/worker benchmark; model card has demo Spaces but no inference-provider deployment",
        why=(
            "Apache-2.0 high-quality Saudi Arabic dialect voice candidate. It may be useful for Gulf/Saudi "
            "material, but it is dialect-specific and not a proven MSA audiobook voice."
        ),
        next_step=(
            "Benchmark beside NAMAA-Saudi-TTS, Saudi Chatterbox fine-tune, Saudi Arabic Qwen3-TTS, "
            "and SILMA/Habibi on the same cleaned Arabic sample before any app wiring."
        ),
        command=(
            "python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf "
            "--env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample"
        ),
    ),
    Candidate(
        name="Egyptian Arabic Chatterbox",
        kind="tts",
        role="Egyptian Arabic dialect Chatterbox benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/AliAbdallah/egyptian-arabic-tts-chatterbox",
        hardware="GPU recommended; Chatterbox Multilingual fine-tune",
        why="Apache-2.0 Egyptian Arabic Chatterbox fine-tune with 120 hours of clean Egyptian Arabic training data; useful for Egyptian dialect content, but not a general MSA book voice and the model card says GPU is needed for real-time inference.",
        next_step="Benchmark only for Egyptian/dialectal PDFs using the same cleaned Arabic sample; keep SILMA/Habibi first for MSA books unless listening tests clearly favor the dialect voice for that text.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="NileTTS-XTTS",
        kind="tts",
        role="Egyptian Arabic XTTS benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/KickItLikeShika/NileTTS-XTTS",
        hardware="GPU recommended; XTTS v2 fine-tune",
        why="Apache-2.0 Egyptian Arabic XTTS fine-tune from the 2026 NileTTS work; useful for Egyptian dialect content, but not a general MSA book voice.",
        next_step="Benchmark only for Egyptian/dialectal PDFs using the same cleaned Arabic sample; keep SILMA/Habibi first for MSA books unless listening tests clearly favor this dialect voice.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Arabic XTTS-v2 Egyptian fine-tune",
        kind="tts",
        role="Egyptian Arabic XTTS voice-quality benchmark",
        status="not wired; benchmark externally first",
        license="MIT project; XTTS-v2 base uses Coqui Public Model License",
        source="https://huggingface.co/Moeeldouma/arabic-tts-xtts-v2",
        hardware="GPU recommended; XTTS-v2 fine-tune and voice-cloning runtime",
        why="Recent Arabic XTTS-v2 improvement project with Egyptian speaker fine-tuning and documented same-text comparisons. It is worth a listening benchmark for dialectal material, but the XTTS-v2 base license and voice-cloning setup keep it out of the permissive default path.",
        next_step="Benchmark externally only for Egyptian/dialectal PDFs, confirm CPML fit for the intended personal use, and compare long-form stability against SILMA/Habibi/NileTTS-XTTS on the exact same cleaned text.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Chatterbox-Multilingual",
        kind="tts",
        role="MIT Arabic-capable multilingual TTS benchmark",
        status="not wired; benchmark externally first",
        license="MIT",
        source="https://github.com/resemble-ai/chatterbox",
        hardware="GPU recommended; multilingual TTS/voice cloning",
        why="MIT-licensed Chatterbox-Multilingual lists Arabic among 23 supported languages and has local generation examples, making it a strong free Arabic voice benchmark candidate.",
        next_step="Export the same cleaned Arabic text used for SILMA/Habibi and compare naturalness, pacing, watermarking, and setup complexity before wiring it into the app.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Chatterbox Arabic fine-tune",
        kind="tts",
        role="MSA-focused Chatterbox Arabic adapter benchmark",
        status="not wired; benchmark externally first",
        license="MIT",
        source="https://huggingface.co/juliardi/chatterbox-multilingual-finetuned-arabic",
        hardware="GPU recommended; Chatterbox Multilingual LoRA/adapter",
        why="MIT Chatterbox Arabic fine-tune claims improved Arabic pronunciation, diacritics, intonation, MSA support, and common dialect support, making it worth a same-text listening test against SILMA/Habibi before any app wiring.",
        next_step="Export the same cleaned Arabic sample used for SILMA/Habibi and compare MSA pronunciation, skipped words, repetition, long-sentence stability, and runtime; keep it benchmark-only until it wins human listening tests.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Chatterbox-Multilingual ONNX",
        kind="tts",
        role="CPU/ONNX Arabic-capable voice benchmark",
        status="not wired; benchmark externally first",
        license="MIT",
        source="https://huggingface.co/onnx-community/chatterbox-multilingual-ONNX",
        hardware="CPU/ONNX-capable worker; multilingual Chatterbox runtime",
        why="MIT ONNX packaging for Chatterbox-Multilingual with Arabic included in the supported language list. It may be easier to benchmark on CPU-style free workers than heavier GPU voice models.",
        next_step="Export the same cleaned Arabic text used for SILMA/Habibi and compare ONNX Chatterbox naturalness, repetition, pacing, pronunciation, and runtime before any app wiring.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Spark-TTS Arabic",
        kind="tts",
        role="classical Arabic voice-cloning benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/azeddinShr/Spark-TTS-Arabic-Complete",
        hardware="GPU/large worker; Spark-TTS repo required",
        why="Apache-2.0 Arabic fine-tune of Spark-TTS on ClArTTS, aimed at Classical/MSA narration, but the model card says non-diacritized input is out of scope and the Spark-TTS repo is required.",
        next_step="Benchmark externally only with diacritized text/reference audio, then compare listenability and setup complexity against SILMA and Habibi.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Sofelia-TTS",
        kind="tts",
        role="Palestinian Arabic dialect voice benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/hamdallah/Sofelia-TTS",
        hardware="GPU/large worker; MiraTTS runtime",
        why="Apache-2.0 Palestinian Arabic TTS/voice-cloning model that may be useful for dialectal content, but it is not a standard MSA audiobook voice and its training data is private.",
        next_step="Benchmark externally only if the target text is Palestinian/dialectal Arabic; keep SILMA/Habibi ahead for MSA books.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Arabic-F5-TTS-v2",
        kind="tts",
        role="personal/non-commercial MSA voice caution",
        status="not default; non-commercial and requires tashkeel",
        license="fair non-commercial research license",
        source="https://huggingface.co/IbrahimSalah/Arabic-F5-TTS-v2",
        hardware="GPU recommended; F5-TTS fine-tune",
        why="Arabic MSA voice candidate with strong sample claims, but it requires fully diacritized Arabic and is not permissive enough for a default public website.",
        next_step="Use only for personal listening tests unless the license is acceptable; do not wire as the default free permissive app voice.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="MOSS-TTS-Nano",
        kind="tts",
        role="CPU-friendly multilingual voice watchlist",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://github.com/OpenMOSS/MOSS-TTS-Nano",
        hardware="CPU-friendly 0.1B model; ONNX path available",
        why="Supports Arabic among 20 languages and has a lightweight ONNX CPU inference path, making it promising for a free worker if Arabic quality beats SILMA/Habibi.",
        next_step="Export a cleaned Arabic sample, run the ONNX CLI with an Arabic reference voice, then compare listenability and runtime against SILMA on the same text.",
        command="python scripts\\dry_run_pdf.py C:\\path\\to\\arabic-book.pdf --include-speech-text --speech-sample-chars 1200",
    ),
    Candidate(
        name="tts-arabic-onnx",
        kind="tts",
        role="compact Arabic-only ONNX voice benchmark",
        status="not wired; benchmark externally first",
        license="license not declared on model card/repo; confirm before production",
        source="https://huggingface.co/nipponjo/tts-arabic-onnx",
        hardware="CPU/ONNX-capable worker; small FastPitch/MixerTTS plus vocoder models",
        why="Arabic-only ONNX package with FastPitch, tiny MixerTTS models, HiFi-GAN/Vocos vocoders, speaker and pace controls, and offline Python examples. It is promising for free CPU benchmarking, but license clarity must be resolved before production use.",
        next_step="Export the same cleaned Arabic sample and benchmark FastPitch, MixerTTS, speaker IDs, pace, and vowelizer options against SILMA, Supertonic, MOSS-TTS-Nano, and Chatterbox ONNX before any app wiring.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Supertonic 3",
        kind="tts",
        role="wired optional fast CPU Arabic-capable voice",
        status="wired optional sidecar",
        license="OpenRAIL model, MIT sample code",
        source="https://huggingface.co/Supertone/supertonic-3",
        hardware="CPU-only ONNX; 99M model assets",
        why="Supertonic 3 supports Arabic, runs locally with ONNX on CPU, and is much smaller than GPU-class multilingual voices, making it a practical free benchmark voice for long-book workers.",
        next_step="Install the sidecar with scripts/setup_supertonic.ps1 or build with INSTALL_SUPERTONIC=1, then benchmark it against SILMA/Habibi on the same cleaned Arabic text.",
        command="python scripts\\benchmark_voices.py --voices silma-local habibi-msa supertonic-ar espeak-ar-clear --text-file outputs\\external-tts-sample\\arabic-tts-sample.txt --out-dir outputs\\voice-benchmark --write-report outputs\\voice-benchmark-report.md",
    ),
    Candidate(
        name="Qwen3-TTS",
        kind="tts",
        role="strong open TTS to not promote for Arabic yet",
        status="not Arabic-ready for this app",
        license="Apache-2.0",
        source="https://huggingface.co/Qwen/Qwen3-TTS-12Hz-1.7B-Base",
        hardware="GPU/large worker; 0.6B or 1.7B models",
        why="Official Qwen3-TTS sources are strong and Apache-2.0, but the released model cards list 10 languages and do not include Arabic.",
        next_step="Do not add it to the Arabic voice dropdown until an official Arabic-capable checkpoint or Arabic fine-tune is verified.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Saudi Arabic Qwen3-TTS",
        kind="tts",
        role="Saudi/KSA Arabic dialect voice benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/vadimbelsky/qwen3-TTS-KSA",
        hardware="GPU/large worker; Qwen3-TTS 1.7B fine-tune",
        why="Apache-2.0 Qwen3-TTS fine-tune for Saudi/KSA Arabic speech; useful when the target text should sound Gulf/Saudi rather than MSA audiobook narration.",
        next_step="Benchmark only for Saudi/KSA dialect fit using the same cleaned Arabic text as SILMA/Habibi, then keep it external unless it wins listening tests and the worker can handle 1.7B-class runtime.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
    Candidate(
        name="Emirati Qwen3.5-TTS",
        kind="tts",
        role="Emirati/Gulf Qwen voice benchmark",
        status="not wired; benchmark externally first",
        license="Apache-2.0",
        source="https://huggingface.co/vadimbelsky/qwen3.5-TTS-Emirati",
        hardware="GPU/large worker; Qwen3-TTS fine-tune",
        why="Apache-2.0 Qwen3-TTS-family Emirati Arabic fine-tune; a newer dialect benchmark beside the smaller Emirati VITS voice.",
        next_step="Benchmark only when Gulf/Emirati pronunciation is desired; keep SILMA/Habibi first for MSA books and compare against Emirati VITS Male before wiring anything.",
        command="python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf --env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample",
    ),
]


def candidates_by_kind(kind: str | None = None) -> list[Candidate]:
    if not kind:
        return list(CANDIDATES)
    return [candidate for candidate in CANDIDATES if candidate.kind == kind]


def score_json_path(kind: str) -> str:
    if kind == "ocr":
        return "outputs\\external-ocr-sample\\external-ocr-score.json"
    if kind == "preprocessor":
        return "outputs\\external-tts-sample\\tts-preprocessor-score.json"
    return "outputs\\external-tts-sample\\voice-listening-score.json"


def score_report_path(kind: str) -> str:
    if kind == "ocr":
        return "outputs\\external-ocr-sample\\external-ocr-score.md"
    if kind == "preprocessor":
        return "outputs\\external-tts-sample\\tts-preprocessor-score.md"
    return "outputs\\external-tts-sample\\voice-listening-score.md"


def promotion_report_path(kind: str) -> str:
    if kind == "ocr":
        return "outputs\\external-ocr-sample\\model-promotion-gate.md"
    if kind == "preprocessor":
        return "outputs\\external-tts-sample\\preprocessor-promotion-gate.md"
    return "outputs\\external-tts-sample\\voice-promotion-gate.md"


def gate_kind(candidate: Candidate) -> str:
    role = candidate.role.lower()
    if candidate.kind == "tts" and "preprocessor" in role:
        return "preprocessor"
    return candidate.kind


def command_with_score_json(command: str, kind: str) -> str:
    lines: list[str] = []
    for line in command.splitlines():
        updated = line
        if "score_external_ocr.py" in updated and "--write-json" not in updated:
            updated += f" --write-json {score_json_path('ocr')}"
        if "score_voice_listening.py" in updated and "--write-json" not in updated:
            updated += f" --write-json {score_json_path('tts')}"
        if "score_tts_preprocessor.py" in updated and "--write-json" not in updated:
            updated += f" --write-json {score_json_path('preprocessor')}"
        lines.append(updated)
    return "\n".join(lines)


def voice_score_command() -> str:
    return (
        "python scripts\\score_voice_listening.py "
        "--rating silma-local=5,4,4,5,5 --rating candidate=5,5,5,5,5 "
        f"--write-report {score_report_path('tts')} --write-json {score_json_path('tts')}"
    )


def preprocessor_score_command() -> str:
    return (
        "python scripts\\score_tts_preprocessor.py "
        "--rating plain=4,5,5,4,4 --rating candidate=5,5,5,5,5 "
        f"--write-report {score_report_path('preprocessor')} --write-json {score_json_path('preprocessor')}"
    )


def candidate_slug(name: str) -> str:
    slug = re.sub(r"[^a-z0-9]+", "-", name.lower()).strip("-")
    return slug or "candidate"


def ocr_score_command(candidate: Candidate) -> str:
    slug = candidate_slug(candidate.name)
    return (
        "python scripts\\score_external_ocr.py "
        f"--candidate {slug}=outputs\\external-ocr-sample\\{slug}.txt "
        "--baseline-json outputs\\external-ocr-sample\\wired-ocr-baseline.json "
        f"--write-report {score_report_path('ocr')} --write-json {score_json_path('ocr')}"
    )


def promotion_gate_command(candidate: Candidate) -> str:
    kind = gate_kind(candidate)
    return (
        "python scripts\\model_promotion_gate.py "
        f"--candidate-name \"{candidate.name}\" --kind {kind} --license \"{candidate.license}\" "
        f"--score-json {score_json_path(kind)} "
        "--same-sample --runtime-ok --privacy-ok --human-reviewed "
        f"--write-report {promotion_report_path(kind)}"
    )


def benchmark_command(candidate: Candidate) -> str:
    command = command_with_score_json(candidate.command, gate_kind(candidate))
    needs_gate = not is_production_default_safe(candidate) and "not Arabic-ready" not in candidate.status
    if not needs_gate:
        return command
    if "model_promotion_gate.py" in command:
        return command
    if candidate.kind == "ocr" and "score_external_ocr.py" not in command:
        command = f"{command}\n{ocr_score_command(candidate)}"
    if candidate.kind == "tts" and "score_voice_listening.py" not in command and "score_tts_preprocessor.py" not in command:
        if gate_kind(candidate) == "preprocessor":
            command = f"{command}\n{preprocessor_score_command()}"
        else:
            command = f"{command}\n{voice_score_command()}"
    return f"{command}\n{promotion_gate_command(candidate)}"


def build_report(candidates: list[Candidate]) -> str:
    lines = [
        "# Free Arabic OCR/TTS Research Watchlist",
        "",
        "Use this file to evaluate new free models without changing the production default first.",
        "A candidate should become a default only after it wins on a representative Arabic book sample and produces listenable audio.",
        "License policy: production/default entries must use a permissive or explicitly acceptable license; uncertain, non-commercial, Llama-licensed, and correction-risk entries stay benchmark-only until reviewed.",
        "",
        "| Candidate | Type | Role | Status | License | Hardware | Source |",
        "| --- | --- | --- | --- | --- | --- | --- |",
    ]
    for item in candidates:
        lines.append(
            f"| {item.name} | {item.kind} | {item.role} | {item.status} | "
            f"{item.license} | {item.hardware} | {item.source} |"
        )
    lines.extend(["", "## Benchmark Steps", ""])
    for item in candidates:
        lines.extend(
            [
                f"### {item.name}",
                "",
                f"Why: {item.why}",
                "",
                f"Next step: {item.next_step}",
                "",
                "```powershell",
                benchmark_command(item),
                "```",
                "",
            ]
        )
    return "\n".join(lines).rstrip() + "\n"


def names_by_status(candidates: list[Candidate], status: str) -> list[Candidate]:
    return [candidate for candidate in candidates if candidate.status == status]


def benchmark_candidates(candidates: list[Candidate], kind: str) -> list[Candidate]:
    return [
        candidate
        for candidate in candidates
        if candidate.kind == kind and not is_production_default_safe(candidate) and "not Arabic-ready" not in candidate.status
    ]


def build_recommendation_report(candidates: list[Candidate]) -> str:
    default_voice = next(candidate for candidate in candidates if candidate.name == "SILMA TTS")
    optional_ocr = [candidate for candidate in names_by_status(candidates, "wired optional sidecar") if candidate.kind == "ocr"]
    optional_tts = [candidate for candidate in names_by_status(candidates, "wired optional sidecar") if candidate.kind == "tts"]
    ocr_benchmarks = benchmark_candidates(candidates, "ocr")[:12]
    tts_benchmarks = benchmark_candidates(candidates, "tts")[:16]

    lines = [
        "# Recommended Free Arabic PDF To Audio Stack",
        "",
        "This is the compact decision report generated from the current research watchlist.",
        "",
        "## Use Now",
        "",
        "| Layer | Recommendation | Why |",
        "| --- | --- | --- |",
        "| Embedded PDFs | PyMuPDF text extraction first | It is free, fast, and avoids OCR errors when the PDF already contains usable Arabic text. |",
        "| Scanned PDFs | `OCR_ENGINE=tesseract OCR_RENDER_ZOOM=2 TESSERACT_PSM=4` | It produced the most readable text on the 5-page Arabic OCR benchmark while staying much faster than the comparison modes. |",
        f"| Default voice | {default_voice.name} | {default_voice.why} |",
        "| Download/storage | Worker-local retained audio files | Free by default and avoids Vercel's 4.5 MB function payload limit; Hugging Face free CPU disk is 50 GB but non-persistent, so downloads are short-lived. |",
        "| Hosted shape | Vercel shell plus Docker worker via `WORKER_BASE_URL` | Vercel serves the easy website while the worker handles large PDFs, OCR, and TTS on free CPU Space hardware when the job size is reasonable. |",
        "",
        "## Install First On A Stronger Worker",
        "",
        "| Candidate | Type | Why | Next Step |",
        "| --- | --- | --- | --- |",
    ]
    for candidate in optional_ocr + optional_tts:
        lines.append(f"| {candidate.name} | {candidate.kind} | {candidate.why} | {candidate.next_step} |")

    lines.extend(
        [
            "",
            "## Benchmark Before Promoting",
            "",
            "These are promising free/open candidates, but they should not replace the default stack until they win on the same 5-page Arabic sample and same cleaned TTS text.",
            "",
            "### OCR",
            "",
            "| Candidate | License | Why It Stays Benchmark-Only |",
            "| --- | --- | --- |",
        ]
    )
    for candidate in ocr_benchmarks:
        lines.append(f"| {candidate.name} | {candidate.license} | {candidate.next_step} |")

    lines.extend(["", "### TTS", "", "| Candidate | License | Why It Stays Benchmark-Only |", "| --- | --- | --- |"])
    for candidate in tts_benchmarks:
        lines.append(f"| {candidate.name} | {candidate.license} | {candidate.next_step} |")

    lines.extend(
        [
            "",
            "### Current Voice Priority",
            "",
            "Use SILMA first for the practical free Arabic audiobook voice. On a stronger worker, benchmark Habibi MSA and OmniVoice next. Keep KaniTTS benchmark-only until the `lfm1.0` Hugging Face license metadata is reconciled with the model-card Apache-2.0 text.",
        ]
    )

    lines.extend(
        [
            "",
            "## Promotion Rule",
            "",
            "Promote a model only when all of these are true:",
            "",
            "1. It is free for the intended personal/family use.",
            "2. Its license is acceptable for the deployment.",
            "3. It beats the current stack on the same selected Arabic pages or same cleaned Arabic voice sample.",
            "4. It preserves Arabic reading order, words, and pronunciation better than the default.",
            "5. Its runtime is acceptable for the target worker.",
            "6. The generated JSON score passes `scripts\\model_promotion_gate.py` after human review.",
            "",
            "Current practical default: PyMuPDF -> `tesseract@2x-psm4` OCR -> SILMA TTS -> downloadable worker audio.",
            "",
        ]
    )
    return "\n".join(lines)


def build_decision_card(candidates: list[Candidate]) -> dict[str, object]:
    optional_sidecars = [
        candidate
        for candidate in candidates
        if candidate.status == "wired optional sidecar"
    ]
    benchmark_ocr = benchmark_candidates(candidates, "ocr")
    benchmark_tts = benchmark_candidates(candidates, "tts")
    return {
        "title": "Recommended Free Arabic PDF To Audio Decision Card",
        "currentDefault": {
            "pdf": "PyMuPDF embedded text first",
            "scannedPdfOcr": "OCR_ENGINE=tesseract OCR_RENDER_ZOOM=2 TESSERACT_PSM=4",
            "voice": "SILMA TTS (silma-local)",
            "audioStorage": "worker-local retained downloads",
            "hosting": "Vercel shell plus Docker worker via WORKER_BASE_URL",
        },
        "whyThisDefault": [
            "Uses free/local software by default instead of paid cloud TTS.",
            "Avoids OCR when embedded Arabic text already exists.",
            "Uses Arabic-trained OCR sidecars when available and keeps Tesseract/PaddleOCR fallbacks.",
            "Uses an Arabic-focused Apache-2.0 voice first, with eSpeak NG only as a fallback.",
            "Keeps large PDF and audio work off Vercel Functions by delegating to the worker.",
        ],
        "installFirstOnStrongerWorker": [
            {
                "name": candidate.name,
                "kind": candidate.kind,
                "license": candidate.license,
                "why": candidate.why,
                "nextStep": candidate.next_step,
            }
            for candidate in optional_sidecars
        ],
        "benchmarkBeforePromoting": {
            "ocrCount": len(benchmark_ocr),
            "ttsCount": len(benchmark_tts),
            "ocrFirst": [candidate.name for candidate in benchmark_ocr[:12]],
            "ttsFirst": [candidate.name for candidate in benchmark_tts[:16]],
            "voicePriority": "Use SILMA first, then benchmark Habibi MSA and OmniVoice on stronger hardware. Keep KaniTTS benchmark-only until its lfm1.0 Hugging Face license metadata is reconciled with the model-card Apache-2.0 text.",
        },
        "promotionGate": {
            "sameSample": "same selected Arabic pages or same cleaned Arabic TTS text",
            "scoreJsonRequired": True,
            "tool": "scripts\\model_promotion_gate.py",
            "requires": [
                "candidate beats the current stack",
                "license is acceptable for the deployment",
                "worker runtime and memory are acceptable",
                "privacy/API terms are clear",
                "human Arabic review confirms faithful text/audio",
            ],
        },
        "commands": {
            "refreshResearch": (
                "python scripts\\refresh_research_evidence.py "
                "--watchlist-report docs\\research-watchlist.md "
                "--recommendation-report docs\\recommended-free-stack.md"
            ),
            "sourceAudit": "python scripts\\check_research_sources.py --json",
            "prepareBook": (
                "python scripts\\prepare_book_workflow.py C:\\path\\to\\arabic-book.pdf "
                "--sample-pages 1 --engine-preset balanced --verify-audio "
                "--write-env outputs\\recommended-ocr.env --write-report outputs\\book-prep-report.md"
            ),
            "externalOcrSample": (
                "python scripts\\export_ocr_sample_images.py C:\\path\\to\\arabic-book.pdf "
                "--out-dir outputs\\external-ocr-sample"
            ),
            "externalTtsSample": (
                "python scripts\\export_tts_sample.py C:\\path\\to\\arabic-book.pdf "
                "--env-file outputs\\recommended-ocr.env --out-dir outputs\\external-tts-sample"
            ),
        },
    }


def build_decision_card_report(card: dict[str, object]) -> str:
    current = card["currentDefault"]  # type: ignore[index]
    promotion = card["promotionGate"]  # type: ignore[index]
    benchmarks = card["benchmarkBeforePromoting"]  # type: ignore[index]
    commands = card["commands"]  # type: ignore[index]
    lines = [
        "# Recommended Free Arabic PDF To Audio Decision Card",
        "",
        "## Current Default",
        "",
        "| Layer | Choice |",
        "| --- | --- |",
    ]
    for key, value in dict(current).items():
        lines.append(f"| {key} | {value} |")
    lines.extend(["", "## Why", ""])
    for reason in card["whyThisDefault"]:  # type: ignore[index]
        lines.append(f"- {reason}")
    lines.extend(
        [
            "",
            "## Benchmark Queue",
            "",
            f"OCR benchmark candidates tracked: {dict(benchmarks)['ocrCount']}",
            f"TTS benchmark candidates tracked: {dict(benchmarks)['ttsCount']}",
            "",
            "OCR first lane: " + ", ".join(dict(benchmarks)["ocrFirst"]),  # type: ignore[arg-type]
            "TTS first lane: " + ", ".join(dict(benchmarks)["ttsFirst"]),  # type: ignore[arg-type]
            "",
            "## Promotion Gate",
            "",
            f"Tool: `{dict(promotion)['tool']}`",
            f"Same sample: {dict(promotion)['sameSample']}",
            "",
        ]
    )
    for item in dict(promotion)["requires"]:  # type: ignore[index]
        lines.append(f"- {item}")
    lines.extend(["", "## Commands", ""])
    for label, command in dict(commands).items():
        lines.extend([f"{label}:", "", "```powershell", str(command), "```", ""])
    return "\n".join(lines).rstrip() + "\n"


def write_report(path: Path, candidates: list[Candidate]) -> None:
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(build_report(candidates), encoding="utf-8")


def write_recommendation_report(path: Path, candidates: list[Candidate]) -> None:
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(build_recommendation_report(candidates), encoding="utf-8")


def write_decision_card_json(path: Path, candidates: list[Candidate]) -> None:
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(json.dumps(build_decision_card(candidates), ensure_ascii=False, indent=2) + "\n", encoding="utf-8")


def write_decision_card_report(path: Path, candidates: list[Candidate]) -> None:
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(build_decision_card_report(build_decision_card(candidates)), encoding="utf-8")


def main() -> None:
    parser = argparse.ArgumentParser(description="Print or write the free Arabic OCR/TTS research watchlist.")
    parser.add_argument("--kind", choices=["ocr", "tts"], help="Show only OCR or TTS candidates.")
    parser.add_argument("--write-report", type=Path, default=DEFAULT_REPORT, help="Markdown report destination.")
    parser.add_argument(
        "--write-recommendation-report",
        type=Path,
        help="Write a compact recommended-stack decision report.",
    )
    parser.add_argument("--write-decision-card-json", type=Path, help="Write a machine-readable recommendation card.")
    parser.add_argument("--write-decision-card-report", type=Path, help="Write a readable recommendation card.")
    parser.add_argument("--json", action="store_true", help="Print JSON instead of Markdown.")
    parser.add_argument("--check-license-policy", action="store_true", help="Fail if default-safe and benchmark-only license lanes are mixed.")
    args = parser.parse_args()

    selected = candidates_by_kind(args.kind)
    violations = license_policy_violations(selected)
    if args.check_license_policy and violations:
        print(json.dumps({"ready": False, "violations": violations}, ensure_ascii=False, indent=2))
        raise SystemExit(1)
    if args.json:
        print(
            json.dumps(
                {
                    "ready": not violations,
                    "violations": violations,
                    "candidates": [
                        {**asdict(candidate), "command": benchmark_command(candidate)} for candidate in selected
                    ],
                },
                ensure_ascii=False,
                indent=2,
            )
        )
        return
    write_report(args.write_report, selected)
    if args.write_recommendation_report:
        write_recommendation_report(args.write_recommendation_report, selected)
    if args.write_decision_card_json:
        write_decision_card_json(args.write_decision_card_json, selected)
    if args.write_decision_card_report:
        write_decision_card_report(args.write_decision_card_report, selected)
    print(f"Wrote {args.write_report}")
    if args.write_recommendation_report:
        print(f"Wrote {args.write_recommendation_report}")
    if args.write_decision_card_json:
        print(f"Wrote {args.write_decision_card_json}")
    if args.write_decision_card_report:
        print(f"Wrote {args.write_decision_card_report}")


if __name__ == "__main__":
    main()