interbolt 0.1.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.
- interbolt-0.1.0/.github/workflows/ci.yml +86 -0
- interbolt-0.1.0/.github/workflows/release.yml +100 -0
- interbolt-0.1.0/.gitignore +41 -0
- interbolt-0.1.0/.pre-commit-config.yaml +23 -0
- interbolt-0.1.0/.python-version +1 -0
- interbolt-0.1.0/CHANGELOG.md +5 -0
- interbolt-0.1.0/CLAUDE.md +77 -0
- interbolt-0.1.0/LICENSE +201 -0
- interbolt-0.1.0/PKG-INFO +104 -0
- interbolt-0.1.0/README.md +73 -0
- interbolt-0.1.0/cliff.toml +95 -0
- interbolt-0.1.0/policy.example.yaml +54 -0
- interbolt-0.1.0/pyproject.toml +100 -0
- interbolt-0.1.0/src/interbolt/__init__.py +55 -0
- interbolt-0.1.0/src/interbolt/cli/__init__.py +43 -0
- interbolt-0.1.0/src/interbolt/constants.py +51 -0
- interbolt-0.1.0/src/interbolt/enforcement/__init__.py +302 -0
- interbolt-0.1.0/src/interbolt/errors.py +70 -0
- interbolt-0.1.0/src/interbolt/models/__init__.py +1 -0
- interbolt-0.1.0/src/interbolt/models/core.py +162 -0
- interbolt-0.1.0/src/interbolt/models/protocols.py +56 -0
- interbolt-0.1.0/src/interbolt/policy/__init__.py +61 -0
- interbolt-0.1.0/src/interbolt/policy/engine.py +205 -0
- interbolt-0.1.0/src/interbolt/policy/schema.json +131 -0
- interbolt-0.1.0/src/interbolt/policy/schema.py +172 -0
- interbolt-0.1.0/src/interbolt/reporting/__init__.py +57 -0
- interbolt-0.1.0/src/interbolt/runtime/__init__.py +259 -0
- interbolt-0.1.0/src/interbolt/runtime/guard.py +176 -0
- interbolt-0.1.0/src/interbolt/taint/__init__.py +355 -0
- interbolt-0.1.0/src/interbolt/utils/__init__.py +43 -0
- interbolt-0.1.0/tests/conftest.py +33 -0
- interbolt-0.1.0/tests/integration/test_agent_loop.py +224 -0
- interbolt-0.1.0/tests/policies/agent_loop.yaml +38 -0
- interbolt-0.1.0/uv.lock +887 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
concurrency:
|
|
9
|
+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
10
|
+
cancel-in-progress: true
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
lint:
|
|
14
|
+
name: Lint & Format (Ruff)
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout
|
|
19
|
+
uses: actions/checkout@v6
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v7
|
|
23
|
+
with:
|
|
24
|
+
enable-cache: true
|
|
25
|
+
|
|
26
|
+
- name: Install Python 3.12
|
|
27
|
+
run: uv python install 3.12
|
|
28
|
+
|
|
29
|
+
- name: Install Lint Deps
|
|
30
|
+
run: uv sync --only-group dev
|
|
31
|
+
|
|
32
|
+
- name: Check Format
|
|
33
|
+
run: uv run ruff format --check .
|
|
34
|
+
|
|
35
|
+
- name: Lint
|
|
36
|
+
run: uv run ruff check .
|
|
37
|
+
|
|
38
|
+
validation:
|
|
39
|
+
name: Types & Tests
|
|
40
|
+
needs: lint
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
|
|
43
|
+
strategy:
|
|
44
|
+
matrix:
|
|
45
|
+
python-version: ["3.12", "3.13", "3.14"]
|
|
46
|
+
|
|
47
|
+
steps:
|
|
48
|
+
- name: Checkout
|
|
49
|
+
uses: actions/checkout@v6
|
|
50
|
+
|
|
51
|
+
- name: Install uv
|
|
52
|
+
uses: astral-sh/setup-uv@v7
|
|
53
|
+
with:
|
|
54
|
+
enable-cache: true
|
|
55
|
+
|
|
56
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
57
|
+
uses: actions/setup-python@v6
|
|
58
|
+
with:
|
|
59
|
+
python-version: ${{ matrix.python-version }}
|
|
60
|
+
|
|
61
|
+
- name: Install All Dependencies
|
|
62
|
+
run: uv sync --all-extras
|
|
63
|
+
|
|
64
|
+
- name: Type Check (Mypy)
|
|
65
|
+
run: uv run mypy .
|
|
66
|
+
|
|
67
|
+
# TODO: Add in when adding unit tests
|
|
68
|
+
# - name: Run Unit Tests
|
|
69
|
+
# run: uv run pytest tests/unit/ --cov=interbolt --cov-report=xml
|
|
70
|
+
|
|
71
|
+
- name: Run Integration Tests
|
|
72
|
+
run: uv run pytest tests/integration/ -v --no-cov
|
|
73
|
+
|
|
74
|
+
summary:
|
|
75
|
+
name: CI Summary
|
|
76
|
+
runs-on: ubuntu-latest
|
|
77
|
+
needs: [lint, validation]
|
|
78
|
+
if: always()
|
|
79
|
+
steps:
|
|
80
|
+
- name: Verify all jobs passed
|
|
81
|
+
run: |
|
|
82
|
+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
|
|
83
|
+
echo "One or more jobs failed."
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
echo "All jobs passed."
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
inputs:
|
|
6
|
+
version:
|
|
7
|
+
description: 'Version to release (e.g. 0.1.0)'
|
|
8
|
+
required: true
|
|
9
|
+
type: string
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write # Needed to push the tag back to the repo
|
|
13
|
+
id-token: write # Needed for trusted publishing
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
validate-and-release:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
if: github.ref == 'refs/heads/main' # Only runs on main branch
|
|
19
|
+
environment:
|
|
20
|
+
name: pypi
|
|
21
|
+
url: https://pypi.org/p/interbolt
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v6
|
|
25
|
+
with:
|
|
26
|
+
fetch-depth: 0 # Fetch all history to see previous tags
|
|
27
|
+
|
|
28
|
+
- name: Install uv
|
|
29
|
+
uses: astral-sh/setup-uv@v7
|
|
30
|
+
|
|
31
|
+
- name: Validate Version Input
|
|
32
|
+
run: |
|
|
33
|
+
NEW_VERSION="${{ inputs.version }}"
|
|
34
|
+
|
|
35
|
+
# Get the latest tag (e.g. v0.0.9), default to v0.0.0 if none
|
|
36
|
+
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
|
37
|
+
LAST_VER=${LAST_TAG#v} # Remove 'v' prefix
|
|
38
|
+
|
|
39
|
+
echo "Previous Version: $LAST_VER"
|
|
40
|
+
echo "Target Version: $NEW_VERSION"
|
|
41
|
+
|
|
42
|
+
# Simple Python script to compare versions
|
|
43
|
+
python3 -c "
|
|
44
|
+
from packaging.version import parse
|
|
45
|
+
import sys
|
|
46
|
+
|
|
47
|
+
old = parse('$LAST_VER')
|
|
48
|
+
new = parse('$NEW_VERSION')
|
|
49
|
+
|
|
50
|
+
if new <= old:
|
|
51
|
+
print(f'ERROR: New version {new} must be greater than {old}')
|
|
52
|
+
sys.exit(1)
|
|
53
|
+
"
|
|
54
|
+
|
|
55
|
+
- name: Verify __init__.py matches
|
|
56
|
+
run: |
|
|
57
|
+
FILE_VERSION=$(grep -E '^__version__\s*=' src/interbolt/__init__.py | head -n1 | cut -d'"' -f2)
|
|
58
|
+
if [ "$FILE_VERSION" != "${{ inputs.version }}" ]; then
|
|
59
|
+
echo "ERROR: src/interbolt/__init__.py says $FILE_VERSION but you requested ${{ inputs.version }}"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
- name: Verify CHANGELOG.md updated
|
|
64
|
+
run: |
|
|
65
|
+
# 1. Check if file exists
|
|
66
|
+
if [ ! -f CHANGELOG.md ]; then
|
|
67
|
+
echo "ERROR: CHANGELOG.md file not found in the root directory."
|
|
68
|
+
exit 1
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# 2. Check if the version string is present in the file
|
|
72
|
+
if ! grep -Fq "${{ inputs.version }}" CHANGELOG.md; then
|
|
73
|
+
echo "ERROR: CHANGELOG.md does not contain version ${{ inputs.version }}."
|
|
74
|
+
echo "Please run locally: uv run git-cliff --tag ${{ inputs.version }} --output CHANGELOG.md"
|
|
75
|
+
echo "Then commit and push the changes."
|
|
76
|
+
exit 1
|
|
77
|
+
fi
|
|
78
|
+
echo "SUCCESS: Found version ${{ inputs.version }} in CHANGELOG.md"
|
|
79
|
+
|
|
80
|
+
- name: Run Tests & Linters
|
|
81
|
+
run: |
|
|
82
|
+
uv sync --all-extras --dev
|
|
83
|
+
uv run ruff check .
|
|
84
|
+
uv run mypy .
|
|
85
|
+
uv run pytest
|
|
86
|
+
|
|
87
|
+
- name: Build Package
|
|
88
|
+
run: uv build
|
|
89
|
+
|
|
90
|
+
- name: Publish to PyPI
|
|
91
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
92
|
+
with:
|
|
93
|
+
verbose: true
|
|
94
|
+
|
|
95
|
+
- name: Create and Push Tag
|
|
96
|
+
run: |
|
|
97
|
+
git config user.name "GitHub Actions"
|
|
98
|
+
git config user.email "actions@github.com"
|
|
99
|
+
git tag -a "v${{ inputs.version }}" -m "Release v${{ inputs.version }}"
|
|
100
|
+
git push origin "v${{ inputs.version }}"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# --- Python ---
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Tools
|
|
7
|
+
.mypy_cache
|
|
8
|
+
.ruff_cache
|
|
9
|
+
|
|
10
|
+
# Distribution / Builds
|
|
11
|
+
build/
|
|
12
|
+
dist/
|
|
13
|
+
*.egg-info/
|
|
14
|
+
.eggs/
|
|
15
|
+
*.egg
|
|
16
|
+
|
|
17
|
+
# --- Virtual Environments ---
|
|
18
|
+
# uv creates .venv by default
|
|
19
|
+
.venv/
|
|
20
|
+
venv/
|
|
21
|
+
env/
|
|
22
|
+
ENV/
|
|
23
|
+
|
|
24
|
+
# --- macOS ---
|
|
25
|
+
.DS_Store
|
|
26
|
+
.AppleDouble
|
|
27
|
+
.LSOverride
|
|
28
|
+
|
|
29
|
+
# --- IDEs / Editors ---
|
|
30
|
+
.idea/
|
|
31
|
+
.vscode/
|
|
32
|
+
*.swp
|
|
33
|
+
|
|
34
|
+
# --- Testing / Coverage ---
|
|
35
|
+
.coverage
|
|
36
|
+
coverage.xml
|
|
37
|
+
htmlcov/
|
|
38
|
+
.pytest_cache/
|
|
39
|
+
|
|
40
|
+
# --- Application ---
|
|
41
|
+
dev/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
+
rev: v0.15.20
|
|
4
|
+
hooks:
|
|
5
|
+
- id: ruff
|
|
6
|
+
args: [--fix]
|
|
7
|
+
- id: ruff-format
|
|
8
|
+
|
|
9
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
10
|
+
rev: v1.14.1
|
|
11
|
+
hooks:
|
|
12
|
+
- id: mypy
|
|
13
|
+
additional_dependencies:
|
|
14
|
+
[
|
|
15
|
+
pydantic,
|
|
16
|
+
types-pyyaml,
|
|
17
|
+
cel-python,
|
|
18
|
+
platformdirs,
|
|
19
|
+
rich,
|
|
20
|
+
pytest,
|
|
21
|
+
pytest-asyncio,
|
|
22
|
+
pytest-mock,
|
|
23
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.12
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Claude Code Instructions
|
|
2
|
+
|
|
3
|
+
## Primary references
|
|
4
|
+
|
|
5
|
+
Before writing any code, read `dev/spec.md` in full. All implementation decisions
|
|
6
|
+
must be consistent with the module structure, dependency rules, naming conventions,
|
|
7
|
+
and component contracts defined there. Where this file and the spec overlap, the
|
|
8
|
+
spec governs; this file is the short enforcement checklist.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Non-negotiable rules
|
|
13
|
+
|
|
14
|
+
### Architecture
|
|
15
|
+
|
|
16
|
+
- The layered dependency direction must never be violated. See `dev/spec.md` §3. Imports point inward along the flow; nothing reaches outward.
|
|
17
|
+
- `models/` contains pure Pydantic models and Protocols only. It imports only stdlib, Pydantic, and the leaf modules (`errors`, `constants`). Nothing else.
|
|
18
|
+
- `errors.py`, `constants.py`, and everything in `utils/` import only Python stdlib (plus `platformdirs` in `utils`). No other internal imports. These are the leaves.
|
|
19
|
+
- `taint/` and `policy/` import only `models/` and the leaves. They never import each other, `enforcement/`, `reporting/`, `runtime/`, `integrations/`, or `cli/`.
|
|
20
|
+
- `enforcement/` imports `taint/`, `policy/`, and `models/`. It never imports `reporting/` (it emits through the `Reporter` protocol from `models/`), `runtime/`, `integrations/`, or `cli/`.
|
|
21
|
+
- `reporting/` imports only `models/` and the leaves. It never imports `enforcement/` or `runtime/`.
|
|
22
|
+
- `runtime/` is the composition root. It may import any flow layer. Nothing imports `runtime/` except the package `__init__`.
|
|
23
|
+
- `integrations/` and `cli/` are thin edges. They import only the public surface (the package `__init__`) and never reach into `taint/`, `policy/`, `enforcement/`, `reporting/`, or `runtime/` internals.
|
|
24
|
+
- `enforcement/` and `taint/` depend on the `Reporter` and `ApprovalResolver` protocols defined in `models/protocols.py`, never on concrete implementations. The concrete reporter and resolver are injected by `runtime/` at composition time.
|
|
25
|
+
- No circular imports anywhere. The structure makes them impossible when the rules above are followed; no import-linting tool is used.
|
|
26
|
+
- `from __future__ import annotations` at the top of every module. Cross-layer type-only references use `TYPE_CHECKING`-guarded imports, never runtime imports.
|
|
27
|
+
|
|
28
|
+
### Core invariants
|
|
29
|
+
|
|
30
|
+
- `taint()` records only the source name on the `Label`. Trust is never resolved at marking time; it is resolved at the sink during `check()` from the policy's `sources` table. Never store a resolved `TrustLevel` on a `Label`.
|
|
31
|
+
- `check()` is the single decision entrypoint. `guard` is sugar over `check()`. Never duplicate the decision sequence (context build, evaluate, assemble `Decision`, emit) anywhere else.
|
|
32
|
+
- Mode (`enforce`, `monitor`, `dry_run`) governs only behavior on evaluation error and whether blocks are real. A correct `block` or `require_approval` always acts, except under `dry_run` where it is downgraded to allow. Never let mode change a correct decision otherwise.
|
|
33
|
+
- Default posture is deny: an undeclared source is untrusted; a sink with no matching rule falls through to `defaults.sink_action`. Never default to allow.
|
|
34
|
+
- Policy evaluation is first-match-wins within a sink's ordered rule list. Never reorder rules at load or evaluate out of order.
|
|
35
|
+
- Policies and CEL expressions are compiled once at load, never per call. Never compile inside `check()`.
|
|
36
|
+
- Tool identity is always the structured `(namespace, tool)` pair internally; the dotted `namespace.tool` form is surface only. The default namespace is `default`. Reject qualified names where the namespace or tool contains a dot.
|
|
37
|
+
- Every `Decision` and `Event` carries the identity triple: `agent_id` (durable, integrator-supplied), `run_id` (minted per run by the runtime), `session_id` (optional, integrator-supplied). Never omit `agent_id` or `run_id`; never fabricate a durable `agent_id`.
|
|
38
|
+
- The `Event` schema is versioned via `constants.EVENT_SCHEMA_VERSION`. Never change the event shape without bumping the version.
|
|
39
|
+
|
|
40
|
+
### Taint propagation invariants
|
|
41
|
+
|
|
42
|
+
- Propagation is in-process only, following the `SafeString` model. When tainted and untainted values combine, the result is tainted. When two tainted values combine, labels merge (union of lineage, fresh `value_id`, tainted). Never let a combining operation produce an untainted result from a tainted input.
|
|
43
|
+
- Propagation does not survive serialization, storage round-trips, or the process boundary. Data re-entering the process is fresh untrusted ingress and must be re-`taint`ed. Never attempt to reconnect re-entered data to a prior label in v1.
|
|
44
|
+
- The propagation contract in `dev/spec.md` §6.3 is authoritative and is documented honestly, including its limits. Never weaken or overstate it in code, docstrings, or docs.
|
|
45
|
+
|
|
46
|
+
### Specific invariants
|
|
47
|
+
|
|
48
|
+
- All exceptions come from `errors.py`, under one base, `InterboltError`. Two branches: decision outcomes (`PolicyViolation`, `PolicyEvaluationError`, `ApprovalDenied`) and misuse (`InterboltConfigError(InterboltError, ValueError)`, `InterboltUsageError(InterboltError, RuntimeError)`). The misuse pair multiply-inherits the fitting builtin so `except InterboltError` and `except ValueError`/`except RuntimeError` both catch correctly. Never raise a generic `Exception`, a bare `ValueError`, or a bare `RuntimeError` anywhere in the library; a config mistake raises `InterboltConfigError`, a bad call sequence raises `InterboltUsageError`. Never add a sixth error class without removing the temptation to over-specialize.
|
|
49
|
+
- All constants live in `constants.py` (global) or the owning layer (layer-specific). Never hardcode a magic value at a call site.
|
|
50
|
+
- `configure()` has no import-time side effects. Importing a module that uses `@guard` must not require `configure()` to have run. Policy compilation happens in `configure()`, never at import.
|
|
51
|
+
- Reporter emission is fire-and-forget and non-blocking. A reporter failure must never affect, delay, or fail a decision. Never `await` or block on the reporter in the decision path.
|
|
52
|
+
- The core makes no network calls under any default configuration. The default reporter is `NullReporter`. Any transmission is a non-default reporter the integrator opts into. Never add a phone-home to the core path.
|
|
53
|
+
- All async methods are `async def`. The decision core is pure and synchronous; only the reporter and approval resolver are colored. `asyncio.run()` is never called inside the library. Never block the event loop.
|
|
54
|
+
- The library logger never configures the root logger and never emits at import. `DEBUG` is extensive; `INFO` is the verbose default. Never call logging configuration from library code.
|
|
55
|
+
- Google-style docstrings on all public functions, methods, and classes (the set re-exported from the package `__init__`). Internal docstrings are optional but recommended and kept short (one-line summary preferred).
|
|
56
|
+
- Type hints on every function and method signature including return types. No `Any` without an inline comment explaining why it is intentional.
|
|
57
|
+
- No agent framework imports in the core (LangChain, LangGraph, CrewAI, etc.). Framework glue lives only in `integrations/`, behind optional extras. Core is plain Python.
|
|
58
|
+
- Split a module into multiple files only when it exceeds 500 lines, or when a separate file is required to break a dependency cycle. Do not pre-split by sub-feature.
|
|
59
|
+
- Always ensure `uv run ruff check .`, `uv run ruff format --check .`, and `uv run mypy .` pass after making changes.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Testing
|
|
64
|
+
|
|
65
|
+
Use `pytest` with `pytest-asyncio` and `pytest-mock`. The colored edges
|
|
66
|
+
(`Reporter`, `ApprovalResolver`) are mocked with the `mocker` fixture or
|
|
67
|
+
`AsyncMock`; `InMemoryReporter` is the assertion surface for decisions. Do not
|
|
68
|
+
build a bespoke test harness. Do not implement tests unless explicitly instructed.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Style
|
|
73
|
+
|
|
74
|
+
- American English only, never British English.
|
|
75
|
+
- Never use the em dash or a double dash.
|
|
76
|
+
- No `print()` calls anywhere. CLI output goes through `rich.console.Console`. Log output goes through stdlib `logging` via the library logger.
|
|
77
|
+
- No inline comments that restate what the code does. Comments explain why, not what.
|
interbolt-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
interbolt-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: interbolt
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Provenance-gated tool calls for AI agents.
|
|
5
|
+
Project-URL: Homepage, https://deconvolutelabs.com
|
|
6
|
+
Project-URL: Issues, https://github.com/deconvolute-labs/interbolt/issues
|
|
7
|
+
Author-email: David Kirchhoff <david@deconvoluteai.com>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Information Technology
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Topic :: Internet
|
|
20
|
+
Classifier: Topic :: Security
|
|
21
|
+
Classifier: Topic :: Security :: Cryptography
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
24
|
+
Requires-Python: >=3.12
|
|
25
|
+
Requires-Dist: cel-python
|
|
26
|
+
Requires-Dist: platformdirs
|
|
27
|
+
Requires-Dist: pydantic
|
|
28
|
+
Requires-Dist: pyyaml
|
|
29
|
+
Requires-Dist: rich
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# Interbolt
|
|
33
|
+
|
|
34
|
+
**Provenance-gated tool calls for AI agents.**
|
|
35
|
+
|
|
36
|
+
[](https://pypi.org/project/interbolt/)
|
|
37
|
+
[](https://pypi.org/project/interbolt/)
|
|
38
|
+
[](LICENSE)
|
|
39
|
+
[](https://github.com/deconvolute-labs/interbolt/actions)
|
|
40
|
+
|
|
41
|
+
Mark untrusted data where it enters an agent. Interbolt propagates that mark through your code and evaluates a YAML+CEL policy at each guarded tool call, returning allow, block, or require-approval based on the provenance of the call's arguments. Decisions are deterministic and in-process: no model, no network calls.
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install interbolt
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from interbolt import configure, taint, Policy, PolicyViolation, Tainted
|
|
51
|
+
|
|
52
|
+
runtime = configure(policy=Policy.from_file("policy.yaml"))
|
|
53
|
+
agent = runtime.agent("support-agent")
|
|
54
|
+
|
|
55
|
+
@agent.guard
|
|
56
|
+
def send_email(to: str, body: str) -> None:
|
|
57
|
+
...
|
|
58
|
+
|
|
59
|
+
# web_search returns a plain str. taint() on a str returns a Tainted, which
|
|
60
|
+
# is a str subclass, so it is accepted anywhere a str is expected with no
|
|
61
|
+
# change to send_email's signature.
|
|
62
|
+
summary: Tainted = taint(web_search("..."), source="web_search")
|
|
63
|
+
|
|
64
|
+
# body: str accepts the Tainted str; the policy still sees the provenance label
|
|
65
|
+
# at the call boundary.
|
|
66
|
+
try:
|
|
67
|
+
send_email(to="attacker@external.com", body=summary)
|
|
68
|
+
except PolicyViolation as e:
|
|
69
|
+
print(e.decision.matched_rule) # "block_untrusted_exfil"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
A starter `policy.example.yaml` ships with the repo. Check policies in CI with `interbolt validate policy.yaml`.
|
|
73
|
+
|
|
74
|
+
## What propagates, and what does not
|
|
75
|
+
|
|
76
|
+
Provenance is a set of source names attached to a value. Trust is resolved at the sink by looking each source up in your policy, so the same file governs both ingress trust and egress gating.
|
|
77
|
+
|
|
78
|
+
The label survives **direct passing** of a value to a tool argument and **operator-style combination** (`+`, `%`, slicing, and string methods called on a tainted value). It does **not** survive the common string-assembly constructs: f-strings with surrounding text, `str.format`, and `" ".join(...)` on a plain separator all produce a fresh string with no label. For those, re-`taint` the result by hand, which is the documented escape hatch. The same applies across a model-mediated agent-to-agent handoff: one agent's generated output reaches the next as plain, unlabeled text, so re-`taint` it at the boundary.
|
|
79
|
+
|
|
80
|
+
This is a deliberate, honest limit of an in-process string-subclass carrier, stated in full in the [propagation contract](docs/concepts/taint-propagation.md). To find the places where a transformation laundered a label that should have been re-tainted, run the audit (below).
|
|
81
|
+
|
|
82
|
+
## Modes and the audit
|
|
83
|
+
|
|
84
|
+
`configure(mode=...)` sets enforcement behavior:
|
|
85
|
+
|
|
86
|
+
- `enforce` (default): fails closed. An evaluation error is treated as a block.
|
|
87
|
+
- `monitor`: fails open on evaluation error and logs it; real blocks still block. An adoption on-ramp.
|
|
88
|
+
- `dry_run`: computes and emits every decision but blocks nothing. Test a new policy against live traffic.
|
|
89
|
+
|
|
90
|
+
`configure(audit=True)` turns on the laundering audit, an in-process instrument orthogonal to the mode. It watches a real run and reports where untrusted content reached a sink without a label, which is how you catch a forgotten re-`taint`. It catches mechanical laundering (the bytes survive into the argument); it cannot catch a model summarizing or paraphrasing the untrusted text first. Findings come out through the reporter, so you assert on them in a test with `InMemoryReporter`.
|
|
91
|
+
|
|
92
|
+
`interbolt validate policy.yaml` is static analysis only: it checks the schema, compiles every CEL expression, and rejects ambiguous dotted names, dead rules, and references to trifecta legs this version cannot compute. It never runs your agent, so it fits CI and pre-commit.
|
|
93
|
+
|
|
94
|
+
## MCP
|
|
95
|
+
|
|
96
|
+
`interbolt[mcp]` provides `wrap_session`, which adapts an MCP client session: the namespace becomes the server name, tool outputs are tainted as untrusted by default, and calls route through the policy. No core dependency, no rewrite of your tool logic.
|
|
97
|
+
|
|
98
|
+
## Documentation
|
|
99
|
+
|
|
100
|
+
See [`docs/`](docs/index.md) for [policies](docs/concepts/policies.md), the [propagation contract](docs/concepts/taint-propagation.md), [identity and namespacing](docs/concepts/identity.md), [testing](docs/guides/testing.md), [auditing](docs/guides/auditing.md), and the [API reference](docs/reference/api.md).
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
Apache-2.0. Built by [Deconvolute Labs](https://deconvoluteai.com).
|