Skip to content

fix(clojure): extract calls whose list head carries metadata (#548) - #715

Open
himanchalkaushale wants to merge 2 commits into
redhat-et:mainfrom
himanchalkaushale:lane/clj-meta-call-548
Open

himanchalkaushale wants to merge 2 commits into
redhat-et:mainfrom
himanchalkaushale:lane/clj-meta-call-548

Conversation

@himanchalkaushale

@himanchalkaushale himanchalkaushale commented Nov 21, 2026 •

Copy link
Copy Markdown

Summary

Clojure extraction was missing valid function calls when metadata appeared before the function name inside a list.

For example:

^{:doc "tagged"} (square 4)
^String (square 5)

The issue was that tree-sitter-clojure represents metadata as a meta_lit node. The existing query did not account for this node before the function name, so these calls were skipped.

This PR fixes the issue by allowing metadata before the list head, just like comments and discard expressions.

The C++ list-head check is also updated to ensure special forms such as if remain excluded correctly.

This PR covers only Arm 1 of #548.

Implementation Details

Updated queries/clojure/tags.scm to allow comment, dis_expr, and meta_lit before the function name.

Updated clojureListHead in src/ingest_clojure.h to skip metadata when identifying the actual list head. This prevents metadata from being mistaken for the function name and keeps special-form filtering working correctly.

Added regression cases in test/clojurefix/core.clj covering normal calls, metadata calls, quoted expressions, special forms, and metadata attached to symbols.

Updated test/clojurecheck.sh with assertions for these cases, including an explicit --callers=square check.

Also updated parser versions:

  • kParserVer: 309 → 311
  • Rich file tag: 312
  • kIngestParserVerMirror: 309 → 311

Updated test/qschemetrip.hash and added a dated justification entry to test/qschemetripcheck.sh.

Testing

The following checks passed locally:

  • clojurecheck.sh: ALL PASS
  • qschemetripcheck.sh: ALL PASS
  • qextractionkeycheck.sh: PASS, mirror 311 == 311
  • langidentitycheck.sh: 371 SAME / 9 DIFF / 0 EMPTY / 0 ERROR

The 9 differences are expected and limited to the Clojure changes.

Two full-repository runs produced byte-identical output, and XML validation passed.

Build and test commands

cmake -S . -B build
cmake --build build -j

bash test/clojurecheck.sh ./build/ripwire
bash test/qschemetripcheck.sh
bash test/qextractionkeycheck.sh ./build/ripwire

Manual verification

./build/ripwire test/clojurefix --no-cache --callees=meta-call
./build/ripwire test/clojurefix --no-cache --callees=tag-call
./build/ripwire test/clojurefix --no-cache --callees=quoted-meta
./build/ripwire test/clojurefix --no-cache --callees=special-form-metadata
./build/ripwire test/clojurefix --no-cache --callers=square

Metadata calls are now detected correctly, while quoted expressions, special forms, and metadata attached to symbols remain excluded.

ASan and the full pargates.py suite were not run because the development environment was Windows.

Scope

This PR fixes only Arm 1 of #548.

The following are intentionally out of scope:

  • anon_fn_lit (Arm 2)
  • Syntax-quote unquotes
  • Qualified-call resolution
  • Reader conditionals
  • Parser refactoring

Closes Arm 1 of #548.

Summary by CodeRabbit

  • Bug Fixes
    • Clojure calls prefixed with metadata are now captured correctly. Quoted metadata, special forms, and metadata on non-call expressions remain excluded.
    • Caller filtering now works for metadata-prefixed calls.

A Clojure list with metadata before its head (`^{:doc "tagged"} (square 4)`,
`^String (square 5)`) parses with a named meta_lit child in front of the head,
so the call pattern's `.` anchor never reached the sym_lit and the call was
dropped. Accept meta_lit in the same leading slot as comments and discards.

The C++ head filter must skip meta_lit too: otherwise a metadata-prefixed
special form would read as head "meta_lit" and bypass the special-form gate.
Metadata on non-call forms and inside quoted code stays inert.

Bump kParserVer 309 -> 311 (rich file tag 312) with quality.h's mirror and
re-pin test/qschemetrip.hash. Add fixture and gate arms for tagged, plain,
quoted, special-form, and non-call metadata, including an explicit
--callers=square assertion. Arm 1 of redhat-et#548 only; anon_fn_lit is untouched.
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Clojure direct-call extraction now accepts metadata literals between a list head and the captured symbol. The C++ list-head filter also skips metadata literals. Tests cover metadata-prefixed calls, excluded forms, and caller filtering. Parser-version markers and the re-pin log are updated; cache versions remain unchanged.

Changes: Clojure call extraction

Layer / File(s) Summary
Metadata-prefixed call extraction
queries/clojure/tags.scm, src/ingest_clojure.h, src/ingest_cache.h, src/quality.h, test/clojurecheck.sh, test/qschemetripcheck.sh
The direct-call query and C++ list-head filter now skip metadata literals. Tests cover metadata-prefixed calls, quoted metadata, special forms, non-calls, and caller filtering. Parser-version markers change from 309 to 311; the rich-file tag is 312. The cache version and cache scheme remain unchanged.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: tag-und-nacht, joyful-ii-v-i

Merge Risk: Minimal · previous review 63a7a

This change makes Clojure calls with metadata before the function name, such as ^String (square 5), appear in extracted call data. Special forms and metadata on non-call forms remain excluded. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: Clojure call extraction now handles list heads that carry metadata. The PR objectives confirm the query and clojureListHead changes that do this. The title follows con…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: Clojure call extraction now handles list heads that carry metadata. The PR objectives confirm the query and clojureListHead changes that do this. The title follows conventional commit form and cites issue #548. It is specific and accurate.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f79a94e and 63a7aaf.

Files ignored due to path filters: 2

  • test/clojurefix/core.clj is excluded by !test/*fix/**
  • test/qschemetrip.hash is excluded by !test/*.hash
Files selected for processing: 6

  • queries/clojure/tags.scm
  • src/ingest_cache.h
  • src/ingest_clojure.h
  • src/quality.h
  • test/clojurecheck.sh
  • test/qschemetripcheck.sh

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

# Conflicts:
#	src/ingest_cache.h
#	src/quality.h
#	test/qschemetrip.hash
#	test/qschemetripcheck.sh
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.

1 participant