1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use BTreeMap;
use env;
use fs;
use Path;
use PathBuf;
use BlockingMode;
use MountInfoRootRewrite;
use Command;
use Deserialize;
use Serialize;
use crateMETADATA_NAME;
use crateContext;
use crateError;
/// Hermit record version. Recorded as part of hermit-record, hermit-replay
/// will check this version and will fail if hermit-record version is newer.
;
/// hermit record/replay version.
// NB: Increase the version number when there are breaking changes, i.e.:
// when new syscalls or event schemas are added.
//
// AUTONOMOUS-BOT-IMPLEMENTED
// TODO-HUMAN-REVIEW(#2373)
// 0x10b -> 0x10c: flock(2) stopped being a Detcore no-op and now reaches
// `record_or_replay`, so a post-fix run emits a `Return` event per flock call.
// Replay re-issues calls for materialized descriptors and fails closed when it
// cannot reproduce the lock side effect. A 0x10b recording contains NO flock
// event at all -- the old handler returned Ok(0) before ever reaching the
// recorder, even though flock was already classified Determinized -- so
// replaying one under this build would read the next thread event for every
// flock and desynchronize the stream. The version gate must refuse it.
//
// TODO-HUMAN-REVIEW(#2370)
// 0x10d -> 0x10e: record/replay now carries successful exec image/path state and
// an explicit ppoll timeout-pointer shape. Older readers cannot interpret those
// events without desynchronizing the stream, so the format advances once.
//
// TODO-HUMAN-REVIEW(#2272)
// 0x10c -> 0x10d: `Ppoll` becomes its OWN event rather than sharing `Poll`'s,
// because ppoll additionally copies out a timeout and must preserve it on
// EINTR and on a partial EFAULT copy-out; and `Poll` itself now records the
// partial `revents` copy-out an error return leaves behind. The recorded
// stream therefore carries a different event shape for both syscalls.
//
// ONE increment covers BOTH halves deliberately. This branch bumped twice --
// once per format change -- but a reader either understands the new stream or
// it does not, so what matters is that the version differs from every stream
// a different shape was written under. Landing two increments would imply a
// 0x10d recording exists that this build can read and it cannot: no build
// ever wrote one.
//
// ⚠️ THIS BUMP IS WHY THE REBASE COULD NOT SIMPLY TAKE EITHER SIDE. This
// change was authored against 0x10a and bumped to 0x10b; main has since gone
// to 0x10c for the unrelated flock work. Keeping the branch's 0x10b would
// move the version BACKWARDS and let a 0x10c flock recording be replayed by a
// build whose ppoll events have a different shape. Keeping main's 0x10c
// unchanged would be worse: the format would change with no bump at all, so a
// recording made here would claim 0x10c while containing a `Ppoll` event the
// 0x10c reader does not know -- exactly the desynchronization the paragraph
// above exists to prevent. The version must go FORWARD once more.
//
// AUTONOMOUS-BOT-IMPLEMENTED
// TODO-HUMAN-REVIEW(#2407)
// 0x10e -> 0x10f: pidfd_getfd(2) is now explicitly subscribed and recorded.
// Earlier builds let the syscall bypass the recorder, so a successful call
// changed the guest descriptor table without a corresponding stream event.
// The replayer now consumes one exact pidfd_getfd event and reissues the
// syscall to reproduce the kernel side effect; accepting a 0x10e stream would
// therefore consume the next event at every pidfd_getfd call.
//
// 0x10f -> 0x110: metadata now carries the recording namespace's proven
// Hermit-owned mount IDs. Detcore applies that map after both the recorder's
// raw read and the replayer's ReadV2 copyout. An older recording has no map and
// would replay different guest-visible mountinfo bytes under this sanitizer,
// so accepting it would violate replay fidelity even though the event enum did
// not change.
//
// 0x110 -> 0x111: metadata now also carries the recording namespace's full
// raw mount-ID order. That makes fdinfo's mnt_id use the same canonical identity
// as mountinfo during replay instead of consulting the unrelated replay
// namespace or collapsing all descriptors to one mount.
// 0x111 -> 0x113: fdinfo mount identities are now keyed by each observed raw
// mount ID rather than broad descriptor classes. Metadata carries only the
// completed namespace's mountinfo row/parent order; pseudo-filesystem IDs that
// are absent from mountinfo are allocated afterward in deterministic guest
// observation order. Replay must rebuild that mapping from recording-time raw
// bytes, or pidfs/nsfs/anon_inodefs can be collapsed or rejected. The draft
// 0x112 format was never shipped.
//
// 0x113 -> 0x114: recordings persist the completed guest's mountinfo order and
// unlisted fdinfo mount-ID order, and event streams use stable recording-local
// thread IDs rather than host PID allocation. An older reader cannot rebuild
// either mapping reliably for a plain public record API recording.
//
// 0x114 -> 0x115: event stream filenames now encode deterministic process-tree
// pedigrees instead of process-local allocation order. Older readers look for
// integer filenames and cannot replay a recording containing child streams.
//
// 0x115 -> 0x116: event stream filenames are fixed-size SHA-256 names and each
// data/debug stream begins with its complete process-tree identity. Older
// readers cannot skip or validate these headers.
// 0x116 -> 0x119: nonpositioned random-device readv now uses Detcore's
// shared canonical cursor and no longer emits or consumes recorder ReadvV2
// events. Old event streams cannot be replayed under this routing.
// 0x117 and 0x118 identify incompatible retained RNG, clock, and network
// recordings from parallel development; do not reinterpret those identities.
// 0x119 -> 0x11a: random-device preadv/preadv2 now use Detcore's canonical
// generator, including the shared cursor for preadv2(-1). They no longer emit
// or consume ReadvV2 events; accepting an older recording would desynchronize
// the event stream and replace its recorded random bytes.
// Early rejection of invalid negative offsets also stops emitting ReadvV2
// error events for non-random descriptors.
// 0x11a -> 0x11b: sysinfo uptime rounds exact elapsed logical time up, removing
// dependence on the calendar epoch's fraction. Detcore recomputes sysinfo during
// recording/replay, even with virtualize_time=false; replaying an older stream
// under the new projection could change guest control flow and event consumption.
// Sysinfo remains determinized rather than gaining a recorded event.
// 0x11b -> 0x11c: /proc/uptime renders the floor of exact elapsed logical time
// instead of the difference of the separately truncated clock and epoch, so a
// fractional epoch no longer moves it (or /proc/stat's idle ticks derived from
// it) by one second. /proc/stat btime is now derived from the fixed boot
// instant rather than from the clock minus uptime. Detcore recomputes these
// fields over the recorded procfs bytes during recording and replay, so an older
// stream replayed under the new projection could show the guest different bytes.
// 0x11c -> 0x11d: with time not virtualized, which is always the case for
// record/replay, detcore passes clock reads to record/replay instead of refusing
// them. Streams now carry Timespec and Timeofday events for clock_gettime,
// gettimeofday and time, and clock_getres gains a recorder event (Timespec, or
// Return for a NULL `res`). An older reader would desynchronize on these events.
// 0x11d -> 0x11e: guest-semantic madvise advice, which detcore used to refuse
// with ENOSYS, now reaches the recorder and replayer and emits a Madvise event.
// 0x11e -> 0x11f: faccessat, faccessat2, chdir, getcwd and the legacy path
// mutations (rename, link, symlink, chmod, chown, lchown, mknod, rmdir) are
// recorded instead of running live. A successful chdir or fchdir carries a
// Bytes event naming the directory it entered. An older reader would
// desynchronize on these events.
// 0x11f -> 0x120: descriptor syncs and metadata changes (fsync, fdatasync,
// syncfs, fchmod, fchown, fsetxattr, fremovexattr) record a Return event, the
// xattr queries (getxattr, lgetxattr, fgetxattr and the listxattr family)
// record a Bytes event (Return for a zero-size query), and zero-count read and
// pread64 calls are recorded instead of running live. An older reader would
// desynchronize on these events.
// 0x120 -> 0x121: splice and tee refuse with EINVAL instead of ENOSYS; vmsplice
// keeps ENOSYS. Record and replay always fail closed, and Detcore computes this
// refusal itself rather than recording it, so replay recomputes the errno. The
// guest can branch on it: GNU grep falls back to read/write on EINVAL but
// reports a read error and exits 2 on ENOSYS. Replaying an older stream under
// the new errno could change guest control flow and event consumption, although
// no event shape changed.
// 0x121 -> 0x122: Detcore numbers raw mount IDs in the order the guest first
// observes them through mountinfo or fdinfo, instead of by row position in the
// run's starting mountinfo. Metadata carries that order as
// `mount_id_assignment_order`, replacing `fdinfo_unlisted_mount_ids`, and
// replay numbers every raw ID from it. An older recording's metadata cannot
// rebuild the mapping its guest saw, so replaying it could change the mount IDs
// the guest reads and its control flow.
// 0x122 -> 0x123: Detcore's inode pool starts at 9000 instead of 1 and every
// numbering request consumes a number, so the deterministic inode numbers
// differ (https://github.com/rrnewton/hermit/issues/2897). Even with
// virtualize_metadata off, as record/replay runs, the procfs sanitizer renders
// pool numbers into /proc/*/fdinfo `ino:` lines and /proc/*/maps and smaps
// inode columns over the recorded raw bytes, during recording and again during
// replay. An older recording replayed under the new numbering could show the
// guest different bytes, although no event shape changed.
// 0x123 -> 0x124: accept and accept4 record an `Accept` event, and bind, listen
// and shutdown record a `Return` event, instead of running live during replay
// (https://github.com/rrnewton/hermit/issues/3864). An older recording has no
// events for these calls, so this replayer would consume another call's event.
// 0x124 -> 0x125: a blocking accept on a listener the container created runs in
// the caller's turn (https://github.com/rrnewton/hermit/issues/3880). It
// records one `Accept` event per nonblocking attempt, where an older recording
// has a single `Accept` event for the backgrounded call. (Its timeout comes
// from Detcore's model of `setsockopt`, not from a recorded event.) Connections accepted under record
// are no longer made nonblocking. An older recording would hand this replayer
// the wrong number of events. A recording also carries a `rejoins` file, the
// turns at which backgrounded calls rejoined the run queue, which replay
// requires.
// 0x125 -> 0x126: in the precise futex mode a FUTEX_WAKE that wakes fewer
// waiters than are waiting takes the longest waiters first, as Linux does,
// instead of the most recent ones, and a FUTEX_WAKE_BITSET leaves the waiters
// it skips in arrival order (https://github.com/rrnewton/hermit/issues/3917).
// Futex waits and wakes are not recorded events; replay recomputes which thread
// each wake takes, so an older recording replayed under the new order could run
// a different schedule, although no event shape changed. Schedule and
// preemption files written by `--record-preemptions-to` carry no version and
// are likewise tied to the old order.
// 0x126 -> 0x127: a vfork barrier ends at the child's release edge (its exec
// or `Exit` grant) whether or not the parent's death has been seen. With a
// live parent, the scheduler then commits no turn until the parent's
// continuation is posted, where the child used to keep running alone for a
// host-timed number of turns (https://github.com/rrnewton/hermit/issues/3984).
// Turn selection is not recorded; replay recomputes it, so an older recording
// containing a vfork replayed under the new rule could run a different
// schedule, although no event shape changed.
// 0x127 -> 0x128: on ptrace, `prctl(PR_SET_CHILD_SUBREAPER)` and
// `PR_GET_CHILD_SUBREAPER` run live in record and replay alike instead of
// failing with ENOSYS, and the scheduler re-parents orphans to a child
// subreaper (https://github.com/rrnewton/hermit/issues/3997). An older
// recording saw ENOSYS for both calls; this replayer would run them and could
// take another branch and a different schedule, although no event shape
// changed.
// 0x128 -> 0x129: record and replay set
// `supports_blocked_wait_signal_interruption`, so the scheduler models
// signal targets as `hermit run` does on ptrace
// (https://github.com/rrnewton/hermit/issues/3963). A thread that a committed
// signal wakes out of a backgrounded call rejoins at the release barrier, a
// precise FUTEX_WAIT or an rt_sigtimedwait ends only for a signal that would end
// it on Linux, and an emulated pause or nanosleep ends for another thread's
// signal. (poll, epoll_wait, select and pselect6 are logged background calls
// here, which the kernel itself ends.) Replay recomputes all of these, so an
// older recording replayed here could run a different schedule, although no
// event shape changed.
// 0x129 -> 0x12a: a SIGCHLD the scheduler sends at a commit point (a child's
// child-exit timer, or a POSIX timer) ends a precise FUTEX_WAIT that catches
// it, as on Linux, where it was held until the call returned
// (https://github.com/rrnewton/hermit/issues/4005). Replay recomputes precise
// futex results, so an older recording replayed here could take the other
// branch, although no event shape changed (Codex review of
// https://github.com/rrnewton/hermit/pull/4039).
// 0x12a -> 0x12b: on ptrace, a clone without CLONE_THREAD and with a
// non-SIGCHLD exit signal is its own process to the Tool, with its own pid and
// its kernel parent (https://github.com/rrnewton/hermit/issues/4012). Detcore
// recomputes calls that name that process (getpid-based prlimit, its exit and
// its parent's notification) from it, so an older recording replayed here
// could take another branch, although no event shape changed.
// 0x12b -> 0x12c: a precise FUTEX_WAIT woken for a signal that is no longer
// pending for it re-reads its word and answers EAGAIN if the word changed
// (EFAULT if unreadable), where it answered 0 as a wakeup; Linux's woken waiter
// reaches the same EAGAIN through -ERESTARTSYS and the restarted wait. A signal
// still pending for it is answered before the word is compared
// (https://github.com/rrnewton/hermit/issues/4033). Replay recomputes
// precise futex results, so an older recording replayed here could see another
// result and take another branch, although no event shape changed.
// 0x12c -> 0x12d: a precise FUTEX_WAIT or FUTEX_WAIT_BITSET checks its timeout
// and bitset before the word, and reads the word with user-mode permissions, as
// Linux's `futex_wait_setup` does: EFAULT for an unmapped or PROT_NONE word,
// where the tracer's read gave EIO or compared a PROT_NONE word's value
// (https://github.com/rrnewton/hermit/issues/4030). Replay recomputes precise
// futex results, so an older recording replayed here could see another errno
// and take another branch, although no event shape changed (Codex review of
// https://github.com/rrnewton/hermit/pull/4061).
// 0x12d -> 0x12e: a pidfd_send_signal to a process with one live thread tells
// the scheduler the signal is pending for that thread, as kill does, so a
// receiver parked in a blocking call is woken to take it
// (https://github.com/rrnewton/hermit/issues/4099). Replay recomputes
// the schedule, so an older recording replayed here could be scheduled
// differently, although no event shape changed.
// 0x12e -> 0x12f: a kill to a zombie (exited, its parent can still wait for
// it) answers 0, as Linux's kill_pid_info does, where it answered ESRCH; a
// kill(pid, 0) to an exited process answers from the same model; and an
// rt_sigaction(SIGCHLD) tells the scheduler whether the process now reaps its
// children automatically (https://github.com/rrnewton/hermit/issues/4091).
// Replay recomputes these answers and the schedule, so an older recording
// replayed here could see another result and take another branch, although
// no event shape changed.
// 0x12f -> 0x130: `epoll_pwait` is recorded with the event `epoll_wait`
// records, and replay serves it from the recording. It used to run live in
// record and replay alike, so an older recording holds no event for it and this
// replayer would desynchronize at the first one.
// 0x130 -> 0x131: an rt_sigqueueinfo to a zombie is forwarded to the kernel,
// which checks the siginfo and then finds the zombie (0), where it answered
// ESRCH (https://github.com/rrnewton/hermit/issues/4091). Replay recomputes
// the answer, so an older recording replayed here could see another result
// and take another branch, although no event shape changed.
// 0x131 -> 0x132: a process-directed signal naming a live non-leader thread's
// id goes to that thread's process, as Linux's kill_pid_info does, where it
// answered ESRCH (https://github.com/rrnewton/hermit/issues/4094). Replay
// recomputes the answer, so an older recording replayed here could see another
// result and take another branch, although no event shape changed.
// 0x132 -> 0x133: record readmits a finished background call while the only
// runnable work queued is threads that yielded and pollers, where it used to
// wait for every yielder to stop (https://github.com/rrnewton/hermit/issues/4092).
// Replay follows the logged readmission turn only once its gate opens, and an
// older replayer's gate stays shut in that state, so it could not consume the
// readmission: it would refuse, or hang behind a yielder that never stops
// (Codex review of https://github.com/rrnewton/hermit/pull/4120).
// 0x133 -> 0x134:
// a masked or zero-timeout ppoll on a stack with no scratch below its red zone
// stages its private timeout and mask in the red zone, where it returned EFAULT
// and recorded nothing, and a masked record/replay pselect6 that replay could
// not deliver an interruption of is refused
// (https://github.com/rrnewton/hermit/issues/4113,
// https://github.com/rrnewton/hermit/issues/4112). An older recording of such a
// ppoll holds no event for the call, so this replayer would desynchronize at it
// (Claude review of https://github.com/rrnewton/hermit/pull/4127).
// 0x134 -> 0x135: an rt_sigqueueinfo to a gone process makes the kernel check
// its siginfo (EFAULT, E2BIG, EPERM) before answering ESRCH, where Detcore
// answered ESRCH first; an rt_sigqueueinfo existence check (signal 0) answers
// from the same exit model (https://github.com/rrnewton/hermit/issues/4124).
// Replay recomputes the answer, so an older recording replayed here could see
// another result and take another branch, although no event shape changed.
// 0x135 -> 0x136: on ptrace, a guest-sent SIGKILL retires its victims at the
// sending turn instead of at their host-timed deregistration
// (https://github.com/rrnewton/hermit/issues/3994). Turn and wait selection
// are not recorded; replay recomputes them, so an older recording replayed
// under the new rule could run a different schedule. The metadata also gains
// `replay_refused`, which an older replayer would not check.
// 0x136 -> 0x137: `epoll_pwait2` is recorded with the event `epoll_wait`
// records, and replay serves it from the recording; it ran live before
// (https://github.com/rrnewton/hermit/issues/4088).
// 0x137 -> 0x138: a guest send of a default-stop signal records SIGHUP and
// SIGCONT as host-timed for every process, which an orphaned process group
// can receive at an exit's physical moment
// (https://github.com/rrnewton/hermit/issues/4111), so no gated wait ends for
// them afterwards. Replay recomputes the schedule, so an older recording
// replayed here could see such a wait end, although no event shape changed.
// Record and replay refuse the newly admitted signal to the sender's own
// process (https://github.com/rrnewton/hermit/issues/4034), so that change
// alters no recording.
// 0x138 -> 0x139: pidfd_send_signal with a PIDFD_SIGNAL_THREAD or
// PIDFD_SIGNAL_THREAD_GROUP flag, or through a /proc/<pid> directory, is
// forwarded, where Detcore answered EINVAL or EBADF without an event
// (https://github.com/rrnewton/hermit/issues/4108). An older recording holds no
// event for such a call, so this replayer would desynchronize at it.
// 0x13b -> 0x13c: pidfd_send_signal through the PIDFD_SELF_THREAD or
// PIDFD_SELF_THREAD_GROUP sentinel is forwarded, where Detcore answered EBADF
// without an event (https://github.com/rrnewton/hermit/issues/4147). An older
// recording holds no event for such a call, so this replayer would
// desynchronize at it.
// 0x13c -> 0x13d: timer_create with SIGEV_THREAD_ID answers EINVAL for a
// thread outside the caller's process (and for an invalid notify value, where
// it answered ENOSYS), and the timer's expirations go to that thread alone,
// dropped once it has exited, where they went to the whole process
// (https://github.com/rrnewton/hermit/issues/4164). Replay recomputes both, so
// an older recording replayed here could see different answers and deliveries.
// 0x13d -> 0x13e: a vfork child that Detcore backgrounded, and that the vfork
// gate waits for while every queued thread is excluded, is readmitted as soon
// as its call finishes, without a rejoin entry: before it, no turn can commit
// (https://github.com/rrnewton/hermit/issues/4163). An older recorder spun
// forever in that state, and replay recomputes the schedule, so an older
// recording replayed here could see the readmission where its recorder did
// not.
// 0x13e -> 0x13f: a guest in a nested PID namespace has its pids translated
// (https://github.com/rrnewton/hermit/issues/4155,
// https://github.com/rrnewton/hermit/issues/4090): kill and its relatives
// deliver where they answered ESRCH, fork returns the nested pid, waits reap
// where they answered ECHILD, the init's own default signals are dropped, and
// orphans go to the nested init. Replay recomputes these, so an older
// recording of such a guest could diverge.
// 0x13f -> 0x140: a record/replay pselect6 that may wait reads its temporary
// mask at the call's entry, where Linux copies it, and recording waits on a
// private copy; replay read it after the grant
// (https://github.com/rrnewton/hermit/issues/4095). An older recording whose
// sibling rewrote the mask between the two can replay differently here.
// 0x140 -> 0x141: sched_getaffinity accepts any length that is a nonzero
// multiple of sizeof(long), as Linux does for one CPU, and copies and returns
// min(len, 16), where it answered EINVAL below 16 bytes
// (https://github.com/rrnewton/hermit/issues/4160). Replay answers the call
// itself, so an older recording that saw EINVAL would see success here.
// 0x141 -> 0x142: a signal that another task sends ends a restartable call
// that Detcore polls internally (a blocking pipe read or write, readv, recv,
// send, accept4, connect, and the legacy wait4 polling) when the kernel would
// deliver it, where the poll ignored it and retried
// (https://github.com/rrnewton/hermit/issues/4187). The recorder logs each
// polled EAGAIN but not the scheduler's signaled answer, so recordings made
// before and after this change do not replay on each other's replayer.
// 0x142 -> 0x143: epoll_ctl is recorded, and replay answers it from the
// recording (https://github.com/rrnewton/hermit/issues/31). An older recording
// has no event for it.
// 0x143 -> 0x144 (https://github.com/rrnewton/hermit/pull/4131):
// a child-exit SIGCHLD the scheduler sends ends an emulated pause or nanosleep
// only when the thread's mask leaves it unblocked and it is caught or
// default-fatal, and a still-queued sleep is woken for it
// (https://github.com/rrnewton/hermit/issues/4126). Replay recomputes such a
// sleep's result, so an older recording of a blocked or default SIGCHLD during
// a nanosleep holds the EINTR it used to return, and this replayer would answer
// 0: a successful replay with different output (Codex review of
// https://github.com/rrnewton/hermit/pull/4131).
// 0x144 -> 0x145: an fcntl that writes its result through its argument
// (F_GETOWN_EX, which glibc uses for F_GETOWN; F_GETLK, F_GETLK64,
// F_OFD_GETLK; the write-hint queries) records the bytes it wrote, and replay
// writes them back (https://github.com/rrnewton/hermit/issues/2289). An older
// recording has no such event.
// 0x145 -> 0x146: a successful exec takes back the POSIX timer signals
// Detcore sent that are still queued, as Linux discards them
// (flush_itimer_signals; https://github.com/rrnewton/hermit/issues/4184),
// where they survived the exec and reached the new image. Replay recomputes
// this, so an older recording replayed here could see a delivery its recorder
// saw and this replayer drops.
// 0x146 -> 0x147: while a vfork barrier stands, the scheduler selects other
// runnable threads when no barrier child is queued to run a turn and none is in
// the background (each is blocked on another thread or polling a call that is
// not ready) (https://github.com/rrnewton/hermit/issues/4194). A polling child
// used to run alone; replay recomputes the schedule, so an older recording of a
// vfork child that polled for a host event, with other threads runnable, could
// replay differently. A backgrounded child is still waited for, as before.
// 0x147 -> 0x148: get_mempolicy answers as a one-node Linux machine
// (https://github.com/rrnewton/hermit/issues/4214): MPOL_F_MEMS_ALLOWED fills
// the node mask with node 0 and the default policy's mask is written empty,
// where Detcore left the guest's buffer unwritten, and flag combinations Linux
// refuses are EINVAL, where Detcore answered 0. Replay answers the call
// itself, so an older recording of such a call would replay with different
// answers.
// 0x148 -> 0x149: when the guest's CPUID comes from Detcore's table,
// /proc/cpuinfo describes that virtual CPU, generated from the table, where it
// showed the host's model, flags and caches
// (https://github.com/rrnewton/hermit/issues/4161). Record virtualizes CPUID,
// and Detcore renders procfs over the recorded bytes during recording and
// again during replay, so an older recording would replay with different bytes.
// 0x149 -> 0x14a: the procfs files that describe the kernel and its fixed
// limits (/proc/version, /proc/cmdline and 12 kernel and vm sysctls)
// are procfs files whose contents Detcore fixes from its machine description
// (https://github.com/rrnewton/hermit/issues/4266), where they were ordinary
// files whose host bytes were recorded as read. Replay serves a classified
// procfs file itself, so an older recording of a read of one would replay
// with different events.
// 0x14a -> 0x14b: a guest's thread-directed SIGCHLD (tgkill, pthread_kill,
// pthread_sigqueue) that the sender's turn recorded ends a precise futex wait, before or after the wait
// parks, when the waiter's mask leaves it unblocked and it is caught
// (https://github.com/rrnewton/hermit/issues/4132). The same copy has ended an
// emulated pause or nanosleep since
// https://github.com/rrnewton/hermit/pull/4177, which changed those results
// with no bump of its own; this one covers both. Replay recomputes both
// results, so an older recording of such a send would replay with the wait or
// the sleep ended early: a successful replay with different output.
// 0x14b -> 0x14c: under record, a vfork child whose call runs in the
// background no longer stops every other thread; it is readmitted as soon as
// the call finishes and the turn is written to the rejoin log, which replay
// follows (https://github.com/rrnewton/hermit/issues/4211). An older recording
// has no rejoin entry for such a readmission, so this replay could not follow
// it.
// 0x14c -> 0x14d: the kernel's tables (/proc/interrupts, softirqs, zoneinfo,
// meminfo, modules and 16 others) are fixed files that Detcore renders from
// its machine description with no kernel read
// (https://github.com/rrnewton/hermit/issues/4266), where Detcore sanitized
// the host's file and kept its shape: its interrupt names, zones and one
// column per host CPU. And every open whose spelling Detcore does not
// classify (nearly every open outside /proc and /sys) now records a readlink
// of the descriptor, which replay answers, so both runs classify it alike. An
// older recording would replay with different bytes and events.
// 0x14d -> 0x14e: a child-exit SIGCHLD the scheduler sends a parked precise
// futex waiter is placed at that commit point, so the waiter's woken turn is
// granted ahead of a runnable sibling rather than deferred behind it, and the
// waiter, not the sibling, takes the signal and returns EINTR
// (https://github.com/rrnewton/hermit/issues/4304). Replay recomputes the
// schedule and futex results, so an older recording of such an exit would
// replay with the handler in another thread and a different futex result.
// 0x14e -> 0x14f: a timer's process-directed signal (alarm, an itimer, a
// POSIX timer) is sent to a thread that does not block it, not to the thread
// that armed it or the one chaos drew when that thread blocks it, and that
// thread is the one woken (https://github.com/rrnewton/hermit/issues/4320).
// Replay recomputes the send, so an older recording of a timer whose arming
// thread blocked its signal would replay with another thread woken. And a
// background rt_sigsuspend that the host reports as ERESTARTSYS returns
// ERESTARTNOHAND, the only result Linux's rt_sigsuspend has, so an older
// recording of one would replay with a different result and restart.
// 0x14f -> 0x150: a robust futex word that one exit's walk finds owned by its
// dying owner reads as marked FUTEX_OWNER_DIED for the rest of that exit, as
// Linux's own store makes it (https://github.com/rrnewton/hermit/issues/4238).
// A word reached twice, through an alias or an entry that is its own
// successor, was woken again, waking a second waiter Linux leaves to time out.
// Replay recomputes the wakes, so an older recording of such an exit would
// replay with one wake fewer: a successful replay with different output.
// 0x150 -> 0x151 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): a pause or
// nanosleep that a child-exit SIGCHLD from the scheduler wakes is resumed
// first, as a woken futex waiter is, so the sleeper, not a running sibling,
// takes the signal and returns EINTR
// (https://github.com/rrnewton/hermit/issues/4333). Replay recomputes the
// schedule, so an older recording of such an exit would replay with the
// handler in another thread and the sleep still asleep.
// 0x151 -> 0x152 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): a call that looks
// up a /proc name outside the --proc level (kallsyms, sysvipc,
// sys/kernel/core_pattern, ...) is issued with that name replaced by one
// procfs cannot hold, so its recorded answer is Linux's for a missing name
// (https://github.com/rrnewton/hermit/issues/4266). An older recording holds
// the kernel's answer for the name itself.
// 0x152 -> 0x153 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): `minimal` is the
// default /proc level, and a recording stores its level (`record start
// --proc`), which its replay runs at
// (https://github.com/rrnewton/hermit/issues/4266). An older recording ran at
// `standard` without saying so, and would replay at `minimal`, where the
// standard level's names are missing.
// 0x153 -> 0x154 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): a call outside the
// schedule that begins while a signal the scheduler sent, and every thread
// blocked, waits in the shared queue, and that the call's mask admits and the
// process catches, is armed for the release barrier at its grant and rejoins
// at a fixed point (https://github.com/rrnewton/hermit/issues/4234). Under
// record it was readmitted through the rejoin log instead, so an older
// recording would replay with that call rejoining at another turn.
// 0x154 -> 0x155 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): a recording can carry the x86-64-v3 CPU profile and the
// host xstate facts its guest's CPUID leaf 0xD and XCOMP answers came from
// (https://github.com/rrnewton/hermit/issues/4243). An older replayer would
// ignore them and replay a v3 recording against the v2 table, so its guest
// would see a different CPU.
// 0x155 -> 0x156: a call that looks up a name in a process's or a thread's
// directory outside the --proc level (limits, wchan, mem, attr, ...) is
// issued with that name replaced by one procfs cannot hold, as for the
// system-wide names at 0x152 (https://github.com/rrnewton/hermit/issues/4266).
// An older recording holds the kernel's answer for the name itself.
// 0x156 -> 0x157 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): a standard
// signal Linux discards when it is sent (ignored, default-ignored with no
// handler, or uncaught to a PID namespace's init) no longer ends a futex wait,
// a sleep, a waitid, or an rt_sigtimedwait or signalfd take once a handler is
// installed, though ptrace still queues its copy; the scheduler records each
// send's fate in its turn (https://github.com/rrnewton/hermit/issues/4293).
// Replay recomputes these results, so an older recording of such a send would
// replay with the wait ended early: a successful replay with different output.
// 0x157 -> 0x158 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): Detcore answers
// readlink of the /proc links it knows the targets of (self, thread-self,
// mounts, net, the caller's namespace links) without a system call, and reads
// the caller's descriptor link spelled through its thread as
// /proc/thread-self/fd/N (https://github.com/rrnewton/hermit/issues/4266). An
// older recording holds a kernel readlink of the guest's own spelling for each
// of those.
// 0x158 -> 0x159 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): /proc/<pid>/cgroup
// is a procfs file whose every hierarchy reads as for a process in the root
// cgroup (https://github.com/rrnewton/hermit/issues/4378), where it was an
// unclassified open that recorded a readlink of its descriptor and the host's
// bytes. Replay serves a classified procfs file itself, so an older recording
// of a read of one would replay with different events.
// 0x159 -> 0x15a (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1; reserved as
// 0x15a): /proc/loadavg is a fixed procfs file, whose bytes come from
// Detcore's table with no kernel read, also under record/replay
// (https://github.com/rrnewton/hermit/issues/4213). An older recording holds
// the captured kernel read, which a new replay never takes, so it would go
// out of step.
// 0x15a -> 0x15b (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): a pause or
// nanosleep that a child-exit SIGCHLD wakes, in a process whose send window is
// unusable, claims the signal in record and replay as it does in a plain run,
// unless another thread outside the schedule could take it
// (https://github.com/rrnewton/hermit/issues/4343). An older recording of such
// an exit holds the sleep returning 0 or never waking, and would replay
// against a schedule in which it returns EINTR.
// 0x15b -> 0x15c (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): under record and
// replay a background read whose descriptor number a later close,
// close_range, dup2 or dup3 replaces before the read enters the kernel, or
// which was not open at its grant, keeps a woken sleep from claiming its
// SIGCHLD (https://github.com/rrnewton/hermit/issues/4410). An older
// recording of such a sleep holds the claim, which a new replay would not make.
// 0x15c -> 0x15d (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1; reserved as
// 0x15d): /proc/uptime is a procfs file Detcore renders
// (https://github.com/rrnewton/hermit/issues/4213), and a /proc/uptime the
// kernel opened (under record and replay, after chroot) now takes Detcore's
// rendered-file path for readv, preadv, preadv2 and lseek. A vectored read of
// it records a capture where an older binary refused it with ENOSYS, so an
// older recording containing one would replay out of step.
// 0x15d -> 0x15e (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1; reserved as
// 0x15e): clone3 with set_tid asking for an id a task of the run had, other
// than the pid of the caller's own zombie child, is refused
// (https://github.com/rrnewton/hermit/issues/4370). An older recording in
// which such a clone3 succeeded would replay to the refusal.
// 0x15e -> 0x15f (taken at land time; https://github.com/rrnewton/hermit/issues/4273,
// R2b-1): pipe read/write/writev woken by a kept signal decided in the sender's
// turn. REVERTED by 0x160.
// 0x15f -> 0x160 (taken at land time, HIGHEST_SHIPPED + 1): the 0x15f change is
// reverted, because its writev turn rule ended an atomic writev to a full pipe
// with a short count with no signal involved (writev_determinism's atomic
// full-pipe case: 4096 of 4096+ written, Linux blocks and completes it). Pipe
// calls woken by signals decide as they did at 0x15e; a 0x15f recording of
// such a wake would replay to another result, so the version moves forward.
// 0x160 -> 0x161 (taken at land time, HIGHEST_SHIPPED + 1; reserved as
// 0x160): a pidfd from clone(CLONE_PIDFD) or clone3's pidfd field is tracked
// as pidfd_open's is (https://github.com/rrnewton/hermit/issues/4430), so
// pidfd_send_signal through it is forwarded and recorded where Detcore
// answered EBADF without recording anything. An older recording holding such
// a send would replay out of step.
// 0x161 -> 0x162 (taken at land time, HIGHEST_SHIPPED + 1; reserved as
// 0x163): Detcore sends a parent-death signal (PR_SET_PDEATHSIG with a
// standard signal other than SIGKILL, SIGSTOP and SIGALRM) itself when the
// parent thread leaves, and arms the kernel with 0
// (https://github.com/rrnewton/hermit/issues/4440). An older recording of
// such a prctl or of the kernel's signal would replay out of step.
// 0x162 -> 0x163 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1; reserved as
// 0x15f): /proc/stat is a procfs file Detcore renders
// (https://github.com/rrnewton/hermit/issues/4213), and a /proc/stat the
// kernel opened (under record and replay, after chroot) now takes Detcore's
// rendered-file path for readv, preadv, preadv2 and lseek, as /proc/uptime
// did at 0x15d. A vectored read of it records a capture where an older binary
// refused it with ENOSYS, so an older recording containing one would replay
// out of step; and every read of it shows Detcore's layout, not the host's
// lines, so an older recording's guest saw other bytes.
// 0x163 -> 0x164 (taken at land time, HIGHEST_SHIPPED + 1): R2b-1 relanded
// (https://github.com/rrnewton/hermit/issues/4273): a pipe read, a pipe write
// or a pipe writev woken by a kept signal ends as Linux's does, and a pipe
// writev makes its first attempt in the slice of its own entry, so the kernel
// imports the iovec array the call began with. (The 0x15f writev requested a
// turn first and then read the array again, so another thread's rewrite in
// that turn changed the bytes an atomic writev to a full pipe wrote:
// writev_determinism's atomic full-pipe case.) Replay recomputes these
// results, so an older recording of such a wake would replay to another
// result.
// 0x164 -> 0x165 (taken at land time, as the reservation file's land-time
// numbering rule gives a ready change HIGHEST_SHIPPED + 1): sendfile records
// the bytes it copied and where its input stopped, and replay applies them
// instead of copying again (https://github.com/rrnewton/hermit/issues/4416).
// An older recording holds sendfile's count alone, which a new replay cannot
// read as its event.
// 0x165 -> 0x166 (taken at land time, HIGHEST_SHIPPED + 1): a joiner woken by
// a thread's CLONE_CHILD_CLEARTID is admitted at the next run-queue drain, in
// DetTid order with the other admissions, where it was pushed at once
// (https://github.com/rrnewton/hermit/issues/4362, part 2 step 0b). That moves
// it behind a lower-DetTid admission already pending, which turn selection,
// unrecorded, recomputes: an older recording could replay another order
// (Codex review of https://github.com/rrnewton/hermit/pull/4453, P2).
// 0x166 -> 0x167 (HIGHEST_SHIPPED + 1): a descriptor opened through one of
// the guest's own descriptor links (/proc/self/fd/N, /dev/fd/N and their
// thread and numeric spellings) records the path of descriptor N, not the
// link's spelling, so a name relative to it is looked up below that file as
// Linux looks it up (https://github.com/rrnewton/hermit/issues/4213,
// https://github.com/rrnewton/hermit/issues/4485). Under record and replay
// such a name is now classified, and checked against the --proc level, as
// the procfs file it is (a name outside the level is answered as absent
// before any open is recorded, where the alias spelling let the open reach
// the kernel), so an older recording with such an open would replay out of
// step.
// 0x167 -> 0x168 (taken at land time, HIGHEST_SHIPPED + 1): under record and
// replay, a POSIX timer's expiry is sent as an SI_TIMER record carrying the
// timer's id and si_value (rt_sigqueueinfo, rt_tgsigqueueinfo), not a bare
// kill or tgkill, so exec's own flush_itimer_signals removes it, and the
// scheduler no longer takes timer copies back at exec
// (https://github.com/rrnewton/hermit/issues/4262). An older recording's
// guest saw si_code 0 and no si_value for such a signal, and a replay would
// show it SI_TIMER.
// 0x168 -> 0x169 (reserved as 0x169): /proc/cpuinfo is a procfs file Detcore
// renders where it answers the guest's CPUID instruction from its own table
// (CPUID virtualized and intercepted;
// https://github.com/rrnewton/hermit/issues/4213), and there a /proc/cpuinfo
// the kernel opened (under record and replay, after chroot) takes Detcore's
// rendered-file path for readv, preadv, preadv2 and lseek, as /proc/stat did
// at 0x163. A vectored read of it records a capture where an older binary
// refused it with ENOSYS, so an older recording containing one would replay
// out of step.
// 0x169 -> 0x16a (reserved as 0x16a): a relative name below a directory
// descriptor Detcore has no record of (one received over SCM_RIGHTS on
// ptrace or KVM) is the kernel's lookup where Detcore answered EBADF before
// the recorder (https://github.com/rrnewton/hermit/issues/4213, K1-0), so an
// openat, stat, access or readlinkat through such a descriptor is now
// recorded, and an older recording containing one would replay out of step.
// 0x16a -> 0x16b was K3a (the recorded container mount table), shipped in
// f8a824cf and reverted in ec169b91. 0x16b -> 0x16c (no format change from
// 0x16a): this tree has no mount table, so it takes a new label rather than
// reusing 0x16b. A K3a recording is then refused by the exact-match gate
// instead of being replayed without its table, and the shipped 0x16b label is
// not moved backward.
// 0x16c -> 0x16d: K3a again (https://github.com/rrnewton/hermit/issues/4213):
// a recording carries its container's mount table, and Detcore serves
// /proc/<pid>/mountinfo and /proc/<pid>/mounts (and /proc/mounts) from it in
// place of the kernel's bytes. A mounts file is now a procfs file Detcore
// serves from a snapshot, where it was read through to the kernel, and
// neither file captures the kernel's bytes, so an older recording that reads
// one would replay out of step.
// 0x16d -> 0x16e (number to be set at land): a restartable call on an
// internal pipe or socket (read, readv, recv*, accept4, the scalar pipe
// write) blocks every blockable signal before its attempt when a signal is
// pending (R2b-2 stage 2, https://github.com/rrnewton/hermit/issues/4273), so
// a pending signal no longer stops the recorded attempt: the attempt's result
// is recorded where an older recording has the stopped attempt's ERESTARTSYS,
// and an older recording containing one would replay out of step.
// 0x16e -> 0x16f: Detcore keeps only the guest's own rows of /proc/locks,
// matching OFD and flock rows against the locks the guest's own open file
// descriptions hold, which their fdinfo names. After every successful
// F_OFD_SETLK or F_OFD_SETLKW, every flock call, and every successful
// pidfd_getfd, Detcore reads the descriptor's /proc/self/fdinfo through the
// recorder (an openat, its reads and a close), and replay matches the
// recorded /proc/locks rows against those recorded bytes. An older recording
// has no such events there and would replay out of step.
// 0x16f -> 0x170 was R2b-2 stage 3 (a recorded private SIGCHLD ends gated
// waits and pipe calls), shipped in 4381d927 and reverted in a6fb8ad0.
// 0x170 -> 0x171 (no format change from 0x16f): this tree does not end those
// calls on a recorded private SIGCHLD, so it takes a new label rather than
// reusing 0x170. A stage 3 recording is then refused by the exact-match gate
// instead of being replayed to other results, and the shipped 0x170 label is
// not moved backward.
// 0x171 -> 0x172: replay recomputes which /proc/locks rows are the guest's
// from the recorded raw rows and fdinfo reads, and that decision changed
// after 0x16f's format shipped: the descriptor-table ledger (d8117115) stops
// a description counting when no guest table references it and hides what it
// cannot follow, an fdinfo that cannot be opened or read no longer stops the
// run at the lock call but at the next /proc/locks read while that
// description is still referenced, and the fdinfo is read through
// /proc/thread-self. A 0x16f or 0x171 recording would replay different guest
// bytes, or refuse where it recorded a run that went on, so it is refused
// here instead.
// 0x172 -> 0x173 (R2b-2 stage 3 re-landed; 0x170's format under a new
// label): a `SIGCHLD` a guest sent a thread, which the schedule recorded in
// its private queue, ends that thread's gated wait (poll, ppoll, epoll_wait,
// epoll_pwait, rt_sigtimedwait) and its restartable pipe read, readv or
// scalar write, as on Linux, where it was held until the call returned
// (https://github.com/rrnewton/hermit/issues/4273). Such a turn also blocks
// signals in place before its timerfd publication. The recorded decisions
// change, so an older recording containing one would replay out of step.
// 0x173 -> 0x176 (reserved as 0x176; 0x174 and 0x175 are reserved by other
// lanes, and whichever lands later takes HIGHEST_SHIPPED + 1): Detcore reads
// a description's fdinfo after a lock call only through an anchor proved to
// be procfs. The recorded sequence is now an openat of the guest's /proc
// (O_PATH), its fstatfs and fstat, an openat2 of thread-self/fdinfo/<fd>
// beneath it (RESOLVE_BENEATH | RESOLVE_NO_XDEV), that entry's fstat, the
// reads and two closes, where an older recording holds one openat of
// /proc/thread-self/fdinfo/<fd>, so it would replay out of step.
// 0x176 -> 0x177 (reserved as 0x175; taken at land time as HIGHEST_SHIPPED + 1
// after 0x176 shipped first): record/replay retains ptrace's actual
// timer-delivery capability, so its stored Config and preemption.timer_enabled
// summary report the supported mechanism. The shared timer gate preserves
// capable ptrace arming and logical expiry, while timerless configurations no
// longer issue physical arms/rearms or manufacture skid state. This
// observable-behavior correction takes a new label even though the event
// layout is unchanged.
// 0x177 -> 0x178 (reserved as 0x178; 0x177 is the dbt lane's, landed as
// 9231425b): the procfs anchor's fix-forward also runs fstatfs on the opened
// fdinfo entry (it must be procfs too, so a sibling's dup2 over the anchor's
// descriptor number cannot pass) and closes the entry on every path, so the
// recorded sequence after each lock call is now the anchor's openat, fstatfs
// and fstat, the openat2, the entry's fstatfs and fstat, the reads and two
// closes. A 0x176 or 0x177 recording has no entry fstatfs and would replay
// out of step.
// 0x178 -> 0x179 (reserved as queue hint 0x17b in minibeads dh-gxmvo; takes
// HIGHEST_SHIPPED + 1 at land): a vfork parent resumes at its child's
// successful exec or exit, as Linux resumes it (`vfork(2)`), instead of once
// nothing else can run, and record logs that readmission in the rejoin log at
// step 2a. Every recording of a vfork now holds a different schedule, so an
// older one would replay out of step at its first vfork.
// 0x179 -> 0x17a (taken at land time as HIGHEST_SHIPPED + 1; reserved as
// 0x17a): fresh-image DBT Tool start and postexec now run before the first
// application instruction with its actual entry PC and live SP. Earlier images
// admitted those hooks at their first syscall, after guest instructions had
// executed. The lifecycle timing/context is observable even with an unchanged
// wire layout, so recordings require a new behavior version.
// 0x17a -> 0x17b: the vfork rejoin (0x179, 7ff8743b) is reverted, because it
// broke record/replay of make -jN (minibeads dh-ojrf): a vfork parent is again
// held until nothing else can run, and the rejoin log entries are gone. A
// recording made with the rejoin is refused by the exact-match gate.
// 0x17b -> 0x17c (takes HIGHEST_SHIPPED + 1 at land): a thread readmitted from
// a blocking pool whose call a signal ended keeps that call's temporary mask
// until its continuation turn (`continuation_masks`), instead of the kernel's
// SigBlk, which replay does not share with record (minibeads dh-ojrf). Replay
// now chooses the SIGCHLD taker, a timer signal's fate and a discard as record
// did, so an older recording could replay a different order there.
// 0x17c -> 0x17d (takes HIGHEST_SHIPPED + 1 at land): the vfork rejoin
// re-lands on the continuation-mask fix: a vfork parent again resumes at its
// child's successful exec or exit (`vfork(2)`), with the readmission logged at
// step 2a, so every recording of a vfork holds a different schedule.
// 0x17d -> 0x17e (taken at land time, HIGHEST_SHIPPED + 1): a signal that stops
// a call's first injection (its mask or action probe) before the probe runs now
// makes the call restart after delivery (-ERESTARTNOINTR), as if the signal came
// first (https://github.com/rrnewton/hermit/issues/4526), where the call failed
// with the probe's -ERESTARTSYS. A recording made before this holds that EINTR
// and would replay out of step.
pub const RECORD_VERSION: RecordVersion = RecordVersion;
/// The highest RECORD_VERSION this project has ever shipped.
///
/// RECORD_VERSION must never move BACKWARD onto it. This is a COMPILE-TIME
/// assertion rather than a test on purpose: it is decidable from two constants,
/// so it should break the build rather than a test run, and it cannot be
/// skipped, filtered or left unrun.
///
/// WHY IT EXISTS AT ALL. The rejection set in `record_version_requires_an_exact_match`
/// used to be a list of specific versions, and `!compatible_with(0x10a)` was
/// catching a backward move BY ACCIDENT. Replacing that list with a window derived
/// from RECORD_VERSION fixes its silent narrowing but cannot catch a regression,
/// because a derived window re-derives from whatever the constant currently says.
/// Dropping the list without this floor would have traded a stale check for a
/// weaker one.
///
/// The failure it guards is near, not hypothetical: a long-stale branch that bumped
/// 0x109 -> 0x10a while main advanced to 0x10e regresses the constant the moment its
/// conflict is resolved by taking the branch side. The build would then stamp the
/// current schema with a label an older reader already claims, and the exact-match
/// gate would accept a stream whose shape it does not know -- the desynchronization
/// the version exists to prevent.
///
/// RAISE THIS IN THE SAME COMMIT THAT RAISES RECORD_VERSION.
const HIGHEST_SHIPPED_RECORD_VERSION: u32 = 0x17e;
const _: = assert!;
/// Metadata associated with the recording. This is serialized as a JSON file.
/// Whether this host can arm Reverie's ptrace timer for a record or replay:
/// working perf counters AND a PMU profile for its CPU. Without a profile,
/// Reverie gives no task a timer, so a timeslice would be configured and never
/// delivered.
/// [`record_timer_support`] from what the host answered: whether perf works,
/// and whether Reverie has a PMU profile for its CPU.
/// Turn off `config`'s timeslice, which this host cannot deliver (`reason`).