Skip to content

feat(#131): add --source-root flag for FQN stripping#137

Merged
zaebee merged 3 commits into
mainfrom
feat/issue-131-source-root
Jun 9, 2026
Merged

feat(#131): add --source-root flag for FQN stripping#137
zaebee merged 3 commits into
mainfrom
feat/issue-131-source-root

Conversation

@zaebee

@zaebee zaebee commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds source_root: str | None param to both file_path_to_module_fqn() functions — strips the given prefix before converting to dots
  • Adds source_roots: list[str] | None to PythonExtractor and TypeScriptExtractor constructors; a _pick_source_root(file_path) helper selects the first matching root per file
  • Adds --source-root / -s option to cgis ingest (repeatable for multiple roots)
  • 399 tests pass; mypy clean

Before: cgis ingest . --output g.db → nodes with FQNs src.cgis.pipeline.*
After: cgis ingest . --source-root src --output g.db → nodes with FQNs cgis.pipeline.*

Closes #131

Test plan

  • uv run pytest — 399 pass
  • make lint && make type-check — clean
  • Manual: uv run cgis ingest . --source-root src --output /tmp/g.db && uv run cgis validate --db /tmp/g.db — confirm unresolved ratio drops

🤖 Generated with Claude Code

Adds optional source_roots to PythonExtractor and TypeScriptExtractor so
FQNs are built relative to the nearest source root instead of the workspace
root. This eliminates phantom edges from the src.cgis.* vs cgis.* mismatch.

CLI: cgis ingest <path> --source-root src (repeatable for multiple roots)

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a --source-root (-s) CLI option to strip directory prefixes when building fully qualified names (FQNs) for Python and TypeScript/TSX files. The PythonExtractor and TypeScriptExtractor have been updated to accept and process these source roots, and comprehensive unit tests have been added. The review feedback suggests a performance optimization for both extractors: pre-normalizing the source_roots during initialization to avoid repetitive string manipulation inside the frequently called _pick_source_root method.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/cgis/extractors/python_extractor.py Outdated
Comment thread src/cgis/extractors/typescript_extractor.py Outdated
@zaebee

zaebee commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

/guardian review

zaebee and others added 2 commits June 9, 2026 15:32
Eliminates ~10 duplicate lines in each extractor (Sonar alert).
Both extractors now call super().__init__(source_roots=source_roots)
and inherit _pick_source_root from the base class.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Store (original, normalized) tuples instead of re-computing
replace/strip/concat on every _pick_source_root call. Matters for
PythonExtractor which calls it per AST node (_get_id, _resolve_type).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

@zaebee zaebee merged commit 42d5b55 into main Jun 9, 2026
3 checks passed
@zaebee zaebee deleted the feat/issue-131-source-root branch June 9, 2026 15:40
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.

feat(cli): --source-root flag for multi-root ingestion

1 participant