-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControlPlaneDomainContractsTests.cs
More file actions
232 lines (198 loc) · 7.94 KB
/
ControlPlaneDomainContractsTests.cs
File metadata and controls
232 lines (198 loc) · 7.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
using System.Text.Json;
namespace DotPilot.Tests;
public class ControlPlaneDomainContractsTests
{
private static readonly DateTimeOffset CreatedAt = new(2026, 3, 13, 10, 15, 30, TimeSpan.Zero);
private static readonly DateTimeOffset UpdatedAt = new(2026, 3, 13, 10, 45, 30, TimeSpan.Zero);
private static readonly JsonSerializerOptions SerializerOptions = new(JsonSerializerDefaults.Web);
[Test]
public void ControlPlaneIdentifiersProduceStableNonEmptyRepresentations()
{
IReadOnlyList<string> values =
[
WorkspaceId.New().ToString(),
AgentProfileId.New().ToString(),
SessionId.New().ToString(),
FleetId.New().ToString(),
ProviderId.New().ToString(),
ModelRuntimeId.New().ToString(),
ToolCapabilityId.New().ToString(),
ApprovalId.New().ToString(),
ArtifactId.New().ToString(),
TelemetryRecordId.New().ToString(),
EvaluationId.New().ToString(),
];
values.Should().OnlyContain(value => !string.IsNullOrWhiteSpace(value));
values.Should().OnlyHaveUniqueItems();
}
[Test]
public void ControlPlaneContractsRoundTripThroughSystemTextJson()
{
var envelope = CreateEnvelope();
var payload = JsonSerializer.Serialize(envelope, SerializerOptions);
var roundTrip = JsonSerializer.Deserialize<ControlPlaneDomainEnvelope>(payload, SerializerOptions);
roundTrip.Should().NotBeNull();
roundTrip!.Should().BeEquivalentTo(envelope);
}
[Test]
public void ControlPlaneContractsModelMixedProviderAndLocalRuntimeSessions()
{
var envelope = CreateEnvelope();
envelope.Session.AgentProfileIds.Should().ContainInOrder(
envelope.CodingAgent.Id,
envelope.ReviewerAgent.Id);
envelope.CodingAgent.ProviderId.Should().Be(envelope.Provider.Id);
envelope.ReviewerAgent.ModelRuntimeId.Should().Be(envelope.LocalRuntime.Id);
envelope.Fleet.ExecutionMode.Should().Be(FleetExecutionMode.Orchestrated);
envelope.Approval.Scope.Should().Be(ApprovalScope.CommandExecution);
envelope.Artifact.Kind.Should().Be(ArtifactKind.Snapshot);
envelope.Telemetry.Kind.Should().Be(TelemetrySignalKind.Trace);
envelope.Evaluation.Metric.Should().Be(EvaluationMetricKind.ToolCallAccuracy);
}
private static ControlPlaneDomainEnvelope CreateEnvelope()
{
var tool = new ToolCapabilityDescriptor
{
Id = ToolCapabilityId.New(),
Name = "workspace-edit",
DisplayName = "Workspace Edit",
Kind = ToolCapabilityKind.FileSystem,
RequiresApproval = true,
IsEnabledByDefault = true,
Tags = ["write", "filesystem"],
};
var provider = new ProviderDescriptor
{
Id = ProviderId.New(),
DisplayName = "Codex",
CommandName = "codex",
Status = ProviderConnectionStatus.Available,
StatusSummary = "codex is available on PATH.",
RequiresExternalToolchain = true,
SupportedToolIds = [tool.Id],
};
var localRuntime = new ModelRuntimeDescriptor
{
Id = ModelRuntimeId.New(),
DisplayName = "Local ONNX Runtime",
EngineName = "ONNX Runtime",
RuntimeKind = RuntimeKind.LocalModel,
Status = ProviderConnectionStatus.Available,
SupportedModelFamilies = ["phi", "qwen"],
};
var workspace = new WorkspaceDescriptor
{
Id = WorkspaceId.New(),
Name = "dotPilot",
RootPath = "/repo/dotPilot",
BranchName = "codex/epic-11-foundation-contracts",
};
var codingAgent = new AgentProfileDescriptor
{
Id = AgentProfileId.New(),
Name = "Implementation Agent",
Role = AgentRoleKind.Coding,
ProviderId = provider.Id,
ToolCapabilityIds = [tool.Id],
Tags = ["implementation", "provider"],
};
var reviewerAgent = new AgentProfileDescriptor
{
Id = AgentProfileId.New(),
Name = "Runtime Reviewer",
Role = AgentRoleKind.Reviewer,
ModelRuntimeId = localRuntime.Id,
ToolCapabilityIds = [tool.Id],
Tags = ["review", "local"],
};
var fleet = new FleetDescriptor
{
Id = FleetId.New(),
Name = "Mixed Provider Fleet",
ExecutionMode = FleetExecutionMode.Orchestrated,
AgentProfileIds = [codingAgent.Id, reviewerAgent.Id],
};
var session = new SessionDescriptor
{
Id = SessionId.New(),
WorkspaceId = workspace.Id,
Title = "Issue 22 domain slice rollout",
Phase = SessionPhase.Execute,
ApprovalState = ApprovalState.Pending,
FleetId = fleet.Id,
AgentProfileIds = [codingAgent.Id, reviewerAgent.Id],
CreatedAt = CreatedAt,
UpdatedAt = UpdatedAt,
};
var approval = new SessionApprovalRecord
{
Id = ApprovalId.New(),
SessionId = session.Id,
Scope = ApprovalScope.CommandExecution,
State = ApprovalState.Pending,
RequestedAction = "Run full solution tests",
RequestedBy = codingAgent.Name,
RequestedAt = UpdatedAt,
};
var artifact = new ArtifactDescriptor
{
Id = ArtifactId.New(),
SessionId = session.Id,
AgentProfileId = codingAgent.Id,
Name = "runtime-foundation.snapshot.json",
Kind = ArtifactKind.Snapshot,
RelativePath = "artifacts/runtime-foundation.snapshot.json",
CreatedAt = UpdatedAt,
};
var telemetry = new TelemetryRecord
{
Id = TelemetryRecordId.New(),
SessionId = session.Id,
Kind = TelemetrySignalKind.Trace,
Name = "RuntimeFoundation.Execute",
Summary = "Deterministic provider-independent trace",
RecordedAt = UpdatedAt,
};
var evaluation = new EvaluationRecord
{
Id = EvaluationId.New(),
SessionId = session.Id,
ArtifactId = artifact.Id,
Metric = EvaluationMetricKind.ToolCallAccuracy,
Score = 0.98m,
Outcome = EvaluationOutcome.Passed,
Summary = "Tool calls matched the expected deterministic sequence.",
EvaluatedAt = UpdatedAt,
};
return new ControlPlaneDomainEnvelope
{
Workspace = workspace,
Tool = tool,
Provider = provider,
LocalRuntime = localRuntime,
CodingAgent = codingAgent,
ReviewerAgent = reviewerAgent,
Fleet = fleet,
Session = session,
Approval = approval,
Artifact = artifact,
Telemetry = telemetry,
Evaluation = evaluation,
};
}
private sealed record ControlPlaneDomainEnvelope
{
public WorkspaceDescriptor Workspace { get; init; } = new();
public ToolCapabilityDescriptor Tool { get; init; } = new();
public ProviderDescriptor Provider { get; init; } = new();
public ModelRuntimeDescriptor LocalRuntime { get; init; } = new();
public AgentProfileDescriptor CodingAgent { get; init; } = new();
public AgentProfileDescriptor ReviewerAgent { get; init; } = new();
public FleetDescriptor Fleet { get; init; } = new();
public SessionDescriptor Session { get; init; } = new();
public SessionApprovalRecord Approval { get; init; } = new();
public ArtifactDescriptor Artifact { get; init; } = new();
public TelemetryRecord Telemetry { get; init; } = new();
public EvaluationRecord Evaluation { get; init; } = new();
}
}