Skip to content

fix: resolve docs audit residuals R.1–R.3 and retire audit#124

Open
SutuSebastian wants to merge 11 commits into
mainfrom
fix/residuals-r1-r3
Open

fix: resolve docs audit residuals R.1–R.3 and retire audit#124
SutuSebastian wants to merge 11 commits into
mainfrom
fix/residuals-r1-r3

Conversation

@SutuSebastian
Copy link
Copy Markdown
Contributor

@SutuSebastian SutuSebastian commented May 25, 2026

Summary

Closes the May 2026 docs fact-check audit (R.1–R.9). R.10–R.12 remain in backlog/plans.

Residual fixes (R.1–R.3)

  • R.1: Project recipes honor --state-dir / CODEMAP_STATE_DIR via resolveStateDir() and setQueryRecipesProjectRoot(root, stateDir); pollution guard when runtime state dir diverges.
  • R.2: function_params.owner_kind populated at extraction (function, method, getter, setter, arrow, constructor); find-by-param-type filter docs restored.
  • R.3: MCP stdio registers codemap://files/{+path} and codemap://symbols/{name}{?in} resource templates (parity with HTTP); symbols ?in= filter via MCP template.

Sweep follow-ups

  • Watcher: custom --state-dir recipes prefix; chokidar ignore uses dynamic state dir (MCP / HTTP / watch CLI).
  • Docs: canonical <state-dir>/recipes/ (default .codemap/recipes/) across README, architecture, glossary, agents, skill template, recipe templates, marketplace plan; codemap://schema path aligned.
  • MCP: recipes moved to live read-per-call cache bucket in cmd-mcp help.

Audit closure

  • Delete docs/audits/2026-05-24-docs-fact-check-residuals.md; index closure in roadmap.md § Closed audits.

Dependencies

  • bun update --latest; qs>=6.15.2 override clears GHSA-q8mj-m7cp-5q26 (transitive via @modelcontextprotocol/sdk → express → body-parser).

Commits

  1. 8ef50f1 — R.1–R.3 + audit retirement
  2. f30873d — docs hydration, watcher state-dir, MCP ?in=, regression tests
  3. d0ceeda — schema resource path nit
  4. 22edef0 — deps bump + qs override

Test plan

  • bun test on changed *.test.ts (query-recipes, pre-bootstrap, mcp-server, watcher, parser)
  • bun run typecheck
  • MCP resources tests: files/symbols templates + read; symbols ?in= filter
  • Watcher custom state-dir prefix
  • bun audit — no vulnerabilities (CI run)
  • Full CI green on 22edef0

Summary by CodeRabbit

  • New Features

    • MCP server now exposes file and symbol resources as live read-per-call endpoints
    • Query recipes now support custom state directory configuration
  • Improvements

    • Enhanced parameter ownership tracking to correctly distinguish between functions, methods, getters, setters, constructors, and arrow functions
  • Documentation

    • Updated MCP server and recipe documentation to reflect new resource capabilities

Review Change Stack

Honor --state-dir for project recipes, populate function_params.owner_kind,
register files/symbols MCP resource templates, and delete the May 2026
fact-check audit tombstone (R.10–R.12 remain in roadmap/plans).
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 25, 2026

🦋 Changeset detected

Latest commit: 729387f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stainless-code/codemap Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Warning

Review limit reached

@SutuSebastian, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 1 review of capacity. Refill in 35 minutes and 15 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d397a21-d270-4a27-9e71-69437f11c6e8

📥 Commits

Reviewing files that changed from the base of the PR and between 8ef50f1 and 729387f.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (39)
  • .agents/lessons.md
  • .agents/rules/agents-tier-system.md
  • .agents/rules/docs-governance.md
  • .agents/rules/lessons.md
  • .agents/skills/audit-pr-architecture/SKILL.md
  • .agents/skills/diagnose/SKILL.md
  • .agents/skills/docs-governance/SKILL.md
  • .agents/skills/docs-lifecycle-sweep/SKILL.md
  • .changeset/fix-residuals-r1-r3.md
  • README.md
  • docs/README.md
  • docs/agents.md
  • docs/architecture.md
  • docs/glossary.md
  • docs/plans/apply-engine-direction.md
  • docs/plans/c9-plugin-layer.md
  • docs/plans/github-marketplace-action.md
  • docs/plans/lsp-diagnostic-push.md
  • docs/plans/substrate-extraction.md
  • docs/research/codemap-richer-index-synthesis-2026-05.md
  • docs/research/non-goals-reassessment-2026-05.md
  • docs/roadmap.md
  • docs/why-codemap.md
  • package.json
  • src/application/http-server.ts
  • src/application/mcp-server.test.ts
  • src/application/mcp-server.ts
  • src/application/query-recipes.pre-bootstrap.test.ts
  • src/application/query-recipes.ts
  • src/application/recipes-loader.ts
  • src/application/watcher.test.ts
  • src/application/watcher.ts
  • src/cli/cmd-mcp.ts
  • src/cli/cmd-watch.ts
  • src/parser.test.ts
  • templates/agent-content/skill/10-recipes-context.md
  • templates/recipes/high-complexity-untested.md
  • templates/recipes/refactor-risk-ranking.md
  • templates/recipes/text-in-deprecated-functions.md
