refactor(domain): derive GPU and model coverage from the Coverage owner (#11406)

GPU discovery, AMD note, payload and kernel coverage and model header, metadata, tensor, range and storage coverage each spelled a local complete/partial enum. Every producer derives partial from the gaps it recorded, so coverage is always known; they now derive coverageStatusSchema without unknown, keeping not-requested and not-started as selection and progress states. Advertised schemas are unchanged. local-completeness-enum -9.
This commit is contained in:
morluto authored and GitHub committed 2026-11-16 03:33:20 +08:00
1 parent 897784042a
commit d1034867ff
4 files changed
+36 -22

No files matched your search

@@ -18,7 +18,7 @@
"src/domain/commandObservation.ts": 2,
"src/domain/evidenceRecordSummary.ts": 1,
"src/domain/firmware/firmwareAnalysis.ts": 1,
"src/domain/gpu/gpuCodeObjects.ts": 5,
"src/domain/gpu/gpuCodeObjects.ts": 1,
"src/domain/javascript/electronActiveObservation.ts": 1,
"src/domain/javascript/javascriptExportShapeComparisonSchemas.ts": 2,
"src/domain/javascript/javascriptFeatureTraceSchemas.ts": 2,
@@ -34,7 +34,7 @@
"src/domain/managed/managedMemberComparison.ts": 3,
"src/domain/managed/managedNativeVerificationSchemas.ts": 2,
"src/domain/managed/managedReconstruction.ts": 1,
"src/domain/model/modelArtifact.ts": 6,
"src/domain/model/modelArtifact.ts": 1,
"src/domain/native/appleIps.ts": 1,
"src/domain/native/elfUnwindRanges.ts": 1,
"src/domain/native/kernelBuildConfig.ts": 1,
+14 -8
View File
@@ -1,11 +1,19 @@
import { z } from "zod";
import { createHash } from "node:crypto";
import { digestSchema } from "../digests.js";
import { coverageStatusSchema } from "../coverage.js";
import {
absoluteLocalPathStringSchema,
localPathStringSchema,
} from "../localPath.js";
const count = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
/**
* GPU inventories report known coverage: discovery, note and payload
* producers derive `partial` from the gaps they recorded, so they never
* report `unknown`.
*/
export const gpuCoverageSchema = coverageStatusSchema.exclude(["unknown"]);
export type GpuCoverage = z.infer<typeof gpuCoverageSchema>;
export const gpuLocationSchema = z.strictObject({
container_id: z.string().nullable(),
offset: count,
@@ -40,11 +48,9 @@ export const gpuObjectSchema = z.strictObject({
flags: z.string().regex(/^0x[0-9a-f]{8}$/u),
processor: z.string().nullable(),
header_location: gpuLocationSchema,
note_coverage: z
.enum(["complete", "partial"])
.describe(
"Complete only after all declared ELF note sections were examined within supported AMD metadata coverage; partial retains only examined facts.",
),
note_coverage: gpuCoverageSchema.describe(
"Complete only after all declared ELF note sections were examined within supported AMD metadata coverage; partial retains only examined facts.",
),
notes: z.array(
z.strictObject({
target: z.string().nullable(),
@@ -175,8 +181,8 @@ export const gpuCodeObjectsObjectSchema = z.strictObject({
discovery_scope: z.literal(
"supported-section-names-and-standalone-formats",
),
discovery: z.enum(["complete", "partial"]),
payloads: z.enum(["not-requested", "complete", "partial"]),
discovery: gpuCoverageSchema,
payloads: z.enum(["not-requested", ...gpuCoverageSchema.options]),
examined_sections: count,
unknown_section_names: count,
}),
@@ -361,7 +367,7 @@ export const gpuTargetSchema = z.strictObject({
.string()
.regex(/^(?:0|[1-9][0-9]*)$/u)
.nullable(),
kernel_coverage: z.enum(["not-requested", "complete", "partial"]),
kernel_coverage: z.enum(["not-requested", ...gpuCoverageSchema.options]),
by_kind: z.strictObject({
ptx: count,
cubin: count,
+12 -5
View File
@@ -1,10 +1,17 @@
import { z } from "zod";
import { localPathStringSchema } from "../localPath.js";
import { digestSchema } from "../digests.js";
import { coverageStatusSchema } from "../coverage.js";
import { jsonValueSchema } from "../jsonValue.js";
const count = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
const decimal = z.string().regex(/^(?:0|[1-9][0-9]*)$/u);
/**
* Model reads report known coverage: header, metadata and tensor progress and
* the range and storage checks are derived from what was read, so they never
* report `unknown`.
*/
const modelCoverageSchema = coverageStatusSchema.exclude(["unknown"]);
export const modelSourceSchema = z.strictObject({
path: localPathStringSchema,
@@ -75,8 +82,8 @@ export const modelArtifactObjectSchema = z.strictObject({
header: z.literal("complete"),
tensor_data: z.literal("not-interpreted"),
array_values: z.enum(["complete", "preview"]),
tensor_ranges: z.enum(["complete", "partial"]),
storage_sizes: z.enum(["complete", "partial"]),
tensor_ranges: modelCoverageSchema,
storage_sizes: modelCoverageSchema,
}),
limitations: z.array(z.string()),
});
@@ -116,9 +123,9 @@ export const modelArtifactPartialSchema = z.strictObject({
tensor_declarations: z.array(modelArtifactPartialTensorSchema),
tensors: z.array(modelTensorSchema),
coverage: z.strictObject({
header: z.enum(["partial", "complete"]),
metadata: z.enum(["not-started", "partial", "complete"]),
tensors: z.enum(["not-started", "partial", "complete"]),
header: modelCoverageSchema,
metadata: z.enum(["not-started", ...modelCoverageSchema.options]),
tensors: z.enum(["not-started", ...modelCoverageSchema.options]),
}),
limitations: z.array(z.string()),
});
+8 -7
View File
@@ -1,4 +1,11 @@
import { decodeStrictUtf8 } from "../domain/strictUtf8.js";
import type {
GpuCoverage,
GpuCodeObjectsInput,
GpuCodeObjects,
GpuObject,
GpuKernel,
} from "../domain/gpu/gpuCodeObjects.js";
import {
CCOB_MAGIC,
CLANG_BUNDLE_MAGIC,
@@ -12,12 +19,6 @@ import { readCudaFatbinary } from "./CudaFatbinary.js";
import { decodeGpuPayload, decodeGpuPayloadStream } from "./GpuPayloadCodec.js";
import { createHash } from "node:crypto";
import { scheduler } from "node:timers/promises";
import type {
GpuCodeObjectsInput,
GpuCodeObjects,
GpuObject,
GpuKernel,
} from "../domain/gpu/gpuCodeObjects.js";
import {
BinaryFormatFailure,
BinaryResourceFailure,
@@ -65,7 +66,7 @@ export class GpuInventory {
"Static declarations only; no GPU execution, SASS disassembly, host launch correlation or runtime compatibility was verified.",
"Object IDs are positional identities scoped to artifact.sha256. Locations inside decoded objects name their containing object; they are not file offsets.",
];
discovery: "complete" | "partial" = "complete";
discovery: GpuCoverage = "complete";
examined_sections = 0;
unknown_section_names = 0;
#factBytes = 0;