feat: add Clojure structural extraction#2203
Conversation
normalize_id() collapses every non-word run to "_" and strips it, so `live?`, `save!` and `x*` each normalized onto the bare name. _clojure_id() guarded only case (Foo vs foo), leaving the sigil pairs to fuse — and since a predicate beside its plain counterpart is ordinary Clojure, the extractor hit its own ID-collision assertion and dropped the WHOLE file from the graph. A namespace defining `live?` next to `live` contributed nothing. Generalize the guard from "case is significant" to "anything normalization destroys is significant". Only `-`, `.` and `/` are treated as information-preserving: they always mean `_`, and `_` is not idiomatic inside a Clojure symbol, which is what makes that mapping safe. Any other divergence between the exact name and its normalized form pins the name with a short digest. Kebab-case functions and dotted namespaces therefore keep their readable IDs (`fetch-record` -> `..._fetch_record`, `nucleus.store.send-records` -> `nucleus_store_send_records`); only genuinely ambiguous names pay for the disambiguation. On a 215-file Clojure corpus that is 16% of nodes. Call edges are unaffected: they resolve through definition_ids_by_name, which is keyed on the exact source name, so a call to `live?` still reaches `live?` and not `live`.
|
Pushed a follow-up (8f69b18) fixing an ID-collision bug found running this extractor over a 215-file Clojure codebase.
The guard is now "anything normalization destroys is significant" rather than "case is significant". Only Kebab-case functions and dotted namespaces keep their readable IDs ( Two tests added: one for sigil distinction plus call routing (a call to |
Summary
.cljcsources,and Babashka scripts through a new optional
clojureextraimplementations, multimethods, imports, and resolved same-file calls
context while excluding quoted, syntax-quoted, commented, and discarded forms
language-family analysis, hooks, docs, and generated skill artifacts
Prior art
This revisits #816 against the current modular
v8extractor architecture.Credit to @alendit for the original Clojure extractor and test direction. That
PR is currently conflicted with
v8; this implementation keeps its intent whileupdating the integration points and expanding behavioral coverage.
Notes
.ednremains data rather than executable Clojure source, so it is not sentthrough the code extractor.
tree-sitter-clojure-orchardcurrently ships as a source distribution.Installing
graphifyy[clojure]therefore requires a C compiler.Validation
uv sync --all-extras --frozenuv run --frozen pytest tests/ -q --tb=short— 3652 passed, 3 skippeduv run pre-commit run --all-filesgraphify extract --code-onlysmoketest over the Clojure fixture — 24 nodes, 38 edges