refactor(pipelines): consolidate 12 tools into 3 CQRS tools#26
Conversation
Replace 12 individual pipeline tools with 3 CQRS-aligned tools using Zod discriminated unions with action parameter: QUERY TOOL: - browse_pipelines: list, get, jobs, triggers, job, logs actions COMMAND TOOLS: - manage_pipeline: create, retry, cancel actions - manage_pipeline_job: play, retry, cancel actions SUPPORTING CHANGES: - Refactor schema-readonly.ts with BrowsePipelinesSchema discriminated union - Refactor schema.ts with ManagePipelineSchema and ManagePipelineJobSchema - Refactor registry.ts with 3 CQRS tool handlers - Update unit tests from 12-tool to 3-tool CQRS structure - Update integration tests to use BrowsePipelinesSchema with action parameter Closes #14
📊 Test Coverage ReportOverall Coverage: 85.86% Coverage Details
📈 Coverage Report: View detailed coverage report
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR refactors the pipelines tooling to follow CQRS (Command Query Responsibility Segregation) patterns by consolidating 12 individual tools into 3 well-organized tools. The refactor maintains backward compatibility while improving the developer experience through discriminated unions.
Changes:
- Consolidated 12 pipeline tools into 3 CQRS-aligned tools using discriminated unions with action parameters
- Refactored schemas to use discriminated unions for better type safety and validation
- Updated all tests (unit and integration) to use the new CQRS structure with action parameters
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/entities/pipelines/schema-readonly.ts |
Refactored to define BrowsePipelinesSchema as a discriminated union supporting 6 query actions (list, get, jobs, triggers, job, logs) |
src/entities/pipelines/schema.ts |
Refactored to define ManagePipelineSchema (create, retry, cancel) and ManagePipelineJobSchema (play, retry, cancel) as discriminated unions |
src/entities/pipelines/registry.ts |
Implemented 3 CQRS tool handlers with switch statements to dispatch actions, replacing 12 individual tool registrations |
tests/unit/entities/pipelines/registry.test.ts |
Updated from 12-tool structure to 3-tool CQRS structure with comprehensive action coverage and edge case testing |
tests/integration/schemas/pipelines.test.ts |
Updated to test BrowsePipelinesSchema with action parameters instead of separate schemas |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ADDRESS COPILOT REVIEW: - Add project_id to integration test cases that were missing it - Add requiredId helper to utils.ts that properly rejects undefined/null - Replace z.coerce.string() with requiredId for all required ID fields The issue: z.coerce.string() converts undefined to literal string "undefined" instead of failing validation. This was causing tests to pass incorrectly. DEPENDENCY UPDATE: - Bump pino from 10.2.0 to 10.2.1
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
browse_pipelines(Query): list, get, jobs, triggers, job, logs actionsmanage_pipeline(Command): create, retry, cancel actionsmanage_pipeline_job(Command): play, retry, cancel actionsChanges
schema-readonly.tswithBrowsePipelinesSchemadiscriminated unionschema.tswithManagePipelineSchemaandManagePipelineJobSchemaregistry.tswith 3 CQRS tool handlersBrowsePipelinesSchemawith action parameterTest plan
Closes #14