Repository navigation
Conversation
…s/.css/.scss/.less and dotfile configs (Graphify-Labs#2498, Graphify-Labs#2698, Graphify-Labs#3473) An explicit wildcard-free '!path' entry in .graphifyignore now overrides only the Stage-3 secrets-keyword heuristic, never the .env/key-file or credential-store stages; a rescued file is kept and the skip report names the escape hatch (Graphify-Labs#2498). Well-known extensionless config/build files (.htaccess, Dockerfile, Makefile, ...) are classified as documents instead of dropped; .less routes to the CSS extractor (Graphify-Labs#2698). Combines and supersedes Graphify-Labs#2747/Graphify-Labs#3505 (.gs Apps Script), Graphify-Labs#3480/Graphify-Labs#3067/Graphify-Labs#2240 (CSS/SCSS design tokens) and Graphify-Labs#1921 (allowlist) against current v8.
234579d to
7651768
Compare
|
Thanks @amslezak! One small thing: our changelog and release notes are built from PR titles, so we use the conventional-commits format, for example: Prefixes we use: |
7651768 to
9cb498b
Compare
…s/.css/.scss/.less and dotfile configs (Graphify-Labs#2498, Graphify-Labs#2698, Graphify-Labs#3473) An explicit wildcard-free '!path' entry in .graphifyignore now overrides only the Stage-3 secrets-keyword heuristic, never the .env/key-file or credential-store stages; a rescued file is kept and the skip report names the escape hatch (Graphify-Labs#2498). Well-known extensionless config/build files (.htaccess, Dockerfile, Makefile, ...) are classified as documents instead of dropped; .less routes to the CSS extractor (Graphify-Labs#2698). Combines and supersedes Graphify-Labs#2747/Graphify-Labs#3505 (.gs Apps Script), Graphify-Labs#3480/Graphify-Labs#3067/Graphify-Labs#2240 (CSS/SCSS design tokens) and Graphify-Labs#1921 (allowlist) against current v8.
9cb498b to
8a5de14
Compare
8a5de14 to
a64a2df
Compare
Neither extension was in any FileType set, so Twig templates and Sass
stylesheets were silently skipped: on a Drupal theme that dropped the entire
component-composition and design-token layer from the graph.
Both are regex extractors in the shape of extractors/blade.py — no new
dependency, and routing them through FileType.CODE means they cost no LLM
tokens and yield EXTRACTED-confidence edges.
twig.py resolves references to real files rather than stubs:
- Drupal SDC (`{% include 'mytheme:card' %}`) via the nearest
`<provider>.info.yml` plus a components/ index
- plain paths and Symfony's `@Namespace/...` via the referring file's dir
and any enclosing templates/ root
- relations: includes, embeds, extends, imports_macro, uses_template,
defines_block, attaches_library
scss.py covers the module, mixin, and design-token graphs:
- @use/@forward/@import through Sass partial (`_name.scss`) and index
(`name/_index.scss`) conventions
- @mixin/@include keyed on the bare name so a namespaced use
(`@include mx.button-reset`) links to its definition
- `--token:` declarations and `var(--token)` references share one node, so
token-defining stylesheets connect to every consumer
Both strip comments before scanning, via a newline-preserving blank pass that
keeps reported line numbers accurate. Without it a component docblock showing
example usage ("Usage: {% include 'mytheme:card' %}") became a real dependency
and gave the component an edge to itself.
.twig/.scss/.sass are also added to _LANG_FAMILY_BY_EXT so their stubs cannot
be remapped onto same-labeled symbols in an unrelated language.
.css is deliberately out of scope: in a Sass project it is compiled output of
the .scss already indexed, so indexing both duplicates the stylesheet layer.
Verified against a 141-template / 109-stylesheet Drupal theme: 97% of Twig
references and 100% of Sass imports resolve to real files, no self-loops. The
unresolved remainder are base-theme templates outside the scanned corpus.
Refs: Graphify-Labs#3473
Co-Authored-By: Claude <[email protected]>
…iguation
A Single Directory Component keeps `card.twig` beside `card.scss`, so both
collapse to the same `card` file id and _disambiguate_colliding_node_ids salts
them apart. An `{% include %}` edge from a THIRD template carries neither
salt's source_key, so the (target, edge_source_key) lookup missed and the edge
dangled on the retired `card` id.
That is the Graphify-Labs#1475 C/ObjC header failure exactly — `foo.h` beside `foo.c`, with
the import edge from a third file. Mirror its fix: repoint template-composition
edges to the .twig variant, since an include always targeted the template.
Also honor the target_file stamp for those relations. It was gated to
imports/imports_from/re_exports, so a stamped `includes` edge fell back to the
importer's own source_key.
On a 141-template Drupal theme this takes dangling composition edges from
198/234 to 0/234, and embeds from 14/14 to 0/14. The extractors emit the edge
only (no stub node) for a resolved reference, matching the documented Graphify-Labs#2195
pattern, so no ghost node duplicates the real file node either.
Co-Authored-By: Claude <[email protected]>
…files rebuild A changed-files rebuild extracts only the edited files, so _disambiguate_colliding_node_ids could not see that foo.c shares its id with the unchanged foo.h. The edited file kept the bare id, its edges missed the salted sibling, and the graph drifted from a full build with every update. extract() now hands the persisted resolution-context nodes to the pass. A context node whose id is the salted form of a batch id or an edge target counts as a collider, so the batch is salted and routed the same way a full build would.
card.twig beside card.scss collide on one file id. Editing either one and running graphify update broke the include edges into and out of the component (47 of 475 edges in a real Drupal theme).
a64a2df to
ddc23b6
Compare
There was a problem hiding this comment.
Graphify review 
2 bugs · 18 possible issues to check · High impact
The change registers Twig and Sass files for extraction and adds Twig template-reference resolution.
Parent-relative Twig references stay disconnected from their templates ·
twig.py:136
Some Twig includes can point to the wrong colliding template ·
resolution.py:1304
18 possible issues we couldn't confirm
- New
.twig,.scssand.sassfiles are routed to the code path, so they add nothing to the graph unless a matching extractor is register ·graphify/detect.py:48 - A
$obj->source('x')or$obj->include('x')call in a template adds a false includes edge ·graphify/extractors/twig.py:45 - Protocol-relative
@import "//host/..."andurl(//cdn...)references are silently dropped by comment stripping ·graphify/extractors/scss.py:32 - +15 more in Graphify
They don't change the score.
What this review covered
- One review pass used all of its turns for reading code, so it reported from what it had already read.
- 3 more possible issues from the per-file sweep were left out to keep the report to its limit.
- 13 of 13 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 8836 functions depend on this change
- 4 functions became more coupled. Largest:
classify_file()(54 callers),extract_scss()(19 callers),extract_twig()(16 callers). - 656 of 656 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 07be958 · 20 earlier findings not re-checked
| identifies component templates without reading any YAML. | ||
| """ | ||
| key = str(root) | ||
| cached = _SDC_INDEX_CACHE.get(key) |
There was a problem hiding this comment.
Twig keeps using an outdated Drupal component index
After a Drupal component is added or removed, later Twig extractions in the same process can still resolve references using the old component list.
Refresh _sdc_index when an extension’s component tree changes.
Evidence · checked against the code
Expected: The later reference reflects the current component tree.
Actually: The cached mapping can omit the new component or retain the removed component's old path, producing an unresolved edge or a stale resolved target.
- Independent source review: Checked extraction's per-file AST cache and run setup: an unchanged cached file may bypass the Twig extractor, limiting when the stale index affects extraction. The cache does not invalidate _SDC_INDEX_CACHE, however, and a newly added or changed Twig file that is extracted in the same process can still use the old map.
- Some lookups asked for files or lines that do not exist; the review was told and carried on.
Prompt to fix with AI
In graphify/extractors/twig.py, _sdc_index (lines 110-113):
Problem: Twig keeps using an outdated Drupal component index
Expected: The later reference reflects the current component tree.
Actually: The cached mapping can omit the new component or retain the removed component's old path, producing an unresolved edge or a stale resolved target.
Fix it at the cause, and add a test that fails without the fix.
Graphify · Checked against the code · View in Graphify
… run Both caches are keyed by path with no mtime, so graphify watch and the MCP server kept resolving SDC includes against the first run's component list after a component was added or removed.
| # Symfony's `@Namespace/rest`: the namespace maps to a directory configured | ||
| # outside the template, so only the remainder is usable statically. | ||
| relative = raw.split("/", 1)[1] if raw.startswith("@") and "/" in raw else raw | ||
| if not relative or relative.startswith("/") or ".." in Path(relative).parts: |
There was a problem hiding this comment.
Parent-relative Twig references stay disconnected from their templates
A Twig include or inheritance reference such as ../shared/base.twig is left as a stub even when the target file exists.
Check candidate files before rejecting .. in _resolve_path_ref.
Evidence · checked against the code
Expected: The dependency edge targets the existing template file.
Actually: The resolver rejects the reference before checking candidates, and extraction emits an edge to a stub keyed by the raw reference.
- Independent source review: The separate SDC resolver does not use this path check, so it is not a counterexample for ordinary path references. The resolver's ordinary-path candidate search does not mitigate the issue because it is reached only after the
..rejection. I did not establish from repository evidence whether the Twig loader accepts the specific parent-relative references in the candidate's limitation. - This assumes the Twig loader permits a parent-relative reference that remains within the template tree.
- Some lookups asked for files or lines that do not exist; the review was told and carried on.
Prompt to fix with AI
In graphify/extractors/twig.py, _resolve_path_ref (lines 133-136):
Problem: Parent-relative Twig references stay disconnected from their templates
Expected: The dependency edge targets the existing template file.
Actually: The resolver rejects the reference before checking candidates, and extraction emits an edge to a stub keyed by the raw reference.
Fix it at the cause, and add a test that fails without the fix.
Graphify · Checked against the code · View in Graphify
| # template, so repoint to the template variant. | ||
| _TEMPLATE_SUFFIXES = (".twig",) | ||
| template_remaps: dict[str, str] = {} | ||
| for old_id in ambiguous_ids: |
There was a problem hiding this comment.
Some Twig includes can point to the wrong colliding template
When distinct Twig paths normalize to the same file ID, an include can be redirected to a different template than the one it resolved to.
Apply the target_file-specific remap before the generic template_remaps entry in _disambiguate_colliding_node_ids.
Evidence · checked against the code
Expected: The edge should target the Twig node corresponding to its resolved target_file.
Actually: The edge can be rewritten to the first Twig collider recorded for the shared ID, even when target_file identifies another collider.
- Independent source review: Checked the path-specific
target_keyroute: it would usetarget_fileto identify the right collider, but the template-relation branch runs first and takes precedence. The Twig tests cover resolved references and target-file stamps, but not multiple Twig targets whose IDs collide. - Requires two distinct Twig paths whose normalized file IDs collide; no test in the inspected Twig tests covers multiple Twig targets sharing a normalized ID.
- Also reported as: Twig references can point to the wrong colliding template
Prompt to fix with AI
In graphify/extractors/resolution.py, _disambiguate_colliding_node_ids (lines 1301-1304):
Problem: Some Twig includes can point to the wrong colliding template
Expected: The edge should target the Twig node corresponding to its resolved `target_file`.
Actually: The edge can be rewritten to the first Twig collider recorded for the shared ID, even when `target_file` identifies another collider.
Fix it at the cause, and add a test that fails without the fix.
Graphify · Checked against the code · View in Graphify
What does this PR do?
Adds extractors for Twig templates and SCSS/Sass stylesheets. Neither extension is in any
FileTypeset today, so detection skips both. On a Drupal or Symfony project the whole template layer is missing from the graph, and on a Sass project the stylesheet module graph and the design tokens are missing too.Refs #3473 (the SCSS and design-token half;
.cssstays out of scope, see Limitations).Both extractors follow
extractors/blade.py: regex only, no new dependency. They route throughFileType.CODE, so they cost no LLM tokens and produceEXTRACTEDedges.extractors/twig.pyresolves references to real files:{% include 'mytheme:card' %}resolves through the nearest<provider>.info.ymland an index ofcomponents/**/<name>/<name>.twig.{% extends 'layout.html.twig' %}and@Namespace/path.html.twigresolve against the referring file's directory and any enclosingtemplates/root.includes,embeds,extends,imports_macro,uses_template,defines_block,attaches_library. It reads the{% tag %}form, the{{ include('x') }}function form and{% from 'x' import y %}.extractors/scss.pycovers three graphs:@use,@forwardand@import, through Sass's partial (_name.scss) and index (name/_index.scss) rules.@import 'a', 'b'lists work. Built-ins likesass:mathstay stubs.@mixinand@includekey on the bare name, so@include mx.button-resetlinks to its definition.--token:declarations andvar(--token)references share one node.A second commit fixes a resolution bug that the extractors exposed. An SDC keeps
card.twigbesidecard.scss. Both get thecardfile id, so_disambiguate_colliding_node_idssalts them apart. An{% include %}edge from a third template carries neither salt'ssource_key, so it dangled on the retiredcardid. This is the #1475 C/ObjC header case (foo.hbesidefoo.c), and the fix mirrors that one: template-composition edges repoint to the.twigvariant. Thetarget_filegate also now covers these relations. It was limited toimports,imports_fromandre_exports.Type of change
Verification & Invariants
target_file, and mints no stub, following Absolute-path node ids on 0.9.25 for in-root relative import targets (residual of #1899 Variant B; ghost duplicates + dangling endpoints) #2195. A second node with the same id would duplicate the real file node.{# Usage: {% include 'mytheme:card' %} #}). Read naively, that gives the component anincludesedge to itself, whichdiagnose_extractionflags.test_twig.pyandtest_scss.pycover this case.components/in sorted order, so a component name that appears twice resolves the same way on every filesystem.test_duplicate_sdc_name_resolves_independent_of_filesystem_orderruns both walk orders and fails without the sort. The extractors read no environment and make no network calls..twig,.scssand.sassare now in_LANG_FAMILY_BY_EXT. Without a family,_lang_familyreturnsNone, and the stub-remap pass could bind an SCSS mixin stub to a function with the same label in another language.Measured on a Drupal theme with 141 templates and 109 stylesheets:
includesdanglingembedsdanglingextendsdanglingThe only Twig references left unresolved point at base-theme templates outside the scanned directory. They correctly stay stubs.
Limitations
.cssis out of scope. In a Sass project the CSS is compiled output of the.scssfiles, so indexing both duplicates the stylesheet layer. Hand-written CSS projects need a separate discussion, which No extraction path for .css/.scss: design-token systems are invisible to the graph (measured: 714 tokens, 1334 edges recoverable) #3473 has started.The extractors use regex, like Blade, not tree-sitter. This keeps them free of new dependencies, but Twig expressions that build a template name at runtime (
include(prefix ~ '-card')) are not resolved.I have not run this on Windows. Path handling goes through
pathlib.Read the CONTRIBUTING.md guide.
Reproduced the issue and identified the invariant.
Made the smallest fix necessary.
Added a regression test (if bug fix) or isolated boundary test.
Kept the PR description synchronized with the final implementation.
Documented any limitations / unsupported cases explicitly.
How was this tested?
Rebased onto
v8at 0.9.92, withuv sync --all-extras:I also ran the installed build against the Drupal theme above and checked the include edges against
git grep.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (No skill fragments changed.)