@mcoda/mswarm 0.1.90 → 0.1.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/codali-executor.d.ts +107 -6
  2. package/dist/codali-executor.d.ts.map +1 -1
  3. package/dist/codali-executor.js +500 -26
  4. package/dist/codali-executor.js.map +1 -1
  5. package/dist/runtime.d.ts +4 -2
  6. package/dist/runtime.d.ts.map +1 -1
  7. package/dist/runtime.js +18 -5
  8. package/dist/runtime.js.map +1 -1
  9. package/dist/vendor/codali/cli/DatasetCommand.d.ts +38 -0
  10. package/dist/vendor/codali/cli/DatasetCommand.d.ts.map +1 -0
  11. package/dist/vendor/codali/cli/DatasetCommand.js +959 -0
  12. package/dist/vendor/codali/cli/EvalCommand.d.ts +3 -0
  13. package/dist/vendor/codali/cli/EvalCommand.d.ts.map +1 -1
  14. package/dist/vendor/codali/cli/EvalCommand.js +55 -1
  15. package/dist/vendor/codali/cli/ImprovementCommand.d.ts +97 -0
  16. package/dist/vendor/codali/cli/ImprovementCommand.d.ts.map +1 -0
  17. package/dist/vendor/codali/cli/ImprovementCommand.js +1879 -0
  18. package/dist/vendor/codali/cli.d.ts.map +1 -1
  19. package/dist/vendor/codali/cli.js +15 -0
  20. package/dist/vendor/codali/dataset-cli.d.ts +3 -0
  21. package/dist/vendor/codali/dataset-cli.d.ts.map +1 -0
  22. package/dist/vendor/codali/dataset-cli.js +30 -0
  23. package/dist/vendor/codali/eval/CodaliGatewayLiveHarness.d.ts +90 -1
  24. package/dist/vendor/codali/eval/CodaliGatewayLiveHarness.d.ts.map +1 -1
  25. package/dist/vendor/codali/eval/CodaliGatewayLiveHarness.js +443 -9
  26. package/dist/vendor/codali/eval/GatewayDatasetEval.d.ts +70 -0
  27. package/dist/vendor/codali/eval/GatewayDatasetEval.d.ts.map +1 -0
  28. package/dist/vendor/codali/eval/GatewayDatasetEval.js +477 -0
  29. package/dist/vendor/codali/eval/GatewayEvalSuite.d.ts +52 -0
  30. package/dist/vendor/codali/eval/GatewayEvalSuite.d.ts.map +1 -1
  31. package/dist/vendor/codali/eval/GatewayEvalSuite.js +135 -1
  32. package/dist/vendor/codali/gateway/CodaliGateway.d.ts +4 -0
  33. package/dist/vendor/codali/gateway/CodaliGateway.d.ts.map +1 -1
  34. package/dist/vendor/codali/gateway/CodaliGateway.js +37 -1
  35. package/dist/vendor/codali/gateway/CodaliGatewaySchemas.d.ts.map +1 -1
  36. package/dist/vendor/codali/gateway/CodaliGatewaySchemas.js +0 -4
  37. package/dist/vendor/codali/gateway/CodaliGatewayStore.d.ts.map +1 -1
  38. package/dist/vendor/codali/gateway/CodaliGatewayStore.js +1 -0
  39. package/dist/vendor/codali/gateway/GatewayPlanner.d.ts.map +1 -1
  40. package/dist/vendor/codali/gateway/GatewayPlanner.js +355 -41
  41. package/dist/vendor/codali/gateway/GatewayStateMachine.d.ts +1 -0
  42. package/dist/vendor/codali/gateway/GatewayStateMachine.d.ts.map +1 -1
  43. package/dist/vendor/codali/gateway/GatewayStateMachine.js +221 -5
  44. package/dist/vendor/codali/improvement/CandidateReleaseBuilder.d.ts +201 -0
  45. package/dist/vendor/codali/improvement/CandidateReleaseBuilder.d.ts.map +1 -0
  46. package/dist/vendor/codali/improvement/CandidateReleaseBuilder.js +1175 -0
  47. package/dist/vendor/codali/improvement/DatasetEligibilityGate.d.ts +75 -0
  48. package/dist/vendor/codali/improvement/DatasetEligibilityGate.d.ts.map +1 -0
  49. package/dist/vendor/codali/improvement/DatasetEligibilityGate.js +497 -0
  50. package/dist/vendor/codali/improvement/DatasetExportManifestReader.d.ts +88 -0
  51. package/dist/vendor/codali/improvement/DatasetExportManifestReader.d.ts.map +1 -0
  52. package/dist/vendor/codali/improvement/DatasetExportManifestReader.js +333 -0
  53. package/dist/vendor/codali/improvement/DocdexRetrievalCandidateBuilder.d.ts +192 -0
  54. package/dist/vendor/codali/improvement/DocdexRetrievalCandidateBuilder.d.ts.map +1 -0
  55. package/dist/vendor/codali/improvement/DocdexRetrievalCandidateBuilder.js +625 -0
  56. package/dist/vendor/codali/improvement/EvalReplayCandidateBuilder.d.ts +173 -0
  57. package/dist/vendor/codali/improvement/EvalReplayCandidateBuilder.d.ts.map +1 -0
  58. package/dist/vendor/codali/improvement/EvalReplayCandidateBuilder.js +363 -0
  59. package/dist/vendor/codali/improvement/FineTuneJobPlanner.d.ts +281 -0
  60. package/dist/vendor/codali/improvement/FineTuneJobPlanner.d.ts.map +1 -0
  61. package/dist/vendor/codali/improvement/FineTuneJobPlanner.js +823 -0
  62. package/dist/vendor/codali/improvement/ImprovementEvalRunner.d.ts +50 -0
  63. package/dist/vendor/codali/improvement/ImprovementEvalRunner.d.ts.map +1 -0
  64. package/dist/vendor/codali/improvement/ImprovementEvalRunner.js +648 -0
  65. package/dist/vendor/codali/improvement/ImprovementPolicy.d.ts +272 -0
  66. package/dist/vendor/codali/improvement/ImprovementPolicy.d.ts.map +1 -0
  67. package/dist/vendor/codali/improvement/ImprovementPolicy.js +1450 -0
  68. package/dist/vendor/codali/improvement/ModelRouterCandidateBuilder.d.ts +186 -0
  69. package/dist/vendor/codali/improvement/ModelRouterCandidateBuilder.d.ts.map +1 -0
  70. package/dist/vendor/codali/improvement/ModelRouterCandidateBuilder.js +880 -0
  71. package/dist/vendor/codali/improvement/OperatorInspector.d.ts +182 -0
  72. package/dist/vendor/codali/improvement/OperatorInspector.d.ts.map +1 -0
  73. package/dist/vendor/codali/improvement/OperatorInspector.js +604 -0
  74. package/dist/vendor/codali/improvement/ProductionGovernance.d.ts +91 -0
  75. package/dist/vendor/codali/improvement/ProductionGovernance.d.ts.map +1 -0
  76. package/dist/vendor/codali/improvement/ProductionGovernance.js +329 -0
  77. package/dist/vendor/codali/improvement/PromptSchemaToolMetadataCandidateBuilder.d.ts +152 -0
  78. package/dist/vendor/codali/improvement/PromptSchemaToolMetadataCandidateBuilder.d.ts.map +1 -0
  79. package/dist/vendor/codali/improvement/PromptSchemaToolMetadataCandidateBuilder.js +480 -0
  80. package/dist/vendor/codali/improvement/PublishOrchestrator.d.ts +113 -0
  81. package/dist/vendor/codali/improvement/PublishOrchestrator.d.ts.map +1 -0
  82. package/dist/vendor/codali/improvement/PublishOrchestrator.js +590 -0
  83. package/dist/vendor/codali/improvement/ReleaseOutcomeReporter.d.ts +133 -0
  84. package/dist/vendor/codali/improvement/ReleaseOutcomeReporter.d.ts.map +1 -0
  85. package/dist/vendor/codali/improvement/ReleaseOutcomeReporter.js +501 -0
  86. package/dist/vendor/codali/improvement/StorageServiceImprovementClient.d.ts +71 -0
  87. package/dist/vendor/codali/improvement/StorageServiceImprovementClient.d.ts.map +1 -0
  88. package/dist/vendor/codali/improvement/StorageServiceImprovementClient.js +245 -0
  89. package/dist/vendor/codali/index.d.ts +43 -0
  90. package/dist/vendor/codali/index.d.ts.map +1 -1
  91. package/dist/vendor/codali/index.js +21 -0
  92. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +0 -2
  93. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -1
  94. package/dist/vendor/codali/runtime/CodaliRuntime.js +0 -5
  95. package/dist/vendor/codali/storage/CodaliDatasetPrivacyEngine.d.ts +138 -0
  96. package/dist/vendor/codali/storage/CodaliDatasetPrivacyEngine.d.ts.map +1 -0
  97. package/dist/vendor/codali/storage/CodaliDatasetPrivacyEngine.js +417 -0
  98. package/dist/vendor/codali/storage/CodaliFeedbackReviewIngestion.d.ts +50 -0
  99. package/dist/vendor/codali/storage/CodaliFeedbackReviewIngestion.d.ts.map +1 -0
  100. package/dist/vendor/codali/storage/CodaliFeedbackReviewIngestion.js +141 -0
  101. package/dist/vendor/codali/storage/CodaliStorageContracts.d.ts +337 -0
  102. package/dist/vendor/codali/storage/CodaliStorageContracts.d.ts.map +1 -0
  103. package/dist/vendor/codali/storage/CodaliStorageContracts.js +1555 -0
  104. package/dist/vendor/codali/storage/DatasetExportJob.d.ts +51 -0
  105. package/dist/vendor/codali/storage/DatasetExportJob.d.ts.map +1 -0
  106. package/dist/vendor/codali/storage/DatasetExportJob.js +358 -0
  107. package/dist/vendor/codali/storage/DatasetReviewQueue.d.ts +98 -0
  108. package/dist/vendor/codali/storage/DatasetReviewQueue.d.ts.map +1 -0
  109. package/dist/vendor/codali/storage/DatasetReviewQueue.js +426 -0
  110. package/dist/vendor/codali/storage/GatewayDatasetStore.d.ts +233 -0
  111. package/dist/vendor/codali/storage/GatewayDatasetStore.d.ts.map +1 -0
  112. package/dist/vendor/codali/storage/GatewayDatasetStore.js +2070 -0
  113. package/package.json +3 -3
