Skip to content

feat(markdown): capture relative links as dependency edges (closes #2638) - #2639

Merged
squid-protocol merged 2 commits into
mainfrom
sweep/2587-markdown
Sep 2, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
sweep/2587-markdown

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Rosetta[markdown] sweep (#2587), the engine half. Three coupled changes:

1. markdown _dependency_capture

Captures the target of every inline link (image form included) whose target is repo-relative. Excluded by lookahead: scheme-prefixed (https:, mailto:), protocol-relative (//…), pure-anchor (#…), and angle-bracket-wrapped (<…>, CommonMark's escape hatch for URLs with parens — found live in wtfpython's README during the re-bless) targets. Capture stops before #fragment/titles so the census suffix map resolves the bare path in O(1). Bracket half reuses lit_links' vetted bounded shape; 4 ReDoS detonations in the strict suite.

2. galaxyscope Phase 6: inert opt-in

An is_inert language that explicitly declares _dependency_capture now opts back into dependency extraction; the other inert skips (security lens, named tokens, popularity census) stay skipped. This also wakes yaml's deliberately-authored but silently dead uses:/image: capture (#813/#843) — GitHub Actions and container refs now produce real DAG edges (supply-chain relevant; moves #2606's numbers as a free improvement).

3. detector.py: early-return raw_imports placeholder removal

The four early-return paths (prose deflection #691, low-confidence bypass, empty code_stream, catastrophic-failure fallback) emitted a placeholder "raw_imports": [] that data_payload.update(logic_data) merged over the worker's already-extracted dependencies — silently erasing them for every file hitting those paths. Removed; regression-pinned in test_detector.py.

Why the golden masters changed

Only .md files gain Extracted Dependencies/Dependency Network fields, their link targets gain downstream popularity (e.g. springboot's LICENSE.txt), plus the rollups new DAG edges imply (imports_unknown +12, modularity/assortativity in the 4th decimal). Verified twice with scope_check.py against origin/main — nothing outside that moved.

Validation

  • 29 strict markdown tests (7 positive captures, 9 negatives incl. the angle-bracket regression, boundary + ReDoS) + detector regression pin: all pass
  • audit_check.py (ruff/mypy/dead-key/ast + format): clean
  • tree_sitter_accuracy_audit.py --ci --all: 30 languages OK
  • tri_comparison_chart.py --all --ci: OK
  • Corpus effect: keyword-rosetta markdown main→a→b→c resolves (import_count main/a/b=1 c=0, popularity a/b/c=1, dependency_links 3 = the cross-language median; api stays 0 — orphan→api conversion needs functions). markdown & yaml both leave dependency_links red: consistency 78%→83%, repo-wide 17→18 metrics ≥80% green band.
  • New docs/language_status/markdown.md with the full rosetta capstone (§8).

Noted, NOT addressed here (pre-existing, engine-wide): import_cleaner strips leading use/source/etc. without a word boundary, mangling captured names like usage.md — see #2638.

Cross-repo

Companion keyword-rosetta PR (ledger markdown-lit-plane-morphology, na_baseline 34→16, bias regen) follows with ENGINE_REF: pull/<this>/head; this PR merges first, then corpus PR restores ENGINE_REF: main and merges, then KEYWORD_ROSETTA_REF bumps here. rosetta-audit on this PR fails until then — expected, the gate catching drift at the source.

Closes #2638. Part of #2587 (epic #2560).

🤖 Generated with Claude Code

squid-protocol and others added 2 commits September 1, 2026 19:46
Three coupled changes, found working the rosetta[markdown] sweep (#2587):

1. markdown gains _dependency_capture: the target of every inline link
   (image form included) whose target is repo-relative -- scheme-prefixed,
   protocol-relative and pure-anchor targets excluded; capture stops before
   fragments/titles so the census suffix map resolves it O(1). The bracket
   half reuses lit_links' vetted bounded shape; ReDoS-detonated in strict
   tests.

2. galaxyscope Phase 6: an is_inert language that explicitly DECLARES
   _dependency_capture now opts back into dependency extraction (the other
   inert skips -- security lens, named tokens, popularity census -- stay
   skipped). This also wakes yaml's deliberately-authored but silently dead
   uses:/image: capture (#813/#843): GitHub Actions/container refs now
   produce real DAG edges.

3. detector.py: the four early-return paths (prose deflection, low-confidence
   bypass, empty code_stream, catastrophic-failure fallback) no longer emit a
   placeholder "raw_imports": [] -- data_payload.update(logic_data) was
   clobbering the worker's already-extracted dependencies for every file
   hitting those paths. Regression-pinned in test_detector.py.

Corpus effect: keyword-rosetta markdown main->a->b->c resolves (import_count
main/a/b=1 c=0, popularity a/b/c=1, dependency_links 3 = median; api stays 0,
orphan->api conversion needs functions). New docs/language_status/markdown.md
carries the full rosetta capstone.

Co-Authored-By: Claude Fable 5 <[email protected]>
…ket link targets

The re-bless diff itself caught a capture flaw: CommonMark angle-bracket
destinations ([x](<https://.../Collision_(computer_science)>), the escape
hatch for URLs with spaces/parens) start with '<', slipping past the scheme
lookahead and capturing a junk fragment. The lookahead now rejects '<'
outright -- angle-wrapped targets are overwhelmingly external URLs. Found
live in wtfpython's README; pinned as strict negative cases.

Fixture diff shape (verified twice via scope_check against origin/main):
only .md files gain Extracted Dependencies / Dependency Network fields,
their link targets gain downstream popularity (e.g. springboot LICENSE.txt),
plus the graph rollups new edges imply (imports_unknown +12,
modularity/assortativity 4th decimal).

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit c4208a1 into main Sep 2, 2026
31 checks passed
@squid-protocol
squid-protocol deleted the sweep/2587-markdown branch September 2, 2026 00:08
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.

markdown: capture relative links as dependency edges (rosetta #2587, dependency_links 0 vs median 3)

1 participant