refactor(test): colocate pure-domain tests and reduce test debt (#471)
* refactor(test): colocate pure-domain tests and reduce test debt Move focused immutable domain/contracts/adapter tests from tests/composition/** beside their production owners under src/** as colocated *.test.ts/*.fixture.ts, and relocate persistence-shaped composition tests under tests/boundary/filesystem/**. Update import paths, the Vitest project topology (shared worker context for pure domain/contracts and recording-port service projects), the test migration ledger, testing docs, and AGENTS.md to match. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: remove test migration ledger The cutover is complete and the ledger is no longer referenced anywhere in source, scripts, or the docs gate. Drop the standalone artifact. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: clean up stale migration artifacts Remove empty directories left by the test migration and replace the "final cutover" language in docs/testing.md with standing PR guidance that no longer references the completed migration. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix: repair CI failures from schema, knip, and stale generated artifacts Three root causes fixed: 1. catalog-schemas.mjs: valuesAt only traversed anyOf from Zod's toJSONSchema, not oneOf. The webScreenshotDiffSchema change to a discriminated union produces oneOf, so the product catalog generator could not derive the web_screenshot_diff schema version. Add oneOf traversal. 2. conformancePackage.ts: the test rewrite removed the only imports of ScenarioManifest, ReplayPlan, ShimPlan, and ExpectedEvidence, making them unused exports that knip flags. Remove the dead type aliases. 3. Regenerate stale artifacts (product catalog, MCP tool catalog, skill metadata, conformance manifest) that drifted from the source changes. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
344b9b6dff
commit
e91c8c39c2
@@ -65,25 +65,49 @@ const historySchema = z.strictObject({
|
||||
.max(256),
|
||||
});
|
||||
|
||||
const storageValueSchema = z.strictObject({
|
||||
const hashedStorageValueShape = {
|
||||
value_state: z.literal("hashed"),
|
||||
value_sha256: digestSchema,
|
||||
};
|
||||
const redactedStorageValueShape = {
|
||||
value_state: z.literal("redacted-secret"),
|
||||
value_sha256: z.null(),
|
||||
};
|
||||
const storageValueFingerprintSchema = z.discriminatedUnion("value_state", [
|
||||
z.strictObject(hashedStorageValueShape),
|
||||
z.strictObject(redactedStorageValueShape),
|
||||
]);
|
||||
export type BrowserStorageValueFingerprint = z.infer<
|
||||
typeof storageValueFingerprintSchema
|
||||
>;
|
||||
|
||||
const storageValueSchema = z.discriminatedUnion("value_state", [
|
||||
z.strictObject({
|
||||
name: z.string().max(1_024),
|
||||
...hashedStorageValueShape,
|
||||
}),
|
||||
z.strictObject({
|
||||
name: z.string().max(1_024),
|
||||
...redactedStorageValueShape,
|
||||
}),
|
||||
]);
|
||||
|
||||
const cookieShape = {
|
||||
name: z.string().max(1_024),
|
||||
value_state: z.enum(["hashed", "redacted-secret"]),
|
||||
value_sha256: digestSchema.nullable(),
|
||||
});
|
||||
domain: z.string().max(2_048),
|
||||
path: z.string().max(4_096),
|
||||
secure: z.boolean(),
|
||||
http_only: z.boolean(),
|
||||
same_site: z.enum(["Strict", "Lax", "None"]),
|
||||
};
|
||||
|
||||
const storageSnapshotSchema = z.strictObject({
|
||||
cookies: z
|
||||
.array(
|
||||
z.strictObject({
|
||||
name: z.string().max(1_024),
|
||||
domain: z.string().max(2_048),
|
||||
path: z.string().max(4_096),
|
||||
secure: z.boolean(),
|
||||
http_only: z.boolean(),
|
||||
same_site: z.enum(["Strict", "Lax", "None"]),
|
||||
value_state: z.enum(["hashed", "redacted-secret"]),
|
||||
value_sha256: digestSchema.nullable(),
|
||||
}),
|
||||
z.discriminatedUnion("value_state", [
|
||||
z.strictObject({ ...cookieShape, ...hashedStorageValueShape }),
|
||||
z.strictObject({ ...cookieShape, ...redactedStorageValueShape }),
|
||||
]),
|
||||
)
|
||||
.max(512),
|
||||
local_storage: z.array(storageValueSchema).max(512),
|
||||
@@ -106,8 +130,22 @@ const eventBase = {
|
||||
};
|
||||
|
||||
const eventUrl = sanitizedBrowserUrlSchema.nullable();
|
||||
const networkEventShape = {
|
||||
...eventBase,
|
||||
method: z.string().min(1).max(32),
|
||||
url: sanitizedBrowserUrlSchema,
|
||||
resource_type: z.string().min(1).max(64),
|
||||
header_names: z.array(z.string().max(256)).max(256),
|
||||
};
|
||||
const webSocketFrameShape = {
|
||||
...eventBase,
|
||||
kind: z.enum(["websocket-frame-sent", "websocket-frame-received"]),
|
||||
url: sanitizedBrowserUrlSchema,
|
||||
payload_bytes: z.number().int().min(0),
|
||||
truncated: z.boolean(),
|
||||
};
|
||||
|
||||
export const browserScenarioEventSchema = z.discriminatedUnion("kind", [
|
||||
export const browserScenarioEventSchema = z.union([
|
||||
z.strictObject({
|
||||
...eventBase,
|
||||
kind: z.literal("console"),
|
||||
@@ -122,14 +160,22 @@ export const browserScenarioEventSchema = z.discriminatedUnion("kind", [
|
||||
stack: z.string().max(262_144).nullable(),
|
||||
}),
|
||||
z.strictObject({
|
||||
...eventBase,
|
||||
kind: z.enum(["request", "response", "request-failed"]),
|
||||
method: z.string().min(1).max(32),
|
||||
url: sanitizedBrowserUrlSchema,
|
||||
resource_type: z.string().min(1).max(64),
|
||||
status: z.number().int().min(100).max(599).nullable(),
|
||||
header_names: z.array(z.string().max(256)).max(256),
|
||||
failure: z.string().max(1_024).nullable(),
|
||||
...networkEventShape,
|
||||
kind: z.literal("request"),
|
||||
status: z.null(),
|
||||
failure: z.null(),
|
||||
}),
|
||||
z.strictObject({
|
||||
...networkEventShape,
|
||||
kind: z.literal("response"),
|
||||
status: z.number().int().min(100).max(599),
|
||||
failure: z.null(),
|
||||
}),
|
||||
z.strictObject({
|
||||
...networkEventShape,
|
||||
kind: z.literal("request-failed"),
|
||||
status: z.null(),
|
||||
failure: z.string().min(1).max(1_024),
|
||||
}),
|
||||
z.strictObject({
|
||||
...eventBase,
|
||||
@@ -137,13 +183,14 @@ export const browserScenarioEventSchema = z.discriminatedUnion("kind", [
|
||||
url: sanitizedBrowserUrlSchema,
|
||||
}),
|
||||
z.strictObject({
|
||||
...eventBase,
|
||||
kind: z.enum(["websocket-frame-sent", "websocket-frame-received"]),
|
||||
url: sanitizedBrowserUrlSchema,
|
||||
payload_type: z.enum(["text", "binary"]),
|
||||
payload_bytes: z.number().int().min(0),
|
||||
payload_text: z.string().max(65_536).nullable(),
|
||||
truncated: z.boolean(),
|
||||
...webSocketFrameShape,
|
||||
payload_type: z.literal("text"),
|
||||
payload_text: z.string().max(65_536),
|
||||
}),
|
||||
z.strictObject({
|
||||
...webSocketFrameShape,
|
||||
payload_type: z.literal("binary"),
|
||||
payload_text: z.null(),
|
||||
}),
|
||||
z.strictObject({
|
||||
...eventBase,
|
||||
@@ -182,50 +229,92 @@ const completenessSectionSchema = z.enum([
|
||||
"popups",
|
||||
"websockets",
|
||||
]);
|
||||
export type BrowserScenarioCompletenessSection = z.infer<
|
||||
typeof completenessSectionSchema
|
||||
>;
|
||||
|
||||
export const browserScenarioCompletenessSchema = z
|
||||
.strictObject({
|
||||
status: z.enum(["complete", "incomplete", "truncated"]),
|
||||
equality_eligible: z.boolean(),
|
||||
missing_sections: z.array(completenessSectionSchema),
|
||||
truncated_sections: z.array(completenessSectionSchema),
|
||||
})
|
||||
.superRefine((value, context) => {
|
||||
const expectedStatus =
|
||||
value.truncated_sections.length > 0
|
||||
? "truncated"
|
||||
: value.missing_sections.length > 0
|
||||
? "incomplete"
|
||||
: "complete";
|
||||
if (value.status !== expectedStatus)
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["status"],
|
||||
message: "Completeness status does not match section accounting",
|
||||
});
|
||||
if (value.equality_eligible !== (expectedStatus === "complete"))
|
||||
context.addIssue({
|
||||
code: "custom",
|
||||
path: ["equality_eligible"],
|
||||
message: "Missing or truncated evidence is never equality-eligible",
|
||||
});
|
||||
});
|
||||
export const browserScenarioCompletenessSchema = z.discriminatedUnion(
|
||||
"status",
|
||||
[
|
||||
z.strictObject({
|
||||
status: z.literal("complete"),
|
||||
equality_eligible: z.literal(true),
|
||||
missing_sections: z.tuple([]),
|
||||
truncated_sections: z.tuple([]),
|
||||
}),
|
||||
z.strictObject({
|
||||
status: z.literal("incomplete"),
|
||||
equality_eligible: z.literal(false),
|
||||
missing_sections: z.array(completenessSectionSchema).min(1),
|
||||
truncated_sections: z.tuple([]),
|
||||
}),
|
||||
z.strictObject({
|
||||
status: z.literal("truncated"),
|
||||
equality_eligible: z.literal(false),
|
||||
missing_sections: z.array(completenessSectionSchema),
|
||||
truncated_sections: z.array(completenessSectionSchema).min(1),
|
||||
}),
|
||||
],
|
||||
);
|
||||
export type BrowserScenarioCompleteness = z.infer<
|
||||
typeof browserScenarioCompletenessSchema
|
||||
>;
|
||||
|
||||
export const browserScenarioStepSchema = z.strictObject({
|
||||
/** Classify canonical browser-scenario completeness from section accounting. */
|
||||
export const classifyBrowserScenarioCompleteness = (
|
||||
missing: Iterable<BrowserScenarioCompletenessSection>,
|
||||
truncated: Iterable<BrowserScenarioCompletenessSection>,
|
||||
): BrowserScenarioCompleteness => {
|
||||
const missingSections = [...new Set(missing)].sort();
|
||||
const truncatedSections = [...new Set(truncated)].sort();
|
||||
if (truncatedSections.length > 0)
|
||||
return browserScenarioCompletenessSchema.parse({
|
||||
status: "truncated",
|
||||
equality_eligible: false,
|
||||
missing_sections: missingSections,
|
||||
truncated_sections: truncatedSections,
|
||||
});
|
||||
if (missingSections.length > 0)
|
||||
return browserScenarioCompletenessSchema.parse({
|
||||
status: "incomplete",
|
||||
equality_eligible: false,
|
||||
missing_sections: missingSections,
|
||||
truncated_sections: [],
|
||||
});
|
||||
return {
|
||||
status: "complete",
|
||||
equality_eligible: true,
|
||||
missing_sections: [],
|
||||
truncated_sections: [],
|
||||
};
|
||||
};
|
||||
|
||||
const browserScenarioStepShape = {
|
||||
step_index: z.number().int().min(0),
|
||||
step_id: z.string().min(1).max(64),
|
||||
action: z.string().min(1).max(64),
|
||||
status: z.enum(["completed", "failed", "cancelled"]),
|
||||
elapsed_ms: z.number().int().min(0),
|
||||
before_url: sanitizedBrowserUrlSchema,
|
||||
after_url: sanitizedBrowserUrlSchema,
|
||||
error: z.string().max(4_096).nullable(),
|
||||
event_sequence_start: z.number().int().min(1),
|
||||
event_sequence_end: z.number().int().min(0),
|
||||
artifacts: browserStepArtifactsSchema,
|
||||
completeness: browserScenarioCompletenessSchema,
|
||||
});
|
||||
};
|
||||
export const browserScenarioStepSchema = z.union([
|
||||
z.strictObject({
|
||||
...browserScenarioStepShape,
|
||||
status: z.literal("completed"),
|
||||
error: z.null(),
|
||||
}),
|
||||
z.strictObject({
|
||||
...browserScenarioStepShape,
|
||||
status: z.enum(["failed", "cancelled"]),
|
||||
error: z.string().max(4_096),
|
||||
}),
|
||||
]);
|
||||
export type BrowserScenarioStep = z.infer<typeof browserScenarioStepSchema>;
|
||||
type StepOutcome<Step> = Step extends BrowserScenarioStep
|
||||
? Pick<Step, "status" | "error">
|
||||
: never;
|
||||
export type BrowserScenarioStepOutcome = StepOutcome<BrowserScenarioStep>;
|
||||
|
||||
Reference in New Issue
Block a user