Skip to content

refactor(pipelines): consolidate 12 tools into 3 CQRS tools#26

Merged
polaz merged 4 commits intomainfrom
refactor/#14-pipelines-cqrs-consolidation
Jan 19, 2026
Merged

refactor(pipelines): consolidate 12 tools into 3 CQRS tools#26
polaz merged 4 commits intomainfrom
refactor/#14-pipelines-cqrs-consolidation

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Jan 19, 2026

Summary

  • Consolidate 12 individual pipeline tools into 3 CQRS-aligned tools
  • browse_pipelines (Query): list, get, jobs, triggers, job, logs actions
  • manage_pipeline (Command): create, retry, cancel actions
  • manage_pipeline_job (Command): play, retry, cancel actions

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

Test plan

  • Unit tests pass (1426 tests)
  • Lint passes
  • Build succeeds

Closes #14

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
Copilot AI review requested due to automatic review settings January 19, 2026 14:38
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 19, 2026

📊 Test Coverage Report

Overall Coverage: 85.86%

Coverage Details

Metric Percentage
Statements $(cat coverage/lcov-report/index.html
Branches $(cat coverage/lcov-report/index.html
Functions $(cat coverage/lcov-report/index.html
Lines $(cat coverage/lcov-report/index.html

📈 Coverage Report: View detailed coverage report

This report was generated automatically from your PR changes.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 81.91489% with 34 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/entities/pipelines/registry.ts 77.77% 22 Missing and 12 partials ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@polaz polaz merged commit ce66319 into main Jan 19, 2026
12 checks passed
@polaz polaz deleted the refactor/#14-pipelines-cqrs-consolidation branch January 19, 2026 14:56
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.

refactor(pipelines): CQRS consolidation - 12 tools → 3 tools

2 participants