Skip to content

feat(schema): add dynamic action filtering with schema transformation pipeline#44

Merged
polaz merged 9 commits intomainfrom
feat/32-dynamic-action-filtering
Jan 19, 2026
Merged

feat(schema): add dynamic action filtering with schema transformation pipeline#44
polaz merged 9 commits intomainfrom
feat/32-dynamic-action-filtering

Conversation

@polaz
Copy link
Copy Markdown
Member

@polaz polaz commented Jan 19, 2026

Summary

  • Add GITLAB_DENIED_ACTIONS config for filtering specific actions from CQRS tools
  • Add GITLAB_ACTION_{TOOL}_{ACTION} for action description overrides
  • Add GITLAB_PARAM_{TOOL}_{PARAM} for parameter description overrides
  • Add GITLAB_SCHEMA_FORMAT config (flat|discriminated) for schema output format
  • Create schema-utils.ts with transformation pipeline
  • Migrate manage_milestone to discriminated union schema (pilot)
  • Add runtime validation for denied actions in handlers

Schema Pipeline

When a tool is registered, the schema goes through a transformation pipeline:

  1. Filter Denied Actions - Removes branches for actions listed in GITLAB_DENIED_ACTIONS
  2. Apply Description Overrides - Applies GITLAB_ACTION_* and GITLAB_PARAM_* overrides
  3. Conditional Flatten - Converts oneOf to flat schema when GITLAB_SCHEMA_FORMAT=flat (default)

Test plan

  • Unit tests for config parsing (GITLAB_DENIED_ACTIONS, action/param overrides)
  • Unit tests for schema-utils.ts (filter, flatten, apply overrides)
  • Unit tests for runtime validation in handlers
  • Integration tests for milestone schemas
  • All 1783 tests passing

Closes #32

… pipeline

- Add GITLAB_DENIED_ACTIONS config for filtering specific actions from CQRS tools
- Add GITLAB_ACTION_{TOOL}_{ACTION} for action description overrides
- Add GITLAB_PARAM_{TOOL}_{PARAM} for parameter description overrides
- Add GITLAB_SCHEMA_FORMAT config (flat|discriminated) for schema output format
- Create schema-utils.ts with transformation pipeline:
  1. Filter denied actions (remove oneOf branches)
  2. Apply description overrides (to oneOf or flat)
  3. Conditional flatten based on config
- Migrate manage_milestone to discriminated union schema (pilot)
- Add runtime validation for denied actions in handlers
- Add comprehensive unit tests for config parsing and schema transformations

Closes #32
Copilot AI review requested due to automatic review settings January 19, 2026 21:27
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 19, 2026

📊 Test Coverage Report

Overall Coverage: 86.44%

Coverage Details

Metric Percentage
Statements 86.44%
Branches 78.86%
Functions 72.17%
Lines 86.9%

Coverage Report: View detailed coverage report

This report was generated automatically from your PR changes.

…n schema

- Convert BrowseMilestonesSchema from flat z.object().refine() to z.discriminatedUnion()
- Define separate schemas for each action: list, get, issues, merge_requests, burndown
- Remove assertDefined calls - TypeScript narrowing handles type safety
- Update integration tests with type narrowing for action-specific properties
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 introduces a comprehensive schema transformation pipeline for CQRS tools, enabling fine-grained control over available actions and reducing AI context token usage. The implementation migrates manage_milestone to a discriminated union schema as a pilot, demonstrating benefits of TypeScript type narrowing and automatic parameter removal when actions are denied.

