Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Goal:
Complete the Context System + Evaluation phase with an end-to-end smoke test, implementation report, durable baseline audit, and cleanup ledger updates.

Scope:
- Add a deterministic smoke test that exercises AgentKit `build_context` composition with Coding Agent KB retrieval, test-failure evidence, and memory reference context.
- Produce the final context-system implementation report.
- Audit ADR-0034 acceptance criteria against executable tests.
- Update the G12-G24 ledger with landed PR status and G24 verification evidence.

Out of scope:
- New retrieval algorithms, ranking changes, or production integrations.
- AgentKit runtime, `ContextBuilder`, or directive schema changes.
- External LLM calls, external judges, production credentials, or remote vector stores.

Context:
- ADR:
- `docs/adr/0034-context-system-boundaries-and-evidence.md`
- Relevant files:
- `tests/coding_agent/test_context_system_smoke.py`
- `docs/context_system/IMPLEMENTATION_REPORT.md`
- `docs/context_system/GOAL_PROGRESS.md`

Target tests:
- `uv run pytest tests/coding_agent/test_context_system_smoke.py -v`
- `uv run pytest tests/test_kb.py -k "repo_chunk_metadata_records_source_kind_and_repo_path or repo_retrieval_returns_ranked_evidence_with_fake_embedder or failure_retrieval_indexes_pytest_failure_evidence" -v`
- `uv run pytest tests/coding_agent/evaluation/ -v`
- `uv run pytest tests/coding_agent/plugins/test_kb.py tests/coding_agent/plugins/test_kb_plugin.py tests/coding_agent/plugins/test_memory.py tests/coding_agent/test_context_pack.py tests/coding_agent/test_context_system_smoke.py -v`
- `uv run pytest tests/coding_agent/ -k "context_pack or retrieval or memory or evaluation" -v`
- `uv run pytest tests/agentkit/runtime/test_pipeline.py -k "build_context or runtime_stage_spans" -v`

Loop policy:
- Engineer adds the final smoke test first.
- Engineer updates report/ledger only after smoke coverage is executable.
- Reviewer reports only P1/P2 issues.
- Engineer fixes accepted P1/P2 findings and reruns target tests.

Stop conditions:
- Stop if end-to-end smoke requires changing AgentKit runtime composition.
- Stop if verification requires external services or credentials.
- Stop if the final audit finds an unmet ADR-0034 acceptance criterion without an executable test.
- Stop after two failed fix iterations for the same failure.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ADR-0034: Bound context-system retrieval, packs, evidence, and evaluation

**Status**: Proposed
**Status**: Accepted
**Date**: 2026-05-19

## Context
Expand Down Expand Up @@ -61,17 +61,17 @@ Make evaluation deterministic and fixture-driven:

Implementation of G14-G24 should add executable tests covering these contracts:

- [ ] `test_repo_chunk_metadata_records_source_kind_and_repo_path`
- [ ] `test_repo_retrieval_returns_ranked_evidence_with_fake_embedder`
- [ ] `test_failure_retrieval_indexes_pytest_failure_evidence`
- [ ] `test_context_pack_renderer_labels_memory_as_reference`
- [ ] `test_context_pack_injection_uses_build_context_without_pipeline_rewrite`
- [ ] `test_retrieval_observability_emits_counts_without_sensitive_attributes`
- [ ] `test_evaluation_manifest_builds_context_system_cases_from_local_fixtures`
- [ ] `test_memory_records_persist_evidence_and_load_legacy_records`
- [ ] `test_memory_without_evidence_is_not_rendered_as_instruction`
- [ ] `uv run pytest tests/coding_agent/ -k "context_pack or retrieval or memory or evaluation" -v`
- [ ] `uv run pytest tests/agentkit/runtime/test_pipeline.py -k "build_context" -v`
- [x] `test_repo_chunk_metadata_records_source_kind_and_repo_path`
- [x] `test_repo_retrieval_returns_ranked_evidence_with_fake_embedder`
- [x] `test_failure_retrieval_indexes_pytest_failure_evidence`
- [x] `test_context_pack_renderer_labels_memory_as_reference`
- [x] `test_context_pack_injection_uses_build_context_without_pipeline_rewrite`
- [x] `test_retrieval_observability_emits_counts_without_sensitive_attributes`
- [x] `test_evaluation_manifest_builds_context_system_cases_from_local_fixtures`
- [x] `test_memory_records_persist_evidence_and_load_legacy_records`
- [x] `test_memory_without_evidence_is_not_rendered_as_instruction`
- [x] `uv run pytest tests/coding_agent/ -k "context_pack or retrieval or memory or evaluation" -v`
- [x] `uv run pytest tests/agentkit/runtime/test_pipeline.py -k "build_context" -v`

