Skip to content

fix(triggers): address code review findings for integration-driven architecture#596

Merged
zbigniewsobiecki merged 2 commits intodevfrom
fix/code-review-trigger-architecture
Mar 1, 2026
Merged

fix(triggers): address code review findings for integration-driven architecture#596
zbigniewsobiecki merged 2 commits intodevfrom
fix/code-review-trigger-architecture

Conversation

@zbigniewsobiecki
Copy link
Copy Markdown
Member

Summary

  • Fix schema validation for trigger definitions (event format, provider, defaultValue type consistency)
  • Fix repository bulkUpsertTriggerConfigs bug (was using first config's values for all conflicts)
  • Refactor router to use repository functions instead of direct DB access
  • Fix YAML definitions (duplicate triggers, invalid events, required+defaultValue contradictions)
  • Add comprehensive test coverage (51 new tests)

Schema Validation Improvements

  • TriggerEventSchema: Validates format {category}:{event-name} (e.g., pm:card-moved, scm:check-suite-success)
  • KnownProviderSchema: Enum of valid providers (trello, jira, github, imap, gmail, twilio)
  • TriggerParameterSchema: Validates defaultValue matches parameter type, prevents required: true with defaultValue
  • IntegrationRequirementsSchema: Prevents same category in both required and optional

Repository Fixes

  • bulkUpsertTriggerConfigs: Now uses individual upserts in a transaction to ensure each config's values are used correctly
  • Added getTriggerConfigById for ownership verification in router

YAML Fixes

  • review.yaml: Consolidated duplicate scm:check-suite-success triggers into single trigger with authorMode select parameter
  • debug.yaml: Removed undeclared pm:attachment-added trigger (agent is manually triggered)
  • implementation/planning/splitting.yaml: Removed contradictory required: true from parameters with defaultValue

Test Plan

  • All 3672 tests pass (51 new tests added)
  • TypeScript type checking passes
  • Linting passes
  • CI tests pass
  • Agent definitions load correctly
  • Trigger configs CRUD operations work

🤖 Generated with Claude Code

zbigniewsobiecki and others added 2 commits March 1, 2026 19:07
…chitecture

Schema validation improvements:
- Add TriggerEventSchema with regex validation for {category}:{event-name} format
- Add KnownProviderSchema enum (trello, jira, github, imap, gmail, twilio)
- Add defaultValue type consistency refinement (must match parameter type)
- Add refinement preventing required: true with defaultValue
- Add IntegrationRequirementsSchema overlap refinement

Repository fixes:
- Fix bulkUpsertTriggerConfigs bug (was using first config's values for all conflicts)
- Add getTriggerConfigById function for ownership verification
- Use individual upserts in transaction for correct per-config values

Router refactoring:
- Replace direct DB access with repository functions in update/delete procedures
- Clean up imports (remove unused getDb, eq)

YAML definition fixes:
- review.yaml: consolidate duplicate scm:check-suite-success triggers into single
  trigger with authorMode select parameter (own/external/all)
- debug.yaml: remove undeclared pm:attachment-added trigger (agent is manually triggered)
- implementation.yaml, planning.yaml, splitting.yaml: remove contradictory
  required: true from parameters that have defaultValue

Tests:
- Add comprehensive tests for TriggerParameterSchema validation
- Add tests for SupportedTriggerSchema event format validation
- Add tests for KnownProviderSchema
- Add tests for IntegrationRequirementsSchema overlap
- Add tests for AgentDefinitionSchema with triggers
- Add full test suite for agentTriggerConfigs router (51 new tests)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add `triggers: []` to EMPTY_DEFINITION in agent-definition-editor.tsx
to satisfy the TypeScript type now that triggers is a required field
in AgentDefinition.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@zbigniewsobiecki zbigniewsobiecki merged commit f527838 into dev Mar 1, 2026
6 checks passed
@zbigniewsobiecki zbigniewsobiecki deleted the fix/code-review-trigger-architecture branch March 1, 2026 18: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