Repository navigation
fix(pr-management): use ERE residue groups and precheck empty matches - #2009
Conversation
The residue command selects git grep -E but wraps variants in non-capturing groups that the tested Git ERE engines reject. Use ordinary groups so the emitted command can search the stack head. Exercise the CLI JSON and real Git argv for matches, no matches, grouping, case folding, quoting and exclusions, and regenerate the packaged source. Generated-by: Codex (GPT-6)
Reuse each variant's Python compilation to reject common empty-matching patterns before the CLI emits a command. This is a limited precheck, not a full validator for Git's POSIX ERE dialect. Document ERE spelling, leading-hyphen arguments and the remaining dialect and backreference limits. Cover rejection without JSON output and real Git matching for a leading dash, digit classes and an escaped pipe. Generated-by: Codex (GPT-6)
The docs now allow POSIX ERE, but compiling `[[:digit:]]` with Python's re prints a FutureWarning on stderr. The precheck only needs the compiled pattern, so silence that warning there. Generated-by: Claude Opus 5
potiuk
left a comment
There was a problem hiding this comment.
Thanks: git grep -E really does reject (?:…), the fix is right, and the real-Git tests are a good guard. I pushed one small fixup so you do not need another round: 58386ecb silences Python's FutureWarning for POSIX classes such as [[:digit:]] around the precheck's re.compile in stack_review/cli.py and its packaged copy, and adds a test in test_findings.py, because the docs now allow those classes.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.More on how Apache Magpie handles maintainer review:
Contributing guide.
Summary
stack-review residue-commandselectsgit grep -Ebut emits non-capturing groups that the tested ERE engines reject. Use ordinary groups so the command returns matches or a normal no-match result, while keeping leading-hyphen tokens protected from option parsing.--variant=-x, with the remaining dialect and backreference limits.check-family-plugins.py --fix.Type of change
Test plan
Validation is for commit
0979b20ce95b23e2595df82c949554f713e6b3e3against17abc4c8c6137f466b60bf698dd2684618e32358:test_findings.py: 30 passed.prek run --all-files --skip workspace-pytest; range-selected workspace tests; normal commit hooks; whole-tree lychee; packaged-source consistency andgit diff --checkpass.RFC-AI-0004 compliance
No network access, privileged operations or configuration is added. Tests use synthetic data and isolate temporary repositories from contributor Git configuration. The guidance states the supported spelling and the limits of the precheck.
Linked issues
Fixes #2008
Notes for reviewers
The Python precheck is deliberately limited. A POSIX character-class pattern such as
[[:digit:]]*can still pass it despite matching empty strings in Git; Python-style\dand numeric backreferences also remain problematic. The help and residue guidance describe these limits. CLI parameters and the successful JSON structure are unchanged; common empty-matching variants are now rejected.Suggested additional label:
capability:fix; the repository has already assigned its component labels automatically.Generative AI disclosure
AI-assisted with Codex (GPT-6), including code, tests, reproduction and drafting. The contributor has completed human review of the final changes. Both commits carry
Generated-by:trailers.