hird 0.3.0

Cross-harness agent work queue and shared assertion memory, backed by one local SQLite database
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
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
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
# hird — cross-harness agent work queue & shared memory

> Working name: `hird` (Norse: a lord's retinue). Rename freely; the binary name is referenced throughout as `hird`.

## 1. Overview

`hird` is a single local-first Rust binary that lets multiple AI coding agents — Claude Code, Codex CLI, GitHub Copilot, or any MCP-capable harness — coordinate through a shared **work queue** and a shared **assertion-based memory store**, with a **ratatui TUI** for the human to observe and drive both.

The human creates tasks (CLI or TUI), then tells any agent in any harness "pick up task 42". The agent claims the task via MCP, works it, records assertions it learns along the way, and completes it. All state lives in one SQLite database. No daemon.

### Goals (v1)
- One binary, three modes: `hird mcp` (stdio MCP server), `hird tui`, `hird <cli-subcommand>`.
- Work queue with atomic claiming, lease-based liveness, and full status history.
- Assertion-based memory with provenance and FTS5 search.
- TUI: live queue board + memory browser.
- Works simultaneously from 3–4 concurrent harness sessions on one machine.

### Non-goals (v1)
- No multi-machine sync (design must not preclude it; see §9).
- No daemon / HTTP server mode. *(v2.9 draws the line more finely: `hird
  web` is a loopback, read-only viewer with the TUI's posture, not a server
  mode anything depends on — see §28.)*
- No task dependencies/DAGs, priorities beyond a simple integer, or scheduling.
- No automatic task dispatch — the human assigns tasks by telling an agent the id.
- No embeddings/vector search — FTS5 only.

> **v1.1 — swarm coordination.** Two of those non-goals were wrong, and §11
> below records why. Once several agents work one queue at the same time, "the
> human assigns tasks by telling an agent the id" is the bottleneck the rest of
> the design exists to remove, and dependencies are what make self-dispatch
> safe. Both are now built, along with a third thing v1 did not anticipate:
> declared file scopes, so the queue can see two agents heading for the same
> file before either of them writes to it. Sections marked **(v1.1)** are
> additions; nothing in v1 was removed.
>
> **v1.3 — plan files.** §13 adds a way to write a dependency graph down and
> file it in one transaction. It is a notation for the rows §11 already
> defined, not a workflow language: "no scheduling" above stays true, and §13
> gives the rule that keeps it true.

## 2. Architecture

```
┌────────────┐  ┌────────────┐  ┌────────────┐
│ Claude Code│  │  Codex CLI │  │  Copilot   │
│  session   │  │  session   │  │  session   │
└─────┬──────┘  └─────┬──────┘  └─────┬──────┘
      │ stdio MCP     │ stdio MCP     │ stdio MCP
┌─────▼──────┐  ┌─────▼──────┐  ┌─────▼──────┐
│ hird mcp   │  │ hird mcp   │  │ hird mcp   │   (one process per session)
└─────┬──────┘  └─────┬──────┘  └─────┬──────┘
      └───────────────┼────────────────┘
                ┌─────▼──────┐        ┌──────────┐
                │  SQLite    │◄───────┤ hird tui │ (poll, 500ms)
                │  (WAL)     │◄───────┤ hird CLI │
                └────────────┘        └──────────┘
```

- **DB location:** `${XDG_DATA_HOME:-~/.local/share}/hird/hird.db`. Overridable via `--db` flag and `HIRD_DB` env var.
- **Concurrency:** `journal_mode=WAL`, `busy_timeout=5000`, `synchronous=NORMAL`, `foreign_keys=ON`. All writes are short transactions.
- **Crate suggestions:** `rusqlite` (bundled), `rmcp` (official Rust MCP SDK) for the MCP server, `ratatui` + `crossterm` for the TUI, `clap` for CLI, `serde`/`serde_json`, `time` or `chrono`, `ulid` for ids.

## 3. Identity & scoping

- **Agent identity:** every MCP session identifies itself as `<harness>:<session>`, e.g. `claude-code:af31`. The harness name comes from the `HIRD_HARNESS` env var set in each harness's MCP registration config; failing that **(v1.6)** from the name the client gives for itself, latched from the first request that carries one; failing that `unknown`. The session suffix is a short random id generated at MCP process start. Stored on claims and assertions.
- **Project scoping:** every task and assertion carries a `project` string — the canonicalized project root path. The MCP server resolves it from `HIRD_PROJECT` env var if set, else the git toplevel of the server's CWD, else the CWD itself. One global DB, filterable by project. All MCP list/search tools default to the current project scope with an explicit `all_projects: true` escape hatch.

## 4. Data model

Use `ulid` strings as primary keys but ALSO give tasks a short monotonic integer `seq` for human reference ("task 42"). All timestamps are UTC ISO 8601 strings.

```sql
CREATE TABLE tasks (
  id          TEXT PRIMARY KEY,            -- ulid
  seq         INTEGER UNIQUE NOT NULL,     -- human-facing number, AUTOINCREMENT-like via meta table
  project     TEXT NOT NULL,
  title       TEXT NOT NULL,
  body        TEXT NOT NULL DEFAULT '',    -- markdown; full instructions for the agent
  status      TEXT NOT NULL DEFAULT 'open'
              CHECK (status IN ('open','claimed','in_progress','done','failed','cancelled')),
  priority    INTEGER NOT NULL DEFAULT 0,  -- higher = more important; informational only in v1
  claimed_by  TEXT,                        -- harness:session, NULL unless claimed/in_progress
  lease_expires_at TEXT,                   -- NULL unless claimed/in_progress
  result      TEXT,                        -- final summary written on done/failed
  created_at  TEXT NOT NULL,
  updated_at  TEXT NOT NULL
);

CREATE TABLE task_events (                 -- append-only audit trail; drives TUI history pane
  id         TEXT PRIMARY KEY,
  task_id    TEXT NOT NULL REFERENCES tasks(id),
  at         TEXT NOT NULL,
  actor      TEXT NOT NULL,                -- harness:session, 'cli', or 'tui'
  kind       TEXT NOT NULL,                -- created|claimed|status|note|lease_renewed|lease_expired|completed|failed|cancelled|reopened
                                           -- (v1.1) |released|dep_added|dep_removed|scoped
  detail     TEXT NOT NULL DEFAULT ''
);

CREATE TABLE assertions (
  id         TEXT PRIMARY KEY,
  project    TEXT NOT NULL,
  content    TEXT NOT NULL,                -- one factual assertion, plain text
  tags       TEXT NOT NULL DEFAULT '',     -- comma-separated, freeform
  actor      TEXT NOT NULL,                -- who asserted it
  task_id    TEXT REFERENCES tasks(id),    -- optional: learned while working this task
  superseded_by TEXT REFERENCES assertions(id),  -- NULL = current
  created_at TEXT NOT NULL
);

CREATE VIRTUAL TABLE assertions_fts USING fts5(
  content, tags, content='assertions', content_rowid='rowid'
);
-- keep in sync with INSERT/UPDATE triggers on assertions

CREATE TABLE meta (key TEXT PRIMARY KEY, value TEXT NOT NULL); -- schema_version, next_seq
```

Indexes: `tasks(project, status)`, `tasks(status, lease_expires_at)`, `task_events(task_id, at)`, `assertions(project, superseded_by)`.

**Schema migrations:** embed numbered SQL migrations, apply on open, track in
`meta.schema_version`. **(v2.7)** A database whose recorded version exceeds
what the binary knows is refused at open — naming both versions, the running
binary's path and the fix — rather than failing later, mid-call, on a column
the old binary never heard of, in an error indistinguishable from corruption.
The refusal writes nothing.

**(v1.1) Migration 2 — the dependency graph and declared file scopes.**

```sql
CREATE TABLE task_deps (
  task_id       TEXT NOT NULL REFERENCES tasks(id),
  depends_on_id TEXT NOT NULL REFERENCES tasks(id),
  actor         TEXT NOT NULL,
  created_at    TEXT NOT NULL,
  PRIMARY KEY (task_id, depends_on_id),
  CHECK (task_id <> depends_on_id)
);

CREATE TABLE task_paths (
  id          TEXT PRIMARY KEY,
  task_id     TEXT NOT NULL REFERENCES tasks(id),
  pattern     TEXT NOT NULL,   -- normalized glob, relative to the project root
  declared_by TEXT NOT NULL,
  at          TEXT NOT NULL,
  UNIQUE (task_id, pattern)
);
```

Indexes: `task_deps(depends_on_id)`, `task_paths(task_id)`.

Two properties are deliberate. **Blocked is derived, not stored**: a task with
unfinished dependencies is still `open`, so the status machine and its `CHECK`
constraint are untouched and there is no seventh state to keep consistent.
**Scopes are patterns, not files**: the work has not been done yet, so there is
nothing to observe; two agents collide when the sets their patterns describe
intersect, which is a decidable question about the patterns themselves. That
second property is what §13's plan preview is built on: two rows that do not
exist yet can still be asked whether they would collide.

**(v1.3) Migration 4 — the name a plan file gave a task.**

```sql
CREATE TABLE task_plan_nodes (
  task_id TEXT PRIMARY KEY REFERENCES tasks(id),
  project TEXT NOT NULL,
  plan    TEXT NOT NULL,
  node    TEXT NOT NULL,
  at      TEXT NOT NULL,
  UNIQUE (project, plan, node)
);
```

Sparse by design — a task filed by hand has no row here — and it is what lets
the same plan be applied twice without filing everything a second time. See §13.


## 5. Queue semantics

### Status machine
```
open ──claim──► claimed ──start──► in_progress ──complete──► done
  ▲                │                    │        └─fail────► failed
  │                └── lease expiry ────┘
  │                └──── release ───────┘   (v1.1)
  └──────── reopen (human) ◄── done|failed|cancelled
open ──cancel (human)──► cancelled
```
- **(v1.1)** `release` is the agent-side counterpart of a lease expiry: the
  holder hands an unfinished task straight back rather than making the queue
  wait out the TTL, and without `failed` — which is a verdict on the task and
  needs a human to clear it.
- `claim` is only valid from `open`. `complete`/`fail` only from `claimed`/`in_progress` **by the lease holder**.
- Humans (CLI/TUI) may `cancel` from any non-terminal state and `reopen` from any terminal state (clears `claimed_by`, `lease_expires_at`, `result`).

### Claiming (atomic CAS)
```sql
UPDATE tasks
SET status='claimed', claimed_by=?1,
    lease_expires_at=?2, updated_at=?3
WHERE seq=?4 AND status='open';
```
Zero rows updated ⇒ claim failed; return the task's current status and holder in the MCP error so the agent can report it to the user.

### Leases
- Default TTL: **15 minutes** (config: `lease_ttl_minutes`).
- Every successful `task_update` / `task_note` by the holder renews the lease.
- **Expiry is enforced lazily**: any reader that touches the tasks table first runs a sweep in the same connection:
  ```sql
  UPDATE tasks SET status='open', claimed_by=NULL, lease_expires_at=NULL, updated_at=?
  WHERE status IN ('claimed','in_progress') AND lease_expires_at < ?now;
  ```
  and writes a `lease_expired` event per affected row. No background thread needed; the TUI's 500 ms poll makes expiry visible promptly — and, since v2.2 (§21), announces what that poll collected.
- A claim by a dead agent therefore self-heals back to `open` within TTL.

### (v1.1) Readiness

A task is **ready** when it is `open` and every task it depends on is `done`.
Only `done` clears a dependency: a `failed` or `cancelled` blocker means the
work its dependents were waiting for did not happen. `claim` refuses a task that
is not ready and names what it is waiting for; a dependency the queue does not
enforce is only a comment.

`task_deps` is kept acyclic by construction — an edge is refused when the
proposed dependency can already reach the dependent through its own
dependencies, and the refusal prints the chain that would have closed.

### (v1.1) Collision detection

Whenever a task's file scope is written — at creation, at claim time, or by
`task_scope` mid-flight — it is checked against every *other* task in the same
project that is currently `claimed` or `in_progress`. Two patterns conflict when
some path exists that both describe. That is an emptiness check on the
intersection of two regular languages, answered exactly by walking the product
of the two patterns' automata (`src/glob.rs`), not approximated by string
comparison: `src/*.rs` and `src/lib*` conflict, `a/**/x.rs` and `a/**/y.rs` do
not.

The check and the write share one `IMMEDIATE` transaction, so two agents
declaring overlapping scopes at the same instant are serialized and at most one
of them can come away believing it is alone in the file.

Policy is configuration, not code: `path_conflicts = "report"` records the
declaration and tells both sides, `"refuse"` rejects the claim and rolls back
everything it had taken.

### (v1.1) Dispatch

`task_next` claims the best *workable* task: `open`, ready, and — unless
`avoid_conflicts` is off — with a file scope that does not overlap live work.
Candidates are considered by descending priority then ascending `seq`, so the
queue is FIFO within a priority band. The whole scan and the claim happen in one
`IMMEDIATE` transaction, which is what lets N agents in N harnesses run the same
loop and come away with N different tasks.

An empty-handed answer carries its reason — how many tasks are blocked, and
which ready ones were passed over for which overlap — because an agent that can
say "three tasks are ready but another agent is in all of their files" is useful
to the human, and one that says "no work" is not.

## 6. MCP server (`hird mcp`)

stdio transport. Instructions string (returned from `server/discover`, and from `initialize` for clients still handshaking) must tell the model: how tasks are referenced (by `seq`), that it must claim before working, must call `task_update` at least every ~10 minutes to keep the lease, and should store assertions for durable facts it learns.

### Tools (exactly these twelve — eight from v1, four from v1.1)

| Tool | Input | Behavior |
|---|---|---|
| `task_list` | `status?`, `all_projects?` | List tasks (seq, title, status, holder, priority, updated_at, blocked_by). Runs lease sweep first. |
| `task_get` | `seq` | Full task incl. body, result, dependencies, file scope, overlaps, last 20 events. |
| `task_claim` | `seq`, `paths?` | Atomic claim as above. Refused while blocked. Returns full task body, scope and overlaps. |
| `task_next` | `all_projects?`, `avoid_conflicts?` | **(v1.1)** Claim the best workable task, or explain why there wasn't one. |
| `task_scope` | `seq`, `paths` | **(v1.1)** Holder-only. Declare files; answer with overlaps and what to do. |
| `task_update` | `seq`, `status?` (`in_progress` only), `note` | Holder-only. Appends `note`/`status` event, renews lease. |
| `task_split` | `seq`, `subtasks`, `sequential?` | **(v1.1)** Holder-only. File the pieces, make this task wait for them, release it. |
| `task_complete` | `seq`, `result`, `verdict?` **(v1.7)** | Holder-only. → `done`, clears lease, stores result. On a review, `verdict` is required and acted on (§16). |
| `task_fail` | `seq`, `reason` | Holder-only. → `failed`, clears lease, stores reason. |
| `task_release` | `seq`, `reason`, `question?` **(v2.5)** | **(v1.1)** Holder-only. → `open`, clears lease; with `question`, waits for `hird answer` before becoming claimable. |
| `mem_store` | `content`, `tags?`, `task_seq?` | Insert assertion with actor + project provenance. |
| `mem_search` | `query`, `limit? (20)`, `all_projects?`, `include_superseded? (false)` | FTS5 `MATCH`; fall back to `LIKE` if the query fails FTS syntax. Results include id, content, tags, actor, created_at. |

**(v1.1)** The server's instructions gain the swarm protocol: ask for work
with `task_next` when no number was named, declare files with `task_scope` as
soon as they are known, split rather than serialize, release rather than fail.

Design rules: every tool result is compact JSON; errors are descriptive strings the model can relay verbatim ("task 42 is claimed by codex:9f2c until 14:32Z"). No tool mutates memory implicitly.

### (v1.6) Lifecycle — MCP 2026-07-28

The server answers every protocol revision the Rust SDK implements, 2024-11-05
through 2026-07-28, and negotiates rather than requiring one. A revision it does
not implement is refused by name, with the list it does implement attached.

2026-07-28 deletes the `initialize` handshake and the protocol-level session:
a client opens with `server/discover` or with the request it actually wanted,
and each request carries the protocol version, the client's implementation and
its capabilities in `params._meta`. Nothing in this design leaned on that
handshake — the transport is stdio, one process per session, and the identity
and project scope are both read from the environment at process start — so the
two lifecycles coexist on one queue with nothing to reconcile.

Three consequences, and only three:

1. **Discovery is not cacheable.** The instructions string names the current
   project and is shaped by this machine's config file, so `server/discover`
   answers `cacheScope: private` and `ttlMs: 0`. It is nobody else's to reuse.
2. **A client names itself on every call**, which is the one thing worth
   taking. `call_tool` offers that name to the session identity, which keeps it
   only if `HIRD_HARNESS` left the identity unnamed — the env var is the half a
   human controls, and `hird register` writes it — and only once. An actor
   string that changed mid-session would leave the process unable to find its
   own leases, so the first name wins and is held.
3. **An opening request that cannot open a connection is answered**, not
   dropped. The SDK's response to one is to close the transport, which reaches
   a harness as "the hird server crashed"; it did not, and a request with an id
   is owed an error saying which `_meta` keys were missing.

Nothing is adopted from the revision beyond that. The three features it
deprecates — roots, sampling, protocol logging — are three this server never
used, so the deprecation window is not a migration for hird.

### Harness registration (document in README)
- Claude Code: `claude mcp add hird -e HIRD_HARNESS=claude-code -- hird mcp`
- Codex CLI: entry in `~/.codex/config.toml` `[mcp_servers.hird]` with `command = "hird"`, `args = ["mcp"]`, `env = { HIRD_HARNESS = "codex" }`
- Copilot / VS Code: `.vscode/mcp.json` stdio server, `HIRD_HARNESS=copilot`.
- Gemini CLI: `.gemini/settings.json` stdio server under `mcpServers.hird`,
  `HIRD_HARNESS=gemini` — project-scoped, as `gemini mcp add` defaults to.
- OpenCode: `${XDG_CONFIG_HOME:-~/.config}/opencode/opencode.json` local server
  under `mcp.hird`, `HIRD_HARNESS=opencode`.

## 7. CLI

```
hird add <title> [--body <md>|--body-file <path>] [--priority N] [--project <path>]   → prints seq
                 [--needs <seq>,…] [--path <glob>]…                                  # (v1.1)
hird ls [--status s] [--all-projects]
hird show <seq>
hird cancel <seq> / hird reopen <seq>
hird answer <seq> <answer>              # (v2.5) resolve the task's open question
hird dep add|rm <seq> --needs <seq>,…    # (v1.1) edit the graph
hird plan apply <file> [--dry-run] [--project <path>]  # (v1.3) file a whole graph
hird graph [--all-projects]              # (v1.1) the queue as dispatch waves
hird scope <seq> [--path <glob>]… [--clear]   # (v1.1) a task's file scope
hird agents [--all-projects]             # (v1.1) who is working what, and overlaps
hird mem add <content> [--tags a,b] / hird mem search <query>
hird tui
hird mcp
hird register <claude-code|codex|copilot|copilot-cli|gemini|opencode>
hird db-path
hird --install                         # copy this binary to ~/.local/bin/hird
hird --install-skill                   # install the skill for Codex, Claude, Copilot, Gemini and OpenCode
```
Human CLI actions record events with `actor='cli'`.

`scripts/install.sh [--install-skill]` builds the locked release, runs the
installer, and cleans the release profile on exit.

## 8. TUI (`hird tui`)

ratatui + crossterm. Poll the DB every 500 ms (cheap queries; WAL makes this safe). Two screens, `Tab` to switch, `q` quits, `?` help overlay.

**Screen 1 — Queue board.** Kanban columns: Open | Claimed/In-progress | Done | Failed/Cancelled. Cards show `#seq title`, holder badge (`claude-code`, `codex`, `copilot` with distinct colors), lease countdown for claimed tasks, priority marker. Keys: `j/k` move, `h/l` columns, `Enter` detail pane (body + event history), `a` add task (title prompt; body optional), `c` cancel, `r` reopen, `/` filter by text, `p` toggle project filter (current/all).

**(v1.1) Cards** carry a `waits #1 #3` badge when a task is `open` but blocked,
because a board that shows unclaimable work as available is lying to the human.

**Screen 2 — Memory browser.** Top: search input (FTS query, live). Below: assertion list — content, tags, actor badge, age, linked task seq. `Enter` shows full assertion + provenance. `d` marks superseded (sets `superseded_by` to a tombstone assertion authored by `tui`). `p` project filter toggle.

**(v1.1) Screen 3 — Swarm.** Left: one row per live agent — harness badge, task,
lease countdown, declared files, and a red line for every overlap with another
agent, resolved by pattern intersection rather than string equality. Right: the
tasks that could be dispatched right now, and how many are queued behind them in
how many waves. `j/k` moves between agents, `Enter` opens the task one holds.

Status bar on every screen: DB path, project filter, counts by status, how many
tasks are ready to dispatch, last-poll age.

## 9. Future (do not build, do not preclude)

- Multi-machine: the append-only `task_events` + assertion model is CRDT-friendly; a later `hird sync` could ship via S3 like ccsync. Keep all mutations expressible as events.
- ~~Task dependencies (`blocked_by`), auto-dispatch~~ — built in v1.1, §11.
- **(v1.3) Not built, deliberately:** a plan file describes tasks and edges and
  nothing else — no conditionals, loops, retries or schedules. See §13 for the
  rule that keeps it that way, and why a queue agents pull from must not grow a
  scheduler.
- Embeddings for memory, HTTP mode for remote harnesses.
- **(v1.1) Not built, deliberately:** scopes are declared, never observed. Reading
  the working tree to check what an agent *actually* touched would make the queue
  depend on the checkout's state, and would report collisions only after the edit
  that caused them. Declaration is earlier and cheaper, and being advisory is the
  point — the queue tells agents about each other and lets them coordinate.

## 10. Implementation plan (milestones)

1. **M1 — Core:** crate skeleton (`clap` multi-mode binary), DB open/migrations, tasks + events + assertions modules with unit tests for the claim CAS and lease sweep (spawn N threads claiming the same task; exactly one wins).
2. **M2 — MCP:** `hird mcp` with all eight tools via `rmcp`; integration test driving the server over stdio JSON-RPC.
3. **M3 — CLI:** all subcommands.
4. **M4 — TUI:** queue board, then memory browser.
5. **M5 — Polish:** README with per-harness setup, `justfile` (build, test, lint, install), config file `~/.config/hird/config.toml` (`lease_ttl_minutes`, default project behavior).

## 11. Quality bar

- `cargo clippy -- -D warnings`, `cargo fmt --check` clean.
- Every DB mutation goes through a typed repository layer; no raw SQL in MCP/TUI/CLI layers.
- Property-style test for the status machine: no transition outside §5's diagram is reachable.
- The binary must start `mcp` mode in <50 ms (harnesses spawn it per session).

## 11. (v1.1) Swarm coordination — what changed and why

v1's queue works beautifully for one agent at a time. The moment three
harnesses are live it develops three problems, and they are the same problem:
the queue knows what work exists but not what work is *workable*.

1. **The human is the dispatcher.** Every task needs a person to say a number
   out loud. Three idle agents and twelve open tasks is twelve interruptions.
2. **Order is a matter of trust.** "Do the schema before the API" lives in a
   task body, and an agent that skips it fails in a way nobody notices until
   later.
3. **Nobody can see anyone else's hands.** Two agents open the same file from
   two harnesses and the second write silently wins.

Each is fixed by giving the queue one more thing to know:

| Problem | What the queue learns | Tool |
|---|---|---|
| dispatch | which task is most important *and* workable | `task_next` |
| order | which tasks wait for which | `task_deps`, enforced in `claim` |
| collisions | which files each task expects to touch | `task_paths`, `task_scope` |

They compose into something none of them is alone. Dependencies make
self-dispatch safe (an agent cannot start work whose prerequisites are missing);
declared scopes make *parallel* self-dispatch safe (two agents are never handed
work in the same files); and `task_split` closes the loop by letting an agent
turn one task into a fan-out the other agents can pick up — the queue's own
contents become the plan, written by the agents working it.

The invariant that keeps this honest: **every one of these decisions is made
inside the same `IMMEDIATE` transaction that performs the claim.** Readiness is
not advice checked beforehand; the collision check is not a race with the write
that follows it. Whatever the queue told an agent was true, was true at the
instant it handed the task over.

## 12. (v1.2) The witness — reading the working tree

§11 gave the queue three new things to know, and every one of them is something
an agent *said*. A task's status is its holder's claim about itself; its file
scope is its holder's prediction; its result is its holder's summary. The board
is an accurate record of what a set of cooperating agents reported, which is a
different thing from a record of what happened, and the difference is where the
expensive failure lives.

Consider the case the collision detector was built for, played out to the end.
Two agents declare `src/config.rs`. Both are told about the overlap. Both decide
their part is small. Both edit. The second write lands on top of the first,
`task_complete` succeeds for both, the board goes green, and git has nothing to
show because nothing was committed — there is one working tree and one version
of the file, and it is the second agent's. Nobody involved is in a position to
notice: not the first agent, whose session ended believing it had finished; not
the second, which never saw the version it replaced; not the human, who has two
completed tasks and a plausible pair of summaries.

So v1.2 adds the one participant that is not taking anybody's word for it.

**Migration 3.** `task_witness` holds one working-tree fingerprint per task —
`HEAD`, plus a content hash for every path that could plausibly move — taken
when the task is claimed and never moved afterwards. `task_changes` holds the
difference between that fingerprint and the tree as it stands, one row per path,
rewritten on every observation, so a file edited and then put back the way it
was leaves no row behind.

**Candidate paths come from git.** `git status --porcelain -z
--untracked-files=all` decides what is worth hashing, which means `.gitignore`
decides what counts as noise and hird reimplements nothing. A clean checkout
costs one process and no hashing at all. When a task's recorded `HEAD` has moved
— an agent that commits its own work — whatever the commits touched is a
candidate too, so committing does not erase the record of having done it.

### What it can and cannot prove

One checkout has one filesystem and no keyboards. When a file changes while
three agents hold leases, all three have it in their footprint, and no amount of
hashing will say which of them typed. hird does not pretend otherwise: the
footprint is described everywhere as *what moved while the task was held*, never
as what the task did.

Saying *who* needs the other half — and the other half already exists. A
declared scope is an agent stating that it holds a copy of a file and intends to
write from it. So:

> **A contention is a path that two live tasks both declared, that has since
> moved under both of them, and that the two of them disagree about the content
> of.**

Each clause carries weight. Both declaring is what supplies attribution the
filesystem cannot. Having moved is what makes it an event rather than a
prediction — the plain declared overlap is already reported, and repeating it
adds nothing. Disagreeing is what makes it *actionable*: two agents who have
both been shown the current version are not in trouble, and warning them anyway
is how a warning stops being read.

That is the predicted collision and the observed one at the same time, and what
it tells the agent holding the stale copy is exactly the thing that saves the
work: **re-read the file before you write it.**

### Looking is not telling

The `hash` on a change row is not "the content now". It is the last version this
task's own holder was *shown*. Anybody may look — another agent's check-in, the
human's TUI polling twice a second — and looking brings footprints up to date
without touching a single hash. Only `confirm`, called on a holder's own
check-in *after* it has been handed the report, moves them.

The ordering is load-bearing and easy to get wrong. Confirming first would mark
an agent's copy current in the same breath as telling it the file had moved,
which is to say it would never tell it anything. Every MCP tool that witnesses
therefore does the same three steps: sweep, read, confirm.

### Off the critical path by construction

The witness is a courtesy on top of the real answer, and the failure mode it
must never have is costing an agent a call it did make in order to deliver a
report it did not ask for.

- `Witness::discover` returning `None` is an ordinary state, not an error: no
  git, no repository, no `git` on `PATH`, `witness = false`. Every tool then
  answers exactly as it did before v1.2, and the handshake omits the paragraph
  about the witness entirely rather than promising a model a field nothing will
  ever populate.
- Every sweep is wrapped and discarded on failure. There is no configuration in
  which a witness error becomes a tool error.
- No live task in the project and git is not invoked at all. The cost is only
  paid while somebody is working.
- Measured on this repository: ~8 ms for a claim, ~6 ms for a check-in, against
  0.5 ms for a tool that never looks. Three git subprocesses, against a
  heartbeat measured in minutes.

### What it feeds

Beyond the contention itself, the footprint answers two questions the queue
could not:

- **Drift.** Paths that moved under a task that none of its declared patterns
  covers come back as `undeclared` — worth saying, because every other agent's
  collision check is reading the declaration and not the edits. The advice is
  phrased conditionally when another agent is live, because in that case hird
  genuinely does not know whose edit it was.
- **Recall.** §11's memory reaches a task through *declared* files, which makes
  it depend on the previous agent having declared any — exactly the step an
  agent in a hurry skips. Witnessed paths count too, on both sides. An agent
  that said nothing and edited `src/config.rs` still leaves the file behind it,
  and what it learned still reaches whoever comes next.

Still twelve MCP tools. Like recall, the witness needed no new one: it rides
along on the calls agents already make, which is the only way a fact reaches an
agent that does not know to ask for it.

## 13. (v1.3) Plan files — the graph as data

§11 gave the queue dependencies and file scopes, which is what makes a plan
worth filing at all. It did not give anyone a way to *write one down*. In
practice a plan was a shell script:

```sh
schema=$(hird add "Design the storage schema" --path 'src/db.rs')
repos=$(hird add "Port the repository layer" --path 'src/repo/**' --needs "$schema")
```

That composes, and it stays supported. But the plan only ever exists as the act
of filing it. There is nothing to review before three agents are pointed at it,
nothing to commit next to the code it describes, no way to run it twice, and a
script that dies between two lines leaves real tasks behind missing exactly the
dependencies that were going to keep them in order.

A plan file is the same graph as data, in TOML, with symbolic names in place of
queue numbers.

### The rule that keeps it a format and not a language

**Nothing may appear in a plan that is not already stored task state.** A plan
may carry a title, body, priority, declared paths, `needs`, `requires` and the
review flag because `tasks`, `task_paths`, `task_deps` and `task_requirements`
hold exactly those. It may not carry a
conditional, a loop, a retry policy or a schedule, because there is no table
for one.

This is not fastidiousness about scope. The whole of §11 rests on agents
pulling: `task_next` is a tool an agent chooses to call, and nothing in hird
pushes work at anybody. A file that could say *when* to run something would be
describing a scheduler this queue does not have and does not want, and every
workflow language that has ever shipped grew `needs` first and `on_failure`
second. Tying the format to the schema makes the boundary structural rather
than a matter of resolve.

Two consequences follow, and both are load-bearing:

- The format is a *serialization of the queue*, so it round-trips in principle:
  a plan file and a set of rows say the same thing.
- The likely author is a model, not a person — "plan this migration" produces a
  file the human reviews. That argues for a syntax models already emit
  perfectly (TOML) over any bespoke grammar, and for spending the effort on
  validation messages rather than on notation. `deny_unknown_fields` is part of
  that: `need = [...]` is a typo worth refusing, not a field worth ignoring.

### Identity, so a plan can be applied twice

```sql
CREATE TABLE task_plan_nodes (
  task_id TEXT PRIMARY KEY REFERENCES tasks(id),
  project TEXT NOT NULL,
  plan    TEXT NOT NULL,
  node    TEXT NOT NULL,
  at      TEXT NOT NULL,
  UNIQUE (project, plan, node)
);
```

A task remembers the name the plan filed it under. Applying the same plan again
recognizes its own work and files only what the file has gained, which is what
makes a plan something to edit rather than something you get one shot at. The
name is scoped by project, so one plan file serves every checkout that uses it.

Existing tasks are never rewritten. By the time a plan is edited an agent may
have claimed a task, worked it, and recorded what it learned against it; a
title that has drifted from the file is reported (`Applied::drifted`) and the
queue's version is kept. A plan is how work is *filed*, not a description the
queue is reconciled against — hird has no mechanism for un-filing work an agent
is holding, and inventing one to serve a file would be the tail wagging the dog.

Applying is one `IMMEDIATE` transaction: every task, every edge, every
declaration, or nothing. The only refusal left at that point is a dependency
that would close a cycle *through an edge added outside the plan* — the plan's
own graph is checked for rings before anything is written — and it is the same
check and the same message `Deps::add` produces.

### Why the dry run is the point

Filing is the smaller half. `--dry-run` resolves the plan through the very same
`dispatch_waves` the board uses, and then reports the thing the queue could not
have reported until the work was already live: **pairs of tasks that declare
intersecting globs with no dependency ordering them.**

The collision detector in §11 compares a declaration against *live* claims,
which means the earliest it can speak is the moment an agent claims the second
task. But glob intersection is a decidable question about the patterns alone —
that is why §11 chose patterns over files — so the same question can be asked
of two rows that do not exist yet. A plan whose first wave lists four tasks, two
of which declare `src/tui/**` and `src/tui/view.rs`, is a three-wide plan with a
queue in it, and that is worth knowing while it is still a file.

The preview also names tasks that declare nothing, since a task with no scope is
invisible to both the collision check and recall's strongest signal.

### Still twelve MCP tools

There is no `plan_apply` tool, and this is a boundary rather than an omission.
The review step is the entire reason the file exists; an agent that could write
a plan and apply it unread would have removed it. An agent that discovers its
task is really three jobs already has `task_split`, which puts the pieces in
front of the *other* agents and keeps the human on the board rather than in the
loop.

## 14. (v1.4) Footing — memory that knows when its evidence moved

Everything hird stores about a *task* is answerable. A claim has a holder. A
declared scope has an overlap. A footprint has a diff. §12 exists because the
one thing agents could not be trusted to report was what they had actually
done, so the queue went and looked.

Memory was never held to that standard, and it is the half where it matters
most. An assertion recorded in March is served up in July in the same voice,
with the same confidence, whether the code it describes has been untouched
since or rewritten twice. That is how a shared memory stops being an asset —
not by filling up with lies, which a human would notice, but by filling up with
sentences that *were* true, which nobody notices, because reading one tells you
nothing about which kind you have.

The sentence cannot tell you. The code can.

### Migration 5

```sql
CREATE TABLE assertion_footing (
  assertion_id TEXT NOT NULL REFERENCES assertions(id),
  path         TEXT NOT NULL,
  hash         TEXT NOT NULL DEFAULT '',
  at           TEXT NOT NULL,
  PRIMARY KEY (assertion_id, path)
);

CREATE TABLE assertion_affirmations (
  assertion_id TEXT NOT NULL REFERENCES assertions(id),
  actor        TEXT NOT NULL,
  at           TEXT NOT NULL,
  PRIMARY KEY (assertion_id, actor)
);
```

An assertion's **footing** is the files it was read off and the content hash
each of them had at the time. Any later reader asks the working tree whether
that ground has moved. hird can afford this for almost nothing because §12 is
already fingerprinting files for a different reason — the whole feature is one
table, one hash per anchored file per read, and the module that decides what it
means.

### It reports, it does not judge

`Standing` has four values and none of them is `false`:

| | |
|---|---|
| `unanchored` | No files were recorded. hird has nothing to say, and says nothing. |
| `firm` | Every file it was read off still hashes to what it hashed to. |
| `shaky` | At least one does not. |
| `orphaned` | All of them are gone. |

A changed file does not falsify an assertion. A rename, a `cargo fmt` and a
total rewrite are indistinguishable from here, and a queue that announced
"this fact is now wrong" on the strength of a whitespace change would be
training every reader to ignore it. `shaky` means **unverified**, which is a
weaker claim and a far more useful one, because that set is exactly where
opening the file pays for itself.

`orphaned` is held to the strongest condition available — not one file gone,
but nothing left standing — for the same reason. An assertion about three files
of which one was deleted is shaky; the other two may still be exactly what it
describes.

### Where the footing comes from

Two sources, unioned, and the asymmetry is deliberate:

- **What the task declared**, but only its *literal* paths. A glob names a set
  nobody has enumerated, and hird will not guess at its members.
- **What the witness saw move.** This covers the agent that never declared
  anything — most of them, in practice — and a realized glob's members are in
  here already by construction: they are the files that actually changed.

An agent may also name files outright (`mem_store` gained a `paths` argument),
which is the escape hatch for a fact not tied to a task. An assertion with
neither stays unanchored, because inventing a footing for a general statement
about the project would be inventing a reason to distrust it later.

The two are not interchangeable, and `assertion_footing.named` records which
happened. **A derived footing never overwrites a named one.** Deriving is hird
being helpful where nobody said anything; overruling a stated footing — on a
finishing task, or when somebody else restates the fact — would be hird
deciding it knows better than the agent that wrote the sentence, about a file
that agent may have chosen precisely because the task never went near it. The
rule lives in `Footings::anchor` rather than at its call sites, so there is one
authority for it and no way to route around it.

### One project at a time

An anchor is a path relative to *its own* project root, and a `Witness` can
only answer for one tree. `Footings::anchors_for` therefore takes the project
it is being resolved for, and a cross-project search gets standings for the
rows hird can vouch for and silence for the rest. `hird mem standing
--all-projects` does the other thing available — discovers a witness per
project — because there it is a report rather than a hot path. Resolving
another checkout's relative paths against this one would produce answers that
look exactly like facts.

### Settling, which is what makes it quiet enough to read

A fact recorded in the third minute of a task is a statement about the code as
it was in the third minute, and by the time that task finishes its own author
has usually edited that code. Without a correction, every task would mark its
own facts shaky by its own hand, and `shaky` would mean nothing at all.

So finishing a task **settles** what it learned: re-anchors every assertion
recorded on it to the tree it is leaving behind. After that, `shaky` means
*somebody else moved this*, which is the only reading worth a warning. Like the
sweep it rides beside, it is best-effort in the strongest sense — nothing it
does may turn a completed task into a failed one.

### The way back, without a thirteenth tool

An agent that checks a shaky fact and finds it still true has exactly one way to
say so: say the fact again. It should not have to know anything else. So that is
what hird made it mean — `mem_store` with content that matches an existing
current assertion **word for word** does not duplicate it. It records this actor
as another voice for it and re-anchors it to today's code, and the answer says
`affirmed: true`.

Word for word is the deliberate bar. Two sentences that mean the same thing are
a judgement call, and a memory store that quietly merged what a model thought
were similar would be a memory store that loses facts.

Two things fall out of it. Duplicate assertions stop accumulating, which is the
oldest complaint about assertion memories. And the affirmation table counts
*voices* rather than sentences, so hird can say the thing no single harness is
positioned to say: **two agents in two different harnesses, unable to see each
other's sessions, arrived at the same fact independently.** That is a trust
signal only the process both of them talk to can produce.

### Still twelve MCP tools

`mem_store` gained an argument and `mem_search` and recall gained a field. There
is no `mem_verify`, no `mem_reaffirm` and no `mem_audit`: something an agent has
to know to ask for is something it will not ask for, and the confirmation an
agent already had a reason to perform is the one that should carry the
re-grounding. The human's audit — `hird mem standing`, and `f` in the memory
browser — is a CLI and TUI concern, because deciding what to do about a memory
that has drifted is a human's job and always was.

### Off is off

`memory_footing = false`, or a project outside git, and memory behaves exactly
as it did before any of this existed: no anchors written, no standing computed,
no `standing` field in any payload, and the server's instructions do not
mention it — a model told to read a field nothing will ever populate has been
handed a rule it cannot use and a reason to doubt the ones it can. That is the
same rule §12 lives by, for the same reason.

## 15. (v1.5) Recusal — no agent reviews its own work

Every result line in the queue was written by the agent that produced the work
it describes. `task_complete` takes a summary; the summary is the last word;
nobody else ever looks. §12 exists because that same asymmetry was intolerable
for *what an agent did*, and went and read the disk instead. It was left in
place for *whether the work was any good*.

For one agent that is not a choice — there is nobody else to ask. For a swarm
it is, and a strange one, because the single most valuable property of running
three different models on one codebase is precisely that they are not the same
model, and the cheapest way to spend that is to have them read each other.

Every harness can review code. What none of them can do is know *whose* code it
is looking at: a harness cannot see another harness's session, and an agent
asked "review this" has no way to tell whether it is being handed its own work
from an hour ago. hird can. It is the process all of them talk to, and it wrote
down who held the lease.

### Migration 6

```sql
CREATE TABLE task_recusals (
  task_id      TEXT NOT NULL REFERENCES tasks(id),
  from_task_id TEXT NOT NULL REFERENCES tasks(id),
  reason       TEXT NOT NULL DEFAULT '',
  actor        TEXT NOT NULL,
  at           TEXT NOT NULL,
  PRIMARY KEY (task_id, from_task_id),
  CHECK (task_id <> from_task_id)
);

ALTER TABLE tasks ADD COLUMN review INTEGER NOT NULL DEFAULT 0;
```

A **recusal** is one edge: *whoever worked task N must not work this one*. It is
the second kind of edge in the graph and the mirror of the first — `task_deps`
constrains *when* a task may be claimed, `task_recusals` constrains *who* may
claim it — and like dependencies it is enforced rather than annotated.

### Three decisions

**The bar is the harness, not the session.** Two Claude Code windows are one
model reading its own homework. A recusal that excluded only the exact session
would be satisfied by opening a new tab, which is to say satisfied by nothing.
`actor_harness` already exists for the badge colours; here it decides an
outcome.

**It is enforced where the claim is decided.** `claim_in_tx` checks it in the
same `IMMEDIATE` transaction as the compare-and-set, between the dependency
check and the `UPDATE`, so there is no race to win and a refused claim leaves no
trace. `claim_next` checks it too, but as a *filter* — dispatch routes around a
recused task rather than handing out something it would then refuse, because an
agent that asked for "whatever is workable" and got an error would reasonably
conclude the queue was empty.

**Who worked a task is read from the trail, not the row.** Completing clears
`claimed_by`, so `worker_of` takes the latest of the `claimed`, `completed` and
`failed` events. That gets the awkward cases right for free: work released and
picked up by somebody else is credited to whoever finished it, and a recusal
filed before anybody has worked the task bars nobody rather than locking the
queue.

**(v3.4)** The bar widened from the latest worker to **every hand that ever
held the work**. A lease that lapsed, or work released and finished by somebody
else, still leaves its first author barred: having written some of the work is
enough to be the wrong reader of it. The latest worker is still the one the
record credits and the verdict names.

### Why the review files itself

A review a human has to remember to file is a review that does not happen. This
is the same observation recall and the witness are built on — *something an
agent has to know to ask for is something it will not ask for* — pointed at the
human for once.

So `tasks.review` is a flag set when the work is filed (`hird add --review`,
`review = true` in a plan), and completing a task that carries it files the
review as an ordinary task: titled after the work, at the same priority,
**scoped to the files the witness actually saw move** rather than the ones
anybody declared, carrying the author's own summary marked as the thing under
review rather than as the brief, and recused from the task it reviews.

It declines to file in three cases, and each of them is a case where filing
would put noise on a human's board: work the witness saw no trace of, work that
`failed` — there is nothing to check, and whether the attempt is worth reading
is the human's call — and work whose previous review is still unfinished, so
reopening and re-completing cannot stack them up.

### It is a constraint, not a scheduler

A recusal says who may **not** take a task. It never says who must, nothing here
pushes work at anybody, and §13's rule holds unchanged: a plan file may carry
`review = true` because `tasks.review` is a column, and may not carry anything
that would decide *when* work runs.

The consequence is that a queue with one harness on it and a recusal in it has
one task nobody can claim. That is reported rather than papered over — a
`task_next` whose only remaining candidates are recused says so in as many
words, because "nothing is open" would send the human away from the one thing
that needs them, and the fix is to open a different tool rather than to wait.

## 16. (v1.7) The verdict — the review closes its own loop

§15 got the work in front of a second harness. It did not listen to the answer.
A review ended in prose — a `result` line saying, somewhere in its own words,
whether the work was any good — and then the loop dangled: a human had to read
the review, decide that "the error path drops the lock" means *broken*, find
the task it reviewed, reopen it, and carry the findings across by hand. Every
other hand-off in hird files itself, on the observation that something an agent
has to remember to do is something that does not happen. The one hand-off
carrying the judgment was the one left manual.

So a review ends in a **verdict**, enforced where the review ends:
`task_complete` on a task that has recusal edges requires one, and refuses one
everywhere else. Both refusals teach, because the agent reading them is
mid-completion with nobody to ask. The two verdicts name their own
consequences:

- **`upheld`** — the work stands. The judged task stays `done`, an event lands
  in its trail, and every surface (`task_list`, `task_get`, `hird show`, the
  TUI) can now distinguish *done* from *done, and seen to be done* by a harness
  that provably did not do it.
- **`sent_back`** — the work does not stand. In the same transaction as the
  review's completion, the judged task reopens with the reviewer's findings
  appended to its brief, so the next claimant — its author included — is handed
  exactly what must change without knowing to ask. The task still carries
  `review = 1`, so finishing it again files a fresh review (§15's "previous
  review still unfinished" guard has just cleared), and the loop runs round
  after round until a review upholds.

### Migration 7

```sql
CREATE TABLE task_verdicts (
  id        TEXT PRIMARY KEY,
  review_id TEXT NOT NULL REFERENCES tasks(id),
  task_id   TEXT NOT NULL REFERENCES tasks(id),
  verdict   TEXT NOT NULL CHECK (verdict IN ('upheld','sent_back')),
  worker    TEXT NOT NULL DEFAULT '',   -- whose work was judged, at that moment
  reviewer  TEXT NOT NULL,
  at        TEXT NOT NULL,
  CHECK (review_id <> task_id)
);
```

Append-only, like the event trail: a task sent back and redone accumulates one
row per round, which is what keeps the record honest about how many rounds
there were. `worker` is resolved at delivery time by the same trail-reading
`worker_of` recusal uses, so the name on a verdict does not move when the
reopened task is later picked up by somebody else.

### One invariant bends, knowingly

"Terminal statuses only leave via a human reopen" was written when nothing but
a human could be trusted to judge finished work. The recusal edge is what
changed that: a `sent_back` comes from a harness the queue *proves* did not do
the work, which is precisely the trust the human reopen was standing in for.
The status machine itself is untouched — `done → open` via `Reopen` was always
an edge; what changed is who may drive it. The human keeps the last word they
always had, and the queue never overrules them: a verdict that lands on work a
human already reopened, cancelled, or that failed since, goes on the record and
does nothing else. Only work sitting exactly where the completion left it —
`done` — is moved.

### The record

Because every verdict is delivered on the record — who judged, whose work,
which round — the queue accumulates the one measurement it is uniquely placed
to take: whose work survives a reading by a different model. `hird record`
aggregates delivered verdicts per harness, both sides: verdicts received on its
work (with a first-pass count over distinct tasks — the verdict that measures
the work as delivered, before any rework), and verdicts handed out as a
reviewer.

It is a report, not a scheduler. Nothing routes work by it — dispatch does not
read it, `task_next` does not prefer a harness by it — because the moment the
queue starts steering work toward whoever scores well, agents are being graded
by a table they can see and the table stops measuring anything. Reading it is
the human's job, and what to do about a harness that ships rework is exactly
the kind of call hird leaves to people.

### Still twelve tools

The verdict is a parameter on `task_complete`, not a thirteenth tool; the
record is a CLI report off a table that writes itself. The MCP surface §6
froze stays frozen.

## 17. (v1.8) The footprint — did this task change anything?

§12 gave every task a list of the files that moved while it was held. The list
answers "what changed?" precisely, and it answers the blunter question — "did
this change *anything*?" — ambiguously, because it comes back empty in two
opposite situations:

- the task read the code and wrote nothing, and
- hird was never watching, so it has nothing to report either way.

A front end that prints nothing in both cases invites the reader to take the
second for the first. That is the mistake this section exists to make
impossible: a finished investigation and a finished refactor arrive on the board
as the same green card, and the difference decides whether there is anything to
review, anything to test, or anything to undo.

### Three answers, never two

`Footprint` is the type, and it is deliberately three-valued:

| value | means | said as |
| --- | --- | --- |
| `Unwatched` | no baseline was ever taken: never claimed under a witness, or not a git checkout | nothing at all |
| `ReadOnly` | a baseline was taken and the tree still matches it | `read-only` |
| `Modified { paths, shared }` | the tree differs from the baseline | `modified 3 files` |

The predicate for "hird was in a position to know" is the existence of the
task's row in `task_witness` — the fingerprint taken at claim time. That is what
makes `ReadOnly` an observation rather than an absence of one, and it is why the
question is not answered off `task_changes` alone.

**No migration.** Both tables already hold everything the answer needs; v1.8 is
a reading of v1.2's evidence, not new evidence. Nothing new is written on any
call, and turning the witness off turns this off with it, in the only way it
can be turned off: hird stops having an opinion.

### What a count may not be read as

The limit from §12 carries over unchanged — one checkout has one filesystem and
no keyboards — so `Modified` says the tree moved while the task was held, not
that this task's agent moved it. Where another task in the same project holds
one of those paths in its own footprint, both were live when the file moved, and
`shared` says so: *modified 2 files, though another agent was live in some of
them*. The count is never allowed to speak with more confidence than the
evidence has earned, which is the same rule the drift advice follows.

### A running total is not a verdict

A task still being worked has not finished not writing anything, so `ReadOnly`
is rendered `read-only so far` while a lease is held and `read-only` once it is
over. `Modified` needs no such hedge: a file that moved has moved.

This is also why `FinishResult` re-says its own footprint. The last look has to
be taken while the task is still live, or the sweep would miss whatever the
agent did on its way out — so by the time the reply is assembled, the hedge in
the sentence is one call out of date. `Evidence::settled` restates it for a task
that has stopped, from the same typed answer rather than by editing a string.

### Where it shows

- `hird ls` badges each row, and now sweeps the tree as it renders — a stale
  answer here is worse than none, because a task that has been writing since the
  last sweep would be listed as read-only.
- `hird show` heads the `changed` block with the one-line answer, above the
  paths it is drawn from.
- `hird agents` says `moved  nothing yet` where an agent has been in the code
  and written none of it. An agent twenty minutes into a task with an empty
  footprint is reading, or it is stuck; a blank space says neither.
- The TUI badges every card on the queue board, writes the sentence into the
  task detail overlay, and marks a live agent's row on the Swarm screen.
- MCP reports it as `footprint`, one string, in the same flattened evidence
  block as `changed` and `contended` — absent where there is nothing to say, the
  way every other witness field is.

The board asks the question of every card it paints, twice a second, so the
repository offers it both ways: `footprint(seq)` for one task and
`footprints(scope)` for a whole board in two queries and a fold.

### Still twelve tools

`footprint` is a field on evidence agents already receive, not a thirteenth
tool. Like recall and the witness before it, it reaches an agent that did not
know to ask.

## 18. (v1.9) The ground — what a task builds on

Every dependency edge in this queue was drawn because one task needs what
another produces. That is what "the API waits for the schema" *means*: not
merely that the schema must exist first, but that the API's author needs to
know what the schema turned out to be. And until now the queue read that edge
exactly once, as a gate. The blocker goes `done`, the gate opens, the
blocker's `result` — the one sentence its finisher wrote for exactly this
moment — is dropped on the floor, and the dependent's agent starts blind
unless recall's file overlap happens to carry something across. The causal
edge, the strongest signal of relevance hird holds, was the one channel
delivering nothing.

And v1.7 quietly made the gate itself unsound. Readiness still says "only
`done` clears a dependency", but §16 made `done` revocable: a review can send
finished work back, reopening it in the same transaction as the verdict. A
dependent claimed in the window between the completion and the verdict is
building on ground that may be pulled out from under it — and when it is,
*nobody tells it*. Its readiness was checked at the claim and never again.
Its holder cannot see the verdict land. The board shows a reopened task and a
live dependent, and the one participant positioned to connect them is the
queue, which until now said nothing.

So v1.9 teaches the queue to treat the ground under a task — the finished
work it builds on — as a first-class thing: handed over, qualified, and
watched.

### The handover

`task_claim` and `task_next` answer with `built_on`: one row per finished
dependency, carrying its `seq`, title, its **own `result`** — the summary its
finisher wrote — and a `standing`. The claim is the one moment the claimant
is guaranteed to be listening, which is where every rider in hird lives, and
the read happens inside the same transaction as the compare-and-set, so the
handover describes the instant the task changed hands. `task_get` and `hird
show` carry the same block (`built on  #3 done — the schema lives in db.rs`),
and the TUI's task detail does too.

`standing` is a deliberate echo of memory's §14: both answer *"this was true
when it was written — is it still?"*, one for assertions, one for work.

| | |
|---|---|
| `done` | finished, with nothing further on record |
| `upheld` | finished and seen to be finished, by a harness that provably did not do it |
| `under review N, provisional` | finished, but the review has not delivered its verdict |

`provisional` is the honest word for the third state and the reason it must
be said: the claimant is about to spend real work on that answer, and the
difference between "settled" and "could be sent back while you build" is
exactly the difference it cannot discover for itself.

### The policy

Whether provisional ground should *hold* a dependent back is not a fact, it
is a judgement about a project's tolerance for rework — so like
`path_conflicts` before it, it is a key rather than a rule:

```toml
under_review = "clears"   # or "holds"
```

`"clears"` is the default and the old behavior with the silence removed:
`done` clears the dependency at once, and the claimant is told what it is
standing on. `"holds"` keeps dependents unclaimable until the pending review
finishes — upheld releases them; sent back reopens the work, and readiness,
being derived, re-gates them behind it automatically; a review a human
cancels abandons the hold, because the human keeps the last word they always
had. The refusal teaches, the way every refusal here does: *"task 7 is
blocked by task 3 (port the loader, done but under review 5); the work is
finished, but this queue holds dependents until the review delivers its
verdict."* And `task_next` routes around held tasks the way it routes around
recused ones, in their own bucket — `held`, with the review each waits on —
because "the work is done and the review has not been read" points a human at
a completely different fix than "the work has not happened". A pending review
is discovered from rows that already exist — an unfinished task recused from
this one is what *being* its review means (§15) — so there is no migration
and nothing new to keep consistent.

### The shift

When a sent-back verdict reopens work, its live dependents — tasks
`claimed` or `in_progress`, let through while the ground was still standing —
are the casualty the verdict cannot see. Delivery now writes a
`ground_shifted` event on each of their trails in the same transaction as the
reopen, so the record exists the moment the fact does. Open dependents get
nothing: readiness is derived, so they are simply blocked again, and their
eventual claim hands them the reopened brief anyway.

The holder itself hears at its next check-in. `task_update` answers with
`ground_shifted` — one sentence per dependency that has stopped being `done`,
computed from the graph as it stands rather than replayed from events, which
buys three things: it cannot be stale, it costs one indexed query only when
the task has edges, and it catches every way ground gives way, not just the
verdict — a blocker a human reopened, cancelled, or that failed since is
reported in the same breath, attributed no further than its status can back.
The sent-back case names its review and points at the findings: *"task 3,
which this task builds on, was sent back by review 5 and reopened; re-read it
— the findings are in its brief — before building further on its work."*
That sentence outranks the witness's advice in the reply, because a contended
file costs an edit and a sent-back foundation costs the task.

The human gets the same three sights without asking: `hird agents` and the
Swarm screen mark a live agent whose ground has shifted, and a `done` card
whose review is still open carries `under review #5` on the board — the
difference between *done* and *done, so far as anyone has checked*, visible
from across the room.

### What it deliberately does not do

The queue does not interrupt. An agent mid-edit is not stopped, its lease is
not revoked, its task is not released — hird tells, at the next moment the
agent is listening, and lets it decide, exactly as the witness does with a
contention. And nothing here re-litigates §16's restraint: a verdict still
moves only work sitting exactly where the completion left it, and the shift
report attributes a reopen to a review only when the newest verdict on
record actually is that sent-back.

### Still twelve tools

`built_on`, `held` and `ground_shifted` are fields on answers agents already
receive; the policy is a configuration key; the event is a row in a table
that existed in v1. Nothing new to call, because an agent that had to ask
"has my ground moved?" is an agent that would not ask.

## 19. (v2.0) The exhibit — the witness keeps what it saw

§12 made hird go and look. Every look ends in a hash: the witness reads a
file, fingerprints it, and throws the content away. That is enough to say
*that* `src/config.rs` moved under task 1, and it is not enough for the three
questions that follow immediately from saying so. *What* changed? — the
change rows name files, and a human or a reviewing agent is left to
reconstruct the edit from the tree as it stands, which by then may say
something else. *What did the review actually judge?* — §15 scopes the review
to the files that moved and hands the reviewer everything except the change
itself. And *where did the overwritten version go?* — §12's contention
warning exists precisely because a write can land on another agent's
uncommitted work, and when the warning comes too late the work is simply
gone. Git cannot help with any of these: nothing was committed. That is not
an edge case of agent work, it is the normal case — agents live between
commits.

So the witness keeps what it sees. The content it was already holding in
memory to hash is written, keyed by that same hash, into the database
everything else lives in.

### Migration 8

```sql
CREATE TABLE witness_blobs (
  hash    TEXT PRIMARY KEY,
  content BLOB NOT NULL,
  size    INTEGER NOT NULL,
  at      TEXT NOT NULL   -- last sighting, refreshed on re-sight
);
```

Content-addressed, so the store is deduplicated by construction — a version
seen under three tasks is one row, a file put back the way it was costs
nothing new — and the hash a baseline or a change row already carries is also
the key to what the file said. Only content the witness fingerprints by
content is kept: an oversized file was never hashed, so it is never stored,
and the exhibit inherits §12's size discipline without a second knob.

Capture rides on the sweeps that already exist. A check-in keeps the versions
its changes name; a claim keeps whatever just moved under the running tasks
plus the dirty entries of its own fresh baseline — those are the versions
that exist nowhere but the working tree, and the claim is the last moment to
keep them. A version already kept costs one indexed existence check and no
I/O, so the steady state of a sweep stores nothing.

A claim also prunes: kept versions that nothing references and that have aged
out (90 days) are deleted. A hash still named on some task's change record is
somebody's evidence and is never pruned, whatever its age. Housekeeping rides
on a rare, already-heavy call rather than on a daemon or a maintenance
command, neither of which this design will grow.

### Reading it back

The "before" of a diff is resolved from two sources, matching §12's two kinds
of knowledge: a file dirty at claim time was fingerprinted then, and its kept
version is the only copy anywhere; a file clean at claim time is asked of git
at the baseline's recorded `HEAD`, because git already holds that version and
a copy would have been redundant. The "after" is the kept version on the
task's change record — for a live task, the disk as it stands, because a
diff that stops at the last heartbeat understates what the tree already
knows.

Three readers, no new tools:

- **`hird diff <seq>`** — the uncommitted diff of what moved under a task,
  rendered by `git diff --no-index` over the kept versions so it reads
  exactly like the diffs every reader already knows. It keeps answering after
  the task is done and the tree has moved on, which is when the question is
  usually asked.
- **The review brief.** §15's review is now handed the diff of the work under
  judgement, clipped to a bounded size with the cut named and pointed at
  `hird diff` — an unmarked bound reads exactly like a diff that found
  nothing more. The completion computes it after the final sweep, while the
  record and the kept versions describe the instant the work ended, and
  passes it into the same transaction that files the review.
- **`hird salvage <seq> <path>`** — the last version the witness saw of a
  file under a task, or with `--baseline` the version the task started from.
  This is §12's headline collision carried one step past detection: the
  version the second write landed on is retrievable.

### What it can and cannot promise

The honest name is "the last version the witness saw". The witness observes
at claims, check-ins and renders, not continuously; a version that came and
went between two observations was never seen and cannot be salvaged. The
exhibit widens no observation and narrows no silence — it keeps exactly what
§12 already read, and where a version was not kept (too large, pruned,
observed before the exhibit existed) every reader says so in as many words
rather than serving the nearest thing it has. `Unkept` is a reason, not an
empty diff: a missing side rendered as "unchanged" would be the one lie this
feature exists to not tell.

### Off is off

`exhibit = false` keeps the watching and gives up the keeping: sweeps store
nothing, and the readers answer with "not kept" for versions only the store
could supply. It rides on `witness` and is off wherever that is, and a
project outside git never had either. The MCP surface is untouched — the
review diff lands in a task body, and the two commands are CLI verbs, because
recovering lost work and reading finished work are human acts.

### Still twelve tools

The exhibit adds two CLI verbs and a column of evidence to a brief that
already existed. Nothing an agent calls has changed, because nothing here is
something an agent would know to ask for — it is what the human reaches for
when the board says `modified 2 files, though another agent was live in some
of them`, and what the reviewer is handed so it does not have to ask.

## 20. (v2.1) The tenure — a task remembers every hand that held it

Every mechanism from §12 on assumes a task and its holder are one story. The
witness measures *the task* against a baseline taken at *the claim*; the
footprint is *the task's*; the diff is *the task's*. That identification is
right until the first time a task changes hands — a lease expires, work is
released, a verdict sends it back — and then it is exactly wrong, and the
code knew it: `Witnessed::begin` on a re-claim deleted the previous holder's
baseline and footprint, because crediting the new holder with the old one's
edits would have been worse.

Deleting was the bug. Consider the founding scenario of the lease: an agent
claims a task, edits three files, and dies — session killed, laptop lid,
context window burned out. The lease lapses, the sweep returns the task to
the pool, and another harness picks it up. That successor starts on a working
tree *carrying a dead agent's uncommitted edits*, indistinguishable from code
that was always there; the human sees one green-ish card and two claims that
look like one continuous task; and the only record that could have said
otherwise was destroyed by the successor's own claim, at the precise moment
it became the most valuable row in the database. The verdict loop (§16) made
this the *normal* case rather than the crash case: every `sent_back` reopens
work whose redo begins by overwriting the evidence of the round the reviewer
judged.

So the fresh measurement stops destroying and starts archiving. Each holding
of a task is a **tenure**: who held it, how the holding ended, the baseline
it was measured against, and what the witness saw move while it was live —
frozen in the same `IMMEDIATE` transaction that replaces them, which is the
only moment there is anything to freeze.

### Migration 9

```sql
ALTER TABLE task_witness ADD COLUMN holder TEXT NOT NULL DEFAULT '';

CREATE TABLE task_tenures (
  id       TEXT PRIMARY KEY,
  task_id  TEXT NOT NULL REFERENCES tasks(id),
  n        INTEGER NOT NULL,          -- 1-based round, per task
  holder   TEXT NOT NULL DEFAULT '',
  began_at TEXT NOT NULL,
  ended    TEXT NOT NULL DEFAULT '',  -- completed|failed|released|lease_expired|cancelled
  ended_at TEXT NOT NULL DEFAULT '',
  head     TEXT NOT NULL DEFAULT '',
  tree     TEXT NOT NULL DEFAULT '{}',
  archived_at TEXT NOT NULL,
  UNIQUE (task_id, n)
);

CREATE TABLE tenure_changes (
  tenure_id  TEXT NOT NULL REFERENCES task_tenures(id),
  path       TEXT NOT NULL,
  kind       TEXT NOT NULL CHECK (kind IN ('added','modified','deleted')),
  hash       TEXT NOT NULL DEFAULT '',
  first_seen TEXT NOT NULL,
  last_seen  TEXT NOT NULL,
  PRIMARY KEY (tenure_id, path)
);
```

Three decisions, each the cheaper honest one:

- **The holder is written at the claim, not reconstructed at the archive.**
  `task_witness` gains a `holder` column filled by the same call that takes
  the baseline; by archive time the task row's `claimed_by` is already the
  successor. How the holding *ended* is the one fact read from the trail —
  the newest `completed`/`failed`/`released`/`lease_expired`/`cancelled`
  event since the baseline — because the ending transitions are many and the
  archive is the one place the answer is needed.
- **The current holding is never in the archive.** `task_witness` and
  `task_changes` remain the live record and every existing reader of them is
  untouched; `n` counts finished holdings only. A task that never changes
  hands never grows a tenure row, and a project without a witness never grows
  any of this — off is off, as always.
- **Archived hashes are evidence.** The blob pruner spares anything named by
  a `tenure_changes` row, exactly as it spares the live change records, so
  `hird diff --tenure` keeps answering for as long as the round is on record.

### The handover

`task_claim` and `task_next` answer with `previously` when the task has
changed hands: one sentence naming the previous holder, how their holding
ended, and which files moved under them, ending in the `hird diff <seq>
--tenure <n>` that shows the round in full. It is computed after the archive
in the same call, so on the claim where a task changes hands the newest
tenure is exactly the holding that just ended. The claim is where every rider
in hird lives, and this one more than most: the previous holder's session is
gone, the successor was not there, and the human is looking at a board where
two claims read as one task. The queue is the only participant that saw both.

The sentence is careful the way the footprint is careful. What is on record
is what moved *while the holding was live* — not that the holder typed it,
and not that the edits are still in the tree (they may have been committed,
or reverted). What is certain is that whatever state those files were left in
is part of the tree the new baseline was just read off, so the advice is the
one that is always right: re-read those files before building on or over
them. A holding that moved nothing says so — *"there are no leftover edits to
inherit"* — because a successor told nothing would go hunting for
half-finished work that verifiably does not exist.

### The readers

- **`hird diff <seq> --tenure <n>`** — what round *n* changed, resolved from
  the archived baseline and the archived record exactly the way the live diff
  is resolved from the live ones, and stable by construction: an archived
  round is over, so its "after" is the last version the witness saw under it,
  never the disk. Round one's diff reads the same after round two rewrites
  everything, which is when somebody finally asks for it.
- **`hird salvage <seq> <path> --tenure <n>`** — §19's recovery, reaching
  rounds the live record no longer describes. The version a vanished agent
  left behind is retrievable *after* its successor has claimed, worked and
  overwritten it — the case where the old code deleted the only pointer.
- **`hird show`** — one `held` line per finished round: who, how it ended,
  what moved. The board's answer to "why does this file mention a port nobody
  finished?"
- **Recall** treats archived footprints as observed territory alongside live
  ones, so what round one learned in a file still reaches whoever works that
  file next — previously, the re-claim that archived the footprint would have
  silently cut that channel.

### Still twelve tools

`previously` is a field on an answer agents already receive, at the only
moment it can matter; `--tenure` is a flag on two CLI verbs that already
existed; the archive writes itself on a call that already ran. Nothing new to
call, because a successor that had to ask "did anyone hold this before me?"
is a successor that would not ask.

## 21. (v2.2) The herald — the one push in a pull design

Everything above is pull. `task_next` is a tool an agent chooses to call, and
that is a load-bearing decision (§11 kept it through the swarm rework): hird
never pushes work at an agent, so an agent nobody points at the queue stays
idle, and a human can always reason about who is being driven by what.

But keeping the *transport* pull left one job on the human that everything
else had been busy removing: noticing. A task that becomes claimable while
every agent is idle — the plan's next wave, a filed review, work sent back by
a verdict, a lease that lapsed — sits on the board, correct and visible and
silent, until the human sees it and goes to find an agent. The queue knew the
moment it happened; the design gave it no way to say so.

### The hook

`dispatch_hook` (config, default empty) names a command. Whenever a task
becomes claimable, hird runs it — detached, through `sh -c`, all three stdio
streams closed — with the announcement in its environment: `HIRD_EVENT` (the
cause: `filed`, `unblocked`, `review_filed`, `sent_back`, `reopened`,
`released`, `answered`, `lease_expired`), `HIRD_TASK`, `HIRD_TITLE`, `HIRD_PROJECT`, and
`HIRD_DB` so the hook's own `hird` invocations read the same board.

Three rules keep this from becoming the daemon the design forbids:

- **hird never waits and never reads the answer.** The hook is spawned after
  the transaction commits and reaped from a thread. A broken hook cannot slow
  a claim, fail a completion, or corrupt an MCP session — stdout is closed
  precisely because the server's stdout is a JSON-RPC wire.
- **Every announcement is read back from the committed board.** The repo
  answers two questions (`Deps::released_by`: which open dependents of a
  finish now wait for nothing; `Deps::claimable`: is this task open with
  nothing unmet), both evaluated after the write lands. A task an agent
  claimed in the race window is not announced; a task filed behind a gate is
  announced by the finish that clears it, not the filing.
- **The hook decides nothing.** It is told a task is waiting for hands and
  why. Scheduling stays where §13 put it: in the graph, read by `task_next`.

Announcement is tied to observation, which for every cause except
`lease_expired` is the write that causes it: `add`/`plan apply`/`task_split`
announce what they file workable, a completion announces the dependents it
released and the review it filed, a verdict announces the work it sent back
(and, under `under_review = "holds"`, the dependents its upholding released),
`task_release`/`reopen`/`dep rm` announce what they put back in reach. Expiry
has no write of its own — it is enforced lazily by sweeps (§4) — so it is
announced by whichever sweep first notices. Since every queue-touching repo
method already sweeps, every MCP tool, every CLI invocation and every TUI
refresh performs that sweep *keeping the outcome* before its real work — the
board included precisely because it is the fastest sweeper in the room, and a
sweep that discards its outcome does not leave the announcement for somebody
else, it consumes it: in a working swarm the very
next call any agent makes — a `task_update` heartbeat included — is the one
that announces a dead colleague's task, whether or not that call then
succeeds. The one cost is a small race on the claim path: a task whose own
lease just lapsed can be announced in the instant before the same call
re-claims it, which is why the skill tells a summoned agent to fall back to
`task_next`.

### Why a command and not an integration

The obvious shape was "hird talks to herdr" — the terminal multiplexer whose
`herdr agent prompt` can wake an idle agent, which is the case this feature
exists for. But herdr is one answer to "something that can address an agent",
and a config key holding a command line is all of them at once: a herdr
prompt, a desktop notification, a log line, a CI trigger. hird stays ignorant
of every one, the pairing lives in one line of the user's config, and the
skill teaches agents the herdr side (spawn a sibling in a pane, prompt it to
work the queue) without the binary knowing herdr exists.

### Still twelve tools

No new MCP tool, no daemon, no schema change. The herald is a field on the
config, two reads on the repo, and a `Command::spawn` at call sites that were
already committing the event being announced.

## 22. (v2.3) The feed — the board as a log

Every mutation in hird has landed one row in `task_events` since v1.0, and
until now that trail had exactly two readers, both narrow: `hird show`
replays one task's slice of it as history, and the TUI polls the tables the
trail is derived from. A human watching a swarm without a TUI — from a
second terminal, a CI job, a log shipper, a script that pages someone — had
nothing, and neither did any tool that wanted to build on hird rather than
inside it. The record existed; the design gave nothing a way to read it in
the order it was written.

### One command, no new writes

`hird events` is the trail read sideways: across tasks, joined to the task
each row happened on, oldest first. Nothing is stored to serve it and no
schema changes — the feed is a projection of what every mutation was
already writing, which is what makes it free to stop, restart, filter, or
never run at all.

The cursor is the `task_events` rowid, not the ULID id and not the
timestamp: two events written in one transaction share a millisecond (and
ULIDs then sort by their random tail), while the rowid never ties and never
runs backwards. `--follow` is a 500 ms poll — the TUI's cadence, against
the same WAL file, for the same reason the TUI gets away with it — that
asks for everything after the last rowid it printed. There is no
subscription state anywhere: the cursor is the trail itself, so a follower
that dies and returns has missed nothing.

### The reader enforces what it reports

A trail only carries what somebody enforced. Expiry is lazy (§4) and
witnessing happens on sweeps (§12), so a feed that only read would go quiet
exactly when the swarm does — an agent dies, nothing calls, the lease that
should lapse is enforced by nobody, and the monitor watching for that shows
nothing. So `--follow` does what any reader of the board does: it sweeps
expired leases (keeping the outcome, so the herald hears, §21) and looks at
the working tree at the TUI's witness interval. The one process guaranteed
to be running while someone is monitoring is the monitor, which makes it
the right process to enforce with.

### A verb, not a tool

The feed is deliberately not the thirteenth MCP tool. Agents already get
the trail's contents pushed at them where it matters — `contended`,
`ground_shifted`, `undeclared` ride along on calls they were making anyway
(§12, §18) — and an agent polling a feed would be an agent burning context
on events mostly about itself. The audiences that lacked a reader were
humans without a TTY worth drawing in and machines that are not MCP
clients, and both speak exit codes and lines: columns for one, `--json`
NDJSON for the other. With the herald (§21) this closes the loop hird can
honestly close without a daemon: the hook says *work is waiting*, the feed
says *here is what happened*, and both are one config key or one command
away from any tool the user already runs.

## 23. (v2.4) The routed summons — the herald says whom a task is not for

The herald (§21) closed the noticing seam: work that becomes claimable is
announced, and under a multiplexer like herdr the announcement is a summons.
But the flagship pairing — one config line, one worker —

    dispatch_hook = 'herdr agent prompt worker "hird task $HIRD_TASK is ready; work the hird queue."'

reopens that seam for exactly the tasks where a second pair of eyes matters.
A `review_filed` announcement is, by construction, a task the queue will
refuse to the harness that did the work (§15). A hook that always prompts the
same agent will sooner or later summon the author to its own review; the
claim is refused, the agent shrugs and takes something else (or nothing), and
the review sits on the board, correct and silent — waiting for the human the
herald existed to relieve. The hook could not route around this because it
was missing one fact, and it is the fact hird is uniquely positioned to know:
a harness cannot see another harness's sessions, but hird recorded who held
the lease.

### One more variable, not a router

`HIRD_RECUSED` joins the announcement's environment: the harnesses the queue
would refuse the task to, comma-separated, empty for the tasks anybody may
take. It is read off the same recusal edges the claim will consult
(`worker_of` resolution included, so a recusal on unworked tasks bars nobody
here exactly as it bars nobody there — the announcement and the refusal can
never disagree). A filed review therefore arrives naming its author's
harness, and one `case` in the hook picks different hands:

    worker=claude; case ",$HIRD_RECUSED," in *,claude-code,*) worker=codex;; esac
    herdr agent prompt "$worker" "hird task $HIRD_TASK is ready; work the hird queue."

The comma is safe as a separator because identity sanitization now strips it
from harness names, alongside the colon it already stripped: a name that
could carry a comma could forge an entry in the list.

The alternative was a roster: hird's config names the agents on duty and
their wake commands, and hird picks. Rejected for the same reason §21
rejected "hird talks to herdr" — the moment hird chooses whom to wake, it
owns liveness, addressing, and a mapping from harness names to panes,
which is to say it has become the scheduler-daemon the design forbids,
with a config schema standing in for the protocol. The decision stays
where §21 put every decision: in the user's command line. hird contributes
the one input the command line could not compute — who is barred — and
remains ignorant of what, if anything, the hook does with it.

### Still nothing new to operate

No new tool, no daemon, no schema change. `Claimable` — the form the herald
already announced in — carries the barred harnesses, filled by the same two
repo reads that screen every announcement, and the skill now tells a
summoned agent what a recusal refusal means: not an error to retry, but a
task that was never for it.

## 24. (v2.5) The question — work that knows why it is waiting

There was still one kind of blocker the dependency graph could not express.
An agent reaches a real choice in the work — whether compatibility matters,
which behavior the user intends, whether a credential or external approval is
available — and no task in the queue can answer it. The holder had two moves,
both wrong in a different direction. `task_release` put the work straight back
in dispatch, where another agent claimed it, discovered the same missing
answer, and handed it around again. `task_fail` stopped the churn, but called a
valid task failed and made the human reopen it after supplying the answer in a
channel the next claimant might never see.

So a release may now carry a **question**. The task still follows the status
machine back to `open`, but an unanswered question is a derived readiness gate:
`task_claim` refuses it by name, `task_next` routes around it into an
`awaiting_answer` bucket, and every board marks it `awaits answer`. The work is
not failed and it is not available. It is waiting on a fact only the human path
may provide.

### Migration 10

```sql
CREATE TABLE task_questions (
  id          TEXT PRIMARY KEY,
  task_id     TEXT NOT NULL REFERENCES tasks(id),
  n           INTEGER NOT NULL,
  asked_by    TEXT NOT NULL,
  question    TEXT NOT NULL,
  asked_at    TEXT NOT NULL,
  answer      TEXT,
  answered_by TEXT,
  answered_at TEXT,
  UNIQUE (task_id, n)
);

CREATE UNIQUE INDEX idx_task_questions_one_open
  ON task_questions(task_id) WHERE answer IS NULL;
```

One task may ask more than once across its life, but only one question may be
open at a time. Earlier rounds remain: a decision that changed the direction of
the implementation is task provenance, not a transient notification. Asking,
releasing the lease, and the `asked`/`released` trail entries share one
`IMMEDIATE` transaction. Answering, updating the task's recency, and the
`answered` event share another. Two humans racing to answer therefore leave one
decision, never a last-write-wins rewrite of the first.

### The human edge

`hird answer <seq> <answer>` and the TUI's `A` action are deliberately the only
answering paths. If another agent can resolve the blocker, it is work: release
normally, or split it into a task the queue can schedule and review. A question
means the queue has reached its authority boundary and needs a human or an
external automation acting through the human CLI.

The answer does not edit the task body. `task_get` shows the structured history,
and the first later `task_claim` or `task_next` carries the same `questions`
rows automatically. The claim is again the handover point: an answer important
enough to stop the work must not depend on the successor knowing to search the
event log. The tenure mechanism remains responsible for what the previous
holder left in the working tree; the question is the missing reason and
decision alongside those edits.

An unanswered release is not announced to the dispatch hook — waking another
agent would recreate the churn this feature removes. The answer is the moment
the task becomes claimable, so it announces `HIRD_EVENT=answered` after the
transaction commits and after the ordinary claimability read-back. A concurrent
claim wins quietly, as it does for every other cause.

### Who notices

The silence toward the hook has a cost worth stating plainly: every cause the
herald announces means *this task is claimable now*, and a question is the one
stall that is deliberately outside that promise. Nothing wakes anybody. A swarm
can therefore go entirely idle behind unanswered questions, and only a human
looking will know.

So the human-facing surfaces carry it instead of the hook. `hird ls` and
`hird graph` mark the row `awaits answer`; `hird show` prints the question and
the exact command that resolves it; the board badges the card and, because a
card can be off-screen in a column the eye is not on, counts them in the status
bar — `· 2 awaiting you`, in the colour it uses for work that cannot move.
`task_next` names them in `awaiting_answer` for the agent that asks, which is
what makes an agent report the stall rather than conclude the queue is empty.

A task can be waiting for an answer *and* for a dependency. It is reported in
both places rather than only the first one checked: a human told only about the
question would answer it and watch nothing move.

### Still twelve tools, and still six statuses

`question` is an optional field on `task_release`; answered history rides on
the claim; the human answers through the CLI or board. `open` remains the task's
stored status and readiness gains one derived predicate. No `blocked` or
`waiting_for_human` status is added, no lease is held while nobody can work,
and no thirteenth MCP tool gives agents the authority to answer themselves.

## 25. (v2.6) The fit — work knows what its worker must have

The queue had learned three reasons not to hand a ready task to a caller:
unfinished ground, live work in the same files, and recusal from work that
caller already did. It still treated every remaining harness as fungible.
They are not. Browser control, network access, deployment credentials, an
operating system, a GPU, and access to a particular external application are
properties of the environment around an agent, not of the model's willingness
to try.

Discovering that mismatch after a claim costs a lease and a handoff. Releasing
the task only lets the next equally unequipped session repeat it; asking a human
misstates the blocker, because the missing answer is not a decision but a
different pair of hands. A hard requirement therefore belongs in the same
readiness decision as recusal: before the compare-and-set writes anything.

### Migration 11

```sql
CREATE TABLE task_requirements (
  task_id     TEXT NOT NULL REFERENCES tasks(id),
  capability  TEXT NOT NULL,
  PRIMARY KEY (task_id, capability)
);

CREATE INDEX idx_task_requirements_capability
  ON task_requirements(capability, task_id);
```

Labels are lowercase tokens, at most 48 characters, using letters, numbers,
`.`, `-` and `_`. Hird defines no vocabulary: `browser`, `macos`,
`deploy.staging` and `gpu.cuda` mean what the human who configured the workers
says they mean. Sorting and deduplication make a set written in a plan, CLI or
environment compare the same way everywhere.

Tasks receive requirements from `hird add --requires`, `requires = [...]` in a
plan, or the `requires` field of a split piece. `hird require` is the human edit
path. A review inherits the judged work's requirements: work that needed a
browser normally needs one to reproduce and judge it too, while the human can
clear the requirement on a review that genuinely needs only its exhibit.

### The claimant says what it can do

`HIRD_CAPABILITIES` is read once when an MCP server process starts, beside
`HIRD_HARNESS`. That makes it the human-controlled half of the match: a model
does not gain deployment access by adding `deploy` to a tool argument. Named
claims with any missing requirement are refused by name before the status row
moves. `task_next` walks past them and returns an `incompatible` bucket with
each task and its missing labels, then takes the best remaining candidate.

An unset variable is an empty set. Old tasks have no requirements, so existing
registrations and queues behave exactly as they did until somebody files
constrained work. Claims return `requires`, and list/detail/TUI readers show it,
so a task that is open but not open *to this session* never looks universally
workable.

### One more routing input, still no router

The herald adds `HIRD_REQUIRES`, comma-separated, next to `HIRD_RECUSED`.
Recusal says whom not to wake; requirements say what the worker selected by the
hook must have. The hook still owns the mapping from labels to panes, harnesses
or machines. Hird has no roster, does not track which capable workers are idle,
and does not choose or start one. This preserves §23's boundary: the queue
contributes the fact only it owns and leaves addressing and liveness to the
user's command.

There are deliberately no preferred capabilities, scores, automatic installs
or fallback attempts. A requirement is a correctness constraint. Preferences
would turn `task_next` into a placement optimizer and capability labels into a
scheduler policy, neither of which a local pull queue should own.

### Still twelve tools and still six statuses

Requirements ride on task creation, plan filing and `task_split`; session
capabilities come from the environment; matching is part of the existing claim
tools. `incompatible` is an explanation on `task_next`, like `blocked`,
`deferred` and `recused`. No capability tool exists for an agent to overstate
its own environment, no stored status pretends incompatibility blocks every
worker, and no new status is needed for a predicate that changes with the
caller.

## 26. (v2.7) The reading — the queue explains itself

Five additions in one release, and none of them writes anything new. Each is a
reader over state the design already keeps, which is the argument for all
five: twenty-five sections of refusing daemons, rosters and schedulers left a
queue whose every answer is derivable — so derive them, out loud, instead of
leaving the human to reconstruct them from the board.

### `hird why` — the claim gates, answered aloud

`task_next` passing over a task is correct and silent, and the silence reads
as a bug. `hird why <seq>` runs the same gates a claim runs, in the same
order — lease, dependencies, question, recusal, requirements, overlap — and
reports each one instead of folding them into an empty hand. The verdict
comes first (`claimable no — waiting on #3 and an answer`), the evidence
after, one gate per line. What stops everyone is separated from what narrows
who: a recusal or a capability requirement does not make a task unclaimable,
so it arrives as a caveat on `yes`, not a reason for `no`. Nothing here
consults a new source; disagreement between `why` and a real claim would be a
bug in one of them, which is why both run the identical repo checks.

### `question_hook` — the herald's twin, facing the human

§24 decided a question release is deliberately not announced: it waits for a
human, not another agent, and waking an agent would only hand the stall
around. That left the human's half of the seam §21 closed for agents — a
question raised while nobody watches the board waits in silence. The
`question_hook` key is the same contract with the opposite audience: one
command, run detached through `sh -c` at the moment the gate opens, with
`HIRD_QUESTION` and `HIRD_ASKED_BY` beside the usual task facts, stdio
closed, failures swallowed. `HIRD_EVENT` is always `asked` — the word the
trail records — so one script can serve both hooks and branch on shared
vocabulary. Answering stays a human act, and the answer's announcement stays
the dispatch hook's job (`answered`, §24). Two hooks, two audiences, zero
daemons.

### `hird plan lint` — the trouble a fileable plan still carries

Parsing was already the hard gate: cycles, dangling needs, bad globs and bad
capability labels refuse to parse (§13), so lint deliberately re-checks none
of them — re-litigating parse here would let the two drift. What it reads for
is the plan that files cleanly and then disappoints: unordered tasks
declaring the same files (waves wider on paper than the queue will run them),
tasks the collision radar cannot see, a `review = true` task with no declared
scope (whose finish files no review when the witness saw nothing move, §15),
and reviews on a board where fewer than two harnesses have ever acted — a
recusal with nobody to route around. That last check is the one place hird
comes near a roster, and it stays on the right side of the line: the trail's
actors say who has shown up, never who could, and lint only reports it.
Advisories, not refusals; the plan files either way.

### `hird replay` — the board at a past moment

The trail is append-only precisely so no question about the past becomes
unanswerable (§22); this is the command that asks one. A fold over
`task_events` up to a cutoff recovers each task's status, holder and question
gate at that moment — claims, finishes, releases, expiries and answers each
imply their transition, and every way a holding ends clears the holder. The
cutoff is a string compare, exact because timestamps are stored fixed-width
(§4). What the trail does not version, replay does not invent: titles and
projects read from the present, and the output says so. Read-only, no new
rows, and doubles as a standing test of the trail's completeness ahead of
`hird sync`.

### `hird mem export` — the memory, on paper

Recall reaches agents through claims and searches, which requires reaching
the queue; a cloud harness or a fresh clone inherits nothing. Export renders
the project's current assertions as Markdown for a CLAUDE.md / AGENTS.md —
one fact per bullet, its anchors beside it — and keeps footing's honesty on
paper: a fact whose ground has moved goes out marked `re-check`, `--firm`
leaves it home entirely, and a fact that was never anchored goes out bare
rather than dressed in ground it never had (§14). One-way and human-invoked;
nothing imports, merges or rewrites, because a memory that round-trips
through prose is a memory that loses facts.

### Still twelve tools, still six statuses

All five are CLI verbs and one config key. No MCP tool was added or changed:
agents already hear their own version of `why` in every claim refusal and
`task_next` explanation, and the exports, replays and lints are the human's
readings, not the agents'.

## 27. (v2.8) The recess — the human stands the queue down

§21 and §23 made the queue live all the time: `task_next` answers whoever
asks, and a dispatch hook summons a worker within a second of a task
becoming claimable. That closed the seam where ready work sat silent, and
opened the opposite one: the human has no way to stop the hand-out. The
moment they need the tree to themselves — a rebase, a merge landing, a plan
they have stopped believing in — the choices were killing sessions or
unwiring the hook, both of which destroy state to express a pause.

`hird recess [reason]` stands one project's queue down; `hird resume` lifts
it. The decisions, in the order they were made:

**A recess stops the hand-out, not the work.** While it stands, no claim is
handed out: a named `task_claim` is refused with the reason in the sentence,
and `task_next` comes back empty-handed. Everything already claimed is
untouched — leases run, `task_update` renews, completions and failures land,
releases and splits work — because the tasks in flight are exactly the state
a pause exists to protect. The gate therefore fires only on `open` tasks,
first among the claim gates: a recess outranks questions, dependencies and
recusals because under it none of them were going to matter.

**`task_next` says which silence this is.** An agent told "nothing to do"
walks away; one told *in recess, not idle* stands by. The dispatch result
carries the recess and deliberately empty buckets — no blocked list, no
deferred list — because enumerating work the human stood the queue down over
is an invitation to act on it. Under an all-projects scope the recess stays
per-project: other queues dispatch normally, and the stood-down project's
tasks land in their own `in_recess` bucket rather than vanishing.

**The herald falls silent through the gate it already had.** Every
announcement path — filing, unblocking, answering, expiries, verdicts — runs
through one claimable check before speaking (§21), and a recess makes
nothing claimable, so the hook goes quiet without any caller knowing to ask.
`hird resume` then announces everything left claimable in the project, each
task reaching the hook as `HIRD_EVENT=resumed` — the backlog summons hands
the moment the human is ready, and not a moment before. A question answered
during a recess follows the same rule: the `answered` announcement is
swallowed by the standing recess, and the task arrives as `resumed` when it
lifts.

**Calling and lifting are human acts.** Like filing a plan (§13), so there
is no MCP tool for either and the count stays at twelve: an agent that could
declare a recess could silence the queue against its human, and an agent
that could lift one could un-pause a rebase in progress. Agents meet the
recess in refusals and dispatch answers, which ride calls they already make.
Calling it again is idempotent and refreshes the reason — the refusals stay
current — without restarting the clock, because the recess began when it
began.

**The state is a row, not an event.** One row per project — reason, actor,
called-at — and lifting deletes it. It does not ride the task trail: a
recess belongs to no task, and the feed's cursor is `task_events`. The row
itself is the record while the recess stands, and every board surface wears
it — `hird ls` and `hird graph` lead with it, `hird why` reports it as the
gate it is, the TUI status bar carries it beside the counts. No daemon and
no scheduler follow from the same shape: enforcement happens where claims
are already decided, and a recess ends when the human says so, never at a
time.

## 28. (v2.9) The picture — the graph as data, and the board in a browser

Everything the queue knew about the shape of a plan it said in words: waves
on `hird graph`, `waits #1 #3` on a card, a wave count in the swarm pane. The
picture existed only as `--dot` and `--mermaid`, a snapshot for a README. A
human watching a swarm work a twenty-task plan could see who held what and
could not see the plan.

Three things were built, in the order a reader should meet them.

### The snapshot

`hird graph --json` prints the board as one value (`src/graph.rs`): every
task in scope with its status, holder, lease, requirements, the plan and
node it was filed under, the wave it sits in (none for finished work),
`waits_for` and `feeds`, whether a question parks it, whether it is a review
or under one and the newest verdict on it; every dependency edge pointing the
way work flows; the waves; the recess if one stands; and the trail's bounds —
the first instant and the newest cursor — so a reader can resume and a
scrubber knows where to start. The renderers are readers of it: the page is
served this object, and anything else that wants to draw the board reads the
same one rather than the tables.

`--plan <name>` narrows any rendering to the tasks one plan filed and the
edges between them, read from `task_plan_nodes` (§13). The `--json` waves
are the queue's own — computed over the whole scope before narrowing, so a
plan's task that waits for work outside the plan reads in the wave it will
really be handed out in — while the text and picture renderers compute waves
over the narrowed set, because those are drawings of the plan rather than
statements about the queue. A plan name nothing here was filed from is
refused by name.

### The graph screen

A fourth TUI screen, after Swarm: one column per wave, and the finished
tasks live work still builds on in a column of their own on the left. Each
card is the queue card with one more line — `needs #1 · feeds #4` — and
selecting a card lights up its neighbours with the side they are on. Edges
are said, not drawn. That is a decision rather than a shortfall: a terminal
draws a dozen crossing arrows badly, and a screen that tried would be worse
at the thing it is good at, which is standing beside the agents. When more
waves exist than fit, the window slides to keep the selected one on screen.

### `hird web` — a viewer, not a transport

§1 wrote "no daemon / HTTP server mode" as a non-goal, and the roadmap
repeats "no daemon, no server, no accounts" as a constraint every item must
respect. Read what those rules protect: nothing hird depends on may stay up,
and no agent may need a socket to reach the queue. A viewer breaks neither,
and the TUI is already a long-lived foreground process that polls SQLite
twice a second. `hird web` is that process rendering into a browser instead
of a terminal, and it is held to exactly the TUI's posture:

- **Loopback, and it dies with the terminal.** It binds `127.0.0.1` unless
  told otherwise, one process per session, nothing installed and nothing
  with an account.
- **Read-only.** Every route is a `GET`; a `POST` is turned away before it
  is read; the page has no button that writes. Cancelling, reopening,
  answering and filing stay with the CLI and the TUI, where the human is.
- **No agent talks to it.** Harnesses reach the queue over MCP on stdio as
  before. The queue does not know it is being watched.
- **It keeps the board's duties while it runs.** It sweeps expired leases at
  the board's cadence and announces them through the herald (§21), so a tab
  left open never swallows a summons, and it looks at the working tree on
  the witness's interval (§12) as `actor = "web"`.

The line, then, is between a *screen* and a *transport*: a transport is what
an agent depends on to reach the queue, and the HTTP mode for `hird mcp` the
roadmap defers is still deferred, on its own merits.

Four routes and one stream, hand-rolled on `std::net` with a thread per
connection: the page, `/api/graph` (live, or `?at=` for a replay, `?plan=`
to narrow), `/api/task/<seq>` (the text of `hird why` and `hird show`,
because the answer a human wants when they click a node is the one those
commands already give), `/api/events` (the tail), and `/api/feed` —
server-sent events, resumable by cursor, at the poll interval. No HTTP
framework: the binary's startup time is something harnesses measure, and
this did not justify a dependency tree.

### The scrubber, and what a replay knows

Dragging the slider asks `/api/graph?at=` for the board as it stood, folded
from the trail by the same `board_at` that `hird replay` prints (§26). A
replayed snapshot says `live: false` and is honest about its limits:
status, holder and the question gate come from events, while dependencies
and requirements are the present-day rows, because the trail records those
edits as sentences rather than as reversible facts. A picture that showed an
edge as of a moment it could not know about would be inventing history; one
that shows today's edges under yesterday's statuses is showing what it can
prove, and says which is which.

### Still twelve tools, six statuses, and no new table

One repo read (`Events::bounds`), one module that reads the tables into a
value, one that serves it, and one screen. No MCP tool, no status, no
schema change, no dependency.

## 29. (v3.0) The principal — who the harness is acting for

An actor has always answered *what* is acting: `claude-code:af31`, a harness
and a session. That was the whole truth for the queue this was designed
around, where one human runs three harnesses and the interesting question is
which model did the work. On a queue more than one person files into, the
actor string answers a question nobody asked and stays silent on the one they
did.

`HIRD_IDENTITY` adds the missing half. When it is set, actors are recorded as
`<principal>/<harness>:<session>` — `ana/claude-code:af31` — and when it is
not, they are exactly the strings they were. No migration: the principal lives
in the actor column that already existed, and every reader that was parsing
`harness:session` keeps working because `actor_harness` now looks past the
prefix.

### The client may name the harness; it may never name the person

`AgentId` takes its harness from `HIRD_HARNESS`, and failing that from the
first client that names itself (§1.6) — being wrong there costs a badge in a
TUI column. The principal is deliberately not offered that second path. A
client that could name the person would be a client that could sign another
person's work, and the whole value of recording who did something is that the
record is not up to them. It comes from the environment, which is the one
place the human curates and the client never reaches, and `hird register
--identity` writes it there beside the harness name.

`sanitize` gains the separator for the same reason it already had the colon
and the comma: a harness or session that could write a `/` could claim to be
somebody. Stripping rather than rejecting keeps a badly set variable cosmetic.

### Recusal still bars the harness

The obvious next move is to make recusal bar the person, and it is wrong.
§15's bar exists because *"the single most valuable property of running three
different models on one codebase is precisely that they are not the same
model"* — the point is model diversity, not accountability. Two people driving
Claude Code at the same task are still one model reading its own work, and
letting the second one through because they are a different human would sell
exactly the property the review loop is for.

So nothing about claiming, dispatch, routing or the summons changes. The
principal is recorded and reported; it steers nothing. This is the same
posture as the witness and the record: hird measures and does not decide.

### The record grows an axis, because *whose* got ambiguous

§16 says the record measures "whose work survives a reading by a different
model." With one human those words have one meaning. With two they have two,
and only the reader knows which was intended — so the choice belongs at the
point of reading rather than in what is stored. `hird record --by person`
groups the same verdicts by principal instead of harness.

The two readings genuinely disagree, which is the point. Ana ships on Claude
Code and Ben reads it on Codex; they swap and repeat. By harness, one model
shipped everything and the other read everything. By person, both of them
shipped one and read one. Same verdicts, same table, different question.

Verdicts whose actors name nobody are left out of a person reading entirely,
rather than collected under `unknown`. An unattributed actor has no person to
credit, and inventing one would be the record steering rather than measuring.

### Still twelve tools

The principal rides in on the actor string that twelve tools were already
writing. No tool gained a parameter, no status was added, and an agent is told
who it acts for in the same handshake instructions that already tell it the
lease TTL and its capabilities — and only when there is something to tell.

## 30. (v3.1) The connection — a session is not a process

Since v1 the MCP server has held one identity, one project, one capability set
and one witness, all read from the environment and the working directory at
startup. That was not a shortcut: one process served exactly one harness
session, so *session state* and *process state* were the same words for the
same thing, and reading them once was the simplest correct implementation.

It is also the single assumption that makes a shared queue impossible. A
process serving two connections under that design serves them as one caller:
both act under one identity, scope to one project, advertise one capability
set, and are witnessed against one tree. Not degraded — wrong, and silently.

### The split

`HirdMcp` becomes two things it always was underneath:

- **`Shared`** — the database handle, the configuration, and the two hooks.
  Everything whose answer is the same whoever is asking, held once per process
  behind an `Arc`.
- **`Session`** — the identity, the project, the capabilities and the witness.
  Everything that is an answer *about the caller*, held once per connection.

One `rusqlite::Connection` behind one mutex still serializes every session's
writes, and that is not a bottleneck to apologise for: the claim CAS wanted a
single writer, and a second connection would buy concurrency the queue then has
to take back. Every field of a `Session` stays fixed for the connection's life,
for the reason `AgentId` latches its harness — a caller whose identity moved
mid-session could not find its own leases.

### Attributes, and who gets to set them

A session that can differ per connection needs somebody to say what it is.
`Attributes` is that: identity, harness, project and capabilities, each
optional, with the environment answering whatever is left unsaid. A harness
setting `HIRD_HARNESS` and nothing else behaves exactly as it did, which is
what keeps this a refactor rather than a migration.

`hird mcp` grows `--identity`, `--harness`, `--project` and `--capability` to
set them. The flags exist for one reason worth stating precisely: **a flag can
be set by somebody other than the caller.** §29 established that a client may
name its harness but never the person, and an environment variable only holds
that line while the environment belongs to the human running the harness. On a
shared queue it does not.

An SSH `authorized_keys` forced command is where the two halves meet:

```
command="hird mcp --identity ana --project /srv/acme" ssh-ed25519 AAAA… ana
```

SSH runs that line and discards whatever the far end asked for, so the identity
is a property of the key rather than a claim by the connection. That is the
whole authentication story, and it is somebody else's — which is the right
place for it. hird checks no passwords and issues no tokens.

`--project` is not a convenience in this arrangement. The server's working
directory is the server's; a remote caller's checkout is on another machine
entirely, so project detection has nothing true to find and must be told.

### What this deliberately does not do

No transport was added. `hird mcp` still speaks stdio, and SSH is what carries
it between machines — which means a harness that cannot spawn `ssh` still
cannot reach a shared queue, and the HTTP transport stays deferred with its
dependency cost unpaid. What changed is that the server is now *able* to serve
more than one session, which was the blocking half.

Nothing routes. Work crosses machines because a human says "file this" on one
side and "pick up 42" on the other. The queue still chooses nobody.

And two things get quietly worse, recorded here so their absence is a decision:
the witness reads the server's tree, which is nobody's checkout, so a shared
queue should turn it off rather than let it report about a directory no one is
editing; and the hooks run on the host, so on a shared queue they are somebody
else's tasks spawning commands on your machine.

## 31. (v3.2) The second binary — a server is a different program

§30 made the MCP server able to hold more than one session. This gives those
sessions a way in from another machine that is not SSH, and it does it in a
separate binary: `hird` stays the local queue, `hird-server` is the central
one.

### Why two binaries and not a flag

A `--http` flag on `hird` would be smaller to write and wrong. Cargo features
are additive per crate, so a flag that pulls in a web stack pulls it in for
everyone who builds the crate — and `hird`'s claim is that it is one binary,
one SQLite file, no network. That claim should be checkable, not aspirational.

As two workspace members it is: `hird-server` depends on `hird` as a library
and adds axum, hyper and tower on its own side of the line, while
`cargo tree -p hird` names none of them. CI asserts exactly that, so the
separation fails loudly rather than eroding.

It also matches what the two programs *are*. One is a thing a harness spawns
and kills a hundred times a day; the other is a thing that stays up, listens on
a socket, authenticates strangers and outlives every session it serves. Those
have different failure modes, different threat models and different reasons to
be audited.

### One endpoint per identity, not one identity per request

rmcp's `StreamableHttpService` takes a service factory with no arguments, so a
service cannot read the request that created it. The obvious response is to
resolve identity per *call* — read the token in every tool handler — and it is
the wrong one: it would thread request state through all twelve tools and make
a session's identity a thing that could differ between two calls on one
connection.

So the server inverts it. It builds **one `StreamableHttpService` per roster
entry**, each closing over the session that entry describes, and dispatch is a
map lookup on the bearer token. Identity is fixed when the endpoint is built,
which is the same invariant the local binary gets from one process per session
— arrived at differently because the constraint is different.

A request with no token, or one the roster does not know, is refused before the
database is touched, with the same answer either way so the response does not
say which tokens are real.

### The roster is a file, and it is outside the queue

Authorization lives in a TOML file the operator edits, not in a table in the
queue's own database. The queue records what happened; who is permitted to make
things happen is a different kind of fact, and keeping it outside means a
compromised queue cannot grant access to itself.

Parsing refuses the mistakes that would quietly mis-attribute work rather than
accepting them: a duplicated token (two people the queue could not tell apart),
a missing project (the server's working directory is not the caller's, so there
is nothing true to guess), a token under 24 characters, an empty roster.

An entry may pin `harness`, and when it does the pin wins over what the client
calls itself. That is §29's rule holding at a distance: a client may name its
harness, because being wrong there costs a badge, and may never name the
person. The roster is where an operator can take the first half back too.

### Capabilities per harness type, keyed on the pin and never on the name

Capabilities are per token, which already gives one person two label sets on
two harnesses: two tokens, each pinned. What that leaves is repetition — every
OpenCode worker typing the same three labels — and a `[harness.<name>]` table
of defaults removes it. A worker that pins that harness starts with the
table's labels and its own `capabilities` add to them. Union, never override:
a worker that should have fewer labels than its type pins a different type.

The rule that makes this safe is the one that decides what the table is keyed
on. §25 says no agent may overstate its own environment; §29 says a client may
name its own harness because nothing valuable hangs on the name. Keying
capabilities on the client's name would put something valuable on it — a
session wanting `browser` would call itself `opencode` — so the table is
reached only by the harness the *operator* pinned. An unpinned worker
inherits nothing, whatever its client says on the first call. The pin and the
table key are both matched after the normalization `AgentId` applies, so they
miss only when they are actually different names.

Two more refusals join the parser's list. A table no worker pins is refused,
because the likeliest cause is a typo in one of the two names and the
symptom of accepting it would be tasks quietly marked `incompatible`. And a
capability label the session would refuse is now refused at parse rather than
at the moment that one worker connects — which was true of every roster label
before this, and should not have been.

### Two lifecycles, one agent each (v3.4)

A client that opens with `initialize` gets a protocol session, and each
session is its own agent with its own suffix, as each local `hird mcp`
process is. A 2026-07-28 client has no protocol session (§6, v1.6), and rmcp
serves each of its requests on a fresh service. Until v3.4 each of those
minted a fresh suffix, so every request was a different agent: a stateless
client could claim a task and then not check in on it, because the check-in
came from a stranger.

Each roster entry now has two endpoints. Session requests go to one, as
before. Stateless requests go to the other, which serves every request as one
agent, with a suffix minted once when the server starts. That is the same
lifetime a local session has, and it has the same consequences:

- **A restart is a new session.** Leases held by the old suffix lapse back to
  the pool, as they do when a local process dies. This also keeps the audit
  honest. A suffix is declared once into `agent_sessions` (§33), so a suffix
  that survived restarts would keep stamping a model the roster had since
  changed.
- **Stateless requests on one token are one agent.** Two harnesses running
  at once and sharing a token would act as one hand: either could check in on
  the other's claim. Give each concurrently running stateless harness its own
  token, which the roster already allows.

The split is decided from headers alone. The protocol makes a 2026-07-28
request name its version in `MCP-Protocol-Version`, and a session request
carries `Mcp-Session-Id`. A wrong guess would be harmless: both endpoints
serve both lifecycles, and they differ only in how long the suffix lasts.

### What it deliberately does not do

- **No TLS.** It speaks plain HTTP and says so; a reverse proxy terminates.
  Rolling certificate handling into a binary that has a working reverse proxy
  in front of it is how it grows a configuration language.
- **No accounts, no token issuance, no OAuth.** The roster is a file. The
  MCP authorization spec — OAuth 2.1, RFC 9728 discovery, tokens bound to a
  resource — is the right answer for a queue open to more than a few known
  people, and `REMOTE.md` sets out what adopting it costs. A file is the right
  answer for two colleagues, and shipping the file first keeps the question
  open honestly.
- **No witness.** The server has no checkout worth reading. It prints a warning
  when the witness is on, because reporting about the host's own directory
  would be the design's one genuinely false report.
- **Nothing routes.** Work still crosses machines because a human says "file
  this" on one side and "pick up 42" on the other.

## 32. (v3.3) The fold — a reading is a question about something

Nine versions of readings left the command line with thirty-one entries, and
seven of them were questions about a thing another command already names. A
reading is now a flag on the command for the thing it asks about:

| Was | Is | Because it asks about |
|---|---|---|
| `hird why <seq>` | `hird show <seq> --why` | one task |
| `hird recall <seq>` | `hird show <seq> --recall` | one task |
| `hird handoff <seq>` | `hird show <seq> --brief` | one task |
| `hird blame <path>` | `hird show <path>` | one file |
| `hird replay <when>` | `hird ls --at <when>` | the board |
| `hird digest` | `hird events --digest` | the trail |
| `hird record` | `hird agents --record` | the agents |

`hird show` reads its argument as a task when it is a number (`42` or `#42`)
and as a project-relative path otherwise; `./42` names a file called 42. The
task flags refuse a path rather than guess. `ls --at` refuses `--status`, and
`events --digest` refuses the flags that shape a tail, because each pair would
be two questions at once.

Nothing about what any reading says changed; the functions behind them are
the same functions. The old names stay as hidden subcommands so scripts and
muscle memory keep working, and a test holds each one to the output of the
form it folded into. They go at the next breaking release.

`diff` and `salvage` stay commands: they read the exhibit, not the trail, and
`salvage` writes a file. `graph` stays: it is a picture, not a question.

The rule this leaves behind is the human-side twin of the twelve-tool line: a
new reading is a flag on `show`, `ls`, `events` or `agents` before it is a
command.

## 33. (v3.4) The factory — roles, gates, and work that is finished when it is in

Core hird is a queue. Tasks are claimed under leases, dependencies are
enforced, reviews file themselves and verdicts act. What it never had is a
notion of *who may do what*, or of work being *in* rather than merely done.
An AI software factory needs both. Builders build. Reviewers who built none
of the work review it. CI gates it. Humans decide. A change is finished when
it is merged, not when its author says so.

This version adds both without making the local queue any different to the
person running it. The split is three layers:

| Layer | Holds | Knows about roles? |
|---|---|---|
| `hird` (core) | Generic building blocks: a gate seam, the audit trail, attempts, merges, links | No |
| `hird-factory` (new crate) | The policy: roles, stages, the transition table, the gate | Yes |
| `hird-server` | The only way in: roles come from its roster, and it serves four more tools | Reads them |

CI checks `hird-factory` for a web stack the same way it checks `hird`.

### Core gains seams, not a second state machine

The six statuses are unchanged. Everything core gained is something a policy
can compose:

- **The gate** (`src/gate.rs`). A `Gate` is consulted *inside* the
  transactions that claim and finish work, after every core check has passed
  and before anything is written. It has `may_claim`, `may_finish`,
  `requires_review`, `escalate_after` and `holds`. A refusal rolls back like
  a recusal does, leaving no trace. Locally there is no gate. A session
  carries one only when the process serving it builds one.
- **The audit trail** (migration 13). `task_events` gains `model`, `role`,
  `from_state`, `to_state` and `evidence`. Every status move fills
  `from_state` and `to_state`. `model` and `role` are stamped from
  `agent_sessions`, which records what each actor runs as, once. Triggers
  refuse every `UPDATE` and `DELETE` on `task_events`, `task_merges` and
  `task_attempts`, and every `UPDATE` on `agent_sessions`. Append-only is now
  enforced rather than a convention. The model comes from `HIRD_MODEL`
  locally, or from the roster on the server. It is never part of the actor
  string, so §29's identity rules are untouched.
- **Merges** (migration 13). `task_merges` records that work is in, with the
  commit SHA or PR URL that proves it. A merge counts only if it comes after
  the work's latest completion in audit order, so merged work that is
  reopened and rebuilt is not merged until it is merged again.
- **Attempts** (migration 14). `task_attempts` records every rejection: who
  held the work, what model it ran, who rejected it (a review's seq, `CI`, a
  human, or the holder itself on `task_fail`), and the gate's output. The
  table is backfilled from verdicts that sent work back before it existed.
  Every claim hands the claimant the full list, with a reminder to read it.
  `max_attempts` (default `0`, off) turns every Nth rejection into a question
  asked as `hird`. The existing question gate (§24) then holds the work
  until a human answers. That is escalation without a new status, and
  without a retry loop: the queue asks, it never reschedules.
- **Links** (migration 15). `task_links` holds a task's current branch,
  worktree and pull request. Every change also lands as a `linked` event.
  The holder sets them through optional `branch`, `worktree` and `pr_url`
  parameters on `task_update`. The human uses `hird link`. Both `hird show`
  and `task_get` show them.
- **Recusal covers every holder** (§15, v3.4 note). The bar was the latest
  worker. It is now every hand that ever held the work, because a builder
  whose lease lapsed is still the builder.

### Stages are derived

`hird-factory` stores nothing core could not read. A work task's stage is
computed from core status, its reviews, verdicts, attempts, CI reports and
merges (`factory/src/stage.rs`):

| Stage | Derived from |
|---|---|
| `ready` | `open`, no unanswered question |
| `claimed` | `claimed` or `in_progress` |
| `built` | `done`, no review of it held, not upheld since its latest completion |
| `in_review` | `done`, and a review of it is held |
| `approved` | `done`, upheld after its latest completion, not merged |
| `merged` | `done`, with a merge recorded after its latest completion |
| `escalated` | `failed`, or `open` with an unanswered question |
| `cancelled` | `cancelled` |

`rejected` is not a resting stage. It is a transition: an attempt row plus a
reopen, landing in `ready` or, on the Nth attempt, `escalated`. A review task
has no stage of its own. It is the means by which work moves through
`in_review`.

### Roles come from the roster and nowhere else

A roster entry's `roles` is a set drawn from `builder`, `reviewer`, `ci` and
`human`. A `[factory]` table sets the policy (`reviewer_harness_differs`,
`max_attempts`, `require_ci_to_merge`, `require_ci_before_review`). Either
one turns the factory on for that server. No client, environment variable or
tool argument can grant a role. A worker with `builder` or `reviewer` must
pin `harness`, or the roster is refused at load. The different-harness rule
is only as strong as the harness name, and an unpinned name is whatever the
client says. An entry with no `roles` behaves exactly as before.

Each factory connection carries a `FactoryGate` built from its entry's roles,
and the twelve core tools obey it. Without that, a builder could take a
review through plain `task_claim`. The gate rules are:

- Taking a review needs `reviewer`.
- A reviewer may not have held the work in any tenure.
- Under `reviewer_harness_differs`, no harness that held the work may review
  it.
- Building needs `builder`.
- Every completion files a review, even when nothing was observed. On a
  server the working tree is somewhere else, so "nothing was observed" is
  the normal case.

### Four tools, served only by `hird-server`

| Tool | Role | Move |
|---|---|---|
| `factory_gate` | ci | Report a test run on built, in-review or approved work. A failure records an attempt, cancels any unfinished review, and sends the work back with the output. |
| `factory_merge` | ci, human | Record that approved work is in, with evidence. It needs the latest CI report to be a pass when `require_ci_to_merge` is set. It announces any dependents it frees. |
| `factory_decide` | human | `approve` or `reject` built or in-review work, `answer` an escalation, `reopen` escalated, approved, merged or cancelled work, or `cancel` unfinished work. |
| `factory_board` | any | Every work task with its stage, its builders, its attempts, and what it waits on. |

The local binary still has twelve tools, and the line in §31 holds. The four
exist only where roles exist, on a server whose operator wrote them down.
Each one runs in one `IMMEDIATE` transaction that checks the stage it moves
from, so two agents racing for the same move cannot both win.

The rules themselves are data. `factory/src/transitions.rs` has 23 rules,
and the tests drive every action, at every stage, under every role against
them: 416 cases, allowed and forbidden alike. Each forbidden case the
factory exists to prevent also has a test of its own: a builder approving
their own task, another session of the builder's harness reviewing it, and
an earlier holder whose lease lapsed reviewing it.

### Leases, and what expiry costs

Leases are unchanged, and a reviewer holds a review under a lease like any
other task. When a review lease lapses, the work goes back to `built` and
the review back to the pool. When a build lease lapses, the work goes back
to `ready`. Neither records an attempt: an agent that vanished has not been
rejected, and counting it would escalate work for a crash.

### A dependency clears only once merged

Core still clears a dependency on `done`, and `under_review = "holds"` still
waits for a verdict. In a factory neither is enough, because approved work
can still fail CI or be rejected at merge. The gate's `holds` keeps a work
task while any dependency is unmerged, and its refusal names them. The
herald consults the same hold before it announces anything. A dependent is
therefore announced by the merge that clears its last dependency, and never
by the completion or approval before it. Cycles are refused as before, on
every path.

### Watching the floor

`hird-server` serves `/watch`, the factory drawn live in a browser. It is
`hird web`'s posture moved to where the roster is:

- **It is read-only.** Every route is a `GET`, and the page has no button
  that writes.
- **It asks for a token.** The page itself carries no data. Its two data
  routes (`/watch/api/floor` and `/watch/api/task/{seq}`) take any roster
  token, refused with the same answer the MCP endpoint gives, because any
  role may read the board. They show only the caller's project.
- **It shows no tokens.** The crew is drawn from the roster's identities,
  harnesses, roles and models.

The page polls once a second, and each poll sweeps expired leases first, as
`hird web` does, so a builder who walked away shows as gone rather than as
working. One answer carries the whole board and the trail since the page's
cursor, read with `Audit::trail` in insertion order. The page finds each
move by comparing stages between polls rather than from event kinds, because
a stage is derived and the trail records statuses. That is what drives the
animation: a card slides to its new lane, and a dot runs along the pipeline
from the old stage to the new one.

`examples/factory-floor.py` (`just floor`) gives it something to watch. It
starts a throwaway server and plays a crew through a release over real MCP
calls: builders, reviewers, CI, a human, a lapsed lease and an escalation.
The first run of it found a bug no test had. The factory's forced review
was being filed for reviews too, so every verdict filed a review of the
review. That bug is now fixed and has a test of its own.

### Getting started: `hird-server quickstart`

A factory is four kinds of token, a policy, and a harness configured per
token. That is a lot to get right before seeing anything work, so
`hird-server quickstart` writes all of it into one directory and says what to
do next:

- **The roster** has fresh 32-byte tokens from the operating system. The
  person running it is `human`, and each agent harness asked for (`claude-code`
  and `codex` unless told otherwise) gets one token with both `builder` and
  `reviewer`. That is the smallest crew in which every piece of work has a
  reviewer, because no harness may review what it built.
- **A playground** is the project unless `--project` names one: a fresh git
  repository with a three-task sample release filed, the second and third
  waiting on the first. The person's own code is never touched the first
  time.
- **The derived files** are a connection snippet per harness, with its
  token, and `ci` and `human` scripts that make one 2026-07-28 tool call per
  command over curl. Without the scripts the guide would have to teach
  JSON-RPC before it could teach the factory. With them, CI is the person
  running the tests.
- **The guide** is printed, saved as `GUIDE.md`, and then the server runs
  as `hird-server --roster` would, with the witness off.

The directory is the state. A second run reads the roster back instead of
writing one, so tokens already pasted into a harness keep working, and it
files the sample only into a database it created. Every file holding a token
is written owner-only. Nothing here is a second way to configure a server:
the roster is an ordinary roster, and `hird-server --roster` serves it the
same way.

### What it deliberately does not do

- **No router, no scheduler.** Roles say who *may* take a task, never who
  *will*. Work is still pulled: `task_next` hands a builder the next task its
  gate allows, and the dispatch hook still only announces. Escalation asks a
  human. It does not retry.
- **No stored stage.** A stage column would be a second source of truth
  that could disagree with the first.
- **No factory without a server.** Locally, the person running the queue
  is every role at once, and gating them against themselves would be
  ceremony. The building blocks (attempts, merges, links and the audit
  trail) are there locally all the same.
- **No CI integration.** CI is a role with a token. It reports what it ran
  and records merges, and how it learns about work is its own business.