Repository navigation
Expand file tree
/
Copy pathStorageContracts.cs
More file actions
299 lines (246 loc) · 8.78 KB
/
Copy pathStorageContracts.cs
File metadata and controls
299 lines (246 loc) · 8.78 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
using CodeMesh.Domain.Contracts;
using CodeMesh.Domain.Graph;
using CodeMesh.Domain.Health;
namespace CodeMesh.Storage;
public interface IGraphStore
{
Task UpsertGraphAsync(CodeGraphBatch batch, CancellationToken cancellationToken = default);
Task<CodeNode?> GetNodeAsync(string nodeId, CancellationToken cancellationToken = default);
Task<IReadOnlyList<CodeRelationship>> GetRelationshipsAsync(
string nodeId,
int depth = 1,
CancellationToken cancellationToken = default);
}
public interface IContentStore
{
Task UpsertContentAsync(CodeContent content, CancellationToken cancellationToken = default);
Task<CodeContent?> GetContentAsync(string contentHash, CancellationToken cancellationToken = default);
}
public interface IRefreshableContentStore : IContentStore
{
Task UpsertContentAsync(
CodeContent content,
RepositoryRef repository,
string ingestionRunId,
DateTimeOffset seenAt,
CancellationToken cancellationToken = default);
Task RemoveStaleContentAsync(
string repositoryId,
string ingestionRunId,
CancellationToken cancellationToken = default);
}
public sealed record StoredContentState(string ContentHash);
public interface IIncrementalContentStore : IContentStore
{
Task<IReadOnlyList<StoredContentState>> GetContentStatesAsync(
string repositoryId,
CancellationToken cancellationToken = default);
Task RemoveContentExceptAsync(
string repositoryId,
IReadOnlySet<string> currentContentHashes,
CancellationToken cancellationToken = default);
}
public interface IVectorStore
{
Task UpsertEmbeddingsAsync(
IReadOnlyList<EmbeddingRecord> embeddings,
CancellationToken cancellationToken = default);
Task<IReadOnlyList<VectorSearchMatch>> SearchAsync(
IReadOnlyList<float> vector,
int limit,
IReadOnlyDictionary<string, string>? filters = null,
CancellationToken cancellationToken = default);
}
public interface INodeSummaryStore
{
Task UpsertSummariesAsync(
IReadOnlyList<CodeNodeSummary> summaries,
CancellationToken cancellationToken = default);
}
public sealed record StoredNodeSummaryState(
string SummaryId,
string NodeId,
string ContentHash,
string SummaryKind,
string Provider,
string Model,
string PromptVersion,
string GenerationConfigurationFingerprint,
string Status);
public interface IIncrementalNodeSummaryStore : INodeSummaryStore
{
Task<IReadOnlyList<StoredNodeSummaryState>> GetSummaryStatesAsync(
string repositoryId,
CancellationToken cancellationToken = default);
Task RemoveSummariesExceptAsync(
string repositoryId,
IReadOnlySet<string> currentSummaryIds,
CancellationToken cancellationToken = default);
}
public sealed record NodeSummaryFailure(
string SummaryId,
string NodeId,
string Kind,
string Name,
string Provider,
string Model,
string PromptVersion,
string Error,
DateTimeOffset GeneratedAt);
public sealed record NodeSummaryProviderModelCount(
string Provider,
string Model,
string PromptVersion,
int Count);
public sealed record NodeSummaryCoverage(
string RepositoryId,
int TotalCount,
int CompletedCount,
int FailedCount,
IReadOnlyDictionary<string, int> StatusCounts,
IReadOnlyDictionary<string, int> KindCounts,
IReadOnlyDictionary<string, int> ProviderModelCounts,
IReadOnlyList<NodeSummaryProviderModelCount> ProviderModelCountDetails,
IReadOnlyList<NodeSummaryFailure> RecentFailures);
public interface INodeSummaryCoverageStore
{
Task<NodeSummaryCoverage> GetSummaryCoverageAsync(
string repositoryId,
CancellationToken cancellationToken = default);
}
public interface IRefreshableGraphStore : IGraphStore
{
Task RemoveStaleGraphAsync(
string repositoryId,
string ingestionRunId,
CancellationToken cancellationToken = default);
}
public sealed record StoredNodeState(
string NodeId,
string ContentHash,
string Fingerprint);
public sealed record StoredRelationshipState(
string RelationshipId,
string Fingerprint);
public interface IIncrementalGraphStore : IGraphStore
{
Task<IReadOnlyList<StoredNodeState>> GetNodeStatesAsync(
string repositoryId,
CancellationToken cancellationToken = default);
Task<IReadOnlyList<StoredRelationshipState>> GetRelationshipStatesAsync(
string repositoryId,
CancellationToken cancellationToken = default);
Task RemoveGraphExceptAsync(
string repositoryId,
IReadOnlySet<string> currentNodeIds,
IReadOnlySet<string> currentRelationshipIds,
CancellationToken cancellationToken = default);
}
public interface IRefreshableVectorStore : IVectorStore
{
Task RemoveStaleEmbeddingsAsync(
string repositoryId,
string ingestionRunId,
CancellationToken cancellationToken = default);
}
public sealed record StoredEmbeddingState(
string EmbeddingId,
string NodeId,
string ContentHash,
string Provider,
string Model);
public interface IIncrementalVectorStore : IVectorStore
{
Task<IReadOnlyList<StoredEmbeddingState>> GetEmbeddingStatesAsync(
string repositoryId,
CancellationToken cancellationToken = default);
Task RemoveEmbeddingsExceptAsync(
string repositoryId,
IReadOnlySet<string> currentEmbeddingIds,
CancellationToken cancellationToken = default);
}
public interface IRegistryStore
{
Task UpsertRepositoryAsync(
RepositoryIndexRecord repository,
CancellationToken cancellationToken = default);
Task UpsertRunAsync(
IngestionRunIndexRecord run,
CancellationToken cancellationToken = default);
Task<IReadOnlyList<RepositoryIndexRecord>> ListRepositoriesAsync(
int limit = 50,
CancellationToken cancellationToken = default);
Task<RepositoryIndexRecord?> GetRepositoryAsync(
string repositoryId,
CancellationToken cancellationToken = default);
Task<IReadOnlyList<IngestionRunIndexRecord>> ListRunsAsync(
string? repositoryId = null,
int limit = 50,
CancellationToken cancellationToken = default);
Task DeleteRepositoryAsync(
string repositoryId,
CancellationToken cancellationToken = default);
}
public interface ISnapshotRegistryStore : IRegistryStore
{
Task<CheckoutIdentityRecord?> GetCheckoutAsync(
string checkoutId,
CancellationToken cancellationToken = default);
Task UpsertCheckoutAsync(
CheckoutIdentityRecord checkout,
CancellationToken cancellationToken = default);
Task<SnapshotIndexRecord?> GetSnapshotAsync(
string snapshotId,
CancellationToken cancellationToken = default);
Task<IReadOnlyList<SnapshotIndexRecord>> ListSnapshotsAsync(
string projectId,
CancellationToken cancellationToken = default);
Task<IReadOnlyList<SnapshotSlotRecord>> ListSlotsAsync(
string projectId,
CancellationToken cancellationToken = default);
Task StageGenerationAsync(
IngestionGenerationRecord generation,
SnapshotIndexRecord snapshot,
CancellationToken cancellationToken = default);
Task<SnapshotPublicationResult> PublishSnapshotAsync(
SnapshotPublication publication,
CancellationToken cancellationToken = default);
Task MarkGenerationFailedAsync(
string generationId,
string error,
CancellationToken cancellationToken = default);
Task<IReadOnlyList<SnapshotIndexRecord>> ListCollectibleSnapshotsAsync(
DateTimeOffset now,
CancellationToken cancellationToken = default);
Task DeleteSnapshotRecordAsync(
string snapshotId,
CancellationToken cancellationToken = default);
Task<SnapshotSlotRecord?> ResolveSlotAsync(
string projectId,
SnapshotSlotKind kind,
string key,
CancellationToken cancellationToken = default);
Task MigrateLegacyRepositoryAsync(
string legacyRepositoryId,
string projectId,
CancellationToken cancellationToken = default);
Task<SnapshotSlotMutationResult> UpsertRetainedSlotAsync(
string projectId,
SnapshotSlotKind kind,
string key,
string snapshotId,
long? expectedVersion,
CancellationToken cancellationToken = default);
Task<SnapshotSlotMutationResult> DeleteSlotAsync(
string projectId,
SnapshotSlotKind kind,
string key,
long? expectedVersion,
TimeSpan unreferencedGracePeriod,
CancellationToken cancellationToken = default);
}
public interface IStoreHealthCheck
{
string Name { get; }
Task<ComponentHealth> CheckAsync(CancellationToken cancellationToken = default);
}