fix: gate kapi approval after review check#158
Conversation
|
@kapi-agent review Revision explanation for current head What changed:
Why this is needed:
Verification rerun:
|
There was a problem hiding this comment.
kapi-agent review
Verdict: APPROVE
Final approval summary
Review journey
The original goal is to fix the formal kapi-agent approval gate race where the gate could run before kapi-agent/review existed for the current head, leaving stale failed required checks. The semantic scope is limited to .github/workflows/kapi-agent-formal-approval-gate.yml. There is no prior kapi-agent review on this PR, so no unresolved ping-pong feedback remains.
What changed
The workflow now:
- Runs on
check_runcompletion forkapi-agent/review. - Keeps
pull_request_reviewevents for review submitted/edited/dismissed re-evaluation. - Resolves the PR number from either review or check-run payloads.
- Polls briefly for the current-head
kapi-agent/reviewcheck/status before failing. - Continues to require a formal PR review by
kapi-agenton the current head, not an approval-shaped comment.
Why this is correct
Moving the gate off early PR lifecycle events avoids evaluating before the review check exists. Re-triggering from the completed kapi-agent/review check aligns the formal gate with the artifact it depends on, while retaining review-event re-evaluation for approval state changes. The current-head review SHA comparison and check/status lookup preserve the intended safety contract.
Evidence
- Verifier gate: PASS.
- Size gate: PASS, 69 changed lines under the 200-line limit.
- Revision explanation status: not required; explanation present.
- Ilchul harness gate: PASS, neutral/comment with 0 blocking findings.
- CI/local evidence provided:
npm ci && npm run verifyexited 0. - Inspected file:
.github/workflows/kapi-agent-formal-approval-gate.yml.
Remaining risks and approval rationale
Remaining risk is low and mainly operational: GitHub event/check-run association behavior can be subtle, but the implementation is narrowly scoped and keeps explicit current-head validation. Approval is justified because all gates pass, the PR is small, and I found no blocking correctness, security, or workflow-contract issue.
Blocking issues
None.
Warnings / risks
.github/workflows/kapi-agent-formal-approval-gate.yml: the workflow still depends oncheck_run.pull_requests[0]being present for thekapi-agent/reviewcheck-run path. That is acceptable for the expected PR check flow, but if the app ever emits check runs without PR association, the gate will fail with a clear diagnostic.
Suggestions
- Consider adding a short comment in the workflow explaining why
pull_requestevents are intentionally omitted, since this is a race-prevention contract and may otherwise look accidental later.
Looks good
- The gate still distinguishes formal PR reviews from approval-shaped comments.
- The latest kapi-agent review is still required to be
APPROVEDand tied to the current head SHA. - Polling is bounded and only waits for missing/pending check state, avoiding an indefinite workflow hang.
- The change is focused on the approval-gate workflow and does not broaden permissions.
Verification notes
- Verifier gate status: PASS,
npm ci && npm run verifyexited 0. - Size gate status: PASS, 69 changed lines < 200.
- Revision-explanation status: not required; found.
- Ilchul review harness: PASS, no blocking findings.
- Local inspection covered the workflow logic in
.github/workflows/kapi-agent-formal-approval-gate.yml.
Engine: pi
Summary
pull_requestevents.kapi-agent/reviewcompletes viacheck_run, while keepingpull_request_reviewevents for review submitted/edited/dismissed re-evaluation.kapi-agent/reviewstate before failing, so race-prone missing/pending checks do not leave stale failed required checks.Why
PR #150 exposed a race where
require formal kapi-agent approvalran beforekapi-agent/reviewexisted on the current head, leaving stale failed required checks that blocked merge even after later success.Test Plan
ruby -e 'require "yaml"; YAML.load_file(".github/workflows/kapi-agent-formal-approval-gate.yml")'node --checkgit diff --check .github/workflows/kapi-agent-formal-approval-gate.ymlnpm run verifyFollow-up to #150.