|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Modules |
| 4 | +- Core code lives in `pyth_observer/`: CLI entrypoint in `cli.py`, check logic under `check/`, alert dispatchers in `dispatch.py`, event types in `event.py`, and HTTP probes in `health_server.py`. |
| 5 | +- Supporting assets and defaults: sample configs (`sample.config.yaml`, `sample.publishers.yaml`, `sample.coingecko.yaml`), Dockerfile for container builds, and helper scripts in `scripts/` (e.g., `build_coingecko_mapping.py`). |
| 6 | +- Tests are in `tests/` and mirror module names (`test_checks_price_feed.py`, `test_checks_publisher.py`). |
| 7 | + |
| 8 | +## Setup, Build & Run |
| 9 | +- Use Python 3.11 with Poetry 2.x. Suggested bootstrap: `poetry env use $(which python)` then `poetry install`. |
| 10 | +- Common Make targets: `make setup` (install deps), `make run` (devnet run), `make test`, `make cover`, `make lint`, `make clean`. |
| 11 | +- Direct commands: `poetry run pyth-observer --config sample.config.yaml --publishers sample.publishers.yaml --coingecko-mapping sample.coingecko.yaml` to run locally; add `-l debug` for verbose logs. |
| 12 | +- CoinGecko mapping: `poetry run python scripts/build_coingecko_mapping.py -o my_mapping.json` and compare with `-e sample.coingecko.yaml` before replacing defaults. |
| 13 | + |
| 14 | +## Testing Guidelines |
| 15 | +- Framework: `pytest`. Quick check with `poetry run pytest`; coverage report via `make cover` (writes `htmlcov/`). |
| 16 | +- Keep tests colocated under `tests/` with `test_*` naming. Prefer async tests for async code paths and mock network calls. |
| 17 | +- Add regression tests alongside new checks or dispatch paths; include sample config fragments when useful. |
| 18 | + |
| 19 | +## Coding Style & Naming |
| 20 | +- Auto-format with `black` and import order via `isort` (run together with `make lint`). Lint also runs `pyright` and `pyflakes`. |
| 21 | +- Target Python 3.11; favor type hints on public functions and dataclasses/models. Use snake_case for functions/variables, PascalCase for classes, and uppercase for constants. |
| 22 | +- Keep config keys consistent with existing YAML samples; avoid hard-coding secrets—read from env vars. |
| 23 | + |
| 24 | +## Commit & PR Practices |
| 25 | +- Follow the existing Conventional Commit style (`fix:`, `chore:`, `refactor!:`, etc.) seen in `git log`. |
| 26 | +- PRs should summarize behavior changes, link issues, and include reproduction or validation steps (commands run, configs used). Add screenshots only when output formatting changes. |
| 27 | +- Keep diffs small and focused; update sample config or docs when user-facing options change. |
| 28 | + |
| 29 | +## Configuration & Security Notes |
| 30 | +- Sensitive values (API keys, tokens) must be supplied via environment variables; never commit them. Use `.env` locally and document new keys in `README.md`. |
| 31 | +- For deployments, wire liveness/readiness probes to `GET /live` and `GET /ready` on port 8080. |
0 commit comments