Repository navigation
refactor(extract): rename _safe_extract_with_xaml_root to _safe_extract_with_scan_root; guard invariant #4 package-wide (#3666) - #5309
Conversation
…ct_with_scan_root; guard invariant Graphify-Labs#4 package-wide (Graphify-Labs#3666) _safe_extract_with_xaml_root publishes the in-flight scan root around every per-file extraction, not just XAML, so the XAML-era name was misleading (the side note in Graphify-Labs#3666). Rename it; no alias is kept, because tests monkeypatch the module attribute and an alias would make patches on the old name silently stop intercepting calls. Graphify-Labs#3666's reverse import from extractors/markdown.py was fixed in Graphify-Labs#3758, but only markdown.py was guarded. Add a test that parses every module under graphify/extractors/ and fails if any imports the graphify.extract facade in any form (absolute, `from graphify import extract`, or relative), so MIGRATION.md invariant Graphify-Labs#4 cannot silently regress. Verified to fail when such an import is introduced and to flag the pre-Graphify-Labs#3758 markdown.py. Refs Graphify-Labs#3666
|
Thanks for the pull request, @Vijay431. 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 · 483893fe079e
Tip
Merge confidence: 5/5 · Looks safe to merge · 🟠 High impact
No issues reported
The extraction wrapper was renamed, and its internal extraction and Markdown-reconciliation callers were updated.
Full summary
The extraction wrapper was renamed, and its internal extraction and Markdown-reconciliation callers were updated. Tests and comments were changed to use the new name and broaden the import-direction guard.
What this review covered
- We didn't review 1 file that isn't source code, such as docs, config, images, or generated or third-party code.
- 8 of 8 changed files inspected. This is scope, not a correctness guarantee.
Code graph and static checks · 6929 functions depend on this change
Impact & health
Impact — 6929 functions depend on the 1249 functions this change touches.
Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
extract()— 1282 callers, 78 callees (high)_rebuild_code()— 281 callers, 76 callees (high)build_from_json()— 324 callers, 26 callees (high)build_merge()— 125 callers, 18 callees (high)dispatch_command()— 8 callers, 156 callees (high)_extract_generic()— 21 callers, 55 callees (high)extract_sql()— 59 callers, 14 callees (high)extract_js()— 101 callers, 8 callees (high)- …and 2 more
Formal checks — 6929 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: 6229 function(s) in the blast radius were not formally verified this run
Test selection
593 of 593 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety (
noncode-change,uncovered-code) — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/pi.test.ts— full-run-safetytests/test_4874_jvm_resolution.py— impact, full-run-safetytests/test_4909_reference_binding_scale.py— impact, full-run-safetytests/test_4978_reconcile_cost.py— impact, full-run-safetytests/test_4992_ts_import_types.py— impact, full-run-safetytests/test_5072_splittable_under_cap_retry.py— impact, full-run-safetytests/test_affected_cli.py— full-run-safetytests/test_affected_defines.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_affected_overrides.py— impact, full-run-safetytests/test_affected_path_file_node.py— full-run-safetytests/test_affected_seed_reference_forms.py— full-run-safetytests/test_agents_platform.py— full-run-safetytests/test_alias_folding.py— impact, full-run-safetytests/test_analyze.py— impact, full-run-safetytests/test_anthropic_custom_endpoint.py— full-run-safetytests/test_antigravity_install.py— full-run-safetytests/test_apm_fallback_version.py— full-run-safetytests/test_architecture_doc.py— full-run-safetytests/test_astro_extraction.py— impact, full-run-safetytests/test_astro_import_ids.py— impact, full-run-safetytests/test_atomic_canvas_export.py— full-run-safetytests/test_atomic_version_stamp.py— full-run-safetytests/test_atomic_writes.py— full-run-safetytests/test_backend_env_isolation.py— full-run-safetytests/test_backend_extras.py— full-run-safetytests/test_backend_opt_in.py— impact, full-run-safetytests/test_benchmark.py— full-run-safetytests/test_benchmark_raw_graph.py— full-run-safetytests/test_benchmark_real_query.py— full-run-safetytests/test_binary_media_words.py— full-run-safetytests/test_blade_extractor.py— impact, full-run-safetytests/test_build.py— impact, full-run-safetytests/test_build_located_semantic_identity.py— impact, full-run-safetytests/test_build_merge_dedup_scope.py— impact, full-run-safetytests/test_build_merge_ghost_fold_4955.py— impact, full-run-safetytests/test_build_merge_hyperedges_and_prune.py— impact, full-run-safetytests/test_build_merge_shrink_guard.py— impact, full-run-safetytests/test_builtin_global_type_refs.py— impact, full-run-safetytests/test_c_include_resolution.py— impact, full-run-safetytests/test_cache.py— impact, changed-test, full-run-safetytests/test_cache_long_paths.py— full-run-safetytests/test_cache_stale_import_target.py— impact, full-run-safetytests/test_cache_windows_case_4925.py— full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_cargo_missing_manifest.py— full-run-safetytests/test_carried_hyperedge_remap.py— impact, full-run-safetytests/test_case_only_decl_ids_4904.py— impact, full-run-safetytests/test_case_sensitive_resolution.py— impact, full-run-safety- … and 543 more
⚠️ non-code file(s) changed (graphify/extractors/MIGRATION.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)
⚠️ changed code file(s) with no mapped test (graphify/extractors/MIGRATION.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests
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.
What does this PR do?
Follow-up to #3666. Item 1 of the issue (
extractors/markdown.pyimportinggraphify.extract) was already fixed in #3758, which moved the in-flight scan root toextractors/base.py. This PR covers the two remaining pieces from item 1:Rename (the issue's side note).
_safe_extract_with_xaml_rootpublishes the scan root around every per-file extraction, not just XAML, so the XAML-era name was misleading. It is now_safe_extract_with_scan_root. No alias is kept. Tests monkeypatch the module attribute, and an alias would make a patch on the old name silently stop intercepting calls. The function is private and has one production importer (watch.py).Package-wide guard for MIGRATION.md invariant Telemetry and data privacy #4. Only
markdown.pywas checked. The issue noted the reverse import "will recur for the next extractor that needs it".tests/test_extractor_scan_root_context.pynow parses every module undergraphify/extractors/withast(no imports, so no side effects). It fails if any module imports the facade in any of these forms:import graphify.extractfrom graphify.extract import …from graphify import extractfrom ..extract import …from .. import extractEach offender is listed as
file:line. MIGRATION.md invariant Telemetry and data privacy #4 now points to this test.Item 2 of the issue (the facade re-exporting private symbols) is a direction question for maintainers and is intentionally not addressed here.
Refs #3666
Type of change
Verification & Invariants
Invariant protected: MIGRATION.md #4, "never import from
graphify.extractinsidegraphify/extractors/". The rename is behavior-neutral: the same function does the same thing under a new name. No persisted or generated state is affected.Proof that the guard catches the old failure:
import graphify.extracttographify/extractors/zig.pymakestest_no_extractor_module_imports_graphify_extractfail. The probe was reverted afterwards.markdown.py(git show 97922b9c^:graphify/extractors/markdown.py) flags line 149, the old function-local import.Limitation: the guard is static (AST). It does not catch dynamic imports such as
importlib.import_module("graphify.extract")or__import__.How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A: no fragments touched)