fix(agent-actions): re-check the linked-issue hard rule on merge accept - #2388
Conversation
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-01 23:25:03 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 7 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2388 +/- ##
=======================================
Coverage 95.88% 95.88%
=======================================
Files 224 224
Lines 25143 25158 +15
Branches 9143 9150 +7
=======================================
+ Hits 24109 24124 +15
Misses 421 421
Partials 613 613
🚀 New features to boost your workflow:
|
decidePendingAgentAction re-validated only the head SHA before replaying a staged auto_with_approval merge. The linked-issue hard rule (owner-assigned / missing-point-label / maintainer-only) is evaluated fresh on every planning pass and takes precedence over merge, but a staged merge only replayed the plan-time snapshot: a maintainer relabeling or reassigning the linked issue between staging and accept (head SHA unchanged) would still merge a now-ineligible PR. Re-run resolveLinkedIssueHardRule for a staged merge before executing it, superseding the same way the head-moved check already does. Skips the check for an owner/automation-authored PR (unless closeOwnerAuthors is on), mirroring the planner's own closeEligible exemption so a trusted PR the rule never blocks in the first place isn't wrongly denied here. Live CI re-verification for this same accept path is covered separately by the already-open PR for #2128, which executeAgentMaintenanceActions applies to every merge regardless of caller — no changes needed here for that part.
…ure path The rebase onto main's later head-pinning fixes shifted this diff's covered range; close the resulting branch-coverage gap on the createInstallationToken(...).catch(() => undefined) fallback added for the #2132 linked-issue hard-rule recheck.
3ea9235 to
d357bb8
Compare
…de plan The linked-issue hard-rule recheck gated on pending.actionClass (the ORIGINAL staged class) rather than the plan's actual contents after the #2127 precision-breaker downgrade. A merge already downgraded to a needs-human-review label by downgradeMergeToHold would still get its whole row rejected on a stale linked-issue violation, silently swallowing the hold label the breaker was supposed to guarantee -- since nothing is about to merge, the linked-issue state is irrelevant to what plan is actually going to execute. Also documents why the recheck's best-effort token mint is intentionally fail-open, consistent with the sibling #2126 CI/mergeable/review re-check: resolveLinkedIssueHardRule already degrades to env.GITHUB_PUBLIC_TOKEN before ever returning "not violated," and this is the same shared resolver + fail-open contract the live planning path already relies on for the primary hard-rule decision.
What
decidePendingAgentAction(the approval-queue accept handler for a stagedauto_with_approvalaction) re-validated only the head SHA before replaying a staged merge. The linked-issue hard rule (owner-assigned / missing-point-label / maintainer-only) is evaluated fresh on every planning pass and takes precedence over merge (planAgentMaintenanceActionsnever plans a merge when the rule is violated) — but a staged merge only replays the PLAN-TIME snapshot. If a maintainer relabels or reassigns the linked issue between staging and accept (head SHA unchanged, so the existing freshness check doesn't catch it), the stale merge decision would still execute, merging a PR that would now trip the deterministic hard-rule close if the planner were re-run.Fix
decidePendingAgentAction(src/services/agent-approval-queue.ts) now re-runsresolveLinkedIssueHardRulefor a stagedmergeaction before executing it, denying/superseding the same way the existing head-moved check already does (same audit event type,agent.pending_action.superseded,outcome: "denied").The recheck mirrors the planner's own
closeEligibleexemption: it's skipped entirely for an owner- or automation-authored PR (unlesscloseOwnerAuthorsis on), since the hard rule never blocks those PRs in the planner either — without this, an owner's legitimate staged merge could be wrongly denied just because their own linked issue happens to match a rule pattern that was never meant to constrain them.Scope note on the sibling CI-recheck deliverable: issue #2132 also asks to re-check live CI state at accept time. That's already covered by a separate, already-open PR for #2128 (
executeAgentMaintenanceActions's step 6 CI re-verification), which applies to everymerge-class action regardless of caller —decidePendingAgentAction's existing call into that executor will pick it up automatically once that PR merges, with zero additional changes needed here. This PR is deliberately scoped to just the linked-issue portion to stay small and avoid duplicating code already in flight; opening as "Advances" rather than "Closes" since full closure depends on that sibling PR landing too.Tests
resolveLinkedIssueHardRulereports a violation between staging and accept (contributor PR).closeEligibleexemption).repoFullNameand a PR with no author login are tolerated (the two defensive fallbacks in the newrepoOwner/authorLoginderivation).npx tsc --noEmitclean.agent-approval-queue.test.ts— 23 passed.routes-agent-approval.test.ts,mcp-automation-state.test.ts,agent-action-executor.test.ts,agent-actions.test.ts,linked-issue-hard-rules.test.ts(the two direct importers of this module plus the hard-rule evaluator itself) — 215 passed.src/services/agent-approval-queue.ts: fully covered.npm run test:coverage: 5605 passed, 4 skipped (pre-existing/unrelated), 0 failed.npm audit --audit-level=moderate: 0 vulnerabilities.Advances #1936. Advances #2132.