weaver-kernel 0.3.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.
Files changed (61) hide show
  1. weaver_kernel-0.3.0/.claude/CLAUDE.md +56 -0
  2. weaver_kernel-0.3.0/.github/copilot-instructions.md +53 -0
  3. weaver_kernel-0.3.0/.github/workflows/ci.yml +47 -0
  4. weaver_kernel-0.3.0/.github/workflows/publish.yml +35 -0
  5. weaver_kernel-0.3.0/.gitignore +207 -0
  6. weaver_kernel-0.3.0/AGENTS.md +143 -0
  7. weaver_kernel-0.3.0/CHANGELOG.md +60 -0
  8. weaver_kernel-0.3.0/CONTRIBUTING.md +36 -0
  9. weaver_kernel-0.3.0/LICENSE +201 -0
  10. weaver_kernel-0.3.0/Makefile +20 -0
  11. weaver_kernel-0.3.0/PKG-INFO +378 -0
  12. weaver_kernel-0.3.0/README.md +142 -0
  13. weaver_kernel-0.3.0/RELEASE.md +88 -0
  14. weaver_kernel-0.3.0/docs/agent-context/architecture.md +50 -0
  15. weaver_kernel-0.3.0/docs/agent-context/invariants.md +76 -0
  16. weaver_kernel-0.3.0/docs/agent-context/lessons-learned.md +46 -0
  17. weaver_kernel-0.3.0/docs/agent-context/review-checklist.md +63 -0
  18. weaver_kernel-0.3.0/docs/agent-context/workflows.md +57 -0
  19. weaver_kernel-0.3.0/docs/architecture.md +70 -0
  20. weaver_kernel-0.3.0/docs/capabilities.md +49 -0
  21. weaver_kernel-0.3.0/docs/context_firewall.md +64 -0
  22. weaver_kernel-0.3.0/docs/integrations.md +70 -0
  23. weaver_kernel-0.3.0/docs/security.md +38 -0
  24. weaver_kernel-0.3.0/examples/basic_cli.py +144 -0
  25. weaver_kernel-0.3.0/examples/billing_demo.py +157 -0
  26. weaver_kernel-0.3.0/examples/http_driver_demo.py +137 -0
  27. weaver_kernel-0.3.0/pyproject.toml +63 -0
  28. weaver_kernel-0.3.0/src/agent_kernel/__init__.py +139 -0
  29. weaver_kernel-0.3.0/src/agent_kernel/drivers/__init__.py +7 -0
  30. weaver_kernel-0.3.0/src/agent_kernel/drivers/base.py +42 -0
  31. weaver_kernel-0.3.0/src/agent_kernel/drivers/http.py +125 -0
  32. weaver_kernel-0.3.0/src/agent_kernel/drivers/memory.py +171 -0
  33. weaver_kernel-0.3.0/src/agent_kernel/enums.py +32 -0
  34. weaver_kernel-0.3.0/src/agent_kernel/errors.py +67 -0
  35. weaver_kernel-0.3.0/src/agent_kernel/firewall/__init__.py +8 -0
  36. weaver_kernel-0.3.0/src/agent_kernel/firewall/budgets.py +26 -0
  37. weaver_kernel-0.3.0/src/agent_kernel/firewall/redaction.py +143 -0
  38. weaver_kernel-0.3.0/src/agent_kernel/firewall/summarize.py +115 -0
  39. weaver_kernel-0.3.0/src/agent_kernel/firewall/transform.py +251 -0
  40. weaver_kernel-0.3.0/src/agent_kernel/handles.py +219 -0
  41. weaver_kernel-0.3.0/src/agent_kernel/kernel.py +350 -0
  42. weaver_kernel-0.3.0/src/agent_kernel/models.py +230 -0
  43. weaver_kernel-0.3.0/src/agent_kernel/policy.py +213 -0
  44. weaver_kernel-0.3.0/src/agent_kernel/py.typed +0 -0
  45. weaver_kernel-0.3.0/src/agent_kernel/registry.py +124 -0
  46. weaver_kernel-0.3.0/src/agent_kernel/router.py +76 -0
  47. weaver_kernel-0.3.0/src/agent_kernel/tokens.py +349 -0
  48. weaver_kernel-0.3.0/src/agent_kernel/trace.py +46 -0
  49. weaver_kernel-0.3.0/tests/conftest.py +172 -0
  50. weaver_kernel-0.3.0/tests/test_drivers.py +185 -0
  51. weaver_kernel-0.3.0/tests/test_firewall.py +157 -0
  52. weaver_kernel-0.3.0/tests/test_handles.py +147 -0
  53. weaver_kernel-0.3.0/tests/test_kernel.py +217 -0
  54. weaver_kernel-0.3.0/tests/test_logging.py +468 -0
  55. weaver_kernel-0.3.0/tests/test_models.py +154 -0
  56. weaver_kernel-0.3.0/tests/test_policy.py +294 -0
  57. weaver_kernel-0.3.0/tests/test_redaction.py +344 -0
  58. weaver_kernel-0.3.0/tests/test_registry.py +112 -0
  59. weaver_kernel-0.3.0/tests/test_router.py +39 -0
  60. weaver_kernel-0.3.0/tests/test_tokens.py +174 -0
  61. weaver_kernel-0.3.0/tests/test_trace.py +58 -0
