uptrakit-wire 0.0.3

Uptrakit shared wire protocol: WS, NATS, and REST message types
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
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
asyncapi: 3.0.0
info:
  title: Uptrakit Service-Controller Protocol
  version: 0.0.3
  description: 'Generated from the Rust wire types (uptrakit-wire). Do not edit by hand; regenerate with the golden test in tests.rs (UPDATE_ASYNCAPI=1). Protocol narrative (enrollment lifecycle, CSR issuance, reconnection semantics): docs/api/wire-protocol.md.'
channels:
  service:
    address: /api/v1/ws/service
    messages:
      audit_event:
        $ref: '#/components/messages/audit_event'
      batch_update_result:
        $ref: '#/components/messages/batch_update_result'
      delete_service_config:
        $ref: '#/components/messages/delete_service_config'
      disconnecting:
        $ref: '#/components/messages/disconnecting'
      discovery_results:
        $ref: '#/components/messages/discovery_results'
      enroll:
        $ref: '#/components/messages/enroll'
      ping:
        $ref: '#/components/messages/ping'
      register:
        $ref: '#/components/messages/register'
      renew_certificate:
        $ref: '#/components/messages/renew_certificate'
      report_hosts:
        $ref: '#/components/messages/report_hosts'
      report_plugin_config:
        $ref: '#/components/messages/report_plugin_config'
      request_certificate:
        $ref: '#/components/messages/request_certificate'
      service_trigger_host_batch_update:
        $ref: '#/components/messages/service_trigger_host_batch_update'
      service_trigger_update:
        $ref: '#/components/messages/service_trigger_update'
      stdin_attention:
        $ref: '#/components/messages/stdin_attention'
      store_service_config:
        $ref: '#/components/messages/store_service_config'
      surface_action_request:
        $ref: '#/components/messages/surface_action_request'
      surface_action_response:
        $ref: '#/components/messages/surface_action_response'
      surface_registration:
        $ref: '#/components/messages/surface_registration'
      test_plugin_config_result:
        $ref: '#/components/messages/test_plugin_config_result'
      update_output:
        $ref: '#/components/messages/update_output'
      update_result:
        $ref: '#/components/messages/update_result'
      update_started:
        $ref: '#/components/messages/update_started'
      version_check_results:
        $ref: '#/components/messages/version_check_results'
      workload_claim:
        $ref: '#/components/messages/workload_claim'
      workload_release:
        $ref: '#/components/messages/workload_release'
      access_invalidated:
        $ref: '#/components/messages/access_invalidated'
      approved:
        $ref: '#/components/messages/approved'
      broadcast_admin_event:
        $ref: '#/components/messages/broadcast_admin_event'
      ca_bundle_updated:
        $ref: '#/components/messages/ca_bundle_updated'
      certificate:
        $ref: '#/components/messages/certificate'
      check_versions:
        $ref: '#/components/messages/check_versions'
      discover_software:
        $ref: '#/components/messages/discover_software'
      enrolled:
        $ref: '#/components/messages/enrolled'
      error:
        $ref: '#/components/messages/error'
      execute_batch_update:
        $ref: '#/components/messages/execute_batch_update'
      execute_update:
        $ref: '#/components/messages/execute_update'
      host_connectivity_updated:
        $ref: '#/components/messages/host_connectivity_updated'
      pong:
        $ref: '#/components/messages/pong'
      rejected:
        $ref: '#/components/messages/rejected'
      report_plugin_config_response:
        $ref: '#/components/messages/report_plugin_config_response'
      request_ca_rotation:
        $ref: '#/components/messages/request_ca_rotation'
      request_cert_renewal:
        $ref: '#/components/messages/request_cert_renewal'
      request_crl_renewal:
        $ref: '#/components/messages/request_crl_renewal'
      reset_data:
        $ref: '#/components/messages/reset_data'
      server_restarting:
        $ref: '#/components/messages/server_restarting'
      service_config_ack:
        $ref: '#/components/messages/service_config_ack'
      service_config_delivery:
        $ref: '#/components/messages/service_config_delivery'
      service_config_updated:
        $ref: '#/components/messages/service_config_updated'
      service_credentials:
        $ref: '#/components/messages/service_credentials'
      service_settings:
        $ref: '#/components/messages/service_settings'
      set_update_freeze:
        $ref: '#/components/messages/set_update_freeze'
      software_states:
        $ref: '#/components/messages/software_states'
      software_states_changed:
        $ref: '#/components/messages/software_states_changed'
      surface_action_cancel:
        $ref: '#/components/messages/surface_action_cancel'
      test_plugin_config:
        $ref: '#/components/messages/test_plugin_config'
      token_revoked:
        $ref: '#/components/messages/token_revoked'
      update_stdin_data:
        $ref: '#/components/messages/update_stdin_data'
      workload_claim_announcement:
        $ref: '#/components/messages/workload_claim_announcement'
      workload_claim_result:
        $ref: '#/components/messages/workload_claim_result'
      workload_claim_sync_request:
        $ref: '#/components/messages/workload_claim_sync_request'
      workload_claim_sync_response:
        $ref: '#/components/messages/workload_claim_sync_response'
operations:
  sendToController:
    action: send
    channel:
      $ref: '#/channels/service'
    messages:
    - $ref: '#/channels/service/messages/audit_event'
    - $ref: '#/channels/service/messages/batch_update_result'
    - $ref: '#/channels/service/messages/delete_service_config'
    - $ref: '#/channels/service/messages/disconnecting'
    - $ref: '#/channels/service/messages/discovery_results'
    - $ref: '#/channels/service/messages/enroll'
    - $ref: '#/channels/service/messages/ping'
    - $ref: '#/channels/service/messages/register'
    - $ref: '#/channels/service/messages/renew_certificate'
    - $ref: '#/channels/service/messages/report_hosts'
    - $ref: '#/channels/service/messages/report_plugin_config'
    - $ref: '#/channels/service/messages/request_certificate'
    - $ref: '#/channels/service/messages/service_trigger_host_batch_update'
    - $ref: '#/channels/service/messages/service_trigger_update'
    - $ref: '#/channels/service/messages/stdin_attention'
    - $ref: '#/channels/service/messages/store_service_config'
    - $ref: '#/channels/service/messages/surface_action_request'
    - $ref: '#/channels/service/messages/surface_action_response'
    - $ref: '#/channels/service/messages/surface_registration'
    - $ref: '#/channels/service/messages/test_plugin_config_result'
    - $ref: '#/channels/service/messages/update_output'
    - $ref: '#/channels/service/messages/update_result'
    - $ref: '#/channels/service/messages/update_started'
    - $ref: '#/channels/service/messages/version_check_results'
    - $ref: '#/channels/service/messages/workload_claim'
    - $ref: '#/channels/service/messages/workload_release'
  receiveFromController:
    action: receive
    channel:
      $ref: '#/channels/service'
    messages:
    - $ref: '#/channels/service/messages/access_invalidated'
    - $ref: '#/channels/service/messages/approved'
    - $ref: '#/channels/service/messages/broadcast_admin_event'
    - $ref: '#/channels/service/messages/ca_bundle_updated'
    - $ref: '#/channels/service/messages/certificate'
    - $ref: '#/channels/service/messages/check_versions'
    - $ref: '#/channels/service/messages/discover_software'
    - $ref: '#/channels/service/messages/enrolled'
    - $ref: '#/channels/service/messages/error'
    - $ref: '#/channels/service/messages/execute_batch_update'
    - $ref: '#/channels/service/messages/execute_update'
    - $ref: '#/channels/service/messages/host_connectivity_updated'
    - $ref: '#/channels/service/messages/pong'
    - $ref: '#/channels/service/messages/rejected'
    - $ref: '#/channels/service/messages/report_plugin_config_response'
    - $ref: '#/channels/service/messages/request_ca_rotation'
    - $ref: '#/channels/service/messages/request_cert_renewal'
    - $ref: '#/channels/service/messages/request_crl_renewal'
    - $ref: '#/channels/service/messages/reset_data'
    - $ref: '#/channels/service/messages/server_restarting'
    - $ref: '#/channels/service/messages/service_config_ack'
    - $ref: '#/channels/service/messages/service_config_delivery'
    - $ref: '#/channels/service/messages/service_config_updated'
    - $ref: '#/channels/service/messages/service_credentials'
    - $ref: '#/channels/service/messages/service_settings'
    - $ref: '#/channels/service/messages/set_update_freeze'
    - $ref: '#/channels/service/messages/software_states'
    - $ref: '#/channels/service/messages/software_states_changed'
    - $ref: '#/channels/service/messages/surface_action_cancel'
    - $ref: '#/channels/service/messages/surface_action_request'
    - $ref: '#/channels/service/messages/surface_action_response'
    - $ref: '#/channels/service/messages/test_plugin_config'
    - $ref: '#/channels/service/messages/token_revoked'
    - $ref: '#/channels/service/messages/update_stdin_data'
    - $ref: '#/channels/service/messages/workload_claim_announcement'
    - $ref: '#/channels/service/messages/workload_claim_result'
    - $ref: '#/channels/service/messages/workload_claim_sync_request'
    - $ref: '#/channels/service/messages/workload_claim_sync_response'
