Skip to content

Make smart rule exclusion cover rule chains of any depth - #7

Open
CoolOppo wants to merge 1 commit into
masterfrom
claude/search-todo-comments-37ybin
Open

Make smart rule exclusion cover rule chains of any depth#7
CoolOppo wants to merge 1 commit into
masterfrom
claude/search-todo-comments-37ybin

Conversation

@CoolOppo

@CoolOppo CoolOppo commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Resolves the TODO in generate_children. The exclusion previously
skipped a rule only when the output file matched exactly the same rule
set as the input, which recognizes re-application just one level deep.
Deeper chains (a.js -> a.min.js -> a.pkg.min.js) re-applied earlier
rules to derived files, and configs whose rules match their own outputs
(e.g. a lone *.js -> *.min.js rule without an exclude) expanded the
file graph without bound until the walker overflowed its stack.

A rule is now also skipped when the input path already matches the
shape of the rule's to template (capture group references treated as
wildcards): such a file already looks like one of the rule's outputs,
so the rule was already applied somewhere along the chain that produced
it. Every file of a chain is checked against the output shapes of all
of its matching rules, so the exclusion composes across chains of any
depth. The TODO suggested recursing on the rule-set comparison instead,
but no signature recursion can work: a genuine source file and a deep
derivative produce identical signature sequences, so only the shape of
the name itself can tell them apart.

The old rule-set comparison is kept as a fallback for to templates
that rewrite only part of a path, where the anchored output shape never
matches. Rules that rewrite a file in-place are now exempt from both
checks: they are stored as self-loops and cannot grow a chain, and the
old comparison used to silently drop them whenever any other rule
matched the same file.

Co-Authored-By: Claude noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01MxcgW5UDkTmh1iB7xKPDdc

Resolves the TODO in generate_children. The exclusion previously
skipped a rule only when the output file matched exactly the same rule
set as the input, which recognizes re-application just one level deep.
Deeper chains (a.js -> a.min.js -> a.pkg.min.js) re-applied earlier
rules to derived files, and configs whose rules match their own outputs
(e.g. a lone *.js -> *.min.js rule without an `exclude`) expanded the
file graph without bound until the walker overflowed its stack.

A rule is now also skipped when the input path already matches the
shape of the rule's `to` template (capture group references treated as
wildcards): such a file already looks like one of the rule's outputs,
so the rule was already applied somewhere along the chain that produced
it. Every file of a chain is checked against the output shapes of all
of its matching rules, so the exclusion composes across chains of any
depth. The TODO suggested recursing on the rule-set comparison instead,
but no signature recursion can work: a genuine source file and a deep
derivative produce identical signature sequences, so only the shape of
the name itself can tell them apart.

The old rule-set comparison is kept as a fallback for `to` templates
that rewrite only part of a path, where the anchored output shape never
matches. Rules that rewrite a file in-place are now exempt from both
checks: they are stored as self-loops and cannot grow a chain, and the
old comparison used to silently drop them whenever any other rule
matched the same file.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MxcgW5UDkTmh1iB7xKPDdc
@cursor

cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

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