@@ -0,0 +1,426 @@
1
+ import { createHash } from "node:crypto";
2
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { validateCodaliStorageDatasetRecord, } from "./CodaliStorageContracts.js";
5
+ import { applyCodaliStorageReviewPromotion, buildCodaliStorageReviewRecord, } from "./CodaliFeedbackReviewIngestion.js";
6
+ export const CODALI_DATASET_RECORDS_FILE = "records.jsonl";
7
+ const isRecord = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
8
+ const cloneJson = (value) => JSON.parse(JSON.stringify(value));
9
+ const normalizeToken = (value) => {
10
+ const trimmed = value?.trim();
11
+ return trimmed ? trimmed.toLowerCase() : undefined;
12
+ };
13
+ const readOptionalString = (value, keys) => {
14
+ for (const key of keys) {
15
+ const candidate = value?.[key];
16
+ if (typeof candidate === "string" && candidate.trim())
17
+ return candidate.trim();
18
+ }
19
+ return undefined;
20
+ };
21
+ const readOptionalNumber = (value, keys) => {
22
+ for (const key of keys) {
23
+ const candidate = value?.[key];
24
+ if (typeof candidate === "number" && Number.isFinite(candidate))
25
+ return candidate;
26
+ if (typeof candidate === "string" && candidate.trim() && Number.isFinite(Number(candidate))) {
27
+ return Number(candidate);
28
+ }
29
+ }
30
+ return undefined;
31
+ };
32
+ const labels = (record) => record.quality?.labels ?? [];
33
+ const labelValue = (record, prefixes) => {
34
+ for (const label of labels(record)) {
35
+ for (const prefix of prefixes) {
36
+ if (label.toLowerCase().startsWith(prefix.toLowerCase())) {
37
+ return label.slice(prefix.length).trim();
38
+ }
39
+ }
40
+ }
41
+ return undefined;
42
+ };
43
+ const confidenceBucket = (score) => {
44
+ if (score === undefined)
45
+ return "unknown";
46
+ if (score >= 0.8)
47
+ return "high";
48
+ if (score >= 0.5)
49
+ return "medium";
50
+ return "low";
51
+ };
52
+ export const datasetRecordFailureCluster = (record) => {
53
+ const metadata = record.metadata;
54
+ return readOptionalString(metadata, [
55
+ "failureCluster",
56
+ "failure_cluster",
57
+ "failureClusterId",
58
+ "failure_cluster_id",
59
+ "errorCode",
60
+ "error_code",
61
+ "policyEventType",
62
+ "policy_event_type",
63
+ "status",
64
+ ])
65
+ ?? labelValue(record, ["cluster:", "failure:", "auto:status:", "auto:policy:"])
66
+ ?? (metadata?.exampleType === "schema_failure" ? "schema_failure" : "none");
67
+ };
68
+ export const datasetRecordIntegration = (record) => {
69
+ const metadata = record.metadata;
70
+ return readOptionalString(metadata, [
71
+ "integration",
72
+ "integrationId",
73
+ "integration_id",
74
+ "sourceType",
75
+ "source_type",
76
+ "usedTool",
77
+ "used_tool",
78
+ "tool",
79
+ "provider",
80
+ "finalModelTier",
81
+ "final_model_tier",
82
+ ])
83
+ ?? labelValue(record, ["integration:", "auto:tool:", "auto:source:", "auto:provider:"])
84
+ ?? "none";
85
+ };
86
+ export const datasetRecordConfidence = (record) => readOptionalString(record.metadata, ["confidence", "confidenceBucket", "confidence_bucket"])
87
+ ?? labelValue(record, ["confidence:", "auto:confidence:"])
88
+ ?? confidenceBucket(record.quality?.score);
89
+ export const datasetRecordBusinessValue = (record) => readOptionalString(record.metadata, [
90
+ "businessValue",
91
+ "business_value",
92
+ "businessValueTier",
93
+ "business_value_tier",
94
+ "valueTier",
95
+ "value_tier",
96
+ ])
97
+ ?? labelValue(record, ["business:", "value:"])
98
+ ?? "unknown";
99
+ const datasetRecordBusinessValueScore = (record) => readOptionalNumber(record.metadata, [
100
+ "businessValue",
101
+ "business_value",
102
+ "businessValueScore",
103
+ "business_value_score",
104
+ "valueScore",
105
+ "value_score",
106
+ ]);
107
+ const stableHash = (value) => createHash("sha256").update(value).digest("hex");
108
+ const deterministicSortKey = (entry, seed) => {
109
+ const scopeKey = `${entry.scope.tenantId}:${entry.scope.productId}:${entry.scope.deploymentId}:${entry.scope.runId}`;
110
+ const base = `${scopeKey}:${entry.record.recordId}:${entry.record.createdAt}`;
111
+ return seed ? stableHash(`${seed}:${base}`) : base;
112
+ };
113
+ const increment = (counts, key) => {
114
+ const normalized = key?.trim() || "unknown";
115
+ counts[normalized] = (counts[normalized] ?? 0) + 1;
116
+ };
117
+ const uniqueStrings = (values) => Array.from(new Set(values.map((value) => value.trim()).filter(Boolean)));
118
+ const parseScope = (value) => {
119
+ const record = isRecord(value) ? value : {};
120
+ return {
121
+ tenantId: typeof record.tenantId === "string" ? record.tenantId : "local",
122
+ productId: typeof record.productId === "string" ? record.productId : "product-neutral",
123
+ deploymentId: typeof record.deploymentId === "string" ? record.deploymentId : "local",
124
+ runId: typeof record.runId === "string" ? record.runId : "dataset-local",
125
+ };
126
+ };
127
+ const isEnoent = (error) => isRecord(error) && error.code === "ENOENT";
128
+ export const readLocalDatasetCollection = async (input) => {
129
+ const recordsPath = path.join(input.directory, input.recordsFileName ?? CODALI_DATASET_RECORDS_FILE);
130
+ let raw = "";
131
+ try {
132
+ raw = await readFile(recordsPath, "utf8");
133
+ }
134
+ catch (error) {
135
+ if (!isEnoent(error))
136
+ throw error;
137
+ }
138
+ const batches = [];
139
+ let invalidLineCount = 0;
140
+ let invalidRecordCount = 0;
141
+ for (const line of raw.split(/\r?\n/g)) {
142
+ if (!line.trim())
143
+ continue;
144
+ let parsed;
145
+ try {
146
+ parsed = JSON.parse(line);
147
+ }
148
+ catch {
149
+ invalidLineCount += 1;
150
+ continue;
151
+ }
152
+ if (!isRecord(parsed) || !Array.isArray(parsed.records)) {
153
+ invalidLineCount += 1;
154
+ continue;
155
+ }
156
+ const records = [];
157
+ for (const item of parsed.records) {
158
+ const validation = validateCodaliStorageDatasetRecord(item);
159
+ if (validation.ok) {
160
+ records.push(validation.value);
161
+ }
162
+ else {
163
+ invalidRecordCount += 1;
164
+ }
165
+ }
166
+ batches.push({
167
+ raw: parsed,
168
+ collectedAt: typeof parsed.collectedAt === "string" ? parsed.collectedAt : undefined,
169
+ idempotencyKey: typeof parsed.idempotencyKey === "string" ? parsed.idempotencyKey : undefined,
170
+ scope: parseScope(parsed.scope),
171
+ records,
172
+ metadata: isRecord(parsed.metadata) ? parsed.metadata : undefined,
173
+ });
174
+ }
175
+ return {
176
+ directory: input.directory,
177
+ recordsPath,
178
+ batches,
179
+ invalidLineCount,
180
+ invalidRecordCount,
181
+ };
182
+ };
183
+ export const writeLocalDatasetCollection = async (collection) => {
184
+ await mkdir(collection.directory, { recursive: true });
185
+ const body = collection.batches
186
+ .map((batch) => JSON.stringify({
187
+ ...batch.raw,
188
+ scope: batch.scope,
189
+ records: batch.records,
190
+ metadata: batch.metadata,
191
+ }))
192
+ .join("\n");
193
+ const tempPath = `${collection.recordsPath}.${process.pid}.${Date.now()}.tmp`;
194
+ await writeFile(tempPath, body ? `${body}\n` : "", "utf8");
195
+ await rename(tempPath, collection.recordsPath);
196
+ };
197
+ export const datasetRecordEntries = (collection) => collection.batches.flatMap((batch, batchIndex) => batch.records.map((record, recordIndex) => ({
198
+ record,
199
+ batchIndex,
200
+ recordIndex,
201
+ scope: batch.scope,
202
+ collectedAt: batch.collectedAt,
203
+ idempotencyKey: batch.idempotencyKey,
204
+ batchMetadata: batch.metadata,
205
+ })));
206
+ const scopedRecordIdentityKey = (entry) => [
207
+ entry.scope.tenantId,
208
+ entry.scope.productId,
209
+ entry.scope.deploymentId,
210
+ entry.scope.runId,
211
+ entry.record.recordId,
212
+ ].join("\t");
213
+ export const latestDatasetRecordEntries = (collection) => {
214
+ const byRecordId = new Map();
215
+ for (const entry of datasetRecordEntries(collection)) {
216
+ byRecordId.set(scopedRecordIdentityKey(entry), entry);
217
+ }
218
+ return Array.from(byRecordId.values()).sort((left, right) => scopedRecordIdentityKey(left).localeCompare(scopedRecordIdentityKey(right)));
219
+ };
220
+ const matchesTextFilter = (actual, expected) => !expected || normalizeToken(actual) === normalizeToken(expected);
221
+ const matchesConfidence = (record, expected) => {
222
+ if (!expected)
223
+ return true;
224
+ const numeric = Number(expected);
225
+ if (Number.isFinite(numeric))
226
+ return (record.quality?.score ?? 0) >= numeric;
227
+ return normalizeToken(datasetRecordConfidence(record)) === normalizeToken(expected);
228
+ };
229
+ const matchesBusinessValue = (record, expected) => {
230
+ if (!expected)
231
+ return true;
232
+ const numeric = Number(expected);
233
+ const score = datasetRecordBusinessValueScore(record);
234
+ if (Number.isFinite(numeric))
235
+ return score !== undefined && score >= numeric;
236
+ return normalizeToken(datasetRecordBusinessValue(record)) === normalizeToken(expected);
237
+ };
238
+ export const matchesDatasetSampleOptions = (entry, options) => {
239
+ if (options.unreviewedOnly && entry.record.quality?.reviewed === true)
240
+ return false;
241
+ return matchesTextFilter(entry.scope.tenantId, options.tenantId)
242
+ && matchesTextFilter(entry.scope.productId, options.productId)
243
+ && matchesTextFilter(entry.scope.deploymentId, options.deploymentId)
244
+ && matchesTextFilter(entry.scope.runId, options.runId)
245
+ && matchesTextFilter(datasetRecordFailureCluster(entry.record), options.failureCluster)
246
+ && matchesTextFilter(datasetRecordIntegration(entry.record), options.integration)
247
+ && matchesConfidence(entry.record, options.confidence)
248
+ && matchesBusinessValue(entry.record, options.businessValue);
249
+ };
250
+ export const sampleDatasetRecordEntries = (collection, options = {}) => {
251
+ const limit = options.limit && options.limit > 0 ? Math.floor(options.limit) : undefined;
252
+ const entries = latestDatasetRecordEntries(collection)
253
+ .filter((entry) => matchesDatasetSampleOptions(entry, options))
254
+ .sort((left, right) => deterministicSortKey(left, options.seed).localeCompare(deterministicSortKey(right, options.seed))
255
+ || left.record.recordId.localeCompare(right.record.recordId));
256
+ return limit ? entries.slice(0, limit) : entries;
257
+ };
258
+ export const summarizeDatasetCollection = (collection) => {
259
+ const entries = latestDatasetRecordEntries(collection);
260
+ const summary = {
261
+ directory: collection.directory,
262
+ recordsPath: collection.recordsPath,
263
+ batchCount: collection.batches.length,
264
+ totalRecordRows: datasetRecordEntries(collection).length,
265
+ uniqueRecordCount: entries.length,
266
+ invalidLineCount: collection.invalidLineCount,
267
+ invalidRecordCount: collection.invalidRecordCount,
268
+ reviewedCount: 0,
269
+ unreviewedCount: 0,
270
+ exportAllowedCount: 0,
271
+ trainingAllowedCount: 0,
272
+ byTenant: {},
273
+ byProduct: {},
274
+ byDatasetKind: {},
275
+ byExampleType: {},
276
+ byFailureCluster: {},
277
+ byIntegration: {},
278
+ byConfidence: {},
279
+ byBusinessValue: {},
280
+ };
281
+ for (const entry of entries) {
282
+ if (entry.record.quality?.reviewed === true)
283
+ summary.reviewedCount += 1;
284
+ else
285
+ summary.unreviewedCount += 1;
286
+ if (entry.record.privacy.exportAllowed)
287
+ summary.exportAllowedCount += 1;
288
+ if (entry.record.privacy.trainingAllowed)
289
+ summary.trainingAllowedCount += 1;
290
+ increment(summary.byTenant, entry.scope.tenantId);
291
+ increment(summary.byProduct, entry.scope.productId);
292
+ increment(summary.byDatasetKind, entry.record.datasetKind);
293
+ increment(summary.byExampleType, typeof entry.record.metadata?.exampleType === "string"
294
+ ? entry.record.metadata.exampleType
295
+ : "unknown");
296
+ increment(summary.byFailureCluster, datasetRecordFailureCluster(entry.record));
297
+ increment(summary.byIntegration, datasetRecordIntegration(entry.record));
298
+ increment(summary.byConfidence, datasetRecordConfidence(entry.record));
299
+ increment(summary.byBusinessValue, datasetRecordBusinessValue(entry.record));
300
+ }
301
+ return summary;
302
+ };
303
+ const mutableMatches = (collection, recordId, options) => datasetRecordEntries(collection).filter((entry) => entry.record.recordId === recordId && matchesDatasetSampleOptions(entry, options));
304
+ const scopeKey = (entry) => `${entry.scope.tenantId}:${entry.scope.productId}:${entry.scope.deploymentId}:${entry.scope.runId}`;
305
+ const assertMutableMatches = (collection, recordId, options) => {
306
+ const matches = mutableMatches(collection, recordId, options);
307
+ if (matches.length === 0) {
308
+ throw new Error(`No dataset record matched ${recordId} in the selected scope.`);
309
+ }
310
+ const scopes = new Set(matches.map(scopeKey));
311
+ const scopeConstrained = Boolean(options.tenantId || options.productId || options.deploymentId || options.runId);
312
+ if (scopes.size > 1 && !scopeConstrained) {
313
+ throw new Error(`Dataset record ${recordId} exists in multiple scopes; pass --tenant/--product/--run to disambiguate.`);
314
+ }
315
+ return matches;
316
+ };
317
+ export const applyDatasetLabel = (collection, input) => {
318
+ const updatedAt = (input.now ?? (() => new Date()))().toISOString();
319
+ const matches = assertMutableMatches(collection, input.recordId, input);
320
+ const labelsToAdd = uniqueStrings(input.labels);
321
+ const recordIds = new Set();
322
+ for (const match of matches) {
323
+ const batch = collection.batches[match.batchIndex];
324
+ const record = batch?.records[match.recordIndex];
325
+ if (!record)
326
+ continue;
327
+ const existingLabels = record.quality?.labels ?? [];
328
+ const nextRecord = {
329
+ ...record,
330
+ quality: {
331
+ ...(record.quality ?? {}),
332
+ labels: uniqueStrings([...existingLabels, ...labelsToAdd]),
333
+ reviewed: true,
334
+ },
335
+ metadata: {
336
+ ...(record.metadata ?? {}),
337
+ cliLabels: uniqueStrings([
338
+ ...((Array.isArray(record.metadata?.cliLabels)
339
+ ? record.metadata?.cliLabels.filter((value) => typeof value === "string")
340
+ : [])),
341
+ ...labelsToAdd,
342
+ ]),
343
+ ...(input.reviewerId ? { reviewerId: input.reviewerId } : {}),
344
+ ...(input.reason ? { labelReason: input.reason } : {}),
345
+ rawTraceIncluded: false,
346
+ labelledAt: updatedAt,
347
+ },
348
+ };
349
+ batch.records[match.recordIndex] = nextRecord;
350
+ recordIds.add(record.recordId);
351
+ }
352
+ return { updatedCount: matches.length, recordIds: [...recordIds].sort() };
353
+ };
354
+ const decisionForPromotionTarget = (promotionTarget) => {
355
+ if (promotionTarget === "gold")
356
+ return "approved";
357
+ if (promotionTarget === "reject")
358
+ return "rejected";
359
+ return "needs_changes";
360
+ };
361
+ export const applyDatasetPromotionTarget = (collection, input) => {
362
+ const reviewedAt = (input.now ?? (() => new Date()))().toISOString();
363
+ const matches = assertMutableMatches(collection, input.recordId, input);
364
+ const recordIds = new Set();
365
+ for (const match of matches) {
366
+ const batch = collection.batches[match.batchIndex];
367
+ const record = batch?.records[match.recordIndex];
368
+ if (!record)
369
+ continue;
370
+ const review = buildCodaliStorageReviewRecord({
371
+ reviewId: `dataset-cli-review-${stableHash(`${record.recordId}:${input.promotionTarget}:${reviewedAt}`).slice(0, 16)}`,
372
+ createdAt: reviewedAt,
373
+ reviewerType: "human",
374
+ reviewerId: input.reviewerId,
375
+ runId: match.scope.runId,
376
+ deletionGroupId: record.inputRef.deletionGroupId,
377
+ productScope: {
378
+ productId: match.scope.productId,
379
+ tenantHash: record.inputRef.ownerScope.tenantHash,
380
+ deploymentId: match.scope.deploymentId,
381
+ },
382
+ requesterScope: {
383
+ requesterHash: input.reviewerId ?? "dataset-cli-reviewer",
384
+ visibility: "requester",
385
+ tenantWide: false,
386
+ },
387
+ candidateRecords: [{
388
+ recordType: "dataset_record",
389
+ recordId: record.recordId,
390
+ datasetKind: record.datasetKind,
391
+ objectRef: record.outputRef ?? record.inputRef,
392
+ labels: record.quality?.labels,
393
+ metadata: {
394
+ sourceGatewayRecordId: record.sourceGatewayRecordId,
395
+ rawTraceIncluded: false,
396
+ },
397
+ }],
398
+ targetType: "dataset_record",
399
+ targetId: record.recordId,
400
+ decision: input.decision ?? decisionForPromotionTarget(input.promotionTarget),
401
+ labels: input.labels,
402
+ reasons: input.reasons,
403
+ promotionTarget: input.promotionTarget,
404
+ promotedRecordIds: [record.recordId],
405
+ privacy: {
406
+ uploadAllowed: false,
407
+ exportAllowed: false,
408
+ trainingAllowed: false,
409
+ },
410
+ metadata: {
411
+ source: "dataset_cli",
412
+ rawTraceIncluded: false,
413
+ },
414
+ });
415
+ const [promoted] = applyCodaliStorageReviewPromotion({
416
+ review,
417
+ records: [record],
418
+ reviewedAt,
419
+ });
420
+ if (promoted) {
421
+ batch.records[match.recordIndex] = cloneJson(promoted);
422
+ recordIds.add(record.recordId);
423
+ }
424
+ }
425
+ return { updatedCount: matches.length, recordIds: [...recordIds].sort() };
426
+ };
@@ -0,0 +1,233 @@
1
+ import type { CodaliGatewayRequest, CodaliGatewayResult } from "../gateway/CodaliGatewayTypes.js";
2
+ import { type CodaliGatewayRunTrace } from "../gateway/CodaliGatewayStore.js";
3
+ import { type CodaliStorageDatasetKind, type CodaliStorageDatasetRecord, type CodaliStorageObjectPrivacyFlags, type CodaliStorageObjectRef, type CodaliStorageObjectRefKind, type CodaliStorageObjectRetentionClass, type CodaliStoragePrivacyMetadata } from "./CodaliStorageContracts.js";
4
+ export declare const GATEWAY_DATASET_SERVICE_SIGNATURE_VERSION = "codali.storage.hmac.v1";
5
+ export declare const DEFAULT_GATEWAY_DATASET_SERVICE_ENDPOINT = "/v1/gateway/batches";
6
+ export interface GatewayDatasetStorageScope {
7
+ tenantId: string;
8
+ productId: string;
9
+ deploymentId: string;
10
+ runId: string;
11
+ }
12
+ export type GatewayDatasetStoreWriteStatus = "stored" | "queued" | "skipped" | "failed";
13
+ export interface GatewayDatasetStoreWriteResult {
14
+ accepted: boolean;
15
+ status: GatewayDatasetStoreWriteStatus;
16
+ recordCount: number;
17
+ objectCount?: number;
18
+ idempotencyKey?: string;
19
+ batchId?: string;
20
+ replayed?: boolean;
21
+ fallbackUsed?: boolean;
22
+ errors?: string[];
23
+ metadata?: Record<string, unknown>;
24
+ }
25
+ export interface GatewayDatasetStoreCollectInput {
26
+ scope: GatewayDatasetStorageScope;
27
+ records: CodaliStorageDatasetRecord[];
28
+ idempotencyKey?: string;
29
+ metadata?: Record<string, unknown>;
30
+ }
31
+ export interface GatewayDatasetStore {
32
+ collect(input: GatewayDatasetStoreCollectInput): Promise<GatewayDatasetStoreWriteResult>;
33
+ }
34
+ export interface GatewayDatasetObjectPutInput {
35
+ scope: GatewayDatasetStorageScope;
36
+ payload: unknown;
37
+ ownerType: string;
38
+ ownerId: string;
39
+ kind?: CodaliStorageObjectRefKind;
40
+ mimeType?: string;
41
+ retentionClass?: CodaliStorageObjectRetentionClass;
42
+ privacyFlags?: Partial<CodaliStorageObjectPrivacyFlags>;
43
+ metadata?: Record<string, unknown>;
44
+ }
45
+ export interface GatewayDatasetObjectStore {
46
+ putObject(input: GatewayDatasetObjectPutInput): Promise<CodaliStorageObjectRef>;
47
+ readObject?(ref: CodaliStorageObjectRef): Promise<unknown | undefined>;
48
+ }
49
+ export type GatewayDatasetGoldTargetKind = "accepted" | "corrected" | "reviewed";
50
+ export interface GatewayDatasetGoldTargetInput {
51
+ id?: string;
52
+ kind: GatewayDatasetGoldTargetKind;
53
+ input?: unknown;
54
+ target?: unknown;
55
+ sourceRecordId?: string;
56
+ sourceModelCallId?: string;
57
+ failedAttemptRecordId?: string;
58
+ failedAttemptModelCallId?: string;
59
+ reviewerId?: string;
60
+ reasons?: string[];
61
+ score?: number;
62
+ labels?: string[];
63
+ metadata?: Record<string, unknown>;
64
+ }
65
+ export interface GatewayDatasetGatewayCollectionOptions {
66
+ enabled?: boolean;
67
+ objectStore?: GatewayDatasetObjectStore;
68
+ fallbackStore?: GatewayDatasetStore;
69
+ scope?: Partial<GatewayDatasetStorageScope>;
70
+ privacy?: Partial<CodaliStoragePrivacyMetadata>;
71
+ privacyFlags?: Partial<CodaliStorageObjectPrivacyFlags>;
72
+ datasetKind?: CodaliStorageDatasetKind;
73
+ idempotencyKey?: string;
74
+ trace?: CodaliGatewayRunTrace;
75
+ traceLoader?: () => Promise<CodaliGatewayRunTrace | undefined>;
76
+ collectModelCalls?: boolean;
77
+ collectSchemaFailures?: boolean;
78
+ collectGoldTargets?: boolean;
79
+ collectRagRetrievals?: boolean;
80
+ collectToolDecisions?: boolean;
81
+ collectEvidenceItems?: boolean;
82
+ collectContextPacks?: boolean;
83
+ collectFinalAnswers?: boolean;
84
+ collectArtifacts?: boolean;
85
+ collectPolicyEvents?: boolean;
86
+ goldTargets?: GatewayDatasetGoldTargetInput[];
87
+ metadata?: Record<string, unknown>;
88
+ now?: () => Date;
89
+ onError?: (error: unknown) => void;
90
+ onResult?: (result: GatewayDatasetStoreWriteResult) => void;
91
+ }
92
+ export interface GatewayDatasetGatewayCollectionInput extends GatewayDatasetGatewayCollectionOptions {
93
+ store: GatewayDatasetStore;
94
+ request: CodaliGatewayRequest;
95
+ result: CodaliGatewayResult;
96
+ }
97
+ export interface GatewayDatasetServiceClientOptions {
98
+ baseUrl: string;
99
+ serviceToken: string;
100
+ hmacSecret?: string;
101
+ endpointPath?: string;
102
+ batchSize?: number;
103
+ maxRetries?: number;
104
+ retryBaseMs?: number;
105
+ timeoutMs?: number;
106
+ fallbackStore?: GatewayDatasetStore;
107
+ fetch?: GatewayDatasetFetch;
108
+ now?: () => Date;
109
+ nonceFactory?: () => string;
110
+ }
111
+ export interface GatewayDatasetFetchRequest {
112
+ method: "GET" | "POST";
113
+ headers: Record<string, string>;
114
+ body?: string;
115
+ signal?: AbortSignal;
116
+ }
117
+ export interface GatewayDatasetFetchResponse {
118
+ ok: boolean;
119
+ status: number;
120
+ statusText?: string;
121
+ text(): Promise<string>;
122
+ }
123
+ export type GatewayDatasetFetch = (url: string, request: GatewayDatasetFetchRequest) => Promise<GatewayDatasetFetchResponse>;
124
+ export interface LocalJsonlGatewayDatasetStoreOptions {
125
+ directory: string;
126
+ recordsFileName?: string;
127
+ now?: () => Date;
128
+ }
129
+ export interface LocalJsonlGatewayDatasetObjectStoreOptions {
130
+ directory: string;
131
+ now?: () => Date;
132
+ }
133
+ export declare class GatewayDatasetStoreError extends Error {
134
+ readonly code: string;
135
+ constructor(code: string, message: string);
136
+ }
137
+ export declare class GatewayDatasetServiceClientError extends Error {
138
+ readonly code: string;
139
+ readonly status?: number;
140
+ readonly retryable: boolean;
141
+ constructor(input: {
142
+ code: string;
143
+ message: string;
144
+ status?: number;
145
+ retryable?: boolean;
146
+ });
147
+ }
148
+ export declare const canonicalizeGatewayDatasetJson: (value: unknown) => string;
149
+ export declare const hashGatewayDatasetRequestBody: (body: unknown) => string;
150
+ export declare const hashGatewayDatasetValue: (value: unknown) => string;
151
+ export declare const createGatewayDatasetLocalOnlyPrivacy: (overrides?: Partial<CodaliStoragePrivacyMetadata>) => CodaliStoragePrivacyMetadata;
152
+ export declare const createGatewayDatasetLocalOnlyObjectPrivacyFlags: (overrides?: Partial<CodaliStorageObjectPrivacyFlags>) => CodaliStorageObjectPrivacyFlags;
153
+ export declare const gatewayDatasetScopeFromGatewayResult: (request: CodaliGatewayRequest, result: CodaliGatewayResult, overrides?: Partial<GatewayDatasetStorageScope>) => GatewayDatasetStorageScope;
154
+ export declare const buildGatewayDatasetIdempotencyKey: (scope: GatewayDatasetStorageScope, records: readonly CodaliStorageDatasetRecord[]) => string;
155
+ export declare const buildGatewayDatasetServiceSignatureHeaders: (input: {
156
+ scope: GatewayDatasetStorageScope;
157
+ body: unknown;
158
+ hmacSecret: string;
159
+ timestamp: string;
160
+ nonce: string;
161
+ }) => Record<string, string>;
162
+ export declare class InMemoryGatewayDatasetObjectStore implements GatewayDatasetObjectStore {
163
+ private readonly options;
164
+ private readonly objects;
165
+ constructor(options?: {
166
+ now?: () => Date;
167
+ });
168
+ putObject(input: GatewayDatasetObjectPutInput): Promise<CodaliStorageObjectRef>;
169
+ readObject(ref: CodaliStorageObjectRef): Promise<unknown | undefined>;
170
+ listObjects(): CodaliStorageObjectRef[];
171
+ }
172
+ export declare const createInMemoryGatewayDatasetObjectStore: (options?: {
173
+ now?: () => Date;
174
+ }) => InMemoryGatewayDatasetObjectStore;
175
+ export declare class InMemoryGatewayDatasetStore implements GatewayDatasetStore {
176
+ private readonly records;
177
+ private readonly batches;
178
+ private readonly idempotency;
179
+ collect(input: GatewayDatasetStoreCollectInput): Promise<GatewayDatasetStoreWriteResult>;
180
+ listRecords(): CodaliStorageDatasetRecord[];
181
+ readRecord(recordId: string): CodaliStorageDatasetRecord | undefined;
182
+ listBatches(): Array<{
183
+ idempotencyKey?: string;
184
+ scope: GatewayDatasetStorageScope;
185
+ recordIds: string[];
186
+ metadata?: Record<string, unknown>;
187
+ }>;
188
+ }
189
+ export declare const createInMemoryGatewayDatasetStore: () => InMemoryGatewayDatasetStore;
190
+ export declare class LocalJsonlGatewayDatasetObjectStore implements GatewayDatasetObjectStore {
191
+ private readonly options;
192
+ constructor(options: LocalJsonlGatewayDatasetObjectStoreOptions);
193
+ putObject(input: GatewayDatasetObjectPutInput): Promise<CodaliStorageObjectRef>;
194
+ readObject(ref: CodaliStorageObjectRef): Promise<unknown | undefined>;
195
+ }
196
+ export declare const createLocalJsonlGatewayDatasetObjectStore: (options: LocalJsonlGatewayDatasetObjectStoreOptions) => LocalJsonlGatewayDatasetObjectStore;
197
+ export declare class LocalJsonlGatewayDatasetStore implements GatewayDatasetStore {
198
+ private readonly options;
199
+ private readonly idempotency;
200
+ constructor(options: LocalJsonlGatewayDatasetStoreOptions);
201
+ collect(input: GatewayDatasetStoreCollectInput): Promise<GatewayDatasetStoreWriteResult>;
202
+ }
203
+ export declare const createLocalJsonlGatewayDatasetStore: (options: LocalJsonlGatewayDatasetStoreOptions) => LocalJsonlGatewayDatasetStore;
204
+ export declare class GatewayDatasetServiceClient implements GatewayDatasetStore {
205
+ private readonly options;
206
+ private readonly fetchImpl;
207
+ constructor(options: GatewayDatasetServiceClientOptions);
208
+ collect(input: GatewayDatasetStoreCollectInput): Promise<GatewayDatasetStoreWriteResult>;
209
+ private writeBatch;
210
+ private fetchWithTimeout;
211
+ }
212
+ export declare const createGatewayDatasetServiceClient: (options: GatewayDatasetServiceClientOptions) => GatewayDatasetServiceClient;
213
+ type GatewayDatasetCollectorBuildInput = Omit<GatewayDatasetGatewayCollectionInput, "store" | "enabled" | "fallbackStore" | "onError" | "onResult">;
214
+ export declare class GatewayDatasetCollector {
215
+ buildCollectInput(input: GatewayDatasetCollectorBuildInput): Promise<GatewayDatasetStoreCollectInput>;
216
+ private buildRunRecord;
217
+ private buildFinalAnswerRecord;
218
+ private buildRagRetrievalRecord;
219
+ private buildToolDecisionRecord;
220
+ private buildEvidenceItemRecord;
221
+ private buildContextPackRecord;
222
+ private buildArtifactRecord;
223
+ private buildPolicyEventRecord;
224
+ private buildModelCallRecord;
225
+ private buildSchemaFailureRecord;
226
+ private buildGoldTargetRecord;
227
+ }
228
+ export declare const createGatewayDatasetCollector: () => GatewayDatasetCollector;
229
+ export declare const buildGatewayDatasetCollectInputFromGatewayResult: (input: Omit<GatewayDatasetGatewayCollectionInput, "store" | "enabled" | "fallbackStore" | "onError" | "onResult">) => Promise<GatewayDatasetStoreCollectInput>;
230
+ export declare const collectGatewayDatasetResult: (input: GatewayDatasetGatewayCollectionInput) => Promise<GatewayDatasetStoreWriteResult>;
231
+ export declare const collectGatewayDatasetResultNonBlocking: (input: GatewayDatasetGatewayCollectionInput) => GatewayDatasetStoreWriteResult;
232
+ export {};
233
+ //# sourceMappingURL=GatewayDatasetStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GatewayDatasetStore.d.ts","sourceRoot":"","sources":["../../src/storage/GatewayDatasetStore.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGV,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAEL,KAAK,qBAAqB,EAI3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAGL,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,EAC/B,KAAK,+BAA+B,EACpC,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,iCAAiC,EACtC,KAAK,4BAA4B,EAClC,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,yCAAyC,2BAA2B,CAAC;AAClF,eAAO,MAAM,wCAAwC,wBAAwB,CAAC;AAE9E,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY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