@@ -0,0 +1,56 @@
1
+ # Claude Instructions — agent-kernel
2
+
3
+ Read `AGENTS.md` before making any changes. It is the canonical source of truth
4
+ for all shared rules, conventions, and documentation pointers.
5
+
6
+ ## Explore before acting
7
+
8
+ - Read `AGENTS.md` and the relevant `docs/agent-context/` file for the topic
9
+ before proposing changes.
10
+ - Check existing code patterns in the target area. Do not infer repo-wide
11
+ conventions from a single file.
12
+ - When path-specific conventions exist (see Code conventions in `AGENTS.md`),
13
+ follow them exactly.
14
+
15
+ ## Implement safely
16
+
17
+ - Preserve invariants. Consult `docs/agent-context/invariants.md` before any
18
+ change that touches security, tokens, policy, or the firewall.
19
+ - Use only the conventions documented in `AGENTS.md`. Do not invent new ones.
20
+ - Use `make ci` as the single validation command. Do not guess alternatives.
21
+ - Do not "clean up" or "simplify" code unless the change was requested. Hidden
22
+ constraints may exist.
23
+
24
+ ## Validate before completing
25
+
26
+ - Run `make ci` and confirm it passes.
27
+ - If a public API, workflow, invariant, or convention changed, update the
28
+ relevant canonical doc in the same changeset.
29
+ - Verify that every changed docstring matches the final implementation.
30
+ - Check for dead code: unused parameters, fixtures, or helpers.
31
+
32
+ ## Handle contradictions
33
+
34
+ When docs contradict code or each other:
35
+ 1. Code is authoritative over docs.
36
+ 2. Canonical shared docs (`AGENTS.md`, `docs/agent-context/`) are authoritative
37
+ over tool-specific files.
38
+ 3. Surface the contradiction explicitly. Do not silently pick one side.
39
+ 4. Fix stale docs in the same changeset when possible.
40
+
41
+ ## Capture lessons
42
+
43
+ When a mistake or unexpected pattern is discovered during work:
44
+ 1. Determine if it generalizes — would it recur in a similar task?
45
+ 2. If yes, identify the canonical home using the workflow in
46
+ `docs/agent-context/lessons-learned.md`.
47
+ 3. Treat candidate lessons as provisional. Do not promote a fresh observation
48
+ into durable guidance from a single incident.
49
+
50
+ ## Update order
51
+
52
+ 1. Update canonical shared docs (`AGENTS.md`, `docs/agent-context/`) first.
53
+ 2. Update tool-specific files (this file, `.github/copilot-instructions.md`)
54
+ second.
55
+ 3. If a Claude-specific rule becomes shared and durable, promote it into
56
+ canonical docs and remove it from `.claude/`.
@@ -0,0 +1,53 @@
1
+ # Copilot Instructions — agent-kernel
2
+
3
+ > Canonical rules: `AGENTS.md`. This file projects review-critical rules that
4
+ > must be visible during GitHub PR review.
5
+
6
+ ## Review checklist
7
+
8
+ Flag these in every PR — CI does not catch them:
9
+
10
+ - Docstrings and descriptions must match actual implementation.
11
+ - No security bypass vectors: whitespace-only justification, truncated JSON, bare `int()` on untrusted input.
12
+ - No dead code: unused parameters, fixtures, or helpers.
13
+ - No backward-compat breaks: adding required methods to an existing Protocol breaks downstream.
14
+ - Naming consistent: use capability, principal, grant, Frame — never synonyms.
15
+
16
+ Canonical checklist: `docs/agent-context/review-checklist.md`
17
+
18
+ ## Code and docs reviewed together
19
+
20
+ - PRs that change public APIs, workflows, invariants, review rules, or path conventions must include doc updates.
21
+ - If a docstring changed, verify it matches the final code.
22
+ - Code is authoritative over docs. Fix stale docs in the same PR.
23
+ - Surface contradictions explicitly. Do not silently work around them.
24
+
25
+ ## Invariants
26
+
27
+ Non-negotiable. Violations silently degrade security:
28
+
29
+ - Firewall always mediates: `RawResult → Frame`. Never bypass.
30
+ - Token verification before every invocation. Never skip.
31
+ - Non-admin principals never get `raw` response mode.
32
+ - Policy rule ordering is security-critical — a rule placed before sensitivity checks creates a silent bypass.
33
+ - New `SensitivityTag` values need a matching policy rule, or the tag is silently ignored.
34
+
35
+ Full list: `docs/agent-context/invariants.md`
36
+
37
+ ## Convention discipline
38
+
39
+ - Follow conventions in `AGENTS.md`. Do not invent new ones.
40
+ - `make ci` is the single pre-push command. Do not guess alternatives.
41
+ - Custom exceptions from `errors.py` only. Never raise bare `ValueError`/`KeyError` to callers (catching stdlib internally to remap is fine).
42
+ - No new dependencies without justification.
43
+
44
+ ## Canonical sources
45
+
46
+ | Topic | File |
47
+ |-------|------|
48
+ | All shared rules | `AGENTS.md` |
49
+ | Hard invariants | `docs/agent-context/invariants.md` |
50
+ | Full review checklist | `docs/agent-context/review-checklist.md` |
51
+ | Workflows & commands | `docs/agent-context/workflows.md` |
52
+ | Recurring mistakes | `docs/agent-context/lessons-learned.md` |
53
+ | Architecture intent | `docs/agent-context/architecture.md` |
@@ -0,0 +1,47 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: ["main", "copilot/**"]
6
+ pull_request:
7
+ branches: ["main"]
8
+ workflow_call:
9
+
10
+ jobs:
11
+ test:
12
+ name: "Python ${{ matrix.python-version }}"
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ strategy:
17
+ matrix:
18
+ python-version: ["3.10", "3.11", "3.12"]
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - name: Set up Python ${{ matrix.python-version }}
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: ${{ matrix.python-version }}
27
+
28
+ - name: Install dependencies
29
+ run: pip install -e ".[dev]"
30
+
31
+ - name: Lint (ruff check)
32
+ run: ruff check src/ tests/ examples/
33
+
34
+ - name: Format check (ruff format)
35
+ run: ruff format --check src/ tests/ examples/
36
+
37
+ - name: Type check (mypy)
38
+ run: mypy src/
39
+
40
+ - name: Test (pytest)
41
+ run: python -m pytest -q --cov=agent_kernel --cov-report=term-missing
42
+
43
+ - name: Examples
44
+ run: |
45
+ python examples/basic_cli.py
46
+ python examples/billing_demo.py
47
+ python examples/http_driver_demo.py
@@ -0,0 +1,35 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ ci:
9
+ name: "CI gate"
10
+ uses: ./.github/workflows/ci.yml
11
+
12
+ publish:
13
+ name: "Build & publish"
14
+ needs: ci
15
+ runs-on: ubuntu-latest
16
+ environment: pypi
17
+ permissions:
18
+ contents: read # required for actions/checkout
19
+ id-token: write # required for Trusted Publisher (OIDC)
20
+ steps:
21
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
25
+ with:
26
+ python-version: "3.12"
27
+
28
+ - name: Install build tools
29
+ run: pip install build
30
+
31
+ - name: Build sdist and wheel
32
+ run: python -m build
33
+
34
+ - name: Publish to PyPI
35
+ uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1,143 @@
1
+ # AGENTS.md — AI Agent Instructions
2
+
3
+ This is the canonical source of truth for AI coding agents working in this repository.
4
+ Tool-specific instruction files (`.github/copilot-instructions.md`, `.claude/CLAUDE.md`)
5
+ reference this file and add only tool-specific guidance.
6
+
7
+ ## Repo layout
8
+
9
+ ```
10
+ src/agent_kernel/ — library source (one module per concern, ≤300 lines each)
11
+ drivers/ — capability drivers (one file per driver)
12
+ firewall/ — context firewall (redaction, summarization, budgets)
13
+ tests/ — pytest suite (one test file per module)
14
+ examples/ — runnable demos (prefer offline; network OK with fallback)
15
+ docs/ — reference documentation
16
+ docs/agent-context/ — deeper agent guidance (architecture, workflows, invariants)
17
+ ```
18
+
19
+ ## Weaver ecosystem
20
+
21
+ agent-kernel is part of the **Weaver ecosystem**:
22
+ - [weaver-spec](https://github.com/dgenio/weaver-spec) — formal specification with invariants
23
+ - [contextweaver](https://github.com/dgenio/contextweaver) — context compilation library
24
+ - ChainWeaver — orchestration layer
25
+
26
+ This repo must conform to weaver-spec invariants. Key invariants (all equally critical):
27
+ - **I-01**: Every tool output must pass through a context boundary before reaching the LLM.
28
+ - **I-02**: Context boundaries must enforce budgets (size, depth, field count).
29
+ - **I-06**: Tokens must bind principal + capability + constraints; no reuse across principals.
30
+
31
+ Full spec: [dgenio/weaver-spec](https://github.com/dgenio/weaver-spec)
32
+
33
+ ## Domain vocabulary
34
+
35
+ Use these terms consistently. Never substitute synonyms:
36
+
37
+ | Term | Means | Not |
38
+ |------|-------|-----|
39
+ | capability | a registered, auditable action | tool, function, API |
40
+ | principal | the identity invoking a capability | agent, user, caller |
41
+ | grant | a policy-approved token issuance | permission, access |
42
+ | Frame | the bounded, redacted result returned to the LLM | response, output |
43
+
44
+ ## Quality bar
45
+
46
+ - `make ci` must pass before every push. It runs: `fmt → lint → type → test → example`.
47
+ - All public interfaces need type hints and docstrings.
48
+ - Never raise bare `ValueError` or `KeyError` to callers. Use custom exceptions from `errors.py`. Catching stdlib exceptions internally to remap them is fine.
49
+ - Error messages are part of the contract — tests must assert both exception type and message.
50
+ - Keep modules ≤ 300 lines. Split if needed.
51
+ - No randomness in matching, routing, or summarization. Deterministic outputs always.
52
+ - No new dependencies without justification. The dep list is intentionally minimal (`httpx` only).
53
+
54
+ ## Security rules
55
+
56
+ - Never log or print secret key material.
57
+ - HMAC secrets come from `AGENT_KERNEL_SECRET` env var; fallback to a random dev secret with a logged warning.
58
+ - Tokens are HMAC-signed but **not encrypted**. Never store secrets in token payloads.
59
+ - Confused-deputy prevention: tokens bind `principal_id + capability_id + constraints`.
60
+ - Never bypass token verification before capability invocation.
61
+ - Firewall always transforms `RawResult → Frame`. Raw driver output never reaches the LLM.
62
+ - Non-admin principals never get `raw` response mode. The Firewall downgrades to `summary`.
63
+ - No duplicate capability IDs in the registry.
64
+
65
+ See [docs/agent-context/invariants.md](docs/agent-context/invariants.md) for the full "never do" list and security traps.
66
+
67
+ ## Code conventions
68
+
69
+ **All modules (`src/agent_kernel/`):**
70
+ Relative imports. Dataclasses with `slots=True`. Protocols for interfaces.
71
+ `__all__` in every `__init__.py`. Google-style docstrings.
72
+ `CamelCase` for classes, `snake_case` for functions. Error classes end with `Error`.
73
+
74
+ **Drivers (`drivers/`):**
75
+ One file per driver. `Driver` Protocol in `base.py`. Async `execute()` method.
76
+ Driver classes end with `Driver`. Use `DriverError` for exceptions.
77
+
78
+ **Firewall (`firewall/`):**
79
+ Pure functions for redaction and summarization. `Firewall` class in `transform.py` orchestrates.
80
+ Use `FirewallError` for exceptions.
81
+
82
+ **Tests (`tests/`):**
83
+ Every module has a corresponding test file (`kernel.py` → `test_kernel.py`).
84
+ Conftest fixtures only for cross-test reuse (≥2 test files). Local helpers otherwise.
85
+
86
+ **Examples (`examples/`):**
87
+ Prefer offline. Network examples OK only with a clear fallback.
88
+
89
+ ## Workflow
90
+
91
+ - One logical change per PR. Squash-merge. Conventional commit titles (`feat:`, `fix:`, `test:`, `docs:`).
92
+ - `make ci` is the single authoritative pre-push command.
93
+ - Update `CHANGELOG.md` in the same PR when adding features or fixes.
94
+ - Code is authoritative over docs. Fix stale docs when you spot discrepancies.
95
+
96
+ See [docs/agent-context/workflows.md](docs/agent-context/workflows.md) for full details.
97
+
98
+ ## Adding a capability driver
99
+
100
+ 1. Implement the `Driver` protocol in `src/agent_kernel/drivers/`.
101
+ 2. Register it with `StaticRouter` or implement a custom `Router`.
102
+ 3. Add integration tests in `tests/test_drivers.py`.
103
+
104
+ See [docs/integrations.md](docs/integrations.md) for MCP and HTTP examples.
105
+
106
+ ## Adding a policy rule
107
+
108
+ 1. Add the rule to `DefaultPolicyEngine.evaluate()` in `policy.py`.
109
+ 2. **Placement matters:** rules are evaluated in order. A new rule placed before sensitivity checks silently bypasses them.
110
+ 3. If adding a new `SensitivityTag`, you must also add a corresponding policy rule — otherwise the tag is silently ignored.
111
+ 4. Cover it with a test in `tests/test_policy.py`.
112
+
113
+ ## Review checklist (beyond `make ci`)
114
+
115
+ Before submitting a PR, verify:
116
+ - [ ] Docstrings and descriptions match the actual implementation.
117
+ - [ ] Security edge cases handled (whitespace-only justification, truncated JSON, bare `int()` on untrusted input).
118
+ - [ ] No dead or unused code (parameters, fixtures, helpers).
119
+ - [ ] No backward compatibility breaks (e.g., adding required methods to a Protocol).
120
+ - [ ] Naming consistent across docs and code (use capability, principal, grant, Frame — never synonyms).
121
+
122
+ See [docs/agent-context/review-checklist.md](docs/agent-context/review-checklist.md) for the full checklist.
123
+
124
+ ## Documentation map
125
+
126
+ | Topic | Canonical source |
127
+ |-------|-----------------|
128
+ | Architecture & design intent | [docs/agent-context/architecture.md](docs/agent-context/architecture.md) |
129
+ | Components & API reference | [docs/architecture.md](docs/architecture.md) |
130
+ | Security model & threats | [docs/security.md](docs/security.md) |
131
+ | Hard invariants & forbidden shortcuts | [docs/agent-context/invariants.md](docs/agent-context/invariants.md) |
132
+ | Workflow rules & commands | [docs/agent-context/workflows.md](docs/agent-context/workflows.md) |
133
+ | Recurring mistakes | [docs/agent-context/lessons-learned.md](docs/agent-context/lessons-learned.md) |
134
+ | Review & self-check | [docs/agent-context/review-checklist.md](docs/agent-context/review-checklist.md) |
135
+ | Driver integration patterns | [docs/integrations.md](docs/integrations.md) |
136
+ | Capability design conventions | [docs/capabilities.md](docs/capabilities.md) |
137
+ | Context firewall details | [docs/context_firewall.md](docs/context_firewall.md) |
138
+
139
+ ## Update policy
140
+
141
+ Code is authoritative. When docs contradict code, fix the docs.
142
+ Each topic has one canonical source (see table above). Update the canonical source;
143
+ do not create parallel guidance elsewhere.
@@ -0,0 +1,60 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.3.0] - 2026-03-09
11
+
12
+ ### Added
13
+ - Structured logging at kernel decision points (invoke, grant, deny, revoke).
14
+ - Agent-facing documentation system: `docs/agent-context/` (architecture, workflows, invariants, lessons-learned, review-checklist).
15
+ - `.github/copilot-instructions.md` — review-critical projections for GitHub Copilot.
16
+ - `.claude/CLAUDE.md` — Claude-specific operating instructions.
17
+ - PyPI publish workflow (`.github/workflows/publish.yml`) with Trusted Publisher (OIDC) (#37).
18
+ - `RELEASE.md` documenting the full release process.
19
+ - `[project.urls]` in `pyproject.toml` (Homepage, Repository, Documentation, Changelog).
20
+ - Optional dependency groups: `mcp` and `otel` in `pyproject.toml`.
21
+
22
+ ### Changed
23
+ - Rewrote `AGENTS.md` with full domain vocabulary, security rules, code conventions, documentation map, and weaver-spec references.
24
+ - Renamed PyPI package from `agent-kernel` to `weaver-kernel` to align with Weaver ecosystem.
25
+ - Added `workflow_call` trigger to CI workflow so publish workflow can reuse it as a gate.
26
+
27
+ ### Refactored
28
+ - Extracted `_log_verify_failure` helper in `tokens.py`.
29
+ - Consolidated invoke logging with shared base dict in `kernel.py`.
30
+ - Extracted `_deny` static method in policy engine.
31
+
32
+ ### Fixed
33
+ - Pinned GitHub Actions to commit SHAs in publish workflow.
34
+ - Added `contents:read` permission to publish job.
35
+ - Clarified PyPI vs import name in README Quickstart.
36
+
37
+ ## [0.2.0] - 2026-03-06
38
+
39
+ ### Added
40
+ - Token revocation support: `revoke_token()` and `revoke_all()` on `Kernel` (#33, #57).
41
+ - `SECRETS` sensitivity tag enforcement in policy engine and redaction (#56).
42
+
43
+ ### Fixed
44
+ - Policy engine now strips whitespace from justification before length check.
45
+ - Policy engine reports both raw and stripped length in justification errors.
46
+ - Policy engine checks role before justification in all safety/sensitivity blocks.
47
+ - Redaction preserves field-name context in API key and connection string patterns.
48
+ - `revoke_all()` drops `_principal_tokens` entry after revoking.
49
+
50
+ ## [0.1.0] - 2024-01-01
51
+
52
+ ### Added
53
+ - Initial scaffold: `CapabilityRegistry`, `PolicyEngine`, `HMACTokenProvider`, `Kernel`.
54
+ - `InMemoryDriver` and `HTTPDriver` (httpx-based).
55
+ - Context `Firewall` with `Budgets`, redaction, and summarization.
56
+ - `HandleStore` with TTL, pagination, field selection, and basic filtering.
57
+ - `TraceStore` and `explain()` for full audit trail.
58
+ - Examples: `basic_cli.py`, `billing_demo.py`, `http_driver_demo.py`.
59
+ - Documentation: architecture, security model, integrations, capabilities, context firewall.
60
+ - CI pipeline for Python 3.10, 3.11, 3.12 with ruff + mypy + pytest.
@@ -0,0 +1,36 @@
1
+ # Contributing to agent-kernel
2
+
3
+ Thank you for your interest in contributing!
4
+
5
+ ## Development setup
6
+
7
+ ```bash
8
+ git clone https://github.com/dgenio/agent-kernel.git
9
+ cd agent-kernel
10
+ python -m venv .venv
11
+ source .venv/bin/activate
12
+ pip install -e ".[dev]"
13
+ ```
14
+
15
+ ## Running checks
16
+
17
+ ```bash
18
+ make fmt # auto-format with ruff
19
+ make lint # lint with ruff
20
+ make type # type-check with mypy
21
+ make test # run pytest with coverage
22
+ make ci # all of the above + examples
23
+ ```
24
+
25
+ ## Pull request guidelines
26
+
27
+ 1. Keep PRs focused — one logical change per PR.
28
+ 2. Add or update tests for every behaviour change.
29
+ 3. All checks in `make ci` must pass.
30
+ 4. Follow the existing code style (ruff-enforced).
31
+ 5. Write docstrings on all public interfaces.
32
+
33
+ ## Security
34
+
35
+ Please report security vulnerabilities privately via GitHub Security Advisories.
36
+ Do **not** open a public issue for a security bug.