Skip to content

refactor: trigger config migration cleanup#636

Merged
zbigniewsobiecki merged 3 commits intodevfrom
refactor/trigger-config-migration-cleanup
Mar 7, 2026
Merged

refactor: trigger config migration cleanup#636
zbigniewsobiecki merged 3 commits intodevfrom
refactor/trigger-config-migration-cleanup

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

Post-migration cleanup for the DB-driven trigger config system. Addresses quality issues found during code review:

  • Eliminate double DB queries — Add checkTriggerEnabledWithParams() that fetches enabled state + parameters in a single getResolvedTriggerConfig() call. Used by check-suite-success and pr-opened handlers.
  • Deduplicate authorMode gating — Extract evaluateAuthorMode() into src/triggers/github/utils.ts, replacing ~25 duplicated lines across two handlers. Includes proper validation against ['own', 'external', 'all'] with fallback to 'own'.
  • Consistent trigger check pattern — Switch pr-ready-to-merge and pr-merged from direct isTriggerEnabled() to the shared checkTriggerEnabled() helper for uniform logging.
  • Add debug logging — Log no-@mention skip path in pr-comment-mention.
  • Remove legacy config — ~1900 lines of obsolete trigger config schemas and tests removed.
  • Test coverage — Add disabled-trigger + toHaveBeenCalledWith argument verification tests to all 13 handler test files.

Changes

Area Files What
New shared helper src/triggers/shared/trigger-check.ts checkTriggerEnabledWithParams()
New utility src/triggers/github/utils.ts evaluateAuthorMode()
GitHub triggers 8 handler files Use shared helpers, remove duplication
PM triggers 6 handler files (Trello + JIRA) Consistent checkTriggerEnabled usage
Legacy removal src/config/schema.ts, triggerConfig.ts, configMapper.ts, etc. Remove ~1900 lines
Tests 13 test files Disabled-trigger tests + argument verification

Test plan

  • npm run typecheck — clean
  • npm run lint — clean
  • npm test — 3762 tests passing
  • All 13 trigger handler test files have disabled-trigger coverage
  • checkTriggerEnabledWithParams argument verification in check-suite-success and pr-opened tests

🤖 Generated with Claude Code

zbigniewsobiecki and others added 3 commits March 7, 2026 07:03
…and harden

- Add `checkTriggerEnabledWithParams()` to combine enabled check + parameter
  fetch in a single DB call (eliminates double query in check-suite-success
  and pr-opened handlers)
- Extract `evaluateAuthorMode()` into `src/triggers/github/utils.ts` to
  deduplicate ~25 lines of authorMode gating logic across two handlers,
  with proper validation against ['own', 'external', 'all'] and fallback
- Switch pr-ready-to-merge and pr-merged from direct `isTriggerEnabled()`
  to shared `checkTriggerEnabled()` helper for consistent logging
- Add debug log for no-@mention path in pr-comment-mention
- Remove ~1900 lines of legacy trigger config schemas and tests
- Add disabled-trigger + argument verification tests to all 13 handler
  test files for complete coverage of the DB-driven trigger config path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Config toggle tests were using legacy `project_integrations.triggers` JSON
which is no longer consulted. Updated to:
- Seed `agent_trigger_configs` rows with `enabled: false` for disable tests
- Test via `handle()` (which checks DB config) instead of `matches()`
- Add `seedTriggerConfig` helper and include table in truncateAll

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit 25a023a into dev Mar 7, 2026
6 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the refactor/trigger-config-migration-cleanup branch March 7, 2026 07:17
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