📝 Walkthrough

Walkthrough

This PR expands codemap's MCP server capabilities by adding live file and symbol resource templates, enables recipe discovery via custom state directories, enriches function parameter metadata with owner kinds (function, method, getter, setter, arrow, constructor), and updates related documentation and audit records.

Changes

MCP Resources and Recipes State Directory Support

Layer / File(s) Summary
MCP file and symbol resource handlers
src/application/mcp-server.ts, src/application/mcp-server.test.ts, README.md, docs/glossary.md
Two new MCP resource templates (codemap://files/{+path}, codemap://symbols/{name}) expose live read-per-call access to per-file roll-ups and symbol matches. New readTemplateResource helper standardizes response formatting. Resource template assertions and per-resource payload validation added to test suite. Documentation updated to reflect MCP resource coverage.
Query recipes state directory resolution
src/application/query-recipes.ts, src/application/query-recipes.test.ts, src/application/query-recipes.pre-bootstrap.test.ts, src/cli/main.ts
resolveProjectRecipesDir and setQueryRecipesProjectRoot extended to accept optional stateDir parameter for state-dir-aware recipe discovery. Internal resolver resolveRecipesProjectDir implements precedence logic (override → runtime state → fallback). CLI wiring updated to pass stateDir. Tests verify pre-bootstrap and runtime recipe loading from custom state directories.
Function parameter owner_kind extraction
src/extractors/scopes.ts, src/extractors/symbols.ts, src/parser.test.ts, templates/recipes/find-by-param-type.md
Method, arrow function, and function expression parameter scopes now track owner_kind (method/getter/setter from node kind; arrow/function/constructor from explicit argument). New test suite validates parameter rows are correctly annotated across all owner kinds. Recipe template documentation lists all supported owner_kind values.
Documentation updates and audit cleanup
docs/README.md, docs/roadmap.md, docs/audits/2026-05-24-docs-fact-check-residuals.md
Removed closed audit file, updated roadmap Backlog and Closed audits table, and clarified File Ownership table to reflect current audit status.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • stainless-code/codemap#93: Both PRs modify query-recipes resolution logic and CLI wiring for setQueryRecipesProjectRoot, with this PR extending support to include stateDir parameter handling and cache invalidation logic.

Suggested labels

documentation, enhancement


🐰 Fresh resources hop and bound,
Recipes find their state-dir home,
Parameters wear their owner's crown,
Audits closed, new docs bloom,
Codemap grows, feature by feature.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically summarizes the main change: resolving three documented audit residuals (R.1–R.3) and retiring the associated audit file, which is reflected in the file deletions and updates throughout the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/residuals-r1-r3

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/application/mcp-server.test.ts (1)

834-859: ⚡ Quick win

Add a test for ?in= query passthrough on codemap://symbols/{name}.

This test verifies base symbol resolution, but not the new query-string propagation path (?in=...) implemented in the handler.

✅ Suggested test addition
+  it("codemap://symbols/{name}?in=... preserves query filter", async () => {
+    const db = openDb();
+    try {
+      db.run(
+        `INSERT INTO symbols (file_path, name, kind, line_start, line_end, signature, is_exported, is_default_export)
+         VALUES ('src/a.ts', 'A', 'const', 1, 1, 'const A', 1, 0)`,
+      );
+      db.run(
+        `INSERT INTO symbols (file_path, name, kind, line_start, line_end, signature, is_exported, is_default_export)
+         VALUES ('src/b.ts', 'A', 'const', 1, 1, 'const A', 1, 0)`,
+      );
+    } finally {
+      closeDb(db);
+    }
+
+    const { client, server } = await makeClient();
+    try {
+      const r = await client.readResource({ uri: "codemap://symbols/A?in=src/a.ts" });
+      const parsed = JSON.parse(readResourceText(r));
+      expect(parsed.matches).toEqual(
+        expect.arrayContaining([
+          expect.objectContaining({ name: "A", file_path: "src/a.ts" }),
+        ]),
+      );
+      expect(
+        parsed.matches.some((m: { file_path: string }) => m.file_path === "src/b.ts"),
+      ).toBe(false);
+    } finally {
+      await server.close();
+    }
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/application/mcp-server.test.ts` around lines 834 - 859, Add a new test in
src/application/mcp-server.test.ts (next to the existing
"codemap://symbols/{name} resolves indexed symbols" test) that inserts the same
symbol into the SQLite symbols table, creates the client/server via
makeClient(), then calls client.readResource with a URI that includes the
query-string passthrough (e.g., "codemap://symbols/A?in=src/a.ts") and asserts
the parsed response contains the symbol (expect(parsed.matches) to include an
objectContaining { name: "A", file_path: "src/a.ts" }); also add a negative
check by requesting "codemap://symbols/A?in=src/other.ts" (or without ?in) to
confirm the handler respects the ?in= filter, and ensure DB is closed and server
closed in finally blocks just like the existing test.
src/parser.test.ts (1)

741-765: ⚡ Quick win

Add coverage for the FunctionExpression owner-kind path.

Line 741 adds strong coverage, but it misses the newly changed FunctionExpression extraction branch; adding one assertion here would close that gap.

Suggested test extension
@@
       const src = [
         "export function greet(name: string): string { return name; }",
         "export class Svc {",
         "  constructor(host: string) { this.host = host; }",
         "  run(id: string): void {}",
         "  set label(value: string) { this._label = value; }",
         "}",
         "export const add = (a: number, b: number): number => a + b;",
+        "export const mul = function (x: number, y: number): number { return x * y; };",
       ].join("\n");
@@
       expect(byOwner("run", "method")?.name).toBe("id");
       expect(byOwner("label", "setter")?.name).toBe("value");
       expect(byOwner("add", "arrow")?.name).toBe("a");
+      expect(byOwner("mul", "function")?.name).toBe("x");
     });
   });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/parser.test.ts` around lines 741 - 765, Add a FunctionExpression case to
the test by appending a source line like `export const expr = function(e:
number): number { return e; }` to the src array and add an assertion using the
existing helpers to check its extracted param: e.g. expect(byOwner("expr",
"function_expression")?.name).toBe("e"); this uses extractFileData,
d.functionParams and byOwner to validate the new FunctionExpression owner-kind
path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/roadmap.md`:
- Line 78: The table row for "Full `.md` fact-check (May 2026)" incorrectly
marks R.1–R.3 as already in this PR with a closed date of 2026-05-24; update
that row in roadmap.md to reflect the true status by either (a) moving the entry
to post-merge (change the date and/or section to Backlog/Plans) or (b) mark it
as pending/in-progress and remove or correct the closed date, making sure the
text referencing "R.1–R.3 in this PR" and the commit range `e6ab158`–`14d3efc`
reflect the actual merge state.

---

Nitpick comments:
In `@src/application/mcp-server.test.ts`:
- Around line 834-859: Add a new test in src/application/mcp-server.test.ts
(next to the existing "codemap://symbols/{name} resolves indexed symbols" test)
that inserts the same symbol into the SQLite symbols table, creates the
client/server via makeClient(), then calls client.readResource with a URI that
includes the query-string passthrough (e.g., "codemap://symbols/A?in=src/a.ts")
and asserts the parsed response contains the symbol (expect(parsed.matches) to
include an objectContaining { name: "A", file_path: "src/a.ts" }); also add a
negative check by requesting "codemap://symbols/A?in=src/other.ts" (or without
?in) to confirm the handler respects the ?in= filter, and ensure DB is closed
and server closed in finally blocks just like the existing test.

In `@src/parser.test.ts`:
- Around line 741-765: Add a FunctionExpression case to the test by appending a
source line like `export const expr = function(e: number): number { return e; }`
to the src array and add an assertion using the existing helpers to check its
extracted param: e.g. expect(byOwner("expr",
"function_expression")?.name).toBe("e"); this uses extractFileData,
d.functionParams and byOwner to validate the new FunctionExpression owner-kind
path.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 95ece27a-09d9-4176-b75e-e477c6e6465e

📥 Commits

Reviewing files that changed from the base of the PR and between 14d3efc and 8ef50f1.

📒 Files selected for processing (15)
  • README.md
  • docs/README.md
  • docs/audits/2026-05-24-docs-fact-check-residuals.md
  • docs/glossary.md
  • docs/roadmap.md
  • src/application/mcp-server.test.ts
  • src/application/mcp-server.ts
  • src/application/query-recipes.pre-bootstrap.test.ts
  • src/application/query-recipes.test.ts
  • src/application/query-recipes.ts
  • src/cli/main.ts
  • src/extractors/scopes.ts
  • src/extractors/symbols.ts
  • src/parser.test.ts
  • templates/recipes/find-by-param-type.md
💤 Files with no reviewable changes (1)
  • docs/audits/2026-05-24-docs-fact-check-residuals.md

Comment thread docs/roadmap.md Outdated
Align canonical docs with <state-dir>/recipes/, extend watcher to honor
custom state dirs, fix cmd-mcp resource cache buckets, add regression
tests (stateDir cache invalidation, symbols ?in= via MCP template).
bun update --latest plus qs>=6.15.2 override resolves GHSA-q8mj-m7cp-5q26
(transitive via @modelcontextprotocol/sdk → express → body-parser).
Relocate deleted-audit pointers to docs/README § Closing audits;
drop perf-triangulation row (plan self-documents); update skills.
Living docs should not cite removed audit paths; closure anchors are
the shipping PR/commit and git history only.
Default research/audit closure to lift+delete; restrict existence test
to inbound cites; stop citing slim-appendix precedent; lessons are
staging not archive.
Lift apply-engine open steps to plans/apply-engine-direction.md; embed
LSP/C.9 cadence + shape history in open plans; keep research archives
(Tier B) with explicit plan pointers; rewire governance cross-refs.
Collapse redundant shipped inventory into §7 lift table; add explicit
backlog rows for open plans + trigger-gated peer ideas; embed cohort
positioning in why-codemap (no peer tracker file).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant