Research conducted on modern AI coding assistants (Cursor, GitHub Copilot, Cline,
Aider, Windsurf, Replit Agent) to understand architecture patterns, context management,
code editing workflows, and tool use protocols.
Key Decision: Pivoted from building full CLI (40-50h) to validation-driven MCP-first
approach (10-15h). Build 5 core CODEX MCP tools that work with ANY coding assistant,
validate adoption over 2-4 weeks, then decide on full CLI if demand proven.
Files:
- research/ai-systems/modern-coding-assistants-architecture.md (comprehensive research)
- research/ai-systems/codex-coding-assistant-implementation-plan.md (original CLI plan, preserved)
- research/ai-systems/codex-mcp-tools-implementation-plan.md (approved MCP-first plan)
- ideas/registry.json (updated with approved MCP tools proposal)
Architech Validation: APPROVED with pivot to MCP-first approach
Human Decision: Approved (pragmatic validation-driven development)
Next: Begin Phase 1 implementation (10-15 hours, 5 core MCP tools)
🤖 Generated with CODEX Research System
Co-Authored-By: The Archivist <archivist@codex.svrnty.io>
Co-Authored-By: The Architech <architech@codex.svrnty.io>
Co-Authored-By: Mathias Beaulieu-Duncan <mat@svrnty.io>
124 lines
4.1 KiB
C#
124 lines
4.1 KiB
C#
using Xunit;
|
|
using Moq;
|
|
using OpenHarbor.MCP.Gateway.Core.Interfaces;
|
|
using OpenHarbor.MCP.Gateway.Core.Models;
|
|
|
|
namespace OpenHarbor.MCP.Gateway.Core.Tests.Interfaces;
|
|
|
|
/// <summary>
|
|
/// Unit tests for IRoutingStrategy interface following TDD approach.
|
|
/// Tests server selection logic.
|
|
/// </summary>
|
|
public class IRoutingStrategyTests
|
|
{
|
|
[Fact]
|
|
public async Task SelectServerAsync_WithHealthyServers_ReturnsServer()
|
|
{
|
|
// Arrange
|
|
var mockStrategy = new Mock<IRoutingStrategy>();
|
|
var servers = new List<ServerInfo>
|
|
{
|
|
new ServerInfo { Id = "server-1", IsHealthy = true },
|
|
new ServerInfo { Id = "server-2", IsHealthy = true }
|
|
};
|
|
var context = new RoutingContext { ToolName = "test_tool" };
|
|
|
|
mockStrategy
|
|
.Setup(s => s.SelectServerAsync(
|
|
It.IsAny<IEnumerable<ServerInfo>>(),
|
|
It.IsAny<RoutingContext>(),
|
|
It.IsAny<CancellationToken>()))
|
|
.ReturnsAsync(servers[0]);
|
|
|
|
// Act
|
|
var selected = await mockStrategy.Object.SelectServerAsync(servers, context, CancellationToken.None);
|
|
|
|
// Assert
|
|
Assert.NotNull(selected);
|
|
Assert.Equal("server-1", selected.Id);
|
|
mockStrategy.Verify(s => s.SelectServerAsync(servers, context, It.IsAny<CancellationToken>()), Times.Once);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task SelectServerAsync_WithNoHealthyServers_ReturnsNull()
|
|
{
|
|
// Arrange
|
|
var mockStrategy = new Mock<IRoutingStrategy>();
|
|
var servers = new List<ServerInfo>
|
|
{
|
|
new ServerInfo { Id = "server-1", IsHealthy = false },
|
|
new ServerInfo { Id = "server-2", IsHealthy = false }
|
|
};
|
|
var context = new RoutingContext { ToolName = "test_tool" };
|
|
|
|
mockStrategy
|
|
.Setup(s => s.SelectServerAsync(
|
|
It.IsAny<IEnumerable<ServerInfo>>(),
|
|
It.IsAny<RoutingContext>(),
|
|
It.IsAny<CancellationToken>()))
|
|
.ReturnsAsync((ServerInfo?)null);
|
|
|
|
// Act
|
|
var selected = await mockStrategy.Object.SelectServerAsync(servers, context, CancellationToken.None);
|
|
|
|
// Assert
|
|
Assert.Null(selected);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task SelectServerAsync_WithRoutingContext_UsesContext()
|
|
{
|
|
// Arrange
|
|
var mockStrategy = new Mock<IRoutingStrategy>();
|
|
var servers = new List<ServerInfo>
|
|
{
|
|
new ServerInfo { Id = "server-1", IsHealthy = true }
|
|
};
|
|
var context = new RoutingContext
|
|
{
|
|
ToolName = "specific_tool",
|
|
ClientId = "client-123",
|
|
Metadata = new Dictionary<string, object> { { "region", "us-east" } }
|
|
};
|
|
|
|
mockStrategy
|
|
.Setup(s => s.SelectServerAsync(
|
|
It.IsAny<IEnumerable<ServerInfo>>(),
|
|
It.Is<RoutingContext>(c => c.ToolName == "specific_tool"),
|
|
It.IsAny<CancellationToken>()))
|
|
.ReturnsAsync(servers[0]);
|
|
|
|
// Act
|
|
var selected = await mockStrategy.Object.SelectServerAsync(servers, context, CancellationToken.None);
|
|
|
|
// Assert
|
|
Assert.NotNull(selected);
|
|
mockStrategy.Verify(s => s.SelectServerAsync(
|
|
It.IsAny<IEnumerable<ServerInfo>>(),
|
|
It.Is<RoutingContext>(c => c.ToolName == "specific_tool"),
|
|
It.IsAny<CancellationToken>()), Times.Once);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task SelectServerAsync_WithEmptyServerList_ReturnsNull()
|
|
{
|
|
// Arrange
|
|
var mockStrategy = new Mock<IRoutingStrategy>();
|
|
var servers = new List<ServerInfo>();
|
|
var context = new RoutingContext { ToolName = "test_tool" };
|
|
|
|
mockStrategy
|
|
.Setup(s => s.SelectServerAsync(
|
|
It.IsAny<IEnumerable<ServerInfo>>(),
|
|
It.IsAny<RoutingContext>(),
|
|
It.IsAny<CancellationToken>()))
|
|
.ReturnsAsync((ServerInfo?)null);
|
|
|
|
// Act
|
|
var selected = await mockStrategy.Object.SelectServerAsync(servers, context, CancellationToken.None);
|
|
|
|
// Assert
|
|
Assert.Null(selected);
|
|
}
|
|
}
|