Markdown skips extract_markdown in the Claude Code skill pipeline: docs go to the LLM instead of the structural extractor
Markdown never reaches extract_markdown in the skill pipeline: docs are sent to the LLM instead of the structural extractor
Repo: safishamsi/graphify · Version: graphifyy 0.9.32 (uv tool) · Backend: gemini-3-flash-preview
Summary
graphify/extractors/markdown.py is a deterministic, zero-token markdown extractor. It emits heading nodes, contains edges for heading nesting, and references edges for inline links, reference-style links, and [[wikilinks]] — all at confidence: EXTRACTED, with no LLM.
In the /graphify skill pipeline it never runs on .md files.
Step 3 Part A passes only detect['files']['code'] into extract(). detect classifies .md as document. Documents route to Part B (semantic/LLM extraction). So markdown files are sent to a model to have their structure inferred, while the exact structural parser for them sits unused.
Code does not have this problem: it gets the AST baseline and a semantic layer. references/extraction-spec.md even tells the model so:
Code files: focus on semantic edges AST cannot find (call relationships, shared data, arch patterns). Do not re-extract imports - AST already has those.
There is no equivalent instruction for documents, because no structural pass ran to make one true.
Relation to #2014
This is the complementary direction of #2014 ("Possible silent downgrade of semantic Markdown nodes during AST-only rebuild", fixed in v0.9.21, verified present in 0.9.32).
- #2014: the CLI
graphify updatepath does runextract_markdownon.md, and it replaced the semantic layer with heading nodes. Fixed by making the semantic layer survive an AST-only rebuild. - This issue: the Claude Code
/graphifyskill pipeline never runsextract_markdownon.mdat all, so the structural layer is never added in the first place.
Same two layers, opposite failure. #2014 stopped structural from clobbering semantic; this asks for structural to actually run alongside semantic — which is what the code path already does with AST.
Evidence
Same four markdown files, two paths.
Path A — what the pipeline actually did (Part B, Gemini): tokens spent, structure inferred, heading tree absent from the graph.
Path B — calling the structural extractor directly:
from pathlib import Path
from graphify.extract import extract
files = [Path('nlm/SPEC-governed-docs-corpus.md'), Path('nlm/nlm-corpus-spec.md'),
Path('CONTRACT-technical-implementation-handback.md'), Path('prompts/fable5-prompting.md')]
r = extract(files, cache_root=Path('.'))nodes: 48 edges: 49
relations: [('contains', 44), ('references', 5)]
input_tokens: 0 output_tokens: 0Nodes carry real heading structure and source_location:
nlm_spec_governed_docs_corpus SPEC-governed-docs-corpus.md
nlm_spec_governed_docs_corpus_spec_governed_docs_corpus SPEC: Governed Docs Corpus
nlm_spec_governed_docs_corpus_0_prior_art_read_before_... 0. Prior art — read before building anyt…
nlm_spec_governed_docs_corpus_1_why 1. Why
nlm_spec_governed_docs_corpus_2_what_it_is 2. What it is48 nodes and 49 edges, deterministic, for zero tokens — from four files that the pipeline instead sent to an LLM.
Effect on a full run
Input: 28 files (26 documents/images, 2 code), 726k words, at ~/projects/meta-tools (files enumerated in graphify-out/manifest.json; greppable with rg <pattern> ~/projects/meta-tools/). Result: 491 nodes, 388 edges, 177 communities, 1,945,808 input / 64,399 output tokens.
Relation distribution in the resulting graph.json:
| relation | edges |
|---|---|
references |
131 |
calls |
105 |
inherits |
67 |
implements |
50 |
imports |
10 |
contains |
8 |
rationale_for |
7 |
conceptually_related_to |
7 |
cites |
2 |
semantically_similar_to |
1 |
Only 8 contains edges across the whole graph, from 26 document files that collectively hold hundreds of headings — because the heading-structure pass never ran on them. In the four-file structural test above, those same four files alone produce 44.
Downstream, the graphify export wiki audit trail on document communities reports:
## Audit Trail
- EXTRACTED: 4 (50%)
- INFERRED: 4 (50%)Half of a document community's relationships are model-reasoned, in a graph where a deterministic extractor for those same files was available and unused. 340 of 491 nodes finished with ≤1 connection.
Proposed fix
Run the structural pass on document-classified files before semantic extraction, mirroring the code path:
- Part A feeds structural extraction with
.md/.mdx/.markdown/.rstfiles fromdetect['files']['document'], not justfiles['code']._MD_LINKABLE_EXTSinextractors/markdown.pyalready enumerates the extensions. - Part C merges structural + semantic for documents exactly as it does for code.
references/extraction-spec.mdgains the document analogue of the existing code instruction: "Do not re-extract headings or markdown links — the structural pass already has those. Focus on named concepts and relationships the parser cannot see."
This costs no new architecture — it reuses the AST/semantic split already proven on the code path — and it moves document structure from INFERRED to EXTRACTED while reducing token spend.
Measured effect of the fix
I applied it: ran extract() over the 24 document-classified .md files plus the 2 code files, merged the result into the existing semantic graph, and rebuilt. Structural extraction returned 367 nodes and 362 edges for 0 tokens.
| nodes | edges | contains |
deg-0 | components | largest component | |
|---|---|---|---|---|---|---|
| before | 491 | 388 | 8 | 121 | 171 | 157 |
| after | 832 | 715 | 335 | 122 | 185 | 157 |
What the fix does deliver: +341 nodes, +327 edges, all EXTRACTED at zero token cost, and heading hierarchy going from 8 contains edges to 335.
What it does not deliver, stated plainly: connectivity is unchanged. The largest connected component stays at 157 nodes, fully-disconnected nodes go 121 → 122, and component count rises as each document grows its own heading tree. The structural pass recovers intra-document structure only. In this input the documents contain 2 cross-document markdown links in total, so there was nothing for the link extractor to connect.
I checked that this is not an ID-merge defect: taking one document (nlm/SPEC-governed-docs-corpus.md, 19 nodes in the rebuilt graph) and mapping its nodes to connected components puts 18 of 19 in a single component. The structural heading tree does attach to that document's semantic nodes. The disconnection is genuinely between documents.
That is worth stating because it separates the two problems cleanly. Routing markdown to the structural extractor is a correctness and cost fix, not a connectivity fix. Inter-document connectivity is a genuinely separate gap — see the frontmatter section below.
One incidental finding while testing: graphify.extract uses a process pool, and on macOS (spawn start method) a caller whose module-level code is not under an if __name__ == "__main__": guard causes every worker to abort with "A process in the process pool was terminated abruptly," silently dropping those files with only a per-file warning. The library recovers and reports 21 source file(s) produced zero nodes, which reads like an extraction failure rather than a caller-side spawn problem. A clearer diagnostic here would save debugging time.
Secondary: relation values are not validated against the declared enum
Possibly a separate issue.
The enum in references/extraction-spec.md is:
calls|implements|references|cites|conceptually_related_to|
shares_data_with|semantically_similar_to|rationale_for85 of 388 edges (21.9%) in the run above carried values outside it — inherits (67), imports (10), contains (8).
These have two distinct origins, and the distinction matters:
contains(8) traced entirely toanalysis/wall-of-text-analysis.py— emitted by the Python AST extractor, not the LLM.extractors/markdown.pyemits it too. This is a legitimate structural relation that the documented enum simply omits.inherits(67) came from document-classified.txtfiles, i.e. the LLM path inventing a relation the prompt never offered it.
So the enum is both incomplete (it omits relations graphify's own structural extractors legitimately emit) and unenforced (the LLM path adds more on top).
The adjacent field is validated strictly (file_type "MUST be one of exactly these six values... Any other value is invalid and will be rejected"), but relation appears unvalidated. Either enforce the enum, or widen it to include what extractors actually emit — manifest_ingest.py emits depends_on, cargo_introspect.py emits crate_depends_on, and extractors/markdown.py emits contains, none of which are in the documented enum. As it stands the documented schema and the produced graph disagree on roughly a fifth of edges, which makes graph.json unreliable for programmatic consumers.
Optional, lower priority: declarative relations in frontmatter
Independent of the above. Markdown's structural extractor recovers hierarchy (contains) and linkage (references), but not the kind of relationship — whether doc A supersedes, constrains, corrects, or merely mentions doc B. references/extraction-spec.md contains no lifecycle relation terms (supersedes, depends_on, constrains, corrects, derived_from, replaces, refines — all zero occurrences).
Frontmatter is already parsed for provenance (spec line 44: source_url, captured_at, author, contributor). A relations: block would let an author declare relation kind deterministically:
---
relations:
supersedes: archive/historical/SPEC-old-playbook.md
rationale_for: specs/indexing-plan.md
cites: [specs/governed-docs.md]
---Worth noting for scoping: the Open Knowledge Format (OKF) v0.2 spec — GoogleCloudPlatform/knowledge-catalog, okf/SPEC.md, §6.1 — deliberately declines to type links ("the specific kind... is conveyed by the surrounding prose, not by the link itself"), so this is not something an emerging standard will supply. It would be graphify's own extension.
The measurement above is the argument for it. Once markdown is routed through the structural extractor, the remaining disconnection is not a pipeline defect — it is the absence of any declarable inter-document relationship. Headings and links are recoverable from the file; "this spec supersedes that one" is not, because nothing in the format lets an author write it down.
Reproduction
uv tool install "graphifyy[gemini]" --force
cd <a directory of markdown docs>
python - <<'EOF'
from pathlib import Path
from graphify.extract import extract
import collections, glob
files = [Path(p) for p in glob.glob('**/*.md', recursive=True)][:5]
r = extract(files, cache_root=Path('.'))
print(len(r['nodes']), 'nodes', len(r['edges']), 'edges', r.get('input_tokens'), 'tokens')
print(collections.Counter(e.get('relation') for e in r['edges']).most_common())
EOFStructural extraction returns nodes and edges at zero token cost. Then run the full /graphify pipeline on the same directory and compare contains edge counts in graphify-out/graph.json — the pipeline's count will be far lower, because Part A never received those files.
Environment
- graphifyy 0.9.32 via
uv tool, Python 3.13 - macOS (Darwin 25.6.0), Apple Silicon
- Backend: Gemini
gemini-3-flash-preview, 28 chunks,max_concurrency=6, 0 failed chunks
Minor: openai missing from the base install
uv tool install graphifyy does not pull openai, which the Gemini backend requires for its OpenAI-compatible endpoint. With GEMINI_API_KEY set, all 33 chunks of a first run failed in under a second. The error message named the exact fix (uv tool install "graphifyy[gemini]" --force), so impact is low — but installing the extra when a Gemini key is present would remove a guaranteed first-run failure. Happy to file separately.
Source: Graphify-Labs/graphify