|
| 1 | +# Agent guide (PolyKin) |
| 2 | + |
| 3 | +This repository is a Python package (src-layout) built and tested via `uv`. |
| 4 | +This document is written for automated coding agents and human maintainers who want |
| 5 | +consistent, low-friction changes. |
| 6 | + |
| 7 | +## Ground rules |
| 8 | + |
| 9 | +- Keep changes minimal and scoped to the user request. |
| 10 | +- Prefer repo-standard tooling and commands (see below) so CI matches local runs. |
| 11 | +- Do not change `README.md` unless explicitly requested. |
| 12 | +- Avoid editing generated content under `docs/generated/`. |
| 13 | +- When making behavioral changes, add or update tests under `tests/`. |
| 14 | + |
| 15 | +## Repo layout |
| 16 | + |
| 17 | +- Source: `src/polykin/` |
| 18 | +- Tests: `tests/` (mirrors package subdomains like `thermo/`, `kinetics/`, etc.) |
| 19 | +- Docs (MkDocs Material): `docs/` (includes tutorial notebooks under `docs/tutorials/`) |
| 20 | +- CI workflows: `.github/workflows/` |
| 21 | + |
| 22 | +## Supported Python |
| 23 | + |
| 24 | +- Python >= 3.10 (see `pyproject.toml`). |
| 25 | + |
| 26 | +## Setup (recommended: uv) |
| 27 | + |
| 28 | +CI uses `uv sync` with `uv.lock`. |
| 29 | + |
| 30 | +### Windows (PowerShell) |
| 31 | + |
| 32 | +```powershell |
| 33 | +# From repo root |
| 34 | +pip install uv |
| 35 | +uv sync |
| 36 | +``` |
| 37 | + |
| 38 | +### macOS/Linux (bash) |
| 39 | + |
| 40 | +```bash |
| 41 | +pip install uv |
| 42 | +uv sync |
| 43 | +``` |
| 44 | + |
| 45 | +## Run tests |
| 46 | + |
| 47 | +### Full test suite |
| 48 | + |
| 49 | +```powershell |
| 50 | +uv run --frozen pytest |
| 51 | +``` |
| 52 | + |
| 53 | +### Run a subset |
| 54 | + |
| 55 | +```powershell |
| 56 | +uv run --frozen pytest tests/thermo |
| 57 | +uv run --frozen pytest -k "flash" -q |
| 58 | +``` |
| 59 | + |
| 60 | +### Disable Numba JIT (useful for determinism / faster CI-style coverage) |
| 61 | + |
| 62 | +CI runs a second pass with JIT disabled. |
| 63 | + |
| 64 | +```powershell |
| 65 | +$env:NUMBA_DISABLE_JIT = "1" |
| 66 | +uv run --frozen pytest |
| 67 | +``` |
| 68 | + |
| 69 | +To re-enable in the same shell: |
| 70 | + |
| 71 | +```powershell |
| 72 | +Remove-Item Env:NUMBA_DISABLE_JIT -ErrorAction SilentlyContinue |
| 73 | +``` |
| 74 | + |
| 75 | +## Linting and formatting |
| 76 | + |
| 77 | +Project config lives in `pyproject.toml`. |
| 78 | + |
| 79 | +- Ruff (lint): |
| 80 | + |
| 81 | +```powershell |
| 82 | +uv run ruff check . |
| 83 | +``` |
| 84 | + |
| 85 | +- Ruff (format): |
| 86 | + |
| 87 | +```powershell |
| 88 | +uv run ruff format . |
| 89 | +``` |
| 90 | + |
| 91 | +If you change imports or add new modules, ensure Ruff import rules pass. |
| 92 | + |
| 93 | +### (Optional) pre-commit hooks |
| 94 | + |
| 95 | +This repo includes a `.pre-commit-config.yaml` that runs Ruff lint and format via `uv`. |
| 96 | + |
| 97 | +```powershell |
| 98 | +uv run --frozen pre-commit install |
| 99 | +uv run --frozen pre-commit run --all-files |
| 100 | +``` |
| 101 | + |
| 102 | +## Documentation build |
| 103 | + |
| 104 | +Docs build in CI using the `docs` dependency group: |
| 105 | + |
| 106 | +```powershell |
| 107 | +uv sync --group docs |
| 108 | +uv run mkdocs build -d _site |
| 109 | +``` |
| 110 | + |
| 111 | +## Change workflow (agent-friendly) |
| 112 | + |
| 113 | +1. Identify the smallest set of files needed. |
| 114 | +2. Implement the change. |
| 115 | +3. Run targeted tests first, then the full suite if the change is broad. |
| 116 | +4. Run `ruff check .` and `ruff format .` if you changed Python files. |
| 117 | +5. If docs are affected, run `mkdocs build`. |
| 118 | + |
| 119 | +## Conventions |
| 120 | + |
| 121 | +- Keep functions/classes type-annotated where practical. |
| 122 | +- Docstrings follow NumPy-style conventions (Ruff pydocstyle is enabled). |
| 123 | +- Respect the repo line length (90) when formatting. |
| 124 | +- Avoid adding new heavy dependencies without a clear need. |
| 125 | + |
| 126 | +## CI parity notes |
| 127 | + |
| 128 | +CI runs: |
| 129 | + |
| 130 | +- `uv sync` (both highest and lowest-direct resolution) |
| 131 | +- `pytest` with and without Numba JIT |
| 132 | +- docs build via `mkdocs build` |
| 133 | + |
| 134 | +When you need to replicate a CI failure locally, prefer running the exact `uv run --frozen ...` command. |
0 commit comments