Skip to content

fix(benchmarks): scope target name uniqueness to cluster and add name filter - #219

Open
JLCode-tech wants to merge 2 commits into
stagingfrom
fix/benchmark-target-cluster-uniqueness
Open

JLCode-tech wants to merge 2 commits into
stagingfrom
fix/benchmark-target-cluster-uniqueness

Conversation

@JLCode-tech

Copy link
Copy Markdown
Collaborator

Description

Fixes benchmark target name collision when multiple clusters register endpoints with identical route names (e.g. via awsbnkctl discovering mcp-<namespace>-<route> on separate clusters).

Changes

  1. Database Migration (v2_156):
    • Replaces the global unique constraint on benchmark_targets.name with composite unique constraint uq_benchmark_targets_cluster_name on (cluster_id, name).
    • Adds lookup index ix_benchmark_targets_name on name for fast filtering.
  2. Backend ORM, Services & Schemas:
    • Updates BenchmarkTarget with composite UniqueConstraint and cluster_name property.
    • Updates BenchmarkTargetService duplicate validation to check (cluster_id, name).
    • Adds name exact-match query filter to list_targets.
    • Eager-loads cluster relationship via joinedload in list_targets and get_target to populate cluster_name without N+1 queries.
    • Exposes cluster_name: str | None on BenchmarkTargetResponse.
    • Updates GET /api/benchmarks/targets route to accept name: str | None = Query(None).
  3. MCP Server Benchmark Tools:
    • Implements list_benchmark_targets and create_benchmark_target MCP tools in bnk_forge_mcp.tools.benchmarks.
    • Registers tools in MCP server and catalog with full governance audit tests.
  4. Frontend UI (frontend-v2):
    • Updates BenchmarkTarget TypeScript type and listTargets API client.
    • In BenchmarkTargetsTab, adds a Cluster column in the targets table and displays the cluster badge in the detail header and Target details card.
    • In RunBenchmarkWizard and BenchmarkTrendsView, renders cluster name in target selection dropdowns so identically named targets across clusters are easily distinguishable.
  5. Testing:
    • Alembic migration tests for SQLite and PostgreSQL: test_v2_156_benchmark_target_name_unique_per_cluster.py.
    • Component tests verifying cross-cluster duplicate creation, same-cluster rejection, rename conflict logic, and filtering: test_benchmark_target_uniqueness.py.
    • Route integration tests in test_routes_benchmarks.py.
    • MCP tool unit and catalog audit tests: test_benchmarks.py, test_tool_catalog.py, test_url_audit.py, test_server.py.
    • Frontend unit tests for hooks and UI components: useBenchmarks.test.ts and BenchmarkTargetsTab.test.tsx.

… filter

- Scope benchmark target name uniqueness to (cluster_id, name) via migration v2_156
- Update BenchmarkTarget model with composite UniqueConstraint and cluster_name property
- Update BenchmarkTargetService and routes to filter by exact name and handle cluster-scoped conflicts
- Expose cluster_name in BenchmarkTargetResponse
- Add list_benchmark_targets and create_benchmark_target MCP tools to bnk_forge_mcp
- Update frontend-v2 BenchmarkTargetsTab, RunBenchmarkWizard, and BenchmarkTrendsView to display cluster badges and labels
- Add comprehensive migration, component, integration, MCP, and frontend unit test suites
Regenerate openapi spec and frontend typescript types following benchmark target schema updates.
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.

1 participant