## References

Expand Down
88 changes: 79 additions & 9 deletions coding-agent/docs/context_system/GOAL_PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ No pre-existing repository document defined G12-G24 individually. The following

## G12 - Current-State Audit And Phase Ledger

Status: passed local verification.
Status: merged via PR #213.

### Before

Expand Down Expand Up @@ -99,7 +99,7 @@ Remaining risks:

## G13 - Context-System Boundary ADR

Status: passed local verification.
Status: merged via PR #214.

### Before

Expand Down Expand Up @@ -160,7 +160,7 @@ Remaining risks:

## G14 - Repo-Aware Retrieval Source And Chunk Metadata

Status: passed local verification.
Status: merged via PR #215.

### Before

Expand Down Expand Up @@ -229,7 +229,7 @@ Remaining risks:

## G15 - Repo-Aware Retrieval Indexing And Query Fixtures

Status: passed local verification.
Status: merged via PR #216.

### Before

Expand Down Expand Up @@ -297,7 +297,7 @@ Remaining risks:

## G16 - Testing Failure Retrieval Ingest/Search Fixtures

Status: passed local verification.
Status: merged via PR #217.

### Before

Expand Down Expand Up @@ -367,7 +367,7 @@ Remaining risks:

## G17 - Context Pack Data Model And Renderer Contract

Status: passed local verification.
Status: merged via PR #218.

### Before

Expand Down Expand Up @@ -431,7 +431,7 @@ Remaining risks:

## G18 - Context Pack Injection Through Existing Build Context Hooks

Status: passed local verification.
Status: merged via PR #219.

### Before

Expand Down Expand Up @@ -712,7 +712,7 @@ Remaining risks:

## G22 - Memory Records With Evidence References And JSONL-Compatible Migration

Status: passed local verification; pending PR.
Status: merged via PR #223.

### Before

Expand Down Expand Up @@ -782,7 +782,7 @@ Remaining risks:

## G23 - Memory Retrieval And Injection As Evidence-Backed Reference Context

Status: in progress.
Status: merged via PR #224.

### Before

Expand Down Expand Up @@ -855,3 +855,73 @@ Remaining risks:

- MemoryPlugin still uses simple tag overlap for memory retrieval; richer memory ranking is outside G23.
- Unevidenced legacy memories remain persisted and loadable but are intentionally invisible to default grounding.

## G24 - End-To-End Context-System Smoke, Implementation Report, And Final Audit

Status: passed local verification; pending PR.

### Before

Goal id: G24

Intended files:

- `tests/coding_agent/test_context_system_smoke.py`
- `docs/context_system/IMPLEMENTATION_REPORT.md`
- `docs/context_system/GOAL_PROGRESS.md`
- `docs/adr/0034-context-system-boundaries-and-evidence.md`
- `.opencode/prompts/tasks/context-system-g24-final-audit.md`

Verification commands:

- `uv run pytest tests/coding_agent/test_context_system_smoke.py -v`
- `uv run pytest tests/test_kb.py -k "repo_chunk_metadata_records_source_kind_and_repo_path or repo_retrieval_returns_ranked_evidence_with_fake_embedder or failure_retrieval_indexes_pytest_failure_evidence" -v`
- `uv run pytest tests/coding_agent/evaluation/ -v`
- `uv run pytest tests/coding_agent/plugins/test_kb.py tests/coding_agent/plugins/test_kb_plugin.py tests/coding_agent/plugins/test_memory.py tests/coding_agent/test_context_pack.py tests/coding_agent/test_context_system_smoke.py -v`
- `uv run pytest tests/coding_agent/ -k "context_pack or retrieval or memory or evaluation" -v`
- `uv run pytest tests/agentkit/runtime/test_pipeline.py -k "build_context or runtime_stage_spans" -v`

Stop criteria:

- End-to-end smoke requires AgentKit runtime, `ContextBuilder`, or directive schema changes.
- Verification requires external services, external judges, production credentials, or remote vector stores.
- Final audit finds an unmet ADR-0034 acceptance criterion without executable test coverage.
- Deterministic verification cannot be produced.
- More than two fix iterations fail for the same reason.

Postmortem routing:

- `tests/coding_agent/test_context_system_smoke.py`, `docs/context_system/GOAL_PROGRESS.md`, and `docs/adr/0034-context-system-boundaries-and-evidence.md` match PM-0009. Release checks: run focused affected tests and review control-flow shape before shipping.

### After

Changed files:

- `tests/coding_agent/test_context_system_smoke.py`
- `docs/context_system/IMPLEMENTATION_REPORT.md`
- `docs/context_system/GOAL_PROGRESS.md`
- `docs/adr/0034-context-system-boundaries-and-evidence.md`
- `.opencode/prompts/tasks/context-system-g24-final-audit.md`

Verification results:

- `uv run ruff format --check tests/coding_agent/test_context_system_smoke.py` passed with the file already formatted after running `uv run ruff format tests/coding_agent/test_context_system_smoke.py`.
- `uv run ruff check tests/coding_agent/test_context_system_smoke.py` passed.
- `git diff --check -- .` passed.
- Green: `uv run pytest tests/coding_agent/test_context_system_smoke.py -v` passed with 1 passed.
- `uv run pytest tests/test_kb.py -k "repo_chunk_metadata_records_source_kind_and_repo_path or repo_retrieval_returns_ranked_evidence_with_fake_embedder or failure_retrieval_indexes_pytest_failure_evidence" -v` passed with 3 passed, 41 deselected.
- `uv run pytest tests/coding_agent/evaluation/ -v` passed with 20 passed.
- `uv run pytest tests/coding_agent/plugins/test_kb.py tests/coding_agent/plugins/test_kb_plugin.py tests/coding_agent/plugins/test_memory.py tests/coding_agent/test_context_pack.py tests/coding_agent/test_context_system_smoke.py -v` passed with 46 passed.
- `uv run pytest tests/coding_agent/ -k "context_pack or retrieval or memory or evaluation" -v` passed with 52 passed, 585 deselected.
- `uv run pytest tests/agentkit/runtime/test_pipeline.py -k "build_context or runtime_stage_spans" -v` passed with 8 passed, 29 deselected.

Implementation notes:

- Added a deterministic smoke test that builds a Pipeline with KBPlugin and MemoryPlugin, indexes repo and test-failure evidence, and verifies the composed `build_context` prompt contains repo, failure, and memory reference context.
- Updated the final implementation report with landed goal and ADR acceptance evidence.
- Marked ADR-0034 accepted and checked off the executable acceptance criteria.
- Updated the phase ledger with merged PR status for G12-G23.

Remaining risks:

- G24 is a final smoke/audit goal; it does not add new ranking, indexing, or memory capture policy beyond prior goals.
62 changes: 62 additions & 0 deletions coding-agent/docs/context_system/IMPLEMENTATION_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Context System + Evaluation Implementation Report

Date: 2026-05-19
Scope: G12-G24

## Summary

The Context System + Evaluation phase is implemented in Coding Agent without moving repository, failure, memory, or evaluation semantics into AgentKit Core. AgentKit still composes plugin-supplied context through the existing `build_context` hook; Coding Agent owns retrieval, context packs, evidence policy, observability counters, and deterministic evaluation fixtures.

Memory grounding now follows the ADR authority boundary: evidence-backed memories render as reference context and unevidenced legacy memories are omitted from default grounding. Repo chunks and test failures render through the same context-pack model as memory references.

## Landed Goals

