refactor(domain): encode comparison and lifecycle states exactly (#473)
* refactor(domain): encode comparison states exactly * refactor(domain): make evidence lifecycles explicit * refactor(browser): parse capture states once * test: prefer behavior over implementation seams * chore: refresh schema-derived metadata * test(process): preserve lifecycle cleanup coverage * test(hopper): bind rename cache coverage to dispatch
This commit is contained in:
@@ -2,8 +2,6 @@ import { z } from "zod";
|
||||
|
||||
const comparisonStatusSchema = z.enum([
|
||||
"unchanged",
|
||||
"added",
|
||||
"removed",
|
||||
"changed",
|
||||
"truncated",
|
||||
"unknown",
|
||||
@@ -36,32 +34,60 @@ const textDeltaSchema = z.object({
|
||||
hunks: z.number().int().min(0),
|
||||
});
|
||||
|
||||
const functionDimensionSchema = z.object({
|
||||
const functionDimensionContextShape = {
|
||||
dimension: dimensionNameSchema,
|
||||
status: comparisonStatusSchema,
|
||||
left_digest: digestSchema.nullable(),
|
||||
right_digest: digestSchema.nullable(),
|
||||
left_count: z.number().int().min(0).nullable(),
|
||||
right_count: z.number().int().min(0).nullable(),
|
||||
text_delta: textDeltaSchema.nullable(),
|
||||
conclusion_kind: z.enum([
|
||||
"derived_relationship",
|
||||
"contradiction",
|
||||
"unresolved_branch",
|
||||
]),
|
||||
evidence_links: z.array(evidenceIdSchema).min(2).max(200),
|
||||
limitations: z.array(z.string()),
|
||||
});
|
||||
};
|
||||
|
||||
const functionDimensionSchema = z.union([
|
||||
z.object({
|
||||
...functionDimensionContextShape,
|
||||
status: z.literal("unchanged"),
|
||||
left_digest: digestSchema,
|
||||
right_digest: digestSchema,
|
||||
text_delta: textDeltaSchema.nullable(),
|
||||
conclusion_kind: z.literal("derived_relationship"),
|
||||
}),
|
||||
z.object({
|
||||
...functionDimensionContextShape,
|
||||
status: z.literal("changed"),
|
||||
left_digest: digestSchema,
|
||||
right_digest: digestSchema,
|
||||
text_delta: textDeltaSchema.nullable(),
|
||||
conclusion_kind: z.enum(["derived_relationship", "contradiction"]),
|
||||
}),
|
||||
z.object({
|
||||
...functionDimensionContextShape,
|
||||
status: z.enum(["truncated", "unknown"]),
|
||||
left_digest: z.null(),
|
||||
right_digest: z.null(),
|
||||
text_delta: z.null(),
|
||||
conclusion_kind: z.literal("unresolved_branch"),
|
||||
}),
|
||||
]);
|
||||
|
||||
const functionMatchSchema = z.union([
|
||||
z.object({
|
||||
status: z.literal("matched"),
|
||||
method: z.literal("symbol"),
|
||||
left_name: z.string(),
|
||||
right_name: z.string(),
|
||||
}),
|
||||
z.object({
|
||||
status: z.enum(["mismatched", "ambiguous"]),
|
||||
method: z.literal("explicit"),
|
||||
left_name: z.string(),
|
||||
right_name: z.string(),
|
||||
}),
|
||||
]);
|
||||
|
||||
/** Deterministic dimension-classified function comparison Evidence payload. */
|
||||
export const functionComparisonResultSchema = z.object({
|
||||
status: comparisonStatusSchema,
|
||||
function_match: z.object({
|
||||
status: z.enum(["matched", "mismatched", "ambiguous", "unknown"]),
|
||||
method: z.enum(["explicit", "symbol"]),
|
||||
left_name: z.string(),
|
||||
right_name: z.string(),
|
||||
}),
|
||||
function_match: functionMatchSchema,
|
||||
left_subject_sha256: digestSchema,
|
||||
right_subject_sha256: digestSchema,
|
||||
summary: z.object({
|
||||
|
||||
Reference in New Issue
Block a user