You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat(mcp): add affected tool for MCP and HTTP
Extract shared affected-engine from cmd-affected; register affected on
MCP/HTTP with paths/changed_since/test_glob/max_depth. Document in
mcp-instructions and skill; include in CODEMAP_MCP_TOOLS allowlist.
* fix(mcp): address PR review findings for affected tool
Move tryRecordRecipeRun to handleAffected/runAffectedCmd (recipe_recency
boundary). Align max_depth integer validation, HTTP 400 vs 500, agent
changed_since error labels. Expand tests and architecture/docs updates.
* fix(mcp): tighten affected review nits — integer params and recency tests
Require integer coercion for recipe number params, document recency skip
on empty paths, and add MCP/HTTP/CLI parity tests for max_depth validation
and recipe_recency writes.
Per-recipe `last_run_at` (epoch ms) + `run_count` for agent-host ranking — surfaces inline on every `--recipes-json` entry and the matching `codemap://recipes` / `codemap://recipes/{id}` resources (live read every call; the resource cache was dropped to avoid freezing recency at first-read for the server-process lifetime). Counts only successful recipe runs; failed runs / param-validation rejections / SQL errors don't write. Default ON; opt-out via `.codemap/config` `recipeRecency: false` (short-circuits before any DB write — no rows ever land). 90-day rolling window enforced eagerly on the write path (single transactional `DELETE` + `INSERT … ON CONFLICT` inside `recordRecipeRun`); reads filter at SELECT, never mutate. Local-only — no upload primitive (resists telemetry-creep PRs by construction). Two write sites — `handleQueryRecipe` in `application/tool-handlers.ts` (covers MCP + HTTP) and `runQueryCmd` in `cli/cmd-query.ts` (CLI) — both call `tryRecordRecipeRun` (the failure-isolated wrapper around `recordRecipeRun`) from `application/recipe-recency.ts`. Failure-isolated: a recency-write throw NEVER blocks the recipe response (warning to stderr unless `quiet`). Schema: see [architecture.md § `recipe_recency`](./architecture.md#recipe_recency--per-recipe-last-run--run-count-user-data-strict-without-rowid).
473
+
Per-recipe `last_run_at` (epoch ms) + `run_count` for agent-host ranking — surfaces inline on every `--recipes-json` entry and the matching `codemap://recipes` / `codemap://recipes/{id}` resources (live read every call; the resource cache was dropped to avoid freezing recency at first-read for the server-process lifetime). Counts only successful recipe runs; failed runs / param-validation rejections / SQL errors don't write. Default ON; opt-out via `.codemap/config` `recipeRecency: false` (short-circuits before any DB write — no rows ever land). 90-day rolling window enforced eagerly on the write path (single transactional `DELETE` + `INSERT … ON CONFLICT` inside `recordRecipeRun`); reads filter at SELECT, never mutate. Local-only — no upload primitive (resists telemetry-creep PRs by construction). Write sites — `handleQueryRecipe` + `handleAffected` in `application/tool-handlers.ts` (MCP + HTTP) and `runQueryCmd` in `cli/cmd-query.ts` + `runAffectedCmd` in `cli/cmd-affected.ts` (CLI) — each calls `tryRecordRecipeRun` (the failure-isolated wrapper around `recordRecipeRun`) from `application/recipe-recency.ts`. Failure-isolated: a recency-write throw NEVER blocks the recipe response (warning to stderr unless `quiet`). Schema: see [architecture.md § `recipe_recency`](./architecture.md#recipe_recency--per-recipe-last-run--run-count-user-data-strict-without-rowid).
Copy file name to clipboardExpand all lines: docs/plans/affected-tests-recipe.md
+21-12Lines changed: 21 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,21 +1,21 @@
1
1
# Affected tests recipe — plan
2
2
3
-
> **Status:**open · **Priority:** P1 · **Effort:** M (~1–2 weeks)
3
+
> **Status:**shipped · **Priority:** P1 · **Effort:** M (~1–2 weeks)
4
4
>
5
5
> **Motivator:** CI can skip full test suites if only a subgraph changed. Codemap already has `dependencies` and `test_suites` — missing a recipe + CLI alias to list test files transitively impacted by changed sources.
| L.1 |**Moat-A clean** — `affected-tests` recipe satisfies the agent surface; **`query_recipe`**is the MCP/HTTP path. Optional dedicated CLI verb **`codemap affected`**for CI (`stdin` / git path discovery) — not a 6th outcome alias. |[Moat A](../roadmap.md#moats-load-bearing)|
16
-
| L.2 | Algorithm: reverse BFS on `dependencies` from changed files → filter test paths via `test_suites.file_path` and configurable globs. | Uses existing substrate |
17
-
| L.3 |**Stdin support** — accept changed paths from `git diff --name-only` (same ergonomics as CI scripts). | CLI ergonomics |
18
-
| L.4 | Not a verdict — output is file paths only; CI composes exit policy. | Moat A |
| L.1 |**Moat-A clean** — `affected-tests` recipe is the substrate; **`query_recipe`**remains the Moat-A path. Optional **`codemap affected`**CLI + MCP/HTTP **`affected`** tool for ergonomics — not a 6th outcome alias. |[Moat A](../roadmap.md#moats-load-bearing)|
16
+
| L.2 | Algorithm: reverse BFS on `dependencies` from changed files → filter test paths via `test_suites.file_path` and configurable globs. | Uses existing substrate |
17
+
| L.3 |**Stdin support** — accept changed paths from `git diff --name-only` (same ergonomics as CI scripts). | CLI ergonomics |
18
+
| L.4 | Not a verdict — output is file paths only; CI composes exit policy. | Moat A |
19
19
20
20
---
21
21
@@ -26,8 +26,8 @@
26
26
**Params (frontmatter):**
27
27
28
28
-`changed_files` — multiline or repeated (from `--params` or stdin preprocessor)
-`max_depth` — optional non-negative integer BFS cap (default 50)
31
31
32
32
**SQL shape:**
33
33
@@ -48,7 +48,9 @@ Dedicated `cmd-affected.ts` (not an outcome alias — 5-alias cap unchanged). Sh
48
48
49
49
## Agent surface (Moat A)
50
50
51
-
No dedicated MCP tool required — agents call **`query_recipe`** with `recipe: "affected-tests"` and `params.changed_files` (ASCII RS between paths when multiple). The recipe is the Moat-A substrate; the CLI verb is CI ergonomics only.
51
+
**Substrate:****`query_recipe`** with `recipe: "affected-tests"` and `params.changed_files` (ASCII RS between paths when multiple).
52
+
53
+
**Convenience surfaces (Phase 2):** MCP/HTTP **`affected`** (`paths?`, `changed_since?`, …) and CLI **`codemap affected`** — thin composers over the same engine + recipe. Moat-A reviewers still verify via `query --recipe affected-tests`.
52
54
53
55
---
54
56
@@ -59,7 +61,13 @@ No dedicated MCP tool required — agents call **`query_recipe`** with `recipe:
59
61
3. Document test-file conventions in recipe `.md`
60
62
4. Optional GitHub Action input `mode: affected` in [github-marketplace-action](./github-marketplace-action.md) (follow-up)
61
63
62
-
**Out of scope:** dedicated MCP/HTTP `affected` tool (same outcome reachable via `query_recipe`; revisit only if agent eval shows friction).
64
+
**Out of scope (v1):**~~dedicated MCP/HTTP `affected` tool~~ — shipped Phase 2 follow-up (`affected` tool; same engine as CLI). `query_recipe` remains the Moat-A substrate.
0 commit comments