feat(#131): add --source-root flag for FQN stripping#137
Conversation
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>
There was a problem hiding this comment.
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.
|
/guardian review |
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>
|



Summary
source_root: str | Noneparam to bothfile_path_to_module_fqn()functions — strips the given prefix before converting to dotssource_roots: list[str] | NonetoPythonExtractorandTypeScriptExtractorconstructors; a_pick_source_root(file_path)helper selects the first matching root per file--source-root / -soption tocgis ingest(repeatable for multiple roots)Before:
cgis ingest . --output g.db→ nodes with FQNssrc.cgis.pipeline.*After:
cgis ingest . --source-root src --output g.db→ nodes with FQNscgis.pipeline.*Closes #131
Test plan
uv run pytest— 399 passmake lint && make type-check— cleanuv 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