|
| 1 | +# atomicmemory-python — agent rules |
| 2 | + |
| 3 | +Python client SDK for the AtomicMemory memory layer. |
| 4 | + |
| 5 | +## Contributor Context |
| 6 | + |
| 7 | +Use this file as the repo-local contributor guide. When behavior depends on |
| 8 | +another AtomicMemory repo, rely on the published HTTP/package contract and call |
| 9 | +out any assumption in the PR. |
| 10 | + |
| 11 | +Before changing code, read the relevant local files first: |
| 12 | + |
| 13 | +- `README.md` for user-facing installation and usage. |
| 14 | +- `pyproject.toml` for supported Python versions, dependencies, and tool config. |
| 15 | +- `atomicmemory/` for package code and `tests/` for expected behavior. |
| 16 | + |
| 17 | +## Repository Shape |
| 18 | + |
| 19 | +- `atomicmemory/` — typed Python package. |
| 20 | +- `tests/` — unit and integration tests. |
| 21 | +- `examples/` — public usage examples. |
| 22 | +- `pyproject.toml` — package metadata and tool configuration. |
| 23 | + |
| 24 | +## Tooling |
| 25 | + |
| 26 | +- **Package management:** `uv sync` (NOT `uv pip install`). |
| 27 | +- **Python interpreter:** `.venv/bin/python`. Never the global `python`. |
| 28 | +- **HTTP:** `httpx` (sync `Client`, async `AsyncClient`). |
| 29 | +- **Validation:** `pydantic>=2.7`. `jsonschema` only when validating against external JSON schemas. |
| 30 | +- **Lint/format:** `ruff` (line=120). `ruff format --check .` is part of pre-commit. |
| 31 | +- **Types:** `mypy --strict`. |
| 32 | +- **Dead code / static health:** `vulture --min-confidence 90`. The whitelist file `.vulture_whitelist.py` MUST be included in every invocation (it allowlists Protocol-method parameter names and context-manager dunder args). Use the `[tool.vulture]` config (`uv run vulture`) or pass it explicitly: `uv run vulture atomicmemory tests .vulture_whitelist.py --min-confidence 90`. `fallow` is TypeScript-only and is not part of this repo's verification. |
| 33 | +- **Tests:** `pytest`, `pytest-asyncio`, `pytest-mock`, `respx`. Integration tests gated behind `-m integration`. |
| 34 | + |
| 35 | +## Code rules |
| 36 | + |
| 37 | +- File ≤400 lines (excl. comments/docstrings); function ≤40 lines (excl. catch/finally and docstrings); test files ≤400 lines; tests ≤40 lines. |
| 38 | +- Google-style docstrings (`Args:`, `Returns:`, `Raises:`). |
| 39 | +- Module docstring at the top of every file. For modules that port a specific TS file, include the TS source-of-truth path (`"""Port of atomicmemory-sdk/src/.../foo.ts."""`). |
| 40 | +- No fallback values; no `os.getenv` in business code (config flows through Pydantic models constructed at startup). |
| 41 | +- No silent `except`. No bare `except:`. |
| 42 | +- Greenfield code — no backwards-compat hacks, no `_` private renames for "removed" code. |
| 43 | +- Snake_case for Python attributes; Pydantic `Field(alias="apiUrl")` aliases preserve TS camelCase wire format. |
| 44 | +- Keep public API behavior aligned with `atomicmemory-sdk` where both SDKs expose the same concept. |
| 45 | +- Prefer integration tests with a real HTTP path for client behavior; use mocks only for narrow transport errors. |
| 46 | + |
| 47 | +## Pre-commit verification |
| 48 | + |
| 49 | +Run before opening any PR: |
| 50 | + |
| 51 | +```bash |
| 52 | +uv sync |
| 53 | +uv run ruff check . |
| 54 | +uv run ruff format --check . |
| 55 | +uv run mypy atomicmemory --strict |
| 56 | +uv run vulture atomicmemory tests .vulture_whitelist.py --min-confidence 90 |
| 57 | +uv run pytest |
| 58 | +``` |
| 59 | + |
| 60 | +All must be green. |
| 61 | + |
| 62 | +## Branching |
| 63 | + |
| 64 | +- `main` is protected; commit only via PR. |
| 65 | +- Per-phase work lands on `feat/phase-N-<slug>` branches. |
0 commit comments