components:
  schemas:
    AttestationStatus:
      description: 'Open wire string (unknown values are forward-compatible). Known values: Verified, NotFound, Unverified.'
      type: string
    BatchUpdateItem:
      description: A single software item within a batch update request.
      type: object
      properties:
        host_software_item_id:
          description: Host software item entity ID.
          type: string
          format: uuid
        update_history_id:
          description: Update history record ID (pre-created by the controller).
          type: string
          format: uuid
        package_identifier:
          description: Plugin-specific package identifier (e.g., APT package name).
          type: string
        to_version:
          description: Target version to install.
          type: string
        release_info:
          description: Optional release metadata from the upstream source.
          anyOf:
          - $ref: '#/components/schemas/ReleaseInfo'
          - type: 'null'
      required:
      - host_software_item_id
      - update_history_id
      - package_identifier
      - to_version
    BatchUpdateItemResult:
      description: Result of updating a single item within a batch operation.
      type: object
      properties:
        host_software_item_id:
          description: Host software item entity ID.
          type: string
          format: uuid
        update_history_id:
          description: Update history record ID.
          type: string
          format: uuid
        status:
          description: Final status of this item's update.
          $ref: '#/components/schemas/UpdateFinalStatus'
        output:
          description: Accumulated output from the update.
          type: string
        installed_version:
          description: Detected installed version after the update (if detection succeeded).
          type:
          - string
          - 'null'
        error:
          description: Error message if the update failed.
          type:
          - string
          - 'null'
      required:
      - host_software_item_id
      - update_history_id
      - status
      - output
    Capability:
      description: 'Open wire string (unknown values are forward-compatible). Known values: graceful_shutdown, update_tracking, software_discovery, ssh_remote, update_hooks, scheduler, database_access, nats_access, master_key_access, ca_management, system_service, ui_surfaces, interactive_updates, reset_data, workload_claims.'
      type: string
    ConfigTestKind:
      description: The kind of configuration test to perform on the agent.
      oneOf:
      - description: Execute `detect_installed_version()` and return output + detected version.
        type: string
        const: version_detection
      - description: Validate update_command syntax (sh -n check, do NOT execute).
        type: string
        const: update_command_validation
      - description: Execute pre-update hook with mock context.
        type: string
        const: pre_update_hook
      - description: Execute post-update hook with mock context.
        type: string
        const: post_update_hook
      - description: Test connectivity for controller-side plugins (`fetch_releases`).
        type: string
        const: connectivity
    DisconnectReason:
      description: 'Open wire string (unknown values are forward-compatible). Known values: shutdown, restart.'
      type: string
    DiscoveredSoftware:
      description: |-
        A piece of software discovered on the local system by a plugin.

        `installed_version` is required — plugins that cannot determine a version
        must omit the item from results entirely.

        This type is the canonical shared definition used in both the agent/plugin
        layer and the wire protocol. The `uptrakit-plugin-core` crate re-exports it.

        # Discovery targets

        The `targets` field drives plugin-config creation and role assignment on the
        controller. When non-empty, the controller processes each target generically
        (find-or-create plugin config, create role assignments). When empty, the
        controller falls back to the `plugin_config_id` on the enclosing
        `DiscoveryPluginResult`.

        The `extra` field is purely informational metadata (e.g. Docker's container
        names) — the controller never interprets it for config synthesis.

        # Per-row qualifier

        The `qualifier` field selects which `host_software_item` row to create or
        reuse. `None` = unqualified (default behaviour, one row per software item per
        host). Docker uses the container name here so that each container gets its
        own tracking row even when multiple containers run the same image.

        # Plugin package identifier

        `plugin_package_identifier`, when set, overrides `package_identifier` as the
        value stored in `host_software_item_plugin.package_identifier` for plugin
        operations. `None` = use `package_identifier` (existing behaviour).

        # Pinning

        When `featured` is `true`, the controller marks the software item as
        featured on first creation so it gets individual MQTT entities and
        prominent visibility. Default `false` — item starts unfeatured
        (bulk/aggregate view only). The controller only applies `featured: true`
        when **creating** a new `software_items` row. Subsequent discoveries do
        not override a user's manual feature/unfeature choice.
      type: object
      properties:
        package_identifier:
          description: Plugin-specific identifier for this software (e.g., package name, app slug).
          type: string
        name:
          description: Human-readable display name.
          type: string
        installed_version:
          description: Currently installed version (required; plugins omit items with unknown versions).
          type: string
        targets:
          description: |-
            Target plugin configurations for managing this item.

            Empty = use the discovering plugin's own config for all roles.
          type: array
          items:
            $ref: '#/components/schemas/DiscoveryTarget'
        extra:
          description: |-
            Optional informational metadata (not used for config synthesis).

            Example: Docker's `{"containers": ["web-server"]}`.
        qualifier:
          description: |-
            Row discriminator within `host_software_items`.

            `None` = unqualified (default). Docker sets this to the container name
            so that each container produces its own `host_software_item` row even
            when multiple containers run the same image.
          type:
          - string
          - 'null'
        plugin_package_identifier:
          description: |-
            Override for the `package_identifier` stored in
            `host_software_item_plugin.package_identifier`.

            `None` = use `package_identifier` (existing behaviour).
          type:
          - string
          - 'null'
        featured:
          description: |-
            When `true`, the controller marks the software item as featured on
            first creation. Default `false` — item starts unfeatured.
          type: boolean
          default: false
        installed_display_version:
          description: |-
            Plugin-provided display version for the installed version (e.g. Docker image publish date).
            `None` when the plugin cannot determine a display version during discovery.
          type:
          - string
          - 'null'
      required:
      - package_identifier
      - name
      - installed_version
    DiscoveryPluginAssignment:
      description: A single plugin assignment inside a [`DiscoverSoftwarePayload`].
      type: object
      properties:
        plugin_config_id:
          description: Pre-existing plugin config ID, or `None` for a default/auto run.
          type:
          - string
          - 'null'
          format: uuid
        plugin_type:
          description: Plugin type to use for discovery.
          $ref: '#/components/schemas/PluginTypeId'
        config:
          description: Plugin-specific configuration (`{}` for default assignments).
      required:
      - plugin_type
      - config
    DiscoveryPluginResult:
      description: Result for a single plugin inside a [`DiscoveryResultsPayload`].
      type: object
      properties:
        plugin_config_id:
          description: |-
            Echoed from [`DiscoveryPluginAssignment`] so the controller can route
            results to the correct `PluginConfig` row.
          type:
          - string
          - 'null'
          format: uuid
        plugin_type:
          description: Plugin type that produced these results.
          $ref: '#/components/schemas/PluginTypeId'
        discoveries:
          description: Discovered software items (empty on error).
          type: array
          items:
            $ref: '#/components/schemas/DiscoveredSoftware'
        error:
          description: Plugin-level error message, if discovery failed.
          type:
          - string
          - 'null'
      required:
      - plugin_type
    DiscoveryTarget:
      description: |-
        A structured target that tells the autodiscovery controller exactly which
        plugin config (and role assignments) to create for a discovered software item.

        Plugins emit `DiscoveryTarget` values inside [`super::DiscoveredSoftware::targets`]
        so that the web-API controller can process them generically — without any
        plugin-specific synthesis logic.

        # Examples

        PHS plugin discovering a GitHub-managed app (fetch releases only; the
        `owner/repo` is expressed as the `package_identifier` override):

        ```
        # use uptrakit_shared_types::{DiscoveryTarget, PluginTypeId, PluginRole, plugin_ids};
        let target = DiscoveryTarget {
            plugin_type: plugin_ids::RELEASES_GITHUB.clone(),
            plugin_config: serde_json::json!({
                "tag_strip_prefix": "v",
                "include_prereleases": false,
            }),
            plugin_config_name: "GitHub Releases".to_string(),
            roles: vec![PluginRole::FetchReleases],
            package_identifier: Some("BookLore/BookLore".to_string()),
            config_override: None,
            execution_site: None,
        };
        ```
      type: object
      properties:
        plugin_type:
          description: |-
            Target plugin type (may differ from the discovering plugin).

            For example, the PHS plugin discovers software but targets
            `releases.github` or `package-manager.apt` for tracking.
          $ref: '#/components/schemas/PluginTypeId'
        plugin_config:
          description: |-
            Config JSON for find-or-create of the target plugin config.

            The controller will search for an existing active plugin config
            whose JSON matches this value, or create a new one.
        plugin_config_name:
          description: Display name for auto-created plugin config (e.g. "BookLore/BookLore").
          type: string
        roles:
          description: |-
            Which roles this target covers.

            Typically all three: `DetectVersion`, `FetchReleases`, `ExecuteUpdate`.
          type: array
          items:
            $ref: '#/components/schemas/PluginRole'
        package_identifier:
          description: |-
            Package identifier override (None = same as parent `DiscoveredSoftware`).

            Used when the target plugin needs a different identifier than the
            discovering plugin's slug (e.g. PHS slug → APT package name).
          type:
          - string
          - 'null'
        config_override:
          description: Per-assignment config override.
        execution_site:
          description: Execution site hint (`"auto"` | `"agent"` | `"controller"`; None = `"auto"`).
          type:
          - string
          - 'null'
      required:
      - plugin_type
      - plugin_config
      - plugin_config_name
      - roles
    EnrollmentStatus:
      description: 'Open wire string (unknown values are forward-compatible). Known values: pending, approved.'
      type: string
    ErrorCode:
      description: 'Open wire string (unknown values are forward-compatible). Known values: bad_request, enrollment_failed, not_approved, forbidden, certificate_error, internal_error, sequence_error.'
      type: string
    HostConnectivityUpdate:
      description: Connectivity status for a single host, used in [`HostConnectivityUpdatedPayload`].
      type: object
      properties:
        host_id:
          description: Host UUID.
          type: string
          format: uuid
        online:
          description: Whether the agent is currently connected (`true` = online, `false` = offline).
          type: boolean
        last_seen_at:
          description: Timestamp of last agent activity (ISO 8601). `null` when unavailable.
          type:
          - string
          - 'null'
        agent_version:
          description: Agent binary version. Present on connect; `null` on disconnect.
          type:
          - string
          - 'null'
      required:
      - host_id
      - online
    HostInfo:
      description: Information about the host machine running the agent.
      type: object
      properties:
        machine_id:
          description: |-
            Persistent machine identifier (e.g. `/etc/machine-id` on Linux, `IOPlatformUUID` on macOS).

            Falls back to `"unknown"` if the identifier cannot be read.
          type: string
        os_type:
          description: Operating system type (e.g. "linux", "macos").
          type:
          - string
          - 'null'
        os_version:
          description: Operating system version (e.g. "Ubuntu 24.04 LTS").
          type:
          - string
          - 'null'
        architecture:
          description: CPU architecture (e.g. "x86_64", "aarch64").
          type:
          - string
          - 'null'
        hostname:
          description: Hostname reported by the agent/host machine.
          type:
          - string
          - 'null'
        ip_address:
          description: Network address of the host (SSH target address for SSH agent hosts).
          type:
          - string
          - 'null'
        agent_host_id:
          description: |-
            Agent-local UUID assigned to this host at bootstrap time.

            When present, the controller uses this as `hosts.id` when creating a
            new row, ensuring agent and controller share the same UUID. This is
            required for plugin FK operations (e.g. Proxmox host mapping) that
            reference `hosts.id` before the controller has generated its own UUID.
          type:
          - string
          - 'null'
          format: uuid
        features:
          description: |-
            Agent-probed host features (e.g. `["posix_shell", "privilege_escalation", "systemd"]`).

            `None` for legacy agents that predate feature reporting. Uses `Vec<String>`
            (not `BTreeSet<HostFeature>`) on the wire for forward-compatibility: if a
            newer agent reports a feature the controller doesn't know, it is stored
            losslessly and ignored by `HostCapabilities` parsing.
          type:
          - array
          - 'null'
          items:
            type: string
      required:
      - machine_id
    HostPackageSummary:
      description: |-
        Per-host aggregate summary of unpinned (unfeatured) software items.

        Included in [`SoftwareStatesPayload`] to surface overall update
        status per host to Home Assistant via a single `update` entity per host.
      type: object
      properties:
        host_id:
          description: Host UUID.
          type: string
          format: uuid
        hostname:
          description: Human-readable hostname.
          type: string
        friendly_name:
          description: User-defined display name for the host.
          type: string
          default: ''
        pending_count:
          description: Count of items where `installed_version != latest_version` (both known).
          type: integer
          format: uint32
          minimum: 0
        security_pending_count:
          description: |-
            Count of items where `update_category = "security"` AND versions differ.

            Used to drive the per-host security updates entity in Home Assistant.
          type: integer
          format: uint32
          minimum: 0
        total_count:
          description: Total count of enabled, non-deactivated unfeatured items for this host.
          type: integer
          format: uint32
          minimum: 0
        update_in_progress:
          description: Whether a batch update is currently pending or in progress for this host.
          type: boolean
        bugfix_count:
          description: |-
            Count of pending packages where `update_category = "bugfix"`.

            Defaults to `0` when absent (older controller that does not compute this field).
          type: integer
          format: uint32
          minimum: 0
          default: 0
        feature_count:
          description: |-
            Count of pending packages where `update_category = "feature"`.

            Defaults to `0` when absent (older controller that does not compute this field).
          type: integer
          format: uint32
          minimum: 0
          default: 0
      required:
      - host_id
      - hostname
      - pending_count
      - security_pending_count
      - total_count
      - update_in_progress
    HostStateMetadata:
      description: |-
        Per-host metadata published to MQTT for MQTT-browser visibility and Home Assistant.

        Included in [`SoftwareStatesPayload`]. All fields are sourced exclusively
        from the shared DB — safe for multi-controller deployments.

        Intentionally excludes `ip_address` (network topology risk) and `agent_online`
        (must come from the event-driven [`HostConnectivityUpdatedPayload`]).
      type: object
      properties:
        host_id:
          description: Host UUID.
          type: string
          format: uuid
        hostname:
          description: Hostname as reported by the agent.
          type: string
        friendly_name:
          description: User-defined display name.
          type: string
        os_type:
          description: Operating system type (e.g. `"linux"`, `"macos"`). `null` when unknown.
          type:
          - string
          - 'null'
        os_version:
          description: Operating system version (e.g. `"Ubuntu 24.04 LTS"`). `null` when unknown.
          type:
          - string
          - 'null'
        architecture:
          description: CPU architecture (e.g. `"x86_64"`, `"aarch64"`). `null` when unknown.
          type:
          - string
          - 'null'
        tags:
          description: Organisational tag names assigned to this host (e.g. `["production", "web-server"]`).
          type: array
          items:
            type: string
          default: []
        agent_version:
          description: |-
            Agent binary version string (e.g. `"0.2.1"`). `null` when never connected.

            Sourced from `services.client_version` for the newest approved, non-deactivated
            agent linked to this host.
          type:
          - string
          - 'null'
        agent_last_seen_at:
          description: |-
            ISO 8601 timestamp of when the agent last sent a message.

            Sourced from `services.last_seen_at`. `null` when never seen.
          type:
          - string
          - 'null'
      required:
      - host_id
      - hostname
      - friendly_name
    OutputStreamType:
      description: Output stream source for update execution output lines.
      type: string
      enum:
      - stdout
      - stderr
      - pre_hook
      - post_hook
      - system
    PluginAssignment:
      description: A plugin assignment for a specific role in a version check or update.
      type: object
      properties:
        plugin_type:
          description: The plugin type (e.g. github_releases, apt, homebrew).
          $ref: '#/components/schemas/PluginTypeId'
        package_identifier:
          description: Package identifier for this role's plugin.
          type: string
        config:
          description: Merged plugin config (base + override).
      required:
      - plugin_type
      - package_identifier
      - config
    PluginRole:
      description: 'Open wire string (unknown values are forward-compatible). Known values: detect_version, fetch_releases, execute_update, pre_update_hook, post_update_hook.'
      type: string
    PluginTypeId:
      description: |-
        Opaque plugin type identifier — validated at the catalog boundary.

        Uses `Cow<'static, str>` so well-known constants are zero-allocation borrows
        while DB/wire values are owned strings. Both are the same type.

        This replaces `PluginType` enum. Instead of matching on variants, code looks up
        the `PluginTypeId` in the `PluginCatalog` to get a `PluginDescriptor`.
      type: string
    ReleaseAsset:
      description: A downloadable asset attached to a release.
      type: object
      properties:
        name:
          description: Asset filename.
          type: string
        download_url:
          description: Direct download URL.
          type: string
        size:
          description: File size in bytes, if known.
          type:
          - integer
          - 'null'
          format: uint64
          minimum: 0
        content_type:
          description: MIME content type, if known.
          type:
          - string
          - 'null'
        sha256_digest:
          description: SHA-256 digest from the release checksums file, if available.
          type:
          - string
          - 'null'
      required:
      - name
      - download_url
    ReleaseInfo:
      description: |-
        Simplified release info for update execution context.

        Contains the minimal release metadata needed by plugins to execute updates.
      type: object
      properties:
        tag:
          type: string
        release_url:
          type: string
        assets:
          type: array
          items:
            $ref: '#/components/schemas/ReleaseAsset'
        attestation_status:
          description: |-
            Attestation status as determined by the GitHub Attestations API.

            Set by the controller from the most recent `fetch_releases` run.
            `None` means the check was never performed or the source is not GitHub.
          anyOf:
          - $ref: '#/components/schemas/AttestationStatus'
          - type: 'null'
        require_attestation:
          description: |-
            When `true`, the agent must abort the update if attestation is not `Verified`.

            Copied from `GitHubConfig.require_attestation` by the controller at
            trigger time.
          type: boolean
          default: false
      required:
      - tag
      - release_url
    ReportPageLimits:
      description: Per-page item-count limits for paginated report payloads.
      type: object
      properties:
        report_hosts:
          description: Maximum `hosts` items per `report_hosts` page.
          type: integer
          format: uint32
          minimum: 0
        version_check_results:
          description: Maximum `results` items per `version_check_results` page.
          type: integer
          format: uint32
          minimum: 0
        discovery_results:
          description: Maximum `results` items per `discovery_results` page.
          type: integer
          format: uint32
          minimum: 0
        batch_update_results:
          description: Maximum `results` items per `batch_update_result` page.
          type: integer
          format: uint32
          minimum: 0
      required:
      - report_hosts
      - version_check_results
      - discovery_results
      - batch_update_results
    ReportPagination:
      required:
      - report_id
      - page
      - total_pages
      title: ReportPagination
      description: |-
        Pagination metadata for a paginated report.

        When a service needs to send a report that exceeds the WebSocket frame
        limit, it splits the payload into pages. Each page carries the same
        `report_id` and a 1-based `page` number out of `total_pages`.

        The controller processes each page immediately (no payload buffering) and
        defers only lightweight finalization (e.g. notification emission) until the
        final page arrives.
      type: object
      properties:
        report_id:
          description: Unique identifier grouping all pages of the same logical report.
          type: string
          format: uuid
        page:
          description: 1-based page number within the report.
          type: integer
          format: uint32
          minimum: 0
        total_pages:
          description: Total number of pages in the report (known upfront by the sender).
          type: integer
          format: uint32
          minimum: 0
    ServiceConfigEntry:
      description: |-
        A single stored service config entry, delivered to the service.

        Sensitive values are already decrypted by the controller before delivery.
      type: object
      properties:
        tenant_id:
          description: Tenant this entry belongs to, or `None` for global entries.
          type:
          - string
          - 'null'
          format: uuid
        key:
          description: Entry key (e.g. `"clients.{uuid}"`).
          type: string
        value:
          description: Entry value (plaintext JSON; controller decrypts before delivery).
      required:
      - key
      - value
    ServiceConfigKey:
      description: Identifies a service config entry by scope and key (used in delete notifications).
      type: object
      properties:
        tenant_id:
          description: Tenant this entry belongs to, or `None` for global entries.
          type:
          - string
          - 'null'
          format: uuid
        key:
          description: Entry key.
          type: string
      required:
      - key
    SoftwareStateHostEntry:
      description: Per-host version data for a software item.
      type: object
      properties:
        host_id:
          description: Host UUID.
          type: string
          format: uuid
        hostname:
          description: Human-readable hostname.
          type: string
        friendly_name:
          description: User-defined display name for the host.
          type: string
        installed_version:
          description: Currently installed version, if known.
          type:
          - string
          - 'null'
        latest_version:
          description: Latest available version, if known.
          type:
          - string
          - 'null'
        update_available:
          description: Whether an update is available (`latest_version > installed_version`).
          type: boolean
        update_in_progress:
          description: |-
            Whether an update is currently pending or in progress for this host-item pair.

            Set to `true` when an `update_history` record exists with status
            `Pending` or `InProgress`. Cleared to `false` once the update
            completes or fails. Defaults to `false` when absent (older controller).
          type: boolean
          default: false
        release_url:
          description: URL to the upstream release page (e.g. GitHub release), if available.
          type:
          - string
          - 'null'
        release_notes:
          description: Release notes or changelog text, if available.
          type:
          - string
          - 'null'
        update_category:
          description: |-
            Classification of the update (e.g. `"security"`, `"bugfix"`, `"feature"`, `"unknown"`).

            Sourced from `host_software_item.update_category`. Defaults to `"unknown"` when absent.
          type:
          - string
          - 'null'
        release_date:
          description: |-
            Date when the latest release was published (ISO 8601 date string, e.g. `"2025-01-15"`).

            Extracted from `latest_release_metadata.published_at`. `null` when metadata is absent.
          type:
          - string
          - 'null'
        last_checked_at:
          description: |-
            Timestamp when the installed version was last detected (ISO 8601).

            Sourced from `host_software_item.installed_version_detected_at`. `null` when never checked.
          type:
          - string
          - 'null'
      required:
      - host_id
      - hostname
      - friendly_name
      - update_available
    SoftwareStateItem:
      description: A single software item entry in [`SoftwareStatesPayload`].
      type: object
      properties:
        software_item_id:
          description: Software item UUID.
          type: string
          format: uuid
        name:
          description: Human-readable software item name.
          type: string
        icon_url:
          description: |-
            Optional HTTPS URL to an icon/logo image.

            When present, the MQTT service includes this as `entity_picture` in the
            Home Assistant discovery config so HA displays it as the entity thumbnail.
            Limited to [`crate::limits::MAX_ICON_URL_LEN`] characters.
          type:
          - string
          - 'null'
        hosts:
          description: Per-host version data for this software item.
          type: array
          items:
            $ref: '#/components/schemas/SoftwareStateHostEntry'
      required:
      - software_item_id
      - name
      - hosts
    SoftwareStatesPage:
      description: |-
        Pagination metadata for a [`SoftwareStatesPayload`] message.

        All payloads carry a `page` field. For single-page delivery use
        `{ page_index: 0, total_pages: 1 }`. Multi-page delivery uses
        `page_index` 0…N-1; the last page satisfies `page_index + 1 == total_pages`.
      type: object
      properties:
        page_index:
          description: Zero-based index of this page.
          type: integer
          format: uint32
          minimum: 0
        total_pages:
          description: Total number of pages in this delivery batch.
          type: integer
          format: uint32
          minimum: 0
      required:
      - page_index
      - total_pages
    TraceContext:
      required:
      - trace_id
      title: TraceContext
      description: |-
        Distributed tracing context for correlating messages across service boundaries.

        ## Wire format

        ```json
        {"trace_id":"0123456789abcdef0123456789abcdef","span_id":"0123456789abcdef"}
        ```

        - `trace_id`: 32 lowercase hex characters (128-bit identifier)
        - `span_id`: 16 lowercase hex characters (64-bit identifier), omitted when absent
      type: object
      properties:
        trace_id:
          description: 128-bit trace identifier encoded as 32 lowercase hex characters.
          type: string
        span_id:
          description: |-
            64-bit span identifier encoded as 16 lowercase hex characters.
            `None` when no parent span is active.
          type:
          - string
          - 'null'
    UpdateCategory:
      description: 'Open wire string (unknown values are forward-compatible). Known values: security, bugfix, feature, unknown.'
      type: string
    UpdateFinalStatus:
      description: 'Open wire string (unknown values are forward-compatible). Known values: completed, failed.'
      type: string
    VersionCheckAssignment:
      description: A single software item to check for installed version and/or latest version.
      type: object
      properties:
        software_item_id:
          description: Software item ID.
          type: string
          format: uuid
        name:
          description: Human-readable name for logging.
          type: string
        detect_version:
          description: |-
            Plugin for the detect_version role.
            None if no detect_version plugin is configured for this host-software pair.
          anyOf:
          - $ref: '#/components/schemas/PluginAssignment'
          - type: 'null'
        fetch_releases:
          description: |-
            Plugin for the fetch_releases role — only included for agent-side plugins
            (i.e., plugins without ControllerSideFetchReleases or with execution_site = agent).
            Controller-side fetch_releases is handled by the scheduler, not sent to the agent.
          anyOf:
          - $ref: '#/components/schemas/PluginAssignment'
          - type: 'null'
        host_software_item_id:
          description: |-
            Host software item ID for routing results to the host_software_items table.
            When set, this assignment is for a host-managed software item rather than
            a targeted software item.
          type:
          - string
          - 'null'
          format: uuid
      required:
      - software_item_id
      - name
    VersionCheckResult:
      description: Result of a single version check.
      type: object
      properties:
        software_item_id:
          description: Software item ID.
          type: string
          format: uuid
        installed_version:
          description: Detected installed version, if any.
          type:
          - string
          - 'null'
        latest_version:
          description: |-
            Latest available version from the package index, if resolved locally
            by the agent (e.g., Homebrew). Absent for plugins whose latest
            version is resolved on the controller side.
          type:
          - string
          - 'null'
        error:
          description: Error message if detection failed.
          type:
          - string
          - 'null'
        update_category:
          description: |-
            Classification of the available update (e.g. security, bugfix).
            Defaults to `Unknown` when the plugin cannot classify the update.
          $ref: '#/components/schemas/UpdateCategory'
          default: unknown
        host_software_item_id:
          description: |-
            Host software item ID for routing results to the host_software_items table.
            Mirrors the value from the corresponding [`VersionCheckAssignment`].
          type:
          - string
          - 'null'
          format: uuid
        installed_display_version:
          description: |-
            Human-readable installed version for display when `installed_version`
            is opaque (e.g. a Docker SHA256 digest → the image publish date).
            Set by the agent from `BatchDetectResult.display_version`.
            `None` when the plugin does not provide a display version.
          type:
          - string
          - 'null'
        not_ready:
          description: |-
            When `true`, the agent is not yet ready to report a meaningful version
            for this item (e.g. a self-update is in progress and the binary has not
            restarted yet). The controller should treat this as "check again later"
            rather than clearing the installed version.

            `None` / absent means "ready" for wire backward compatibility.
          type:
          - boolean
          - 'null'
      required:
      - software_item_id
    WorkloadClaimSyncEntry:
      description: A single entry in a `WorkloadClaimSyncResponse`.
      type: object
      properties:
        service_id:
          description: The service that owns this claim.
          type: string
          format: uuid
        tenant_id:
          description: The tenant this config key belongs to.
          type: string
          format: uuid
        claimed_at:
          description: ISO 8601 timestamp when the claim was granted.
          type: string
      required:
      - service_id
      - tenant_id
      - claimed_at
    access_invalidatedPayload:
      description: |-
        Cross-controller access-cache invalidation published by the controller
        that mutated access grants or role assignments. Controller→controller
        over NATS only — never sent over the service WebSocket. Receivers
        flush their whole access cache; the ID lists are diagnostic and
        forward-compat only (no granular invalidation promise).

        **Safe to publish via NATS** — contains no credential material.
      type: object
      properties:
        type:
          type: string
          const: access_invalidated
        user_ids:
          description: Users whose grant rows or role assignments changed.
          type: array
          items:
            type: string
            format: uuid
        role_ids:
          description: Roles whose grant rows changed.
          type: array
          items:
            type: string
            format: uuid
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - user_ids
      - role_ids
      - protocol_version
      - seq
    approvedPayload:
      type: object
      properties:
        type:
          type: string
          const: approved
        service_id:
          type: string
          format: uuid
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - service_id
      - protocol_version
      - seq
    audit_eventPayload:
      description: |-
        Service -> Controller: forwarded semantic audit event.

        The controller re-validates the event and silently drops invalid or
        non-forwardable payloads without closing the connection.
      type: object
      properties:
        type:
          type: string
          const: audit_event
        action_type:
          description: Semantic action identifier, such as `service.certificate.issue`.
          type: string
        tenant_id:
          description: Tenant UUID as a string when the event is tenant-scoped.
          type:
          - string
          - 'null'
        target_type:
          description: Optional semantic target type.
          type:
          - string
          - 'null'
        target_id:
          description: Optional semantic target identifier.
          type:
          - string
          - 'null'
        target_display:
          description: Optional human-readable target display value.
          type:
          - string
          - 'null'
        outcome:
          description: Semantic outcome, such as `success` or `denied`.
          type: string
        details_json:
          description: Optional JSON-encoded details payload.
          type:
          - string
          - 'null'
        request_id:
          description: Optional correlation identifier.
          type:
          - string
          - 'null'
        correlation_id:
          description: Optional correlation identifier linking events in a workflow chain.
          type:
          - string
          - 'null'
          format: uuid
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - action_type
      - outcome
      - protocol_version
      - seq
    batch_update_resultPayload:
      type: object
      properties:
        type:
          type: string
          const: batch_update_result
        batch_id:
          description: Batch ID matching the request.
          type: string
          format: uuid
        results:
          description: Per-item results.
          type: array
          items:
            $ref: '#/components/schemas/BatchUpdateItemResult'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - batch_id
      - results
      - protocol_version
      - seq
    broadcast_admin_eventPayload:
      description: |-
        Cross-controller admin event broadcast.

        Published via NATS to the `controller` subject by any controller
        instance when it emits an `AdminEvent` to local SSE subscribers.
        Receiving controller instances decode the payload and re-broadcast
        to their own local SSE subscribers using `send_local` /
        `send_global_local` (without re-publishing to NATS to avoid loops).

        **Safe to publish via NATS** — contains no credential material.
      type: object
      properties:
        type:
          type: string
          const: broadcast_admin_event
        tenant_id:
          description: Target tenant, or `None` for system-wide events.
          type:
          - string
          - 'null'
          format: uuid
        event_json:
          description: JSON-serialised `AdminEvent`.
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - event_json
      - protocol_version
      - seq
    ca_bundle_updatedPayload:
      type: object
      properties:
        type:
          type: string
          const: ca_bundle_updated
        ca_bundle_pem:
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - ca_bundle_pem
      - protocol_version
      - seq
    certificatePayload:
      type: object
      properties:
        type:
          type: string
          const: certificate
        cert_pem:
          type: string
        not_after:
          description: Certificate "not valid after" timestamp.
          type: integer
          format: int64
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - cert_pem
      - not_after
      - protocol_version
      - seq
    check_versionsPayload:
      type: object
      properties:
        type:
          type: string
          const: check_versions
        host_machine_id:
          description: |-
            The machine_id of the host to check versions on.

            For the regular agent (one service = one host), the agent validates that
            this matches its own machine_id as a defensive sanity check.
            For the SSH agent (one service = N remote hosts), the agent uses this
            field to look up the correct SSH credentials and route the operation to
            the right remote host.
          type: string
        assignments:
          description: List of software items to check.
          type: array
          items:
            $ref: '#/components/schemas/VersionCheckAssignment'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - host_machine_id
      - assignments
      - protocol_version
      - seq
    delete_service_configPayload:
      description: |-
        Service → Controller: delete a config entry from the controller DB.

        The controller deletes, ACKs, and broadcasts `ServiceConfigUpdated`.
      type: object
      properties:
        type:
          type: string
          const: delete_service_config
        request_id:
          description: Correlation ID for the `ServiceConfigAck` response.
          type: string
        tenant_id:
          description: Tenant scope. `None` = global scope.
          type:
          - string
          - 'null'
          format: uuid
        key:
          description: Config key to delete.
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - request_id
      - key
      - protocol_version
      - seq
    disconnectingPayload:
      type: object
      properties:
        type:
          type: string
          const: disconnecting
        reason:
          $ref: '#/components/schemas/DisconnectReason'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - reason
      - protocol_version
      - seq
    discover_softwarePayload:
      type: object
      properties:
        type:
          type: string
          const: discover_software
        host_machine_id:
          description: |-
            Machine ID of the host to discover software on.

            For the regular agent this is validated to match its own machine_id.
            For the SSH agent it identifies which remote host to connect to.
          type: string
        plugins:
          description: Per-plugin discovery assignments.
          type: array
          items:
            $ref: '#/components/schemas/DiscoveryPluginAssignment'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - host_machine_id
      - plugins
      - protocol_version
      - seq
    discovery_resultsPayload:
      type: object
      properties:
        type:
          type: string
          const: discovery_results
        host_machine_id:
          description: Machine ID of the host that was scanned (echoed from the assignment).
          type: string
        results:
          description: Per-plugin results.
          type: array
          items:
            $ref: '#/components/schemas/DiscoveryPluginResult'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - host_machine_id
      - results
      - protocol_version
      - seq
    enrollPayload:
      type: object
      properties:
        type:
          type: string
          const: enroll
        hostname:
          type: string
        friendly_name:
          type: string
        enrollment_token:
          type:
          - string
          - 'null'
        capabilities:
          description: |-
            Capabilities this service supports.

            The controller persists these in the `services.capabilities` column and
            derives behavioral defaults from the resulting [`ServiceProfile`](crate::ServiceProfile).
          type: array
          uniqueItems: true
          items:
            $ref: '#/components/schemas/Capability'
        service_app_name:
          description: |-
            The binary/crate name of the enrolling service (e.g., `"uptrakit-agent-ssh"`).

            Derived from `env!("CARGO_PKG_NAME")` at compile time. Used for UI
            display, extension conflict detection, and distinguishing service binaries.
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - hostname
      - friendly_name
      - capabilities
      - service_app_name
      - protocol_version
      - seq
    enrolledPayload:
      type: object
      properties:
        type:
          type: string
          const: enrolled
        service_id:
          type: string
          format: uuid
        enrollment_secret:
          type: string
        status:
          $ref: '#/components/schemas/EnrollmentStatus'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - service_id
      - enrollment_secret
      - status
      - protocol_version
      - seq
    errorPayload:
      type: object
      properties:
        type:
          type: string
          const: error
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - code
      - message
      - protocol_version
      - seq
    execute_batch_updatePayload:
      type: object
      properties:
        type:
          type: string
          const: execute_batch_update
        host_machine_id:
          description: |-
            The machine_id of the host to run the batch update on.

            For the regular agent (one service = one host) this is validated against
            its own machine_id. For the SSH agent this routes to the correct remote host.
          type: string
        batch_id:
          description: Unique identifier for this batch operation.
          type: string
          format: uuid
        plugin_type:
          description: Plugin type for all items in this batch.
          $ref: '#/components/schemas/PluginTypeId'
        plugin_config:
          description: Merged plugin configuration.
        updates:
          description: Individual items to update.
          type: array
          items:
            $ref: '#/components/schemas/BatchUpdateItem'
        pre_update_hook_plugins:
          description: Pre-update hook plugins to execute before the batch, ordered by priority.
          type: array
          items:
            $ref: '#/components/schemas/PluginAssignment'
        post_update_hook_plugins:
          description: Post-update hook plugins to execute after the batch, ordered by priority.
          type: array
          items:
            $ref: '#/components/schemas/PluginAssignment'
        timeout_seconds:
          description: |-
            Timeout for the entire batch operation.

            Wire field name: `timeout_seconds` (kept for backward compatibility).
          type: integer
          format: uint32
          minimum: 0
          default: 7200
        interactive:
          description: |-
            When `true`, the agent allocates a PTY and keeps stdin open for forwarding.

            Requires the agent to advertise the `InteractiveUpdates` capability.
            Defaults to `false` for backward compatibility with older agents.
          type: boolean
          default: false
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - host_machine_id
      - batch_id
      - plugin_type
      - plugin_config
      - updates
      - protocol_version
      - seq
    execute_updatePayload:
      type: object
      properties:
        type:
          type: string
          const: execute_update
        host_machine_id:
          description: |-
            The machine_id of the host to run the update on.

            For the regular agent (one service = one host), the agent validates that
            this matches its own machine_id as a defensive sanity check.
            For the SSH agent (one service = N remote hosts), the agent uses this
            field to look up the correct SSH credentials and route the operation to
            the right remote host.
          type: string
        update_history_id:
          type: string
          format: uuid
        software_item_id:
          type: string
          format: uuid
        software_item_name:
          type: string
        to_version:
          type: string
        detect_version_plugin:
          description: |-
            Plugin for the detect_version role (for before/after installed-version detection).
            Absent when no detect_version plugin is configured for this assignment.
          anyOf:
          - $ref: '#/components/schemas/PluginAssignment'
          - type: 'null'
        execute_update_plugin:
          description: Plugin for the execute_update role.
          $ref: '#/components/schemas/PluginAssignment'
        pre_update_hook_plugins:
          description: Pre-update hook plugins to execute before the update, ordered by priority.
          type: array
          items:
            $ref: '#/components/schemas/PluginAssignment'
        post_update_hook_plugins:
          description: Post-update hook plugins to execute after the update, ordered by priority.
          type: array
          items:
            $ref: '#/components/schemas/PluginAssignment'
        release_info:
          anyOf:
          - $ref: '#/components/schemas/ReleaseInfo'
          - type: 'null'
        timeout_seconds:
          description: |-
            Timeout for the update execution.

            Wire field name: `timeout_seconds` (kept for backward compatibility).
          type: integer
          format: uint32
          minimum: 0
          default: 7200
        interactive:
          description: |-
            When `true`, the agent allocates a PTY and keeps stdin open for forwarding.

            Requires the agent to advertise the `InteractiveUpdates` capability.
            Defaults to `false` for backward compatibility with older agents.
          type: boolean
          default: false
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - host_machine_id
      - update_history_id
      - software_item_id
      - software_item_name
      - to_version
      - execute_update_plugin
      - protocol_version
      - seq
    host_connectivity_updatedPayload:
      description: |-
        Agent connectivity changed for one or more hosts.

        Published to NATS with `target_capability = "update_tracking"` by the controller
        that owns the agent WebSocket connection (on connect and disconnect). The MQTT
        service updates its per-tenant connectivity cache and publishes the
        `{prefix}/hosts/{h}/connectivity/state` retained topic.

        **Safe to publish via NATS** — contains no credential material.
      type: object
      properties:
        type:
          type: string
          const: host_connectivity_updated
        tenant_id:
          description: Tenant this update belongs to.
          type: string
          format: uuid
        updates:
          description: One entry per host whose connectivity changed.
          type: array
          items:
            $ref: '#/components/schemas/HostConnectivityUpdate'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - tenant_id
      - updates
      - protocol_version
      - seq
    pingPayload:
      type: object
      properties:
        type:
          type: string
          const: ping
        service_ts:
          description: Timestamp when the service sent the ping.
          type: integer
          format: int64
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - service_ts
      - protocol_version
      - seq
    pongPayload:
      type: object
      properties:
        type:
          type: string
          const: pong
        service_ts:
          description: Original timestamp from the service's ping.
          type: integer
          format: int64
        controller_ts:
          description: Timestamp when the controller processed the ping.
          type: integer
          format: int64
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - service_ts
      - controller_ts
      - protocol_version
      - seq
    registerPayload:
      description: |-
        Service declares its capabilities immediately on connect.

        Sent from `on_connected` before `ServiceSettings` is processed.
        The controller uses this to establish session-level capability flags
        without relying on DB-stored values (which may be absent on first connect).
      type: object
      properties:
        type:
          type: string
          const: register
        capabilities:
          description: Capabilities declared by this service instance.
          type: array
          uniqueItems: true
          items:
            $ref: '#/components/schemas/Capability'
        runtime_instance_id:
          description: |-
            Runtime instance identity for restart-vs-reconnect detection.

            Optional for mixed-version compatibility: legacy services omit this
            field and are treated as service-scoped (not instance-scoped).
          type:
          - string
          - 'null'
          format: uuid
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - protocol_version
      - seq
    rejectedPayload:
      type: object
      properties:
        type:
          type: string
          const: rejected
        service_id:
          type: string
          format: uuid
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - service_id
      - protocol_version
      - seq
    renew_certificatePayload:
      type: object
      properties:
        type:
          type: string
          const: renew_certificate
        csr_pem:
          description: PEM-encoded Certificate Signing Request with CN=service_id.
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - csr_pem
      - protocol_version
      - seq
    report_hostsPayload:
      type: object
      properties:
        type:
          type: string
          const: report_hosts
        hosts:
          description: One or more host machines managed by this service.
          type: array
          items:
            $ref: '#/components/schemas/HostInfo'
        agent_version:
          description: Agent binary version (e.g., "0.0.1").
          type: string
        capabilities:
          description: |-
            Capabilities advertised by this service.

            The controller computes the agreed set as the intersection of this set
            with its own capabilities, considering only typed (known) variants.
          type: array
          uniqueItems: true
          items:
            $ref: '#/components/schemas/Capability'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - hosts
      - agent_version
      - protocol_version
      - seq
    report_plugin_configPayload:
      description: |-
        Service reports a plugin configuration to the controller.

        Sent by agents that detect infrastructure (e.g. PVE nodes) during
        bootstrap. The controller creates or returns an existing plugin config
        matching `(tenant_id, plugin_type, name)` and responds with
        `ReportPluginConfigResponse`.
      type: object
      properties:
        type:
          type: string
          const: report_plugin_config
        request_id:
          description: Unique request identifier for correlating the response.
          type: string
        plugin_type:
          description: Plugin type string (e.g. `"infrastructure.proxmox"`).
          type: string
        name:
          description: Human-readable name for the config (e.g. `"pve.local"`).
          type: string
        config:
          description: Plugin-specific configuration JSON.
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - request_id
      - plugin_type
      - name
      - config
      - protocol_version
      - seq
    report_plugin_config_responsePayload:
      description: |-
        Response to a `ReportPluginConfig` request from a service.

        Contains the plugin config ID if the operation succeeded, or an error
        message if it failed. Idempotent: returns the existing config ID if a
        matching `(tenant_id, plugin_type, name)` already exists.
      type: object
      properties:
        type:
          type: string
          const: report_plugin_config_response
        request_id:
          description: The request ID from the original `ReportPluginConfig` message.
          type: string
        success:
          description: Whether the operation succeeded.
          type: boolean
        plugin_config_id:
          description: The plugin config ID (set on success).
          type:
          - string
          - 'null'
          format: uuid
        error:
          description: Error message (set on failure).
          type:
          - string
          - 'null'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - request_id
      - success
      - protocol_version
      - seq
    request_ca_rotationPayload:
      description: |-
        Request from an external component (e.g. scheduler) for the controller to
        perform CA certificate rotation. Published via NATS to the controller subject;
        handled by triggering `ca_rotation_trigger.notify_one()`.
      type: object
      properties:
        type:
          type: string
          const: request_ca_rotation
        reason:
          description: Human-readable reason for the rotation request.
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - reason
      - protocol_version
      - seq
    request_cert_renewalPayload:
      type: object
      properties:
        type:
          type: string
          const: request_cert_renewal
        reason:
          description: Human-readable reason for the renewal request.
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - reason
      - protocol_version
      - seq
    request_certificatePayload:
      type: object
      properties:
        type:
          type: string
          const: request_certificate
        csr_pem:
          description: PEM-encoded Certificate Signing Request.
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - csr_pem
      - protocol_version
      - seq
    request_crl_renewalPayload:
      description: |-
        Request all controller instances to rebuild the CRL immediately.

        Published via NATS to the controller subject by any controller that
        revokes a certificate or by the `CrlRenewal` scheduled task.
        Receiving controllers fire `revocation_notify.notify_one()` so that
        `CrlManager::run()` rebuilds and hot-reloads the TLS configuration.
      type: object
      properties:
        type:
          type: string
          const: request_crl_renewal
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - protocol_version
      - seq
    reset_dataPayload:
      description: |-
        Controller → Services: reset all tenant-scoped data.

        Broadcast to services with the `ResetData` capability after the
        controller has cleared the database. Services should truncate their
        local data stores (e.g. SSH host list, Proxmox state).
      type: object
      properties:
        type:
          type: string
          const: reset_data
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - protocol_version
      - seq
    server_restartingPayload:
      type: object
      properties:
        type:
          type: string
          const: server_restarting
        reason:
          description: Human-readable reason for the restart.
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - reason
      - protocol_version
      - seq
    service_config_ackPayload:
      description: |-
        Controller → Service: acknowledgment of a store or delete operation.

        **Security**: NEVER published to NATS — session-targeted.
      type: object
      properties:
        type:
          type: string
          const: service_config_ack
        request_id:
          description: Correlation ID matching the request.
          type: string
        success:
          description: '`true` if the operation succeeded.'
          type: boolean
        error:
          description: Error message when `success` is `false`.
          type:
          - string
          - 'null'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - request_id
      - success
      - protocol_version
      - seq
    service_config_deliveryPayload:
      description: |-
        Controller → Service: initial delivery of all stored config entries.

        Sent once after authentication (after credential delivery if applicable).
        **Security**: contains decrypted sensitive values — NEVER published to NATS.
      type: object
      properties:
        type:
          type: string
          const: service_config_delivery
        entries:
          description: All config entries stored for this `service_app_name`.
          type: array
          items:
            $ref: '#/components/schemas/ServiceConfigEntry'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - entries
      - protocol_version
      - seq
    service_config_updatedPayload:
      description: |-
        Controller → Service: incremental update pushed to all instances of the
        same `service_app_name` when any instance modifies a config entry.

        **Security**: may contain decrypted sensitive values — NEVER published to NATS.
      type: object
      properties:
        type:
          type: string
          const: service_config_updated
        changed:
          description: Entries that were inserted or updated (with decrypted values).
          type: array
          items:
            $ref: '#/components/schemas/ServiceConfigEntry'
        deleted:
          description: Keys that were deleted.
          type: array
          items:
            $ref: '#/components/schemas/ServiceConfigKey'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - protocol_version
      - seq
    service_credentialsPayload:
      description: |-
        Infrastructure credentials for services that advertise credential
        capabilities. Fields are populated based on the service's capability set:
          - `database_access` → `db_url` is set
          - `nats_access` → `nats_url` is set (if controller has NATS)
          - `master_key_access` → `master_key_hex` is set (if encryption enabled)

        **Security**: NEVER published to NATS. Delivered locally via WebSocket only,
        following the same pattern as MQTT credential messages.
      type: object
      properties:
        type:
          type: string
          const: service_credentials
        db_url:
          description: Database connection URL. Present when the service has `database_access`.
          type:
          - string
          - 'null'
        master_key_hex:
          description: |-
            Master encryption key as 64-char hex. Present when the service has
            `master_key_access` and encryption is enabled on the controller.
          type:
          - string
          - 'null'
        nats_url:
          description: |-
            NATS server URL. Present when the service has `nats_access` and
            NATS is configured on the controller.
          type:
          - string
          - 'null'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - protocol_version
      - seq
    service_settingsPayload:
      type: object
      properties:
        type:
          type: string
          const: service_settings
        renewal_window_hours:
          type: integer
          format: uint16
          minimum: 0
          maximum: 65535
        ca_bundle_hash:
          type: string
          default: ''
        capabilities:
          description: |-
            Capabilities advertised by the controller.

            The service computes the agreed set as the intersection of this set
            with its own capabilities, considering only typed (known) variants.
          type: array
          uniqueItems: true
          items:
            $ref: '#/components/schemas/Capability'
        report_page_limits:
          description: |-
            Per-page item-count limits for paginated service-to-controller reports.

            Services must honor these limits when splitting large `report_hosts`,
            `discovery_results`, `version_check_results`, and
            `batch_update_result` payloads across pages.
          $ref: '#/components/schemas/ReportPageLimits'
        shutdown_timeout_seconds:
          description: |-
            Maximum time to wait for in-flight operations during shutdown.
            Present for agents, absent for MQTT services.

            Wire field name: `shutdown_timeout_seconds` (kept for backward compatibility).
          type:
          - integer
          - 'null'
          format: uint32
          minimum: 0
        ping_interval:
          description: |-
            How often the service should send ping messages.
            Controller-managed; derived from per-service DB override or service-type default.
          type: integer
          format: uint32
          minimum: 0
        tenant_id:
          description: |-
            Tenant UUID that this service belongs to.

            `None` for system services (MQTT, scheduler) which are not
            tenant-scoped. Present for tenant-scoped agents so they can
            include the tenant identity in external provisioning operations
            (e.g. PVE API credential naming).
          type:
          - string
          - 'null'
          format: uuid
        trust_domain:
          description: |-
            SPIFFE trust domain for Service identity URIs.

            Empty string when the Controller has no trust domain configured.
            Agent falls back to the dialed hostname for SPIFFE SAN generation.
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - renewal_window_hours
      - ping_interval
      - protocol_version
      - seq
    service_trigger_host_batch_updatePayload:
      description: |-
        Service → Controller: trigger a batch update of all outdated software items on a host.

        Sent when a Home Assistant user presses "Install" on a host update entity.
      type: object
      properties:
        type:
          type: string
          const: service_trigger_host_batch_update
        tenant_id:
          description: Tenant UUID (for validation).
          type: string
          format: uuid
        host_id:
          description: Host whose items should be updated.
          type: string
          format: uuid
        actor_service_id:
          description: Service instance UUID that initiated the trigger (used as actor_id).
          type: string
          format: uuid
        security_only:
          description: When `true`, only items with `update_category = "security"` are updated.
          type: boolean
          default: false
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - tenant_id
      - host_id
      - actor_service_id
      - protocol_version
      - seq
    service_trigger_updatePayload:
      type: object
      properties:
        type:
          type: string
          const: service_trigger_update
        tenant_id:
          description: Tenant UUID (for validation).
          type: string
          format: uuid
        software_item_id:
          description: Software item to update.
          type: string
          format: uuid
        host_id:
          description: Host to update on.
          type: string
          format: uuid
        to_version:
          description: Target version to install.
          type: string
        actor_service_id:
          description: Service instance UUID that initiated the trigger (used as actor_id).
          type: string
          format: uuid
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - tenant_id
      - software_item_id
      - host_id
      - to_version
      - actor_service_id
      - protocol_version
      - seq
    set_update_freezePayload:
      type: object
      properties:
        type:
          type: string
          const: set_update_freeze
        enabled:
          description: Whether to enable (`true`) or disable (`false`) the freeze.
          type: boolean
        reason:
          description: Optional human-readable reason for the freeze (audit trail).
          type:
          - string
          - 'null'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - enabled
      - protocol_version
      - seq
    software_statesPayload:
      type: object
      properties:
        type:
          type: string
          const: software_states
        tenant_id:
          description: Tenant this state belongs to.
          type: string
          format: uuid
        items:
          description: All active software items for the tenant with per-host version data.
          type: array
          items:
            $ref: '#/components/schemas/SoftwareStateItem'
        host_summaries:
          description: |-
            Per-host aggregate summary of unpinned (unfeatured) software items.

            Each entry summarises all enabled, non-deactivated unfeatured items for
            one host. Only hosts with at least one such item are included.
            Defaults to an empty list on deserialization for backward compatibility
            with older MQTT services.
          type: array
          items:
            $ref: '#/components/schemas/HostPackageSummary'
          default: []
        hosts:
          description: |-
            Per-host metadata for all hosts referenced in `items` or `host_summaries`.

            Includes OS info, tags, and agent last-seen data. Sourced exclusively from DB.
            Defaults to an empty list for backward compatibility with older MQTT services.
          type: array
          items:
            $ref: '#/components/schemas/HostStateMetadata'
          default: []
        page:
          description: Pagination metadata indicating which page this payload represents.
          $ref: '#/components/schemas/SoftwareStatesPage'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - tenant_id
      - items
      - page
      - protocol_version
      - seq
    software_states_changedPayload:
      description: |-
        Signal that software states have changed for a tenant.

        Published to the `controller` NATS subject by the external scheduler
        after a version-check run completes. The receiving controller loads
        the states from the database and pushes them to update-tracking services.
      type: object
      properties:
        type:
          type: string
          const: software_states_changed
        tenant_id:
          type: string
          format: uuid
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - tenant_id
      - protocol_version
      - seq
    stdin_attentionPayload:
      description: |-
        Agent → Controller: the update process appears to be waiting for stdin input.

        Sent when the agent detects that the process has produced no output for
        a sustained period while still running (heuristic: ~10 seconds of silence).
        The controller broadcasts this to interactive session subscribers and may
        trigger notifications.
      type: object
      properties:
        type:
          type: string
          const: stdin_attention
        update_history_id:
          description: The update history record that needs attention.
          type: string
          format: uuid
        hint:
          description: Optional hint about what the process might be waiting for.
          type:
          - string
          - 'null'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - update_history_id
      - protocol_version
      - seq
    store_service_configPayload:
      description: |-
        Service → Controller: upsert a config entry in the controller DB.

        The controller encrypts sensitive values at rest, ACKs, and broadcasts
        `ServiceConfigUpdated` to all connected instances of the same service app.
      type: object
      properties:
        type:
          type: string
          const: store_service_config
        request_id:
          description: Correlation ID for the `ServiceConfigAck` response.
          type: string
        tenant_id:
          description: Tenant scope. `None` = global scope.
          type:
          - string
          - 'null'
          format: uuid
        key:
          description: Config key (e.g. `"clients.{uuid}"`).
          type: string
        value:
          description: Config value (plaintext JSON; controller encrypts at rest if `sensitive`).
        sensitive:
          description: When `true`, the controller stores the value using `EncryptedString`.
          type: boolean
          default: false
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - request_id
      - key
      - value
      - protocol_version
      - seq
    surface_action_cancelPayload:
      description: |-
        Cancellation of an in-flight proxied surface action request.

        Session-targeted and never published to NATS.
      type: object
      properties:
        type:
          type: string
          const: surface_action_cancel
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - protocol_version
      - seq
    surface_action_requestPayload:
      description: |-
        Service requests a surface action invocation from the controller.

        Enables services to call surface actions via the wire protocol and
        receive the correlated `ControllerMessage::SurfaceActionResponse`.
      type: object
      properties:
        type:
          type: string
          const: surface_action_request
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - protocol_version
      - seq
    surface_action_responsePayload:
      description: |-
        Response to a proxied surface action invocation.

        Sent by the service after processing a `SurfaceActionRequest` from the
        controller.
      type: object
      properties:
        type:
          type: string
          const: surface_action_response
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - protocol_version
      - seq
    surface_registrationPayload:
      description: |-
        Service declares its surfaces after connecting.

        Sent once after connection setup by services that participate in the
        surface contract.
      type: object
      properties:
        type:
          type: string
          const: surface_registration
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - protocol_version
      - seq
    test_plugin_configPayload:
      description: |-
        Controller -> Agent: test a plugin configuration on a specific host.

        Sent when a user invokes the config test API endpoint for an agent-side
        plugin. The agent executes the test and responds with
        `ServiceMessage::TestPluginConfigResult`.

        **Security**: session-targeted, NEVER published to NATS.
      type: object
      properties:
        type:
          type: string
          const: test_plugin_config
        request_id:
          description: Unique request ID for correlation (UUID v7).
          type: string
        host_machine_id:
          description: Target host machine ID on the agent.
          type: string
        test_kind:
          description: What to test.
          $ref: '#/components/schemas/ConfigTestKind'
        plugin_type:
          description: The plugin type to test.
          type: string
        config:
          description: The plugin configuration JSON to test.
        package_identifier:
          description: Package identifier for testing (required for version detection).
          type:
          - string
          - 'null'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - request_id
      - host_machine_id
      - test_kind
      - plugin_type
      - config
      - protocol_version
      - seq
    test_plugin_config_resultPayload:
      description: |-
        Agent -> Controller: result of a plugin configuration test.

        Sent after the agent completes a config test request. The controller
        uses `request_id` to correlate with the pending REST API request.
      type: object
      properties:
        type:
          type: string
          const: test_plugin_config_result
        request_id:
          description: Correlation ID matching the original request.
          type: string
        success:
          description: Whether the test passed.
          type: boolean
        output:
          description: Command output or connectivity response.
          type:
          - string
          - 'null'
        error:
          description: Error message if the test failed.
          type:
          - string
          - 'null'
        detected_version:
          description: Detected version (for version detection tests).
          type:
          - string
          - 'null'
        duration_ms:
          description: Test duration in milliseconds.
          type: integer
          format: uint64
          minimum: 0
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - request_id
      - success
      - duration_ms
      - protocol_version
      - seq
    token_revokedPayload:
      description: |-
        Token revocation event published by the originating controller to the
        "controller" NATS subject so that all other instances update their
        in-memory denylist caches without a per-request DB query.

        A message carries either a JTI-level revocation (when `jti` and `exp`
        are set) or a user-level revocation (when `user_id`, `iat_cutoff`, and
        `purge_after` are set). Both kinds may be present in a single message
        (e.g. when revoking a specific token *and* all prior tokens for a user).

        **Safe to publish via NATS** — contains no credential material.
      type: object
      properties:
        type:
          type: string
          const: token_revoked
        jti:
          description: JWT ID to deny (`exp` must also be set for JTI-level revocations).
          type:
          - string
          - 'null'
        exp:
          description: Token expiry unix timestamp (seconds). Required when `jti` is set.
          type:
          - integer
          - 'null'
          format: int64
        user_id:
          description: User UUID for user-level revocations.
          type:
          - string
          - 'null'
          format: uuid
        iat_cutoff:
          description: Deny tokens with `iat < iat_cutoff`. Required when `user_id` is set.
          type:
          - integer
          - 'null'
          format: int64
        purge_after:
          description: Remove the user entry after this unix timestamp.
          type:
          - integer
          - 'null'
          format: int64
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - protocol_version
      - seq
    update_outputPayload:
      type: object
      properties:
        type:
          type: string
          const: update_output
        update_history_id:
          type: string
          format: uuid
        output:
          type: string
        stream:
          $ref: '#/components/schemas/OutputStreamType'
          default: stdout
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - update_history_id
      - output
      - protocol_version
      - seq
    update_resultPayload:
      type: object
      properties:
        type:
          type: string
          const: update_result
        update_history_id:
          type: string
          format: uuid
        status:
          $ref: '#/components/schemas/UpdateFinalStatus'
        from_version:
          type:
          - string
          - 'null'
        to_version:
          type:
          - string
          - 'null'
        output:
          type: string
        error:
          type:
          - string
          - 'null'
        resumable:
          description: |-
            When `true`, the agent signals that this update can be resumed after
            a restart (e.g. the update script supports idempotent re-entry or the
            agent is mid-self-update and will re-attach on reconnect).

            `None` / absent means "not resumable" for wire backward compatibility.
          type:
          - boolean
          - 'null'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - update_history_id
      - status
      - output
      - protocol_version
      - seq
    update_startedPayload:
      type: object
      properties:
        type:
          type: string
          const: update_started
        update_history_id:
          type: string
          format: uuid
        from_version:
          type:
          - string
          - 'null'
        interactive:
          description: |-
            Whether this update was dispatched in interactive mode and the agent's
            executor supports PTY allocation (dispatch intent). The PTY itself is
            allocated when the update command starts; on reconnect replay the agent
            reports live reality instead (channels resolved). Old agents that do
            not send this field will deserialize as `false`.
          type: boolean
          default: false
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - update_history_id
      - protocol_version
      - seq
    update_stdin_dataPayload:
      description: |-
        Controller → Agent: forward stdin data or a signal to the running update process.

        Only sent to agents that advertise the `InteractiveUpdates` capability
        and have an in-flight interactive update matching the `update_history_id`.

        **Security**: session-targeted, NEVER published to NATS.
      type: object
      properties:
        type:
          type: string
          const: update_stdin_data
        update_history_id:
          description: The update history record this stdin data belongs to.
          type: string
          format: uuid
        data:
          description: 'Raw bytes encoded as base64 (supports binary: Ctrl+C = \x03, etc.).'
          type: string
        signal:
          description: |-
            When set, send this signal to the process group instead of writing stdin.
            Values: 2 = SIGINT, 15 = SIGTERM.
          type:
          - integer
          - 'null'
          format: int32
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - update_history_id
      - data
      - protocol_version
      - seq
    version_check_resultsPayload:
      type: object
      properties:
        type:
          type: string
          const: version_check_results
        results:
          description: Results for each checked software item.
          type: array
          items:
            $ref: '#/components/schemas/VersionCheckResult'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - results
      - protocol_version
      - seq
    workload_claimPayload:
      description: |-
        Service → Controller: request exclusive ownership of config keys.

        Sent after `ServiceConfigDelivery` is processed and whenever the
        desired config set changes. Uses full replacement semantics.
        Requires the `WorkloadClaims` capability.
      type: object
      properties:
        type:
          type: string
          const: workload_claim
        claims:
          description: Map of `config_key → tenant_id` representing the full desired set.
          type: object
          additionalProperties:
            type: string
            format: uuid
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - claims
      - protocol_version
      - seq
    workload_claim_announcementPayload:
      description: |-
        Controller → NATS: announce claim state changes for cross-controller sync.

        Published to the `controller` NATS subject after granting or releasing
        claims. Other controllers update their global claim registry from this.

        **Safe to publish via NATS** — contains no credential material.
      type: object
      properties:
        type:
          type: string
          const: workload_claim_announcement
        service_id:
          description: The service that owns these claims.
          type: string
          format: uuid
        controller_id:
          description: The controller that granted these claims.
          type: string
          format: uuid
        claimed:
          description: 'Newly claimed keys: `config_key → tenant_id`.'
          type: object
          additionalProperties:
            type: string
            format: uuid
        released:
          description: Keys that were released.
          type: array
          uniqueItems: true
          items:
            type: string
        claimed_at:
          description: ISO 8601 timestamp when the claims were granted (for conflict resolution).
          type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - service_id
      - controller_id
      - claimed_at
      - protocol_version
      - seq
    workload_claim_resultPayload:
      description: |-
        Controller → Service: grant/reject response for a workload claim.

        Sent in response to `WorkloadClaim`, unsolicited for proactive
        re-grants when previously rejected keys become available, or for
        revocations during cross-controller conflict resolution.

        **Session-targeted**: NEVER published to NATS.
      type: object
      properties:
        type:
          type: string
          const: workload_claim_result
        granted:
          description: Config keys that were granted (exclusive ownership).
          type: array
          uniqueItems: true
          items:
            type: string
        rejected:
          description: Config keys that were rejected (already claimed by another service).
          type: array
          uniqueItems: true
          items:
            type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - protocol_version
      - seq
    workload_claim_sync_requestPayload:
      description: |-
        Controller → NATS: request full claim state from all active controllers.

        Published on controller startup. Each active controller responds with
        `WorkloadClaimSyncResponse`.

        **NATS-only** (controller-to-controller).
      type: object
      properties:
        type:
          type: string
          const: workload_claim_sync_request
        controller_id:
          description: The requesting controller's ID.
          type: string
          format: uuid
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - controller_id
      - protocol_version
      - seq
    workload_claim_sync_responsePayload:
      description: |-
        Controller → NATS: respond with full local claim state.

        Sent in response to `WorkloadClaimSyncRequest`.

        **NATS-only** (controller-to-controller).
      type: object
      properties:
        type:
          type: string
          const: workload_claim_sync_response
        controller_id:
          description: The responding controller's ID.
          type: string
          format: uuid
        claims:
          description: 'Full local claim state: `config_key → (service_id, tenant_id)`.'
          type: object
          additionalProperties:
            $ref: '#/components/schemas/WorkloadClaimSyncEntry'
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
      required:
      - type
      - controller_id
      - claims
      - protocol_version
      - seq
    workload_releasePayload:
      description: |-
        Service → Controller: voluntarily release config keys.

        Sent when a service no longer wants to serve certain configs.
        Requires the `WorkloadClaims` capability.
      type: object
      properties:
        type:
          type: string
          const: workload_release
        keys:
          description: Config keys to release.
          type: array
          uniqueItems: true
          items:
            type: string
        protocol_version:
          type: integer
          format: uint32
          minimum: 0
        seq:
          type: integer
          format: uint64
          minimum: 0
        trace_context:
          $ref: '#/components/schemas/TraceContext'
        pagination:
          $ref: '#/components/schemas/ReportPagination'
      required:
      - type
      - keys
      - protocol_version
      - seq
  messages:
    access_invalidated:
      name: access_invalidated
      payload:
        $ref: '#/components/schemas/access_invalidatedPayload'
    approved:
      name: approved
      payload:
        $ref: '#/components/schemas/approvedPayload'
    audit_event:
      name: audit_event
      payload:
        $ref: '#/components/schemas/audit_eventPayload'
    batch_update_result:
      name: batch_update_result
      payload:
        $ref: '#/components/schemas/batch_update_resultPayload'
    broadcast_admin_event:
      name: broadcast_admin_event
      payload:
        $ref: '#/components/schemas/broadcast_admin_eventPayload'
    ca_bundle_updated:
      name: ca_bundle_updated
      payload:
        $ref: '#/components/schemas/ca_bundle_updatedPayload'
    certificate:
      name: certificate
      payload:
        $ref: '#/components/schemas/certificatePayload'
    check_versions:
      name: check_versions
      payload:
        $ref: '#/components/schemas/check_versionsPayload'
    delete_service_config:
      name: delete_service_config
      payload:
        $ref: '#/components/schemas/delete_service_configPayload'
    disconnecting:
      name: disconnecting
      payload:
        $ref: '#/components/schemas/disconnectingPayload'
    discover_software:
      name: discover_software
      payload:
        $ref: '#/components/schemas/discover_softwarePayload'
    discovery_results:
      name: discovery_results
      payload:
        $ref: '#/components/schemas/discovery_resultsPayload'
    enroll:
      name: enroll
      payload:
        $ref: '#/components/schemas/enrollPayload'
    enrolled:
      name: enrolled
      payload:
        $ref: '#/components/schemas/enrolledPayload'
    error:
      name: error
      payload:
        $ref: '#/components/schemas/errorPayload'
    execute_batch_update:
      name: execute_batch_update
      payload:
        $ref: '#/components/schemas/execute_batch_updatePayload'
    execute_update:
      name: execute_update
      payload:
        $ref: '#/components/schemas/execute_updatePayload'
    host_connectivity_updated:
      name: host_connectivity_updated
      payload:
        $ref: '#/components/schemas/host_connectivity_updatedPayload'
    ping:
      name: ping
      payload:
        $ref: '#/components/schemas/pingPayload'
    pong:
      name: pong
      payload:
        $ref: '#/components/schemas/pongPayload'
    register:
      name: register
      payload:
        $ref: '#/components/schemas/registerPayload'
    rejected:
      name: rejected
      payload:
        $ref: '#/components/schemas/rejectedPayload'
    renew_certificate:
      name: renew_certificate
      payload:
        $ref: '#/components/schemas/renew_certificatePayload'
    report_hosts:
      name: report_hosts
      payload:
        $ref: '#/components/schemas/report_hostsPayload'
    report_plugin_config:
      name: report_plugin_config
      payload:
        $ref: '#/components/schemas/report_plugin_configPayload'
    report_plugin_config_response:
      name: report_plugin_config_response
      payload:
        $ref: '#/components/schemas/report_plugin_config_responsePayload'
    request_ca_rotation:
      name: request_ca_rotation
      payload:
        $ref: '#/components/schemas/request_ca_rotationPayload'
    request_cert_renewal:
      name: request_cert_renewal
      payload:
        $ref: '#/components/schemas/request_cert_renewalPayload'
    request_certificate:
      name: request_certificate
      payload:
        $ref: '#/components/schemas/request_certificatePayload'
    request_crl_renewal:
      name: request_crl_renewal
      payload:
        $ref: '#/components/schemas/request_crl_renewalPayload'
    reset_data:
      name: reset_data
      payload:
        $ref: '#/components/schemas/reset_dataPayload'
    server_restarting:
      name: server_restarting
      payload:
        $ref: '#/components/schemas/server_restartingPayload'
    service_config_ack:
      name: service_config_ack
      payload:
        $ref: '#/components/schemas/service_config_ackPayload'
    service_config_delivery:
      name: service_config_delivery
      payload:
        $ref: '#/components/schemas/service_config_deliveryPayload'
    service_config_updated:
      name: service_config_updated
      payload:
        $ref: '#/components/schemas/service_config_updatedPayload'
    service_credentials:
      name: service_credentials
      payload:
        $ref: '#/components/schemas/service_credentialsPayload'
    service_settings:
      name: service_settings
      payload:
        $ref: '#/components/schemas/service_settingsPayload'
    service_trigger_host_batch_update:
      name: service_trigger_host_batch_update
      payload:
        $ref: '#/components/schemas/service_trigger_host_batch_updatePayload'
    service_trigger_update:
      name: service_trigger_update
      payload:
        $ref: '#/components/schemas/service_trigger_updatePayload'
    set_update_freeze:
      name: set_update_freeze
      payload:
        $ref: '#/components/schemas/set_update_freezePayload'
    software_states:
      name: software_states
      payload:
        $ref: '#/components/schemas/software_statesPayload'
    software_states_changed:
      name: software_states_changed
      payload:
        $ref: '#/components/schemas/software_states_changedPayload'
    stdin_attention:
      name: stdin_attention
      payload:
        $ref: '#/components/schemas/stdin_attentionPayload'
    store_service_config:
      name: store_service_config
      payload:
        $ref: '#/components/schemas/store_service_configPayload'
    surface_action_cancel:
      name: surface_action_cancel
      payload:
        $ref: '#/components/schemas/surface_action_cancelPayload'
    surface_action_request:
      name: surface_action_request
      payload:
        $ref: '#/components/schemas/surface_action_requestPayload'
    surface_action_response:
      name: surface_action_response
      payload:
        $ref: '#/components/schemas/surface_action_responsePayload'
    surface_registration:
      name: surface_registration
      payload:
        $ref: '#/components/schemas/surface_registrationPayload'
    test_plugin_config:
      name: test_plugin_config
      payload:
        $ref: '#/components/schemas/test_plugin_configPayload'
    test_plugin_config_result:
      name: test_plugin_config_result
      payload:
        $ref: '#/components/schemas/test_plugin_config_resultPayload'
    token_revoked:
      name: token_revoked
      payload:
        $ref: '#/components/schemas/token_revokedPayload'
    update_output:
      name: update_output
      payload:
        $ref: '#/components/schemas/update_outputPayload'
    update_result:
      name: update_result
      payload:
        $ref: '#/components/schemas/update_resultPayload'
    update_started:
      name: update_started
      payload:
        $ref: '#/components/schemas/update_startedPayload'
    update_stdin_data:
      name: update_stdin_data
      payload:
        $ref: '#/components/schemas/update_stdin_dataPayload'
    version_check_results:
      name: version_check_results
      payload:
        $ref: '#/components/schemas/version_check_resultsPayload'
    workload_claim:
      name: workload_claim
      payload:
        $ref: '#/components/schemas/workload_claimPayload'
    workload_claim_announcement:
      name: workload_claim_announcement
      payload:
        $ref: '#/components/schemas/workload_claim_announcementPayload'
    workload_claim_result:
      name: workload_claim_result
      payload:
        $ref: '#/components/schemas/workload_claim_resultPayload'
    workload_claim_sync_request:
      name: workload_claim_sync_request
      payload:
        $ref: '#/components/schemas/workload_claim_sync_requestPayload'
    workload_claim_sync_response:
      name: workload_claim_sync_response
      payload:
        $ref: '#/components/schemas/workload_claim_sync_responsePayload'
    workload_release:
      name: workload_release
      payload:
        $ref: '#/components/schemas/workload_releasePayload'