amiril 0.0.0.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. amiril/__init__.py +51 -0
  2. amiril/_adapters.py +399 -0
  3. amiril/_engine/__init__.py +1 -0
  4. amiril/_engine/engine.py +113 -0
  5. amiril/_engine/expr.py +653 -0
  6. amiril/_engine/numbers.py +111 -0
  7. amiril/_engine/regex.py +262 -0
  8. amiril/_engine/rules.py +192 -0
  9. amiril/_engine/sentence.py +251 -0
  10. amiril/_engine/timeparse.py +72 -0
  11. amiril/_engine/validate.py +863 -0
  12. amiril/_engine/values.py +273 -0
  13. amiril/_kernel/__init__.py +1 -0
  14. amiril/_kernel/bundle.py +245 -0
  15. amiril/_kernel/coerce.py +103 -0
  16. amiril/_kernel/events.py +87 -0
  17. amiril/_kernel/guard.py +1196 -0
  18. amiril/_kernel/ids.py +66 -0
  19. amiril/_kernel/messages.py +30 -0
  20. amiril/_kernel/normalise.py +165 -0
  21. amiril/_kernel/records.py +131 -0
  22. amiril/_kernel/store.py +661 -0
  23. amiril/_runtime.py +617 -0
  24. amiril/adk.py +577 -0
  25. amiril/control/__init__.py +25 -0
  26. amiril/control/_delivery.py +567 -0
  27. amiril/control/_disk.py +418 -0
  28. amiril/control/_holds.py +252 -0
  29. amiril/control/_jsonschema.py +265 -0
  30. amiril/control/_pathc.py +85 -0
  31. amiril/control/_records.py +293 -0
  32. amiril/control/_redact.py +79 -0
  33. amiril/control/_transport.py +184 -0
  34. amiril/control/_wire.py +73 -0
  35. amiril/control/client.py +1313 -0
  36. amiril/control/config.py +204 -0
  37. amiril/control/schemas/bundle.response.schema.json +22 -0
  38. amiril/control/schemas/common.schema.json +593 -0
  39. amiril/control/schemas/decisions.request.schema.json +558 -0
  40. amiril/control/schemas/decisions.response.schema.json +23 -0
  41. amiril/control/schemas/error.response.schema.json +54 -0
  42. amiril/control/schemas/heartbeat.request.schema.json +305 -0
  43. amiril/control/schemas/heartbeat.response.schema.json +34 -0
  44. amiril/control/schemas/hold-create.request.schema.json +138 -0
  45. amiril/control/schemas/hold.response.schema.json +226 -0
  46. amiril/control/schemas/installation-register.request.schema.json +492 -0
  47. amiril/control/schemas/installation-register.response.schema.json +85 -0
  48. amiril/core.py +89 -0
  49. amiril/docs/README.md +14 -0
  50. amiril/docs/durability/langgraph.md +292 -0
  51. amiril/docs/frameworks/adk.md +141 -0
  52. amiril/docs/frameworks/langgraph.md +154 -0
  53. amiril/docs/frameworks/no-framework.md +238 -0
  54. amiril/docs/frameworks/write-an-adapter.md +203 -0
  55. amiril/durable.py +342 -0
  56. amiril/langgraph.py +746 -0
  57. amiril/plain.py +454 -0
  58. amiril/py.typed +0 -0
  59. amiril/seams.py +357 -0
  60. amiril/testing.py +21 -0
  61. amiril-0.0.0.dev0.dist-info/METADATA +114 -0
  62. amiril-0.0.0.dev0.dist-info/RECORD +64 -0
  63. amiril-0.0.0.dev0.dist-info/WHEEL +4 -0
  64. amiril-0.0.0.dev0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,305 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://amiril.ai/spec/protocol/1/heartbeat.request.schema.json",
