agenthold 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.
- agenthold-0.1.0/.github/workflows/ci.yml +40 -0
- agenthold-0.1.0/.github/workflows/publish.yml +23 -0
- agenthold-0.1.0/.gitignore +217 -0
- agenthold-0.1.0/.python-version +1 -0
- agenthold-0.1.0/CHANGELOG.md +25 -0
- agenthold-0.1.0/CONTRIBUTING.md +89 -0
- agenthold-0.1.0/LICENSE +21 -0
- agenthold-0.1.0/PKG-INFO +360 -0
- agenthold-0.1.0/README.md +346 -0
- agenthold-0.1.0/assets/budget_with.gif +0 -0
- agenthold-0.1.0/assets/budget_without.gif +0 -0
- agenthold-0.1.0/examples/budget_allocation/make_budget_gifs.py +251 -0
- agenthold-0.1.0/examples/budget_allocation/with_agenthold.py +160 -0
- agenthold-0.1.0/examples/budget_allocation/without_agenthold.py +99 -0
- agenthold-0.1.0/examples/order_processing/with_agenthold.py +133 -0
- agenthold-0.1.0/examples/order_processing/without_agenthold.py +75 -0
- agenthold-0.1.0/pyproject.toml +50 -0
- agenthold-0.1.0/src/agenthold/__init__.py +17 -0
- agenthold-0.1.0/src/agenthold/exceptions.py +30 -0
- agenthold-0.1.0/src/agenthold/models.py +46 -0
- agenthold-0.1.0/src/agenthold/server.py +265 -0
- agenthold-0.1.0/src/agenthold/store.py +231 -0
- agenthold-0.1.0/tests/conftest.py +18 -0
- agenthold-0.1.0/tests/test_conflicts.py +298 -0
- agenthold-0.1.0/tests/test_server.py +168 -0
- agenthold-0.1.0/tests/test_store.py +277 -0
- agenthold-0.1.0/uv.lock +1166 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.11", "3.12"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Install uv
|
|
20
|
+
uses: astral-sh/setup-uv@v3
|
|
21
|
+
|
|
22
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
23
|
+
run: uv python install ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: uv sync --all-extras --dev
|
|
27
|
+
|
|
28
|
+
- name: Run ruff (lint + format check)
|
|
29
|
+
run: |
|
|
30
|
+
uv run ruff check src/ tests/
|
|
31
|
+
uv run ruff format --check src/ tests/
|
|
32
|
+
|
|
33
|
+
- name: Run mypy
|
|
34
|
+
run: uv run mypy src/
|
|
35
|
+
|
|
36
|
+
- name: Run tests
|
|
37
|
+
run: uv run pytest tests/ -v --tb=short
|
|
38
|
+
|
|
39
|
+
- name: Check test coverage
|
|
40
|
+
run: uv run pytest tests/ --cov=agenthold --cov-report=term-missing --cov-fail-under=80
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*" # triggers on v0.1.0, v0.2.0, etc.
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
|
|
14
|
+
- name: Install uv
|
|
15
|
+
uses: astral-sh/setup-uv@v3
|
|
16
|
+
|
|
17
|
+
- name: Build distribution
|
|
18
|
+
run: uv build
|
|
19
|
+
|
|
20
|
+
- name: Publish to PyPI
|
|
21
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
22
|
+
with:
|
|
23
|
+
password: ${{ secrets.AGENTHOLD_PYPI_TOKEN }}
|
|
@@ -0,0 +1,217 @@
|
|
|
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
|
+
*.pyc
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
.pybuilder/
|
|
77
|
+
target/
|
|
78
|
+
|
|
79
|
+
# Jupyter Notebook
|
|
80
|
+
.ipynb_checkpoints
|
|
81
|
+
|
|
82
|
+
# IPython
|
|
83
|
+
profile_default/
|
|
84
|
+
ipython_config.py
|
|
85
|
+
|
|
86
|
+
# pyenv
|
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
89
|
+
# .python-version
|
|
90
|
+
|
|
91
|
+
# pipenv
|
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
95
|
+
# install all needed dependencies.
|
|
96
|
+
#Pipfile.lock
|
|
97
|
+
|
|
98
|
+
# UV
|
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
101
|
+
# commonly ignored for libraries.
|
|
102
|
+
#uv.lock
|
|
103
|
+
|
|
104
|
+
# poetry
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
107
|
+
# commonly ignored for libraries.
|
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
109
|
+
#poetry.lock
|
|
110
|
+
#poetry.toml
|
|
111
|
+
|
|
112
|
+
# pdm
|
|
113
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
114
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
115
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
116
|
+
#pdm.lock
|
|
117
|
+
#pdm.toml
|
|
118
|
+
.pdm-python
|
|
119
|
+
.pdm-build/
|
|
120
|
+
|
|
121
|
+
# pixi
|
|
122
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
123
|
+
#pixi.lock
|
|
124
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
125
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
126
|
+
.pixi
|
|
127
|
+
|
|
128
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
129
|
+
__pypackages__/
|
|
130
|
+
|
|
131
|
+
# Celery stuff
|
|
132
|
+
celerybeat-schedule
|
|
133
|
+
celerybeat.pid
|
|
134
|
+
|
|
135
|
+
# SageMath parsed files
|
|
136
|
+
*.sage.py
|
|
137
|
+
|
|
138
|
+
# Environments
|
|
139
|
+
.env
|
|
140
|
+
.envrc
|
|
141
|
+
.venv
|
|
142
|
+
env/
|
|
143
|
+
venv/
|
|
144
|
+
ENV/
|
|
145
|
+
env.bak/
|
|
146
|
+
venv.bak/
|
|
147
|
+
|
|
148
|
+
# Spyder project settings
|
|
149
|
+
.spyderproject
|
|
150
|
+
.spyproject
|
|
151
|
+
|
|
152
|
+
# Rope project settings
|
|
153
|
+
.ropeproject
|
|
154
|
+
|
|
155
|
+
# mkdocs documentation
|
|
156
|
+
/site
|
|
157
|
+
|
|
158
|
+
# mypy
|
|
159
|
+
.mypy_cache/
|
|
160
|
+
.dmypy.json
|
|
161
|
+
dmypy.json
|
|
162
|
+
|
|
163
|
+
# Pyre type checker
|
|
164
|
+
.pyre/
|
|
165
|
+
|
|
166
|
+
# pytype static type analyzer
|
|
167
|
+
.pytype/
|
|
168
|
+
|
|
169
|
+
# Cython debug symbols
|
|
170
|
+
cython_debug/
|
|
171
|
+
|
|
172
|
+
# PyCharm
|
|
173
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
174
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
175
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
176
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
177
|
+
#.idea/
|
|
178
|
+
|
|
179
|
+
# Abstra
|
|
180
|
+
# Abstra is an AI-powered process automation framework.
|
|
181
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
182
|
+
# Learn more at https://abstra.io/docs
|
|
183
|
+
.abstra/
|
|
184
|
+
|
|
185
|
+
# Visual Studio Code
|
|
186
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
187
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
188
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
189
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
190
|
+
# .vscode/
|
|
191
|
+
|
|
192
|
+
# Ruff stuff:
|
|
193
|
+
.ruff_cache/
|
|
194
|
+
|
|
195
|
+
# PyPI configuration file
|
|
196
|
+
.pypirc
|
|
197
|
+
|
|
198
|
+
# Cursor
|
|
199
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
200
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
201
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
202
|
+
.cursorignore
|
|
203
|
+
.cursorindexingignore
|
|
204
|
+
|
|
205
|
+
# Marimo
|
|
206
|
+
marimo/_static/
|
|
207
|
+
marimo/_lsp/
|
|
208
|
+
__marimo__/
|
|
209
|
+
|
|
210
|
+
# Personal Notes
|
|
211
|
+
plan.md
|
|
212
|
+
|
|
213
|
+
# DB
|
|
214
|
+
*.db
|
|
215
|
+
|
|
216
|
+
# Claude
|
|
217
|
+
.claude/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented here.
|
|
4
|
+
|
|
5
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
|
+
This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [0.1.0] - 2026-03-15
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- MCP server exposing four tools: `agenthold_get`, `agenthold_set`, `agenthold_list`, `agenthold_history`
|
|
15
|
+
- SQLite state store with optimistic concurrency control via `expected_version`
|
|
16
|
+
- Append-only version history for every key (`state_history` table)
|
|
17
|
+
- `ConflictError` with full conflict detail: expected version, actual version, who wrote it, and when
|
|
18
|
+
- `NotFoundError` for missing keys (returned as `{"status": "not_found"}` at the tool level, never a hard error)
|
|
19
|
+
- Thread-safe store with a single `threading.Lock` protecting all reads and writes
|
|
20
|
+
- WAL mode enabled on the SQLite connection for improved concurrent read performance
|
|
21
|
+
- CLI entry point: `agenthold --db ./state.db`
|
|
22
|
+
- In-memory store option (`:memory:`) for testing without a file
|
|
23
|
+
- Order processing example: two agents updating the same order record concurrently, with and without conflict detection
|
|
24
|
+
- Budget allocation example: two agents drawing from a shared budget, demonstrating silent overcommit vs. safe retry
|
|
25
|
+
- GitHub Actions CI running on Python 3.11 and 3.12: ruff, mypy, pytest, and coverage gate at 80%
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Contributing to agenthold
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Development environment
|
|
8
|
+
|
|
9
|
+
You will need [uv](https://docs.astral.sh/uv/) to manage the Python environment.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
git clone https://github.com/edobusy/agenthold.git
|
|
13
|
+
cd agenthold
|
|
14
|
+
uv sync --all-extras --dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This creates a virtual environment in `.venv/` and installs all runtime and development dependencies.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Running the tests
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
uv run pytest tests/ -v
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
To check coverage:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
uv run pytest tests/ --cov=agenthold --cov-report=term-missing
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The test suite must pass at 80%+ coverage before a PR can be merged. CI enforces this.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Linting and formatting
|
|
38
|
+
|
|
39
|
+
agenthold uses [ruff](https://docs.astral.sh/ruff/) for linting and formatting, and [mypy](https://mypy.readthedocs.io/) in strict mode for type checking.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Check and auto-fix lint issues
|
|
43
|
+
uv run ruff check --fix src/ tests/
|
|
44
|
+
|
|
45
|
+
# Format the code
|
|
46
|
+
uv run ruff format src/ tests/
|
|
47
|
+
|
|
48
|
+
# Type checking
|
|
49
|
+
uv run mypy src/
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
All three must pass with zero errors before a PR is reviewed. The CI workflow runs them on every push.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## PR process
|
|
57
|
+
|
|
58
|
+
1. Fork the repository and create a branch from `main`.
|
|
59
|
+
2. Make your change. Keep commits focused: one logical change per commit.
|
|
60
|
+
3. Follow the commit message convention: `feat:`, `fix:`, `test:`, `docs:`, `chore:`, `refactor:`.
|
|
61
|
+
4. Make sure tests pass, ruff is clean, and mypy has no errors.
|
|
62
|
+
5. Open a pull request against `main`. Describe what you changed and why.
|
|
63
|
+
|
|
64
|
+
There are no contributor licence agreements or special requirements. Small, well-scoped PRs are much easier to review than large ones.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Project structure
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
src/agenthold/
|
|
72
|
+
__init__.py public API and version
|
|
73
|
+
server.py MCP server and tool registration
|
|
74
|
+
store.py all SQLite operations (the core of the project)
|
|
75
|
+
models.py Pydantic models for records and errors
|
|
76
|
+
exceptions.py ConflictError, NotFoundError
|
|
77
|
+
|
|
78
|
+
tests/
|
|
79
|
+
conftest.py shared fixtures (in-memory store, temp db paths)
|
|
80
|
+
test_store.py unit tests for all store operations
|
|
81
|
+
test_server.py integration tests for the MCP tool dispatch
|
|
82
|
+
test_conflicts.py concurrent write edge cases
|
|
83
|
+
|
|
84
|
+
examples/
|
|
85
|
+
order_processing/ two-agent order workflow demo
|
|
86
|
+
budget_allocation/ two-agent budget allocation demo
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The `StateStore` class in `store.py` is the place to start if you are adding a new capability. The MCP tool layer in `server.py` is intentionally thin: it validates inputs, calls the store, and serialises the result.
|
agenthold-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Edoardo Busano
|
|
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.
|