Skip to content

feat(impact): add optional doc_refs field for DocRel integration#6

Closed
seek-hope wants to merge 1 commit into
codegraph-ai:mainfrom
seek-hope:feat/doc-refs-in-impact
Closed

feat(impact): add optional doc_refs field for DocRel integration#6
seek-hope wants to merge 1 commit into
codegraph-ai:mainfrom
seek-hope:feat/doc-refs-in-impact

Conversation

@seek-hope

Copy link
Copy Markdown

Summary

This PR adds an optional doc_refs field to the codegraph_analyze_impact tool response, enabling integration with the DocRel code-documentation sync system.

Design

When a project uses DocRel, a .docrel/mappings.json file exists in the project root with symbol→document references. This PR:

  1. Adds DocRef structdoc_file, doc_anchor, relationship, symbol_name
  2. Adds doc_refs: Option<Vec<DocRef>> to ImpactResult — skips serialization when absent
  3. Reads .docrel/mappings.json in analyze_impact() — matches affected symbol names against mappings
  4. Passes workspace folder as project_root — from workspace_folders.first()

Behavior

  • Zero-cost when DocRel is not in use — if .docrel/mappings.json doesn't exist, doc_refs is None
  • Graceful degradation — file read or parse failure silently falls back to None
  • Only returns matching refs — filters mappings to symbols affected by the change

Context

This is the lightweight CodeGraph side of the DocRel design spec — CodeGraph provides read-only doc hints; DocRel manages mappings and sync logic.

🤖 Generated with Claude Code

When a project uses the DocRel code-documentation sync system, a
.docrel/mappings.json file exists in the project root. This change:

1. Adds a DocRef struct with doc_file, doc_anchor, relationship, and
   symbol_name fields.
2. Adds an optional doc_refs: Option<Vec<DocRef>> field to ImpactResult.
3. In analyze_impact(), reads .docrel/mappings.json if present and
   attaches matching doc references for affected symbols.
4. Passes the workspace folder as project_root to enable the lookup.

The feature is zero-cost when DocRel is not in use — if the
.docrel/mappings.json file doesn't exist, no doc_refs are returned.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 23, 2026 10:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds optional DocRel documentation references (doc_refs) to the codegraph_analyze_impact tool response so downstream agents can see which docs may need updates when impacted symbols change.

Changes:

  • Introduce DocRef and add doc_refs: Option<Vec<DocRef>> to the impact analysis result (skipping serialization when absent).
  • Read .docrel/mappings.json (when present) and attach matching doc references for affected symbols.
  • Thread a project_root argument into analyze_impact() (MCP passes the first workspace folder; LSP passes None).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/codegraph-server/src/domain/impact.rs Adds DocRel types/field and reads .docrel/mappings.json to populate doc_refs.
crates/codegraph-server/src/mcp/server.rs Passes workspace folder as project_root into analyze_impact() for DocRel lookup.
crates/codegraph-server/src/handlers/custom.rs Updates the LSP handler call to match the new analyze_impact() signature (passes None for project_root).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// entries so agents see which docs need updating when a symbol changes.
let doc_refs: Option<Vec<DocRef>> = project_root.and_then(|root| {
let mappings_path = root.join(".docrel").join("mappings.json");
let content = std::fs::read_to_string(&mappings_path).ok()?;
Comment on lines +331 to +335
relationship: m
.get("rel_type")
.and_then(|v| v.as_str())
.unwrap_or("describes")
.to_string(),
@seek-hope seek-hope closed this by deleting the head repository Jun 24, 2026
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.

2 participants