Skip to content

Commit 2f502b4

Browse files
authored
Merge pull request #52 from ayhammouda/chore/v0.3.0-agent-pipeline
chore(v0.3.0): scaffold autonomous-agent pipeline
2 parents 9d6fc7d + 5949b0d commit 2f502b4

21 files changed

Lines changed: 1920 additions & 0 deletions

.coderabbit.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
2+
language: "en-US"
3+
4+
reviews:
5+
profile: "chill"
6+
request_changes_workflow: false
7+
high_level_summary: true
8+
review_status: true
9+
path_filters:
10+
- "src/**"
11+
- "tests/**"
12+
path_instructions:
13+
- path: "src/**"
14+
instructions: |
15+
Focus review on correctness, MCP tool behavior, runtime compatibility,
16+
cache/index compatibility, packaging impact, and security boundaries.
17+
Avoid comments about planning docs, release docs, or repository process
18+
unless the changed source code makes those docs materially inaccurate.
19+
- path: "tests/**"
20+
instructions: |
21+
Focus review on meaningful assertions, regression coverage, fixture
22+
correctness, deterministic behavior, and avoiding network- or
23+
environment-dependent tests unless the test is explicitly marked as an
24+
integration smoke test.

.github/CODEOWNERS

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# CODEOWNERS — forces maintainer review on forbidden-territory paths.
2+
#
3+
# Source of truth: AGENT-EXECUTION-PIPELINE.md §2 (Forbidden Territory),
4+
# required by §10 (Pre-flight Checklist).
5+
#
6+
# For these rules to be ENFORCED, branch protection on `main` must enable
7+
# "Require review from Code Owners". CODEOWNERS alone only requests review;
8+
# branch protection is what blocks merge.
9+
#
10+
# Autonomous agents may NOT modify these paths without explicit human approval
11+
# (pipeline §2). Any agent PR touching them must add the `🛑 needs-human-review`
12+
# label and stop short of requesting merge (pipeline §7).
13+
14+
# --- Project identity, dependencies, classifiers (only `version` is agent-editable) ---
15+
/pyproject.toml @ayhammouda
16+
17+
# --- Permanent commitments and trust posture ---
18+
/LICENSE @ayhammouda
19+
/SECURITY.md @ayhammouda
20+
21+
# --- Load-bearing brand assets ---
22+
/README.md @ayhammouda
23+
/.planning/POSITIONING.md @ayhammouda
24+
25+
# --- Release history (adding entries is fine; rewriting history is not) ---
26+
/CHANGELOG.md @ayhammouda
27+
28+
# --- CI/CD and supply chain (release path especially) ---
29+
# The single /.github/ rule covers workflows and release.yml. Last-matching-
30+
# pattern wins in CODEOWNERS — adding narrower entries with the same owner
31+
# below would be no-ops and would silently *override* this rule if a different
32+
# owner is ever added here, so we keep ownership of /.github/ uniform.
33+
/.github/ @ayhammouda
34+
35+
# --- Index schema and migrations (rebuilds existing user indexes) ---
36+
# NOTE: the retrieved-docs *cache* table lives in
37+
# src/mcp_server_python_docs/services/persistent_cache.py and is NOT covered
38+
# here — it is best-effort, fingerprint-scoped, and agent-editable per
39+
# decision 5.7. Only the canonical *index* schema is forbidden territory.
40+
**/storage/schema.sql @ayhammouda
41+
**/migrations/ @ayhammouda
42+
43+
# --- Archival roadmap history ---
44+
/.planning/ROADMAP.md @ayhammouda
45+
46+
# --- Governing policy + strategy documents ---
47+
/AGENT-EXECUTION-PIPELINE.md @ayhammouda
48+
/OPENCLAW-FORGE-PROTOCOL.md @ayhammouda
49+
/STRATEGIC-ROADMAP-2026-05-29.md @ayhammouda
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Autonomous Agent Task
2+
description: A task spec scoped for unattended execution by an autonomous coding agent (Claude Code or similar).
3+
title: "[vX.Y.Z] <scope> — <verb> <thing>"
4+
body:
5+
- type: markdown
6+
attributes:
7+
value: |
8+
This template enforces the issue structure required by
9+
`AGENT-EXECUTION-PIPELINE.md` §3 (in the repo root). An issue missing
10+
any required section is **not** agent-ready and will not pass the §10
11+
pre-flight checklist. Do not apply the `agent-ready` label from this
12+
template; a maintainer applies it only after reading the completed
13+
issue end-to-end. Read the pipeline doc and
14+
`STRATEGIC-ROADMAP-2026-05-29.md` before filling this out.
15+
- type: textarea
16+
id: context
17+
attributes:
18+
label: Context (self-containment)
19+
description: Link to the per-issue context file, this pipeline doc, the roadmap, any relevant ADR or `.planning/phases/0X-*` directory, and prior related issues.
20+
value: |
21+
- Per-issue context file: `.planning/agent-context/<issue-slug>.md` (read this first)
22+
- Pipeline: `AGENT-EXECUTION-PIPELINE.md`
23+
- Roadmap: `STRATEGIC-ROADMAP-2026-05-29.md` §<section>
24+
- Related issues:
25+
validations:
26+
required: true
27+
- type: textarea
28+
id: goal
29+
attributes:
30+
label: Goal (one sentence)
31+
description: The single outcome that counts as success.
32+
validations:
33+
required: true
34+
- type: textarea
35+
id: acceptance
36+
attributes:
37+
label: Acceptance criteria (testable checkbox list)
38+
description: Each criterion must be testable, atomic, achievable without touching forbidden territory, and verifiable in <5 minutes (pipeline §4). Prefer exact commands and expected output.
39+
value: |
40+
- [ ] `<exact command>` <expected result>
41+
- [ ] `<exact command>` <expected result>
42+
validations:
43+
required: true
44+
- type: textarea
45+
id: scope
46+
attributes:
47+
label: Scope boundaries
48+
description: Explicit In scope / Out of scope. Out-of-scope work is a stop-and-comment trigger, never silent expansion.
49+
value: |
50+
**In scope:**
51+
-
52+
53+
**Out of scope:**
54+
-
55+
validations:
56+
required: true
57+
- type: textarea
58+
id: forbidden
59+
attributes:
60+
label: Forbidden-territory reminders
61+
description: Repeat the AGENT-EXECUTION-PIPELINE.md §2 items relevant to THIS issue. If the task appears to require touching any of them, stop and comment.
62+
validations:
63+
required: true
64+
- type: textarea
65+
id: validation
66+
attributes:
67+
label: Validation commands (pipeline §5 gate)
68+
description: The exact canonical gate, in order, plus any change-type-specific gates. Must pass before any PR is opened.
69+
value: |
70+
```bash
71+
uv run ruff check src/ tests/
72+
uv run pyright src/
73+
uv run pytest --tb=short -q
74+
uv run python-docs-mcp-server doctor
75+
```
76+
validations:
77+
required: true
78+
- type: textarea
79+
id: pr-and-recovery
80+
attributes:
81+
label: PR requirements & recovery
82+
description: What the PR description must include (pipeline §6) and where to go if blocked (pipeline §8).
83+
value: |
84+
- PR title matches this issue title verbatim; body uses
85+
`.github/PULL_REQUEST_TEMPLATE/agent.md`.
86+
- Branch: `agent/<issue-number>-<kebab-summary>`.
87+
- If blocked: stop, write `WORKING-NOTES.md` on the branch, comment on
88+
this issue per pipeline §8. **No PR, no auto-merge, ever.**
89+
validations:
90+
required: true
91+
- type: input
92+
id: effort
93+
attributes:
94+
label: Effort estimate (hours)
95+
description: Rough hours. Agent must bail and escalate if work exceeds 2× this estimate (pipeline §8).
96+
validations:
97+
required: true
98+
- type: checkboxes
99+
id: acknowledgements
100+
attributes:
101+
label: Agent acknowledgements
102+
options:
103+
- label: I will work on a branch, never on `main`, and will not auto-merge.
104+
required: true
105+
- label: I will stop and comment rather than silently expand scope or touch forbidden territory.
106+
required: true
107+
- label: I will add `🛑 needs-human-review` if any pipeline §7 trigger fires.
108+
required: true
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!--
2+
Autonomous-agent PR template. Enforces AGENT-EXECUTION-PIPELINE.md §6.
3+
PR title MUST match the issue title verbatim. Never request auto-merge.
4+
-->
5+
6+
Closes #<issue-number>
7+
8+
## Acceptance criteria
9+
<!-- Copy every criterion from the issue. Check the box only when satisfied,
10+
and add one line of evidence (command + observed result) per item. -->
11+
- [ ] <criterion 1> — <evidence>
12+
- [ ] <criterion 2> — <evidence>
13+
14+
## Validation gate output
15+
<!-- Paste the tail of each gate command. All must be green before opening this PR. -->
16+
```text
17+
$ uv run ruff check src/ tests/
18+
$ uv run pyright src/
19+
$ uv run pytest --tb=short -q
20+
$ uv run python-docs-mcp-server doctor
21+
```
22+
<!-- Plus any change-type-specific gates from pipeline §5 (stdio smoke,
23+
validate-corpus, uv lock --check) that applied to this change. -->
24+
25+
## CodeRabbit review
26+
<!-- After CodeRabbit comments, summarize findings as:
27+
- Blocking: <items or None>
28+
- Follow-up: <items or None>
29+
- False positive: <items or None>
30+
If CodeRabbit has not run yet, write "Pending." Do not mark findings green
31+
by silence. -->
32+
Pending.
33+
34+
## Why this approach
35+
<!-- One paragraph max. If the issue fully prescribed the approach, say so.
36+
If you cite a design choice NOT in the issue, that is a §7 trigger. -->
37+
38+
## Why this triggered human review
39+
<!-- List any pipeline §7 triggers and explain each. If none, write "None."
40+
If any fired: this PR is opened for review only — do NOT request merge,
41+
and ensure the `🛑 needs-human-review` label is applied. -->
42+
None.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Agent Context — ADR-001 (Source Adapters)
2+
3+
> One-read working context for issue `[v0.3.0] docs — write ADR-001 (Source Adapters)`.
4+
> A **writing** task. Every claim must match the code — verify before you assert.
5+
6+
## 1. Roadmap excerpts (the principles you are recording)
7+
8+
- **Principle 2.1:** Canonical source only. CPython at a pinned tag for stdlib
9+
docs; PyPI metadata API for package URLs. No scraped mirrors. No third-party indexers.
10+
- **Principle 2.2:** Offline-first *runtime*. No network access at query time.
11+
- **Principle 2.7:** Layered design with stable contracts; the **source
12+
connector** is layer 1 of 8 and is what makes the pattern cloneable.
13+
14+
## 2. The two source adapters that exist today (describe these)
15+
16+
1. **CPython documentation source** (`src/mcp_server_python_docs/ingestion/`):
17+
- `cpython_versions.py` — pinned build targets (`CPYTHON_DOCS_BUILD_CONFIG`:
18+
per-version `tag` + `sphinx_pin`). Five versions: 3.10–3.14.
19+
- `__main__.py` `build-index` path — `git clone --depth 1 --branch <tag>` of
20+
`python/cpython`, builds docs with `sphinx-build -b json` in a dedicated venv.
21+
- `sphinx_json.py` — parses the Sphinx JSON output into the index; also loads
22+
`synonyms.yaml`. `inventory.py` — parses `objects.inv` for exact symbol resolution.
23+
2. **PyPI metadata source** (`src/mcp_server_python_docs/services/package_docs.py`):
24+
- Backs `lookup_package_docs`. A **controlled** PyPI metadata lookup
25+
(`GET /pypi/<project>/json`) that returns only project/docs/homepage/source
26+
URLs — not a generic web fetch, not scraped docs.
27+
28+
## 3. The one documented exception to "offline-first"
29+
30+
- `lookup_package_docs` performs a network call to PyPI's metadata API. This is
31+
**not** a docs-*query*-time call against the canonical stdlib index — it is a
32+
controlled, narrowly-scoped metadata lookup. The ADR must state this exception
33+
explicitly so the offline-first invariant (2.2) stays honest. (See README's
34+
"Why not Context7" section and `SECURITY.md` scope for the existing framing.)
35+
36+
## 4. Known pitfalls
37+
38+
- **Verify, don't assume.** Open each cited file and confirm the behavior before
39+
writing it into the ADR. An ADR that misstates current behavior is worse than none.
40+
- Don't document adapters that don't exist (Rust/Go) beyond a single "future
41+
adopters clone this contract" sentence — that's the cloneability point, not a claim.
42+
- No code, schema, or workflow changes — writing only.
43+
- Keep it factual; "reference architecture" is not claimed externally (5.6).
44+
45+
## 5. Decision log
46+
47+
- File path:
48+
- Claims you verified against code (file:line):
49+
- Anything ambiguous about the layer contract that you flagged for the maintainer:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Agent Context — ADR-006 (Serialization)
2+
3+
> One-read working context for issue `[v0.3.0] docs — write ADR-006 (Serialization)`.
4+
> This is a **writing** task. You are recording locked decisions, not making new ones.
5+
6+
## 1. Roadmap excerpts (the decisions you are recording — verbatim)
7+
8+
- **Principle 2.5:** Wire format is explicit and pluggable on structured tools
9+
only. Compact JSON default; TOON opt-in *if and only if* the empirical study
10+
supports it. `get_docs` stays markdown. *Token economy is empirical, not architectural.*
11+
- **Principle 2.7:** Layered design with stable contracts — eight layers, the
12+
**serializer** being one of them.
13+
- **Decision 5.3:** Storage stays SQLite + markdown. **TOON-as-storage killed.**
14+
- **Decision 5.4:** Empirical Claude-tokenizer study **gates** the `format="toon"` decision.
15+
- **Decision 5.5:** `format` parameter on `search_docs`, `list_versions`,
16+
`compare_versions` **only**. JSON default; TOON opt-in. `get_docs` stays markdown.
17+
- **Decision 5.8:** The study measures **client-side rewrap**, not just raw
18+
payload tokens; reports tokens AND latency per tool family.
19+
20+
## 2. Code touch-points (for accuracy — describe, do NOT change)
21+
22+
- Tool results are Pydantic models in `src/mcp_server_python_docs/models.py`
23+
(e.g. `GetDocsResult`); tools live in `server.py` and return those models,
24+
which FastMCP serializes. The "serializer layer" is the conceptual seam where
25+
a structured result becomes a wire string — that's what the `format` parameter
26+
will eventually parameterize. You are documenting that seam, not building it.
27+
- `get_docs` returns markdown content (`GetDocsResult.content`) — this is why it
28+
is carved out of the `format` parameter (markdown is already the canonical body).
29+
30+
## 3. Pattern to follow
31+
32+
- There is no `docs/architecture/` ADR yet — you are establishing the house
33+
style. Use the exact skeleton embedded in the issue. Keep it tight (1–2 pages).
34+
- Number/name the file `docs/architecture/ADR-006-serialization.md` to match the
35+
roadmap's ADR numbering (ADR-001 and ADR-006 are the first two written).
36+
37+
## 4. Known pitfalls
38+
39+
- **Do not invent.** If you find yourself making a serialization choice that is
40+
not in §2 above, that's a pipeline §7 trigger ("cites a design choice not in
41+
the issue") — stop and comment.
42+
- **Do not implement `format`.** That is v0.3.x and is gated by the study.
43+
- Don't claim a TOON token win — the study hasn't run. The ADR records that TOON
44+
is *opt-in and gated*, with the bar being "win holds after client rewrap" (5.8).
45+
- "Reference architecture" is **not** claimed externally (decision 5.6) — keep
46+
the ADR factual, not promotional.
47+
48+
## 5. Decision log
49+
50+
- Final file path:
51+
- Any wording you were unsure mapped to a locked decision (and how you resolved it):
52+
- Open follow-ups (e.g. link to TOKEN-STUDY.md once it exists):
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Agent Context — CPython source SHA pin
2+
3+
> One-read working context for issue `[v0.3.0] ingestion — pin CPython source by commit SHA`.
4+
> PARTIAL issue: you do the pin + verification; the human writes the SECURITY.md prose.
5+
6+
## 1. Roadmap excerpt
7+
8+
> **Build-time supply-chain hardening** (roadmap §4, v0.3.0): Pin CPython source
9+
> by SHA, not by tag. Document the threat model in SECURITY.md (the `build-index`
10+
> CPython clone is the largest non-runtime attack surface). Verify Sphinx-build
11+
> environment isolation.
12+
>
13+
> **Decision 5.10 (locked):** Build-time supply chain (the `build-index` CPython
14+
> clone) is an explicit risk area; threat model documented in SECURITY.md;
15+
> CPython source pinned by SHA.
16+
17+
## 2. Code touch-points
18+
19+
- `src/mcp_server_python_docs/ingestion/cpython_versions.py`
20+
- `CPythonDocsBuildConfig(TypedDict)` — add `sha: str`.
21+
- `CPYTHON_DOCS_BUILD_CONFIG` — five entries, currently `{"tag": ..., "sphinx_pin": ...}`:
22+
`3.10→v3.10.20`, `3.11→v3.11.15`, `3.12→v3.12.13`, `3.13→v3.13.13`, `3.14→v3.14.4`.
23+
Add the resolved SHA to each. Resolve with:
24+
`git ls-remote https://github.com/python/cpython.git refs/tags/<tag>`
25+
(use the dereferenced commit — the `<tag>^{}` line — not the annotated-tag object).
26+
- `src/mcp_server_python_docs/__main__.py:210–226` — the clone:
27+
`git clone --depth 1 --branch config["tag"] https://github.com/python/cpython.git <clone_dir>`.
28+
After it, add: `rev = git -C <clone_dir> rev-parse HEAD`; if `rev != config["sha"]`,
29+
log a clear error and **abort this version's build** (raise / skip-with-failure —
30+
match the existing error-handling style in this function; do not silently continue).
31+
- `tests/test_ingestion.py:53` — existing assertion
32+
`config["tag"].startswith(f"v{version}.")`. Add a sibling assertion that
33+
`config["sha"]` matches `^[0-9a-f]{40}$`.
34+
35+
## 3. Patterns to follow
36+
37+
- `tests/test_ingestion.py` iterates `CPYTHON_DOCS_BUILD_CONFIG.items()` for the
38+
tag assertion — extend that same loop for the SHA assertion. No new fixtures.
39+
- The clone block already uses `subprocess.run([...], check=True, capture_output=True, text=True)`
40+
— reuse that idiom for the `rev-parse` call.
41+
42+
## 4. Known pitfalls
43+
44+
- **`--branch <tag>` cannot take a raw SHA** on a shallow clone against GitHub by
45+
default. Keep the tag-based shallow fetch; make the **SHA a post-clone
46+
verification gate**, not the fetch ref. That is the integrity win: a moved/re-tagged
47+
tag now fails the build instead of silently changing canonical content.
48+
- Use the **dereferenced commit SHA** (peeled tag), not the annotated tag object's
49+
own SHA — `rev-parse HEAD` after checkout gives the commit; match that.
50+
- **Do not edit `SECURITY.md`** (forbidden). Draft the threat-model paragraph in
51+
the PR body + decision log below for a human to paste.
52+
- A full `build-index` clones over the network and takes minutes — do not gate the
53+
PR on it. The unit tests cover the config + verification logic offline.
54+
- Don't bump any tag to a newer CPython point release; pin the SHA of the
55+
**current** tag only.
56+
57+
## 5. Decision log
58+
59+
- Resolved SHAs (tag → 40-hex commit), one line each:
60+
- 3.10 / v3.10.20 →
61+
- 3.11 / v3.11.15 →
62+
- 3.12 / v3.12.13 →
63+
- 3.13 / v3.13.13 →
64+
- 3.14 / v3.14.4 →
65+
- Where/how the verification aborts on mismatch:
66+
- **Draft SECURITY.md threat-model paragraph (for human to paste):**
67+
>

0 commit comments

Comments
 (0)