Files
codegraph/__tests__
Colby MchenryandClaude Opus 5.5 53f72fec90 fix(liquid): variables declared with {% capture %} are indexed, as assigned ones are (#2814)
The Liquid extractor indexed a variable declared with {% assign %} as a
variable node, in both spellings (braced, and as a line of a
{% liquid %} tag) and skipping comment and raw regions, but it never
read {% capture %}, Liquid's other way to declare a variable. A
captured variable could not be found: search missed it, and
codegraph_explore reported its name as not in the index.

Fix:
- extractAssignments reads capture tags through the same
  findTagOccurrences scanner as assign, so both spellings and the
  comment/raw rule apply. The name is word characters, as for assign,
  optionally in single or double quotes (Liquid reads 'title' as
  title), and must end at whitespace or the tag's end (-%} included). A
  name that goes on with "-" or ".", which the assign rule doesn't read
  either, gets no node rather than a cut-short one.
- Captures are read after assigns. Node ids are keyed by file, kind,
  name and line, so an assign keeps its id when a capture of the same
  name shares its line.
- One helper now builds the variable node and its contains edge for
  both. It computes the declaration's column once, where the assign
  code computed it three times, each a split of the whole file.

Validation:
- 13 new tests in __tests__/extraction.test.ts. 11 fail with main's
  extractor and pass with the fix: 8 declaration forms (braced,
  whitespace-trimmed, tight -%}, single- and double-quoted, {% liquid %}
  lines with LF and CRLF, a quoted {% liquid %} line), an assign and two
  captures of one name on one line (distinct ids, the assign keeps
  its), tags inside a capture body, and an index-level test that search
  finds captured variables in a non-theme folder. 2 guards pass on
  both: no capture from comment, raw, inline comments, prose, a
  nameless tag or a tag inside a string, and no cut-short hyphenated
  or dotted name. Red/green on the committed tree: 42 passed and 11
  failed with main's extractor, 53 passed with the fix.
- A/B on efb091ec, each arm built from its own checkout: 8 Shopify
  theme repos (Shopify/dawn, Shopify/horizon, Shopify/skeleton-theme,
  ChumsInc/chums-impulse-dev, agencecinq/cinquante-et-un,
  noclocks/shopify-devstore-theme, panoply/syncify, Shopify/theme-tools)
  and 2 controls (express, requests). The controls and skeleton-theme,
  which has no capture, are byte-identical. Every other theme gains
  only variable nodes, each with one contains edge: dawn 36, horizon
  192, chums-impulse-dev 90, cinquante-et-un 25, shopify-devstore-theme
  27, syncify 25, theme-tools 49, 444 in all (383 braced, 61 in
  {% liquid %} tags). That is exactly the count of capture tags a
  separate scan finds outside comment and raw regions, and a script
  checked each new node against the source text: it sits on a capture
  tag naming it, with no edge but its contains. 444 right, 0 wrong.
  Nothing is removed or moved, no unresolved ref changes, and no node
  present on both arms changed its id. Every capture and assign name in
  these themes is a plain word.
- Cost: the extractor is faster with the fix. A microbenchmark over
  1,386 Liquid files (8 MB), 15 runs in each of 3 interleaved rounds,
  gave per-round medians of 443-465 ms on main and 316-387 ms with the
  fix, because whole-file line-start scans fall from 29,807 to 20,671.
  Index wall time, median of 3 interleaved runs, main vs fix: horizon
  2975 vs 2935 ms, chums-impulse-dev 2404 vs 2311, syncify 4329 vs
  3867, theme-tools 8405 vs 8108, and the byte-identical controls
  express 2427 vs 2417 and requests 2006 vs 1942, which is within the
  noise of a shared machine.
- Rebased onto 68fcf2f1, which adds only PR #2813 (JS/TS static and
  instance overrides, with a kernel change, so the kernel was rebuilt).
  There the Liquid tests pass, and re-indexing the 8 theme repos
  changes no Liquid or JSON line: 4 are byte-identical to the
  pre-rebase fix arm, and the others differ only in PR #2813's
  is_static flag on JavaScript methods (dawn 30, horizon 26,
  shopify-devstore-theme 14) and one synthesized TypeScript call in
  syncify.
- Kernel parity: not applicable, the kernel does not extract Liquid.

The issue also asks for README and docs-site wording about what Liquid
support covers. That is PR #2815, a docs-only change held for the
maintainer's review, so this change leaves the issue open.

Refs #2498

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 21:49:29 +00:00
..