Skip to content

[MCP T3] Test fixture project + assertion contract #650

@DvirDukhan

Description

@DvirDukhan

Phase 1 ticket T3. Depends on #649 (T2 CI workflow).

Context

Every per-tool ticket from T4 onward runs an integration test against the same fixture project. Without a shared fixture and assertion contract, each tool ticket has to invent its own — creating drift, duplicate work, and weak coverage. This ticket builds the fixture once so subsequent tickets can lean on it.

Scope

In:

  • New tests/mcp/fixtures/sample_project/ directory containing:
    • A Python module with a known call graph: entrypoint() → service() → repo() → db(), plus a small class hierarchy (e.g. BaseRepoUserRepo, OrderRepo).
    • At least one Java file and one C# file with a known call graph (so the multilspy second-pass code paths are exercised).
    • A handful of imports between files so IMPORTS edges exist.
  • New tests/mcp/fixtures/expected.yaml declaring the assertion contract:
    • Expected node counts per label (File, Class, Function).
    • Expected callers/callees for named symbols (e.g. service is called by entrypoint and calls repo).
    • Expected paths between named symbols (e.g. entrypoint → ... → db).
    • Expected prefix-search hits for sample prefixes.
  • New tests/mcp/conftest.py with:
    • A session-scoped pytest fixture that boots a clean FalkorDB graph (using a unique graph name per test session to avoid stomping on real data).
    • Indexes the sample project once via Project.from_local_directory() + Project.analyze_sources() (api/project.py:79-94).
    • Yields a handle that subsequent tests use to query the indexed graph.
  • A trivial sanity test in tests/mcp/test_fixture.py that loads expected.yaml, indexes the fixture, and asserts the actual node/edge counts match the contract — catches drift if anyone edits the fixture without updating the contract.

Out:

  • Any tool implementation (T4–T8, T11).
  • Per-tool tests (those land with their tools).
  • Per-branch graph naming (T17 — fixture will be migrated when T17 lands).

Files to create / modify

  • new tests/mcp/fixtures/sample_project/python/entrypoint.py
  • new tests/mcp/fixtures/sample_project/python/service.py
  • new tests/mcp/fixtures/sample_project/python/repo.py
  • new tests/mcp/fixtures/sample_project/python/db.py
  • new tests/mcp/fixtures/sample_project/java/Main.java (small known call graph)
  • new tests/mcp/fixtures/sample_project/csharp/Main.cs (small known call graph)
  • new tests/mcp/fixtures/expected.yaml
  • new tests/mcp/conftest.py
  • new tests/mcp/test_fixture.py

Acceptance criteria

  • Fixture indexes successfully via Project.from_local_directory() / analyze_sources() against the FalkorDB CI service.
  • expected.yaml is loaded and validated by a small Python helper (e.g. pydantic or dataclasses + yaml).
  • test_fixture.py asserts:
    • Total node count matches contract
    • Total edge count matches contract
    • At least one named caller/callee assertion passes
    • At least one named path assertion passes
    • At least one prefix-search assertion passes
  • Test runs green in the CI workflow from [MCP T2] CI workflow with FalkorDB service for MCP tests #649.
  • The session-scoped fixture cleans up its graph on teardown (no orphan graphs left in FalkorDB).

Dependencies

Out of scope (do NOT do in this PR)

  • Tool implementations.
  • Per-language additions beyond Python/Java/C# (T16 will add fixtures for the new tree-sitter languages).
  • Per-branch graph naming (T17).

Notes for the implementer

  • The fixture should be small but not trivial — 4-5 functions per language is enough to assert call/callers/paths/search/impact-analysis without bloating CI runtime.
  • Use a unique graph name like code:test_fixture:_default (the _default branch suffix anticipates T17 — it will line up with the per-branch convention).
  • Document the fixture's call graph in a tests/mcp/fixtures/sample_project/README.md so future contributors don't have to reverse-engineer it.
  • Reference: see how tests/endpoints/ boots and tears down test data for an existing pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmcpMCP server (model context protocol) work

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions