Skip to content

test: cross-workspace contract tests + root orchestrator (Phase 3) #1500

@JeremyDev87

Description

@JeremyDev87

Parent

E2E test infrastructure initiative.

Problem

The three workspaces (MCP server, Plugin, Rules) have inter-dependencies that are only validated by convention:

  • Plugin → MCP: Plugin calls `activate`, `search_rules`, `parse_mode` — but no test verifies the MCP server actually returns what the plugin expects.
  • Rules → MCP: Agent JSON files in `packages/rules/.ai-rules/agents/` must match the schema the MCP server uses to parse them — currently only ajv validates the schema, not the runtime behavior.
  • Root orchestration: There is no single command to run all E2E tests across workspaces.

A breaking change in the MCP server's tool response format would silently break the plugin with no test catching it.

Scope

Contract tests (~5-8 tests)

MCP ↔ Plugin contract

  • `activate` tool returns `{mode, rules, primaryAgent, specialists}` structure
  • `search_rules` returns `{results: [{name, content, relevance}]}` structure
  • `get_agent_details` returns agent with required fields (name, description, expertise)
  • Tool names match what plugin code references (no typos in tool name strings)

Rules ↔ MCP contract

  • Every agent JSON in `packages/rules/.ai-rules/agents/*.json` loads successfully via MCP server's RulesService
  • Rule markdown files referenced by `activate` actually exist on disk
  • Agent count matches between filesystem and MCP `resources/list`

Root orchestrator

  • Add `test:e2e` to root `package.json` that runs:
    1. `yarn workspace codingbuddy test:e2e` (MCP E2E — Phase 1)
    2. `python3 -m pytest tests/e2e/plugin-hooks/ -v` (Plugin E2E — existing)
    3. `yarn workspace landing-page test:e2e` (Landing E2E — Phase 2)
    4. Contract tests (this phase)

Technical approach

  • Location: `tests/e2e/contracts/` at repo root (cross-workspace)
  • Framework: Vitest (can import from both MCP server and rules package)
  • MCP interaction: Spawn MCP server in stdio mode, send JSON-RPC calls
  • CI: Add `e2e-contracts` job to `dev.yml`, depends on `build`

Test commands

# Individual
yarn test:e2e:contracts     # Contract tests only

# Root orchestrator
yarn test:e2e               # ALL e2e across workspaces

Acceptance criteria

  • `tests/e2e/contracts/` with ≥5 contract tests
  • MCP ↔ Plugin response shape validated
  • Rules ↔ MCP agent count parity validated
  • Root `test:e2e` script orchestrates all workspace E2E
  • CI job for contract tests
  • Contract tests fail fast on response shape mismatch

Dependencies

  • Phase 1 (MCP E2E) — reuses the stdio spawn infrastructure
  • Phase 2 (Landing E2E) — needed for root orchestrator completeness

Out of scope

  • Plugin Python ↔ MCP server live integration (requires running both)
  • CDC (Consumer-Driven Contracts) tooling like Pact — overkill for current scale

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions