authority-runtime 0.5.2__tar.gz → 0.6.0__tar.gz
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.
- {authority_runtime-0.5.2/src/authority_runtime.egg-info → authority_runtime-0.6.0}/PKG-INFO +28 -6
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/README.md +24 -2
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/pyproject.toml +14 -7
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/__init__.py +1 -1
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/approvals.py +64 -34
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/backends/slos.py +8 -2
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/cli.py +222 -1
- authority_runtime-0.6.0/src/authority_runtime/cli_models.py +122 -0
- authority_runtime-0.6.0/src/authority_runtime/cli_rules.py +58 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/compiler.py +30 -15
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/constraints.py +26 -2
- authority_runtime-0.6.0/src/authority_runtime/egress.py +334 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/enforce.py +146 -17
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/envelope.py +7 -1
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/langgraph.py +3 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/mcp_server.py +281 -70
- authority_runtime-0.6.0/src/authority_runtime/models/__init__.py +22 -0
- authority_runtime-0.6.0/src/authority_runtime/models/allowlist.py +83 -0
- authority_runtime-0.6.0/src/authority_runtime/models/audit.py +70 -0
- authority_runtime-0.6.0/src/authority_runtime/models/backtest.py +112 -0
- authority_runtime-0.6.0/src/authority_runtime/models/policy.py +157 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/policy.py +15 -1
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/router/registry.py +20 -17
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/router/router.py +12 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/rule_packs/__init__.py +17 -2
- authority_runtime-0.6.0/src/authority_runtime/rule_packs/builtin.py +182 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/rule_packs/pack.py +7 -3
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/storage.py +35 -7
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/supervisor/__init__.py +15 -1
- authority_runtime-0.6.0/src/authority_runtime/supervisor/render.py +204 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0/src/authority_runtime.egg-info}/PKG-INFO +28 -6
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime.egg-info/SOURCES.txt +20 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime.egg-info/requires.txt +2 -1
- authority_runtime-0.6.0/tests/test_approvals.py +96 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_archive.py +8 -3
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_cli.py +80 -0
- authority_runtime-0.6.0/tests/test_cli_gates.py +58 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_compiler.py +60 -163
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_constraints.py +39 -12
- authority_runtime-0.6.0/tests/test_egress.py +245 -0
- authority_runtime-0.6.0/tests/test_egress_wiring.py +121 -0
- authority_runtime-0.6.0/tests/test_fail_closed.py +84 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_hash_chain.py +52 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_integration.py +20 -8
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_mcp_server.py +204 -1
- authority_runtime-0.6.0/tests/test_model_backtest.py +83 -0
- authority_runtime-0.6.0/tests/test_model_policy.py +170 -0
- authority_runtime-0.6.0/tests/test_model_wiring.py +177 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_quickstart_example.py +0 -1
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_router.py +16 -11
- authority_runtime-0.6.0/tests/test_rule_packs_builtin.py +161 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_scope_matching.py +2 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_slos_backend.py +23 -0
- authority_runtime-0.6.0/tests/test_supervisor_render.py +358 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/LICENSE +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/setup.cfg +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/backends/__init__.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/backends/base.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/backends/memory.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/compliance.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/crypto.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/harness_audit/__init__.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/harness_audit/auditor.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/harness_audit/rules/__init__.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/harness_audit/rules/builtin.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/keys.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/logging_config.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/roles.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/router/__init__.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/router/classifier.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/router/usage_logger.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/rule_packs/decorators.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/rule_packs/registry.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/shell.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/skill_loader.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/supervisor/contract.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/supervisor/derive.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/supervisor/fleet.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/types.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/validation.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime/vault_scope.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime.egg-info/dependency_links.txt +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime.egg-info/entry_points.txt +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/src/authority_runtime.egg-info/top_level.txt +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_backends_protocol.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_compliance.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_compliance_report.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_envelope.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_fake_compiler.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_harness_audit.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_logging.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_mcp_auth.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_memory_backend.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_migrations.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_policy.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_roles.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_rule_packs.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_skill_loader.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_soul_loader.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_storage.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_supervisor.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_validation.py +0 -0
- {authority_runtime-0.5.2 → authority_runtime-0.6.0}/tests/test_vault_scope.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: authority-runtime
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.6.0
|
|
4
4
|
Summary: IAM + Context Control Plane for AI Agents — cryptographic policy enforcement with Ed25519 signed envelopes
|
|
5
5
|
Author-email: Authority Runtime <hello@authority-runtime.dev>
|
|
6
6
|
License: BSL-1.1
|
|
@@ -10,14 +10,13 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: License :: Other/Proprietary License
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.10
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
18
17
|
Classifier: Topic :: Security
|
|
19
18
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
-
Requires-Python: >=3.
|
|
19
|
+
Requires-Python: >=3.10
|
|
21
20
|
Description-Content-Type: text/markdown
|
|
22
21
|
License-File: LICENSE
|
|
23
22
|
Requires-Dist: pynacl>=1.5.0
|
|
@@ -44,7 +43,8 @@ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
|
44
43
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
45
44
|
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
46
45
|
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
47
|
-
Requires-Dist: ruff
|
|
46
|
+
Requires-Dist: ruff==0.15.10; extra == "dev"
|
|
47
|
+
Requires-Dist: types-PyYAML>=6.0.0; extra == "dev"
|
|
48
48
|
Dynamic: license-file
|
|
49
49
|
|
|
50
50
|
# Authority Runtime
|
|
@@ -52,7 +52,7 @@ Dynamic: license-file
|
|
|
52
52
|
**Cryptographic IAM for AI agents** -- scoped, signed, time-limited permissions with a tamper-evident audit trail.
|
|
53
53
|
|
|
54
54
|
[](LICENSE)
|
|
55
|
-
[](https://www.python.org/downloads/)
|
|
56
56
|
[]()
|
|
57
57
|
|
|
58
58
|
---
|
|
@@ -245,7 +245,7 @@ Audit Trail (SQLite, hash chain, compliance export)
|
|
|
245
245
|
|
|
246
246
|
## Test Suite
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
490 tests covering envelope operations, scope matching, constraint enforcement, policy engine, compliance reports, hash chain integrity, schema migrations, MCP auth, structured logging, and the five v0.5.0 port packages (`skill_loader`, `harness_audit`, `rule_packs`, `router`, `SkillSoul`).
|
|
249
249
|
|
|
250
250
|
```bash
|
|
251
251
|
pytest # Run all tests
|
|
@@ -254,6 +254,28 @@ pytest -v -x # Verbose, stop on first failure
|
|
|
254
254
|
|
|
255
255
|
---
|
|
256
256
|
|
|
257
|
+
## Local development
|
|
258
|
+
|
|
259
|
+
The repo ships a `Makefile` at the repo root that mirrors what CI runs — `make check` locally and a green CI on the same commit mean the same thing.
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
make install # Create authority-runtime-python/.venv and editable-install dev extras
|
|
263
|
+
make lint # ruff check (CI parity)
|
|
264
|
+
make typecheck # mypy src/ (CI parity)
|
|
265
|
+
make test # pytest (CI parity)
|
|
266
|
+
make check # lint + typecheck + test
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Pre-commit hooks catch the lint class of failure *before* CI does:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
make precommit-install # one-time: pip install pre-commit && pre-commit install
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
After that, `git commit` runs `ruff --fix` and `ruff-format` on staged files automatically.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
257
279
|
## License
|
|
258
280
|
|
|
259
281
|
Business Source License 1.1 - See [LICENSE](LICENSE). Converts to Apache 2.0 after 4 years.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
**Cryptographic IAM for AI agents** -- scoped, signed, time-limited permissions with a tamper-evident audit trail.
|
|
4
4
|
|
|
5
5
|
[](LICENSE)
|
|
6
|
-
[](https://www.python.org/downloads/)
|
|
7
7
|
[]()
|
|
8
8
|
|
|
9
9
|
---
|
|
@@ -196,7 +196,7 @@ Audit Trail (SQLite, hash chain, compliance export)
|
|
|
196
196
|
|
|
197
197
|
## Test Suite
|
|
198
198
|
|
|
199
|
-
|
|
199
|
+
490 tests covering envelope operations, scope matching, constraint enforcement, policy engine, compliance reports, hash chain integrity, schema migrations, MCP auth, structured logging, and the five v0.5.0 port packages (`skill_loader`, `harness_audit`, `rule_packs`, `router`, `SkillSoul`).
|
|
200
200
|
|
|
201
201
|
```bash
|
|
202
202
|
pytest # Run all tests
|
|
@@ -205,6 +205,28 @@ pytest -v -x # Verbose, stop on first failure
|
|
|
205
205
|
|
|
206
206
|
---
|
|
207
207
|
|
|
208
|
+
## Local development
|
|
209
|
+
|
|
210
|
+
The repo ships a `Makefile` at the repo root that mirrors what CI runs — `make check` locally and a green CI on the same commit mean the same thing.
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
make install # Create authority-runtime-python/.venv and editable-install dev extras
|
|
214
|
+
make lint # ruff check (CI parity)
|
|
215
|
+
make typecheck # mypy src/ (CI parity)
|
|
216
|
+
make test # pytest (CI parity)
|
|
217
|
+
make check # lint + typecheck + test
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Pre-commit hooks catch the lint class of failure *before* CI does:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
make precommit-install # one-time: pip install pre-commit && pre-commit install
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
After that, `git commit` runs `ruff --fix` and `ruff-format` on staged files automatically.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
208
230
|
## License
|
|
209
231
|
|
|
210
232
|
Business Source License 1.1 - See [LICENSE](LICENSE). Converts to Apache 2.0 after 4 years.
|
|
@@ -4,20 +4,19 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "authority-runtime"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.6.0"
|
|
8
8
|
description = "IAM + Context Control Plane for AI Agents — cryptographic policy enforcement with Ed25519 signed envelopes"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
11
11
|
{ name = "Authority Runtime", email = "hello@authority-runtime.dev" }
|
|
12
12
|
]
|
|
13
13
|
license = { text = "BSL-1.1" }
|
|
14
|
-
requires-python = ">=3.
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
15
|
classifiers = [
|
|
16
16
|
"Development Status :: 3 - Alpha",
|
|
17
17
|
"Intended Audience :: Developers",
|
|
18
18
|
"License :: Other/Proprietary License",
|
|
19
19
|
"Programming Language :: Python :: 3",
|
|
20
|
-
"Programming Language :: Python :: 3.9",
|
|
21
20
|
"Programming Language :: Python :: 3.10",
|
|
22
21
|
"Programming Language :: Python :: 3.11",
|
|
23
22
|
"Programming Language :: Python :: 3.12",
|
|
@@ -65,7 +64,10 @@ dev = [
|
|
|
65
64
|
"pytest-cov>=4.0.0",
|
|
66
65
|
"black>=23.0.0",
|
|
67
66
|
"mypy>=1.0.0",
|
|
68
|
-
|
|
67
|
+
# Pinned: CI and `make lint` must run the same rules. ruff 0.16 widened the
|
|
68
|
+
# default rule set, which turned a green main red without a code change.
|
|
69
|
+
"ruff==0.15.10",
|
|
70
|
+
"types-PyYAML>=6.0.0",
|
|
69
71
|
]
|
|
70
72
|
|
|
71
73
|
[project.urls]
|
|
@@ -77,11 +79,16 @@ where = ["src"]
|
|
|
77
79
|
|
|
78
80
|
[tool.black]
|
|
79
81
|
line-length = 100
|
|
80
|
-
target-version = ['
|
|
82
|
+
target-version = ['py310']
|
|
81
83
|
|
|
82
84
|
[tool.ruff]
|
|
83
85
|
line-length = 100
|
|
84
|
-
target-version = "
|
|
86
|
+
target-version = "py310"
|
|
87
|
+
|
|
88
|
+
[tool.ruff.lint]
|
|
89
|
+
# Explicit, so a ruff upgrade cannot silently widen what CI enforces. This is
|
|
90
|
+
# ruff's historical default (E4/E7/E9 + F) plus pycodestyle warnings.
|
|
91
|
+
select = ["E4", "E7", "E9", "F", "W"]
|
|
85
92
|
|
|
86
93
|
[tool.pytest.ini_options]
|
|
87
94
|
testpaths = ["tests"]
|
|
@@ -91,6 +98,6 @@ python_functions = "test_*"
|
|
|
91
98
|
addopts = "-v --tb=short"
|
|
92
99
|
|
|
93
100
|
[tool.mypy]
|
|
94
|
-
python_version = "3.
|
|
101
|
+
python_version = "3.10"
|
|
95
102
|
warn_return_any = true
|
|
96
103
|
warn_unused_configs = true
|
|
@@ -44,6 +44,7 @@ class ApprovalQueue:
|
|
|
44
44
|
target_domain: Optional[str] = None,
|
|
45
45
|
fields_needed: Optional[list[str]] = None,
|
|
46
46
|
ttl_seconds: int = 86400,
|
|
47
|
+
auto_deny_seconds: Optional[int] = None,
|
|
47
48
|
) -> str:
|
|
48
49
|
"""
|
|
49
50
|
Create a pending approval request.
|
|
@@ -56,6 +57,9 @@ class ApprovalQueue:
|
|
|
56
57
|
target_domain: Target vault domain
|
|
57
58
|
fields_needed: Specific fields requested (optional)
|
|
58
59
|
ttl_seconds: Time to live before auto-expiry (default 24h)
|
|
60
|
+
auto_deny_seconds: If set, transitions to "denied" after this many
|
|
61
|
+
seconds with no human decision. Must be < ttl_seconds.
|
|
62
|
+
Default None preserves legacy behaviour (TTL -> "expired").
|
|
59
63
|
|
|
60
64
|
Returns:
|
|
61
65
|
Request ID (UUIDv7-style)
|
|
@@ -80,6 +84,9 @@ class ApprovalQueue:
|
|
|
80
84
|
"status": "pending",
|
|
81
85
|
}
|
|
82
86
|
|
|
87
|
+
if auto_deny_seconds is not None and auto_deny_seconds < ttl_seconds:
|
|
88
|
+
record["auto_deny_at"] = (now + timedelta(seconds=auto_deny_seconds)).isoformat()
|
|
89
|
+
|
|
83
90
|
if fields_needed:
|
|
84
91
|
record["fields_needed"] = fields_needed
|
|
85
92
|
|
|
@@ -147,12 +154,39 @@ class ApprovalQueue:
|
|
|
147
154
|
logger.info(f"Approval request {request_id} {decision} by {decided_by}: {reason}")
|
|
148
155
|
return True
|
|
149
156
|
|
|
157
|
+
def _maybe_auto_transition(self, record: dict, path: Path) -> dict:
|
|
158
|
+
"""Auto-transition a pending record to "denied" or "expired" if due.
|
|
159
|
+
|
|
160
|
+
"denied" takes precedence over "expired" — auto_deny_at is always
|
|
161
|
+
earlier than expires_at when both are set, and a timeout-deny is a
|
|
162
|
+
stronger statement than a TTL expiry.
|
|
163
|
+
"""
|
|
164
|
+
if record.get("status") != "pending":
|
|
165
|
+
return record
|
|
166
|
+
now = datetime.now(timezone.utc)
|
|
167
|
+
auto_deny_at = record.get("auto_deny_at")
|
|
168
|
+
if auto_deny_at and now > datetime.fromisoformat(auto_deny_at):
|
|
169
|
+
record["status"] = "denied"
|
|
170
|
+
record["decided_at"] = now.isoformat()
|
|
171
|
+
record["decided_by"] = "auto-deny"
|
|
172
|
+
record["decision_reason"] = "auto-denied: no human decision before auto_deny_at"
|
|
173
|
+
with open(path, "w") as f:
|
|
174
|
+
yaml.dump(record, f, default_flow_style=False, sort_keys=False)
|
|
175
|
+
return record
|
|
176
|
+
expires_at = datetime.fromisoformat(record["expires_at"])
|
|
177
|
+
if now > expires_at:
|
|
178
|
+
record["status"] = "expired"
|
|
179
|
+
with open(path, "w") as f:
|
|
180
|
+
yaml.dump(record, f, default_flow_style=False, sort_keys=False)
|
|
181
|
+
return record
|
|
182
|
+
|
|
150
183
|
def check(self, request_id: str) -> Optional[dict]:
|
|
151
184
|
"""
|
|
152
185
|
Check the status of an approval request.
|
|
153
186
|
|
|
154
187
|
Returns:
|
|
155
|
-
Record dict if found, None otherwise. Auto-
|
|
188
|
+
Record dict if found, None otherwise. Auto-transitions stale
|
|
189
|
+
requests to "denied" (if auto_deny_at passed) or "expired".
|
|
156
190
|
"""
|
|
157
191
|
path = self._request_path(request_id)
|
|
158
192
|
if not path.exists():
|
|
@@ -161,21 +195,18 @@ class ApprovalQueue:
|
|
|
161
195
|
with open(path) as f:
|
|
162
196
|
record = yaml.safe_load(f)
|
|
163
197
|
|
|
164
|
-
|
|
165
|
-
if record.get("status") == "pending":
|
|
166
|
-
expires_at = datetime.fromisoformat(record["expires_at"])
|
|
167
|
-
if datetime.now(timezone.utc) > expires_at:
|
|
168
|
-
record["status"] = "expired"
|
|
169
|
-
with open(path, "w") as f:
|
|
170
|
-
yaml.dump(record, f, default_flow_style=False, sort_keys=False)
|
|
171
|
-
|
|
172
|
-
return record
|
|
198
|
+
return self._maybe_auto_transition(record, path)
|
|
173
199
|
|
|
174
200
|
def is_approved(self, request_id: str) -> bool:
|
|
175
201
|
"""Check if a specific request has been approved."""
|
|
176
202
|
record = self.check(request_id)
|
|
177
203
|
return record is not None and record.get("status") == "approved"
|
|
178
204
|
|
|
205
|
+
def is_denied(self, request_id: str) -> bool:
|
|
206
|
+
"""Check if a specific request has been denied (by human or auto-deny)."""
|
|
207
|
+
record = self.check(request_id)
|
|
208
|
+
return record is not None and record.get("status") == "denied"
|
|
209
|
+
|
|
179
210
|
def find_approved(
|
|
180
211
|
self,
|
|
181
212
|
agent_id: str,
|
|
@@ -210,22 +241,15 @@ class ApprovalQueue:
|
|
|
210
241
|
return None
|
|
211
242
|
|
|
212
243
|
def list_pending(self) -> list[dict]:
|
|
213
|
-
"""List all pending (non-expired) approval requests."""
|
|
244
|
+
"""List all pending (non-expired, non-auto-denied) approval requests."""
|
|
214
245
|
pending = []
|
|
215
|
-
now = datetime.now(timezone.utc)
|
|
216
246
|
for path in sorted(self.approvals_dir.glob("*.yaml")):
|
|
217
247
|
try:
|
|
218
248
|
with open(path) as f:
|
|
219
249
|
record = yaml.safe_load(f)
|
|
250
|
+
record = self._maybe_auto_transition(record, path)
|
|
220
251
|
if record.get("status") == "pending":
|
|
221
|
-
|
|
222
|
-
if now <= expires_at:
|
|
223
|
-
pending.append(record)
|
|
224
|
-
else:
|
|
225
|
-
# Auto-expire
|
|
226
|
-
record["status"] = "expired"
|
|
227
|
-
with open(path, "w") as f:
|
|
228
|
-
yaml.dump(record, f, default_flow_style=False, sort_keys=False)
|
|
252
|
+
pending.append(record)
|
|
229
253
|
except Exception:
|
|
230
254
|
continue
|
|
231
255
|
return pending
|
|
@@ -245,23 +269,29 @@ class ApprovalQueue:
|
|
|
245
269
|
continue
|
|
246
270
|
return history
|
|
247
271
|
|
|
248
|
-
def expire_stale(self) -> int:
|
|
249
|
-
"""
|
|
250
|
-
|
|
251
|
-
|
|
272
|
+
def expire_stale(self) -> dict[str, int]:
|
|
273
|
+
"""Run auto-transitions across all pending requests.
|
|
274
|
+
|
|
275
|
+
Returns a count of newly-transitioned records keyed by terminal
|
|
276
|
+
status: ``{"denied": N, "expired": M}``.
|
|
277
|
+
"""
|
|
278
|
+
counts = {"denied": 0, "expired": 0}
|
|
252
279
|
for path in self.approvals_dir.glob("*.yaml"):
|
|
253
280
|
try:
|
|
254
281
|
with open(path) as f:
|
|
255
282
|
record = yaml.safe_load(f)
|
|
256
|
-
if record.get("status")
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
count += 1
|
|
283
|
+
if record.get("status") != "pending":
|
|
284
|
+
continue
|
|
285
|
+
transitioned = self._maybe_auto_transition(record, path)
|
|
286
|
+
new_status = transitioned.get("status")
|
|
287
|
+
if new_status in counts:
|
|
288
|
+
counts[new_status] += 1
|
|
263
289
|
except Exception:
|
|
264
290
|
continue
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
291
|
+
total = counts["denied"] + counts["expired"]
|
|
292
|
+
if total:
|
|
293
|
+
logger.info(
|
|
294
|
+
f"Auto-transitioned {total} stale approval requests "
|
|
295
|
+
f"(denied={counts['denied']}, expired={counts['expired']})"
|
|
296
|
+
)
|
|
297
|
+
return counts
|
|
@@ -144,9 +144,15 @@ class SlosBackend:
|
|
|
144
144
|
signing_key = self.key_store.load_signing_key(agent_id)
|
|
145
145
|
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
|
|
146
146
|
|
|
147
|
-
# Create canonical JSON of arguments (without _auth)
|
|
147
|
+
# Create canonical JSON of arguments (without _auth).
|
|
148
|
+
# ensure_ascii=False is load-bearing: the Rust runtime re-canonicalizes
|
|
149
|
+
# as raw UTF-8, so signing over \uXXXX-escaped JSON fails verification
|
|
150
|
+
# for ANY non-ASCII content (em-dash in an LLM brief was enough). This
|
|
151
|
+
# silently broke every signed write of LLM-generated prose for a month
|
|
152
|
+
# while ASCII test content passed (bjornswarm sl-t94n, 2026-07-16).
|
|
148
153
|
args_without_auth = {k: v for k, v in arguments.items() if k != "_auth"}
|
|
149
|
-
args_json = json.dumps(args_without_auth, sort_keys=True,
|
|
154
|
+
args_json = json.dumps(args_without_auth, sort_keys=True,
|
|
155
|
+
separators=(",", ":"), ensure_ascii=False)
|
|
150
156
|
|
|
151
157
|
# Sign: agent_id || timestamp || json
|
|
152
158
|
message = f"{agent_id}{timestamp}{args_json}".encode()
|
|
@@ -18,6 +18,8 @@ Commands:
|
|
|
18
18
|
carryall audit Query audit log
|
|
19
19
|
carryall audit --verify Verify audit log integrity
|
|
20
20
|
carryall mcp serve Start MCP server for Clawdbot integration
|
|
21
|
+
carryall models list|check|backtest Model allowlist inspection and replay
|
|
22
|
+
carryall rules list|check Hard-rule pack (destructive commands, credential paths)
|
|
21
23
|
"""
|
|
22
24
|
|
|
23
25
|
import json
|
|
@@ -37,6 +39,8 @@ from .compliance import ComplianceReport
|
|
|
37
39
|
from .policy import PolicyEngine, PolicyValidationError
|
|
38
40
|
from .types import AuthorityEnvelope
|
|
39
41
|
from .backends.slos import SlosBackend, Decision
|
|
42
|
+
from .cli_models import models_app
|
|
43
|
+
from .cli_rules import rules_app
|
|
40
44
|
|
|
41
45
|
# Initialize Typer app
|
|
42
46
|
app = typer.Typer(
|
|
@@ -65,6 +69,8 @@ app.add_typer(compliance_app, name="compliance")
|
|
|
65
69
|
app.add_typer(policy_app, name="policy")
|
|
66
70
|
app.add_typer(mcp_app, name="mcp")
|
|
67
71
|
app.add_typer(db_app, name="db")
|
|
72
|
+
app.add_typer(models_app, name="models")
|
|
73
|
+
app.add_typer(rules_app, name="rules")
|
|
68
74
|
|
|
69
75
|
|
|
70
76
|
def get_keys_dir() -> str:
|
|
@@ -157,6 +163,19 @@ def shell(
|
|
|
157
163
|
shell_instance.run()
|
|
158
164
|
|
|
159
165
|
|
|
166
|
+
# Dry-run verdict exit codes. 2 stays reserved for usage errors across the CLI.
|
|
167
|
+
EXIT_ALLOW = 0
|
|
168
|
+
EXIT_DENY = 1
|
|
169
|
+
EXIT_REQUIRE_APPROVAL = 3
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def _verdict_exit(decision: Decision) -> None:
|
|
173
|
+
"""Exit with the decision so a caller can gate on it instead of parsing output."""
|
|
174
|
+
if decision == Decision.ALLOW:
|
|
175
|
+
raise typer.Exit(EXIT_ALLOW)
|
|
176
|
+
raise typer.Exit(EXIT_DENY if decision == Decision.DENY else EXIT_REQUIRE_APPROVAL)
|
|
177
|
+
|
|
178
|
+
|
|
160
179
|
@app.command()
|
|
161
180
|
def test(
|
|
162
181
|
credential: str = typer.Option(..., "--credential", "-c", help="Path to credential/envelope JSON"),
|
|
@@ -164,7 +183,10 @@ def test(
|
|
|
164
183
|
resource: str = typer.Option(..., "--resource", "-r", help="Resource URI (e.g., slos://vaults/finance/doc-id)"),
|
|
165
184
|
mock: bool = typer.Option(False, "--mock", help="Use mock backend (no real SLOS)"),
|
|
166
185
|
):
|
|
167
|
-
"""Dry-run policy evaluation for a credential and resource.
|
|
186
|
+
"""Dry-run policy evaluation for a credential and resource.
|
|
187
|
+
|
|
188
|
+
Exit code carries the verdict: 0 allow, 1 deny, 3 require_approval.
|
|
189
|
+
"""
|
|
168
190
|
# Load credential
|
|
169
191
|
cred_path = Path(credential).expanduser()
|
|
170
192
|
if not cred_path.exists():
|
|
@@ -196,12 +218,211 @@ def test(
|
|
|
196
218
|
for key, value in result.metadata.items():
|
|
197
219
|
console.print(f" {key}: {value}")
|
|
198
220
|
|
|
221
|
+
_verdict_exit(result.decision)
|
|
222
|
+
|
|
199
223
|
else:
|
|
200
224
|
console.print(f"[red]Error:[/red] Unknown resource URI scheme: {resource}")
|
|
201
225
|
console.print("Supported: slos://")
|
|
202
226
|
raise typer.Exit(1)
|
|
203
227
|
|
|
204
228
|
|
|
229
|
+
# =============================================================================
|
|
230
|
+
# Health check + policy dry-run
|
|
231
|
+
# =============================================================================
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
def _check_keys_dir() -> tuple[str, str]:
|
|
235
|
+
"""Returns ("PASS"|"WARN"|"FAIL", detail). Key files must be 0o600."""
|
|
236
|
+
keys_dir = Path(get_keys_dir()).expanduser()
|
|
237
|
+
if not keys_dir.exists():
|
|
238
|
+
return "FAIL", f"{keys_dir} does not exist (run `carryall init`)"
|
|
239
|
+
key_files = list(keys_dir.glob("*.key"))
|
|
240
|
+
if not key_files:
|
|
241
|
+
return "WARN", f"{keys_dir} present but contains no .key files"
|
|
242
|
+
bad_perms: list[str] = []
|
|
243
|
+
for kf in key_files:
|
|
244
|
+
mode = kf.stat().st_mode & 0o777
|
|
245
|
+
if mode != 0o600:
|
|
246
|
+
bad_perms.append(f"{kf.name} mode={oct(mode)}")
|
|
247
|
+
if bad_perms:
|
|
248
|
+
return "FAIL", f"{len(key_files)} keys, {len(bad_perms)} with wrong perms: {', '.join(bad_perms[:3])}"
|
|
249
|
+
return "PASS", f"{len(key_files)} agent keys, all 0o600"
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def _check_audit_chain() -> tuple[str, str]:
|
|
253
|
+
db_path = Path(get_db_path()).expanduser()
|
|
254
|
+
if not db_path.exists():
|
|
255
|
+
return "WARN", f"{db_path} does not exist (no audit yet)"
|
|
256
|
+
try:
|
|
257
|
+
store = EnvelopeStore(str(db_path))
|
|
258
|
+
result = store.verify_audit_chain()
|
|
259
|
+
except Exception as e:
|
|
260
|
+
return "FAIL", f"chain verify raised {type(e).__name__}: {e}"
|
|
261
|
+
if not result["valid"]:
|
|
262
|
+
return "FAIL", (
|
|
263
|
+
f"chain INVALID at entry #{result['first_invalid_id']}: {result.get('error')}"
|
|
264
|
+
)
|
|
265
|
+
stats = store.get_stats()
|
|
266
|
+
sig_fails = stats["audit_trail"]["signature_failures"]
|
|
267
|
+
detail = f"{result['entries_checked']} entries verified"
|
|
268
|
+
if sig_fails:
|
|
269
|
+
return "FAIL", f"{detail}, but {sig_fails} signature failure(s)"
|
|
270
|
+
if result.get("gaps"):
|
|
271
|
+
return "WARN", f"{detail}, {len(result['gaps'])} gap(s) (possible deletions)"
|
|
272
|
+
return "PASS", detail
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def _check_approvals_dir() -> tuple[str, str]:
|
|
276
|
+
raw = os.environ.get("CARRYALL_APPROVALS_DIR", "~/slos/vaults/meta/approvals")
|
|
277
|
+
approvals = Path(raw).expanduser()
|
|
278
|
+
if not approvals.exists():
|
|
279
|
+
return "WARN", f"{approvals} does not exist (will be created on first request)"
|
|
280
|
+
if not os.access(approvals, os.W_OK):
|
|
281
|
+
return "FAIL", f"{approvals} is not writable"
|
|
282
|
+
pending = len(list(approvals.glob("*.yaml")))
|
|
283
|
+
return "PASS", f"{approvals} writable, {pending} record(s)"
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def _check_backend_config() -> tuple[str, str]:
|
|
287
|
+
cfg = os.environ.get("CARRYALL_SLOS_CONFIG")
|
|
288
|
+
if not cfg:
|
|
289
|
+
return "WARN", "CARRYALL_SLOS_CONFIG not set (will fall back to MemoryBackend)"
|
|
290
|
+
cfg_path = Path(cfg).expanduser()
|
|
291
|
+
if not cfg_path.exists():
|
|
292
|
+
return "FAIL", f"CARRYALL_SLOS_CONFIG points to missing file: {cfg_path}"
|
|
293
|
+
return "PASS", str(cfg_path)
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def _check_recent_activity() -> tuple[str, str]:
|
|
297
|
+
db_path = Path(get_db_path()).expanduser()
|
|
298
|
+
if not db_path.exists():
|
|
299
|
+
return "WARN", "no audit DB; nothing to count"
|
|
300
|
+
try:
|
|
301
|
+
store = EnvelopeStore(str(db_path))
|
|
302
|
+
stats = store.get_stats()
|
|
303
|
+
except Exception as e:
|
|
304
|
+
return "WARN", f"stats unavailable: {e}"
|
|
305
|
+
audit = stats["audit_trail"]
|
|
306
|
+
return "PASS", (
|
|
307
|
+
f"{audit['total_actions']} entries "
|
|
308
|
+
f"({audit['successful']} ok, {audit['blocked']} blocked)"
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
@app.command()
|
|
313
|
+
def doctor():
|
|
314
|
+
"""Run a health check across keys, audit chain, approvals, and backend config.
|
|
315
|
+
|
|
316
|
+
Exits 1 if any check FAILs. WARN does not fail the run.
|
|
317
|
+
"""
|
|
318
|
+
checks = [
|
|
319
|
+
("Agent keys (dir + 0o600 perms)", _check_keys_dir),
|
|
320
|
+
("Audit hash chain", _check_audit_chain),
|
|
321
|
+
("Approvals dir", _check_approvals_dir),
|
|
322
|
+
("Backend config (CARRYALL_SLOS_CONFIG)", _check_backend_config),
|
|
323
|
+
("Audit activity", _check_recent_activity),
|
|
324
|
+
]
|
|
325
|
+
|
|
326
|
+
table = Table(title="carryall doctor")
|
|
327
|
+
table.add_column("Check")
|
|
328
|
+
table.add_column("Status")
|
|
329
|
+
table.add_column("Detail", style="dim")
|
|
330
|
+
|
|
331
|
+
any_fail = False
|
|
332
|
+
for label, fn in checks:
|
|
333
|
+
try:
|
|
334
|
+
status, detail = fn()
|
|
335
|
+
except Exception as e: # noqa: BLE001 — doctor must not raise
|
|
336
|
+
status, detail = "FAIL", f"check raised {type(e).__name__}: {e}"
|
|
337
|
+
if status == "PASS":
|
|
338
|
+
style = "green"
|
|
339
|
+
elif status == "WARN":
|
|
340
|
+
style = "yellow"
|
|
341
|
+
else:
|
|
342
|
+
style = "red"
|
|
343
|
+
any_fail = True
|
|
344
|
+
table.add_row(label, f"[{style}]{status}[/{style}]", detail)
|
|
345
|
+
|
|
346
|
+
console.print(table)
|
|
347
|
+
if any_fail:
|
|
348
|
+
raise typer.Exit(1)
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
_TIER_LABELS = [
|
|
352
|
+
("denied_agents", "1. Explicit deny (document)"),
|
|
353
|
+
("requires_approval", "2. Requires approval (document)"),
|
|
354
|
+
("allowed_agents", "3. Explicit allow (document)"),
|
|
355
|
+
("envelope_scope", "4. Envelope scope match"),
|
|
356
|
+
]
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
@app.command()
|
|
360
|
+
def explain(
|
|
361
|
+
credential: str = typer.Option(..., "--credential", "-c", help="Path to envelope JSON"),
|
|
362
|
+
action: str = typer.Option(..., "--action", "-a", help="Action (read, write, delete)"),
|
|
363
|
+
resource: str = typer.Option(..., "--resource", "-r", help="Resource URI"),
|
|
364
|
+
mock: bool = typer.Option(False, "--mock", help="Use mock backend"),
|
|
365
|
+
):
|
|
366
|
+
"""Dry-run policy evaluation and show which precedence tier fired.
|
|
367
|
+
|
|
368
|
+
Like ``carryall test`` but renders the 5-tier OPA precedence ladder
|
|
369
|
+
(deny > approval > allow > scope > default-deny) and surfaces the
|
|
370
|
+
structured deny payload (reason_class, suggested_scope, retry_hint)
|
|
371
|
+
that the MCP server returns to agents.
|
|
372
|
+
|
|
373
|
+
Exit code carries the verdict: 0 allow, 1 deny, 3 require_approval.
|
|
374
|
+
"""
|
|
375
|
+
if not resource.startswith("slos://"):
|
|
376
|
+
console.print(f"[red]Error:[/red] Unknown resource URI scheme: {resource}")
|
|
377
|
+
raise typer.Exit(1)
|
|
378
|
+
|
|
379
|
+
cred_path = Path(credential).expanduser()
|
|
380
|
+
if not cred_path.exists():
|
|
381
|
+
console.print(f"[red]Error:[/red] Credential file not found: {credential}")
|
|
382
|
+
raise typer.Exit(1)
|
|
383
|
+
|
|
384
|
+
with open(cred_path) as f:
|
|
385
|
+
envelope_data = json.load(f)
|
|
386
|
+
envelope = AuthorityEnvelope(**envelope_data)
|
|
387
|
+
|
|
388
|
+
key_store = AgentKeyStore(get_keys_dir())
|
|
389
|
+
backend = SlosBackend(key_store=key_store)
|
|
390
|
+
result = backend.check_access(envelope, action, resource, mock=mock)
|
|
391
|
+
rule = result.metadata.get("rule")
|
|
392
|
+
|
|
393
|
+
table = Table(title=f"Precedence ladder for {action} {resource}")
|
|
394
|
+
table.add_column("Tier")
|
|
395
|
+
table.add_column("Fired", justify="center")
|
|
396
|
+
for tier_rule, label in _TIER_LABELS:
|
|
397
|
+
marker = "[bold green]✓[/bold green]" if rule == tier_rule else ""
|
|
398
|
+
table.add_row(label, marker)
|
|
399
|
+
final_tier = "5. Default deny" if rule is None and result.decision == Decision.DENY else "—"
|
|
400
|
+
table.add_row(final_tier, "[bold green]✓[/bold green]" if rule is None and result.decision == Decision.DENY else "")
|
|
401
|
+
console.print(table)
|
|
402
|
+
|
|
403
|
+
if result.decision == Decision.ALLOW:
|
|
404
|
+
console.print(f"\n[green]✓ ALLOW[/green]: {result.reason}")
|
|
405
|
+
elif result.decision == Decision.REQUIRE_APPROVAL:
|
|
406
|
+
console.print(f"\n[yellow]⚠ REQUIRE_APPROVAL[/yellow]: {result.reason}")
|
|
407
|
+
else:
|
|
408
|
+
from .enforce import classify_denial
|
|
409
|
+
classified = classify_denial(result.reason, result.metadata)
|
|
410
|
+
console.print(f"\n[red]✗ DENY[/red]: {result.reason}")
|
|
411
|
+
if classified["reason_class"]:
|
|
412
|
+
console.print(f" reason_class: {classified['reason_class']}")
|
|
413
|
+
if classified["suggested_scope"]:
|
|
414
|
+
console.print(f" suggested_scope: {classified['suggested_scope']}")
|
|
415
|
+
if classified["retry_hint"]:
|
|
416
|
+
console.print(f" retry_hint: {classified['retry_hint']}")
|
|
417
|
+
|
|
418
|
+
if result.metadata:
|
|
419
|
+
console.print("\n[dim]Backend metadata:[/dim]")
|
|
420
|
+
for key, value in result.metadata.items():
|
|
421
|
+
console.print(f" {key}: {value}")
|
|
422
|
+
|
|
423
|
+
_verdict_exit(result.decision)
|
|
424
|
+
|
|
425
|
+
|
|
205
426
|
# =============================================================================
|
|
206
427
|
# Keys commands
|
|
207
428
|
# =============================================================================
|