Repository navigation
feat(markdown): resolve code-span mentions into references edges - #3562
AstroMined wants to merge 3 commits into
Conversation
The markdown extractor's docstring promised a heading --references--> node edge when a backtick Name matches a known pattern, but nothing implemented it, so an AST build produced no document-to-code edge at all. extract_markdown now collects inline code spans outside fences and frontmatter as raw_calls tagged language "markdown", owned by the heading they sit under (the page before the first heading). A new markdown_mentions language resolver runs after the id-remap passes and turns them into references edges: the explicit path::Symbol[::member] form resolves through the cited file's symbols and is EXTRACTED 1.0; a bare or dotted name resolves only when exactly one callable code node carries that label and is INFERRED 0.95. Ambiguous names, builtins, missing files and non-callable matches emit nothing. The shared cross-file call pass skips markdown raw_calls so prose never emits calls edges. Tests cover span classification, raw_call ownership, end-to-end resolution, ambiguity, and cache round-tripping.
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 3 advisory finding(s) below merit a look before merge.
Formal verification. No changes could be formally verified in this run.
Graphify review — findings
Adds a Markdown code-span mention pass that turns backtick-quoted symbol references (Widget, render(), pkg.Widget, src/mod.py::Widget::render) in headings and body prose into references edges from the citing heading (or the page, above the first heading) to the code node that defines the symbol. Path-qualified mentions resolve against the cited file, walking the :: chain through contains/method edges and emitting an EXTRACTED edge; bare mentions resolve only on a unique case-sensitive match among callable/type nodes, emitting an INFERRED (0.95) edge, and ambiguous names produce nothing. Mentions ride the raw_calls channel tagged language: "markdown" so the id-remap passes rewrite them, and the shared cross-file call pass skips them so a citation never becomes a calls edge; spans reading as files (setup.py), commands, or prose are filtered out during extraction.
Worth a look
- Dotted bare mention with non-code extension misclassified as symbol —
graphify/extractors/markdown.py:275· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Segment-aligned suffix match returns first of a single-element list but suffix strip is wrong for './' prefixes —
graphify/markdown_resolution.py· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Relative Markdown paths with '..' can resolve to an unrelated suffix —
graphify/markdown_resolution.py:79· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1978 functions depend on the 288 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract()— 591 callers, 44 callees - new:
_rebuild_code()— 116 callers, 51 callees - new:
extract_js()— 85 callers, 4 callees - new:
extract_xaml()— 19 callers, 17 callees - new:
dispatch_command()— 2 callers, 124 callees - new:
_get_extractor()— 26 callers, 6 callees - new:
extract_markdown()— 17 callers, 9 callees - new:
run_pipeline()— 8 callers, 13 callees - …and 31 more — each is listed as a finding
Verification — 1978 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1803 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
276 of 276 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/test_affected_cli.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_agents_platform.py— full-run-safetytests/test_analyze.py— 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_benchmark.py— full-run-safetytests/test_benchmark_raw_graph.py— full-run-safetytests/test_build.py— impact, full-run-safetytests/test_build_merge_dedup_scope.py— full-run-safetytests/test_build_merge_hyperedges_and_prune.py— full-run-safetytests/test_build_merge_shrink_guard.py— full-run-safetytests/test_builtin_global_type_refs.py— impact, full-run-safetytests/test_cache.py— full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_carried_hyperedge_remap.py— full-run-safetytests/test_case_sensitive_resolution.py— impact, full-run-safetytests/test_charmap_encoding.py— full-run-safetytests/test_chunking.py— full-run-safetytests/test_cjs_module_extension.py— impact, full-run-safetytests/test_claude_cli_backend.py— full-run-safetytests/test_claude_md.py— full-run-safetytests/test_cli_broken_pipe.py— full-run-safetytests/test_cli_export.py— full-run-safetytests/test_cli_help.py— full-run-safetytests/test_cluster.py— full-run-safetytests/test_codebuddy.py— full-run-safetytests/test_community_hub_labels.py— full-run-safetytests/test_community_labels_skill.py— full-run-safetytests/test_confidence.py— full-run-safetytests/test_corrupt_graph_json.py— full-run-safetytests/test_cpp_nested_and_cli.py— impact, full-run-safetytests/test_cpp_objc_cross_file_calls.py— impact, full-run-safetytests/test_cpp_preprocess.py— full-run-safetytests/test_cross_extension_reexport_self_cycle.py— impact, full-run-safetytests/test_cross_language_call_resolution.py— impact, full-run-safetytests/test_cross_repo_member_calls.py— impact, full-run-safetytests/test_cross_repo_shared_types.py— full-run-safetytests/test_csharp_call_site_generic_args.py— impact, full-run-safetytests/test_csharp_enum_members.py— impact, full-run-safety- … and 226 more
changed code file(s) with no mapped test (
graphify/markdown_resolution.py) — 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.
Formal verification
Could not verify: Could not verify extract.
The verifier did not have enough to check extract, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: parameter `cache_root` is annotated `Path | None` — outside the synthesizable primitive/collection set
Could not verify: Could not verify extract\_markdown.
The verifier did not have enough to check extract\_markdown, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: parameter `path` is annotated `Path` — outside the synthesizable primitive/collection set
· 2 grounded finding(s) anchored inline below; 37 more finding(s) on lines outside this diff (see the check run).
| return None, [m.group(1)] | ||
|
|
||
|
|
||
| def extract_markdown(path: Path) -> dict: |
There was a problem hiding this comment.
extract_markdown()
fans out to 9 callees (efferent coupling); 17 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
| return calls | ||
|
|
||
|
|
||
| def resolve_markdown_mentions( |
There was a problem hiding this comment.
resolve_markdown_mentions()
fans out to 6 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
…n mention resolution Three findings from the automated review of Graphify-Labs#3562, all reproduced: A dotted span with a non-code extension (README.md, pyproject.toml) was classified as a symbol because only CODE_EXTENSIONS was checked, and every dotted form was reduced to its last segment, so time.sleep matched a repo's own sleep(). The dotted form now keeps its whole chain, the file early-exit also checks DOC_EXTENSIONS, and a bare-name match must carry every qualifier as an owner label or a segment or stem of its source path. _match_cited_file used lstrip("./"), which strips characters, so a .github/... cite could never match by suffix. The leading ./ and ../ segments are now stripped as segments, and the suffix form also matches a root-level file. An explicit ./ or ../ cite that escaped the corpus fell through to the suffix rule and could land on an unrelated copy of the file. It now resolves relative to the document only.
…isting graph _reconcile_markdown_links treats every AST-tier references edge owned by a re-parsed Markdown file as an authored [link](file) and prunes any pair it did not author. A code-span mention is also a references edge owned by its document, so a plain `graphify update` over an existing graph, with or without changes, dropped every mention edge; only a build from scratch kept them. A mention targets a code symbol, never a file representative, so the reconcile now leaves those edges to the AST ownership rule: re-extracting the document regenerates them and re-extracting the code side keeps or drops them with the target node.
|
Thanks for the review. All three advisory findings reproduce and are fixed in a0325ee:
Tests cover each case. The coupling notes describe the new resolver's fan-out and are expected for a language resolver registered through Proving the fixes through |
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 3 advisory finding(s) below merit a look before merge.
Formal verification. No changes could be formally verified in this run.
Graphify review — findings
Adds Markdown code-span mentions as a first-class cross-file signal: extract_markdown now collects backtick spans on heading and body lines (Widget, render(), pkg.Widget, src/mod.py::Widget::render) as raw_calls tagged language: "markdown" via add_mention, while _code_span_mention filters out file names, commands, and prose. The new resolve_markdown_mentions resolver turns each mention into a heading/page --references--> symbol edge once ids are final — EXTRACTED for path-qualified forms matched against the cited file, INFERRED for a bare name that resolves to exactly one callable/type, with dotted qualifiers checked against the candidate's owner chain and path. The shared cross-file call pass skips language == "markdown" raw_calls so a mention is never minted as a calls edge.
Worth a look
- Dead branch: dotted mention always returns None after extension check —
graphify/extractors/markdown.py:286· Escalate · high- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- New test module ends with incomplete expression —
tests/test_markdown_code_spans.py:289· Escalate · high- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- Path-qualified Markdown symbol chains can be resolved across different parent paths —
graphify/markdown_resolution.py:175· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 2097 functions depend on the 373 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract()— 591 callers, 44 callees - new:
_rebuild_code()— 118 callers, 51 callees - new:
extract_js()— 85 callers, 4 callees - new:
extract_xaml()— 19 callers, 17 callees - new:
dispatch_command()— 2 callers, 124 callees - new:
_get_extractor()— 26 callers, 6 callees - new:
extract_markdown()— 17 callers, 9 callees - new:
run_pipeline()— 8 callers, 13 callees - …and 32 more — each is listed as a finding
Verification — 2097 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 1923 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
111 of 276 test file(s) selected (40%) via static blast radius.
tests/test_astro_extraction.py— impacttests/test_astro_import_ids.py— impacttests/test_build.py— impacttests/test_builtin_global_type_refs.py— impacttests/test_case_sensitive_resolution.py— impacttests/test_cjs_module_extension.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_cpp_objc_cross_file_calls.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_cross_language_call_resolution.py— impacttests/test_cross_repo_member_calls.py— impacttests/test_csharp_call_site_generic_args.py— impacttests/test_csharp_enum_members.py— impacttests/test_csharp_field_generic_args.py— impacttests/test_csharp_generic_callsites.py— impacttests/test_csharp_interface_dispatch.py— impacttests/test_csharp_member_calls.py— impacttests/test_csharp_member_nodes.py— impacttests/test_csharp_object_creation.py— impacttests/test_csharp_partial_classes.py— impacttests/test_csharp_type_resolution.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_dotnet.py— impacttests/test_duplicate_annotation_edges.py— impacttests/test_extract.py— impacttests/test_extract_cache_location.py— impacttests/test_file_label_disambiguation.py— impacttests/test_file_node_id_spec.py— impacttests/test_forwarding_review_findings.py— impacttests/test_go_builtin_call_targets.py— impacttests/test_go_qualified_resolution.py— impacttests/test_import_extension_resolution.py— impacttests/test_import_self_loops.py— impacttests/test_imported_export_forwarding.py— impacttests/test_incremental.py— impacttests/test_indirect_call_arrow_single_param_shadow.py— impacttests/test_indirect_call_catch_binding_shadow.py— impacttests/test_indirect_call_external_import_shadow.py— impacttests/test_indirect_call_for_of_binding_shadow.py— impacttests/test_indirect_call_function_expression_shadow.py— impacttests/test_indirect_call_nested_closure_shadow.py— impacttests/test_indirect_dispatch.py— impacttests/test_indirect_dispatch_assign_return.py— impacttests/test_indirect_dispatch_getattr.py— impacttests/test_inferred_confidence_rubric.py— impacttests/test_inherited_field_receivers.py— impacttests/test_issue_3405_python_resolution.py— impacttests/test_java_member_calls.py— impacttests/test_java_type_resolution.py— impact- … and 61 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.
Formal verification
Could not verify: Could not verify extract.
The verifier did not have enough to check extract, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: parameter `cache_root` is annotated `Path | None` — outside the synthesizable primitive/collection set
Could not verify: Could not verify extract\_markdown.
The verifier did not have enough to check extract\_markdown, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: parameter `path` is annotated `Path` — outside the synthesizable primitive/collection set
Could not verify: Could not verify \_reconcile\_markdown\_links.
The verifier did not have enough to check \_reconcile\_markdown\_links, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: parameter `project_root` is annotated `Path` — outside the synthesizable primitive/collection set
· 2 grounded finding(s) anchored inline below; 38 more finding(s) on lines outside this diff (see the check run).
| return None, [m.group(1)] | ||
|
|
||
|
|
||
| def extract_markdown(path: Path) -> dict: |
There was a problem hiding this comment.
extract_markdown()
fans out to 9 callees (efferent coupling); 17 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
| return calls | ||
|
|
||
|
|
||
| def resolve_markdown_mentions( |
There was a problem hiding this comment.
resolve_markdown_mentions()
fans out to 7 callees (efferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
|
Shipped in v0.9.62 (now on PyPI: |
…n mention resolution Three findings from the automated review of #3562, all reproduced: A dotted span with a non-code extension (README.md, pyproject.toml) was classified as a symbol because only CODE_EXTENSIONS was checked, and every dotted form was reduced to its last segment, so time.sleep matched a repo's own sleep(). The dotted form now keeps its whole chain, the file early-exit also checks DOC_EXTENSIONS, and a bare-name match must carry every qualifier as an owner label or a segment or stem of its source path. _match_cited_file used lstrip("./"), which strips characters, so a .github/... cite could never match by suffix. The leading ./ and ../ segments are now stripped as segments, and the suffix form also matches a root-level file. An explicit ./ or ../ cite that escaped the corpus fell through to the suffix rule and could land on an unrelated copy of the file. It now resolves relative to the document only. (cherry picked from commit 3f84e7f)
Fixes #3561.
The markdown extractor's docstring promised a heading --references--> node edge for backtick names
but nothing implemented it, so an AST build produced no document-to-code edge.
extract_markdownnow reports inline code spans (outside fences and frontmatter) asraw_callstagged
language: "markdown", owned by the enclosing heading or the page node. A newgraphify/markdown_resolution.pyregisters amarkdown_mentionslanguage resolver that turns theminto
referencesedges:path::Symbol[::member]resolves through the cited file's symbols(EXTRACTED 1.0); a bare or dotted name resolves only to a unique callable code node (INFERRED 0.95).
Ambiguous, builtin, missing-file and non-callable mentions emit nothing. The shared cross-file call
pass skips markdown raw_calls so prose never produces
callsedges. The stale docstring line isreplaced with the actual behaviour.
Tests:
tests/test_markdown_code_spans.pycovers span classification, raw_call ownership and linepinning, end-to-end resolution (INFERRED, EXTRACTED, doc-relative path, ambiguous, missing file, no
calls from document nodes, no dangling edges), and cache round-tripping.
uv run pytestanduv run --frozen ruff check .are green apart from fourtest_backup_*cases intest_export.pyand four
test_pathless_postgres_*cases intest_extract_cli.py, which fail identically on cleanv8.