Skip to content

fix(pr-management): use ERE residue groups and precheck empty matches - #36

Draft
MakerFlyFly wants to merge 2 commits into
audit/m-072-basefrom
fix/stack-review-residue-ere
Draft

MakerFlyFly wants to merge 2 commits into
audit/m-072-basefrom
fix/stack-review-residue-ere

Conversation

@MakerFlyFly

@MakerFlyFly MakerFlyFly commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Upstream submission: apache/magpie issue #2008 and PR #2009. This fork item is retained as an audit record; the contributor has completed human review.

Summary

  • Replace the non-capturing groups emitted by stack-review residue-command with ordinary ERE groups so git grep -E can search the saved stack ref. Preserve the grouping that also keeps leading-hyphen tokens from being parsed as Git options.
  • Reject common empty-matching variants using the existing Python compilation before emitting JSON. Document POSIX ERE, [0-9], --variant=-x, and the remaining dialect and backreference limitations.
  • Extend real-Git and CLI rejection coverage and regenerate the packaged tool source with the official generator.

Type of change

  • Python package
  • Skill guidance — residue classification subdocument; six existing Step 3 cases self-evaluated

Test plan

  • The original five real-Git cases fail on the upstream base. Six new rejection cases fail on the first fix before the empty-match precheck, on both Linux and Windows.
  • Linux package tests: 758 passed, 15 subtests passed.
  • Windows: all 30 tests in tests/stack_review/test_findings.py pass.
  • Real CLI processes on both platforms: each of the six rejected inputs exits 1, includes the offending variant in stderr, and produces empty stdout. Valid leading-hyphen, digit-class and escaped-pipe inputs still emit JSON; help names POSIX ERE.
  • The six existing Step 3 structural-finding cases were answered from the runner-generated system/user prompts and then compared by full JSON equality against their expected outputs: 6/6 pass. This is a self-eval smoke test, not independent cross-model review.
  • Package ruff, format and mypy checks; whole-tree non-test hooks (including lychee); packaged-source consistency and diff checks pass.
  • Normal commit hooks and range-selected workspace tests pass on follow-up commit 0979b20c; Magpie pre-first-PR checks report all five categories passing, ready, zero blocking and advisory items.

RFC-AI-0004 compliance

This repair adds no network access, privileged operations or configuration. Tests use synthetic data and isolate temporary repositories from contributor Git configuration. The guidance makes the supported spelling and the precheck's limitations explicit.

Linked issues

Refs #35

Review decisions and limits

  • Accepted: clarify POSIX ERE, retain grouping, add --variant=-x coverage, and reject patterns that the existing Python check recognises as matching the empty string. Compilation happens once per variant; rejection precedes command JSON output.
  • Clarified: py310| has an empty alternative; py310\| matches a literal pipe. They have distinct regression coverage. Capturing groups preserve matching only when no numbered backreference relies on the original group numbering.
  • Deferred: complete ERE validation and backreference handling. [[:digit:]]* can pass the Python precheck despite matching empty strings in Git; \d and numeric backreferences remain problematic. The implementation and guidance explicitly disclose these limits.
  • Retained: Git configuration isolation (Git 2.32+), strict Git-stderr assertions and representative exclusion coverage. No change in exclusion logic warrants expanding this PR into exhaustive exclusion tests.

This remains a fork-only Draft PR against audit/m-072-base at upstream 17abc4c8c6137f466b60bf698dd2684618e32358. The final change spans four files. The reviewed change has been submitted upstream through the independent publication branch linked above.

Generative AI disclosure

AI-generated with Codex (GPT-6), including code, tests, reproduction and drafting. Commits carry Generated-by: trailers. The review feedback has been addressed as described above and the contributor has completed human review of the final changes.

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)
@MakerFlyFly MakerFlyFly added family:pr-management pr-management-* skills capability:fix Implement code change to resolve an issue labels Nov 5, 2026 — with ChatGPT Codex Connector
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)
@MakerFlyFly MakerFlyFly changed the title fix(pr-management): generate ERE-compatible residue grep groups fix(pr-management): use ERE residue groups and precheck empty matches Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant