fix(pr-linking): require word boundary before closing keywords (#151)#152
fix(pr-linking): require word boundary before closing keywords (#151)#152dale053 wants to merge 6 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughEnforces correct closing-keyword boundaries with a regex fix and tests, migrates the DB to track reconcile versioning, changes the closing-issues backfill to per-PR reconciliation (delete+insert) with sweep reprocessing, and adds a Node test script. ChangesPR→Issue Link Reconciliation
Sequence DiagramsequenceDiagram
participant BackfillSweep
participant GitHubGraphQL
participant BackfillWorker
participant Database
BackfillSweep->>BackfillWorker: select repos needing reconcile
BackfillWorker->>GitHubGraphQL: fetch PRs' closingIssuesReferences batch
GitHubGraphQL-->>BackfillWorker: PR nodes (some may be null)
BackfillWorker->>BackfillWorker: compute existing vs want per-PR
BackfillWorker->>Database: delete stale pr_issue_links for PR (if mismatch)
BackfillWorker->>Database: insert reconciled pr_issue_links (INSERT OR IGNORE)
BackfillWorker->>Database: update repo_meta with closing_issues_reconcile_version and backfilled_at
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Around line 9-11: The package.json scripts block contains a duplicate "lint"
entry and a missing comma after the "test" script which breaks JSON parsing;
remove the duplicated "lint" key so only the original "lint": "next lint"
remains, ensure the "test": "node --test 'src/**/*.test.ts'" entry has a
trailing comma separating it from the next property, and keep the existing
"lint" value (do not replace it with "eslint . --max-warnings=0"); update the
scripts object to contain unique keys ("lint" and "test") with proper comma
separators.
In `@src/lib/pr-linking.ts`:
- Line 11: Remove the stray regex literal
"/\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s*:?\s*(?:(?:https?:\/\/github\.com\/)?([\w.-]+\/[\w.-]+))?#(\d+)/gi"
from the codebase (it appears to be a leftover) or, if it was intended as
documentation, replace it with a clear comment explaining its purpose and
reference the actual variable/function that holds the active PR-parsing regex
(e.g., the constant or function that previously used this pattern), then re-run
tests and ensure the committed file no longer contains the orphaned regex
literal.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b9b493cd-66b5-4f0d-b844-abe9dea3ce9e
📒 Files selected for processing (7)
package.jsonsrc/lib/db.tssrc/lib/github.tssrc/lib/pr-linking.test.tssrc/lib/pr-linking.tssrc/lib/refresh.tstsconfig.json
|
Thanks for the PR. I’m going to close this one as not applicable for #151. The concrete regex bug from #151 is already fixed on This PR also introduces a broader delete-then-insert reconciliation path, but that is risky as written: The parser regression tests are useful, but the PR no longer has a valid target issue and the extra reconciliation behavior would need a separate, current issue with pagination/partial-response handling covered. |
Summary
Fix PR→issue closing-keyword linking to require a word boundary before the keyword, and add an authoritative cleanup path for the bad links the old regex already created.
close/fix/resolvealternation had no leading word boundary, so it matched the keyword as the tail of a larger word —bugfix #42,hotfix #1234,prefix #7,unresolved #5,discloses #3all became false "closing" links. Added a non-consuming(?<=^|[^\w])lookbehind (a consuming prefix would eat the separator and break adjacent matches undermatchAll). GitHub does not treat these as closing references.backfillClosingIssuesForReponow treats GitHub'sclosingIssuesReferencesas the source of truth and delete-then-inserts each PR's rows, so it can finally purge the stale/falsebugfix #N-class links the old append-only path could never remove. Untouched PRs do no writes (avoids WAL churn). The per-poll path stays additive (never deletes) so GraphQL-only links survive between reconciles.closing_issues_reconcile_versioncolumn +CLOSING_RECONCILE_VERSION = 1, so already-backfilled repos re-run exactly once when reconcile semantics change.fetchPrsClosingIssuesBatchnow omits PRs with null/absent nodes from the returned map (deleted PR / partial-data error) instead of asserting "closes nothing", so a failing batch never causes a delete.testscript (node --test) andallowImportingTsExtensionsto support the new unit tests.Related Issues
Fixes #151.
Type of Change
Testing
pnpm buildpassespnpm test— new regression suite in src/lib/pr-linking.test.ts covers thebugfix #N-class over-matches plus standalone keyword/tense, punctuation, cross-repo, and de-dup casesChecklist
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores