docs: add agent-oriented knowledge base (AGENTS.md + .kb/) - #522
Conversation
hammerstefan
left a comment
There was a problem hiding this comment.
This is a great initiative, helps agents and humans. I raised my eyebrows at some architectural smells this exposes 😄 .
I left a few minor comments around the cloud/areas that I know enough about to be able to find potential issues while skimming.
None of my feedback is blocking.
|
|
||
| # Important | ||
|
|
||
| - The OCI CLI must be initialized first (see the launch doc referenced in `oci/cloud.py`'s docstring). `compartment_id` falls back to `oci iam compartment get` via the CLI; failure raises `CloudSetupError`. |
There was a problem hiding this comment.
I don't think this is true in a strict sense. OCI CLI only has to be initialized if you need pycloudlib to fall back on locally configured defaults for users of the oci tool.
I'd be afraid that absolute statements like this will cause the agents to chase red herrings (trying to install/init oci themselves when they are running in a sandbox without oci installed).
There was a problem hiding this comment.
Good point, I've updated the docs for clarity for this pass with the following diff
diff --git a/.kb/adding-a-cloud.md b/.kb/adding-a-cloud.md
index e22cad8..1265227 100644
--- a/.kb/adding-a-cloud.md
+++ b/.kb/adding-a-cloud.md
@@ -12,7 +12,7 @@ A new backend is a subpackage under `pycloudlib/<cloud>/` providing a concrete `
# Important
-1. **Subpackage** `pycloudlib/<cloud>/` with `__init__.py`, `cloud.py` (`<Cloud>(BaseCloud)`), `instance.py` (`<Cloud>Instance(BaseInstance)`). Add `errors.py`/`util.py`/`vpc.py` only if needed; cloud-specific exceptions MUST inherit from `PycloudlibException` (root in `pycloudlib/errors.py`).
+1. **Subpackage** `pycloudlib/<cloud>/` with `__init__.py`, `cloud.py` (`<Cloud>(BaseCloud)`), `instance.py` (`<Cloud>Instance(BaseInstance)`). Add `errors.py`/`util.py` only if needed; cloud-specific exceptions MUST inherit from `PycloudlibException` (root in `pycloudlib/errors.py`).
2. **Implement every abstract method** of `BaseCloud` and `BaseInstance` (read `cloud.py`/`instance.py` for the list). If a method is genuinely unsupported, raise `PycloudlibError` (see `Openstack.released_image`).
3. **Register the class** in `pycloudlib/__init__.py` (import + `__all__` entry).
4. **Add SDK deps** to `pyproject.toml` `[project.dependencies]` and, if the SDK lacks type stubs, add it to the `[[tool.mypy.overrides]] ignore_missing_imports` list. Prefer strict typing where possible.
diff --git a/pycloudlib/oci/.kb/oci.md b/pycloudlib/oci/.kb/oci.md
index e2b21e4..07f08aa 100644
--- a/pycloudlib/oci/.kb/oci.md
+++ b/pycloudlib/oci/.kb/oci.md
@@ -7,7 +7,7 @@ Read the top-level `.kb/agents.md` file before continuing below.
# Overview
-`OCI(BaseCloud)` authenticates via the `oci` SDK using `~/.oci/config` (CLI-initialized), a config dict, or env vars; `OciInstance(BaseInstance)` wraps a compute instance. OCI uses availability domains, compartments, and VCNs.
+`OCI(BaseCloud)` authenticates via the `oci` python SDK reading pycloudlib.toml oci.confg_path value or falling back to `~/.oci/config` (CLI or SDK initialized), a config dict, or env vars; `OciInstance(BaseInstance)` wraps a compute instance. OCI uses availability domains, compartments, and VCNs.
# Important|
|
||
| # Overview | ||
|
|
||
| Unit tests (`tests/unit_tests/`) are hermetic and mocked, run on every PR across Python 3.8/3.10/3.12. Integration tests (`tests/integration_tests/`) exercise real cloud APIs, require credentials, and are marker-gated; they run in dedicated tox envs, not the default `tox`. |
There was a problem hiding this comment.
out of scope: we should probably start testing 3.14 as well since that's in 26.04
There was a problem hiding this comment.
Agreed, let's take it to a separate PR.
rpocase
left a comment
There was a problem hiding this comment.
nothing blocking here - looks great and i really like this. it's great to see a full example. i haven't seen anything fully adopt it yet.
how was this generated? i would like to extract this to some larger repositories too.
| @@ -0,0 +1,44 @@ | |||
| # Preface | |||
|
|
|||
| pycloudlib is a Python library (Python >=3.8) that launches, interacts with, and snapshots Ubuntu cloud instances across many public and private clouds through a uniform `BaseCloud` / `BaseInstance` abstraction. This file is relevant to any task touching the source tree, build, tests, docs, or examples. | |||
There was a problem hiding this comment.
ideally should merge #508 first and change the python ref to 3.10. not a blocker though (can change in that branch if we land later)
There was a problem hiding this comment.
While I agree it may have been nice to see this changset in #508 land, I kindof also would like to see the kb articles be automatically updated by an agent after this PR lands too. @rpocase if you get a chance on #508 during addressing the review comments, can you rebase against tip of main to get the.kb articles and ask an agent to update any relevant kb articles due to current changes so we can see how this works in practice?
|
|
||
| # Overview | ||
|
|
||
| pycloudlib uses `uv` (wrapped by a thin `Makefile`) and `tox` for the multi-check workflow. Supported Python range is >=3.8; CI covers 3.8/3.10/3.12. ruff handles lint+format, mypy handles typing, pytest runs unit tests with `--doctest-modules`. |
There was a problem hiding this comment.
again, python version constraints if we merge #508
There was a problem hiding this comment.
+1 we need this changed, but I want an agent to do that as part of #508 if we can so we can review a known expected .kb delta as part of the PR.
| # Important | ||
|
|
||
| - After editing any Python in `pycloudlib/` or `examples/`, run ruff and mypy. Prefer `make test` (full tox) or the individual tox envs defined in `tox.ini`. | ||
| - Default `tox` envlist only **checks** (does not reformat): `ruff`, `mypy`, `py38`. Use `tox -e format` to apply formatting. |
|
|
||
| # Overview | ||
|
|
||
| `VMWare(BaseCloud)` shells out to `govc` (the govmomi CLI, not an SDK) against a vSphere endpoint; `VMWareInstance(BaseInstance)` wraps a VM. Image selection maps Ubuntu series to pre-uploaded VM templates. |
There was a problem hiding this comment.
are there any specific vsphere version constraints? govc officially supports 7.0, but i'm not familiar with the implementation to know if pycloudlib only exposes a subset of features.
Thanks @rpocase and @hammerstefan. Initial prompt with your favorite AI harness to generate intiial structured docs based on it's own assessment of the repo conventions/practices/architecture:
3B: Remove too detailed 'specs' from kb docs for stuff that is documented by the class APIs anyway
|
d69083d to
ee75954
Compare
Adopt the canonical-agents convention: AGENTS.md directory indexes and distilled .kb/*.md knowledge notes spanning the dev workflow, configuration, BaseCloud/BaseInstance architecture, per-cloud backend specifics, testing, examples, and Sphinx docs. Content describes architecture and references self-documenting source modules rather than restating method signatures.
ee75954 to
ed79bca
Compare
Description
Adopt the canonical-agents convention: AGENTS.md directory indexes and
distilled .kb/*.md knowledge notes spanning the dev workflow, configuration,
BaseCloud/BaseInstance architecture, per-cloud backend specifics, testing,
examples, and Sphinx docs. Content describes architecture and references
self-documenting source modules rather than restating method signatures.
Additional Context and Relevant Issues
Test Steps
Prompt your favorite AI harness CLI or IDE and watch it reference .kb files to better inform
the agent with minimal context. Expectation of reduced token use and workload wall time for
agent-driven requests on this repository.