| Goal | Result |
| --- | --- |
| G12 | Current-state audit and phase ledger landed in PR #213. |
| G13 | ADR-0034 context-system boundary decision landed in PR #214. |
| G14 | Repo-aware chunk metadata landed in PR #215. |
| G15 | Deterministic repo retrieval fixtures landed in PR #216. |
| G16 | Test-failure ingest/search fixtures landed in PR #217. |
| G17 | Context-pack model and renderer landed in PR #218. |
| G18 | Context-pack injection through `build_context` landed in PR #219. |
| G19 | Safe retrieval observability counters landed in PR #220. |
| G20 | Manifest-driven evaluation baseline landed in PR #221. |
| G21 | Retrieval/context-pack golden cases landed in PR #222. |
| G22 | Memory evidence records and JSONL-compatible migration landed in PR #223. |
| G23 | Memory context-pack rendering and unevidenced-memory omission landed in PR #224. |
| G24 | End-to-end smoke, final audit, and this report are covered by `tests/coding_agent/test_context_system_smoke.py`. |

## Acceptance Audit

| ADR-0034 criterion | Executable evidence |
| --- | --- |
| Repo chunk metadata records source kind and repo path | `tests/test_kb.py::TestKBIndexing::test_repo_chunk_metadata_records_source_kind_and_repo_path` |
| Repo retrieval returns ranked evidence with fake embedder | `tests/test_kb.py::TestKBSearch::test_repo_retrieval_returns_ranked_evidence_with_fake_embedder` |
| Failure retrieval indexes pytest failure evidence | `tests/test_kb.py::TestKBSearch::test_failure_retrieval_indexes_pytest_failure_evidence` |
| Context-pack renderer labels memory as reference | `tests/coding_agent/test_context_pack.py::test_context_pack_renderer_labels_memory_as_reference` |
| Context-pack injection uses `build_context` without pipeline rewrite | `tests/coding_agent/plugins/test_kb_plugin.py::test_context_pack_injection_uses_build_context_without_pipeline_rewrite` |
| Retrieval observability emits safe counters only | `tests/coding_agent/plugins/test_kb_plugin.py::test_retrieval_observability_emits_counts_without_sensitive_attributes` |
| Evaluation manifest builds context-system cases from fixtures | `tests/coding_agent/evaluation/test_manifest.py::test_evaluation_manifest_builds_context_system_cases_from_local_fixtures` |
| Memory records persist evidence and load legacy records | `tests/coding_agent/plugins/test_memory.py::TestMemoryPersistence::test_mount_loads_persisted_memory_records_with_importance_decay` |
| Memory without evidence is not rendered as instruction | `tests/coding_agent/plugins/test_memory.py::TestMemoryPlugin::test_build_context_omits_unevidenced_memory_by_default` |
| End-to-end build-context composition covers repo, failure, and memory evidence | `tests/coding_agent/test_context_system_smoke.py::test_context_system_smoke_combines_retrieval_failure_and_memory` |

## Durable Baseline

The G24 smoke test proves the integrated path that matters for runtime safety: `Pipeline._stage_build_context` gathers Coding Agent KB and memory plugin context through HookRuntime, composes it through AgentKit `ContextBuilder`, and produces LLM-visible reference grounding without a pipeline rewrite.

The durable baseline remains local and deterministic:

- Fake embedders and local fixtures are used for retrieval and evaluation.
- No external LLM, external judge, production credentials, or remote vector store is required.
- Observability tests assert metadata-only retrieval attributes and avoid raw prompt/content/result text in span attributes.
- JSONL tape and memory compatibility are covered by evaluation adapter tests and memory persistence tests.
- AgentKit `build_context` and runtime-stage span tests remain the guardrail for generic runtime behavior.

## Residual Risks

- Retrieval quality is deterministic and fixture-proven, not production-tuned. Richer ranking/query shaping remains future work.
- Memory evidence inference is conservative and mostly file-tag based. Session, tape-entry, command, and failure evidence fields are supported, but richer capture policy can be expanded later.
- Unevidenced legacy memories remain persisted and loadable, but are intentionally hidden from default grounding.
- Evaluation fixtures cover representative local cases; broader benchmark coverage can be added without changing the AgentKit boundary.
Loading