Skip to content

refactor(triggers): decouple triggers from PR body work item parsing#477

Merged
zbigniewsobiecki merged 1 commit intodevfrom
refactor/decouple-triggers-from-pr-body-parsing
Feb 22, 2026
Merged

refactor(triggers): decouple triggers from PR body work item parsing#477
zbigniewsobiecki merged 1 commit intodevfrom
refactor/decouple-triggers-from-pr-body-parsing

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

  • Add pr_work_items DB table to persist PR-to-work-item links at PR creation time, replacing fragile PR body URL parsing
  • Gate check-suite triggers on implementer persona authorship instead of Trello URL presence — fixes JIRA projects where PRs were silently skipped
  • Add resolveWorkItemId() utility with DB-first lookup and PR body extraction fallback for backward compatibility
  • All triggers now fire without a linked work item (graceful degradation) — agents run, PM updates are simply skipped

Motivation

PR #77 on car-dealership (JIRA project) didn't trigger a review because CheckSuiteSuccessTrigger gated on finding a Trello card URL in the PR body. JIRA uses issue keys like BTS-54, so the Trello-only regex silently skipped all JIRA PRs.

Changes

Database

  • New migration 0014_pr_work_items.sql with unique constraint on (project_id, pr_number)
  • Drizzle schema + repository with linkPRToWorkItem (upsert) and lookupWorkItemForPR

GitHub client

  • Add user: { login } to PRDetails for persona matching in check-suite triggers

Session state / CreatePR gadget

  • Thread projectId and cardId through session state → builder factory → agents
  • CreatePR gadget persists the PR↔work-item link after successful PR creation (best-effort)

Triggers (8 files updated)

Trigger Before After
check-suite-success Gate on hasTrelloCardUrl() Gate on implementer persona authorship
check-suite-failure Gate on hasTrelloCardUrl() Gate on implementer persona authorship
pr-review-submitted requireTrelloCardId() → return null resolveWorkItemId() → proceed
pr-comment-mention requireTrelloCardId() → return null resolveWorkItemId() → proceed
pr-opened hasTrelloCardUrl() → return null resolveWorkItemId() → proceed
review-requested extractWorkItemId() → return null resolveWorkItemId() → proceed
pr-ready-to-merge requireWorkItemId() → return null resolveWorkItemId() → skip if none
pr-merged requireWorkItemId() → return null resolveWorkItemId() → skip if none

Backward 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

  • New unit tests for prWorkItemsRepository (upsert, lookup)
  • New unit tests for resolveWorkItemId (DB hit, PR body fallback, JIRA fallback, DB error fallback, null body)
  • Updated check-suite-success tests: implementer persona gate replaces Trello URL gate
  • Updated check-suite-failure tests: same pattern
  • Updated all other trigger tests: mock lookupWorkItemForPR, verify triggers fire without work item
  • Updated getPR tests: user field in response
  • Updated CreatePR gadget tests: repoFullName in result
  • All 2506 tests passing, lint clean, typecheck clean

🤖 Generated with Claude Code

…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>
@zbigniewsobiecki zbigniewsobiecki merged commit 2f33e78 into dev Feb 22, 2026
5 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the refactor/decouple-triggers-from-pr-body-parsing branch February 22, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant