fix(native): bound retained observations and preserve failure evidence

This commit is contained in:
morluto
2026-10-09 01:55:12 +08:00
parent d6cc9ca3a6
commit 7c323870c2
15 changed files with 1045 additions and 36 deletions
@@ -0,0 +1,46 @@
import { z } from "zod";
import { nativeCallEventSchema } from "./nativeCallObservation.js";
const capturedOutputSchema = z.strictObject({
text: z.string(),
/** Bytes observed so far; the final stream size may be unknown. */
bytes: z.number().int().nonnegative(),
truncated: z.boolean(),
complete: z.boolean(),
});
/** Native call evidence retained when observation fails before a full result. */
export const nativeCallPartialObservationSchema = z.strictObject({
kind: z.literal("native-call-observation"),
target: z.strictObject({
path: z.string(),
sha256: z.string().regex(/^[0-9a-f]{64}$/u),
architecture: z.string(),
arguments: z.array(z.string()),
environment: z.record(z.string(), z.string()),
working_directory: z.string().nullable(),
}),
process: z.strictObject({
pid: z.number().int().positive().nullable(),
stdout: capturedOutputSchema.nullable(),
stderr: capturedOutputSchema.nullable(),
other_stops: z.array(z.string()),
}),
debugger: z.strictObject({ version: z.string().nullable() }),
events: z.array(nativeCallEventSchema),
coverage: z.strictObject({
status: z.literal("partial"),
reason: z.enum([
"cancelled",
"timeout",
"tracer-failure",
"capture-failure",
"cleanup-failure",
]),
}),
limitations: z.array(z.string()),
});
export type NativeCallPartialObservation = z.infer<
typeof nativeCallPartialObservationSchema
>;