refactor(snapshots): derive workflow entries from canonical schema

This commit is contained in:
morluto committed 2026-10-26 14:04:39 +08:00
1 parent 52976ac5cd
commit 72fa15a509
2 files changed
+45 -12

No files matched your search

+43
View File
@@ -73,6 +73,49 @@ const snapshotWithHistoricalEvidence = () => {
};
};
describe("analysis snapshot entry admission", () => {
it("preserves provider entries without profiles and requires profiles on workflow entries", () => {
const { snapshot } = snapshotWithHistoricalEvidence();
const entry = snapshot.entries[0];
if (entry === undefined) throw new Error("Missing fixture query");
const providerSchema = analysisSnapshotSchema.shape.entries.element;
const workflowSchema =
analysisSnapshotSchema.shape.workflow_entries.element;
expect(providerSchema.parse(entry)).toEqual(entry);
expect(workflowSchema.safeParse(entry).success).toBe(false);
const workflow = {
...entry,
execution: {
...entry.execution,
analysis_profile: snapshot.binding.analysis_profile,
},
};
expect(workflowSchema.parse(workflow)).toEqual(workflow);
for (const schema of [providerSchema, workflowSchema]) {
expect(
schema.safeParse({
...workflow,
execution: { ...workflow.execution, provider: undefined },
}).success,
).toBe(false);
}
expect(
providerSchema.parse({
...workflow,
unknown_entry: true,
execution: { ...workflow.execution, unknown_execution: true },
}),
).toEqual(entry);
expect(
workflowSchema.parse({
...workflow,
unknown_entry: true,
execution: { ...workflow.execution, unknown_execution: true },
}),
).toEqual(workflow);
});
});
describe("analysis snapshot target identity", () => {
it.each(RAW_ONLY_ARCHITECTURES)(
"keeps %s confined to executable raw snapshots",
+2 -12
View File
@@ -170,19 +170,9 @@ const entrySchema = z.object({
subject: subjectSchema.nullable(),
}),
});
const workflowEntrySchema = z.object({
query_id: prefixedDigestSchema("query"),
operation: z.string().min(1),
parameters: jsonObjectSchema,
execution: z.object({
result: jsonValueSchema,
raw_result: jsonValueSchema.nullable(),
provider: committedProviderSchema,
const workflowEntrySchema = entrySchema.extend({
execution: entrySchema.shape.execution.extend({
analysis_profile: analysisProfileSchema,
limitations: z.array(z.string()),
relationship_coverage: relationshipCoverageSchema.nullable(),
locations: z.array(evidenceLocationSchema),
subject: subjectSchema.nullable(),
}),
});