@mcoda/codali 0.1.90 → 0.1.91
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.
- package/dist/cli/DatasetCommand.d.ts +38 -0
- package/dist/cli/DatasetCommand.d.ts.map +1 -0
- package/dist/cli/DatasetCommand.js +959 -0
- package/dist/cli/EvalCommand.d.ts +3 -0
- package/dist/cli/EvalCommand.d.ts.map +1 -1
- package/dist/cli/EvalCommand.js +55 -1
- package/dist/cli/ImprovementCommand.d.ts +97 -0
- package/dist/cli/ImprovementCommand.d.ts.map +1 -0
- package/dist/cli/ImprovementCommand.js +1879 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +15 -0
- package/dist/dataset-cli.d.ts +3 -0
- package/dist/dataset-cli.d.ts.map +1 -0
- package/dist/dataset-cli.js +30 -0
- package/dist/eval/CodaliGatewayLiveHarness.d.ts +90 -1
- package/dist/eval/CodaliGatewayLiveHarness.d.ts.map +1 -1
- package/dist/eval/CodaliGatewayLiveHarness.js +443 -9
- package/dist/eval/GatewayDatasetEval.d.ts +70 -0
- package/dist/eval/GatewayDatasetEval.d.ts.map +1 -0
- package/dist/eval/GatewayDatasetEval.js +477 -0
- package/dist/eval/GatewayEvalSuite.d.ts +52 -0
- package/dist/eval/GatewayEvalSuite.d.ts.map +1 -1
- package/dist/eval/GatewayEvalSuite.js +135 -1
- package/dist/gateway/CodaliGateway.d.ts +4 -0
- package/dist/gateway/CodaliGateway.d.ts.map +1 -1
- package/dist/gateway/CodaliGateway.js +37 -1
- package/dist/gateway/CodaliGatewaySchemas.d.ts.map +1 -1
- package/dist/gateway/CodaliGatewaySchemas.js +0 -4
- package/dist/gateway/CodaliGatewayStore.d.ts.map +1 -1
- package/dist/gateway/CodaliGatewayStore.js +1 -0
- package/dist/gateway/GatewayPlanner.d.ts.map +1 -1
- package/dist/gateway/GatewayPlanner.js +355 -41
- package/dist/gateway/GatewayStateMachine.d.ts +1 -0
- package/dist/gateway/GatewayStateMachine.d.ts.map +1 -1
- package/dist/gateway/GatewayStateMachine.js +221 -5
- package/dist/improvement/CandidateReleaseBuilder.d.ts +201 -0
- package/dist/improvement/CandidateReleaseBuilder.d.ts.map +1 -0
- package/dist/improvement/CandidateReleaseBuilder.js +1175 -0
- package/dist/improvement/DatasetEligibilityGate.d.ts +75 -0
- package/dist/improvement/DatasetEligibilityGate.d.ts.map +1 -0
- package/dist/improvement/DatasetEligibilityGate.js +497 -0
- package/dist/improvement/DatasetExportManifestReader.d.ts +88 -0
- package/dist/improvement/DatasetExportManifestReader.d.ts.map +1 -0
- package/dist/improvement/DatasetExportManifestReader.js +333 -0
- package/dist/improvement/DocdexRetrievalCandidateBuilder.d.ts +192 -0
- package/dist/improvement/DocdexRetrievalCandidateBuilder.d.ts.map +1 -0
- package/dist/improvement/DocdexRetrievalCandidateBuilder.js +625 -0
- package/dist/improvement/EvalReplayCandidateBuilder.d.ts +173 -0
- package/dist/improvement/EvalReplayCandidateBuilder.d.ts.map +1 -0
- package/dist/improvement/EvalReplayCandidateBuilder.js +363 -0
- package/dist/improvement/FineTuneJobPlanner.d.ts +281 -0
- package/dist/improvement/FineTuneJobPlanner.d.ts.map +1 -0
- package/dist/improvement/FineTuneJobPlanner.js +823 -0
- package/dist/improvement/ImprovementEvalRunner.d.ts +50 -0
- package/dist/improvement/ImprovementEvalRunner.d.ts.map +1 -0
- package/dist/improvement/ImprovementEvalRunner.js +648 -0
- package/dist/improvement/ImprovementPolicy.d.ts +272 -0
- package/dist/improvement/ImprovementPolicy.d.ts.map +1 -0
- package/dist/improvement/ImprovementPolicy.js +1450 -0
- package/dist/improvement/ModelRouterCandidateBuilder.d.ts +186 -0
- package/dist/improvement/ModelRouterCandidateBuilder.d.ts.map +1 -0
- package/dist/improvement/ModelRouterCandidateBuilder.js +880 -0
- package/dist/improvement/OperatorInspector.d.ts +182 -0
- package/dist/improvement/OperatorInspector.d.ts.map +1 -0
- package/dist/improvement/OperatorInspector.js +604 -0
- package/dist/improvement/ProductionGovernance.d.ts +91 -0
- package/dist/improvement/ProductionGovernance.d.ts.map +1 -0
- package/dist/improvement/ProductionGovernance.js +329 -0
- package/dist/improvement/PromptSchemaToolMetadataCandidateBuilder.d.ts +152 -0
- package/dist/improvement/PromptSchemaToolMetadataCandidateBuilder.d.ts.map +1 -0
- package/dist/improvement/PromptSchemaToolMetadataCandidateBuilder.js +480 -0
- package/dist/improvement/PublishOrchestrator.d.ts +113 -0
- package/dist/improvement/PublishOrchestrator.d.ts.map +1 -0
- package/dist/improvement/PublishOrchestrator.js +590 -0
- package/dist/improvement/ReleaseOutcomeReporter.d.ts +133 -0
- package/dist/improvement/ReleaseOutcomeReporter.d.ts.map +1 -0
- package/dist/improvement/ReleaseOutcomeReporter.js +501 -0
- package/dist/improvement/StorageServiceImprovementClient.d.ts +71 -0
- package/dist/improvement/StorageServiceImprovementClient.d.ts.map +1 -0
- package/dist/improvement/StorageServiceImprovementClient.js +245 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -0
- package/dist/runtime/CodaliRuntime.d.ts +0 -2
- package/dist/runtime/CodaliRuntime.d.ts.map +1 -1
- package/dist/runtime/CodaliRuntime.js +0 -5
- package/dist/storage/CodaliDatasetPrivacyEngine.d.ts +138 -0
- package/dist/storage/CodaliDatasetPrivacyEngine.d.ts.map +1 -0
- package/dist/storage/CodaliDatasetPrivacyEngine.js +417 -0
- package/dist/storage/CodaliFeedbackReviewIngestion.d.ts +50 -0
- package/dist/storage/CodaliFeedbackReviewIngestion.d.ts.map +1 -0
- package/dist/storage/CodaliFeedbackReviewIngestion.js +141 -0
- package/dist/storage/CodaliStorageContracts.d.ts +337 -0
- package/dist/storage/CodaliStorageContracts.d.ts.map +1 -0
- package/dist/storage/CodaliStorageContracts.js +1555 -0
- package/dist/storage/DatasetExportJob.d.ts +51 -0
- package/dist/storage/DatasetExportJob.d.ts.map +1 -0
- package/dist/storage/DatasetExportJob.js +358 -0
- package/dist/storage/DatasetReviewQueue.d.ts +98 -0
- package/dist/storage/DatasetReviewQueue.d.ts.map +1 -0
- package/dist/storage/DatasetReviewQueue.js +426 -0
- package/dist/storage/GatewayDatasetStore.d.ts +233 -0
- package/dist/storage/GatewayDatasetStore.d.ts.map +1 -0
- package/dist/storage/GatewayDatasetStore.js +2070 -0
- package/package.json +5 -4
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type CodaliStorageExportKind, type CodaliStorageExportManifest, type CodaliStorageObjectRef } from "../storage/CodaliStorageContracts.js";
|
|
2
|
+
export declare const CODALI_IMPROVEMENT_ELIGIBILITY_GATE_SCHEMA_VERSION: "codali.improvement.eligibility_gate.v1";
|
|
3
|
+
export type DatasetEligibilityGateReasonCode = "artifact_privacy_read_disallowed" | "artifact_type_missing" | "artifact_type_not_allowed" | "deletion_group_revoked" | "duplicate_lineage" | "privacy_metadata_missing" | "row_invalid" | "row_privacy_read_disallowed";
|
|
4
|
+
export type DatasetEligibilityGateWarningCode = "artifact_payload_read_blocked" | "duplicate_lineage_dropped" | "lineage_revoked" | "no_accepted_examples";
|
|
5
|
+
export type DatasetEligibilityGatePreferenceSignal = "human_reviewed" | "accepted_correction" | "high_confidence" | "strong_negative";
|
|
6
|
+
export interface DatasetEligibilityGateReason {
|
|
7
|
+
code: DatasetEligibilityGateReasonCode;
|
|
8
|
+
message: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
details?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export interface DatasetEligibilityGateWarning {
|
|
13
|
+
code: DatasetEligibilityGateWarningCode;
|
|
14
|
+
message: string;
|
|
15
|
+
recordId?: string;
|
|
16
|
+
dedupeKey?: string;
|
|
17
|
+
details?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface DatasetEligibilityGateAcceptedExample {
|
|
20
|
+
recordId: string;
|
|
21
|
+
sourceGatewayRecordId?: string;
|
|
22
|
+
dedupeKey: string;
|
|
23
|
+
lineageKey: DatasetEligibilityLineageKey;
|
|
24
|
+
deletionGroupIds: string[];
|
|
25
|
+
runIds: string[];
|
|
26
|
+
artifactTypes: string[];
|
|
27
|
+
preferenceSignals: DatasetEligibilityGatePreferenceSignal[];
|
|
28
|
+
priorityScore: number;
|
|
29
|
+
}
|
|
30
|
+
export interface DatasetEligibilityGateRejectedExample {
|
|
31
|
+
targetType: "artifact" | "example";
|
|
32
|
+
recordId?: string;
|
|
33
|
+
dedupeKey?: string;
|
|
34
|
+
reasons: DatasetEligibilityGateReason[];
|
|
35
|
+
}
|
|
36
|
+
export interface DatasetEligibilityGateReport {
|
|
37
|
+
schemaVersion: typeof CODALI_IMPROVEMENT_ELIGIBILITY_GATE_SCHEMA_VERSION;
|
|
38
|
+
exportId: string;
|
|
39
|
+
manifestId: string;
|
|
40
|
+
exportKind: CodaliStorageExportKind;
|
|
41
|
+
artifactReadAllowed: boolean;
|
|
42
|
+
lineageValid: boolean;
|
|
43
|
+
totalExamples: number;
|
|
44
|
+
acceptedCount: number;
|
|
45
|
+
rejectedCount: number;
|
|
46
|
+
warningCount: number;
|
|
47
|
+
acceptedRecordIds: string[];
|
|
48
|
+
rejectedRecordIds: string[];
|
|
49
|
+
reasonCounts: Record<string, number>;
|
|
50
|
+
accepted: DatasetEligibilityGateAcceptedExample[];
|
|
51
|
+
rejected: DatasetEligibilityGateRejectedExample[];
|
|
52
|
+
warnings: DatasetEligibilityGateWarning[];
|
|
53
|
+
}
|
|
54
|
+
export interface DatasetEligibilityLineageKey {
|
|
55
|
+
runIds: string[];
|
|
56
|
+
deletionGroupIds: string[];
|
|
57
|
+
taskHash?: string;
|
|
58
|
+
promptHash?: string;
|
|
59
|
+
toolContractHash?: string;
|
|
60
|
+
expectedTargetHash?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface DatasetEligibilityGateInput {
|
|
63
|
+
exportId?: string;
|
|
64
|
+
manifest: CodaliStorageExportManifest;
|
|
65
|
+
primaryArtifactRef: CodaliStorageObjectRef;
|
|
66
|
+
rows?: readonly unknown[];
|
|
67
|
+
allowedArtifactTypes?: readonly string[];
|
|
68
|
+
revokedDeletionGroupIds?: readonly string[];
|
|
69
|
+
}
|
|
70
|
+
export declare const evaluateDatasetExportArtifactPayloadRead: (manifest: CodaliStorageExportManifest, primaryArtifactRef: CodaliStorageObjectRef) => DatasetEligibilityGateReason[];
|
|
71
|
+
export declare class DatasetEligibilityGate {
|
|
72
|
+
curate(input: DatasetEligibilityGateInput): DatasetEligibilityGateReport;
|
|
73
|
+
}
|
|
74
|
+
export declare const curateDatasetExportForImprovement: (input: DatasetEligibilityGateInput) => DatasetEligibilityGateReport;
|
|
75
|
+
//# sourceMappingURL=DatasetEligibilityGate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatasetEligibilityGate.d.ts","sourceRoot":"","sources":["../../src/improvement/DatasetEligibilityGate.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAE5B,MAAM,sCAAsC,CAAC;AAM9C,eAAO,MAAM,kDAAkD,EAC7D,wCAAiD,CAAC;AAEpD,MAAM,MAAM,gCAAgC,GACxC,kCAAkC,GAClC,uBAAuB,GACvB,2BAA2B,GAC3B,wBAAwB,GACxB,mBAAmB,GACnB,0BAA0B,GAC1B,aAAa,GACb,6BAA6B,CAAC;AAElC,MAAM,MAAM,iCAAiC,GACzC,+BAA+B,GAC/B,2BAA2B,GAC3B,iBAAiB,GACjB,sBAAsB,CAAC;AAE3B,MAAM,MAAM,sCAAsC,GAC9C,gBAAgB,GAChB,qBAAqB,GACrB,iBAAiB,GACjB,iBAAiB,CAAC;AAEtB,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,gCAAgC,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,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,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,QAAQ,EAAE,qCAAqC,EAAE,CAAC;IAClD,QAAQ,EAAE,qCAAqC,EAAE,CAAC;IAClD,QAAQ,EAAE,6BAA6B,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,2BAA2B,CAAC;IACtC,kBAAkB,EAAE,sBAAsB,CAAC;IAC3C,IAAI,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IAC1B,oBAAoB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,uBAAuB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAkVD,eAAO,MAAM,wCAAwC,GACnD,UAAU,2BAA2B,EACrC,oBAAoB,sBAAsB,KACzC,4BAA4B,EAwB9B,CAAC;AAqKF,qBAAa,sBAAsB;IACjC,MAAM,CAAC,KAAK,EAAE,2BAA2B,GAAG,4BAA4B;CA8HzE;AAED,eAAO,MAAM,iCAAiC,GAC5C,OAAO,2BAA2B,KACjC,4BAA0E,CAAC"}
|
|
@@ -0,0 +1,497 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { evaluateCodaliDatasetObjectPayloadRead, } from "../storage/CodaliDatasetPrivacyEngine.js";
|
|
3
|
+
export const CODALI_IMPROVEMENT_ELIGIBILITY_GATE_SCHEMA_VERSION = "codali.improvement.eligibility_gate.v1";
|
|
4
|
+
const isRecord = (value) => Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
5
|
+
const sha256Hex = (input) => createHash("sha256").update(input).digest("hex");
|
|
6
|
+
const uniqueSorted = (values) => Array.from(new Set(values
|
|
7
|
+
.map((value) => value?.trim())
|
|
8
|
+
.filter((value) => Boolean(value))))
|
|
9
|
+
.sort();
|
|
10
|
+
const normalizeToken = (value) => value.trim().toLowerCase().replace(/[\s-]+/g, "_");
|
|
11
|
+
const readString = (record, keys) => {
|
|
12
|
+
for (const key of keys) {
|
|
13
|
+
const value = record?.[key];
|
|
14
|
+
if (typeof value === "string" && value.trim())
|
|
15
|
+
return value.trim();
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
};
|
|
19
|
+
const readBoolean = (record, keys) => {
|
|
20
|
+
for (const key of keys) {
|
|
21
|
+
const value = record?.[key];
|
|
22
|
+
if (typeof value === "boolean")
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
};
|
|
27
|
+
const readNumber = (record, keys) => {
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
const value = record?.[key];
|
|
30
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
31
|
+
return value;
|
|
32
|
+
if (typeof value === "string" && value.trim() && Number.isFinite(Number(value))) {
|
|
33
|
+
return Number(value);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
};
|
|
38
|
+
const stringList = (value) => {
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
return uniqueSorted(value.map((entry) => typeof entry === "string" ? entry : undefined));
|
|
41
|
+
}
|
|
42
|
+
if (typeof value === "string" && value.trim())
|
|
43
|
+
return [value.trim()];
|
|
44
|
+
return [];
|
|
45
|
+
};
|
|
46
|
+
const recordList = (value) => Array.isArray(value) ? value.filter(isRecord) : [];
|
|
47
|
+
const refRecord = (value) => isRecord(value) &&
|
|
48
|
+
typeof value.refId === "string" &&
|
|
49
|
+
typeof value.contentHash === "string" &&
|
|
50
|
+
typeof value.deletionGroupId === "string" &&
|
|
51
|
+
isRecord(value.privacyFlags)
|
|
52
|
+
? value
|
|
53
|
+
: undefined;
|
|
54
|
+
const refsForExample = (record) => {
|
|
55
|
+
const refs = [
|
|
56
|
+
refRecord(record.inputRef),
|
|
57
|
+
refRecord(record.outputRef),
|
|
58
|
+
...recordList(record.evidenceRefs).map((entry) => refRecord(entry)),
|
|
59
|
+
];
|
|
60
|
+
return refs.filter((ref) => Boolean(ref));
|
|
61
|
+
};
|
|
62
|
+
const privacyForExample = (record) => isRecord(record.privacy)
|
|
63
|
+
? record.privacy
|
|
64
|
+
: undefined;
|
|
65
|
+
const labelsForExample = (record) => {
|
|
66
|
+
const quality = isRecord(record.quality) ? record.quality : undefined;
|
|
67
|
+
const labels = Array.isArray(quality?.labels) ? quality.labels : [];
|
|
68
|
+
return labels
|
|
69
|
+
.filter((label) => typeof label === "string" && label.trim().length > 0)
|
|
70
|
+
.map(normalizeToken);
|
|
71
|
+
};
|
|
72
|
+
const metadataForExample = (record) => isRecord(record.metadata) ? record.metadata : {};
|
|
73
|
+
const refMetadataToken = (ref, keys) => readString(isRecord(ref.metadata) ? ref.metadata : undefined, keys);
|
|
74
|
+
const explicitArtifactTypesForExample = (record, refs) => uniqueSorted([
|
|
75
|
+
readString(metadataForExample(record), [
|
|
76
|
+
"artifactType",
|
|
77
|
+
"artifact_type",
|
|
78
|
+
"exampleType",
|
|
79
|
+
"example_type",
|
|
80
|
+
]),
|
|
81
|
+
...refs.map((ref) => refMetadataToken(ref, ["artifactType", "artifact_type"])),
|
|
82
|
+
]).map(normalizeToken);
|
|
83
|
+
const artifactTypesForExportKind = (exportKind) => {
|
|
84
|
+
const normalized = normalizeToken(exportKind);
|
|
85
|
+
if (exportKind === "prompt-regression")
|
|
86
|
+
return [normalized, "prompt"];
|
|
87
|
+
if (exportKind === "eval-replay")
|
|
88
|
+
return [normalized, "eval_replay", "replay"];
|
|
89
|
+
if (exportKind.endsWith("-sft"))
|
|
90
|
+
return [normalized, "sft", "training"];
|
|
91
|
+
return [normalized];
|
|
92
|
+
};
|
|
93
|
+
const artifactTypesForExample = (record, refs, manifest) => uniqueSorted([
|
|
94
|
+
...explicitArtifactTypesForExample(record, refs),
|
|
95
|
+
...artifactTypesForExportKind(manifest.exportKind),
|
|
96
|
+
...refs.flatMap((ref) => [
|
|
97
|
+
ref.kind,
|
|
98
|
+
ref.mediaType,
|
|
99
|
+
ref.mimeType,
|
|
100
|
+
refMetadataToken(ref, ["artifactType", "artifact_type", "part"]),
|
|
101
|
+
]),
|
|
102
|
+
]).map(normalizeToken);
|
|
103
|
+
const artifactFilterTypesForExample = (record, refs, manifest) => {
|
|
104
|
+
const explicitTypes = explicitArtifactTypesForExample(record, refs);
|
|
105
|
+
return explicitTypes.length > 0
|
|
106
|
+
? explicitTypes
|
|
107
|
+
: artifactTypesForExportKind(manifest.exportKind).map(normalizeToken);
|
|
108
|
+
};
|
|
109
|
+
const extractNestedHash = (metadata, directKeys, nestedKeys) => {
|
|
110
|
+
const direct = readString(metadata, directKeys);
|
|
111
|
+
if (direct)
|
|
112
|
+
return direct;
|
|
113
|
+
for (const key of nestedKeys) {
|
|
114
|
+
const nested = metadata[key];
|
|
115
|
+
if (!isRecord(nested))
|
|
116
|
+
continue;
|
|
117
|
+
const hash = readString(nested, ["hash", "contentHash", "content_hash"]);
|
|
118
|
+
if (hash)
|
|
119
|
+
return hash;
|
|
120
|
+
}
|
|
121
|
+
return undefined;
|
|
122
|
+
};
|
|
123
|
+
const lineageKeyForExample = (record, refs, manifest) => {
|
|
124
|
+
const metadata = metadataForExample(record);
|
|
125
|
+
const recordId = readString(record, ["recordId", "record_id"]) ?? "";
|
|
126
|
+
return {
|
|
127
|
+
runIds: uniqueSorted([
|
|
128
|
+
readString(metadata, ["runId", "run_id"]),
|
|
129
|
+
...refs.map((ref) => ref.ownerScope?.runId),
|
|
130
|
+
]),
|
|
131
|
+
deletionGroupIds: uniqueSorted([
|
|
132
|
+
...(manifest.deletionGroupSnapshot.byRecordId[recordId] ?? []),
|
|
133
|
+
...refs.map((ref) => ref.deletionGroupId),
|
|
134
|
+
readString(metadata, ["deletionGroupId", "deletion_group_id"]),
|
|
135
|
+
]),
|
|
136
|
+
taskHash: extractNestedHash(metadata, ["taskHash", "task_hash"], ["task", "taskMetadata", "task_metadata"]),
|
|
137
|
+
promptHash: extractNestedHash(metadata, ["promptHash", "prompt_hash"], ["prompt", "promptMetadata", "prompt_metadata"]) ?? refs[0]?.contentHash,
|
|
138
|
+
toolContractHash: extractNestedHash(metadata, ["toolContractHash", "tool_contract_hash"], ["toolContract", "tool_contract", "toolMetadata", "tool_metadata"]),
|
|
139
|
+
expectedTargetHash: extractNestedHash(metadata, ["expectedTargetHash", "expected_target_hash", "targetHash", "target_hash"], ["expectedTarget", "expected_target", "target"]) ?? refs.find((ref) => ref !== refs[0])?.contentHash,
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
const dedupeKeyForLineage = (lineageKey, recordId) => {
|
|
143
|
+
const hasLineage = lineageKey.runIds.length > 0 ||
|
|
144
|
+
lineageKey.deletionGroupIds.length > 0 ||
|
|
145
|
+
Boolean(lineageKey.taskHash) ||
|
|
146
|
+
Boolean(lineageKey.promptHash) ||
|
|
147
|
+
Boolean(lineageKey.toolContractHash) ||
|
|
148
|
+
Boolean(lineageKey.expectedTargetHash);
|
|
149
|
+
return `lineage-${sha256Hex(JSON.stringify(hasLineage
|
|
150
|
+
? lineageKey
|
|
151
|
+
: { recordId })).slice(0, 24)}`;
|
|
152
|
+
};
|
|
153
|
+
const hasLabel = (labels, tokens) => labels.some((label) => tokens.some((token) => label.includes(token)));
|
|
154
|
+
const preferenceSignalsForExample = (record) => {
|
|
155
|
+
const quality = isRecord(record.quality) ? record.quality : {};
|
|
156
|
+
const metadata = metadataForExample(record);
|
|
157
|
+
const labels = labelsForExample(record);
|
|
158
|
+
const score = readNumber(quality, ["score"]);
|
|
159
|
+
const confidence = normalizeToken(readString(metadata, [
|
|
160
|
+
"confidence",
|
|
161
|
+
"confidenceBucket",
|
|
162
|
+
"confidence_bucket",
|
|
163
|
+
]) ?? "");
|
|
164
|
+
const signals = [];
|
|
165
|
+
const humanReviewed = readBoolean(quality, ["reviewed"]) === true ||
|
|
166
|
+
Boolean(readString(metadata, ["reviewId", "review_id", "reviewerId", "reviewer_id"])) ||
|
|
167
|
+
hasLabel(labels, ["human_reviewed", "reviewed", "review_approved", "review_gold"]);
|
|
168
|
+
if (humanReviewed)
|
|
169
|
+
signals.push("human_reviewed");
|
|
170
|
+
const acceptedCorrection = readBoolean(metadata, ["acceptedCorrection", "accepted_correction"]) === true ||
|
|
171
|
+
hasLabel(labels, [
|
|
172
|
+
"accepted_correction",
|
|
173
|
+
"correction_accepted",
|
|
174
|
+
"review_accepted",
|
|
175
|
+
"review_approved",
|
|
176
|
+
]) ||
|
|
177
|
+
["accepted", "approved"].includes(normalizeToken(readString(metadata, [
|
|
178
|
+
"reviewDecision",
|
|
179
|
+
"review_decision",
|
|
180
|
+
"correctionDecision",
|
|
181
|
+
"correction_decision",
|
|
182
|
+
]) ?? ""));
|
|
183
|
+
if (acceptedCorrection)
|
|
184
|
+
signals.push("accepted_correction");
|
|
185
|
+
if (confidence === "high" ||
|
|
186
|
+
hasLabel(labels, ["confidence_high", "high_confidence"]) ||
|
|
187
|
+
(score !== undefined && score >= 0.8)) {
|
|
188
|
+
signals.push("high_confidence");
|
|
189
|
+
}
|
|
190
|
+
const negativeStrength = readNumber(metadata, [
|
|
191
|
+
"negativeExampleStrength",
|
|
192
|
+
"negative_example_strength",
|
|
193
|
+
]);
|
|
194
|
+
if (readBoolean(metadata, ["strongNegative", "strong_negative"]) === true ||
|
|
195
|
+
hasLabel(labels, ["strong_negative", "negative_strong", "hard_negative"]) ||
|
|
196
|
+
negativeStrength !== undefined && negativeStrength >= 0.8) {
|
|
197
|
+
signals.push("strong_negative");
|
|
198
|
+
}
|
|
199
|
+
return Array.from(new Set(signals));
|
|
200
|
+
};
|
|
201
|
+
const priorityScoreForExample = (record, signals) => {
|
|
202
|
+
const quality = isRecord(record.quality) ? record.quality : {};
|
|
203
|
+
const score = readNumber(quality, ["score"]) ?? 0;
|
|
204
|
+
return ((signals.includes("human_reviewed") ? 1000 : 0) +
|
|
205
|
+
(signals.includes("accepted_correction") ? 800 : 0) +
|
|
206
|
+
(signals.includes("high_confidence") ? 500 : 0) +
|
|
207
|
+
(signals.includes("strong_negative") ? 400 : 0) +
|
|
208
|
+
Math.round(score * 100));
|
|
209
|
+
};
|
|
210
|
+
const purposesForExportKind = (exportKind) => {
|
|
211
|
+
const purposes = ["export"];
|
|
212
|
+
if (exportKind === "eval-replay")
|
|
213
|
+
purposes.push("eval", "replay");
|
|
214
|
+
if (exportKind.endsWith("-sft"))
|
|
215
|
+
purposes.push("training");
|
|
216
|
+
return purposes;
|
|
217
|
+
};
|
|
218
|
+
const reasonFromBlocker = (code, message, blocker, details) => ({
|
|
219
|
+
code,
|
|
220
|
+
message,
|
|
221
|
+
...(blocker.path ? { path: blocker.path } : {}),
|
|
222
|
+
details: {
|
|
223
|
+
...details,
|
|
224
|
+
privacyCode: blocker.code,
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
export const evaluateDatasetExportArtifactPayloadRead = (manifest, primaryArtifactRef) => {
|
|
228
|
+
if (!manifest.privacy) {
|
|
229
|
+
return [{
|
|
230
|
+
code: "privacy_metadata_missing",
|
|
231
|
+
message: "Export manifest privacy metadata is required before artifact payload reads.",
|
|
232
|
+
path: "$.privacy",
|
|
233
|
+
}];
|
|
234
|
+
}
|
|
235
|
+
const decision = evaluateCodaliDatasetObjectPayloadRead("export", primaryArtifactRef, manifest.privacy);
|
|
236
|
+
if (decision.allowed)
|
|
237
|
+
return [];
|
|
238
|
+
return decision.blockers.map((blocker) => reasonFromBlocker("artifact_privacy_read_disallowed", blocker.message, blocker, {
|
|
239
|
+
purpose: "export",
|
|
240
|
+
refId: primaryArtifactRef.refId,
|
|
241
|
+
}));
|
|
242
|
+
};
|
|
243
|
+
const revokedDeletionGroupIds = (manifest, explicitIds) => {
|
|
244
|
+
const metadata = isRecord(manifest.metadata) ? manifest.metadata : {};
|
|
245
|
+
const snapshot = manifest.deletionGroupSnapshot;
|
|
246
|
+
const snapshotRecord = isRecord(snapshot) ? snapshot : {};
|
|
247
|
+
return uniqueSorted([
|
|
248
|
+
...(explicitIds ?? []),
|
|
249
|
+
...stringList(metadata.revokedDeletionGroupIds),
|
|
250
|
+
...stringList(metadata.revoked_deletion_group_ids),
|
|
251
|
+
...recordList(metadata.deletionGroupRevocations)
|
|
252
|
+
.map((entry) => readString(entry, ["deletionGroupId", "deletion_group_id"])),
|
|
253
|
+
...stringList(snapshotRecord.revokedDeletionGroupIds),
|
|
254
|
+
...stringList(snapshotRecord.revoked_deletion_group_ids),
|
|
255
|
+
]);
|
|
256
|
+
};
|
|
257
|
+
const artifactTypeReasons = (artifactTypes, allowedArtifactTypes) => {
|
|
258
|
+
if (!allowedArtifactTypes || allowedArtifactTypes.length === 0)
|
|
259
|
+
return [];
|
|
260
|
+
const allowed = new Set(allowedArtifactTypes.map(normalizeToken));
|
|
261
|
+
if (artifactTypes.length === 0) {
|
|
262
|
+
return [{
|
|
263
|
+
code: "artifact_type_missing",
|
|
264
|
+
message: "Example artifact type is required by the curation filter.",
|
|
265
|
+
path: "$.metadata.artifactType",
|
|
266
|
+
details: {
|
|
267
|
+
allowedArtifactTypes: [...allowed].sort(),
|
|
268
|
+
},
|
|
269
|
+
}];
|
|
270
|
+
}
|
|
271
|
+
if (artifactTypes.some((type) => allowed.has(type)))
|
|
272
|
+
return [];
|
|
273
|
+
return [{
|
|
274
|
+
code: "artifact_type_not_allowed",
|
|
275
|
+
message: "Example artifact type is not allowed by the curation filter.",
|
|
276
|
+
path: "$.metadata.artifactType",
|
|
277
|
+
details: {
|
|
278
|
+
artifactTypes,
|
|
279
|
+
allowedArtifactTypes: [...allowed].sort(),
|
|
280
|
+
},
|
|
281
|
+
}];
|
|
282
|
+
};
|
|
283
|
+
const parseExample = (row, index, input, revokedIds) => {
|
|
284
|
+
const record = isRecord(row) ? row : {};
|
|
285
|
+
const recordId = readString(record, ["recordId", "record_id"]) ?? `row-${index + 1}`;
|
|
286
|
+
const sourceGatewayRecordId = readString(record, [
|
|
287
|
+
"sourceGatewayRecordId",
|
|
288
|
+
"source_gateway_record_id",
|
|
289
|
+
]);
|
|
290
|
+
const refs = refsForExample(record);
|
|
291
|
+
const privacy = privacyForExample(record);
|
|
292
|
+
const reasons = [];
|
|
293
|
+
if (!isRecord(row)) {
|
|
294
|
+
reasons.push({
|
|
295
|
+
code: "row_invalid",
|
|
296
|
+
message: "Curated example row must be an object.",
|
|
297
|
+
path: `$[${index}]`,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
if (!readString(record, ["recordId", "record_id"])) {
|
|
301
|
+
reasons.push({
|
|
302
|
+
code: "row_invalid",
|
|
303
|
+
message: "Curated example row must include a record id.",
|
|
304
|
+
path: `$[${index}].recordId`,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if (refs.length === 0) {
|
|
308
|
+
reasons.push({
|
|
309
|
+
code: "row_invalid",
|
|
310
|
+
message: "Curated example row must include at least one object ref.",
|
|
311
|
+
path: `$[${index}].inputRef`,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
if (!privacy) {
|
|
315
|
+
reasons.push({
|
|
316
|
+
code: "privacy_metadata_missing",
|
|
317
|
+
message: "Curated example privacy metadata is required before row object reads.",
|
|
318
|
+
path: `$[${index}].privacy`,
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
if (privacy) {
|
|
322
|
+
for (const purpose of purposesForExportKind(input.manifest.exportKind)) {
|
|
323
|
+
for (const ref of refs) {
|
|
324
|
+
const decision = evaluateCodaliDatasetObjectPayloadRead(purpose, ref, privacy);
|
|
325
|
+
if (!decision.allowed) {
|
|
326
|
+
reasons.push(...decision.blockers.map((blocker) => reasonFromBlocker("row_privacy_read_disallowed", blocker.message, blocker, {
|
|
327
|
+
purpose,
|
|
328
|
+
refId: ref.refId,
|
|
329
|
+
recordId,
|
|
330
|
+
})));
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const artifactTypes = artifactTypesForExample(record, refs, input.manifest);
|
|
336
|
+
const artifactFilterTypes = artifactFilterTypesForExample(record, refs, input.manifest);
|
|
337
|
+
reasons.push(...artifactTypeReasons(artifactFilterTypes, input.allowedArtifactTypes));
|
|
338
|
+
const lineageKey = lineageKeyForExample(record, refs, input.manifest);
|
|
339
|
+
const revokedForExample = lineageKey.deletionGroupIds.filter((id) => revokedIds.has(id));
|
|
340
|
+
if (revokedForExample.length > 0) {
|
|
341
|
+
reasons.push({
|
|
342
|
+
code: "deletion_group_revoked",
|
|
343
|
+
message: "Example lineage references a revoked deletion group.",
|
|
344
|
+
path: "$.deletionGroupSnapshot",
|
|
345
|
+
details: {
|
|
346
|
+
deletionGroupIds: revokedForExample,
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
const dedupeKey = dedupeKeyForLineage(lineageKey, recordId);
|
|
351
|
+
const preferenceSignals = preferenceSignalsForExample(record);
|
|
352
|
+
return {
|
|
353
|
+
record,
|
|
354
|
+
recordId,
|
|
355
|
+
...(sourceGatewayRecordId ? { sourceGatewayRecordId } : {}),
|
|
356
|
+
refs,
|
|
357
|
+
privacy,
|
|
358
|
+
artifactTypes,
|
|
359
|
+
lineageKey,
|
|
360
|
+
dedupeKey,
|
|
361
|
+
preferenceSignals,
|
|
362
|
+
priorityScore: priorityScoreForExample(record, preferenceSignals),
|
|
363
|
+
reasons,
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
const rejectedExample = (parsed, reasons) => ({
|
|
367
|
+
targetType: "example",
|
|
368
|
+
recordId: parsed.recordId,
|
|
369
|
+
dedupeKey: parsed.dedupeKey,
|
|
370
|
+
reasons,
|
|
371
|
+
});
|
|
372
|
+
const reasonCounts = (rejected) => {
|
|
373
|
+
const counts = {};
|
|
374
|
+
for (const item of rejected) {
|
|
375
|
+
for (const reason of item.reasons) {
|
|
376
|
+
counts[reason.code] = (counts[reason.code] ?? 0) + 1;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return counts;
|
|
380
|
+
};
|
|
381
|
+
export class DatasetEligibilityGate {
|
|
382
|
+
curate(input) {
|
|
383
|
+
const exportId = input.exportId?.trim() || input.manifest.manifestId;
|
|
384
|
+
const artifactReadReasons = evaluateDatasetExportArtifactPayloadRead(input.manifest, input.primaryArtifactRef);
|
|
385
|
+
const warnings = [];
|
|
386
|
+
const rejected = [];
|
|
387
|
+
if (artifactReadReasons.length > 0) {
|
|
388
|
+
rejected.push({
|
|
389
|
+
targetType: "artifact",
|
|
390
|
+
recordId: input.primaryArtifactRef.refId,
|
|
391
|
+
reasons: artifactReadReasons,
|
|
392
|
+
});
|
|
393
|
+
warnings.push({
|
|
394
|
+
code: "artifact_payload_read_blocked",
|
|
395
|
+
message: "Primary export artifact payload was not read because privacy metadata disallowed it.",
|
|
396
|
+
details: {
|
|
397
|
+
refId: input.primaryArtifactRef.refId,
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
const rows = artifactReadReasons.length === 0 ? input.rows ?? [] : [];
|
|
402
|
+
const revokedIds = new Set(revokedDeletionGroupIds(input.manifest, input.revokedDeletionGroupIds));
|
|
403
|
+
const parsedRows = rows.map((row, index) => parseExample(row, index, input, revokedIds));
|
|
404
|
+
const eligibleRows = [];
|
|
405
|
+
for (const parsed of parsedRows) {
|
|
406
|
+
if (parsed.reasons.length > 0) {
|
|
407
|
+
rejected.push(rejectedExample(parsed, parsed.reasons));
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
eligibleRows.push(parsed);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const accepted = [];
|
|
414
|
+
const byDedupeKey = new Map();
|
|
415
|
+
for (const parsed of eligibleRows) {
|
|
416
|
+
const group = byDedupeKey.get(parsed.dedupeKey) ?? [];
|
|
417
|
+
group.push(parsed);
|
|
418
|
+
byDedupeKey.set(parsed.dedupeKey, group);
|
|
419
|
+
}
|
|
420
|
+
for (const [dedupeKey, group] of byDedupeKey.entries()) {
|
|
421
|
+
const sorted = [...group].sort((left, right) => right.priorityScore - left.priorityScore ||
|
|
422
|
+
left.recordId.localeCompare(right.recordId));
|
|
423
|
+
const winner = sorted[0];
|
|
424
|
+
if (!winner)
|
|
425
|
+
continue;
|
|
426
|
+
accepted.push({
|
|
427
|
+
recordId: winner.recordId,
|
|
428
|
+
...(winner.sourceGatewayRecordId ? {
|
|
429
|
+
sourceGatewayRecordId: winner.sourceGatewayRecordId,
|
|
430
|
+
} : {}),
|
|
431
|
+
dedupeKey,
|
|
432
|
+
lineageKey: winner.lineageKey,
|
|
433
|
+
deletionGroupIds: winner.lineageKey.deletionGroupIds,
|
|
434
|
+
runIds: winner.lineageKey.runIds,
|
|
435
|
+
artifactTypes: winner.artifactTypes,
|
|
436
|
+
preferenceSignals: winner.preferenceSignals,
|
|
437
|
+
priorityScore: winner.priorityScore,
|
|
438
|
+
});
|
|
439
|
+
for (const duplicate of sorted.slice(1)) {
|
|
440
|
+
rejected.push(rejectedExample(duplicate, [{
|
|
441
|
+
code: "duplicate_lineage",
|
|
442
|
+
message: "Example duplicates an already accepted lineage key.",
|
|
443
|
+
details: {
|
|
444
|
+
acceptedRecordId: winner.recordId,
|
|
445
|
+
dedupeKey,
|
|
446
|
+
lineageKey: duplicate.lineageKey,
|
|
447
|
+
},
|
|
448
|
+
}]));
|
|
449
|
+
warnings.push({
|
|
450
|
+
code: "duplicate_lineage_dropped",
|
|
451
|
+
message: "Duplicate lineage example was rejected during curation.",
|
|
452
|
+
recordId: duplicate.recordId,
|
|
453
|
+
dedupeKey,
|
|
454
|
+
details: {
|
|
455
|
+
acceptedRecordId: winner.recordId,
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
accepted.sort((left, right) => right.priorityScore - left.priorityScore ||
|
|
461
|
+
left.recordId.localeCompare(right.recordId));
|
|
462
|
+
const lineageValid = !rejected.some((item) => item.reasons.some((reason) => reason.code === "deletion_group_revoked"));
|
|
463
|
+
if (!lineageValid) {
|
|
464
|
+
warnings.push({
|
|
465
|
+
code: "lineage_revoked",
|
|
466
|
+
message: "At least one curated example references a revoked deletion group.",
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
if (artifactReadReasons.length === 0 && rows.length > 0 && accepted.length === 0) {
|
|
470
|
+
warnings.push({
|
|
471
|
+
code: "no_accepted_examples",
|
|
472
|
+
message: "No examples passed the improvement eligibility gate.",
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
return {
|
|
476
|
+
schemaVersion: CODALI_IMPROVEMENT_ELIGIBILITY_GATE_SCHEMA_VERSION,
|
|
477
|
+
exportId,
|
|
478
|
+
manifestId: input.manifest.manifestId,
|
|
479
|
+
exportKind: input.manifest.exportKind,
|
|
480
|
+
artifactReadAllowed: artifactReadReasons.length === 0,
|
|
481
|
+
lineageValid,
|
|
482
|
+
totalExamples: rows.length,
|
|
483
|
+
acceptedCount: accepted.length,
|
|
484
|
+
rejectedCount: rejected.length,
|
|
485
|
+
warningCount: warnings.length,
|
|
486
|
+
acceptedRecordIds: accepted.map((item) => item.recordId),
|
|
487
|
+
rejectedRecordIds: rejected
|
|
488
|
+
.map((item) => item.recordId)
|
|
489
|
+
.filter((value) => Boolean(value)),
|
|
490
|
+
reasonCounts: reasonCounts(rejected),
|
|
491
|
+
accepted,
|
|
492
|
+
rejected,
|
|
493
|
+
warnings,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
export const curateDatasetExportForImprovement = (input) => new DatasetEligibilityGate().curate(input);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type CodaliStorageExportKind, type CodaliStorageExportManifest, type CodaliStorageObjectRef, type CodaliStorageValidationIssue } from "../storage/CodaliStorageContracts.js";
|
|
2
|
+
import type { CodaliImprovementCandidateKind } from "./ImprovementPolicy.js";
|
|
3
|
+
import { type DatasetEligibilityGateReport } from "./DatasetEligibilityGate.js";
|
|
4
|
+
export declare const CODALI_IMPROVEMENT_MANIFEST_READER_SCHEMA_VERSION: "codali.improvement.manifest_reader.v1";
|
|
5
|
+
export declare const CODALI_IMPROVEMENT_SUPPORTED_EXPORT_KINDS: readonly ["eval-replay", "model-router", "prompt-regression", "query-expander-sft", "rag-reranker"];
|
|
6
|
+
export type DatasetExportManifestReaderWarningCode = "unsupported_export_kind";
|
|
7
|
+
export interface DatasetExportManifestReaderWarning {
|
|
8
|
+
code: DatasetExportManifestReaderWarningCode;
|
|
9
|
+
message: string;
|
|
10
|
+
exportKind?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface DatasetExportManifestReaderInput {
|
|
13
|
+
exportId?: string;
|
|
14
|
+
manifestPath?: string;
|
|
15
|
+
directory?: string;
|
|
16
|
+
supportedExportKinds?: readonly CodaliStorageExportKind[];
|
|
17
|
+
allowedExampleArtifactTypes?: readonly string[];
|
|
18
|
+
revokedDeletionGroupIds?: readonly string[];
|
|
19
|
+
}
|
|
20
|
+
export interface DatasetExportArtifactPayloadSummary {
|
|
21
|
+
payloadKind: "json" | "jsonl" | "text";
|
|
22
|
+
rowCount?: number;
|
|
23
|
+
byteSize: number;
|
|
24
|
+
}
|
|
25
|
+
export interface DatasetExportVerifiedArtifact {
|
|
26
|
+
ref: CodaliStorageObjectRef;
|
|
27
|
+
path: string;
|
|
28
|
+
contentHash: string;
|
|
29
|
+
byteSize: number;
|
|
30
|
+
payloadSummary: DatasetExportArtifactPayloadSummary;
|
|
31
|
+
}
|
|
32
|
+
export interface DatasetExportCandidateProvenance {
|
|
33
|
+
schemaVersion: typeof CODALI_IMPROVEMENT_MANIFEST_READER_SCHEMA_VERSION;
|
|
34
|
+
exportId: string;
|
|
35
|
+
manifestId: string;
|
|
36
|
+
manifestPath: string;
|
|
37
|
+
exportKind: CodaliStorageExportKind;
|
|
38
|
+
exportFormat: string;
|
|
39
|
+
checksum: string;
|
|
40
|
+
recordCount: number;
|
|
41
|
+
sourceRecordIds: string[];
|
|
42
|
+
sourceGatewayRecordIds: string[];
|
|
43
|
+
sourceObjectHashes: string[];
|
|
44
|
+
deletionGroupIds: string[];
|
|
45
|
+
artifactRefs: Array<{
|
|
46
|
+
refId: string;
|
|
47
|
+
contentHash: string;
|
|
48
|
+
byteSize: number;
|
|
49
|
+
mimeType: string;
|
|
50
|
+
uri?: string;
|
|
51
|
+
}>;
|
|
52
|
+
generatedBy?: string;
|
|
53
|
+
primaryArtifactRefId: string;
|
|
54
|
+
primaryArtifactContentHash: string;
|
|
55
|
+
}
|
|
56
|
+
export interface DatasetExportImprovementCandidate {
|
|
57
|
+
candidateId: string;
|
|
58
|
+
candidateKind: CodaliImprovementCandidateKind;
|
|
59
|
+
status: "proposed";
|
|
60
|
+
sourceExportIds: string[];
|
|
61
|
+
sourceRecordIds: string[];
|
|
62
|
+
artifactIds: string[];
|
|
63
|
+
exampleCount: number;
|
|
64
|
+
objectBytes: number;
|
|
65
|
+
provenance: DatasetExportCandidateProvenance;
|
|
66
|
+
}
|
|
67
|
+
export interface DatasetExportManifestReaderResult {
|
|
68
|
+
schemaVersion: typeof CODALI_IMPROVEMENT_MANIFEST_READER_SCHEMA_VERSION;
|
|
69
|
+
exportId: string;
|
|
70
|
+
manifestPath: string;
|
|
71
|
+
manifest: CodaliStorageExportManifest;
|
|
72
|
+
primaryArtifact?: DatasetExportVerifiedArtifact;
|
|
73
|
+
primaryArtifactRows: unknown[];
|
|
74
|
+
provenance: DatasetExportCandidateProvenance;
|
|
75
|
+
candidates: DatasetExportImprovementCandidate[];
|
|
76
|
+
warnings: DatasetExportManifestReaderWarning[];
|
|
77
|
+
curationReport: DatasetEligibilityGateReport;
|
|
78
|
+
}
|
|
79
|
+
export declare class DatasetExportManifestReaderError extends Error {
|
|
80
|
+
readonly code: string;
|
|
81
|
+
readonly issues?: CodaliStorageValidationIssue[];
|
|
82
|
+
constructor(code: string, message: string, issues?: CodaliStorageValidationIssue[]);
|
|
83
|
+
}
|
|
84
|
+
export declare class DatasetExportManifestReader {
|
|
85
|
+
inspect(input: DatasetExportManifestReaderInput): Promise<DatasetExportManifestReaderResult>;
|
|
86
|
+
}
|
|
87
|
+
export declare const inspectDatasetExportManifestForImprovement: (input: DatasetExportManifestReaderInput) => Promise<DatasetExportManifestReaderResult>;
|
|
88
|
+
//# sourceMappingURL=DatasetExportManifestReader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatasetExportManifestReader.d.ts","sourceRoot":"","sources":["../../src/improvement/DatasetExportManifestReader.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EAClC,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAEL,KAAK,4BAA4B,EAClC,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,iDAAiD,EAC5D,uCAAgD,CAAC;AAEnD,eAAO,MAAM,yCAAyC,qGAMC,CAAC;AAExD,MAAM,MAAM,sCAAsC,GAC9C,yBAAyB,CAAC;AAE9B,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB,CAAC,EAAE,SAAS,uBAAuB,EAAE,CAAC;IAC1D,2BAA2B,CAAC,EAAE,SAAS,MAAM,E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