Repository navigation
fix(5223): point tsconfig extends and exact paths at the scanned file - #5341
Deepjyoti-Sarmah wants to merge 4 commits into
Conversation
…onfigs
build_from_json returns an undirected graph, so g.edges() can list an edge
either way round; build keeps the written direction in _src/_tgt. A base
config holding only {} has no config name or key and is skipped by
_is_config_json, so it has no node to point at. The inherited-baseUrl case
now requires the lib/x.ts edge tsc 5.9.3 resolves.
A relative extends (or one that resolves after appending .json, as tsc does) now emits an edge stamped with target_file, so extract()'s repoint pass lands it on the real config's node instead of a concept stub labelled with the raw text. Package and missing extends keep their stub. An exact compilerOptions.paths alias now references the first target that exists, resolved against baseUrl (the config's own, else one inherited through local extends) or the declaring config's directory. Wildcard aliases, and configs whose baseUrl could come from a package, get no edge.
A cache filled by 0.9.112 served the old ref_tsconfig_json stub to the fixed extractor (2/2 from cache); with 49 both files re-extract.
|
Thanks for the pull request, @Deepjyoti-Sarmah. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify code review 
Review completed · 115ec25010ac
Warning
Merge confidence: 3/5 · Review before merging · 🟠 High impact
1 P2 bug checked against the code
The JSON config extractor now links local tsconfig extends values and exact paths aliases to files in the scan.
Full summary
The JSON config extractor now links local tsconfig extends values and exact paths aliases to files in the scan. Cache schema 49 invalidates prior cached extractions.
Bugs (1)
P2 · Check all parents in extends when resolving baseUrl in _paths_base: choosing only the last parent can resolve exact paths aliases against the child directory instead of an earlier parent's inherited baseUrl. Inspect source
Detailed review · checked against the code
Mappings miss baseUrl inherited from earlier parent configs
When a config extends multiple local configs, paths mappings can point to the wrong files if only an earlier parent sets baseUrl.
Expected: Resolve the alias target against the inherited baseUrl declared by the earlier parent.
Actually: Resolve the target against the child config directory, potentially omitting the reference or linking the wrong scanned file.
When paths has an exact alias, extract_json calls _paths_base and resolves the target against its returned directory. For an extends array, _paths_base selects only the last string parent. If that parent has no baseUrl or further extends, it returns the child config directory without checking earlier parents. The alias loader independently confirms arrays are processed in order and parent aliases are merged, so an earlier parent’s inherited settings can remain in effect. This can make the extractor miss the target file or emit a reference to the wrong file.
-
Independent source review: Checked the alias loader’s array handling and the
extract_jsonpath-resolution caller. The loader processes parents in order; no guard in the inspected_paths_baseroute checks earlier parents after selecting the last one. -
Also reported as: Aliases use the wrong base when a later parent omits
baseUrl
Code graph and static checks · 3752 functions depend on this change
Impact & health
Impact — 3752 functions depend on the 123 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract()— 1284 callers, 78 callees - worse:
extract_json()— 33 callers, 8 callees - new:
_edges()— 5 callers, 3 callees - worse:
walk_object()— 1 callers, 11 callees
Formal checks — 3752 functions this change can affect weren't formally checked in this review. Formal checks are informational only.
Gate & verification
✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 2211 function(s) in the blast radius were not formally verified this run
Test selection
60 of 594 test file(s) selected (10%) via static blast radius.
tests/test_binary_media_words.py— impacttests/test_cache.py— impacttests/test_cache_long_paths.py— impacttests/test_cache_stale_import_target.py— impacttests/test_cache_windows_case_4925.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_code_only_scope_4923.py— impacttests/test_cpp_template_members.py— impacttests/test_csharp_partial_classes.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_extract.py— impacttests/test_extract_cache_location.py— impacttests/test_extract_cli.py— impacttests/test_grammar_cache_key.py— impacttests/test_hook_content_freshness.py— impacttests/test_ignore_file_encoding.py— impacttests/test_incremental_mtime_collision.py— impacttests/test_java_member_calls.py— impacttests/test_java_nested_type_identity.py— impacttests/test_js_member_collisions.py— impacttests/test_json_schema_config.py— impacttests/test_language_override_lifecycle.py— impacttests/test_language_overrides.py— impacttests/test_linked_worktree_reconcile.py— impacttests/test_llm_ambiguous_fragments.py— impacttests/test_llm_backends.py— impacttests/test_manifest_ingest.py— impacttests/test_msbuild_dir_evidence.py— impacttests/test_objc_field_table_remap.py— impacttests/test_out_dir_evidence.py— impacttests/test_partial_cache.py— impacttests/test_pipeline.py— impacttests/test_python_inherited_method_calls.py— impacttests/test_python_injected_factory_calls.py— impacttests/test_python_property_reads.py— impacttests/test_python_pytest_fixture_receivers.py— impacttests/test_rust_self_member_calls.py— impacttests/test_rust_use_trees.py— impacttests/test_semantic_cache_basename_recovery.py— impacttests/test_semantic_cache_out_root.py— impacttests/test_skill_persisted_scan_options.py— impacttests/test_skill_semantic_all_cached.py— impacttests/test_skillgen.py— impacttests/test_slice_checkpoint_completeness.py— impacttests/test_stale_prune.py— impacttests/test_stat_index_husk.py— impacttests/test_stat_index_multi_root.py— impacttests/test_stat_index_portability.py— impact- … and 10 more
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Every flagged function
extract()ingraphify/extract.py:11742· 1284 callers, 78 callees: fans out to 78 callees (efferent coupling); 1284 callers depend on it (afferent coupling)extract_json()ingraphify/extractors/json_config.py:141· 33 callers, 8 callees: fans out to 8 callees (efferent coupling); 33 callers depend on it (afferent coupling)_edges()intests/test_tsconfig_declaration_targets.py:7· 5 callers, 3 callees: high coupling complexity (Ca·Ce = 15)walk_object()ingraphify/extractors/json_config.py:231· 1 callers, 11 callees: fans out to 11 callees (efferent coupling)
What does this PR do?
Fixes #5223. In a tsconfig, a local
extendsbecame a concept stub labelled with its raw text, and an exactcompilerOptions.pathsalias produced no edge at all. On 0.9.112, with the issue's repro:Both come from
extract_jsoningraphify/extractors/json_config.py. Traced in pdb:The fix resolves both to the real file and emits only the edge, stamped with
target_file. That's how JS imports already do it (#2195), so extract()'s existing repoint pass lands the edge on the target's file node:Choosing the base directory for
pathsI measured four candidates against the new tests, and checked the disputed cases against
tsc5.9.3 (--traceResolution,--showConfig):base/setsbaseUrl: "../lib", child declares"@d": ["x.ts"])x.ts, wrongextendsmay supply oneextendsfor baseUrl (this PR)lib/x.ts, same as tsc./tsconfig.json, so a label alone can't tella/fromb/tscresolved@dtolib/x.tsand"extends": "./tsconfig.base"totsconfig.base.json. C matches both.Commits
Type of change
Verification & Invariants
Invariant: an
extendsor exactpathstarget that is a scanned file is that file's node. Anything else keeps today's stub or gets no edge.Merge Danger
Door: two-way. No schema or API change. Reverting the two fix commits restores 0.9.112 output; the cache bump only forces one re-extraction.
Blast Radius: small.
extendsandpathsedges.extendsnow joins the parent config's node instead of a private stub, so those configs may move into the same community._AST_CACHE_SCHEMA48 -> 49, so every cached file re-extracts once. Without it, a cache filled by 0.9.112 served the oldref_tsconfig_jsonstub to the fixed extractor (2/2 files from cache).Limitations
"@/*": ["src/*"]) get no edge, as the issue suggests; expanding them needs its own policy.pathshas no own baseUrl and theextendschain leaves the scan (a package such as@tsconfig/...), the base can't be known, so there is no edge.extendspointing at a JSON file graphify doesn't scan (no config name or key, e.g.{}) has no node to link to and drops out, as before.pathsisreferences, notimports, so it stays out of import-cycle and dependency analytics.How was this tested?
New
tests/test_tsconfig_declaration_targets.py, 15 tests, each building a graph from a small tree:340268a7115ec250Full suite, both trees run at the same time in the same venv:
340268a7115ec250No failure is unique to this branch. The one failure unique to
340268a7,test_language_override_lifecycle.py::test_watch_root_config_lifecycle_rebuilds_and_refreshes_event_mapping[replace], is a watch timing test unrelated to JSON extraction.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (No fragment change.)