Skip to content

fix(review): require distinct PR for unlinked repeat close - #3672

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-auto-close-on-unlinked-issue-hold
Jul 6, 2026
Merged

fix(review): require distinct PR for unlinked repeat close#3672
JSONbored merged 1 commit into
mainfrom
codex/fix-auto-close-on-unlinked-issue-hold

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Prevent a first-offense unlinked-issue hold from being auto-closed when the same PR is reprocessed or retried by ensuring repeat-detection excludes the current PR target.
  • Record occurrences in a way that distinguishes the PR target so only a later distinct PR by the same contributor can escalate to an automated close.

Description

  • Added hasRecentAuditEventForOtherTarget to src/db/repositories.ts to query recent audit events for an actor/event type while excluding a specific targetKey.
  • Threaded pullNumber into the unlinked-issue guardrail (src/review/unlinked-issue-guardrail.ts) and changed audit targetKey to repoFullName#pullNumber; store the matched issueNumber in metadata when recording the occurrence.
  • Changed repeat check to call the new DB helper with the current PR target before recording the current occurrence so the same-PR replay does not count as a prior occurrence.
  • Passed pullNumber into the resolver from the queue processor (src/queue/processors.ts).
  • Added/updated regression tests in test/unit/unlinked-issue-guardrail.test.ts to assert that reprocessing the same PR remains a hold while a later distinct PR by the same contributor escalates to close.

Testing

  • Ran npx vitest run test/unit/unlinked-issue-guardrail.test.ts and the suite passed (16 tests passed).
  • Ran npx vitest run test/unit/unlinked-issue-guardrail.test.ts test/unit/agent-actions.test.ts and both files passed (246 tests total passed).
  • npm run typecheck succeeded with tsc --noEmit (no type errors).
  • git diff --check was clean.
  • npm run test:coverage was started but the full coverage run was interrupted by unrelated long-running/timeout failures in other test files; the targeted unit tests above passed.
  • npm audit --audit-level=moderate could not complete due to registry audit endpoint returning 403 Forbidden (external).

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 6, 2026
@loopover-orb

loopover-orb Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-06 01:59:38 UTC

4 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This PR fixes a real self-inflicted-escalation bug: the repeat-offense check previously keyed on repoFullName#issueNumber and had no way to distinguish a reprocessed/retried PR from a genuinely new PR, so replaying the same PR could count as its own 'prior occurrence' and escalate a first offense to an automatic close. The fix threads pullNumber through, changes the audit targetKey to repoFullName#pullNumber, and adds hasRecentAuditEventForOtherTarget to explicitly exclude the current PR's target when checking for a prior match, calling it before recording the current occurrence so ordering can't self-count. The new tests cover both the replay-stays-hold case and the distinct-PR-escalates-to-close case, and CI (including typecheck) passed, so the `not`/query wiring is sound.

Nits — 4 non-blocking
  • The occurrence record now stores the matched issueNumber only in `metadata` while `targetKey` is PR-based (src/review/unlinked-issue-guardrail.ts) — worth confirming the audit_events schema already has a metadata column, since that wasn't visible in the diff.
  • `unlinkedIssueMatchTargetKey` is a small pure helper duplicated conceptually between the guardrail and any future caller of hasRecentAuditEventForOtherTarget — fine for now but worth noting if a third call site appears.
  • Consider a regression test asserting the recorded audit event's `targetKey` format directly (e.g. `owner/repo#101`) rather than only through behavioral hold/close assertions, to lock the key format against future refactors.
  • If `metadata` is a new/loosely-typed JSON column on auditEvents, add a short comment or type reference for what shape callers should expect there long-term.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 55 registered-repo PR(s), 46 merged, 457 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 55 PR(s), 457 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 55 PR(s), 457 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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.

  • Re-run Gittensory review

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.20%. Comparing base (5bc2711) to head (c90fd03).
⚠️ Report is 30 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3672   +/-   ##
=======================================
  Coverage   93.20%   93.20%           
=======================================
  Files         313      313           
  Lines       31910    31915    +5     
  Branches    11677    11677           
=======================================
+ Hits        29741    29746    +5     
  Misses       1517     1517           
  Partials      652      652           
Files with missing lines Coverage Δ
src/db/repositories.ts 96.51% <100.00%> (+<0.01%) ⬆️
src/queue/processors.ts 93.59% <ø> (ø)
src/review/unlinked-issue-guardrail.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 6, 2026
@JSONbored
JSONbored merged commit 4e37d25 into main Jul 6, 2026
10 checks passed
@JSONbored
JSONbored deleted the codex/fix-auto-close-on-unlinked-issue-hold branch July 6, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant