feat(agent): auto-apply high-confidence project/milestone matches - #4698
Conversation
Wire the "auto" branch of autoProjectMilestoneMatch (the tri-state config already shipped and parsed by JSONbored#3183/JSONbored#3184) to actually attach the matched milestone/project instead of only commenting (JSONbored#3185). maybeSuggestMilestoneMatchForPr now routes mode "auto" to a new maybeAutoApplyProjectOrMilestoneMatch, which resolves matches against the repo's configured backend (GitHub by default, Linear when opted in) and attaches whichever milestone/project clears a confidence threshold, via the very same adapters suggest mode uses. Auto-apply is deliberately more conservative than suggest mode (DEFAULT_AUTO_APPLY_MIN_SCORE 0.85 vs the 0.65 suggest floor): a wrong auto-attach silently mislabels a PR, whereas a wrong suggestion is only an advisory comment a maintainer can ignore. A "native" confirmed link (score 1, e.g. Linear's GitHub integration) always clears it; a below-threshold match is left untouched. The threshold is a parameter (defaulting to the constant) so it can be tuned to a repo's observed suggest-mode false-positive rate. Best-effort: an attach failure is logged (milestone_auto_apply_failed) and swallowed by the webhook entry point, never blocking the maintenance step -- the same fail-open contract suggest mode already uses. Attaching is idempotent, so a repeated sweep never double-applies. Covered by test/unit/project-tracker-adapter.test.ts: attach on a threshold-clearing match, no-attach below the default threshold, a lowered-threshold override attaching the same match, a Projects v2 GraphQL attach, an inert Linear backend, the "auto" route attaching instead of commenting, and a failing attach logged-and-swallowed. Closes JSONbored#3185
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4698 +/- ##
=======================================
Coverage 94.14% 94.14%
=======================================
Files 437 437
Lines 38533 38551 +18
Branches 14049 14055 +6
=======================================
+ Hits 36276 36294 +18
Misses 1599 1599
Partials 658 658
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-10 14:06:30 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Linked issue satisfactionPartially addressed 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.
|
What & why
Closes #3185.
Suggest-mode (#3183/#3184) already ships the
autoProjectMilestoneMatchtri-state config (off/suggest/auto) and posts an advisory comment when a PR fuzzy-matches an open Milestone or Projects v2 board. Until now"auto"behaved the same as"suggest"— it only commented. This wires the"auto"branch to actually attach the match.What it does
maybeSuggestMilestoneMatchForPrnow branches on the mode:"auto"→ newmaybeAutoApplyProjectOrMilestoneMatch: resolves matches against the repo's configured backend (GitHub by default, Linear when opted in) and callsattachToMilestone/attachToProjectfor whichever match clears a confidence threshold — using the very same adapters suggest mode uses."suggest"→ the existing comment-only path (unchanged).Conservative by design. Auto-apply uses a higher bar than the suggest floor —
DEFAULT_AUTO_APPLY_MIN_SCORE = 0.85vs. the0.65suggest floor — because a wrong auto-attach silently mislabels a PR, while a wrong suggestion is only an advisory comment. A"native"confirmed link (score 1) always clears it; a below-threshold match is deliberately left untouched. The threshold is a parameter (defaulting to the constant) so it can be tightened to a repo's observed suggest-mode false-positive rate.Best-effort / never blocks the gate. An attach failure is logged (
milestone_auto_apply_failed) and swallowed by the webhook entry point — the same fail-open contract suggest mode already follows (src/queue/processors.tsmaintenance step). Attaching is idempotent (re-PATCHing the same milestone / re-adding the same Projects v2 item is a no-op), so a repeated maintenance/webhook sweep never double-applies or spams.Tests
test/unit/project-tracker-adapter.test.ts(all new cases pass; the module keeps 100% coverage on the added lines):"auto"through to an attach, never a suggestion comment;"auto"mode is logged and swallowed, never blocking the maintenance step.Scope note
Per the issue's own prerequisite ("should not start until there's real false-positive data to set a default threshold from"), the threshold ships as a conservative code default + a function parameter rather than a persisted per-repo
.gittensory.ymlsetting: the auto-apply mechanism and its confidence gate land here, and wiring the threshold to a per-repo setting (once production suggest-mode false-positive data exists to calibrate a default) is a clean, isolated follow-on that needs no change to this attach logic. Nosrc/services/**or other guarded paths are touched; the change is confined to the integrations adapter and its unit test.