Merge remote-tracking branch 'origin/main' into fix/exact-empty-graph-identities
# Conflicts: # docs/product-catalog.json # docs/verification/managed-conformance-manifest.json # skills/reverse-engineer-anything/SKILL.md # src/generatedMcpToolCatalog.ts
This commit is contained in:
@@ -216,6 +216,7 @@ const artifactStateErrorDetails = (
|
||||
operation: error.operation,
|
||||
reason: error.reason,
|
||||
...(error.reason === "limit" ? { truncated: true } : {}),
|
||||
...(error.detail === undefined ? {} : { detail: error.detail }),
|
||||
};
|
||||
if (error instanceof UnknownRegistryError) return { reason: error.reason };
|
||||
if (error instanceof EvidenceFileError)
|
||||
|
||||
@@ -28,6 +28,8 @@ export class ArtifactOperationError extends AnalysisError {
|
||||
calculatedSha256: string | null;
|
||||
unpacked: boolean;
|
||||
}>,
|
||||
/** The specific constraint that failed, such as the colliding path. */
|
||||
readonly detail?: string,
|
||||
) {
|
||||
super(
|
||||
artifactDetails === undefined
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { projectPlistValue } from "./plistValue.js";
|
||||
|
||||
it("projects plist data, dates, and non-finite reals as typed values", () => {
|
||||
expect(
|
||||
projectPlistValue({
|
||||
blob: new Uint8Array([0, 1, 2]),
|
||||
when: new Date("2020-01-01T00:00:00Z"),
|
||||
nested: [{ ratio: 0.5, missing: Number.NaN, unbounded: -Infinity }],
|
||||
plain: { "": "empty key", flag: true, count: 42 },
|
||||
}),
|
||||
).toEqual({
|
||||
value: {
|
||||
blob: { $plist_type: "data", base64: "AAEC" },
|
||||
when: { $plist_type: "date", iso8601: "2020-01-01T00:00:00.000Z" },
|
||||
nested: [
|
||||
{
|
||||
ratio: 0.5,
|
||||
missing: { $plist_type: "real", value: null },
|
||||
unbounded: { $plist_type: "real", value: null },
|
||||
},
|
||||
],
|
||||
plain: { "": "empty key", flag: true, count: 42 },
|
||||
},
|
||||
unknownRealCount: 2,
|
||||
});
|
||||
});
|
||||
|
||||
it("rejects values a plist decoder cannot produce", () => {
|
||||
expect(() => projectPlistValue({ value: Symbol("x") })).toThrow();
|
||||
const deep: unknown[] = [];
|
||||
let cursor = deep;
|
||||
for (let depth = 0; depth < 200; depth += 1) {
|
||||
const next: unknown[] = [];
|
||||
cursor.push(next);
|
||||
cursor = next;
|
||||
}
|
||||
expect(() => projectPlistValue(deep)).toThrow(RangeError);
|
||||
});
|
||||
@@ -0,0 +1,50 @@
|
||||
import { z } from "zod";
|
||||
|
||||
import type { JsonValue } from "./jsonValue.js";
|
||||
|
||||
const MAX_PLIST_DEPTH = 128;
|
||||
|
||||
/** A decoded plist projected into JSON, with values JSON cannot express. */
|
||||
export interface ProjectedPlistValue {
|
||||
readonly value: JsonValue;
|
||||
/** Reals decoded as NaN, which the decoder also uses for ±infinity. */
|
||||
readonly unknownRealCount: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Project a decoded plist into JSON. Data and dates become explicit
|
||||
* `$plist_type` objects; a non-finite real becomes an explicit unknown
|
||||
* because the XML decoder reports NaN and ±infinity alike.
|
||||
*/
|
||||
export const projectPlistValue = (value: unknown): ProjectedPlistValue => {
|
||||
let unknownRealCount = 0;
|
||||
const project = (item: unknown, depth: number): JsonValue => {
|
||||
if (depth > MAX_PLIST_DEPTH)
|
||||
throw new RangeError(
|
||||
`Plist exceeds ${String(MAX_PLIST_DEPTH)} nesting levels`,
|
||||
);
|
||||
if (item instanceof Uint8Array)
|
||||
return {
|
||||
$plist_type: "data",
|
||||
base64: Buffer.from(item).toString("base64"),
|
||||
};
|
||||
if (item instanceof Date)
|
||||
return { $plist_type: "date", iso8601: item.toISOString() };
|
||||
if (typeof item === "number" && !Number.isFinite(item)) {
|
||||
unknownRealCount += 1;
|
||||
return { $plist_type: "real", value: null };
|
||||
}
|
||||
if (Array.isArray(item))
|
||||
return item.map((entry: unknown) => project(entry, depth + 1));
|
||||
if (item !== null && typeof item === "object")
|
||||
return Object.fromEntries(
|
||||
Object.entries(item).map(([key, entry]) => [
|
||||
key,
|
||||
project(entry, depth + 1),
|
||||
]),
|
||||
);
|
||||
return z.union([z.string(), z.number(), z.boolean(), z.null()]).parse(item);
|
||||
};
|
||||
const projected = project(value, 0);
|
||||
return { value: projected, unknownRealCount };
|
||||
};
|
||||
@@ -4,43 +4,8 @@ import {
|
||||
parseArtifactInventoryEvidence,
|
||||
tryAssembleInventorySet,
|
||||
} from "./artifactInventoryEvidence.js";
|
||||
import { EvidenceReferenceError } from "./evidenceErrors.js";
|
||||
import type { ReferenceSourceReaderError } from "../reference/ReferenceSourceReaderTypes.js";
|
||||
|
||||
/**
|
||||
* The three validation taxonomies and their disjoint codes:
|
||||
* - Filesystem reader: cancelled | invalid-root | io | unsupported
|
||||
* (per-entry: cancelled | changed | io | symlink | unsupported).
|
||||
* - Session evidence references: missing | wrong_operation |
|
||||
* wrong_predicate | identity_mismatch.
|
||||
* - Inventory assembly: TypeError strings, migrating to Result leaves
|
||||
* starting with the empty-pages code below.
|
||||
*/
|
||||
const readerCodes: readonly ReferenceSourceReaderError["code"][] = [
|
||||
"cancelled",
|
||||
"invalid-root",
|
||||
"io",
|
||||
"unsupported",
|
||||
];
|
||||
|
||||
const referenceReasons = (
|
||||
[
|
||||
"missing",
|
||||
"wrong_operation",
|
||||
"wrong_predicate",
|
||||
"identity_mismatch",
|
||||
] as const
|
||||
).map(
|
||||
(reason) =>
|
||||
new EvidenceReferenceError("ev_test", reason, "expected", null).reason,
|
||||
);
|
||||
|
||||
describe("validation taxonomy mapping", () => {
|
||||
it("keeps session reference reasons disjoint from reader codes", () => {
|
||||
for (const reason of referenceReasons)
|
||||
expect(readerCodes).not.toContain(reason);
|
||||
});
|
||||
|
||||
describe("inventory validation failure channels", () => {
|
||||
it("returns the empty-pages leaf as Result without throwing", () => {
|
||||
const result = tryAssembleInventorySet([]);
|
||||
expect(result).toEqual({
|
||||
|
||||
Reference in New Issue
Block a user