Files
reverse-engineering-anything/src/domain/qlogCapture.ts
T
郭立 Guo Li 7590b50801 perf(schema): reduce retained integer validator allocations (#4360)
Construct integer formats directly while preserving bounds, refinements, metadata and current shared schema owners. Keep Incur-dependent CLI numeric coercion declarations unchanged.

Verify canonical advertisements, 126 numeric boundary cases, 974 actual CLI parser cases, broad source tests and real public-artifact SDK workflows. Record 72 normal tasks and 12 separate owned-inspector heap diagnostics with whole-family resource bounds; distinguish SDK spans and asymmetric audit overhead. Generate numerical report sections from receipts and reject stale tables through documentation conformance checks.

Closes #6236. Current-head CI and Greptile pass; actionable review findings are addressed. Codex review was unavailable due repository usage limits.
2026-10-22 05:11:08 +00:00

77 lines
2.6 KiB
TypeScript

import { z } from "zod";
const decimal = z.string().regex(/^(0|[1-9][0-9]*)$/u);
const unsignedFact = z.discriminatedUnion("state", [
z.strictObject({ state: z.literal("reported"), value: decimal }),
z.strictObject({
state: z.literal("unknown"),
reason: z.literal("omitted-null-or-redacted"),
}),
]);
const traceLocation = z.discriminatedUnion("kind", [
z.strictObject({ kind: z.literal("json-pointer"), pointer: z.string() }),
z.strictObject({
kind: z.literal("unknown"),
reason: z.literal("explicit-sensitive-value"),
}),
]);
/** Exact, source-bound transport facts; coverage never establishes network completeness. */
export const qlogCaptureFactsSchema = z.strictObject({
profile: z.literal("aioquic-1.5.0-json-0.3"),
scope: z.literal("all-recorded-events-before-selection"),
body_bytes: z.literal("not-reported"),
clock: z.strictObject({
unit: z.literal("milliseconds"),
domain: z.literal("unix-epoch"),
basis: z.literal("selected-aioquic-profile-not-producer-authentication"),
}),
traces: z.array(
z.strictObject({
trace_index: z.int().nonnegative(),
location: traceLocation,
event_count: z.int().nonnegative(),
odcid: z.string().nullable(),
vantage_point: z.enum(["client", "server"]).nullable(),
incomplete_fact_records: z.array(z.int().nonnegative()),
loss_declarations: z.array(
z.strictObject({
record_ordinal: z.int().nonnegative(),
confidence: z.literal("observed"),
packet_number: unsignedFact,
packet_type: z.string().nullable(),
packet_number_space: z
.enum(["initial", "handshake", "application"])
.nullable(),
}),
),
streams: z.array(
z.strictObject({
stream_id: decimal,
direction: z.enum(["sent", "received"]),
confidence: z.literal("derived"),
scope: z.literal("observed-stream-frame-ranges"),
contributions: z.array(
z.strictObject({
record_ordinal: z.int().nonnegative(),
frame_index: z.int().nonnegative(),
offset: decimal,
length: decimal,
fin: z.boolean().nullable(),
}),
),
covered_ranges: z.array(
z.strictObject({ start: decimal, end: decimal }),
),
unique_bytes: decimal,
frame_length_sum: decimal,
repeated_bytes: decimal,
reported_final_sizes: z.array(decimal),
}),
),
}),
),
});
export type QlogCaptureFacts = z.output<typeof qlogCaptureFactsSchema>;