Add --composite-rules flag to annotate multi license rules with required phrases - #5118
Open
Kaushik-Kumar-CEG wants to merge 2 commits into
Open
Conversation
Author
|
@AyanSinhaMahapatra ready for review when you have a moment |
Kaushik-Kumar-CEG
force-pushed
the
gsoc/annotate-composite-rules
branch
from
June 20, 2026 20:52
baa56a6 to
59026a3
Compare
Author
|
@AyanSinhaMahapatra please review when you have a moment :) |
AyanSinhaMahapatra
requested changes
Aug 17, 2026
Member
There was a problem hiding this comment.
@Kaushik-Kumar-CEG thanks for the PR.
The logic is looking better than before and should work, but your tests aren't testing for the functionality added at all. And we need a lot of refactoring elsewhere. Also skip using attributes for this, as this is redundant double work.
Could you also rebase/merge from main?
Kaushik-Kumar-CEG
force-pushed
the
gsoc/annotate-composite-rules
branch
from
August 23, 2026 21:46
4502b67 to
a8beda9
Compare
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.
references #5077
adds
--composite-rules(-c) flag to theadd-required-phrasesCLI command.For composite (AND/OR) rules, collects candidate phrases from existing required phrase rules with a single license key, skips generic licenses, then marks the rule only if every remaining key has a non-overlapping match in the text.
uses existing:
find_phrase_spans_in_textfor token-based matching,add_required_phrase_to_rulefor safe injection with overlap and ignorable checks, andget_updatable_rules_by_expressionfor rule filtering.Usage:
Tests cover candidate collection, multi-key matching, the all-keys gate, existing markers, overlaps, rollback, dry-run behavior, and CLI wiring.
Tasks
disclosure: used Claude to help review and clean up a few bugs in the script