openlatch-client 0.1.18

OpenLatch runtime enforcement node — the capture-and-enforce client for the AI Operations Platform
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
// AUTO-GENERATED by build.rs from schemas/*.schema.json
// DO NOT EDIT — changes will be overwritten on next build.
// To modify types, edit the JSON Schema files in schemas/ and rebuild.

/// Error types.
pub mod error {
    /// Error from a `TryFrom` or `FromStr` implementation.
    pub struct ConversionError(::std::borrow::Cow<'static, str>);
    impl ::std::error::Error for ConversionError {}
    impl ::std::fmt::Display for ConversionError {
        fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
            ::std::fmt::Display::fmt(&self.0, f)
        }
    }
    impl ::std::fmt::Debug for ConversionError {
        fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
            ::std::fmt::Debug::fmt(&self.0, f)
        }
    }
    impl From<&'static str> for ConversionError {
        fn from(value: &'static str) -> Self {
            Self(value.into())
        }
    }
    impl From<String> for ConversionError {
        fn from(value: String) -> Self {
            Self(value.into())
        }
    }
}
///The business function the platform assigned to an agent's owner — the frozen 14-value vocabulary of the Agent Ownership PRD (D9: adding a value is already a contract change plus a client release, so a closed enum here couples nothing new). Closed enum, like ChurnLayer: it is the value type of a policy rule's conditions[].value (policy-bundle.schema.json), where the client compares by enum equality and a value it does not know fails that ONE rule at deserialization (dropped as unrecognized_field, the bundle stays active) — never the whole document. It is deliberately NOT the type of client_config.agent_context.function, which stays an open string carrying this list as x-known-values: client_config is deserialized as one typed object outside the per-rule tolerance, so an enum there would fail the whole bundle (fail-static fleet-wide) on a single unrecognised value. That buys tolerance for an unrecognised WORD only — a non-string function still fails the whole document, because client_config is typed either way. 'unknown' is an ordinary member — a rule listing it matches only agents whose function is 'unknown'; it is never a wildcard.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "The business function the platform assigned to an agent's owner — the frozen 14-value vocabulary of the Agent Ownership PRD (D9: adding a value is already a contract change plus a client release, so a closed enum here couples nothing new). Closed enum, like ChurnLayer: it is the value type of a policy rule's conditions[].value (policy-bundle.schema.json), where the client compares by enum equality and a value it does not know fails that ONE rule at deserialization (dropped as unrecognized_field, the bundle stays active) — never the whole document. It is deliberately NOT the type of client_config.agent_context.function, which stays an open string carrying this list as x-known-values: client_config is deserialized as one typed object outside the per-rule tolerance, so an enum there would fail the whole bundle (fail-static fleet-wide) on a single unrecognised value. That buys tolerance for an unrecognised WORD only — a non-string function still fails the whole document, because client_config is typed either way. 'unknown' is an ordinary member — a rule listing it matches only agents whose function is 'unknown'; it is never a wildcard.",
///  "type": "string",
///  "enum": [
///    "engineering",
///    "product",
///    "data",
///    "security",
///    "it_ops",
///    "sales",
///    "marketing",
///    "finance",
///    "legal",
///    "hr",
///    "support",
///    "research",
///    "other",
///    "unknown"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum AgentFunction {
    #[serde(rename = "engineering")]
    Engineering,
    #[serde(rename = "product")]
    Product,
    #[serde(rename = "data")]
    Data,
    #[serde(rename = "security")]
    Security,
    #[serde(rename = "it_ops")]
    ItOps,
    #[serde(rename = "sales")]
    Sales,
    #[serde(rename = "marketing")]
    Marketing,
    #[serde(rename = "finance")]
    Finance,
    #[serde(rename = "legal")]
    Legal,
    #[serde(rename = "hr")]
    Hr,
    #[serde(rename = "support")]
    Support,
    #[serde(rename = "research")]
    Research,
    #[serde(rename = "other")]
    Other,
    #[serde(rename = "unknown")]
    Unknown,
}
impl ::std::fmt::Display for AgentFunction {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::Engineering => f.write_str("engineering"),
            Self::Product => f.write_str("product"),
            Self::Data => f.write_str("data"),
            Self::Security => f.write_str("security"),
            Self::ItOps => f.write_str("it_ops"),
            Self::Sales => f.write_str("sales"),
            Self::Marketing => f.write_str("marketing"),
            Self::Finance => f.write_str("finance"),
            Self::Legal => f.write_str("legal"),
            Self::Hr => f.write_str("hr"),
            Self::Support => f.write_str("support"),
            Self::Research => f.write_str("research"),
            Self::Other => f.write_str("other"),
            Self::Unknown => f.write_str("unknown"),
        }
    }
}
impl ::std::str::FromStr for AgentFunction {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "engineering" => Ok(Self::Engineering),
            "product" => Ok(Self::Product),
            "data" => Ok(Self::Data),
            "security" => Ok(Self::Security),
            "it_ops" => Ok(Self::ItOps),
            "sales" => Ok(Self::Sales),
            "marketing" => Ok(Self::Marketing),
            "finance" => Ok(Self::Finance),
            "legal" => Ok(Self::Legal),
            "hr" => Ok(Self::Hr),
            "support" => Ok(Self::Support),
            "research" => Ok(Self::Research),
            "other" => Ok(Self::Other),
            "unknown" => Ok(Self::Unknown),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for AgentFunction {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for AgentFunction {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for AgentFunction {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///Response from GET /api/v1/users/me for auth status validation (D-19) and PostHog identity stitching (telemetry Phase C). user_db_id, when present, is used as the persistent distinct_id and triggers a one-time $create_alias merging prior agent_id events into the platform person. Mirrors the `id` field on the platform side; both carry the stable better-auth user TEXT primary key.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Response from GET /api/v1/users/me for auth status validation (D-19) and PostHog identity stitching (telemetry Phase C). user_db_id, when present, is used as the persistent distinct_id and triggers a one-time $create_alias merging prior agent_id events into the platform person. Mirrors the `id` field on the platform side; both carry the stable better-auth user TEXT primary key.",
///  "examples": [
///    {
///      "email": "alice@example.com",
///      "id": "usr_019d8af1-f8da-73b3-92eb-79a99e59b10b",
///      "organization_id": "a1b2c3d4-e5f6-4000-a000-000000000001",
///      "organization_name": "Acme Corp",
///      "user_db_id": "usr_019d8af1-f8da-73b3-92eb-79a99e59b10b"
///    }
///  ],
///  "type": "object",
///  "properties": {
///    "email": {
///      "description": "Email of the authenticated user.",
///      "type": "string"
///    },
///    "id": {
///      "description": "Stable database identifier for the authenticated user (better-auth user.id). Mirror of user_db_id — either field may be read; prefer user_db_id for telemetry alias semantics.",
///      "type": "string"
///    },
///    "organization_id": {
///      "description": "Organization id for the user's active organization.",
///      "type": "string"
///    },
///    "organization_name": {
///      "description": "Human-readable display name of the user's active organization. Surfaced by the client on re-runs of `openlatch init` so the user can confirm which org their cached credential belongs to. Optional — when absent, the client displays `Authenticated` without the parenthetical org suffix.",
///      "type": "string"
///    },
///    "user_db_id": {
///      "description": "Stable database identifier for the authenticated user. Used as the PostHog distinct_id post-auth and as the alias target for $create_alias. Optional in this client schema for backwards compatibility — older platforms may not return it; client falls back to agent_id and skips the alias when absent.",
///      "type": "string"
///    }
///  },
///  "additionalProperties": true,
///  "x-postgresql-skip": true
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
pub struct AuthMeResponse {
    ///Email of the authenticated user.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub email: ::std::option::Option<::std::string::String>,
    ///Stable database identifier for the authenticated user (better-auth user.id). Mirror of user_db_id — either field may be read; prefer user_db_id for telemetry alias semantics.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub id: ::std::option::Option<::std::string::String>,
    ///Organization id for the user's active organization.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub organization_id: ::std::option::Option<::std::string::String>,
    ///Human-readable display name of the user's active organization. Surfaced by the client on re-runs of `openlatch init` so the user can confirm which org their cached credential belongs to. Optional — when absent, the client displays `Authenticated` without the parenthetical org suffix.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub organization_name: ::std::option::Option<::std::string::String>,
    ///Stable database identifier for the authenticated user. Used as the PostHog distinct_id post-auth and as the alias target for $create_alias. Optional in this client schema for backwards compatibility — older platforms may not return it; client falls back to agent_id and skips the alias when absent.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub user_db_id: ::std::option::Option<::std::string::String>,
}
impl ::std::default::Default for AuthMeResponse {
    fn default() -> Self {
        Self {
            email: Default::default(),
            id: Default::default(),
            organization_id: Default::default(),
            organization_name: Default::default(),
            user_db_id: Default::default(),
        }
    }
}
///Which prompt-cache layer a kind=request policy rule targets — the frozen churn_layer enum owned by the Model Boundary Enforcement Layer. 'tools' invalidates everything downstream on a change; 'messages' the least. Closed enum, like Verdict: the values are a contract between the platform's rule author and the client's boundary listener, so the client branches exhaustively on them. A hand-written boundary-internal twin exists at src/boundary/churn.rs; this $def is the wire-side type and the single owner of the values.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Which prompt-cache layer a kind=request policy rule targets — the frozen churn_layer enum owned by the Model Boundary Enforcement Layer. 'tools' invalidates everything downstream on a change; 'messages' the least. Closed enum, like Verdict: the values are a contract between the platform's rule author and the client's boundary listener, so the client branches exhaustively on them. A hand-written boundary-internal twin exists at src/boundary/churn.rs; this $def is the wire-side type and the single owner of the values.",
///  "type": "string",
///  "enum": [
///    "tools",
///    "system",
///    "messages"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum ChurnLayer {
    #[serde(rename = "tools")]
    Tools,
    #[serde(rename = "system")]
    System,
    #[serde(rename = "messages")]
    Messages,
}
impl ::std::fmt::Display for ChurnLayer {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::Tools => f.write_str("tools"),
            Self::System => f.write_str("system"),
            Self::Messages => f.write_str("messages"),
        }
    }
}
impl ::std::str::FromStr for ChurnLayer {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "tools" => Ok(Self::Tools),
            "system" => Ok(Self::System),
            "messages" => Ok(Self::Messages),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for ChurnLayer {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for ChurnLayer {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for ChurnLayer {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///HTTP request body for POST /api/v1/events/ingest sent by openlatch-client. CloudEvents v1.0.2 batch mode — a bare JSON array of EventEnvelope objects, sent with Content-Type: application/cloudevents-batch+json. Client-wide metadata (schema_version, agent_id) is carried on each CloudEvent via extension attributes rather than a wrapper object.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "HTTP request body for POST /api/v1/events/ingest sent by openlatch-client. CloudEvents v1.0.2 batch mode — a bare JSON array of EventEnvelope objects, sent with Content-Type: application/cloudevents-batch+json. Client-wide metadata (schema_version, agent_id) is carried on each CloudEvent via extension attributes rather than a wrapper object.",
///  "examples": [
///    [
///      {
///        "arch": "x86_64",
///        "clientversion": "0.2.0",
///        "data": {
///          "tool_input": {
///            "command": "ls -la"
///          },
///          "tool_name": "Bash"
///        },
///        "datacontenttype": "application/json",
///        "id": "evt_019d8af1-f8da-73b3-92eb-79a99e59b10b",
///        "os": "linux",
///        "source": "claude-code",
///        "specversion": "1.0",
///        "subject": "sess_abc123",
///        "time": "2026-04-16T12:00:00Z",
///        "type": "pre_tool_use"
///      }
///    ]
///  ],
///  "type": "array",
///  "items": {
///    "$ref": "#/$defs/EventEnvelope"
///  },
///  "maxItems": 100,
///  "minItems": 1,
///  "x-postgresql-skip": true
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(transparent)]
pub struct CloudIngestionRequest(pub ::std::vec::Vec<EventEnvelope>);
impl ::std::ops::Deref for CloudIngestionRequest {
    type Target = ::std::vec::Vec<EventEnvelope>;
    fn deref(&self) -> &::std::vec::Vec<EventEnvelope> {
        &self.0
    }
}
impl ::std::convert::From<CloudIngestionRequest> for ::std::vec::Vec<EventEnvelope> {
    fn from(value: CloudIngestionRequest) -> Self {
        value.0
    }
}
impl ::std::convert::From<::std::vec::Vec<EventEnvelope>> for CloudIngestionRequest {
    fn from(value: ::std::vec::Vec<EventEnvelope>) -> Self {
        Self(value)
    }
}
///HTTP response body for POST /api/v1/events/ingest returned to openlatch-client. The client uses status to determine whether to retry, and event_id to correlate verdicts.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "HTTP response body for POST /api/v1/events/ingest returned to openlatch-client. The client uses status to determine whether to retry, and event_id to correlate verdicts.",
///  "examples": [
///    {
///      "event_id": "019d8af1-f8da-73b3-92eb-79a99e59b10b",
///      "status": "accepted"
///    },
///    {
///      "error": "Envelope failed schema validation: missing required attribute 'specversion'",
///      "status": "rejected"
///    }
///  ],
///  "type": "object",
///  "required": [
///    "status"
///  ],
///  "properties": {
///    "error": {
///      "description": "Human-readable error description. Present when status is rejected.",
///      "type": "string"
///    },
///    "event_id": {
///      "description": "Server-assigned UUIDv7 event_id for the stored event. Present when status is accepted.",
///      "type": "string"
///    },
///    "status": {
///      "description": "Ingestion outcome — accepted means persisted (or duplicate), rejected means permanently invalid.",
///      "type": "string",
///      "enum": [
///        "accepted",
///        "rejected"
///      ]
///    }
///  },
///  "additionalProperties": false,
///  "x-postgresql-skip": true
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct CloudIngestionResponse {
    ///Human-readable error description. Present when status is rejected.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub error: ::std::option::Option<::std::string::String>,
    ///Server-assigned UUIDv7 event_id for the stored event. Present when status is accepted.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub event_id: ::std::option::Option<::std::string::String>,
    ///Ingestion outcome — accepted means persisted (or duplicate), rejected means permanently invalid.
    pub status: CloudIngestionResponseStatus,
}
///Ingestion outcome — accepted means persisted (or duplicate), rejected means permanently invalid.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Ingestion outcome — accepted means persisted (or duplicate), rejected means permanently invalid.",
///  "type": "string",
///  "enum": [
///    "accepted",
///    "rejected"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum CloudIngestionResponseStatus {
    #[serde(rename = "accepted")]
    Accepted,
    #[serde(rename = "rejected")]
    Rejected,
}
impl ::std::fmt::Display for CloudIngestionResponseStatus {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::Accepted => f.write_str("accepted"),
            Self::Rejected => f.write_str("rejected"),
        }
    }
}
impl ::std::str::FromStr for CloudIngestionResponseStatus {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "accepted" => Ok(Self::Accepted),
            "rejected" => Ok(Self::Rejected),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for CloudIngestionResponseStatus {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for CloudIngestionResponseStatus {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for CloudIngestionResponseStatus {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///CloudEvents v1.0.2 structured-mode envelope for agent hook events. Content-Type is application/cloudevents+json (single) or application/cloudevents-batch+json (batch). The 'data' field contains the raw agent payload untouched; all OpenLatch metadata lives in CloudEvents extension attributes. Extension attribute names MUST match ^[a-z0-9]+$ per the CloudEvents spec. verdict and latency_ms are NOT on the wire — they are produced by the daemon after processing and attached to stored events as the olverdict and ollatencyms extension attributes.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "CloudEvents v1.0.2 structured-mode envelope for agent hook events. Content-Type is application/cloudevents+json (single) or application/cloudevents-batch+json (batch). The 'data' field contains the raw agent payload untouched; all OpenLatch metadata lives in CloudEvents extension attributes. Extension attribute names MUST match ^[a-z0-9]+$ per the CloudEvents spec. verdict and latency_ms are NOT on the wire — they are produced by the daemon after processing and attached to stored events as the olverdict and ollatencyms extension attributes.",
///  "examples": [
///    {
///      "agentversion": "1.2.0",
///      "arch": "x86_64",
///      "clientversion": "0.2.0",
///      "data": {
///        "tool_input": {
///          "command": "ls -la"
///        },
///        "tool_name": "Bash"
///      },
///      "datacontenttype": "application/json",
///      "id": "evt_019d8af1-f8da-73b3-92eb-79a99e59b10b",
///      "localipv4": "192.168.1.42",
///      "os": "linux",
///      "publicipv4": "203.0.113.7",
///      "source": "claude-code",
///      "specversion": "1.0",
///      "subject": "sess_abc123",
///      "time": "2026-04-16T12:00:00Z",
///      "type": "pre_tool_use"
///    }
///  ],
///  "type": "object",
///  "required": [
///    "id",
///    "source",
///    "specversion",
///    "time",
///    "type"
///  ],
///  "properties": {
///    "agentid": {
///      "description": "OpenLatch extension. Stamped by the daemon on outbound events — identifies the AI agent install (one openlatch-client installation) that emitted this event (agt_<uuid>).",
///      "type": "string"
///    },
///    "agentversion": {
///      "description": "OpenLatch extension (was 'agent_version'). Agent software version, if reported by the hook.",
///      "type": "string"
///    },
///    "arch": {
///      "description": "OpenLatch extension. CPU architecture ('x86_64', 'aarch64').",
///      "type": "string"
///    },
///    "clientversion": {
///      "description": "OpenLatch extension (was 'client_version'). Semver of the openlatch-client that emitted the envelope.",
///      "type": "string"
///    },
///    "data": {
///      "description": "Raw agent payload, forwarded verbatim. Shape is agent-specific (e.g. Claude Code PreToolUse emits { tool_name, tool_input, … }; Cursor beforeShellExecution emits { command, … }). OpenLatch does NOT normalise this field. When `type` is `ai.openlatch.config.*` and `configkind` is `mcp`, the payload may additionally include an optional `scope` key — one of `enterprise` / `personal` / `project` / `local` — declaring the precedence tier of the source path; the cloud routing engine reads it to resolve same-named MCP servers across multiple filesystem locations."
///    },
///    "datacontenttype": {
///      "description": "Media type of the 'data' field. CloudEvents core optional attribute. Fixed to application/json for all OpenLatch events.",
///      "type": "string",
///      "const": "application/json"
///    },
///    "gitemail": {
///      "description": "OpenLatch extension. git config user.email for the session's working directory. Absent outside a repository.",
///      "type": "string"
///    },
///    "id": {
///      "description": "Unique event identifier — UUIDv7 with 'evt_' prefix. CloudEvents core attribute.",
///      "type": "string"
///    },
///    "localipv4": {
///      "description": "OpenLatch extension (was 'local_ipv4'). Machine's local IPv4 address. Detected once at daemon startup, cached for the process lifetime. Omitted when no non-loopback interface is available.",
///      "type": "string",
///      "format": "ipv4"
///    },
///    "localipv6": {
///      "description": "OpenLatch extension (was 'local_ipv6'). Machine's local IPv6 address.",
///      "type": "string",
///      "format": "ipv6"
///    },
///    "os": {
///      "description": "OpenLatch extension. Operating system ('linux', 'macos', 'windows'). CloudEvents extension — lowercase alphanumeric attribute name.",
///      "type": "string"
///    },
///    "osuser": {
///      "description": "OpenLatch extension. Logged-in OS user on the host. Absent when capture is disabled or no interactive user exists.",
///      "type": "string"
///    },
///    "provideracct": {
///      "description": "OpenLatch extension. AI-provider account identifier, or the literal shared-key when the credential carries no human. Never a token or key.",
///      "type": "string"
///    },
///    "publicipv4": {
///      "description": "OpenLatch extension (was 'public_ipv4'). Machine's public IPv4 address.",
///      "type": "string",
///      "format": "ipv4"
///    },
///    "publicipv6": {
///      "description": "OpenLatch extension (was 'public_ipv6'). Machine's public IPv6 address.",
///      "type": "string",
///      "format": "ipv6"
///    },
///    "source": {
///      "description": "Agent platform identifier (was 'agent_platform'). CloudEvents core attribute. Bare string per OpenLatch convention; any string is valid. See x-known-values in enums.schema.json#/$defs/AgentType for the canonical set.",
///      "$ref": "#/$defs/AgentType"
///    },
///    "specversion": {
///      "description": "CloudEvents spec version. MUST be '1.0' for CloudEvents v1.0.2.",
///      "type": "string",
///      "const": "1.0"
///    },
///    "subject": {
///      "description": "CloudEvents 'subject' attribute. OpenLatch uses this for the agent session identifier (was 'session_id'). Consumers can group events by subject for per-session analytics.",
///      "type": "string"
///    },
///    "time": {
///      "description": "Event creation timestamp (was 'timestamp'). RFC 3339 UTC with Z suffix. CloudEvents core attribute.",
///      "type": "string",
///      "format": "date-time"
///    },
///    "type": {
///      "description": "Hook event lifecycle name (was 'event_type'). CloudEvents core attribute. Any string is valid. See x-known-values in enums.schema.json#/$defs/HookEventType for the canonical set.",
///      "$ref": "#/$defs/HookEventType"
///    }
///  },
///  "additionalProperties": true,
///  "x-postgresql-skip": true
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
pub struct EventEnvelope {
    ///OpenLatch extension. Stamped by the daemon on outbound events — identifies the AI agent install (one openlatch-client installation) that emitted this event (agt_<uuid>).
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub agentid: ::std::option::Option<::std::string::String>,
    ///OpenLatch extension (was 'agent_version'). Agent software version, if reported by the hook.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub agentversion: ::std::option::Option<::std::string::String>,
    ///OpenLatch extension. CPU architecture ('x86_64', 'aarch64').
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub arch: ::std::option::Option<::std::string::String>,
    ///OpenLatch extension (was 'client_version'). Semver of the openlatch-client that emitted the envelope.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub clientversion: ::std::option::Option<::std::string::String>,
    ///Raw agent payload, forwarded verbatim. Shape is agent-specific (e.g. Claude Code PreToolUse emits { tool_name, tool_input, … }; Cursor beforeShellExecution emits { command, … }). OpenLatch does NOT normalise this field. When `type` is `ai.openlatch.config.*` and `configkind` is `mcp`, the payload may additionally include an optional `scope` key — one of `enterprise` / `personal` / `project` / `local` — declaring the precedence tier of the source path; the cloud routing engine reads it to resolve same-named MCP servers across multiple filesystem locations.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub data: ::std::option::Option<::serde_json::Value>,
    ///Media type of the 'data' field. CloudEvents core optional attribute. Fixed to application/json for all OpenLatch events.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub datacontenttype: ::std::option::Option<::std::string::String>,
    ///OpenLatch extension. git config user.email for the session's working directory. Absent outside a repository.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub gitemail: ::std::option::Option<::std::string::String>,
    ///Unique event identifier — UUIDv7 with 'evt_' prefix. CloudEvents core attribute.
    pub id: ::std::string::String,
    ///OpenLatch extension (was 'local_ipv4'). Machine's local IPv4 address. Detected once at daemon startup, cached for the process lifetime. Omitted when no non-loopback interface is available.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub localipv4: ::std::option::Option<::std::net::Ipv4Addr>,
    ///OpenLatch extension (was 'local_ipv6'). Machine's local IPv6 address.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub localipv6: ::std::option::Option<::std::net::Ipv6Addr>,
    ///OpenLatch extension. Operating system ('linux', 'macos', 'windows'). CloudEvents extension — lowercase alphanumeric attribute name.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub os: ::std::option::Option<::std::string::String>,
    ///OpenLatch extension. Logged-in OS user on the host. Absent when capture is disabled or no interactive user exists.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub osuser: ::std::option::Option<::std::string::String>,
    ///OpenLatch extension. AI-provider account identifier, or the literal shared-key when the credential carries no human. Never a token or key.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub provideracct: ::std::option::Option<::std::string::String>,
    ///OpenLatch extension (was 'public_ipv4'). Machine's public IPv4 address.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub publicipv4: ::std::option::Option<::std::net::Ipv4Addr>,
    ///OpenLatch extension (was 'public_ipv6'). Machine's public IPv6 address.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub publicipv6: ::std::option::Option<::std::net::Ipv6Addr>,
    ///Agent platform identifier (was 'agent_platform'). CloudEvents core attribute. Bare string per OpenLatch convention; any string is valid. See x-known-values in enums.schema.json#/$defs/AgentType for the canonical set.
    pub source: crate::core::envelope::known_types::AgentType,
    ///CloudEvents spec version. MUST be '1.0' for CloudEvents v1.0.2.
    pub specversion: ::std::string::String,
    ///CloudEvents 'subject' attribute. OpenLatch uses this for the agent session identifier (was 'session_id'). Consumers can group events by subject for per-session analytics.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub subject: ::std::option::Option<::std::string::String>,
    ///Event creation timestamp (was 'timestamp'). RFC 3339 UTC with Z suffix. CloudEvents core attribute.
    pub time: ::chrono::DateTime<::chrono::offset::Utc>,
    ///Hook event lifecycle name (was 'event_type'). CloudEvents core attribute. Any string is valid. See x-known-values in enums.schema.json#/$defs/HookEventType for the canonical set.
    #[serde(rename = "type")]
    pub type_: crate::core::envelope::known_types::HookEventType,
}
///The policy bundle served by GET /api/v1/policy/bundle and held resident by the daemon. Canonicalized by the platform with RFC 8785 (JCS); the ETag is 'sha256:<hex>' over exactly those bytes and the client verifies the digest against the raw response body it received — it MUST NOT re-serialize before hashing. The bundle carries strings, booleans, integers and null only: no floats anywhere, which eliminates the RFC 8785 ES6 Number::toString divergence between Python and Rust by construction. A resident bundle keeps enforcing offline forever; there is no expiry.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "The policy bundle served by GET /api/v1/policy/bundle and held resident by the daemon. Canonicalized by the platform with RFC 8785 (JCS); the ETag is 'sha256:<hex>' over exactly those bytes and the client verifies the digest against the raw response body it received — it MUST NOT re-serialize before hashing. The bundle carries strings, booleans, integers and null only: no floats anywhere, which eliminates the RFC 8785 ES6 Number::toString divergence between Python and Rust by construction. A resident bundle keeps enforcing offline forever; there is no expiry.",
///  "examples": [
///    {
///      "built_at": "2026-07-21T09:00:00Z",
///      "enforcement_enabled": true,
///      "organization_id": "0192f8a1-4c3b-7e2a-9f10-5d8c3b1a7e42",
///      "revision": 42,
///      "rules": [
///        {
///          "action": "deny",
///          "kind": "command",
///          "match_pattern": "*rm -rf /*",
///          "mode": "enforce",
///          "reason": "Recursive delete of a root path",
///          "rule_id": "OL-CMD-001",
///          "severity": "critical"
///        }
///      ],
///      "schema_version": 1,
///      "signature": null
///    },
///    {
///      "built_at": "2026-07-20T11:30:00Z",
///      "enforcement_enabled": true,
///      "organization_id": "0192f8a1-4c3b-7e2a-9f10-5d8c3b1a7e42",
///      "revision": 1,
///      "rules": [],
///      "schema_version": 1,
///      "signature": null
///    },
///    {
///      "built_at": "2026-07-24T14:05:00Z",
///      "enforcement_enabled": true,
///      "organization_id": "0192f8a1-4c3b-7e2a-9f10-5d8c3b1a7e42",
///      "revision": 77,
///      "rules": [
///        {
///          "action": "deny",
///          "kind": "command",
///          "match_pattern": "*rm -rf /*",
///          "mode": "enforce",
///          "reason": "Recursive delete of a root path",
///          "rule_id": "OL-CMD-001",
///          "severity": "critical"
///        },
///        {
///          "action": "prefix_reorder",
///          "kind": "request",
///          "mode": "observe",
///          "reason": "Stabilize the cache prefix so the tool block stops churning",
///          "rule_id": "OL-REQ-001",
///          "rule_version": 3,
///          "select": {
///            "exclude_layers": [
///              "tools"
///            ],
///            "model_in": [
///              "claude-opus-5"
///            ]
///          },
///          "severity": "low"
///        },
///        {
///          "action": "prefix_reorder",
///          "kind": "request",
///          "mode": "observe",
///          "params": {
///            "mechanism": "insert_breakpoints"
///          },
///          "reason": "Repeated context is served at full input price (only 22% cache-read); caching the stable prefix recovers most of it",
///          "rule_id": "OL-ECO-CACHE-3f9c1a2b",
///          "rule_version": 1,
///          "severity": "medium"
///        },
///        {
///          "action": "history_trim",
///          "kind": "request",
///          "mode": "observe",
///          "params": {
///            "keep_messages": 20
///          },
///          "reason": "Long sessions carry more history than the task needs",
///          "rule_id": "OL-REQ-002",
///          "rule_version": 1,
///          "select": {
///            "min_messages": 40
///          },
///          "severity": "low"
///        }
///      ],
///      "schema_version": 1,
///      "signature": null
///    },
///    {
///      "built_at": "2026-08-16T08:00:00Z",
///      "enforcement_enabled": true,
///      "organization_id": "0192f8a1-4c3b-7e2a-9f10-5d8c3b1a7e42",
///      "revision": 79,
///      "rules": [
///        {
///          "action": "deny",
///          "kind": "command",
///          "match_pattern": "*rm -rf /*",
///          "mode": "enforce",
///          "reason": "Recursive delete of a root path",
///          "rule_id": "OL-CMD-001",
///          "severity": "critical"
///        },
///        {
///          "action": "deny",
///          "conditions": [
///            {
///              "field": "agent.function",
///              "op": "in",
///              "value": [
///                "marketing",
///                "sales"
///              ]
///            }
///          ],
///          "kind": "command",
///          "match_pattern": "*psql*",
///          "mode": "enforce",
///          "reason": "Direct database access is not part of a marketing or sales workflow",
///          "rule_id": "OL-CMD-002",
///          "severity": "high"
///        }
///      ],
///      "schema_version": 1,
///      "signature": null
///    },
///    {
///      "built_at": "2026-08-16T08:00:00Z",
///      "client_config": {
///        "agent_context": {
///          "function": "unknown"
///        },
///        "capture_identity_signals": true
///      },
///      "enforcement_enabled": true,
///      "organization_id": "0192f8a1-4c3b-7e2a-9f10-5d8c3b1a7e42",
///      "revision": 80,
///      "rules": [
///        {
///          "action": "deny",
///          "conditions": [
///            {
///              "field": "agent.function",
///              "op": "in",
///              "value": [
///                "unknown"
///              ]
///            }
///          ],
///          "kind": "command",
///          "match_pattern": "*curl*",
///          "mode": "observe",
///          "reason": "Outbound transfers from an agent nobody has claimed are reviewed before they are allowed",
///          "rule_id": "OL-CMD-003",
///          "severity": "medium"
///        }
///      ],
///      "schema_version": 1,
///      "signature": null
///    }
///  ],
///  "type": "object",
///  "required": [
///    "built_at",
///    "enforcement_enabled",
///    "organization_id",
///    "revision",
///    "rules",
///    "schema_version",
///    "signature"
///  ],
///  "properties": {
///    "built_at": {
///      "description": "RFC 3339 UTC timestamp with a Z suffix (microsecond precision allowed) recording when the rule content last actually changed — not when the bundle was served. Drives olpolicybundleage (now minus built_at, clamped at 0), which measures policy freshness. It does NOT drive the staleness warning, which is measured from the last successful fetch. Deliberately a plain string rather than format: date-time so the generated Rust type stays a String; the poller parses it once into a SystemTime.",
///      "type": "string"
///    },
///    "client_config": {
///      "description": "Client-bound configuration delivered on the bundle — the only client-bound configuration channel. Optional; a client that never receives it captures nothing (fail closed). The platform MUST NOT emit this field to a fleet that still runs clients predating it: the bundle root is additionalProperties:false, so such a client rejects the whole document (OL-1212) and fails static on its previous rules.",
///      "type": "object",
///      "properties": {
///        "agent_context": {
///          "description": "This install's own agent context, composed by the platform at serve time from the X-OpenLatch-Agent-Id header the poller sends — one object about THIS agent, never a fleet roster. Optional: a client that never receives it holds no context, and every rule carrying conditions matches nothing (absent context is not 'unknown'). Tolerant like its parent, so a newer platform can add keys without failing older clients.",
///          "type": "object",
///          "properties": {
///            "function": {
///              "description": "The business function assigned to this agent's owner. Deliberately an OPEN string carrying the AgentFunction vocabulary as x-known-values rather than a $ref to that enum — the same reasoning as params.mechanism: client_config is deserialized as one typed object outside the per-rule tolerance, so an enum here would fail the WHOLE bundle (fleet-wide fail-static) on a single out-of-vocabulary value. The client parses it into AgentFunction at load; a STRING value it cannot parse reads as no context, so scoped rules match nothing rather than the bundle being rejected. The tolerance is over the vocabulary, not the shape: a non-string value here (or a non-object agent_context) is a malformed client_config and does fail the whole document, exactly as a malformed capture_identity_signals does. 'unknown' is a real platform-assigned value, distinct from the field being absent.",
///              "type": "string",
///              "x-known-values": [
///                "engineering",
///                "product",
///                "data",
///                "security",
///                "it_ops",
///                "sales",
///                "marketing",
///                "finance",
///                "legal",
///                "hr",
///                "support",
///                "research",
///                "other",
///                "unknown"
///              ]
///            }
///          },
///          "additionalProperties": true
///        },
///        "capture_identity_signals": {
///          "description": "The client's copy of the org setting identity.capture_signals. Identity signals are captured and stamped only when this is explicitly true.",
///          "type": "boolean"
///        }
///      },
///      "additionalProperties": true
///    },
///    "enforcement_enabled": {
///      "description": "The organization-wide kill switch. When false, every rule behaves as observe regardless of its own mode — matches produce a shadow verdict and nothing is blocked. Stored outside the built artifact on the platform so it survives every rebuild.",
///      "type": "boolean"
///    },
///    "organization_id": {
///      "description": "Canonical UUID form of the owning organization, matching the platform's organization_id column — not the API-key prefix. The client learns its own org from GET /api/v1/users/me, caches it in bundle.meta.json, and MUST reject a bundle whose value differs (OL-1211). Never evaluate another org's rules.",
///      "type": "string"
///    },
///    "revision": {
///      "description": "Monotonic per organization, incrementing only on real content change — a rebuild over unchanged rules is a no-op that leaves this untouched. Serialized as a JSON number and treated as i64 in Rust. Recorded on every verdict as olpolicybundlerev: the replay key.",
///      "type": "integer"
///    },
///    "rules": {
///      "description": "The active rule set, sorted by rule_id so the serialization is deterministic. May be empty, which means 'allow everything' and is distinguishable in telemetry from 'no bundle' because olpolicybundlerev is still stamped. Rules disabled by the author are omitted at build time — every rule present here is active.",
///      "type": "array",
///      "items": {
///        "title": "PolicyRule",
///        "description": "One authored rule, on either plane. A kind=command rule is evaluated against the normalized command string extracted from a pre_tool_use envelope. A kind=request rule targets an outbound model request at the boundary and is held, not evaluated, in v1. The allOf below is the per-kind/per-action gate: the platform enforces it at authoring time (422) and the client validates every rule against it individually at bundle load, skipping the ones that fail — one bad rule must never cost the fleet its denies.",
///        "type": "object",
///        "required": [
///          "action",
///          "kind",
///          "mode",
///          "reason",
///          "rule_id",
///          "severity"
///        ],
///        "properties": {
///          "action": {
///            "description": "What a match does. Authorable actions are 'deny' (the only one on kind=command) and 'prefix_reorder', 'history_trim', 'prompt_edit' (kind=request). Which action is legal for which kind is owned by the gate below, not by this list. An open string for the same forward-compatibility reason as kind.",
///            "type": "string"
///          },
///          "conditions": {
///            "description": "Which agents the rule applies to, decided locally by the client against the client_config.agent_context THIS install received — the network is not on the evaluation path. Absent (or empty) means unconditional: the rule applies on every agent, exactly as before this field existed. When present, EVERY condition must hold (AND semantics), and a rule whose context never arrived matches nothing — absent context is not 'unknown'. v1 is the command plane only: forbidden on kind=request by the gate below, and the only vocabulary is field 'agent.function' with op 'in'. The field/op enums are the general shape, so widening either later is additive; a client that predates a widening drops that one rule at load (unrecognized_field) and keeps the bundle. Values are the closed AgentFunction enum, so a value the client does not know fails that one rule at deserialization, never the whole document. 'unknown' is an ordinary value, not a wildcard.",
///            "type": "array",
///            "items": {
///              "type": "object",
///              "required": [
///                "field",
///                "op",
///                "value"
///              ],
///              "properties": {
///                "field": {
///                  "description": "The agent-context attribute the condition reads. v1 knows exactly one: 'agent.function', read from client_config.agent_context.function.",
///                  "type": "string",
///                  "enum": [
///                    "agent.function"
///                  ]
///                },
///                "op": {
///                  "description": "The comparison. v1 knows exactly one: 'in' — the attribute's value is a member of `value`. Several conditions on the same field AND together, so two 'in' sets intersect.",
///                  "type": "string",
///                  "enum": [
///                    "in"
///                  ]
///                },
///                "value": {
///                  "description": "The set the attribute must belong to. At least one member — an empty set would match nothing while looking like a scoped rule, and the platform rejects it at authoring (422). Compared by enum equality on the client.",
///                  "type": "array",
///                  "items": {
///                    "$ref": "#/$defs/AgentFunction"
///                  },
///                  "minItems": 1
///                }
///              },
///              "additionalProperties": false
///            }
///          },
///          "kind": {
///            "description": "Which plane the rule acts on. Two kinds are authorable: 'command' (a shell command intercepted at the pre_tool_use hook) and 'request' (an outbound model request intercepted at the boundary). Deliberately an open string rather than a closed enum: the client MUST skip a rule whose kind it does not recognize and keep the rest of the bundle active, so that a v1 client tolerates a v1.1 bundle. A closed enum would fail deserialization of the whole document instead.",
///            "type": "string"
///          },
///          "match_pattern": {
///            "description": "Required for kind=command and forbidden for kind=request — see the gate below; it is optional in the base only so that a request rule does not fail deserialization on a client that predates the gate. Fully-anchored, case-sensitive glob over the entire normalized command string. Exactly two metacharacters: '*' (any sequence including empty, crossing '/' and every other character — this is not path-aware globbing) and '?' (exactly one character). No character classes, no escapes, no alternation, no regex. Anchoring surprises authors: 'rm -rf /*' does not match 'sudo rm -rf /tmp'; write '*rm -rf*' to catch a command anywhere in the string. The platform normalizes and validates this at authoring time and rejects empty, over-1024-character, control-character-bearing, and bare-'*' patterns with 422.",
///            "type": "string"
///          },
///          "mode": {
///            "description": "Staged rollout control. 'observe' records a shadow verdict and allows the action; 'enforce' denies it. Most restrictive wins across matching rules. Overridden to observe for every rule when enforcement_enabled is false.",
///            "type": "string",
///            "enum": [
///              "observe",
///              "enforce"
///            ]
///          },
///          "params": {
///            "description": "How a kind=request rule transforms the request. Forbidden on kind=command. Exactly which keys are required and which are rejected is per-action, in the gate below.",
///            "type": "object",
///            "properties": {
///              "keep_messages": {
///                "description": "How many of the most recent messages history_trim retains. Required by history_trim, rejected everywhere else.",
///                "type": "integer"
///              },
///              "marker": {
///                "description": "The literal marker prompt_edit rewrites around. Deliberately unconstrained here: a length or pattern keyword would make the generated Rust type a constrained newtype whose deserializer fails the WHOLE bundle on one over-long value. Length is bounded platform-side at authoring.",
///                "type": "string"
///              },
///              "max_system_tokens": {
///                "description": "Token ceiling prompt_edit trims the system block to. Alternative to marker — exactly one of the two is required.",
///                "type": "integer"
///              },
///              "mechanism": {
///                "description": "Which caching intervention a prefix_reorder rule means. The detector that authors these rules fires on two different causes needing two different interventions, and the action alone cannot tell them apart: 'insert_breakpoints' — nothing is being cached at all, so cache_control breakpoints must be INJECTED; 'reorder_blocks' — breakpoints exist but a volatile block sits early in the prefix and must be MOVED after the stable ones. Read by prefix_reorder only. Deliberately an OPEN string rather than an enum, for the same reason as kind and action: an out-of-vocabulary value must fail one rule, not deserialization of the whole bundle. An enum here would be a known field with an unknown value, which the unknown-FIELD tolerance does not cover. Absent means the rule names no mechanism — a client that cannot infer one skips it rather than guessing.",
///                "examples": [
///                  "insert_breakpoints",
///                  "reorder_blocks"
///                ],
///                "type": "string"
///              }
///            },
///            "additionalProperties": false
///          },
///          "reason": {
///            "description": "Plain-language explanation shown to the developer verbatim when the rule blocks an action. A deny the developer cannot understand is a broken feature.",
///            "type": "string"
///          },
///          "rule_id": {
///            "description": "Stable public identifier, e.g. 'OL-CMD-001'. Unique within the organization. Reported on the verdict as olpolicyruleid, and the tiebreak key: the lexicographically first rule within the deciding set is the one reported.",
///            "type": "string"
///          },
///          "rule_version": {
///            "description": "Required for kind=request, absent on kind=command — the middle term of the D-04 replay tuple, so a would-have report can be tied to the exact rule text that produced it. Platform-managed: set on create and incremented on every edit, never authored by hand.",
///            "type": "integer"
///          },
///          "select": {
///            "description": "Which requests a kind=request rule applies to; an absent select means every request the boundary sees. Forbidden on kind=command. Each key is narrowed further per action by the gate below — a key that an action does not read is rejected rather than silently ignored.",
///            "type": "object",
///            "properties": {
///              "exclude_layers": {
///                "description": "Cache layers this rule must leave untouched. Read by prefix_reorder only.",
///                "type": "array",
///                "items": {
///                  "$ref": "#/$defs/ChurnLayer"
///                }
///              },
///              "min_messages": {
///                "description": "Apply only once the in-context history has at least this many messages. Read by history_trim only.",
///                "type": "integer"
///              },
///              "model_in": {
///                "description": "Apply only to requests whose model identifier is in this list. Matched verbatim against the model string on the wire; no globbing.",
///                "type": "array",
///                "items": {
///                  "type": "string"
///                }
///              }
///            },
///            "additionalProperties": false
///          },
///          "severity": {
///            "description": "Author-assigned severity, surfaced on the verdict returned to the agent hook.",
///            "type": "string",
///            "enum": [
///              "low",
///              "medium",
///              "high",
///              "critical"
///            ]
///          }
///        },
///        "additionalProperties": false
///      }
///    },
///    "schema_version": {
///      "description": "Bundle format version. Always 1 in v1. The client MUST refuse a bundle whose schema_version it does not know and keep the previous bundle (OL-1212). Forward compatibility is the platform's responsibility, not the client's.",
///      "type": "integer"
///    },
///    "signature": {
///      "description": "Reserved for a detached Ed25519 signature over the canonical bytes. Required but always null in v1, and the client MUST accept null. A client that cannot verify a non-null signature MUST reject the bundle rather than ignore the field, so that enabling signing later cannot be silently downgraded by an old client.",
///      "default": null,
///      "type": [
///        "string",
///        "null"
///      ]
///    }
///  },
///  "additionalProperties": false,
///  "x-postgresql-skip": true
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct PolicyBundle {
    ///RFC 3339 UTC timestamp with a Z suffix (microsecond precision allowed) recording when the rule content last actually changed — not when the bundle was served. Drives olpolicybundleage (now minus built_at, clamped at 0), which measures policy freshness. It does NOT drive the staleness warning, which is measured from the last successful fetch. Deliberately a plain string rather than format: date-time so the generated Rust type stays a String; the poller parses it once into a SystemTime.
    pub built_at: ::std::string::String,
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub client_config: ::std::option::Option<PolicyBundleClientConfig>,
    ///The organization-wide kill switch. When false, every rule behaves as observe regardless of its own mode — matches produce a shadow verdict and nothing is blocked. Stored outside the built artifact on the platform so it survives every rebuild.
    pub enforcement_enabled: bool,
    ///Canonical UUID form of the owning organization, matching the platform's organization_id column — not the API-key prefix. The client learns its own org from GET /api/v1/users/me, caches it in bundle.meta.json, and MUST reject a bundle whose value differs (OL-1211). Never evaluate another org's rules.
    pub organization_id: ::std::string::String,
    ///Monotonic per organization, incrementing only on real content change — a rebuild over unchanged rules is a no-op that leaves this untouched. Serialized as a JSON number and treated as i64 in Rust. Recorded on every verdict as olpolicybundlerev: the replay key.
    pub revision: i64,
    ///The active rule set, sorted by rule_id so the serialization is deterministic. May be empty, which means 'allow everything' and is distinguishable in telemetry from 'no bundle' because olpolicybundlerev is still stamped. Rules disabled by the author are omitted at build time — every rule present here is active.
    pub rules: ::std::vec::Vec<PolicyRule>,
    ///Bundle format version. Always 1 in v1. The client MUST refuse a bundle whose schema_version it does not know and keep the previous bundle (OL-1212). Forward compatibility is the platform's responsibility, not the client's.
    pub schema_version: i64,
    ///Reserved for a detached Ed25519 signature over the canonical bytes. Required but always null in v1, and the client MUST accept null. A client that cannot verify a non-null signature MUST reject the bundle rather than ignore the field, so that enabling signing later cannot be silently downgraded by an old client.
    pub signature: ::std::option::Option<::std::string::String>,
}
///Client-bound configuration delivered on the bundle — the only client-bound configuration channel. Optional; a client that never receives it captures nothing (fail closed). The platform MUST NOT emit this field to a fleet that still runs clients predating it: the bundle root is additionalProperties:false, so such a client rejects the whole document (OL-1212) and fails static on its previous rules.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Client-bound configuration delivered on the bundle — the only client-bound configuration channel. Optional; a client that never receives it captures nothing (fail closed). The platform MUST NOT emit this field to a fleet that still runs clients predating it: the bundle root is additionalProperties:false, so such a client rejects the whole document (OL-1212) and fails static on its previous rules.",
///  "type": "object",
///  "properties": {
///    "agent_context": {
///      "description": "This install's own agent context, composed by the platform at serve time from the X-OpenLatch-Agent-Id header the poller sends — one object about THIS agent, never a fleet roster. Optional: a client that never receives it holds no context, and every rule carrying conditions matches nothing (absent context is not 'unknown'). Tolerant like its parent, so a newer platform can add keys without failing older clients.",
///      "type": "object",
///      "properties": {
///        "function": {
///          "description": "The business function assigned to this agent's owner. Deliberately an OPEN string carrying the AgentFunction vocabulary as x-known-values rather than a $ref to that enum — the same reasoning as params.mechanism: client_config is deserialized as one typed object outside the per-rule tolerance, so an enum here would fail the WHOLE bundle (fleet-wide fail-static) on a single out-of-vocabulary value. The client parses it into AgentFunction at load; a STRING value it cannot parse reads as no context, so scoped rules match nothing rather than the bundle being rejected. The tolerance is over the vocabulary, not the shape: a non-string value here (or a non-object agent_context) is a malformed client_config and does fail the whole document, exactly as a malformed capture_identity_signals does. 'unknown' is a real platform-assigned value, distinct from the field being absent.",
///          "type": "string",
///          "x-known-values": [
///            "engineering",
///            "product",
///            "data",
///            "security",
///            "it_ops",
///            "sales",
///            "marketing",
///            "finance",
///            "legal",
///            "hr",
///            "support",
///            "research",
///            "other",
///            "unknown"
///          ]
///        }
///      },
///      "additionalProperties": true
///    },
///    "capture_identity_signals": {
///      "description": "The client's copy of the org setting identity.capture_signals. Identity signals are captured and stamped only when this is explicitly true.",
///      "type": "boolean"
///    }
///  },
///  "additionalProperties": true
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
pub struct PolicyBundleClientConfig {
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub agent_context: ::std::option::Option<PolicyBundleClientConfigAgentContext>,
    ///The client's copy of the org setting identity.capture_signals. Identity signals are captured and stamped only when this is explicitly true.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub capture_identity_signals: ::std::option::Option<bool>,
}
impl ::std::default::Default for PolicyBundleClientConfig {
    fn default() -> Self {
        Self {
            agent_context: Default::default(),
            capture_identity_signals: Default::default(),
        }
    }
}
///This install's own agent context, composed by the platform at serve time from the X-OpenLatch-Agent-Id header the poller sends — one object about THIS agent, never a fleet roster. Optional: a client that never receives it holds no context, and every rule carrying conditions matches nothing (absent context is not 'unknown'). Tolerant like its parent, so a newer platform can add keys without failing older clients.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "This install's own agent context, composed by the platform at serve time from the X-OpenLatch-Agent-Id header the poller sends — one object about THIS agent, never a fleet roster. Optional: a client that never receives it holds no context, and every rule carrying conditions matches nothing (absent context is not 'unknown'). Tolerant like its parent, so a newer platform can add keys without failing older clients.",
///  "type": "object",
///  "properties": {
///    "function": {
///      "description": "The business function assigned to this agent's owner. Deliberately an OPEN string carrying the AgentFunction vocabulary as x-known-values rather than a $ref to that enum — the same reasoning as params.mechanism: client_config is deserialized as one typed object outside the per-rule tolerance, so an enum here would fail the WHOLE bundle (fleet-wide fail-static) on a single out-of-vocabulary value. The client parses it into AgentFunction at load; a STRING value it cannot parse reads as no context, so scoped rules match nothing rather than the bundle being rejected. The tolerance is over the vocabulary, not the shape: a non-string value here (or a non-object agent_context) is a malformed client_config and does fail the whole document, exactly as a malformed capture_identity_signals does. 'unknown' is a real platform-assigned value, distinct from the field being absent.",
///      "type": "string",
///      "x-known-values": [
///        "engineering",
///        "product",
///        "data",
///        "security",
///        "it_ops",
///        "sales",
///        "marketing",
///        "finance",
///        "legal",
///        "hr",
///        "support",
///        "research",
///        "other",
///        "unknown"
///      ]
///    }
///  },
///  "additionalProperties": true
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
pub struct PolicyBundleClientConfigAgentContext {
    ///The business function assigned to this agent's owner. Deliberately an OPEN string carrying the AgentFunction vocabulary as x-known-values rather than a $ref to that enum — the same reasoning as params.mechanism: client_config is deserialized as one typed object outside the per-rule tolerance, so an enum here would fail the WHOLE bundle (fleet-wide fail-static) on a single out-of-vocabulary value. The client parses it into AgentFunction at load; a STRING value it cannot parse reads as no context, so scoped rules match nothing rather than the bundle being rejected. The tolerance is over the vocabulary, not the shape: a non-string value here (or a non-object agent_context) is a malformed client_config and does fail the whole document, exactly as a malformed capture_identity_signals does. 'unknown' is a real platform-assigned value, distinct from the field being absent.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub function: ::std::option::Option<::std::string::String>,
}
impl ::std::default::Default for PolicyBundleClientConfigAgentContext {
    fn default() -> Self {
        Self {
            function: Default::default(),
        }
    }
}
///One authored rule, on either plane. A kind=command rule is evaluated against the normalized command string extracted from a pre_tool_use envelope. A kind=request rule targets an outbound model request at the boundary and is held, not evaluated, in v1. The allOf below is the per-kind/per-action gate: the platform enforces it at authoring time (422) and the client validates every rule against it individually at bundle load, skipping the ones that fail — one bad rule must never cost the fleet its denies.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "title": "PolicyRule",
///  "description": "One authored rule, on either plane. A kind=command rule is evaluated against the normalized command string extracted from a pre_tool_use envelope. A kind=request rule targets an outbound model request at the boundary and is held, not evaluated, in v1. The allOf below is the per-kind/per-action gate: the platform enforces it at authoring time (422) and the client validates every rule against it individually at bundle load, skipping the ones that fail — one bad rule must never cost the fleet its denies.",
///  "type": "object",
///  "required": [
///    "action",
///    "kind",
///    "mode",
///    "reason",
///    "rule_id",
///    "severity"
///  ],
///  "properties": {
///    "action": {
///      "description": "What a match does. Authorable actions are 'deny' (the only one on kind=command) and 'prefix_reorder', 'history_trim', 'prompt_edit' (kind=request). Which action is legal for which kind is owned by the gate below, not by this list. An open string for the same forward-compatibility reason as kind.",
///      "type": "string"
///    },
///    "conditions": {
///      "description": "Which agents the rule applies to, decided locally by the client against the client_config.agent_context THIS install received — the network is not on the evaluation path. Absent (or empty) means unconditional: the rule applies on every agent, exactly as before this field existed. When present, EVERY condition must hold (AND semantics), and a rule whose context never arrived matches nothing — absent context is not 'unknown'. v1 is the command plane only: forbidden on kind=request by the gate below, and the only vocabulary is field 'agent.function' with op 'in'. The field/op enums are the general shape, so widening either later is additive; a client that predates a widening drops that one rule at load (unrecognized_field) and keeps the bundle. Values are the closed AgentFunction enum, so a value the client does not know fails that one rule at deserialization, never the whole document. 'unknown' is an ordinary value, not a wildcard.",
///      "type": "array",
///      "items": {
///        "type": "object",
///        "required": [
///          "field",
///          "op",
///          "value"
///        ],
///        "properties": {
///          "field": {
///            "description": "The agent-context attribute the condition reads. v1 knows exactly one: 'agent.function', read from client_config.agent_context.function.",
///            "type": "string",
///            "enum": [
///              "agent.function"
///            ]
///          },
///          "op": {
///            "description": "The comparison. v1 knows exactly one: 'in' — the attribute's value is a member of `value`. Several conditions on the same field AND together, so two 'in' sets intersect.",
///            "type": "string",
///            "enum": [
///              "in"
///            ]
///          },
///          "value": {
///            "description": "The set the attribute must belong to. At least one member — an empty set would match nothing while looking like a scoped rule, and the platform rejects it at authoring (422). Compared by enum equality on the client.",
///            "type": "array",
///            "items": {
///              "$ref": "#/$defs/AgentFunction"
///            },
///            "minItems": 1
///          }
///        },
///        "additionalProperties": false
///      }
///    },
///    "kind": {
///      "description": "Which plane the rule acts on. Two kinds are authorable: 'command' (a shell command intercepted at the pre_tool_use hook) and 'request' (an outbound model request intercepted at the boundary). Deliberately an open string rather than a closed enum: the client MUST skip a rule whose kind it does not recognize and keep the rest of the bundle active, so that a v1 client tolerates a v1.1 bundle. A closed enum would fail deserialization of the whole document instead.",
///      "type": "string"
///    },
///    "match_pattern": {
///      "description": "Required for kind=command and forbidden for kind=request — see the gate below; it is optional in the base only so that a request rule does not fail deserialization on a client that predates the gate. Fully-anchored, case-sensitive glob over the entire normalized command string. Exactly two metacharacters: '*' (any sequence including empty, crossing '/' and every other character — this is not path-aware globbing) and '?' (exactly one character). No character classes, no escapes, no alternation, no regex. Anchoring surprises authors: 'rm -rf /*' does not match 'sudo rm -rf /tmp'; write '*rm -rf*' to catch a command anywhere in the string. The platform normalizes and validates this at authoring time and rejects empty, over-1024-character, control-character-bearing, and bare-'*' patterns with 422.",
///      "type": "string"
///    },
///    "mode": {
///      "description": "Staged rollout control. 'observe' records a shadow verdict and allows the action; 'enforce' denies it. Most restrictive wins across matching rules. Overridden to observe for every rule when enforcement_enabled is false.",
///      "type": "string",
///      "enum": [
///        "observe",
///        "enforce"
///      ]
///    },
///    "params": {
///      "description": "How a kind=request rule transforms the request. Forbidden on kind=command. Exactly which keys are required and which are rejected is per-action, in the gate below.",
///      "type": "object",
///      "properties": {
///        "keep_messages": {
///          "description": "How many of the most recent messages history_trim retains. Required by history_trim, rejected everywhere else.",
///          "type": "integer"
///        },
///        "marker": {
///          "description": "The literal marker prompt_edit rewrites around. Deliberately unconstrained here: a length or pattern keyword would make the generated Rust type a constrained newtype whose deserializer fails the WHOLE bundle on one over-long value. Length is bounded platform-side at authoring.",
///          "type": "string"
///        },
///        "max_system_tokens": {
///          "description": "Token ceiling prompt_edit trims the system block to. Alternative to marker — exactly one of the two is required.",
///          "type": "integer"
///        },
///        "mechanism": {
///          "description": "Which caching intervention a prefix_reorder rule means. The detector that authors these rules fires on two different causes needing two different interventions, and the action alone cannot tell them apart: 'insert_breakpoints' — nothing is being cached at all, so cache_control breakpoints must be INJECTED; 'reorder_blocks' — breakpoints exist but a volatile block sits early in the prefix and must be MOVED after the stable ones. Read by prefix_reorder only. Deliberately an OPEN string rather than an enum, for the same reason as kind and action: an out-of-vocabulary value must fail one rule, not deserialization of the whole bundle. An enum here would be a known field with an unknown value, which the unknown-FIELD tolerance does not cover. Absent means the rule names no mechanism — a client that cannot infer one skips it rather than guessing.",
///          "examples": [
///            "insert_breakpoints",
///            "reorder_blocks"
///          ],
///          "type": "string"
///        }
///      },
///      "additionalProperties": false
///    },
///    "reason": {
///      "description": "Plain-language explanation shown to the developer verbatim when the rule blocks an action. A deny the developer cannot understand is a broken feature.",
///      "type": "string"
///    },
///    "rule_id": {
///      "description": "Stable public identifier, e.g. 'OL-CMD-001'. Unique within the organization. Reported on the verdict as olpolicyruleid, and the tiebreak key: the lexicographically first rule within the deciding set is the one reported.",
///      "type": "string"
///    },
///    "rule_version": {
///      "description": "Required for kind=request, absent on kind=command — the middle term of the D-04 replay tuple, so a would-have report can be tied to the exact rule text that produced it. Platform-managed: set on create and incremented on every edit, never authored by hand.",
///      "type": "integer"
///    },
///    "select": {
///      "description": "Which requests a kind=request rule applies to; an absent select means every request the boundary sees. Forbidden on kind=command. Each key is narrowed further per action by the gate below — a key that an action does not read is rejected rather than silently ignored.",
///      "type": "object",
///      "properties": {
///        "exclude_layers": {
///          "description": "Cache layers this rule must leave untouched. Read by prefix_reorder only.",
///          "type": "array",
///          "items": {
///            "$ref": "#/$defs/ChurnLayer"
///          }
///        },
///        "min_messages": {
///          "description": "Apply only once the in-context history has at least this many messages. Read by history_trim only.",
///          "type": "integer"
///        },
///        "model_in": {
///          "description": "Apply only to requests whose model identifier is in this list. Matched verbatim against the model string on the wire; no globbing.",
///          "type": "array",
///          "items": {
///            "type": "string"
///          }
///        }
///      },
///      "additionalProperties": false
///    },
///    "severity": {
///      "description": "Author-assigned severity, surfaced on the verdict returned to the agent hook.",
///      "type": "string",
///      "enum": [
///        "low",
///        "medium",
///        "high",
///        "critical"
///      ]
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct PolicyRule {
    ///What a match does. Authorable actions are 'deny' (the only one on kind=command) and 'prefix_reorder', 'history_trim', 'prompt_edit' (kind=request). Which action is legal for which kind is owned by the gate below, not by this list. An open string for the same forward-compatibility reason as kind.
    pub action: ::std::string::String,
    ///Which agents the rule applies to, decided locally by the client against the client_config.agent_context THIS install received — the network is not on the evaluation path. Absent (or empty) means unconditional: the rule applies on every agent, exactly as before this field existed. When present, EVERY condition must hold (AND semantics), and a rule whose context never arrived matches nothing — absent context is not 'unknown'. v1 is the command plane only: forbidden on kind=request by the gate below, and the only vocabulary is field 'agent.function' with op 'in'. The field/op enums are the general shape, so widening either later is additive; a client that predates a widening drops that one rule at load (unrecognized_field) and keeps the bundle. Values are the closed AgentFunction enum, so a value the client does not know fails that one rule at deserialization, never the whole document. 'unknown' is an ordinary value, not a wildcard.
    #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
    pub conditions: ::std::vec::Vec<PolicyRuleConditionsItem>,
    ///Which plane the rule acts on. Two kinds are authorable: 'command' (a shell command intercepted at the pre_tool_use hook) and 'request' (an outbound model request intercepted at the boundary). Deliberately an open string rather than a closed enum: the client MUST skip a rule whose kind it does not recognize and keep the rest of the bundle active, so that a v1 client tolerates a v1.1 bundle. A closed enum would fail deserialization of the whole document instead.
    pub kind: ::std::string::String,
    ///Required for kind=command and forbidden for kind=request — see the gate below; it is optional in the base only so that a request rule does not fail deserialization on a client that predates the gate. Fully-anchored, case-sensitive glob over the entire normalized command string. Exactly two metacharacters: '*' (any sequence including empty, crossing '/' and every other character — this is not path-aware globbing) and '?' (exactly one character). No character classes, no escapes, no alternation, no regex. Anchoring surprises authors: 'rm -rf /*' does not match 'sudo rm -rf /tmp'; write '*rm -rf*' to catch a command anywhere in the string. The platform normalizes and validates this at authoring time and rejects empty, over-1024-character, control-character-bearing, and bare-'*' patterns with 422.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub match_pattern: ::std::option::Option<::std::string::String>,
    ///Staged rollout control. 'observe' records a shadow verdict and allows the action; 'enforce' denies it. Most restrictive wins across matching rules. Overridden to observe for every rule when enforcement_enabled is false.
    pub mode: PolicyRuleMode,
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub params: ::std::option::Option<PolicyRuleParams>,
    ///Plain-language explanation shown to the developer verbatim when the rule blocks an action. A deny the developer cannot understand is a broken feature.
    pub reason: ::std::string::String,
    ///Stable public identifier, e.g. 'OL-CMD-001'. Unique within the organization. Reported on the verdict as olpolicyruleid, and the tiebreak key: the lexicographically first rule within the deciding set is the one reported.
    pub rule_id: ::std::string::String,
    ///Required for kind=request, absent on kind=command — the middle term of the D-04 replay tuple, so a would-have report can be tied to the exact rule text that produced it. Platform-managed: set on create and incremented on every edit, never authored by hand.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub rule_version: ::std::option::Option<i64>,
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub select: ::std::option::Option<PolicyRuleSelect>,
    ///Author-assigned severity, surfaced on the verdict returned to the agent hook.
    pub severity: PolicyRuleSeverity,
}
///`PolicyRuleConditionsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "type": "object",
///  "required": [
///    "field",
///    "op",
///    "value"
///  ],
///  "properties": {
///    "field": {
///      "description": "The agent-context attribute the condition reads. v1 knows exactly one: 'agent.function', read from client_config.agent_context.function.",
///      "type": "string",
///      "enum": [
///        "agent.function"
///      ]
///    },
///    "op": {
///      "description": "The comparison. v1 knows exactly one: 'in' — the attribute's value is a member of `value`. Several conditions on the same field AND together, so two 'in' sets intersect.",
///      "type": "string",
///      "enum": [
///        "in"
///      ]
///    },
///    "value": {
///      "description": "The set the attribute must belong to. At least one member — an empty set would match nothing while looking like a scoped rule, and the platform rejects it at authoring (422). Compared by enum equality on the client.",
///      "type": "array",
///      "items": {
///        "$ref": "#/$defs/AgentFunction"
///      },
///      "minItems": 1
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct PolicyRuleConditionsItem {
    ///The agent-context attribute the condition reads. v1 knows exactly one: 'agent.function', read from client_config.agent_context.function.
    pub field: PolicyRuleConditionsItemField,
    ///The comparison. v1 knows exactly one: 'in' — the attribute's value is a member of `value`. Several conditions on the same field AND together, so two 'in' sets intersect.
    pub op: PolicyRuleConditionsItemOp,
    ///The set the attribute must belong to. At least one member — an empty set would match nothing while looking like a scoped rule, and the platform rejects it at authoring (422). Compared by enum equality on the client.
    pub value: ::std::vec::Vec<AgentFunction>,
}
///The agent-context attribute the condition reads. v1 knows exactly one: 'agent.function', read from client_config.agent_context.function.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "The agent-context attribute the condition reads. v1 knows exactly one: 'agent.function', read from client_config.agent_context.function.",
///  "type": "string",
///  "enum": [
///    "agent.function"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum PolicyRuleConditionsItemField {
    #[serde(rename = "agent.function")]
    AgentFunction,
}
impl ::std::fmt::Display for PolicyRuleConditionsItemField {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::AgentFunction => f.write_str("agent.function"),
        }
    }
}
impl ::std::str::FromStr for PolicyRuleConditionsItemField {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "agent.function" => Ok(Self::AgentFunction),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for PolicyRuleConditionsItemField {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for PolicyRuleConditionsItemField {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for PolicyRuleConditionsItemField {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///The comparison. v1 knows exactly one: 'in' — the attribute's value is a member of `value`. Several conditions on the same field AND together, so two 'in' sets intersect.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "The comparison. v1 knows exactly one: 'in' — the attribute's value is a member of `value`. Several conditions on the same field AND together, so two 'in' sets intersect.",
///  "type": "string",
///  "enum": [
///    "in"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum PolicyRuleConditionsItemOp {
    #[serde(rename = "in")]
    In,
}
impl ::std::fmt::Display for PolicyRuleConditionsItemOp {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::In => f.write_str("in"),
        }
    }
}
impl ::std::str::FromStr for PolicyRuleConditionsItemOp {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "in" => Ok(Self::In),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for PolicyRuleConditionsItemOp {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for PolicyRuleConditionsItemOp {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for PolicyRuleConditionsItemOp {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///Staged rollout control. 'observe' records a shadow verdict and allows the action; 'enforce' denies it. Most restrictive wins across matching rules. Overridden to observe for every rule when enforcement_enabled is false.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Staged rollout control. 'observe' records a shadow verdict and allows the action; 'enforce' denies it. Most restrictive wins across matching rules. Overridden to observe for every rule when enforcement_enabled is false.",
///  "type": "string",
///  "enum": [
///    "observe",
///    "enforce"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum PolicyRuleMode {
    #[serde(rename = "observe")]
    Observe,
    #[serde(rename = "enforce")]
    Enforce,
}
impl ::std::fmt::Display for PolicyRuleMode {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::Observe => f.write_str("observe"),
            Self::Enforce => f.write_str("enforce"),
        }
    }
}
impl ::std::str::FromStr for PolicyRuleMode {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "observe" => Ok(Self::Observe),
            "enforce" => Ok(Self::Enforce),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for PolicyRuleMode {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for PolicyRuleMode {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for PolicyRuleMode {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///How a kind=request rule transforms the request. Forbidden on kind=command. Exactly which keys are required and which are rejected is per-action, in the gate below.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "How a kind=request rule transforms the request. Forbidden on kind=command. Exactly which keys are required and which are rejected is per-action, in the gate below.",
///  "type": "object",
///  "properties": {
///    "keep_messages": {
///      "description": "How many of the most recent messages history_trim retains. Required by history_trim, rejected everywhere else.",
///      "type": "integer"
///    },
///    "marker": {
///      "description": "The literal marker prompt_edit rewrites around. Deliberately unconstrained here: a length or pattern keyword would make the generated Rust type a constrained newtype whose deserializer fails the WHOLE bundle on one over-long value. Length is bounded platform-side at authoring.",
///      "type": "string"
///    },
///    "max_system_tokens": {
///      "description": "Token ceiling prompt_edit trims the system block to. Alternative to marker — exactly one of the two is required.",
///      "type": "integer"
///    },
///    "mechanism": {
///      "description": "Which caching intervention a prefix_reorder rule means. The detector that authors these rules fires on two different causes needing two different interventions, and the action alone cannot tell them apart: 'insert_breakpoints' — nothing is being cached at all, so cache_control breakpoints must be INJECTED; 'reorder_blocks' — breakpoints exist but a volatile block sits early in the prefix and must be MOVED after the stable ones. Read by prefix_reorder only. Deliberately an OPEN string rather than an enum, for the same reason as kind and action: an out-of-vocabulary value must fail one rule, not deserialization of the whole bundle. An enum here would be a known field with an unknown value, which the unknown-FIELD tolerance does not cover. Absent means the rule names no mechanism — a client that cannot infer one skips it rather than guessing.",
///      "examples": [
///        "insert_breakpoints",
///        "reorder_blocks"
///      ],
///      "type": "string"
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct PolicyRuleParams {
    ///How many of the most recent messages history_trim retains. Required by history_trim, rejected everywhere else.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub keep_messages: ::std::option::Option<i64>,
    ///The literal marker prompt_edit rewrites around. Deliberately unconstrained here: a length or pattern keyword would make the generated Rust type a constrained newtype whose deserializer fails the WHOLE bundle on one over-long value. Length is bounded platform-side at authoring.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub marker: ::std::option::Option<::std::string::String>,
    ///Token ceiling prompt_edit trims the system block to. Alternative to marker — exactly one of the two is required.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub max_system_tokens: ::std::option::Option<i64>,
    ///Which caching intervention a prefix_reorder rule means. The detector that authors these rules fires on two different causes needing two different interventions, and the action alone cannot tell them apart: 'insert_breakpoints' — nothing is being cached at all, so cache_control breakpoints must be INJECTED; 'reorder_blocks' — breakpoints exist but a volatile block sits early in the prefix and must be MOVED after the stable ones. Read by prefix_reorder only. Deliberately an OPEN string rather than an enum, for the same reason as kind and action: an out-of-vocabulary value must fail one rule, not deserialization of the whole bundle. An enum here would be a known field with an unknown value, which the unknown-FIELD tolerance does not cover. Absent means the rule names no mechanism — a client that cannot infer one skips it rather than guessing.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub mechanism: ::std::option::Option<::std::string::String>,
}
impl ::std::default::Default for PolicyRuleParams {
    fn default() -> Self {
        Self {
            keep_messages: Default::default(),
            marker: Default::default(),
            max_system_tokens: Default::default(),
            mechanism: Default::default(),
        }
    }
}
///Which requests a kind=request rule applies to; an absent select means every request the boundary sees. Forbidden on kind=command. Each key is narrowed further per action by the gate below — a key that an action does not read is rejected rather than silently ignored.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Which requests a kind=request rule applies to; an absent select means every request the boundary sees. Forbidden on kind=command. Each key is narrowed further per action by the gate below — a key that an action does not read is rejected rather than silently ignored.",
///  "type": "object",
///  "properties": {
///    "exclude_layers": {
///      "description": "Cache layers this rule must leave untouched. Read by prefix_reorder only.",
///      "type": "array",
///      "items": {
///        "$ref": "#/$defs/ChurnLayer"
///      }
///    },
///    "min_messages": {
///      "description": "Apply only once the in-context history has at least this many messages. Read by history_trim only.",
///      "type": "integer"
///    },
///    "model_in": {
///      "description": "Apply only to requests whose model identifier is in this list. Matched verbatim against the model string on the wire; no globbing.",
///      "type": "array",
///      "items": {
///        "type": "string"
///      }
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct PolicyRuleSelect {
    ///Cache layers this rule must leave untouched. Read by prefix_reorder only.
    #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
    pub exclude_layers: ::std::vec::Vec<ChurnLayer>,
    ///Apply only once the in-context history has at least this many messages. Read by history_trim only.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub min_messages: ::std::option::Option<i64>,
    ///Apply only to requests whose model identifier is in this list. Matched verbatim against the model string on the wire; no globbing.
    #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
    pub model_in: ::std::vec::Vec<::std::string::String>,
}
impl ::std::default::Default for PolicyRuleSelect {
    fn default() -> Self {
        Self {
            exclude_layers: Default::default(),
            min_messages: Default::default(),
            model_in: Default::default(),
        }
    }
}
///Author-assigned severity, surfaced on the verdict returned to the agent hook.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Author-assigned severity, surfaced on the verdict returned to the agent hook.",
///  "type": "string",
///  "enum": [
///    "low",
///    "medium",
///    "high",
///    "critical"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum PolicyRuleSeverity {
    #[serde(rename = "low")]
    Low,
    #[serde(rename = "medium")]
    Medium,
    #[serde(rename = "high")]
    High,
    #[serde(rename = "critical")]
    Critical,
}
impl ::std::fmt::Display for PolicyRuleSeverity {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::Low => f.write_str("low"),
            Self::Medium => f.write_str("medium"),
            Self::High => f.write_str("high"),
            Self::Critical => f.write_str("critical"),
        }
    }
}
impl ::std::str::FromStr for PolicyRuleSeverity {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "low" => Ok(Self::Low),
            "medium" => Ok(Self::Medium),
            "high" => Ok(Self::High),
            "critical" => Ok(Self::Critical),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for PolicyRuleSeverity {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for PolicyRuleSeverity {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for PolicyRuleSeverity {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///Verdict returned to the agent hook. Closed enum — client must handle all three variants exhaustively. allow = proceed normally, approve = user-confirmed allow, deny = blocked.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Verdict returned to the agent hook. Closed enum — client must handle all three variants exhaustively. allow = proceed normally, approve = user-confirmed allow, deny = blocked.",
///  "type": "string",
///  "enum": [
///    "allow",
///    "approve",
///    "deny"
///  ]
///}
/// ```
/// </details>
#[derive(
    ::serde::Deserialize,
    ::serde::Serialize,
    Clone,
    Copy,
    Debug,
    Eq,
    Hash,
    Ord,
    PartialEq,
    PartialOrd,
)]
pub enum Verdict {
    #[serde(rename = "allow")]
    Allow,
    #[serde(rename = "approve")]
    Approve,
    #[serde(rename = "deny")]
    Deny,
}
impl ::std::fmt::Display for Verdict {
    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
        match *self {
            Self::Allow => f.write_str("allow"),
            Self::Approve => f.write_str("approve"),
            Self::Deny => f.write_str("deny"),
        }
    }
}
impl ::std::str::FromStr for Verdict {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        match value {
            "allow" => Ok(Self::Allow),
            "approve" => Ok(Self::Approve),
            "deny" => Ok(Self::Deny),
            _ => Err("invalid value".into()),
        }
    }
}
impl ::std::convert::TryFrom<&str> for Verdict {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for Verdict {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for Verdict {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
///Verdict response returned to the agent hook after processing. The client passes this through to the agent hook without interpreting the verdict itself. Mirrors the cloud response schema. Schema version '1.1' adds the optional 'context' object (headline / body / evidence[]) carrying user-facing copy that the agent renders in its end-user notification (D-16 of OpenRouter of Security).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Verdict response returned to the agent hook after processing. The client passes this through to the agent hook without interpreting the verdict itself. Mirrors the cloud response schema. Schema version '1.1' adds the optional 'context' object (headline / body / evidence[]) carrying user-facing copy that the agent renders in its end-user notification (D-16 of OpenRouter of Security).",
///  "examples": [
///    {
///      "event_id": "019d8af1-f8da-73b3-92eb-79a99e59b10b",
///      "latency_ms": 42,
///      "schema_version": "1.0",
///      "verdict": "allow"
///    },
///    {
///      "context": {
///        "body": "This action would share a credential (API key, token, password). Remove the credential and use a secrets manager.",
///        "evidence": [
///          {
///            "label": "credential_kind",
///            "value_redacted": "github_pat (ghp_****)"
///          }
///        ],
///        "headline": "Credential detected"
///      },
///      "details_url": "https://app.openlatch.ai/events/019d8af1-f8da-73b3-92eb-000000000002",
///      "event_id": "019d8af1-f8da-73b3-92eb-000000000002",
///      "latency_ms": 88,
///      "offline": false,
///      "reason": "Credential detected in tool output",
///      "rule_id": "rule_cred_001",
///      "schema_version": "1.1",
///      "severity": "critical",
///      "threat_category": "credential_detection",
///      "verdict": "deny"
///    },
///    {
///      "context": {
///        "body": "Your security detection tools are currently unreachable. This action was allowed to avoid blocking work. Check the platform routing page for status.",
///        "evidence": [],
///        "headline": "Security tools unreachable"
///      },
///      "event_id": "019d8af1-f8da-73b3-92eb-000000000003",
///      "latency_ms": 201,
///      "offline": true,
///      "schema_version": "1.1",
///      "verdict": "allow"
///    }
///  ],
///  "type": "object",
///  "required": [
///    "event_id",
///    "latency_ms",
///    "schema_version",
///    "verdict"
///  ],
///  "properties": {
///    "context": {
///      "description": "Schema 1.1+. Optional user-facing copy for rendering an end-user-visible notification when the verdict is rendered to the human. Clients render context.headline + context.body + context.evidence directly. 'remediation' is intentionally NOT on the wire (D-16) — it is stored on the platform and accessible via details_url. Older clients (1.0) ignore this field. Nullability is expressed via anyOf (object | null) instead of `\"type\": [\"object\", \"null\"]` because typify (the Rust codegen) does not yet support the JSON Schema 2020-12 type-array form for inline object shapes.",
///      "default": null,
///      "anyOf": [
///        {
///          "type": "null"
///        },
///        {
///          "type": "object",
///          "required": [
///            "body",
///            "headline"
///          ],
///          "properties": {
///            "body": {
///              "description": "One-paragraph explanation shown below the headline.",
///              "type": "string",
///              "maxLength": 500,
///              "minLength": 1
///            },
///            "evidence": {
///              "default": [],
///              "type": "array",
///              "items": {
///                "type": "object",
///                "required": [
///                  "label"
///                ],
///                "properties": {
///                  "label": {
///                    "description": "Short tag, e.g. 'credit_card', 'host', 'tool_name'.",
///                    "type": "string",
///                    "maxLength": 64,
///                    "minLength": 1
///                  },
///                  "value_redacted": {
///                    "description": "Redacted display string. Provider redacts before submission; platform re-runs SENSITIVE_FIELD_PATTERNS defensively.",
///                    "type": "string",
///                    "maxLength": 200
///                  }
///                },
///                "additionalProperties": false
///              },
///              "maxItems": 16
///            },
///            "headline": {
///              "description": "One-line summary shown as the toast / notification title.",
///              "type": "string",
///              "maxLength": 120,
///              "minLength": 1
///            }
///          },
///          "additionalProperties": false
///        }
///      ]
///    },
///    "details_url": {
///      "description": "URL to the OpenLatch dashboard with detailed event analysis. Omitted when not available.",
///      "type": "string"
///    },
///    "event_id": {
///      "description": "Server-assigned or client-generated ID of the event this verdict responds to.",
///      "type": "string"
///    },
///    "latency_ms": {
///      "description": "Total end-to-end processing latency in milliseconds, including cloud round-trip when applicable.",
///      "type": "number",
///      "minimum": 0.0
///    },
///    "offline": {
///      "description": "Schema 1.1+. True when all configured security tools were unreachable. The verdict is fail-open ('allow') and 'context.headline' will read 'Security tools unreachable'. Older clients ignore this field.",
///      "default": false,
///      "type": "boolean"
///    },
///    "reason": {
///      "description": "Human-readable explanation for the verdict. Omitted for allow verdicts.",
///      "type": "string"
///    },
///    "rule_id": {
///      "description": "Identifier of the detection rule that triggered this verdict. Omitted when no rule matched.",
///      "type": "string"
///    },
///    "schema_version": {
///      "description": "Schema version for forward compatibility. '1.0' = legacy. '1.1' = adds optional 'context' + 'offline' fields (D-16 of OpenRouter of Security). Older clients ignore unknown fields and remain compatible.",
///      "type": "string"
///    },
///    "severity": {
///      "description": "Threat severity level (e.g., 'critical', 'high', 'medium', 'low'). Omitted when no threat was detected.",
///      "type": "string"
///    },
///    "threat_category": {
///      "description": "Category of detected threat (e.g., 'credential_exfiltration', 'command_injection'). Omitted when no threat detected.",
///      "type": "string"
///    },
///    "verdict": {
///      "description": "The verdict: allow = proceed, approve = user-confirmed allow, deny = blocked.",
///      "$ref": "#/$defs/Verdict"
///    }
///  },
///  "additionalProperties": false,
///  "x-postgresql-skip": true
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct VerdictResponse {
    ///Schema 1.1+. Optional user-facing copy for rendering an end-user-visible notification when the verdict is rendered to the human. Clients render context.headline + context.body + context.evidence directly. 'remediation' is intentionally NOT on the wire (D-16) — it is stored on the platform and accessible via details_url. Older clients (1.0) ignore this field. Nullability is expressed via anyOf (object | null) instead of `"type": ["object", "null"]` because typify (the Rust codegen) does not yet support the JSON Schema 2020-12 type-array form for inline object shapes.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub context: ::std::option::Option<VerdictResponseContext>,
    ///URL to the OpenLatch dashboard with detailed event analysis. Omitted when not available.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub details_url: ::std::option::Option<::std::string::String>,
    ///Server-assigned or client-generated ID of the event this verdict responds to.
    pub event_id: ::std::string::String,
    ///Total end-to-end processing latency in milliseconds, including cloud round-trip when applicable.
    pub latency_ms: f64,
    ///Schema 1.1+. True when all configured security tools were unreachable. The verdict is fail-open ('allow') and 'context.headline' will read 'Security tools unreachable'. Older clients ignore this field.
    #[serde(default)]
    pub offline: bool,
    ///Human-readable explanation for the verdict. Omitted for allow verdicts.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub reason: ::std::option::Option<::std::string::String>,
    ///Identifier of the detection rule that triggered this verdict. Omitted when no rule matched.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub rule_id: ::std::option::Option<::std::string::String>,
    ///Schema version for forward compatibility. '1.0' = legacy. '1.1' = adds optional 'context' + 'offline' fields (D-16 of OpenRouter of Security). Older clients ignore unknown fields and remain compatible.
    pub schema_version: ::std::string::String,
    ///Threat severity level (e.g., 'critical', 'high', 'medium', 'low'). Omitted when no threat was detected.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub severity: ::std::option::Option<::std::string::String>,
    ///Category of detected threat (e.g., 'credential_exfiltration', 'command_injection'). Omitted when no threat detected.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub threat_category: ::std::option::Option<::std::string::String>,
    ///The verdict: allow = proceed, approve = user-confirmed allow, deny = blocked.
    pub verdict: Verdict,
}
///`VerdictResponseContext`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "type": "object",
///  "required": [
///    "body",
///    "headline"
///  ],
///  "properties": {
///    "body": {
///      "description": "One-paragraph explanation shown below the headline.",
///      "type": "string",
///      "maxLength": 500,
///      "minLength": 1
///    },
///    "evidence": {
///      "default": [],
///      "type": "array",
///      "items": {
///        "type": "object",
///        "required": [
///          "label"
///        ],
///        "properties": {
///          "label": {
///            "description": "Short tag, e.g. 'credit_card', 'host', 'tool_name'.",
///            "type": "string",
///            "maxLength": 64,
///            "minLength": 1
///          },
///          "value_redacted": {
///            "description": "Redacted display string. Provider redacts before submission; platform re-runs SENSITIVE_FIELD_PATTERNS defensively.",
///            "type": "string",
///            "maxLength": 200
///          }
///        },
///        "additionalProperties": false
///      },
///      "maxItems": 16
///    },
///    "headline": {
///      "description": "One-line summary shown as the toast / notification title.",
///      "type": "string",
///      "maxLength": 120,
///      "minLength": 1
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct VerdictResponseContext {
    ///One-paragraph explanation shown below the headline.
    pub body: VerdictResponseContextBody,
    #[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
    pub evidence: ::std::vec::Vec<VerdictResponseContextEvidenceItem>,
    ///One-line summary shown as the toast / notification title.
    pub headline: VerdictResponseContextHeadline,
}
///One-paragraph explanation shown below the headline.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "One-paragraph explanation shown below the headline.",
///  "type": "string",
///  "maxLength": 500,
///  "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct VerdictResponseContextBody(::std::string::String);
impl ::std::ops::Deref for VerdictResponseContextBody {
    type Target = ::std::string::String;
    fn deref(&self) -> &::std::string::String {
        &self.0
    }
}
impl ::std::convert::From<VerdictResponseContextBody> for ::std::string::String {
    fn from(value: VerdictResponseContextBody) -> Self {
        value.0
    }
}
impl ::std::str::FromStr for VerdictResponseContextBody {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        if value.chars().count() > 500usize {
            return Err("longer than 500 characters".into());
        }
        if value.chars().count() < 1usize {
            return Err("shorter than 1 characters".into());
        }
        Ok(Self(value.to_string()))
    }
}
impl ::std::convert::TryFrom<&str> for VerdictResponseContextBody {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for VerdictResponseContextBody {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for VerdictResponseContextBody {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl<'de> ::serde::Deserialize<'de> for VerdictResponseContextBody {
    fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
    where
        D: ::serde::Deserializer<'de>,
    {
        ::std::string::String::deserialize(deserializer)?
            .parse()
            .map_err(|e: self::error::ConversionError| {
                <D::Error as ::serde::de::Error>::custom(e.to_string())
            })
    }
}
///`VerdictResponseContextEvidenceItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "type": "object",
///  "required": [
///    "label"
///  ],
///  "properties": {
///    "label": {
///      "description": "Short tag, e.g. 'credit_card', 'host', 'tool_name'.",
///      "type": "string",
///      "maxLength": 64,
///      "minLength": 1
///    },
///    "value_redacted": {
///      "description": "Redacted display string. Provider redacts before submission; platform re-runs SENSITIVE_FIELD_PATTERNS defensively.",
///      "type": "string",
///      "maxLength": 200
///    }
///  },
///  "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug, PartialEq)]
#[serde(deny_unknown_fields)]
pub struct VerdictResponseContextEvidenceItem {
    ///Short tag, e.g. 'credit_card', 'host', 'tool_name'.
    pub label: VerdictResponseContextEvidenceItemLabel,
    ///Redacted display string. Provider redacts before submission; platform re-runs SENSITIVE_FIELD_PATTERNS defensively.
    #[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
    pub value_redacted: ::std::option::Option<VerdictResponseContextEvidenceItemValueRedacted>,
}
///Short tag, e.g. 'credit_card', 'host', 'tool_name'.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Short tag, e.g. 'credit_card', 'host', 'tool_name'.",
///  "type": "string",
///  "maxLength": 64,
///  "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct VerdictResponseContextEvidenceItemLabel(::std::string::String);
impl ::std::ops::Deref for VerdictResponseContextEvidenceItemLabel {
    type Target = ::std::string::String;
    fn deref(&self) -> &::std::string::String {
        &self.0
    }
}
impl ::std::convert::From<VerdictResponseContextEvidenceItemLabel> for ::std::string::String {
    fn from(value: VerdictResponseContextEvidenceItemLabel) -> Self {
        value.0
    }
}
impl ::std::str::FromStr for VerdictResponseContextEvidenceItemLabel {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        if value.chars().count() > 64usize {
            return Err("longer than 64 characters".into());
        }
        if value.chars().count() < 1usize {
            return Err("shorter than 1 characters".into());
        }
        Ok(Self(value.to_string()))
    }
}
impl ::std::convert::TryFrom<&str> for VerdictResponseContextEvidenceItemLabel {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for VerdictResponseContextEvidenceItemLabel {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for VerdictResponseContextEvidenceItemLabel {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl<'de> ::serde::Deserialize<'de> for VerdictResponseContextEvidenceItemLabel {
    fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
    where
        D: ::serde::Deserializer<'de>,
    {
        ::std::string::String::deserialize(deserializer)?
            .parse()
            .map_err(|e: self::error::ConversionError| {
                <D::Error as ::serde::de::Error>::custom(e.to_string())
            })
    }
}
///Redacted display string. Provider redacts before submission; platform re-runs SENSITIVE_FIELD_PATTERNS defensively.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "Redacted display string. Provider redacts before submission; platform re-runs SENSITIVE_FIELD_PATTERNS defensively.",
///  "type": "string",
///  "maxLength": 200
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct VerdictResponseContextEvidenceItemValueRedacted(::std::string::String);
impl ::std::ops::Deref for VerdictResponseContextEvidenceItemValueRedacted {
    type Target = ::std::string::String;
    fn deref(&self) -> &::std::string::String {
        &self.0
    }
}
impl ::std::convert::From<VerdictResponseContextEvidenceItemValueRedacted>
    for ::std::string::String
{
    fn from(value: VerdictResponseContextEvidenceItemValueRedacted) -> Self {
        value.0
    }
}
impl ::std::str::FromStr for VerdictResponseContextEvidenceItemValueRedacted {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        if value.chars().count() > 200usize {
            return Err("longer than 200 characters".into());
        }
        Ok(Self(value.to_string()))
    }
}
impl ::std::convert::TryFrom<&str> for VerdictResponseContextEvidenceItemValueRedacted {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String>
    for VerdictResponseContextEvidenceItemValueRedacted
{
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String>
    for VerdictResponseContextEvidenceItemValueRedacted
{
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl<'de> ::serde::Deserialize<'de> for VerdictResponseContextEvidenceItemValueRedacted {
    fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
    where
        D: ::serde::Deserializer<'de>,
    {
        ::std::string::String::deserialize(deserializer)?
            .parse()
            .map_err(|e: self::error::ConversionError| {
                <D::Error as ::serde::de::Error>::custom(e.to_string())
            })
    }
}
///One-line summary shown as the toast / notification title.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
///  "description": "One-line summary shown as the toast / notification title.",
///  "type": "string",
///  "maxLength": 120,
///  "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct VerdictResponseContextHeadline(::std::string::String);
impl ::std::ops::Deref for VerdictResponseContextHeadline {
    type Target = ::std::string::String;
    fn deref(&self) -> &::std::string::String {
        &self.0
    }
}
impl ::std::convert::From<VerdictResponseContextHeadline> for ::std::string::String {
    fn from(value: VerdictResponseContextHeadline) -> Self {
        value.0
    }
}
impl ::std::str::FromStr for VerdictResponseContextHeadline {
    type Err = self::error::ConversionError;
    fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        if value.chars().count() > 120usize {
            return Err("longer than 120 characters".into());
        }
        if value.chars().count() < 1usize {
            return Err("shorter than 1 characters".into());
        }
        Ok(Self(value.to_string()))
    }
}
impl ::std::convert::TryFrom<&str> for VerdictResponseContextHeadline {
    type Error = self::error::ConversionError;
    fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<&::std::string::String> for VerdictResponseContextHeadline {
    type Error = self::error::ConversionError;
    fn try_from(
        value: &::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl ::std::convert::TryFrom<::std::string::String> for VerdictResponseContextHeadline {
    type Error = self::error::ConversionError;
    fn try_from(
        value: ::std::string::String,
    ) -> ::std::result::Result<Self, self::error::ConversionError> {
        value.parse()
    }
}
impl<'de> ::serde::Deserialize<'de> for VerdictResponseContextHeadline {
    fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
    where
        D: ::serde::Deserializer<'de>,
    {
        ::std::string::String::deserialize(deserializer)?
            .parse()
            .map_err(|e: self::error::ConversionError| {
                <D::Error as ::serde::de::Error>::custom(e.to_string())
            })
    }
}