feat(lab): publish E37 R0 acceptance result
This commit is contained in:
@@ -89,12 +89,56 @@ export interface E33LaboratoryResult {
|
||||
access: "read-only";
|
||||
}
|
||||
|
||||
export interface E37AcceptanceContractResult {
|
||||
resultId: string;
|
||||
createdAtUtc: string | null;
|
||||
sourceSessionId: string;
|
||||
sourceDisplayName: string;
|
||||
status: "accepted-r0-source-scoped-contract";
|
||||
profileId: string;
|
||||
workerNode: string;
|
||||
metrics: {
|
||||
reviewedItems: number;
|
||||
developmentItems: number;
|
||||
validationItems: number;
|
||||
engineeringItems: number;
|
||||
humanExceptionItems: number;
|
||||
terminalOutcomes: number;
|
||||
accountingFraction: number;
|
||||
falseFreeClaims: number;
|
||||
};
|
||||
dimensionDistributions: {
|
||||
presence: Readonly<Record<string, number>>;
|
||||
geometryAssociation: Readonly<Record<string, number>>;
|
||||
freshness: Readonly<Record<string, number>>;
|
||||
};
|
||||
severityDistribution: Readonly<Record<string, number>>;
|
||||
labelProvenance: {
|
||||
engineeringItems: number;
|
||||
humanExceptionItems: number;
|
||||
independentGroundTruth: false;
|
||||
};
|
||||
split: {
|
||||
strategy: string;
|
||||
validationFraction: number;
|
||||
};
|
||||
targets: {
|
||||
presenceTarget: number;
|
||||
geometryAssociationTarget: number;
|
||||
freshnessTarget: number;
|
||||
};
|
||||
qualityTargetEvaluated: false;
|
||||
limitations: readonly string[];
|
||||
access: "read-only";
|
||||
}
|
||||
|
||||
export interface AdvancedLaboratoryResults {
|
||||
e31: E31LaboratoryResult | null;
|
||||
e32: E32LaboratoryResult | null;
|
||||
e33: E33LaboratoryResult | null;
|
||||
e34: E34TemporalLayerResult | null;
|
||||
e35: E35DegradationRecoveryResult | null;
|
||||
e37: E37AcceptanceContractResult | null;
|
||||
}
|
||||
|
||||
export class AdvancedLaboratoryContractError extends Error {
|
||||
@@ -181,6 +225,19 @@ function strings(value: unknown, label: string): readonly string[] {
|
||||
return value.map((item, index) => stringValue(item, `${label}[${index}]`));
|
||||
}
|
||||
|
||||
function numberRecord(
|
||||
value: unknown,
|
||||
label: string,
|
||||
): Readonly<Record<string, number>> {
|
||||
const source = record(value, label);
|
||||
return Object.fromEntries(
|
||||
Object.entries(source).map(([key, item]) => [
|
||||
key,
|
||||
integerValue(item, `${label}.${key}`),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
function contentId(value: unknown, prefix: string, label: string): string {
|
||||
const parsed = stringValue(value, label);
|
||||
if (!new RegExp(`^${prefix}-[a-f0-9]{64}$`).test(parsed)) {
|
||||
@@ -349,6 +406,139 @@ function parseE33(value: unknown): E33LaboratoryResult {
|
||||
};
|
||||
}
|
||||
|
||||
function parseE37(value: unknown): E37AcceptanceContractResult {
|
||||
const item = record(value, "E37");
|
||||
const metrics = record(item.metrics, "E37.metrics");
|
||||
const distributions = record(
|
||||
item.dimension_distributions,
|
||||
"E37.dimension_distributions",
|
||||
);
|
||||
const provenance = record(item.label_provenance, "E37.label_provenance");
|
||||
const split = record(item.split, "E37.split");
|
||||
const targets = record(item.targets, "E37.targets");
|
||||
diagnosticAuthority(item.authority, "E37.authority");
|
||||
if (item.quality_target_evaluated !== false) {
|
||||
throw new AdvancedLaboratoryContractError(
|
||||
"E37.quality_target_evaluated: R0 не должен объявлять метрику проверенной.",
|
||||
);
|
||||
}
|
||||
if (provenance.independent_ground_truth !== false) {
|
||||
throw new AdvancedLaboratoryContractError(
|
||||
"E37.label_provenance: R0 не является независимой разметкой.",
|
||||
);
|
||||
}
|
||||
return {
|
||||
resultId: contentId(
|
||||
item.result_id,
|
||||
"e37-ravnoves-acceptance",
|
||||
"E37.result_id",
|
||||
),
|
||||
createdAtUtc: optionalString(item.created_at_utc, "E37.created_at_utc"),
|
||||
sourceSessionId: stringValue(
|
||||
item.source_session_id,
|
||||
"E37.source_session_id",
|
||||
),
|
||||
sourceDisplayName: stringValue(
|
||||
item.source_display_name,
|
||||
"E37.source_display_name",
|
||||
),
|
||||
status: exactString(
|
||||
item.status,
|
||||
"accepted-r0-source-scoped-contract",
|
||||
"E37.status",
|
||||
),
|
||||
profileId: stringValue(item.profile_id, "E37.profile_id"),
|
||||
workerNode: stringValue(item.worker_node, "E37.worker_node"),
|
||||
metrics: {
|
||||
reviewedItems: integerValue(
|
||||
metrics.reviewed_items,
|
||||
"E37.metrics.reviewed_items",
|
||||
),
|
||||
developmentItems: integerValue(
|
||||
metrics.development_items,
|
||||
"E37.metrics.development_items",
|
||||
),
|
||||
validationItems: integerValue(
|
||||
metrics.validation_items,
|
||||
"E37.metrics.validation_items",
|
||||
),
|
||||
engineeringItems: integerValue(
|
||||
metrics.engineering_items,
|
||||
"E37.metrics.engineering_items",
|
||||
),
|
||||
humanExceptionItems: integerValue(
|
||||
metrics.human_exception_items,
|
||||
"E37.metrics.human_exception_items",
|
||||
),
|
||||
terminalOutcomes: integerValue(
|
||||
metrics.terminal_outcomes,
|
||||
"E37.metrics.terminal_outcomes",
|
||||
),
|
||||
accountingFraction: numberValue(
|
||||
metrics.accounting_fraction,
|
||||
"E37.metrics.accounting_fraction",
|
||||
),
|
||||
falseFreeClaims: integerValue(
|
||||
metrics.false_free_claims,
|
||||
"E37.metrics.false_free_claims",
|
||||
),
|
||||
},
|
||||
dimensionDistributions: {
|
||||
presence: numberRecord(
|
||||
distributions.presence,
|
||||
"E37.dimension_distributions.presence",
|
||||
),
|
||||
geometryAssociation: numberRecord(
|
||||
distributions.geometry_association,
|
||||
"E37.dimension_distributions.geometry_association",
|
||||
),
|
||||
freshness: numberRecord(
|
||||
distributions.freshness,
|
||||
"E37.dimension_distributions.freshness",
|
||||
),
|
||||
},
|
||||
severityDistribution: numberRecord(
|
||||
item.severity_distribution,
|
||||
"E37.severity_distribution",
|
||||
),
|
||||
labelProvenance: {
|
||||
engineeringItems: integerValue(
|
||||
provenance.engineering_items,
|
||||
"E37.label_provenance.engineering_items",
|
||||
),
|
||||
humanExceptionItems: integerValue(
|
||||
provenance.human_exception_items,
|
||||
"E37.label_provenance.human_exception_items",
|
||||
),
|
||||
independentGroundTruth: false,
|
||||
},
|
||||
split: {
|
||||
strategy: stringValue(split.strategy, "E37.split.strategy"),
|
||||
validationFraction: numberValue(
|
||||
split.validation_fraction,
|
||||
"E37.split.validation_fraction",
|
||||
),
|
||||
},
|
||||
targets: {
|
||||
presenceTarget: numberValue(
|
||||
targets.presence_target,
|
||||
"E37.targets.presence_target",
|
||||
),
|
||||
geometryAssociationTarget: numberValue(
|
||||
targets.geometry_association_target,
|
||||
"E37.targets.geometry_association_target",
|
||||
),
|
||||
freshnessTarget: numberValue(
|
||||
targets.freshness_target,
|
||||
"E37.targets.freshness_target",
|
||||
),
|
||||
},
|
||||
qualityTargetEvaluated: false,
|
||||
limitations: strings(item.limitations, "E37.limitations"),
|
||||
access: exactString(item.access, "read-only", "E37.access"),
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchOne<T>(
|
||||
path: string,
|
||||
parser: (value: unknown) => T,
|
||||
@@ -373,14 +563,15 @@ export async function fetchAdvancedLaboratoryResults({
|
||||
fetcher?: LaboratoryFetch;
|
||||
signal?: AbortSignal;
|
||||
} = {}): Promise<AdvancedLaboratoryResults> {
|
||||
const [e31, e32, e33, e34, e35] = await Promise.all([
|
||||
const [e31, e32, e33, e34, e35, e37] = await Promise.all([
|
||||
fetchOne("/api/v1/laboratory/e31/results?limit=1", parseE31, fetcher, signal),
|
||||
fetchOne("/api/v1/laboratory/e32/results?limit=1", parseE32, fetcher, signal),
|
||||
fetchOne("/api/v1/laboratory/e33/results?limit=1", parseE33, fetcher, signal),
|
||||
fetchE34TemporalLayerResult({ fetcher, signal }),
|
||||
fetchE35DegradationRecoveryResult({ fetcher, signal }),
|
||||
fetchOne("/api/v1/laboratory/e37/results?limit=1", parseE37, fetcher, signal),
|
||||
]);
|
||||
return { e31, e32, e33, e34, e35 };
|
||||
return { e31, e32, e33, e34, e35, e37 };
|
||||
}
|
||||
import {
|
||||
fetchE34TemporalLayerResult,
|
||||
|
||||
Reference in New Issue
Block a user