Skip to content

feat: resolve_concern — cross-repo concern-based querying MCP tool - #1

Merged
Koed00 merged 10 commits into
mainfrom
feature/concern-based-querying
Jun 19, 2026
Merged

Koed00 merged 10 commits into
mainfrom
feature/concern-based-querying

Conversation

@Koed00

@Koed00 Koed00 commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a new MCP tool resolve_concern(concern: string) to LoreMCP that lets an AI agent ask "what owns auth?" without knowing upfront which repo or feature to look in.

This PR covers the full nWave wave sequence (DISCUSS → DESIGN → DISTILL) plus the DELIVER implementation (in progress on this branch).

Problem

query_context requires repo_name + feature_id — the agent must already know the landscape. Before designing a new feature, an agent doesn't know where constraints live. It needs cross-repo, concern-based querying.

What's in this PR

DISCUSS wave (docs/feature/concern-based-querying/discuss/):

  • 4 user stories (US-CBQ-01..04) with Elevator Pitches and acceptance criteria
  • Journey map, story map, outcome KPIs, DoR 4/4 PASS

DESIGN wave (docs/feature/concern-based-querying/design/, docs/product/architecture/):

  • ADR-005: keyword matching strategy (vs semantic search, tag manifests, concern files)
  • architecture-design.md: Changes Per File table for the crafter
  • brief.md extended: C4 Component diagram, INVALID_CONCERN + CONCERN_NOT_FOUND error codes

DISTILL wave (tests/acceptance/concern-based-querying/):

  • 17 BDD scenarios across 4 feature files (47% error/edge — exceeds 40% mandate)
  • RED scaffold: src/core/concern-matcher.ts (throws, TypeScript compiles clean)
  • Stub resolve_concern tool registration in src/shell/server.ts
  • 9 existing test files still green ✓

DELIVER (in progress):

  • docs/feature/concern-based-querying/deliver/execution-log.json initialized

New tool contract

resolve_concern(concern: string)
→ { concern, matches[], rejected_paths[], searched_repos[], retrieved_at }
→ { error: "CONCERN_NOT_FOUND", searched_repos[], ... }
→ { error: "INVALID_CONCERN", ... }

Files to be implemented (DELIVER)

File Change
src/core/concern-matcher.ts NEW — validateConcern, matchConcernInSnapshot, detectRejectedPaths
src/core/format-response.ts Extend — new types + formatters
src/shell/server.ts Extend — resolve_concern tool registration

Architecture constraints maintained

  • src/core/ stays pure (no fs imports) — dependency-cruiser enforced
  • Live reads, no cache (ADR-004)
  • Structured errors only, snake_case JSON contract
  • Zero new npm dependencies

🤖 Generated with Claude Code

Ilan Steemers and others added 10 commits June 18, 2026 18:31
Sets up execution-log.json for DES monitoring of the resolve_concern
implementation. DELIVER wave in progress on this branch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lking skeleton

Step-ID: 01-01

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…format-response

Step-ID: 01-01 RED_UNIT

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… only CLAUDE.md

When the docs directory does not exist but CLAUDE.md is present at the repo
root, the probe check was skipping the repo entirely. Now also checks for
CLAUDE.md existence before deciding to skip, enabling repo-conventions matches
when no docs structure is present.

Step-ID: 02-01
…enarios

All 7 release-1 scenarios passing: feature-level match, ADR match,
repo-conventions match, relevance ordering, and CONCERN_NOT_FOUND.
matchConcernInSnapshot and format-response.ts implementation complete.

Step-ID: 02-02

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Step-ID: 03-01

All 4 cross-repo scenarios were already passing via the handler
implemented in step 01-01. Full suite (303 tests, 14 files) passes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ure warning

Step-ID: 04-01

Implementation was already delivered as part of the walking skeleton
(commit 613d7ea). All 5 acceptance scenarios in release-3-rejected-paths
and all 303 tests pass. detectRejectedPaths splits content into paragraphs,
filters by concern + rejection keyword, caps snippets at 1500 chars.
formatResolveConcernResponse appends partial-structure warning when no
feature-level matches exist. Architectural constraints verified clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
L1: Remove unused StructuredError type import from server.ts.
L1/L2: Eliminate duplicate path.dirname(entry.docPath) computation in
resolve_concern handler (repoRootForEntry vs repoRoot in same loop body).

No changes needed in concern-matcher.ts or format-response.ts — both
were already clean.

Step-ID: refactor
@Koed00
Koed00 merged commit 155aad0 into main Jun 19, 2026
1 check passed
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