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
amiril/seams.py ADDED
@@ -0,0 +1,357 @@
1
+ """The seams between the kernel, the framework adapters and the control-plane
2
+ client: typed interfaces (`typing.Protocol`) and a local-only implementation
3
+ of each, so the core and the adapters run with no control plane.
4
+
5
+ Each method names the spec section it serves. The adapters (built on top of
6
+ the kernel) and the control-plane client (built beside it) implement or
7
+ consume these without editing each other's files.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import logging
14
+ import threading
15
+ import time
16
+ from collections.abc import Callable, Iterable
17
+ from dataclasses import dataclass, field
18
+ from pathlib import Path
19
+ from typing import TYPE_CHECKING, Any, Protocol, Union, runtime_checkable
20
+
21
+ from ._engine.numbers import dumps_line
22
+ from ._kernel.events import DecisionEvent, decision_line
23
+ from ._kernel.records import CallRecord, Decision
24
+
25
+ log = logging.getLogger("amiril")
26
+
27
+
28
+ # ---------------------------------------------------------------- bundle source (kernel.md 8.4, protocol.md 3, 5)
29
+
30
+ @runtime_checkable
31
+ class BundleSource(Protocol):
32
+ """Where rule documents come from. The control-plane client implements it
33
+ over `GET /v1/rules/bundle`; `FileBundleSource` and `StaticBundleSource`
34
+ serve local-only mode (protocol.md 3)."""
35
+
36
+ def initial(self) -> dict | None:
37
+ """The bundle body or bare document to load at start (kernel.md 8.4), or None for none."""
38
+ ...
39
+
40
+ def subscribe(self, on_bundle: Callable[[dict], None]) -> None:
41
+ """Register the callback to receive every later bundle; the kernel's
42
+ `swap` is the usual callback (protocol.md 5.4: validate, then swap atomically)."""
43
+ ...
44
+
45
+
46
+ class StaticBundleSource:
47
+ """A bundle or document held in memory; it never changes."""
48
+
49
+ def __init__(self, document_or_bundle: dict | None) -> None:
50
+ self._doc = document_or_bundle
51
+
52
+ def initial(self) -> dict | None:
53
+ return self._doc
54
+
55
+ def subscribe(self, on_bundle: Callable[[dict], None]) -> None:
56
+ return None
57
+
58
+
59
+ class FileBundleSource:
60
+ """A rules file: a bundle response body or a bare rule document
61
+ (protocol.md 3). `reload()` reads it again and notifies subscribers, so a
62
+ host can wire it to a file watcher or a signal; nothing polls by itself."""
63
+
64
+ def __init__(self, path: str | Path) -> None:
65
+ self.path = Path(path)
66
+ self._subscribers: list[Callable[[dict], None]] = []
67
+
68
+ def _read(self) -> dict:
69
+ with open(self.path, encoding="utf-8") as fh:
70
+ return json.load(fh)
71
+
72
+ def initial(self) -> dict | None:
73
+ return self._read()
74
+
75
+ def subscribe(self, on_bundle: Callable[[dict], None]) -> None:
76
+ self._subscribers.append(on_bundle)
77
+
78
+ def reload(self) -> None:
79
+ doc = self._read()
80
+ for fn in list(self._subscribers):
81
+ fn(doc)
82
+
83
+
84
+ # ---------------------------------------------------------------- decision sink (decision-line.md, protocol.md 8)
85
+
86
+ @runtime_checkable
87
+ class DecisionSink(Protocol):
88
+ """Receives every `DecisionEvent` the kernel emits: one per decision line,
89
+ summary line and fault line (decision-line.md 1). The event carries the
90
+ fields protocol.md 8.3 needs that the kernel knows: the decision (rule,
91
+ action, mode, rule_mode, outcome, evidence, sentence, error, latency), the
92
+ call record (ids, attempt, batch, seq, parent, tool id and raw name,
93
+ declared id, whether the call id is the framework's `tool_call_id` or
94
+ minted), the run context (run, root run, session, agent and root agent),
95
+ the aggregate, the phase, the hold resolution (answer, token and outcome
96
+ detail), the fault text, action and kind (`kernel`, `hold` or `adapter`;
97
+ a `hold` fault posts no separate record, protocol.md 7.4), the bundle
98
+ version and the time taken."""
99
+
100
+ def on_event(self, event: DecisionEvent) -> None: ...
101
+
102
+
103
+ class DecisionLineLog:
104
+ """The local-only sink: decision lines (decision-line.md) kept in memory and,
105
+ with a path, appended to a JSONL file. The conformance runner reads `lines`."""
106
+
107
+ def __init__(self, path: str | Path | None = None, keep: bool = True) -> None:
108
+ self.path = Path(path) if path is not None else None
109
+ self.keep = keep
110
+ self.lines: list[dict] = []
111
+ self._lock = threading.Lock()
112
+
113
+ def on_event(self, event: DecisionEvent) -> None:
114
+ line = decision_line(event)
115
+ with self._lock:
116
+ if self.keep:
117
+ self.lines.append(line)
118
+ if self.path is not None:
119
+ with open(self.path, "a", encoding="utf-8") as fh:
120
+ fh.write(dumps_line(line) + "\n")
121
+
122
+ def clear(self) -> None:
123
+ with self._lock:
124
+ self.lines.clear()
125
+
126
+
127
+ # ---------------------------------------------------------------- resolver (kernel.md 7, protocol.md 7)
128
+
129
+ @runtime_checkable
130
+ class SyncResolver(Protocol):
131
+ """What a hold waits on (kernel.md 7), synchronous shape. `resolve` returns
132
+ `{"answer": "allow" | "block" | "timeout", "token": str | None, "outcome":
133
+ ...}` where `outcome` is the hold outcome detail of protocol.md 7.4
134
+ (`approved`, `denied`, `expired`, `unreachable`) and may be omitted, in
135
+ which case the kernel derives it from the answer (a hold the control plane
136
+ does not know is `denied`). `owns_deadline` declares that the resolver
137
+ bounds its own wait (the control-plane resolver does: the server's
138
+ `expires_at` plus grace); when False the kernel's timer, the rule's
139
+ `hold_timeout_ms`, applies."""
140
+
141
+ owns_deadline: bool
142
+
143
+ def resolve(self, decision: Decision, record: CallRecord, timeout_ms: int) -> dict: ...
144
+
145
+
146
+ @runtime_checkable
147
+ class AsyncResolver(Protocol):
148
+ """The awaitable shape of `SyncResolver`, which the asynchronous kernel path
149
+ prefers. The kernel accepts a resolver implementing either shape or both:
150
+ a synchronous call of an async-only resolver runs `aresolve` on the hold
151
+ worker thread; an asynchronous call of a sync-only resolver runs `resolve`
152
+ in a thread."""
153
+
154
+ owns_deadline: bool
155
+
156
+ async def aresolve(self, decision: Decision, record: CallRecord, timeout_ms: int) -> dict: ...
157
+
158
+
159
+ def is_resolver(obj: Any) -> bool:
160
+ """True when `obj` implements `SyncResolver`, `AsyncResolver` or both: a
161
+ callable `resolve` or `aresolve`. `owns_deadline` is optional and read with
162
+ `getattr` (absent means False), as the kernel reads it."""
163
+ return callable(getattr(obj, "resolve", None)) or callable(getattr(obj, "aresolve", None))
164
+
165
+
166
+ if TYPE_CHECKING:
167
+ Resolver = Union[SyncResolver, AsyncResolver]
168
+ else:
169
+ class _ResolverCheck(type):
170
+ def __instancecheck__(cls, obj: Any) -> bool:
171
+ return is_resolver(obj)
172
+
173
+ class Resolver(metaclass=_ResolverCheck):
174
+ """`Union[SyncResolver, AsyncResolver]` to a type checker. At run time
175
+ `isinstance(x, Resolver)` is `is_resolver(x)`: a Union of Protocols with a
176
+ data member (`owns_deadline`) cannot be used with `isinstance` before
177
+ Python 3.12."""
178
+
179
+
180
+ class FunctionResolver:
181
+ """Local-only resolver over a host callable `(decision, record, timeout_ms)
182
+ -> "allow" | "block"` (a prompt, a ticket system, a test script). The
183
+ kernel's timer bounds the wait; an exception is a `timeout` answer."""
184
+
185
+ owns_deadline = False
186
+
187
+ def __init__(self, fn: Callable[[Decision, CallRecord, int], Any]) -> None:
188
+ self._fn = fn
189
+ self._n = 0
190
+
191
+ def resolve(self, decision: Decision, record: CallRecord, timeout_ms: int) -> dict:
192
+ answer = self._fn(decision, record, timeout_ms)
193
+ if isinstance(answer, dict):
194
+ return answer
195
+ self._n += 1
196
+ return {"answer": answer, "token": f"local:{decision.rule_id}:{record.call_id}:{self._n}"}
197
+
198
+ async def aresolve(self, decision: Decision, record: CallRecord, timeout_ms: int) -> dict:
199
+ # The host callable may block (a prompt, a ticket system): run it off the
200
+ # event loop, so the loop keeps running and the kernel's timer can fire.
201
+ import asyncio
202
+
203
+ return await asyncio.to_thread(self.resolve, decision, record, timeout_ms)
204
+
205
+
206
+ # ---------------------------------------------------------------- durable store (kernel.md 4.1a)
207
+
208
+ @runtime_checkable
209
+ class DurableStore(Protocol):
210
+ """Where the kernel's history survives a process restart (kernel.md 4.1a).
211
+ The kernel writes through synchronously: `put` on every record write that
212
+ matters (the record appended at `before_call` with its outcome, a status
213
+ change, the completion at `after_call`), `delete` when records are
214
+ evicted, `close_run` when a root run is evicted as idle (its `seq` counter
215
+ goes), `end_run` when a root run ends (its session-less records and its
216
+ counter go, held in memory or not), and `sweep(now)` on the kernel's
217
+ periodic sweep (the store's own retention; returns the records deleted).
218
+ `load` returns, in arrival order, every stored record of a root run and
219
+ of an (agent, session), each with its stored outcome (`{"action",
220
+ "decisions", "message"}` or None); the `seq` counter of each root run
221
+ among them that is still open; and the rows it could not decode, each as
222
+ (root run id, call id, attempt, agent id, session id, error text), so one
223
+ bad row is skipped with a fault line and never fails the unit. A store
224
+ that cannot be read or written must raise when it is opened.
225
+ `amiril.durable.SqliteStore` is the local implementation."""
226
+
227
+ def put(self, record: CallRecord, outcome: dict | None, seq: int | None) -> None: ...
228
+
229
+ def delete(self, keys: Iterable[tuple[str, str, int]]) -> None: ...
230
+
231
+ def close_run(self, root_run_id: str) -> None: ...
232
+
233
+ def end_run(self, root_run_id: str) -> None: ...
234
+
235
+ def sweep(self, now: float) -> int: ...
236
+
237
+ def load(self, root_run_id: str | None, agent_id: str, session_id: str | None
238
+ ) -> tuple[list[tuple[CallRecord, dict | None]], dict[str, int],
239
+ list[tuple[str, str, int, str, str | None, str]]]: ...
240
+
241
+
242
+ # ---------------------------------------------------------------- registration reporter (protocol.md 4, 12)
243
+
244
+ @dataclass
245
+ class CoverageReport:
246
+ """protocol.md 4.3: what the adapter found at install."""
247
+
248
+ agents: list[dict] = field(default_factory=list)
249
+ tools: list[dict] = field(default_factory=list)
250
+ uncovered: list[dict] = field(default_factory=list)
251
+ truncated: bool = False
252
+ redaction_failed: bool = False
253
+ generated_at: float = field(default_factory=time.time)
254
+
255
+
256
+ @dataclass
257
+ class AdapterRegistration:
258
+ """What an adapter reports once at install (protocol.md 4.1, 4.3, 12):
259
+ the adapter's name and version, the framework and its version (both None
260
+ for an agent wired by hand, `amiril.plain`), the per-framework constants
261
+ `span_role` (`tool`, `parent`, `unknown`) and `blocked_span` (`emitted`,
262
+ `none`, `unknown`), and the coverage report.
263
+ `key` names what was instrumented (the app's root agent, the compiled
264
+ graph): a later registration with the same adapter and key replaces the
265
+ earlier one instead of adding to it, so superseded coverage goes away."""
266
+
267
+ adapter: str
268
+ adapter_version: str
269
+ framework: str | None
270
+ framework_version: str | None
271
+ span_role: str
272
+ blocked_span: str
273
+ coverage: CoverageReport
274
+ key: str | None = None
275
+
276
+
277
+ def replace_registration(registrations: list, registration: AdapterRegistration) -> None:
278
+ """Add `registration`, replacing one with the same adapter and key (a key of None never replaces)."""
279
+ if registration.key is not None:
280
+ for i, r in enumerate(registrations):
281
+ if r.adapter == registration.adapter and r.key == registration.key:
282
+ registrations[i] = registration
283
+ return
284
+ registrations.append(registration)
285
+
286
+
287
+ @runtime_checkable
288
+ class RegistrationReporter(Protocol):
289
+ """Where adapters report their registration. The control-plane client posts
290
+ it (`POST /v1/installations`); `LocalRegistrationReporter` keeps it."""
291
+
292
+ def register(self, registration: AdapterRegistration) -> None: ...
293
+
294
+
295
+ class LocalRegistrationReporter:
296
+ """Local-only: remembers every registration and logs one line each."""
297
+
298
+ def __init__(self) -> None:
299
+ self.registrations: list[AdapterRegistration] = []
300
+
301
+ def register(self, registration: AdapterRegistration) -> None:
302
+ self.registrations.append(registration)
303
+ log.info("amiril: adapter %s %s for %s registered locally (%d tools, %d uncovered)",
304
+ registration.adapter, registration.adapter_version, registration.framework or "no framework",
305
+ len(registration.coverage.tools), len(registration.coverage.uncovered))
306
+
307
+
308
+ # ------------------------------------------------ counters and history report (kernel.md 4.4, 14; protocol.md 6.1)
309
+
310
+ @runtime_checkable
311
+ class KernelStats(Protocol):
312
+ """What a heartbeat reads from the kernel: `history_report()` (kernel.md
313
+ 4.4, carried verbatim as the heartbeat's `kernel`), `drain_counts()` (the
314
+ heartbeat's `counts[]`, reset per window), the loaded `ruleset_version`,
315
+ the `bundle_version` in use, its `bundle_warnings` (`sync.warnings`) and
316
+ `skipped_environment` (`sync.skipped_environment`), and the kernel `mode`.
317
+ All of these describe the one document in use at the time of reading
318
+ (kernel.md 15)."""
319
+
320
+ mode: str
321
+
322
+ @property
323
+ def bundle_version(self) -> str | None: ...
324
+
325
+ @property
326
+ def bundle_warnings(self) -> list[dict]: ...
327
+
328
+ @property
329
+ def skipped_environment(self) -> int: ...
330
+
331
+ @property
332
+ def ruleset_version(self) -> str: ...
333
+
334
+ def history_report(self) -> dict[str, int]: ...
335
+
336
+ def drain_counts(self) -> list[dict]: ...
337
+
338
+
339
+ __all__ = [
340
+ "AdapterRegistration",
341
+ "AsyncResolver",
342
+ "BundleSource",
343
+ "CoverageReport",
344
+ "DecisionLineLog",
345
+ "DecisionSink",
346
+ "DurableStore",
347
+ "FileBundleSource",
348
+ "FunctionResolver",
349
+ "KernelStats",
350
+ "LocalRegistrationReporter",
351
+ "RegistrationReporter",
352
+ "Resolver",
353
+ "is_resolver",
354
+ "replace_registration",
355
+ "StaticBundleSource",
356
+ "SyncResolver",
357
+ ]
amiril/testing.py ADDED
@@ -0,0 +1,21 @@
1
+ """Test seams (spec/kernel.md 10, conformance/README.md 1.3 `fault`).
2
+
3
+ `InjectedFault` is a value the kernel cannot normalise: its string form
4
+ raises. Passed as an argument value it makes `before_call` fault before the
5
+ record exists; passed as a tool result it makes `after_call` fault. The
6
+ kernel must fail open and write a fault line either way.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+
12
+ class InjectedFault:
13
+ """A value whose normalisation raises; stands in for an adapter or kernel bug."""
14
+
15
+ def __str__(self) -> str:
16
+ raise RuntimeError("injected fault")
17
+
18
+ __repr__ = __str__
19
+
20
+
21
+ __all__ = ["InjectedFault"]
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.5
2
+ Name: amiril
3
+ Version: 0.0.0.dev0
4
+ Summary: Check an agent's tool calls against rules before they run, through the agent framework's native hooks.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.11
8
+ Provides-Extra: adk
9
+ Requires-Dist: google-adk>=2.11; extra == 'adk'
10
+ Provides-Extra: crewai
11
+ Provides-Extra: langgraph
12
+ Requires-Dist: langchain-core>=1.5; extra == 'langgraph'
13
+ Requires-Dist: langchain>=1.3; extra == 'langgraph'
14
+ Requires-Dist: langgraph-prebuilt>=1.1; extra == 'langgraph'
15
+ Requires-Dist: langgraph>=1.2; extra == 'langgraph'
16
+ Provides-Extra: otel
17
+ Description-Content-Type: text/markdown
18
+
19
+ # amiril (Python)
20
+
21
+ The Python Amiril SDK: the rule engine (`spec/edoc.md`) and the kernel
22
+ (`spec/kernel.md`) with no runtime dependencies, `amiril.init()` and
23
+ `amiril.instrument()`, and the framework adapters as extras:
24
+ `amiril[adk]` (Google ADK) and `amiril[langgraph]` (LangGraph and
25
+ LangChain `create_agent`). `amiril.plain` is the same checks for an agent
26
+ written by hand, with no extra. Getting started: `docs/frameworks/adk.md`,
27
+ `docs/frameworks/langgraph.md` and `docs/frameworks/no-framework.md`.
28
+
29
+ ```
30
+ src/amiril/
31
+ __init__.py init(), instrument(), the handle (_runtime.py) and the install errors
32
+ adk.py the ADK adapter: one plugin, first in the app's plugin list
33
+ langgraph.py the LangGraph adapter: create_agent middleware and a ToolNode for StateGraph
34
+ plain.py no framework (spec/plain.md): name an agent, wrap its tools, mark a run,
35
+ or check each call by hand; also what an adapter for another framework calls
36
+ _adapters.py what the adapters share: parent link, faults, coercion, coverage entries
37
+ core.py the public surface adapters import: Guard, RunContext, CallRecord,
38
+ Decision, Outcome, load_document, coerce_args, ...
39
+ seams.py the interfaces between the kernel, the adapters and the control-plane
40
+ client (bundle source, decision sink, resolver, registration reporter,
41
+ kernel stats), each with a local-only implementation
42
+ control/ the control-plane client (spec/protocol.md): registration, rule sync,
43
+ heartbeats, decision delivery and spool, holds, redaction, path C
44
+ testing.py InjectedFault, the fault-injection seam the conformance suite uses
45
+ _engine/ loader and validator, evaluator, sentences
46
+ _kernel/ records, history store, Guard, decision lines, coercion, ids
47
+ tests/
48
+ control/ the client against a fake control plane that schema-checks every request
49
+ (../../spec/protocol), and an integration test against the real ingest
50
+ service, skipped unless AMIRIL_TEST_ENDPOINT and AMIRIL_TEST_KEY are set
51
+ conformance/ the runner over ../../conformance (scenarios and golden lines, probes,
52
+ bad documents, catalogue, coercion)
53
+ frameworks/ the scenarios through real ADK and LangGraph runs (scripted models), the
54
+ span constants, install order, coverage, tool-error parity, the examples
55
+ unit/ eviction, history report, swap, tool_id, holds and faults, init()
56
+ examples/ runnable offline examples behind the getting-started pages
57
+ scripts/
58
+ test-installed.sh build the wheel, install it into a fresh venv, run the suite against it
59
+ bench.py latency benchmark: 50 rules, 200 prior calls, p50 and p99 per decision
60
+ ```
61
+
62
+ Running the control-plane client in production:
63
+
64
+ - **SIGTERM loses queued records** unless the host acts: Python's default
65
+ SIGTERM handling skips `atexit`, so the client neither sends nor spools
66
+ what is queued. Call the handle's `shutdown()` (or the client's) from a
67
+ SIGTERM handler, or install one that raises `SystemExit`.
68
+ - **Forking servers** (gunicorn `--preload`, celery prefork) are supported:
69
+ each child re-initialises the client with a new process id and starts it
70
+ on first use.
71
+ - **Proxies** come from `HTTPS_PROXY`/`HTTP_PROXY` and `NO_PROXY`.
72
+ - **Disk**: the spool and bundle cache live in `AMIRIL_CACHE_DIR`, else
73
+ `$XDG_CACHE_HOME/amiril`, else `<tmp>/amiril-<uid>`, a directory that must
74
+ be private to the user (0700); otherwise they are not used.
75
+ - **DNS** is not bounded by the client's timeouts (hold reads included); the
76
+ system resolver's own timeouts apply.
77
+
78
+ Develop with `uv sync` then `uv run pytest`; for the framework tests,
79
+ `uv sync --group frameworks --python 3.12`. Prove publishability with
80
+ `scripts/test-installed.sh [3.11]` and, with the frameworks,
81
+ `scripts/test-installed.sh 3.12 frameworks`, which is what CI runs.
82
+
83
+ With a framework, local-only (no API key, no network):
84
+
85
+ ```python
86
+ import amiril
87
+
88
+ amiril.init(rules_file="rules.json")
89
+ amiril.instrument(app) # an ADK App or Runner; for LangGraph see docs/frameworks/langgraph.md
90
+ ```
91
+
92
+ The kernel on its own:
93
+
94
+ ```python
95
+ from amiril.core import Guard, RunContext, load_document_file
96
+
97
+ guard = Guard(mode="enforce", document=load_document_file("rules.json"))
98
+ ctx = RunContext(run_id="run-1", agent_id="planner")
99
+ outcome = guard.before_call(ctx, "call-1", "update_record", {"id": "rec_1", "count": 12}, batch_id="turn-1")
100
+ if outcome.proceeds:
101
+ result = update_record(id="rec_1", count=12)
102
+ guard.after_call(ctx, "call-1", raw_result=result)
103
+ else:
104
+ result = outcome.message # what the model is told
105
+ guard.end_run(ctx)
106
+ ```
107
+
108
+ ## For AI assistants
109
+
110
+ The installed package carries its docs for the installed version in
111
+ `amiril/docs/` under site-packages; start at `amiril/docs/README.md`. They
112
+ need no network call. Find the folder with
113
+ `python -c "import amiril, pathlib; print(pathlib.Path(amiril.__file__).parent / 'docs')"`.
114
+ Fuller docs: https://docs.amiril.ai/llms.txt
@@ -0,0 +1,64 @@
1
+ amiril/__init__.py,sha256=jZcILN_VS3jdw7ec96iSGh5_328xm_8hUn_bZr093Uk,1628
2
+ amiril/_adapters.py,sha256=r9udkq4lCRuRvHmEikMEoAl-yFPUyDJkKcQIzS2jMKU,14017
3
+ amiril/_runtime.py,sha256=fL9Cfjg4Ndyrv06Ibr1HAzksLKPOFWsK3p1em9Vq51c,26609
4
+ amiril/adk.py,sha256=d6OHAzxRw6MnErTA0x_v3K0rtNSWFakhnLTpA4N_FKU,25646
5
+ amiril/core.py,sha256=BjbvkVQxOSLZSS3uoEKqr3R-f3i2Zz_op1M2d3rUK8M,3114
6
+ amiril/durable.py,sha256=9XJII0k2x-q5aaRVRSGzDV9AhMDBPlUJms8FyGHtHz0,16524
7
+ amiril/langgraph.py,sha256=4ft6xnVP3RJ142yQuik1UHJErWF-iQhordjs9Q_yRBI,31688
8
+ amiril/plain.py,sha256=WK4gB-ye1lrBMMnjUSn3TNHb43xCof6ViKdCxlF6Feg,19307
9
+ amiril/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ amiril/seams.py,sha256=DULMGwhopCUzJ3TM3snWo5QWutYbPpBejdEQtA-TNqM,14087
11
+ amiril/testing.py,sha256=ve0goirkGhR81d8HyF9Gp-YWaFL2vrsApwEWGENAEjc,627
12
+ amiril/_engine/__init__.py,sha256=T9a1mEebp_Sfz4Pw2-S-cKsY4yWOk2GpKEe_J-U_MgA,74
13
+ amiril/_engine/engine.py,sha256=qOWy-ijx-S_S3IBFYV1y7D_4-qyiY_JX58zhqS1dAI0,5047
14
+ amiril/_engine/expr.py,sha256=ym1_nr7knEJhSyl3bEUp6UtE2RtuY4-LQ3V5w7gy1X8,24731
15
+ amiril/_engine/numbers.py,sha256=PT8Lls3s44n_TPLTuSSgDguWRAI-upqT-kumKLhRSEg,3313
16
+ amiril/_engine/regex.py,sha256=2r4AIcNxjWA-o8XJcT0trnY1R5m86EEfJQ8SG5bMTEY,8098
17
+ amiril/_engine/rules.py,sha256=YvhCZoP8hqlKgR2roPBiitzZ6A37_MIqeuIGj5Cf3hY,7817
18
+ amiril/_engine/sentence.py,sha256=RiaHNu50vCcSKeZXi3OeDDeJYWuz8hmgpVaNSrYXWUM,9219
19
+ amiril/_engine/timeparse.py,sha256=4as0fVsWCC_OpB0_Q50MVq25OzlHstq-q-TXe4xYFFo,2707
20
+ amiril/_engine/validate.py,sha256=0PWnc8QN_u9schbmSMiiF4oysnC9LSnH2IHJ-k6wocE,39291
21
+ amiril/_engine/values.py,sha256=YO3TWPTCjOXuqKcU8zGXssmV_uPNYNrtfVhYMRiZLyM,7338
22
+ amiril/_kernel/__init__.py,sha256=_7O--RMIOzAgzgzobOmPPmE9ZERz5Rmht519KOS41wI,71
23
+ amiril/_kernel/bundle.py,sha256=21DkwOkbCEsnPtkJz3azgVu9XEp15FMmpr8C63EIxHE,11384
24
+ amiril/_kernel/coerce.py,sha256=iDNLpfgEjwJgFc5-Wz3S8a8dEAbJU-BJKKRvPJ8UVuI,3730
25
+ amiril/_kernel/events.py,sha256=AZM9qHWiOXlF0Hcb-B79cIzfA7d_yEaMH5e7isNNWgk,3926
26
+ amiril/_kernel/guard.py,sha256=JrtrkqVtAqGZOXAd0clIFKK_nNIFAhPnBJl3Zpf6FHk,57954
27
+ amiril/_kernel/ids.py,sha256=_jpvzX19xJtxrbrormJb35lSbHEQHnYNwn4Ra3UquLo,2365
28
+ amiril/_kernel/messages.py,sha256=D8-u9OW5eRZXoow2xPay-dZDvLBRBOQMesFEdyvppgw,1312
29
+ amiril/_kernel/normalise.py,sha256=obMTdEMPbg4BP-8YERkCNREh_oi6wuH3m7qVfqUeU2s,5620
30
+ amiril/_kernel/records.py,sha256=KDd91h86r55xsdmeb8XYTOOuuDic-2zKqulunzFnLWU,4220
31
+ amiril/_kernel/store.py,sha256=4NjooWQtraG4Z9SpLuCpgKy8wT70JYb2Bgkig30MGg0,31416
32
+ amiril/control/__init__.py,sha256=VtoMd7-yF7QMsQXbWi9d7jIZ2VOsORvRmnofafsUggI,1111
33
+ amiril/control/_delivery.py,sha256=EVztCId5Pxf0CNNuU8mGuvwOzkrHtA5tLuCZk5Sl41k,23482
34
+ amiril/control/_disk.py,sha256=ZCIEQnP7vITA9jsjk-DAeJ84H5m8rxwPgkj-5y8y22g,15324
35
+ amiril/control/_holds.py,sha256=GURKk8pO-hG4-JqX5RF9YvV8MUvaPaA11j5LmOxVynA,11779
36
+ amiril/control/_jsonschema.py,sha256=a9nSTj0reBc3QXUi1DJWuWJDoQuO6snxxqiGvk2zHcc,11029
37
+ amiril/control/_pathc.py,sha256=sTgHvwtWyoR0BLrrmr2-1pDGUlMFz5Hnb80aHCTs94g,2585
38
+ amiril/control/_records.py,sha256=UeELOYLDZvCGk-8VATRloYkMyXY-8ujSpcnmjdoojSU,11671
39
+ amiril/control/_redact.py,sha256=3kvZi29OPhJPKVTNggCBILrx3638-xvkmUGmTHzRQNc,3522
40
+ amiril/control/_transport.py,sha256=w-Y9vtpZPenDspZg27K6i2BQ3Cx8Suk4EREqjK1G53w,8156
41
+ amiril/control/_wire.py,sha256=1sP1TstWxrwJyjM0Mb-Z_viHifq4Q-tlecgg5X3DFLE,2544
42
+ amiril/control/client.py,sha256=d4-RSu4CxIbZg1hCkLOQ_PVsmtQ4kTJCsH__hK3HusM,60748
43
+ amiril/control/config.py,sha256=5QuAfv8EEytpcGSRsfv4OnCgnf7rG1E8FBZdkw6pui4,9360
44
+ amiril/control/schemas/bundle.response.schema.json,sha256=TO7jCnlDBWz0d1K7w29y3kMXQhKUU_oyM_KItmeUziw,619
45
+ amiril/control/schemas/common.schema.json,sha256=nHLxWMFParG1IUaWTCBFhp_EEZtdEXKe7_cnWgx-qqc,16615
46
+ amiril/control/schemas/decisions.request.schema.json,sha256=NdnTqJPeZLjA-VgwFDxj9aFc3IdOJuFG5rQjfk16384,15312
47
+ amiril/control/schemas/decisions.response.schema.json,sha256=I_I4mG5cEnSxkD5A3guVJ9bCwxtlQ6eJMfNKUw8GlDk,529
48
+ amiril/control/schemas/error.response.schema.json,sha256=Ps19-PwHK12LLEJcqwCij90FantEo8uebaYcZpLHeMQ,1367
49
+ amiril/control/schemas/heartbeat.request.schema.json,sha256=DCHjvagVBt_cKF8ydeIoK0xMzO4YsvosEeomcfJFe-g,7467
50
+ amiril/control/schemas/heartbeat.response.schema.json,sha256=N_PJMIhFACpatRq4c1oR9MBGG8AF62RzD-7NMvXCIz4,869
51
+ amiril/control/schemas/hold-create.request.schema.json,sha256=O2oVw2UdA1ZAoAro5be7AMGnaH5XsnGMK-2S5OMHb4o,3553
52
+ amiril/control/schemas/hold.response.schema.json,sha256=F1nQ2Ccj04jNmpyiiFbyC6Lezb66sIY6rqBxtdlO1WY,5626
53
+ amiril/control/schemas/installation-register.request.schema.json,sha256=7eUfR5pn39yGou5SJAm_1ezKOLmcyV6oEjN2zUiE4Mg,13298
54
+ amiril/control/schemas/installation-register.response.schema.json,sha256=TmC9mGmBjEmajRpm8vOhBMkAjax63xowHxlIqfAdE7g,1973
55
+ amiril/docs/README.md,sha256=9HyFjfPrLqHL9sdqN1hpMphl26OytshrJeiV-Dw1dc4,861
56
+ amiril/docs/durability/langgraph.md,sha256=XBFtJ0gi47Qx4z0FzPc_ntJe9n_4odpZF1TCt-4ZjJI,18048
57
+ amiril/docs/frameworks/adk.md,sha256=PqAcAdx-B1lNXXKrq8WxvPSqUfuFwZepQNDVkWNhIiI,6217
58
+ amiril/docs/frameworks/langgraph.md,sha256=DyRByp9U7AF2GegoOt_cHwapMZ9jhTg1OB_m31Wc_1I,6908
59
+ amiril/docs/frameworks/no-framework.md,sha256=vUcvNXb0PdtPq90azmkohzzS4hfgeIgoyeJZg0_s6rY,8496
60
+ amiril/docs/frameworks/write-an-adapter.md,sha256=QuULFLMXzQZphPl2szJvGTVGY0U2egVVC67-QQTD0G0,8138
61
+ amiril-0.0.0.dev0.dist-info/METADATA,sha256=bAcihYZ6uSntmLhlmBBaC0RdzhV--zobnv4HhjKzqb0,5761
62
+ amiril-0.0.0.dev0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
63
+ amiril-0.0.0.dev0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
64
+ amiril-0.0.0.dev0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any