Make smart rule exclusion cover rule chains of any depth - #7
Open
CoolOppo wants to merge 1 commit into
Open
Conversation
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
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thefile 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
totemplate (capture group references treated aswildcards): 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
totemplatesthat 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