Skip to content

Commit e464eb7

Browse files
committed
docs: add Agent Guide with source of truth, architecture, testing, and PR guidelines
1 parent 2020c67 commit e464eb7

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Agent Guide
2+
3+
## Source of Truth
4+
5+
- This is the official synchronous Python SDK for the Linode API. Supported
6+
Python versions come from [pyproject.toml](pyproject.toml) (`>=3.10`); do not
7+
infer support from the older environment names still present in [tox.ini](tox.ini).
8+
- Make changes only in canonical source trees such as `linode_api4/`, `test/`,
9+
`docs/`, `examples/`, and `.github/`. Do not edit generated copies or output in
10+
`build/`, `dist/`, `docs/build/`, `docs/_build/`, or `linode_api4.egg-info/`.
11+
- `linode_api4/version.py` is generated by `make create-version` and `make build`.
12+
Do not hand-edit it for ordinary feature work.
13+
- Use [README.rst](README.rst) for setup and test details and
14+
[CONTRIBUTING.md](CONTRIBUTING.md) for contribution policy. Keep this file
15+
limited to guidance that is easy to miss while navigating the repository.
16+
17+
## Architecture and Implementation
18+
19+
- `linode_api4/linode_client.py` owns HTTP behavior and wires API groups onto
20+
`LinodeClient`; `linode_api4/groups/` exposes operations; `linode_api4/objects/`
21+
defines resource models; `linode_api4/paginated_list.py` handles collection
22+
pagination.
23+
- Follow the nearest existing group method, model, and unit test before adding a
24+
new pattern. Collection methods normally use `client._get_and_filter(...)`;
25+
create/update/delete methods use the client's request helpers and return model
26+
objects where appropriate.
27+
- Models are lazy-loaded, and reading an unknown or stale property may issue an
28+
API request. Read [docs/guides/core_concepts.rst](docs/guides/core_concepts.rst)
29+
before changing model properties, relationships, filtering, or pagination.
30+
- New public models must be exported from `linode_api4/objects/__init__.py`. New
31+
groups must be exported from `linode_api4/groups/__init__.py` and wired into
32+
`LinodeClient`. Preserve public API compatibility unless the task explicitly
33+
requires a breaking change.
34+
- Public behavior belongs in Sphinx-compatible docstrings and, when needed, the
35+
source files under `docs/`. Never edit rendered documentation.
36+
37+
## Tests
38+
39+
- Start with the narrowest relevant unit test, for example
40+
`python -m pytest test/unit/objects/linode_test.py -k test_name`. Run
41+
`make test-unit` for the full mocked unit suite.
42+
- Unit tests normally extend `test.unit.base.ClientBaseCase`. GET requests are
43+
resolved from JSON under `test/fixtures/`; use `mock_post`, `mock_put`, and
44+
`mock_delete` for other verbs and assert the captured URL, body, or headers.
45+
- Fixture names encode endpoint paths: a single underscore becomes `/`, while a
46+
doubled underscore becomes a literal `_`. Paginated fixtures containing
47+
`results` also provide per-ID responses automatically when items include an
48+
`id` field. See
49+
`test/unit/fixtures.py` before inventing custom request mocking.
50+
- `make test-int` and `make test-smoke` call the live Linode API, require
51+
`LINODE_TOKEN`, and may create or delete real resources. Run them only when the
52+
change requires live validation and the environment is intentionally configured.
53+
54+
## Formatting and Validation
55+
56+
- Install development dependencies with `make dev-install`.
57+
- Formatting is Black + isort + autoflake with settings in [pyproject.toml](pyproject.toml).
58+
`make format` rewrites all of `linode_api4/` and `test/`, so review the worktree
59+
before and after using it for a focused change.
60+
- `make lint` is the broad CI-equivalent check: it builds distributions, checks
61+
formatting/imports, runs pylint, and validates package metadata. Prefer focused
62+
tests first because this target regenerates build artifacts and version metadata.
63+
64+
## Pull Requests
65+
66+
- Target the `dev` branch unless the task specifies otherwise.
67+
- PR titles must use `TPT-1234: Description`; CI exempts only the labels documented
68+
in [.github/workflows/ci.yml](.github/workflows/ci.yml).
69+
- Keep changes focused, add tests for behavior changes, and use
70+
[.github/pull_request_template.md](.github/pull_request_template.md) when drafting
71+
the PR description.

0 commit comments

Comments
 (0)