Metadata-Version: 2.4
Name: armoriq-policy-ir
Version: 0.1.5
Summary: Armor Policy v2 evaluator for Python, checked against the golden vectors of @armoriq/policy-ir
Author-email: ArmorIQ Team <license@armoriq.io>
License-Expression: MIT
Project-URL: Source Code, https://github.com/armoriq/armoriq-policy-ir
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"

# armoriq-policy-ir (Python)

The Armor Policy v2 evaluator for Python runtimes. CI runs it on every vector in `vectors/evaluate.json`, the same file the TypeScript `evaluate()` in `@armoriq/policy-ir` must pass.

```python
from armoriq_policy_ir import evaluate

evaluation = evaluate(
    {"tool": "create_payment", "arguments": {"amount": 900}, "timestamp": "2026-10-16T12:00:00.000Z"},
    {"agent": document},
)
evaluation["verdict"]  # "allow" | "hold" | "block"
```

Inputs and outputs are the same JSON shapes as the TypeScript package, with camelCase keys.

It follows JavaScript semantics where Python's defaults differ: numbers compare as IEEE doubles, strings are compared and matched as UTF-16 units, dotpaths read own keys only, and regex conditions are translated to JavaScript `RegExp` behaviour.

`evaluate` raises instead of guessing when an input is outside what both runtimes read alike:

- `NotPortable`: a regex outside the portable subset. The TypeScript validator rejects these patterns when a policy compiles.
- `UnsupportedTime`: a timestamp or expiry that isn't strict ISO-8601 (`YYYY-MM-DDTHH:mm:ss.sssZ`, with optional parts and a `±HH:mm` offset), or a local time outside years 1 to 9999.

A caller must treat any exception from `evaluate` as a block.