Changes:

  • New configuration options for filtering and customizing CQRS tools (GITLAB_DENIED_ACTIONS, GITLAB_ACTION_*, GITLAB_PARAM_*, GITLAB_SCHEMA_FORMAT)
  • Schema transformation pipeline in schema-utils.ts with filtering, flattening, and override capabilities
  • Migration of manage_milestone from flat schema to discriminated union with runtime validation

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/schema-utils.ts New utility implementing schema transformation pipeline (filter, flatten, apply overrides)
src/config.ts Added parsing for denied actions, action/param description overrides, and helper functions
src/entities/milestones/schema.ts Migrated manage_milestone from flat schema to discriminated union
src/entities/milestones/registry.ts Added runtime validation for denied actions in both milestone tools
src/registry-manager.ts Integrated schema transformation pipeline into tool registration
tests/unit/utils/schema-utils.test.ts Comprehensive unit tests for all transformation functions (469 lines)
tests/unit/config.test.ts Added tests for new config parsing functions (280+ new lines)
tests/unit/entities/milestones/registry.test.ts Added runtime validation tests for denied actions
tests/integration/schemas/milestones.test.ts Updated type narrowing checks for discriminated union
tests/unit/RegistryManager.test.ts Updated mocks for new config functions and entities
README.md Added comprehensive documentation for new features with examples

polaz added 7 commits January 19, 2026 23:33
…ated union schema

- Convert BrowseLabelsSchema from flat z.object().refine() to z.discriminatedUnion()
- Convert ManageLabelSchema from flat z.object().refine() to z.discriminatedUnion()
- Add runtime validation for denied actions in handlers
- Update integration tests with type narrowing for action-specific properties
- Convert BrowseVariablesSchema to z.discriminatedUnion with list/get actions
- Convert ManageVariableSchema to z.discriminatedUnion with create/update/delete actions
- Add runtime validation for denied actions via isActionDenied()
- Update unit tests with proper type narrowing for action-specific properties
- Update integration tests with type narrowing
- Convert BrowseWikiSchema to z.discriminatedUnion with list/get actions
- Convert ManageWikiSchema to z.discriminatedUnion with create/update/delete actions
- Add runtime validation for denied actions via isActionDenied()
- Remove assertDefined calls since types are now properly narrowed
- Update integration tests with proper type narrowing
- Convert BrowsePipelinesSchema to z.discriminatedUnion with 6 actions: list, get, jobs, triggers, job, logs
- Convert ManagePipelineSchema to z.discriminatedUnion with create/retry/cancel actions
- Convert ManagePipelineJobSchema to z.discriminatedUnion with play/retry/cancel actions
- Add runtime validation for denied actions via isActionDenied()
- Remove assertDefined calls since types are now properly narrowed
Migrate all entity schemas from z.object().refine() pattern to
z.discriminatedUnion() for type-safe action handling and better
AI client compatibility.

Changes:
- core: browse_commits, browse_events, browse_projects, browse_namespaces,
  manage_project schemas now use discriminatedUnion
- files: browse_files, manage_files schemas migrated
- mrs: browse_merge_requests, browse_mr_discussions, manage_merge_request,
  manage_mr_discussions schemas with action-specific field validation
- snippets: browse_snippets, manage_snippet schemas migrated
- webhooks: list_webhooks, manage_webhook schemas migrated
- workitems: list_work_items, manage_work_item schemas migrated
- integrations: manage_integration schema migrated

Schema improvements:
- Added .passthrough() to preserve unknown fields for validation
- Added superRefine validation for action-specific fields
- Updated tests for requiredId string coercion behavior
- Fixed type narrowing in test assertions

Closes #32
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 60 out of 60 changed files in this pull request and generated no new comments.

@polaz polaz merged commit 10069c9 into main Jan 19, 2026
26 checks passed
@polaz polaz deleted the feat/32-dynamic-action-filtering branch January 19, 2026 23:06
sw-release-bot bot pushed a commit that referenced this pull request Jan 19, 2026
## [6.9.0](v6.8.0...v6.9.0) (2026-01-19)

### Features

* **schema:** add dynamic action filtering with schema transformation pipeline ([#44](#44)) ([10069c9](10069c9)), closes [#32](#32) [#32](#32)
polaz added a commit that referenced this pull request Apr 3, 2026
Fixes Dependabot alerts:
- #47 hono Prototype Pollution via __proto__ (medium, fixed in 4.12.7)
- #44 @hono/node-server auth bypass (high, fixed in 1.19.10, already at 1.19.11)
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.

feat: Dynamic action filtering with multi-level description customization

2 participants