Problem
Current path resolution for RagCode tools creates friction and stale-context errors in real IDE usage:
- Requiring
file_path on every call is repetitive and error-prone.
last_valid_file_path is not branch-aware, causing wrong reuse after Git branch switches.
- Resolver decisions are opaque (AI cannot see why a path was selected).
- Cache invalidation is weak, leading to stale entries and retry loops.
- No explicit mechanism for AI to reject a resolved path and suggest correction.
This is especially problematic when users work across multiple branches/worktrees in the same repository.
Proposal
Implement a Path Resolver v2 with 5 components:
-
Branch-aware context key
- Replace global workspace-only key with:
workspace_root + git_branch + git_head (+ worktree_id)
- Keep temporary backward-compatible fallback to old key during rollout.
-
Explicit path-resolution metadata in every tool response
- Add:
resolved_file_path
path_resolution_source
path_resolution_confidence
used_fallback
workspace_root
git_branch
git_head
worktree_id (if available)
path_context_key
-
Invalidation and anti-loop policy
- Invalidate or isolate cache on branch switch.
- Confidence decay on HEAD mismatch/rewrite.
- Short TTL for fallback cache entries.
- Prevent infinite retries on missing paths.
-
AI ↔ resolver feedback loop
- Support request-side feedback:
path_feedback.status = "mismatch"
path_feedback.suggested_file_path
- optional
reason
- Store suggestion as candidate; promote to
last_valid only after successful resolution/execution.
-
Branch mismatch risk signal
- Return
branch_mismatch_risk: low|medium|high
- Raise risk when path likely comes from stale/other-branch context.
Example response metadata (proposed)
{
"resolved_file_path": "/abs/path/internal/config/loader.go",
"path_resolution_source": "last_valid_file_path",
"path_resolution_confidence": 0.86,
"used_fallback": true,
"workspace_root": "/home/.../go/src/github.com/doITmagic/rag-code-mcp",
"git_branch": "feature/path-resolver-v2",
"git_head": "a1b2c3d",
"worktree_id": "main-worktree",
"path_context_key": "workspace+branch+head+worktree",
"branch_mismatch_risk": "low"
}
Scope
- Path resolver internals
- RagCode tool response envelope metadata
- Cache keying + invalidation behavior
- Feedback input handling
Non-goals
- Full redesign of all search tools
- UI command palette implementation (can be separate issue)
- Cross-repo context sharing
Acceptance Criteria
Suggested implementation order
- Context key v2
- Response metadata
- Invalidation policy
- Feedback loop
- Risk flag + hardening tests
Problem
Current path resolution for RagCode tools creates friction and stale-context errors in real IDE usage:
file_pathon every call is repetitive and error-prone.last_valid_file_pathis not branch-aware, causing wrong reuse after Git branch switches.This is especially problematic when users work across multiple branches/worktrees in the same repository.
Proposal
Implement a Path Resolver v2 with 5 components:
Branch-aware context key
workspace_root + git_branch + git_head (+ worktree_id)Explicit path-resolution metadata in every tool response
resolved_file_pathpath_resolution_sourcepath_resolution_confidenceused_fallbackworkspace_rootgit_branchgit_headworktree_id(if available)path_context_keyInvalidation and anti-loop policy
AI ↔ resolver feedback loop
path_feedback.status = "mismatch"path_feedback.suggested_file_pathreasonlast_validonly after successful resolution/execution.Branch mismatch risk signal
branch_mismatch_risk: low|medium|highExample response metadata (proposed)
{ "resolved_file_path": "/abs/path/internal/config/loader.go", "path_resolution_source": "last_valid_file_path", "path_resolution_confidence": 0.86, "used_fallback": true, "workspace_root": "/home/.../go/src/github.com/doITmagic/rag-code-mcp", "git_branch": "feature/path-resolver-v2", "git_head": "a1b2c3d", "worktree_id": "main-worktree", "path_context_key": "workspace+branch+head+worktree", "branch_mismatch_risk": "low" }Scope
Non-goals
Acceptance Criteria
mismatchfeedback is accepted and influences next resolution.branch_mismatch_riskis computed and returned.file_pathwhen context is inferable.Suggested implementation order