Skip to content

test: add consistency checks for processor tool target schemas - #1859

Merged
dyoshikawa merged 2 commits into
dyoshikawa:mainfrom
saitota:issue4
Jun 15, 2026
Merged

test: add consistency checks for processor tool target schemas#1859
dyoshikawa merged 2 commits into
dyoshikawa:mainfrom
saitota:issue4

Conversation

@saitota

@saitota saitota commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Background

The knowledge of which tools are supported by which processor feature is scattered across multiple places: each processor's hardcoded tool list (e.g. `rulesProcessorToolTargets` in `rules-processor.ts`), each processor's factory `Map`, and `ALL_TOOL_TARGETS` in `src/types/tool-targets.ts`. There was no runtime or test-time check that these lists stay in sync.

A concrete failure mode: adding a new tool to `ALL_TOOL_TARGETS` without updating a processor's schema list produces no type error and no test failure — the tool silently generates nothing for that feature.

Changes

  • Add a `"processor tool target consistency"` describe block to `src/types/tool-targets.test.ts` that verifies all 8 processor `*ProcessorToolTargetSchema.options` are subsets of `ALL_TOOL_TARGETS`
  • Export `toolRuleFactories` from `rules-processor.ts` and add a parity test that `RulesProcessorToolTargetSchema.options` and `toolRuleFactories` keys are equal sets — catching drift between the hardcoded enum array and the factory Map at runtime

No production behavior changes. Test-only addition (plus one `export` keyword on an existing constant).

Test plan

  • `pnpm test` — 9 new tests pass
  • `pnpm oxlint` — clean
  • `pnpm fmt` — applied
  • `pnpm typecheck` — clean (pre-existing errors in `scripts/` unrelated to this change)

saitota added 2 commits June 13, 2026 14:34
All 8 processor tool target schemas are now verified to be subsets of
ALL_TOOL_TARGETS at test time, catching silent mismatches when a new
tool is added to one list but not the other.
- Apply oxfmt formatting (filter callback collapsed to one line)
- Export toolRuleFactories to enable runtime map-vs-schema comparison
- Add test: RulesProcessorToolTargetSchema.options must equal
  toolRuleFactories keys, catching drift between the hardcoded enum
  array and the factory Map
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Unfortunately, you currently have 3 open PRs (including this one), which exceeds the limit of 2 for external contributors.

Please wait for an existing PR to be reviewed/merged, or close one before opening a new one. See CONTRIBUTING.md for details.

@dyoshikawa
dyoshikawa merged commit 9a7c904 into dyoshikawa:main Jun 15, 2026
5 checks passed
@dyoshikawa

Copy link
Copy Markdown
Owner

@saitota Thank you!

rudironsoni pushed a commit to rudironsoni/rulesync that referenced this pull request Jun 18, 2026
Follow-ups from PR dyoshikawa#1859.

- Export the seven remaining `tool*Factories` maps (commands, hooks, ignore,
  mcp, permissions, skills, subagents) so tests can assert their keys, matching
  the visibility already given to `toolRuleFactories`.
- Apply the strong bidirectional schema-vs-factory parity check (schema enum
  set-equals factory Map keys) to every processor, not just RulesProcessor, so
  drift in either direction is caught uniformly.
- Clarify in comments that the subset check intentionally guards only the
  "target declared by a processor must exist in ALL_TOOL_TARGETS" direction, and
  that the reverse is not asserted because not every tool supports every feature.
- Note that the hand-maintained `processors` list must be kept in sync as a known
  footgun until a central processor registry exists.

Closes dyoshikawa#1866
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.

2 participants