Repository navigation
fix(pr-management): verify CI status check rollup belongs to PR head (part 1 of #2034) - #2061
Conversation
…(part 1 of apache#2034) * Query commit OID under latest: commits(last: 1) in cr-open.graphql and cr-pr.graphql * In data.py from_node(), verify commit.oid == headRefOid case-insensitively and fail closed (discard rollup) on mismatch or missing OID * When discarded, disposition.py blocks APPROVE with 'CI is not reported' * Add regression tests in test_data.py and test_decisions.py Refs apache#2034
shahar1
left a comment
There was a problem hiding this comment.
This adds a fail-closed check that the CI rollup belongs to the head commit, but the case it tests is not the one #2034 reported, and a missing oid (an older vetted-ops install) looks the same as an unreported CI.
Smaller observations
- See inline comments on
tools/pr-management/tests/code_review/test_data.py:82,tools/pr-management/src/pr_management/code_review/data.py:218.
Worth a second look from
Folks with the most context on these paths:
@potiuk— 6 recent commit(s) on the changed paths (frequent contributor, not a committer)
None of them have been notified — asking any of them for an
extra pass is the maintainer's call, and optional.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. The findings
below are observations, not blockers; an Apache Magpie
maintainer — a real person — will take the next look at the
PR. If you think a finding is mis-applied, please reply on
the PR and a maintainer will weigh in.More on how Apache Magpie handles maintainer review:
Contributing guide.
… scoping - In data.py, distinguish missing commit OID from mismatched OID when a rollup exists - Flag ci_outdated_query on PR so disposition can gate with an explicit upgrade instruction rather than leaving maintainers guessing why CI is unreported - Clarify test docstrings and naming to reflect Direction 1 (lagging commit edge guard) without overstating coverage of same-head stale rollups - Sync dual-tree mirrors under plugins/magpie-security-tools
shahar1
left a comment
There was a problem hiding this comment.
The head-commit check and the missing-oid handling look right and both earlier threads are addressed; two smaller points remain, about where the out-of-date-query signal shows up and the texts that describe the CI gates.
Smaller observations
- See inline comments on
tools/pr-management/src/pr_management/code_review/cli.py:446,tools/pr-management/src/pr_management/code_review/disposition.py:148.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Magpie maintainer. The findings
below are observations, not blockers; an Apache Magpie
maintainer — a real person — will take the next look at the
PR. If you think a finding is mis-applied, please reply on
the PR and a maintainer will weigh in.More on how Apache Magpie handles maintainer review:
Contributing guide.
… document the gate - code_review/cli.py (+ vendored copy): when the installed vetted-ops queries do not return the latest commit's oid, the headline says CI cannot be verified instead of "none reported", and the context `ci` object carries `outdated_query`. - pr-management-family.md, review-flow.md: describe the head-commit check and the vetted-ops upgrade `ci_action`. - test_data.py: the headline names the stale-query state. Generated-by: Claude Opus 5
potiuk
left a comment
There was a problem hiding this comment.
The fail-closed check is right: a rollup is used only when its commit is the head commit, and a stale vetted-ops query gets its own gate. I pushed one fixup commit, 9ccaaef, for the two open points:
tools/pr-management/src/pr_management/code_review/cli.py(and the vendored copy): the headline now saysCI: cannot verify (vetted-ops queries are out of date; upgrade vetted-ops)instead of "none reported", and thecontextciobject carriesoutdated_query, so the cause shows beforedisposition.tools/spec-loop/specs/pr-management-family.mdandplugins/magpie-pr-management/skills/code-review/review-flow.mddescribe the new gate and its upgradeci_action.- A test that the headline names the stale-query state.
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
commits(last: 1)can lag behind or return astatusCheckRollupbelonging to a prior commit rather than the PR's trueheadRefOid.cr-open.graphqlandcr-pr.graphql, requestoidonlatest: commits(last: 1) { nodes { commit { oid statusCheckRollup ... } } }.pr_management.code_review.data.from_node():commit_oidstrictly matchesheadRefOid(case-normalized); on mismatch, fail closed by clearingrollup = {}.statusCheckRollupexists butcommit_oidis absent (e.g. an older installedvetted-opsthat lacksoidunderlatest), fail closed on rollup and setci_outdated_query = True.disposition.pick():ci_outdated_queryis set, blockAPPROVEwith an explicit gate ("CI rollup cannot be verified — vetted-ops is out of date (latest commit lacks OID)") and provide an actionableci_action("upgrade vetted-ops to update GraphQL queries, then re-run disposition"), rather than silently showing "CI is not reported".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)Test plan
ruff checkpasses acrosstools/andplugins/ruff format --checkpasses acrosstools/andplugins/mypypasses (76 source files checked, 0 issues) in bothtools/andplugins/pytest tools/pr-management/tests/code_review/passes (241 passed)tools/andplugins/forpr_managementandvetted_opstest_data.py:test_from_node_accepts_matching_head_and_commit_oidtest_from_node_discards_rollup_when_commit_oid_mismatches_head_ref_oid(lagging commit edge guard)test_from_node_discards_rollup_and_flags_outdated_query_when_commit_oid_missing(query skew handling)test_from_node_discards_rollup_when_head_ref_oid_missingtest_from_node_accepts_rollup_case_insensitivelytest_decisions.py:test_pr_with_lagging_commit_edge_fails_closed_to_commenttest_pr_with_outdated_vetted_ops_query_gates_approval_with_upgrade_actionRFC-AI-0004 compliance
<PROJECT>,<tracker>,<upstream>,<security-list>) used in all skill / tool prose (thecheck-placeholdersprek hook is the mechanical gate)Linked issues
Refs #2034 (part 1 of 2: Direction 1 fail-closed guard against lagging GraphQL commit edges, plus query-skew defense)
Notes for reviewers (optional)
latestcommit has not advanced toheadRefOid. It does not claim to address cases where GitHub's API attaches a stale rollup to a commit node that already carriesheadRefOid; that case will be addressed in Direction 2 (probing check-runs for the head commit).pr-managementandvetted-ops. A missing OID fails closed to prevent unverified approvals, but surfaces an explicit"vetted-ops is out of date"approval gate andci_actionso maintainers are immediately informed.