4
+ "title": "POST /v1/installations/{id}/heartbeat request",
5
+ "type": "object",
6
+ "properties": {
7
+ "protocol": {
8
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/protocol"
9
+ },
10
+ "process": {
11
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/process"
12
+ },
13
+ "sent_at": {
14
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
15
+ },
16
+ "since": {
17
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
18
+ },
19
+ "shutdown": {
20
+ "type": "boolean"
21
+ },
22
+ "bundle": {
23
+ "oneOf": [
24
+ {
25
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/bundle_ref"
26
+ },
27
+ {
28
+ "type": "null"
29
+ }
30
+ ]
31
+ },
32
+ "sync": {
33
+ "type": "object",
34
+ "properties": {
35
+ "last_success_at": {
36
+ "oneOf": [
37
+ {
38
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
39
+ },
40
+ {
41
+ "type": "null"
42
+ }
43
+ ]
44
+ },
45
+ "consecutive_failures": {
46
+ "type": "integer",
47
+ "minimum": 0
48
+ },
49
+ "rejected": {
50
+ "oneOf": [
51
+ {
52
+ "type": "object",
53
+ "properties": {
54
+ "version": {
55
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/short_string"
56
+ },
57
+ "etag": {
58
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/etag"
59
+ },
60
+ "reason": {
61
+ "type": "string",
62
+ "minLength": 1,
63
+ "maxLength": 1024
64
+ }
65
+ },
66
+ "required": [
67
+ "version",
68
+ "etag",
69
+ "reason"
70
+ ]
71
+ },
72
+ {
73
+ "type": "null"
74
+ }
75
+ ]
76
+ },
77
+ "skipped_environment": {
78
+ "type": "integer",
79
+ "minimum": 0
80
+ },
81
+ "warnings": {
82
+ "type": "array",
83
+ "items": {
84
+ "type": "object",
85
+ "properties": {
86
+ "rule_id": {
87
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/short_string"
88
+ },
89
+ "code": {
90
+ "type": "string",
91
+ "pattern": "^[a-z][a-z0-9_]*$",
92
+ "maxLength": 64
93
+ },
94
+ "text": {
95
+ "type": "string",
96
+ "minLength": 1,
97
+ "maxLength": 1024
98
+ }
99
+ },
100
+ "required": [
101
+ "rule_id",
102
+ "code",
103
+ "text"
104
+ ]
105
+ },
106
+ "description": "Static bundle problems that did not reject it; code applies_to_target_mismatch or unreadable_rule today."
107
+ }
108
+ },
109
+ "required": [
110
+ "last_success_at",
111
+ "consecutive_failures",
112
+ "rejected",
113
+ "skipped_environment",
114
+ "warnings"
115
+ ]
116
+ },
117
+ "counts": {
118
+ "type": "array",
119
+ "items": {
120
+ "type": "object",
121
+ "properties": {
122
+ "rule_id": {
123
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/short_string"
124
+ },
125
+ "rule_version": {
126
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/short_string"
127
+ },
128
+ "allow": {
129
+ "type": "integer",
130
+ "minimum": 0
131
+ },
132
+ "flag": {
133
+ "type": "integer",
134
+ "minimum": 0
135
+ },
136
+ "hold": {
137
+ "type": "integer",
138
+ "minimum": 0
139
+ },
140
+ "block": {
141
+ "type": "integer",
142
+ "minimum": 0
143
+ },
144
+ "error": {
145
+ "type": "integer",
146
+ "minimum": 0
147
+ },
148
+ "would_fire": {
149
+ "type": "integer",
150
+ "minimum": 0
151
+ },
152
+ "shadow_error": {
153
+ "type": "integer",
154
+ "minimum": 0
155
+ }
156
+ },
157
+ "required": [
158
+ "rule_id",
159
+ "rule_version",
160
+ "allow",
161
+ "flag",
162
+ "hold",
163
+ "block",
164
+ "error",
165
+ "would_fire",
166
+ "shadow_error"
167
+ ]
168
+ },
169
+ "description": "One entry per rule that targeted at least one call in the window. Allows and flags are reported here and nowhere else."
170
+ },
171
+ "drops": {
172
+ "type": "object",
173
+ "description": "Records dropped in the window, by reason. Absent keys mean zero; the server sums.",
174
+ "properties": {
175
+ "queue_full": {
176
+ "type": "integer",
177
+ "minimum": 0
178
+ },
179
+ "rejected": {
180
+ "type": "integer",
181
+ "minimum": 0
182
+ },
183
+ "too_large": {
184
+ "type": "integer",
185
+ "minimum": 0
186
+ },
187
+ "expired": {
188
+ "type": "integer",
189
+ "minimum": 0
190
+ },
191
+ "shutdown": {
192
+ "type": "integer",
193
+ "minimum": 0
194
+ },
195
+ "redacted": {
196
+ "type": "integer",
197
+ "minimum": 0
198
+ }
199
+ },
200
+ "required": [],
201
+ "additionalProperties": false
202
+ },
203
+ "queue": {
204
+ "type": "object",
205
+ "properties": {
206
+ "depth": {
207
+ "type": "integer",
208
+ "minimum": 0
209
+ },
210
+ "capacity": {
211
+ "type": "integer",
212
+ "minimum": 1
213
+ },
214
+ "spool_records": {
215
+ "type": "integer",
216
+ "minimum": 0
217
+ }
218
+ },
219
+ "required": [
220
+ "depth",
221
+ "capacity",
222
+ "spool_records"
223
+ ]
224
+ },
225
+ "kernel": {
226
+ "type": "object",
227
+ "description": "The kernel's history report, field for field as spec/kernel.md defines it.",
228
+ "properties": {
229
+ "records": {
230
+ "type": "integer",
231
+ "minimum": 0
232
+ },
233
+ "runs_open": {
234
+ "type": "integer",
235
+ "minimum": 0
236
+ },
237
+ "sessions": {
238
+ "type": "integer",
239
+ "minimum": 0
240
+ },
241
+ "evicted_runs": {
242
+ "type": "integer",
243
+ "minimum": 0
244
+ },
245
+ "evicted_sessions": {
246
+ "type": "integer",
247
+ "minimum": 0
248
+ },
249
+ "evicted_records_by_age": {
250
+ "type": "integer",
251
+ "minimum": 0
252
+ },
253
+ "evicted_records_by_size": {
254
+ "type": "integer",
255
+ "minimum": 0
256
+ },
257
+ "over_limit_events": {
258
+ "type": "integer",
259
+ "minimum": 0
260
+ }
261
+ },
262
+ "required": [
263
+ "records",
264
+ "runs_open",
265
+ "sessions",
266
+ "evicted_runs",
267
+ "evicted_sessions",
268
+ "evicted_records_by_age",
269
+ "evicted_records_by_size",
270
+ "over_limit_events"
271
+ ]
272
+ },
273
+ "holds": {
274
+ "type": "object",
275
+ "properties": {
276
+ "opened": {
277
+ "type": "integer",
278
+ "minimum": 0
279
+ },
280
+ "wait_ms_max": {
281
+ "type": "integer",
282
+ "minimum": 0
283
+ }
284
+ },
285
+ "required": [
286
+ "opened",
287
+ "wait_ms_max"
288
+ ]
289
+ }
290
+ },
291
+ "required": [
292
+ "protocol",
293
+ "process",
294
+ "sent_at",
295
+ "since",
296
+ "shutdown",
297
+ "bundle",
298
+ "sync",
299
+ "counts",
300
+ "drops",
301
+ "queue",
302
+ "kernel",
303
+ "holds"
304
+ ]
305
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://amiril.ai/spec/protocol/1/heartbeat.response.schema.json",
4
+ "title": "POST /v1/installations/{id}/heartbeat response (200)",
5
+ "type": "object",
6
+ "properties": {
7
+ "protocol": {
8
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/protocol"
9
+ },
10
+ "server_time": {
11
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
12
+ },
13
+ "heartbeat_interval_ms": {
14
+ "type": "integer",
15
+ "minimum": 1
16
+ },
17
+ "bundle_hint": {
18
+ "oneOf": [
19
+ {
20
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/bundle_ref"
21
+ },
22
+ {
23
+ "type": "null"
24
+ }
25
+ ]
26
+ }
27
+ },
28
+ "required": [
29
+ "protocol",
30
+ "server_time",
31
+ "heartbeat_interval_ms",
32
+ "bundle_hint"
33
+ ]
34
+ }
@@ -0,0 +1,138 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://amiril.ai/spec/protocol/1/hold-create.request.schema.json",
4
+ "title": "POST /v1/holds request",
5
+ "type": "object",
6
+ "properties": {
7
+ "protocol": {
8
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/protocol"
9
+ },
10
+ "idempotency_key": {
11
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/uuid"
12
+ },
13
+ "installation_id": {
14
+ "oneOf": [
15
+ {
16
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/opaque_id"
17
+ },
18
+ {
19
+ "type": "null"
20
+ }
21
+ ]
22
+ },
23
+ "process_id": {
24
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/uuid"
25
+ },
26
+ "hold": {
27
+ "type": "object",
28
+ "properties": {
29
+ "rule": {
30
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/rule_ref"
31
+ },
32
+ "bundle_version": {
33
+ "oneOf": [
34
+ {
35
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/short_string"
36
+ },
37
+ {
38
+ "type": "null"
39
+ }
40
+ ]
41
+ },
42
+ "tool": {
43
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/tool"
44
+ },
45
+ "agent": {
46
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/agent"
47
+ },
48
+ "call": {
49
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/call"
50
+ },
51
+ "trace": {
52
+ "oneOf": [
53
+ {
54
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/trace"
55
+ },
56
+ {
57
+ "type": "null"
58
+ }
59
+ ]
60
+ },
61
+ "blocked_span": {
62
+ "enum": [
63
+ "emitted",
64
+ "none",
65
+ "unknown"
66
+ ]
67
+ },
68
+ "run_id": {
69
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/short_string"
70
+ },
71
+ "root_run_id": {
72
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/short_string"
73
+ },
74
+ "session_id": {
75
+ "oneOf": [
76
+ {
77
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/short_string"
78
+ },
79
+ {
80
+ "type": "null"
81
+ }
82
+ ]
83
+ },
84
+ "arguments": {
85
+ "oneOf": [
86
+ {
87
+ "type": "object"
88
+ },
89
+ {
90
+ "type": "null"
91
+ }
92
+ ]
93
+ },
94
+ "arguments_truncated": {
95
+ "type": "boolean"
96
+ },
97
+ "sentence": {
98
+ "type": "string",
99
+ "minLength": 1
100
+ },
101
+ "evidence": {
102
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/evidence"
103
+ },
104
+ "timeout_ms": {
105
+ "type": "integer",
106
+ "minimum": 1
107
+ },
108
+ "requested_at": {
109
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
110
+ }
111
+ },
112
+ "required": [
113
+ "rule",
114
+ "bundle_version",
115
+ "tool",
116
+ "agent",
117
+ "call",
118
+ "trace",
119
+ "blocked_span",
120
+ "run_id",
121
+ "root_run_id",
122
+ "session_id",
123
+ "arguments",
124
+ "sentence",
125
+ "evidence",
126
+ "timeout_ms",
127
+ "requested_at"
128
+ ]
129
+ }
130
+ },
131
+ "required": [
132
+ "protocol",
133
+ "idempotency_key",
134
+ "installation_id",
135
+ "process_id",
136
+ "hold"
137
+ ]
138
+ }
@@ -0,0 +1,226 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://amiril.ai/spec/protocol/1/hold.response.schema.json",
4
+ "title": "POST /v1/holds response (201/200) and GET /v1/holds/{id} response (200)",
5
+ "type": "object",
6
+ "properties": {
7
+ "protocol": {
8
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/protocol"
9
+ },
10
+ "server_time": {
11
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
12
+ },
13
+ "hold": {
14
+ "type": "object",
15
+ "properties": {
16
+ "id": {
17
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/opaque_id"
18
+ },
19
+ "state": {
20
+ "enum": [
21
+ "pending",
22
+ "approved",
23
+ "denied",
24
+ "expired"
25
+ ]
26
+ },
27
+ "created_at": {
28
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
29
+ },
30
+ "expires_at": {
31
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
32
+ },
33
+ "resolution": {
34
+ "oneOf": [
35
+ {
36
+ "type": "object",
37
+ "properties": {
38
+ "answer": {
39
+ "enum": [
40
+ "approved",
41
+ "denied",
42
+ "expired"
43
+ ]
44
+ },
45
+ "note": {
46
+ "oneOf": [
47
+ {
48
+ "type": "string",
49
+ "maxLength": 4096
50
+ },
51
+ {
52
+ "type": "null"
53
+ }
54
+ ]
55
+ },
56
+ "resolved_at": {
57
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
58
+ }
59
+ },
60
+ "required": [
61
+ "answer",
62
+ "note",
63
+ "resolved_at"
64
+ ]
65
+ },
66
+ {
67
+ "type": "null"
68
+ }
69
+ ]
70
+ }
71
+ },
72
+ "required": [
73
+ "id",
74
+ "state",
75
+ "created_at",
76
+ "expires_at",
77
+ "resolution"
78
+ ],
79
+ "allOf": [
80
+ {
81
+ "if": {
82
+ "type": "object",
83
+ "properties": {
84
+ "state": {
85
+ "const": "pending"
86
+ }
87
+ },
88
+ "required": [
89
+ "state"
90
+ ]
91
+ },
92
+ "then": {
93
+ "type": "object",
94
+ "properties": {
95
+ "resolution": {
96
+ "type": "null"
97
+ }
98
+ }
99
+ },
100
+ "else": {
101
+ "type": "object",
102
+ "properties": {
103
+ "resolution": {
104
+ "type": "object",
105
+ "properties": {
106
+ "answer": {
107
+ "enum": [
108
+ "approved",
109
+ "denied",
110
+ "expired"
111
+ ]
112
+ },
113
+ "note": {
114
+ "oneOf": [
115
+ {
116
+ "type": "string",
117
+ "maxLength": 4096
118
+ },
119
+ {
120
+ "type": "null"
121
+ }
122
+ ]
123
+ },
124
+ "resolved_at": {
125
+ "$ref": "https://amiril.ai/spec/protocol/1/common.schema.json#/$defs/timestamp"
126
+ }
127
+ },
128
+ "required": [
129
+ "answer",
130
+ "note",
131
+ "resolved_at"
132
+ ]
133
+ }
134
+ }
135
+ }
136
+ },
137
+ {
138
+ "if": {
139
+ "type": "object",
140
+ "properties": {
141
+ "state": {
142
+ "const": "approved"
143
+ }
144
+ },
145
+ "required": [
146
+ "state"
147
+ ]
148
+ },
149
+ "then": {
150
+ "type": "object",
151
+ "properties": {
152
+ "resolution": {
153
+ "type": "object",
154
+ "properties": {
155
+ "answer": {
156
+ "const": "approved"
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ },
163
+ {
164
+ "if": {
165
+ "type": "object",
166
+ "properties": {
167
+ "state": {
168
+ "const": "denied"
169
+ }
170
+ },
171
+ "required": [
172
+ "state"
173
+ ]
174
+ },
175
+ "then": {
176
+ "type": "object",
177
+ "properties": {
178
+ "resolution": {
179
+ "type": "object",
180
+ "properties": {
181
+ "answer": {
182
+ "const": "denied"
183
+ }
184
+ }
185
+ }
186
+ }
187
+ }
188
+ },
189
+ {
190
+ "if": {
191
+ "type": "object",
192
+ "properties": {
193
+ "state": {
194
+ "const": "expired"
195
+ }
196
+ },
197
+ "required": [
198
+ "state"
199
+ ]
200
+ },
201
+ "then": {
202
+ "type": "object",
203
+ "properties": {
204
+ "resolution": {
205
+ "type": "object",
206
+ "properties": {
207
+ "answer": {
208
+ "const": "expired"
209
+ },
210
+ "note": {
211
+ "type": "null"
212
+ }
213
+ }
214
+ }
215
+ }
216
+ }
217
+ }
218
+ ]
219
+ }
220
+ },
221
+ "required": [
222
+ "protocol",
223
+ "server_time",
224
+ "hold"
225
+ ]
226
+ }