Repository navigation
feat(pr-management): add review findings data model and parser (part of #1887) - #1920
Conversation
27f5c43 to
979911d
Compare
|
up for review! |
potiuk
left a comment
There was a problem hiding this comment.
Thanks for splitting #1887 into three, Kaap10; a small, well-tested parser first is the right foundation for the pane. Since the pane's output is what decides which comments get posted, though, the bridge to render has to agree with it exactly, and two places do not yet (inline below): the keep answer numbers comments over a different list than render does, and an edited finding is dropped from the answer. Both would post a review the maintainer did not pick.
The other inline comments are smaller and fine in the same push.
One question rather than a finding: register adds a pass-through session.start handler, so every session of every magpie-pr-management user loads this module before anything uses it. If it is there only so the mod is wired up and its tests run in CI, a short comment saying so would help; otherwise the hooks.json entry could wait for PR-2, when there is a pane to show.
the keep answer numbers comments differently from render (plugins/magpie-pr-management/hooks/review-findings.ts:160)
Converts finding action states into inline-picker keep answer format
- compatible with code-review render keep parameter.
const anchored = findings.filter(
(f) => f.line !== null && f.line !== undefined && f.line >= 1
);
render numbers the inline comments over the raw findings file, anchored = [f for f in findings if f.get("line")] (tools/pr-management/src/pr_management/code_review/cli.py), while this numbers them over the parsed list. The two disagree whenever the parser normalises: a finding carrying lineNumber or line_number is anchored here and not there, "0" is anchored there and not here, and an item the parser drops as "not an object" shifts every later index. One disagreement moves 1,3 onto different comments, so the review posts comments the maintainer skipped and drops ones they kept. Please number over exactly the list render reads (the pane writes the normalised findings file that render then consumes, or the anchoring predicate is render's on the raw item), and add a test that runs both rules over the same input.
an edited finding is dropped from the review (plugins/magpie-pr-management/hooks/review-findings.ts:171)
The inline picker's answer:
A,N,1,3(keep),-2,-3(drop),E 2(edit).
if (item && item.action === 'accept') {
acceptedIndices.push(i + 1);
Only accept counts as kept, so a finding the maintainer marked edit is left out of the answer and never posted. In the picker grammar an edit keeps the comment (E 2 keeps every comment and edits number 2). Please treat edit as kept here, and leave how the edited text reaches render to PR-3, with a test for a mixed accept/edit/skip list.
Smaller observations
- See inline comments on
plugins/magpie-pr-management/hooks/review-findings.ts:108,plugins/magpie-pr-management/hooks/review-findings.ts:47,plugins/magpie-pr-management/hooks/review-findings.ts:77,plugins/magpie-pr-management/hooks/review-findings.ts:270.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. After you've
addressed the points above and pushed an update, an Apache Magpie
maintainer — a real person — will take the next look
at the PR. The findings cite the project's review criteria;
if you think one of them is mis-applied, please reply on the
PR and a maintainer will weigh in.More on how Apache Magpie handles maintainer review:
Contributing guide.
979911d to
e20e6a6
Compare
|
Thanks for the detailed review and catching these subtle bridge edge cases, @potiuk! All points and the question have been addressed in this push:
All 18 unit tests pass cleanly locally ( |
apache#1887) Add the core TypeScript data model, findings parser, and hook wiring for the interactive review findings pane mod in magpie-pr-management. Part 1 of 3 for apache#1887 (parent issue apache#1497): - Add types.ts defining ReviewFinding, ReviewFindingsSummary, ReviewFindingsState, and ParseFindingsResult. - Add review-findings.ts with robust parseFindings extracting raw JSON, wrapped markdown fences, and field aliases without node built-ins. - Add formatKeepAnswer converting accepted and edited findings into Step 7a keep answer format with render indexing parity. - Add serializeFindingsForRender to bridge 1:1 with render input. - Add hooks.json and clean codex-hooks.json with CODEX_FAMILY_HOOKS registration to preserve strict vendor neutrality across harnesses. - Add comprehensive 18-test unit suite in review-findings.test.ts covering synonyms, strict line parsing, action defaults, and suggestion indentation. All tests pass via claude plugin test and strict manifest validation passes.
Review fixups: - serializeFindingsForRender wrote body / rule / fixup, which render never reads, so every inline comment rendered from the file came out as a bare title. It now keeps every field of the original finding (explanation, rule_id, quoted_rule, excerpt, suggestion_block, side, reviewers, ...), drops the parser-only aliases, overrides the normalised file / line / severity, and maps body / rule to explanation / rule_id when the finding had only those. - Tests: a full Step-4 finding round-trips with every key render reads, and render's numbering over the serialised file matches formatKeepAnswer on the inputs where the raw keys diverge (lineNumber / line_number aliases, the string "0", a non-object item). - A numeric non-integer or negative line and a non-string severity are now recorded in errors, like their string counterparts. - The Codex manifest picks up the version main moved to. Generated-by: Claude Opus 5.5
e20e6a6 to
abe9a4e
Compare
potiuk
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround — the edit, unknown-action, severity, malformed-line and indentation fixes are all in and tested, and the session.start docstring answers my question. Rather than send this back for another round, I rebased the branch onto main and pushed one fixup commit, abe9a4e, for what was left (please pull before pushing again):
hooks/review-findings.ts—serializeFindingsForRenderwrotebody/rule/fixup, whichrendernever reads, so every inline comment rendered from the file would have come out as a bare title. It now keeps every field of the original finding (explanation,rule_id,quoted_rule,excerpt,suggestion_block,side,reviewers, …), drops the parser-only aliases, and overrides only the normalisedfile/line/severity; a finding that arrived with onlybody/rulegets them asexplanation/rule_id.hooks/review-findings.test.ts— a full Step-4 finding now round-trips with every keyrenderreads, and the parity test runsrender's own rule over the serialised file on the inputs where the raw keys diverge (lineNumber/line_number, the string"0", a non-object item). 21 tests pass underclaude plugin test.hooks/review-findings.ts— a numeric non-integer or negative line and a non-string severity are now recorded inerrors, like their string counterparts..codex-plugin/plugin.json— picks up the versionmainmoved to in #1934 (check-family-plugins --fix), which would otherwise have failed themainbuild after merge.
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.
…iew-flow integration (part 3 of #1887) (#1992) This is **PR-3 (Part 3 of 3)** completing Issue #1887 (and part of #1497) for the `magpie-pr-management` Claude Code mod. Building on the data models in PR-1 (#1920) and the presentational Pane component in PR-2 (#1954), this PR wires the live session feed, interactive action toggling, and vendor-neutral skill flow integration: - **Live session feed (Fail-open):** Intercepts `pr-management code-review disposition --findings <file>` via `tool.call` on Bash. Reads and parses the live drafted findings into `reviewFindingsState`. Unconditionally invokes `next(e)` so tool execution is never blocked or gated. When findings are empty (`[]`), or when reading the findings file fails, resets the state atom to `null` to avoid stale findings sticking across sessions. - **Zero-token curation command:** Registers the `/magpie-findings` slash command for inspecting and curating review findings directly from the prompt (`status`, `all`, `none`, `keep <indices>`, `drop <indices>`, `edit <idx> <note>`). Shows both inline comments (`1..N`) and general observations (`g1..M`). - **Edited findings serialization (not wired yet):** `serializeFindingsForRender` removes `base.suggestion` and sets `base.explanation = f.body` for an edited finding. Nothing outside the tests calls it yet, so the pane does not change what is posted. - **Interactive UI controls & disambiguated indexing:** Attaches interactive Button elements with direct clicks and `ui.press` event handling (`toggle-<N>`, `toggle-general-<N>`, `accept-all`, `skip-all`, `prev-finding`, `next-finding`). Disambiguates 1-based indexing so inline actions map strictly to anchored findings (`1..anchored.length`), returns `-1` on out-of-range indices without arbitrary whole-list fallbacks, and supports `g<N>` / `G<N>` for general observations. - **Skill workflow documentation:** Documents the interactive pane mod in `review-flow.md` Step 7a as an interactive visual overview during review triage, with semantic line breaks (one sentence per line) while upholding strict vendor neutrality: Codex, Antigravity, Cursor, and headless CI continue using the standard sequential text picker prompt. Closes #1887 Part of #1497
Summary
magpie-pr-management(Part 1 of 3 for feat(pr-management): add interactive review findings pane Claude Code mod (part of #1497) #1887, parent issue Explore Claude Code mods across the skill families #1497).parseFindingsfunction inplugins/magpie-pr-management/hooks/review-findings.tsthat safely handles raw JSON, nested structures, markdown fences (with surrounding prose), field aliasing, path sanitization, and deterministic ID assignment without node built-ins.magpie-pr-managementinCODEX_FAMILY_HOOKSwith dedicatedcodex-hooks.jsonand.codex-plugin/plugin.jsonto preserve strict vendor neutrality and avoid harness startup warnings.Type of change
.claude/skills/<name>/) — eval fixtures updated belowtools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)plugins/magpie-pr-management/hooks/)Test plan
review-findings.test.tspasses viaclaude plugin test plugins/magpie-pr-management(14 pass, 0 fail across 1 file in 0.46s).claude plugin validate --strict plugins/magpie-pr-management.check_codex_family_hooks()andcheck_codex_hook_files()return 0 errors).RFC-AI-0004 compliance
Linked issues
Notes for reviewers (optional)
This is PR-1 of the 3-part split for #1887:
ui.renderPanecomponent, severity badges, and terminal fallback.accept/skip/edit) and integration intoreview-flow.mdStep 7a.