Skip to content

feat(extract): cover the remaining Shopify theme constructs - #5555

Closed
dalexhd wants to merge 15 commits into
Graphify-Labs:v8from
dalexhd:feat/shopify-theme-coverage
Closed

dalexhd wants to merge 15 commits into
Graphify-Labs:v8from
dalexhd:feat/shopify-theme-coverage

Conversation

@dalexhd

@dalexhd dalexhd commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Part 3 of #5552, stacked on #5554 (theme JSON) and #5553 (Liquid). Until those merge, this diff also shows their commits.

What does this PR do?

It covers the remaining Shopify theme constructs that create a dependency between files. I measured them on three production themes, one of them Horizon 3.5.1. One commit per construct, so any of them can be dropped on its own.

Construct Edge Horizon, before → after
'x' | inline_asset_content references to the asset 93 → 171 asset edges
{% schema %} presets[].blocks (list, dict, nested) imports to blocks/<type>.liquid when the file exists 237 → 301
enabled_on / disabled_on (templates, groups) references to templates/<x>.json or the section group 0 → 45
'x' | asset_img_url references to the asset covered by tests (0 uses in Horizon)
config/settings_data.json sections and blocks by type imports to their .liquid covered by tests
{% content_for 'blocks' %} in a section whose schema accepts @theme imports, confidence INFERRED, to every public blocks/*.liquid (no _ prefix) 0 → 1002

Implementation notes

  • Missing targets follow the same rule as the first PR: an AMBIGUOUS edge to an unresolved: true node (ref_kind template or section_group). "*" and dynamic names create nothing.
  • enabled_on.groups looks for sections/<g>-group.json, then sections/<g>.json. Templates accept .json or .liquid.
  • Section-local preset blocks (no file) get no edge.
  • content_for 'blocks' is the one inferred relation. Any theme block may be placed there at runtime, so the edge is honest but broad. In Horizon it is 17 % of all edges, from 28 sections. It is the last commit, so it is easy to drop if you prefer to keep it out.

Not covered (impossible statically)

App blocks (@app, shopify://apps/...), render some_var, and | t on a non-literal key.

How was this tested?

uv run pytest tests/test_liquid_extractor.py tests/test_shopify_theme_json_extractor.py -q   # 48 passed, 1 xfailed
uv run ruff check graphify/extractors/liquid.py graphify/extractors/shopify_theme_json.py
uv run pytest tests -q

Full suite: the same failures as an unmodified v8 checkout in the same environment, none new. Horizon was rebuilt with graphify update --no-cluster, no API key set.

AI disclosure

Written with Claude Code. I reviewed the code and ran the commands above myself.

dalexhd and others added 15 commits November 27, 2026 15:00
Extract .liquid files of a Shopify theme (gated on a layout/theme.liquid ancestor). render/include/section/sections/content_for and schema blocks become 'imports' edges to the file they name, so 'graphify affected' on a snippet lists the sections rendering it. asset_url and the t filter become 'references' edges (asset file, or key of the single default locale). Relation 'includes' is avoided because affected does not follow it. Dynamic names, comment/doc/raw regions and path-traversal names emit nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A statically named render/include/section/sections/content_for target, asset or translation key that does not exist becomes an AMBIGUOUS edge (score 0.2) to a node flagged unresolved with id ref_liquid_<kind>_<name>, instead of being dropped. Documents how to list them from graph.json and adds Liquid to the built-in parsers list. The incremental cache keeps the stale edge of an unchanged citing file after the target appears; pinned by a strict xfail, a full rebuild clears it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A literal such as 'font.eot?#iefix' piped into asset_url named a file that cannot exist. Resolve the part before ? or # instead of reporting a broken reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… to JS siblings

Shopify default locales start with a // header, so json.loads failed and every | t edge was lost; strip // and /* */ outside strings. A .liquid -> .js reference was dropped by the cross-language guard in build, and the references target was not salted with the colliding id when x.css and x.js share a stem.

Co-Authored-By: Claude <[email protected]>
Templates and section groups of a Shopify theme place sections and blocks in JSON, which were skipped as data JSON. Route them by path (gated on a theme root) before the generic .json dispatch, link each placed section and existing theme block, and link t: schema keys to the default schema locale.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Templates place top-level blocks with section type _blocks, which Shopify provides; it never has a sections/ file, so it must not be reported as a broken reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

Thanks for the pull request, @dalexhd. A maintainer will review it soon.

Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions.

A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic.

@graphify-labs graphify-labs Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graphify review View in Graphify

Review before merging · Merge confidence 4/5

1 bug · 8 possible issues to check · High impact

The changes add Shopify theme-aware extraction for Liquid files and selected theme JSON files, linking placements, assets, translations, and related references.

P2  Adding a missing theme file leaves its reference unresolved · liquid.py:208

8 possible issues we couldn't confirm
  • Theme settings_data.json over 1 MB gets no section placement links, while settings_schema.json is always read in full · graphify/extractors/shopify_theme_json.py:131
  • Liquid templates now get their own language family, which blocks cross-file calls from Liquid into JavaScript and TypeScript files · graphify/extract.py:4896
  • Liquid templates bypass the cross-language import guard for every target, so unverified references can bind to same-named nodes in other lan · graphify/build.py:2308
  • +5 more in Graphify

They don't change the score.

What this review covered
  • We didn't review 9 files that aren't source code, such as docs, config, images, or generated or third-party code.
  • Some lookups asked for files or lines that do not exist; the review was told and carried on.
  • Some findings could not be double-checked.
  • 10 of 10 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 7582 functions depend on this change
  • 6 functions became more coupled. Largest: extract() (1400 callers), build_from_json() (349 callers), _get_extractor() (47 callers).
  • 644 of 644 test files are affected by this change.
  • Gate, test list and every flagged function: in the Graphify check.

Reviewed 6c1acdd

Comment on lines +205 to +208
if state == "out":
return
if state == "missing":
self._unresolved(relation, kind, name, target.relative_to(self.root).as_posix(), line)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2  Adding a missing theme file leaves its reference unresolved

After a missing snippet is added, an incremental update can still show the Liquid file pointing to an unresolved reference instead of the new snippet.

Re-resolve cached AMBIGUOUS edges when a target file is added.

Evidence · checked against the code

Expected: The reference edge resolves to the added target file.
Actually: The citing file can retain its cached AMBIGUOUS edge to the unresolved node.

  • Independent source review: Checked the full-rebuild behavior described in the extractor documentation and the strict-xfail incremental test. A full rebuild clears the stale edge, but it does not resolve the incremental-update case.
Prompt to fix with AI
In graphify/extractors/liquid.py, _Collector.file_edge (lines 205-208):
Problem: Adding a missing theme file leaves its reference unresolved
Expected: The reference edge resolves to the added target file.
Actually: The citing file can retain its cached AMBIGUOUS edge to the unresolved node.
Fix it at the cause, and add a test that fails without the fix.

Graphify · Checked against the code · View in Graphify

safishamsi pushed a commit that referenced this pull request Nov 28, 2026
…5557)

Squashed landing of @dalexhd's four-PR Liquid/Shopify-theme extractor stack:
a Liquid extractor (.liquid), theme-JSON template→section/block linking, CSS
classes, settings, custom elements and metafields. Pure-stdlib scanners, no
new dependencies; all new extraction is gated to a theme root (layout/
theme.liquid) so non-theme .css/.json files are unaffected. Verified by
adversarial review: zero node/edge diff on Python and a 20-language corpus
(no existing-language regression), new extraction works, broken themes
degrade gracefully.

Schema bump is consolidated with the rest of this release's extraction-output
changes in a following commit.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
safishamsi added a commit that referenced this pull request Nov 28, 2026
…ema 58

Collapse the Shopify stack's internal 58/59/60 bumps and the TS/C++/Markdown
bumps into a single 57->58 bump with one combined entry (TS #5525/#5529,
C++ #5550/#5551, Markdown #5480, Shopify #5553/#5554/#5555/#5557), chaining to
the shipped-57 (0.9.121) entry. Fixes the stack's schema-history mislabel that
had carried the shipped-57 Rust text as 58.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.122 as the Shopify/Liquid theme extractor. The four-PR stack landed as a single squashed commit authored to you (@dalexhd) so it keeps your authorship. Adversarial review confirmed zero regression to existing-language extraction (zero node/edge diff on Python + a 20-language corpus), no new dependencies, and graceful handling of broken themes. Thanks for a substantial feature!

@safishamsi safishamsi closed this Nov 28, 2026
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.

2 participants