refactor(triggers): decouple triggers from PR body work item parsing#477
Merged
zbigniewsobiecki merged 1 commit intodevfrom Feb 22, 2026
Merged
Conversation
…arsing Replace Trello URL checks in trigger gates with implementer persona authorship checks and DB-backed work item resolution. This fixes JIRA projects where PRs were silently skipped because triggers only matched Trello card URLs. Key changes: - Add pr_work_items table to store PR-to-work-item links at PR creation - Gate check-suite-success/failure on implementer persona (not URL presence) - Add resolveWorkItemId() utility: DB lookup with PR body extraction fallback - All triggers now fire even without a linked work item (graceful degradation) - Thread projectId/cardId through session state to CreatePR gadget for persistence - Add user.login to PRDetails for persona matching Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pr_work_itemsDB table to persist PR-to-work-item links at PR creation time, replacing fragile PR body URL parsingresolveWorkItemId()utility with DB-first lookup and PR body extraction fallback for backward compatibilityMotivation
PR #77 on car-dealership (JIRA project) didn't trigger a review because
CheckSuiteSuccessTriggergated on finding a Trello card URL in the PR body. JIRA uses issue keys likeBTS-54, so the Trello-only regex silently skipped all JIRA PRs.Changes
Database
0014_pr_work_items.sqlwith unique constraint on(project_id, pr_number)linkPRToWorkItem(upsert) andlookupWorkItemForPRGitHub client
user: { login }toPRDetailsfor persona matching in check-suite triggersSession state / CreatePR gadget
projectIdandcardIdthrough session state → builder factory → agentsCreatePRgadget persists the PR↔work-item link after successful PR creation (best-effort)Triggers (8 files updated)
check-suite-successhasTrelloCardUrl()check-suite-failurehasTrelloCardUrl()pr-review-submittedrequireTrelloCardId()→ return nullresolveWorkItemId()→ proceedpr-comment-mentionrequireTrelloCardId()→ return nullresolveWorkItemId()→ proceedpr-openedhasTrelloCardUrl()→ return nullresolveWorkItemId()→ proceedreview-requestedextractWorkItemId()→ return nullresolveWorkItemId()→ proceedpr-ready-to-mergerequireWorkItemId()→ return nullresolveWorkItemId()→ skip if nonepr-mergedrequireWorkItemId()→ return nullresolveWorkItemId()→ skip if noneBackward compatibility
resolveWorkItemId()falls back to PR body regex extraction when the DB lookup returns null, so PRs created before this migration continue to work.Test plan
prWorkItemsRepository(upsert, lookup)resolveWorkItemId(DB hit, PR body fallback, JIRA fallback, DB error fallback, null body)check-suite-successtests: implementer persona gate replaces Trello URL gatecheck-suite-failuretests: same patternlookupWorkItemForPR, verify triggers fire without work itemgetPRtests:userfield in responseCreatePRgadget tests:repoFullNamein result🤖 Generated with Claude Code