axor-core 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.
Files changed (78) hide show
  1. axor_core-0.1.0/.github/workflows/ci.yml +102 -0
  2. axor_core-0.1.0/.gitignore +13 -0
  3. axor_core-0.1.0/CHANGELOG.md +17 -0
  4. axor_core-0.1.0/CONTRIBUTING.md +55 -0
  5. axor_core-0.1.0/LICENSE +21 -0
  6. axor_core-0.1.0/PKG-INFO +905 -0
  7. axor_core-0.1.0/README.md +882 -0
  8. axor_core-0.1.0/axor_core/__init__.py +119 -0
  9. axor_core-0.1.0/axor_core/budget/__init__.py +30 -0
  10. axor_core-0.1.0/axor_core/budget/estimator.py +113 -0
  11. axor_core-0.1.0/axor_core/budget/policy_engine.py +195 -0
  12. axor_core-0.1.0/axor_core/budget/tracker.py +128 -0
  13. axor_core-0.1.0/axor_core/capability/__init__.py +23 -0
  14. axor_core-0.1.0/axor_core/capability/executor.py +115 -0
  15. axor_core-0.1.0/axor_core/capability/resolver.py +137 -0
  16. axor_core-0.1.0/axor_core/context/__init__.py +47 -0
  17. axor_core-0.1.0/axor_core/context/cache.py +159 -0
  18. axor_core-0.1.0/axor_core/context/compressor.py +392 -0
  19. axor_core-0.1.0/axor_core/context/invalidator.py +125 -0
  20. axor_core-0.1.0/axor_core/context/lineage.py +89 -0
  21. axor_core-0.1.0/axor_core/context/manager.py +306 -0
  22. axor_core-0.1.0/axor_core/context/selector.py +173 -0
  23. axor_core-0.1.0/axor_core/context/symbol_table.py +208 -0
  24. axor_core-0.1.0/axor_core/contracts/__init__.py +105 -0
  25. axor_core-0.1.0/axor_core/contracts/agent.py +160 -0
  26. axor_core-0.1.0/axor_core/contracts/cancel.py +80 -0
  27. axor_core-0.1.0/axor_core/contracts/command.py +49 -0
  28. axor_core-0.1.0/axor_core/contracts/context.py +75 -0
  29. axor_core-0.1.0/axor_core/contracts/envelope.py +68 -0
  30. axor_core-0.1.0/axor_core/contracts/extension.py +100 -0
  31. axor_core-0.1.0/axor_core/contracts/intent.py +51 -0
  32. axor_core-0.1.0/axor_core/contracts/invokable.py +42 -0
  33. axor_core-0.1.0/axor_core/contracts/memory.py +171 -0
  34. axor_core-0.1.0/axor_core/contracts/policy.py +165 -0
  35. axor_core-0.1.0/axor_core/contracts/result.py +73 -0
  36. axor_core-0.1.0/axor_core/contracts/trace.py +192 -0
  37. axor_core-0.1.0/axor_core/errors/__init__.py +29 -0
  38. axor_core-0.1.0/axor_core/errors/exceptions.py +96 -0
  39. axor_core-0.1.0/axor_core/extensions/__init__.py +20 -0
  40. axor_core-0.1.0/axor_core/extensions/registry.py +61 -0
  41. axor_core-0.1.0/axor_core/extensions/sanitizer.py +89 -0
  42. axor_core-0.1.0/axor_core/node/__init__.py +25 -0
  43. axor_core-0.1.0/axor_core/node/envelope.py +85 -0
  44. axor_core-0.1.0/axor_core/node/export.py +79 -0
  45. axor_core-0.1.0/axor_core/node/intent_loop.py +383 -0
  46. axor_core-0.1.0/axor_core/node/spawn.py +91 -0
  47. axor_core-0.1.0/axor_core/node/wrapper.py +468 -0
  48. axor_core-0.1.0/axor_core/policy/__init__.py +26 -0
  49. axor_core-0.1.0/axor_core/policy/analyzer.py +134 -0
  50. axor_core-0.1.0/axor_core/policy/composer.py +183 -0
  51. axor_core-0.1.0/axor_core/policy/heuristic.py +167 -0
  52. axor_core-0.1.0/axor_core/policy/presets.py +211 -0
  53. axor_core-0.1.0/axor_core/policy/selector.py +201 -0
  54. axor_core-0.1.0/axor_core/trace/__init__.py +21 -0
  55. axor_core-0.1.0/axor_core/trace/collector.py +234 -0
  56. axor_core-0.1.0/axor_core/trace/events.py +179 -0
  57. axor_core-0.1.0/axor_core/worker/__init__.py +22 -0
  58. axor_core-0.1.0/axor_core/worker/commands.py +178 -0
  59. axor_core-0.1.0/axor_core/worker/dispatcher.py +25 -0
  60. axor_core-0.1.0/axor_core/worker/session.py +268 -0
  61. axor_core-0.1.0/pyproject.toml +55 -0
  62. axor_core-0.1.0/tests/__init__.py +0 -0
  63. axor_core-0.1.0/tests/budget/__init__.py +0 -0
  64. axor_core-0.1.0/tests/capability/__init__.py +0 -0
  65. axor_core-0.1.0/tests/capability/test_capability.py +177 -0
  66. axor_core-0.1.0/tests/conftest.py +259 -0
  67. axor_core-0.1.0/tests/context/__init__.py +0 -0
  68. axor_core-0.1.0/tests/context/test_context.py +223 -0
  69. axor_core-0.1.0/tests/contracts/__init__.py +0 -0
  70. axor_core-0.1.0/tests/contracts/test_cancel.py +66 -0
  71. axor_core-0.1.0/tests/integration/__init__.py +0 -0
  72. axor_core-0.1.0/tests/integration/test_session.py +173 -0
  73. axor_core-0.1.0/tests/node/__init__.py +0 -0
  74. axor_core-0.1.0/tests/node/test_node.py +183 -0
  75. axor_core-0.1.0/tests/policy/__init__.py +0 -0
  76. axor_core-0.1.0/tests/policy/test_policy.py +214 -0
  77. axor_core-0.1.0/tests/trace/__init__.py +0 -0
  78. axor_core-0.1.0/tests/worker/__init__.py +0 -0
@@ -0,0 +1,102 @@
1
+ name: CI/CD
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ["v*.*.*"]
7
+ pull_request:
8
+ branches: [main]
9
+
10
+ jobs:
11
+ test:
12
+ name: Test (Python ${{ matrix.python-version }})
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ python-version: ["3.11", "3.12"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ cache: pip
25
+
26
+ - name: Install
27
+ run: |
28
+ pip install -e ".[dev]"
29
+
30
+ - name: Static analysis — no provider imports in core
31
+ run: |
32
+ python - << 'EOF'
33
+ import ast, os, sys
34
+ issues = []
35
+ for root, dirs, files in os.walk("axor_core"):
36
+ dirs[:] = [d for d in dirs if not d.startswith("__")]
37
+ for f in files:
38
+ if not f.endswith(".py"):
39
+ continue
40
+ path = os.path.join(root, f)
41
+ src = open(path).read()
42
+ for provider in ["anthropic", "openai", "langchain", "boto3"]:
43
+ if f"import {provider}" in src or f"from {provider}" in src:
44
+ issues.append(f"PROVIDER_IMPORT: {path} imports {provider}")
45
+ if issues:
46
+ print("\n".join(issues))
47
+ sys.exit(1)
48
+ print(f"✓ no provider imports in axor_core/")
49
+ EOF
50
+
51
+ - name: Run tests
52
+ run: pytest tests/ -v --tb=short
53
+
54
+ publish:
55
+ name: Publish to PyPI
56
+ needs: test
57
+ runs-on: ubuntu-latest
58
+ if: startsWith(github.ref, 'refs/tags/v')
59
+ environment: pypi
60
+
61
+ permissions:
62
+ id-token: write # for trusted publishing
63
+
64
+ steps:
65
+ - uses: actions/checkout@v4
66
+
67
+ - uses: actions/setup-python@v5
68
+ with:
69
+ python-version: "3.12"
70
+
71
+ - name: Verify tag matches package version
72
+ run: |
73
+ python - << 'EOF'
74
+ import pathlib
75
+ import re
76
+ import sys
77
+ import tomllib
78
+
79
+ ref = "${{ github.ref_name }}"
80
+ m = re.fullmatch(r"v(\d+\.\d+\.\d+)", ref)
81
+ if not m:
82
+ print(f"Tag {ref!r} must match vX.Y.Z")
83
+ sys.exit(1)
84
+
85
+ tag_version = m.group(1)
86
+ data = tomllib.loads(pathlib.Path("pyproject.toml").read_text(encoding="utf-8"))
87
+ pkg_version = data["project"]["version"]
88
+
89
+ if tag_version != pkg_version:
90
+ print(f"Version mismatch: tag={tag_version}, pyproject={pkg_version}")
91
+ sys.exit(1)
92
+
93
+ print(f"Version check passed: {pkg_version}")
94
+ EOF
95
+
96
+ - name: Build
97
+ run: |
98
+ pip install hatchling build
99
+ python -m build
100
+
101
+ - name: Publish to PyPI
102
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,13 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ .env
8
+ *.egg
9
+ .pytest_cache/
10
+ .coverage
11
+ htmlcov/
12
+ ~/.axor/
13
+ *.bin
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2025-04-12
4
+
5
+ Initial release.
6
+
7
+ ### Added
8
+ - Core governance kernel (axor-core)
9
+ - Claude Code adapter (axor-claude)
10
+ - CLI with interactive REPL (axor-cli)
11
+ - Dynamic policy selection (7-policy matrix)
12
+ - ContextManager with 11 waste categories
13
+ - ToolResultBus for async tool loop
14
+ - Federation via spawn_child with child_executor
15
+ - CancelToken cooperative cancellation
16
+ - BudgetPolicyEngine (60/80/90/95% thresholds)
17
+ - TraceCollector with lineage (17 event kinds)
@@ -0,0 +1,55 @@
1
+ # Contributing to axor-core
2
+
3
+ ## Architecture principles
4
+
5
+ Before contributing, read the design invariants in README.md.
6
+
7
+ The most important ones:
8
+
9
+ - **Core never imports providers.** No anthropic, openai, or other SDK imports in `axor_core/`.
10
+ - **Policy meaning belongs to core.** Adapters translate envelopes, never define governance.
11
+ - **Executors never self-assign capabilities.** Always derived from policy.
12
+ - **Waste elimination always runs.** Mode controls aggressiveness, not whether it happens.
13
+
14
+ ## Setup
15
+
16
+ ```bash
17
+ git clone https://github.com/your-org/axor-core
18
+ cd axor-core
19
+ python -m venv .venv
20
+ source .venv/bin/activate
21
+ pip install -e ".[dev]"
22
+ ```
23
+
24
+ ## Running tests
25
+
26
+ ```bash
27
+ pytest tests/
28
+ pytest tests/integration/ # integration only
29
+ pytest tests/ -k "cancel" # filter by name
30
+ ```
31
+
32
+ ## Adding a subsystem
33
+
34
+ 1. Add contracts to `axor_core/contracts/` first — no imports from other axor_core modules
35
+ 2. Implement in the appropriate subsystem package
36
+ 3. Export from the package `__init__.py`
37
+ 4. Add tests in `tests/<subsystem>/`
38
+ 5. Update `axor_core/__init__.py` if adding public API
39
+
40
+ ## Adding an adapter
41
+
42
+ Adapters live in separate repositories (`axor-claude`, `axor-openai`, etc.).
43
+ They implement:
44
+ - `Invokable` — the executor contract
45
+ - `ToolHandler` — one per tool
46
+ - `ExtensionLoader` — optional, for provider-specific extensions (CLAUDE.md etc.)
47
+
48
+ See `README.md` → "Implementing an Adapter" for details.
49
+
50
+ ## Pull request checklist
51
+
52
+ - [ ] No provider imports in `axor_core/`
53
+ - [ ] New contracts added to `contracts/__init__.py`
54
+ - [ ] Tests added for new functionality
55
+ - [ ] `PYTHONPATH=. python -c "from axor_core import GovernedSession"` passes
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Axor Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.