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.
This commit is contained in:
郭立 Guo Li authored and GitHub committed 2026-10-22 05:11:08 +00:00
1 parent bd5d189a8f
commit 7590b50801
182 files changed
+9562 -1329

No files matched your search

@@ -45,13 +45,13 @@ const recordSchema = z.discriminatedUnion("kind", [
/** Complete-file coordinates authenticated before adopting any worker facts. */
export const javaScriptAnalysisTransferDescriptorSchema = z.strictObject({
bytes: z.number().int().nonnegative().max(MAX_TRANSFER_BYTES),
bytes: z.int().nonnegative().max(MAX_TRANSFER_BYTES),
sha256: digestSchema,
records: z.number().int().nonnegative(),
module_bytes: z.number().int().nonnegative(),
module_records: z.number().int().nonnegative(),
graph_bytes: z.number().int().nonnegative(),
graph_records: z.number().int().nonnegative(),
records: z.int().nonnegative(),
module_bytes: z.int().nonnegative(),
module_records: z.int().nonnegative(),
graph_bytes: z.int().nonnegative(),
graph_records: z.int().nonnegative(),
});
type Descriptor = z.output<typeof javaScriptAnalysisTransferDescriptorSchema>;
@@ -24,14 +24,14 @@ export const javaScriptCheckpointCeilingRemediation = (
/** Caller-selected artifact identity, separate from the decoded source-text digest. */
export const javaScriptWorkerRequestSchema = z.strictObject({
id: z.uuid(),
unknown_budget: z.number().int().min(0).max(JAVASCRIPT_SEMANTIC_ITEM_MAXIMUM),
node_budget: z.number().int().min(0).max(JAVASCRIPT_SEMANTIC_ITEM_MAXIMUM),
unknown_budget: z.int().min(0).max(JAVASCRIPT_SEMANTIC_ITEM_MAXIMUM),
node_budget: z.int().min(0).max(JAVASCRIPT_SEMANTIC_ITEM_MAXIMUM),
text_sha256: digestSchema,
file: z.strictObject({
path: z.string(),
sha256: digestSchema,
container_sha256: digestSchema,
bytes: z.number().int().nonnegative(),
bytes: z.int().nonnegative(),
inventory_artifact_id: z.string(),
kind: z.literal("javascript"),
unpacked: z.boolean(),
@@ -41,7 +41,7 @@ export const javaScriptWorkerRequestSchema = z.strictObject({
/** Parent admission after validated static observations have been retained. */
export const javaScriptWorkerAdmissionSchema = z.strictObject({
id: z.uuid(),
semantic_result_budget_bytes: z.number().int().nonnegative(),
semantic_result_budget_bytes: z.int().nonnegative(),
});
const identity = { id: z.uuid() };
@@ -51,7 +51,7 @@ export const javaScriptWorkerMessageSchema = z.discriminatedUnion("kind", [
z.strictObject({
kind: z.literal("ready"),
// Null when the worker runtime (Bun) does not enforce V8 heap flags.
heap_limit_bytes: z.number().int().positive().nullable(),
heap_limit_bytes: z.int().positive().nullable(),
}),
z.strictObject({
kind: z.literal("phase"),
@@ -61,7 +61,7 @@ export const javaScriptWorkerMessageSchema = z.discriminatedUnion("kind", [
z.strictObject({
kind: z.literal("static"),
...identity,
bytes: z.number().int().nonnegative(),
bytes: z.int().nonnegative(),
sha256: digestSchema,
}),
z.strictObject({
@@ -17,7 +17,7 @@ import {
const range =
javaScriptSemanticNodeSchema.shape.identity.shape.source_range.unwrap();
const count = z.number().int().nonnegative();
const count = z.int().nonnegative();
const strings = z.array(z.string());
const pathContext = z.enum(["module-specifier", "filesystem-expression"]);
const findingContext = {
+4 -7
View File
@@ -31,14 +31,11 @@ const reportSchema = z.looseObject({
}),
),
warnings: z.array(warningSchema),
total: z.number().int().nonnegative(),
failed: z.number().int().nonnegative(),
elapsed_ms: z.number().int().nonnegative(),
total: z.int().nonnegative(),
failed: z.int().nonnegative(),
elapsed_ms: z.int().nonnegative(),
});
const rangeSchema = z.tuple([
z.number().int().nonnegative(),
z.number().int().nonnegative(),
]);
const rangeSchema = z.tuple([z.int().nonnegative(), z.int().nonnegative()]);
const provenanceSchema = z.looseObject({
format: z.string(),
strategy: z.string(),
+4 -4
View File
@@ -17,8 +17,8 @@ const leafSchema = z.object({
sourcesContent: z.array(z.string().nullable()).nullable().optional(),
names: z.array(z.string()).default([]),
mappings: sourceMapMappingsSchema.regex(/^[A-Za-z0-9+/,;]*$/u),
ignoreList: z.array(z.number().int().min(0)).optional(),
x_google_ignoreList: z.array(z.number().int().min(0)).optional(),
ignoreList: z.array(z.int().min(0)).optional(),
x_google_ignoreList: z.array(z.int().min(0)).optional(),
});
const mapHeaderSchema = z.object({
version: z.literal(3),
@@ -27,8 +27,8 @@ const mapHeaderSchema = z.object({
});
const sectionSchema = z.object({
offset: z.object({
line: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
column: z.number().int().min(0).max(Number.MAX_SAFE_INTEGER),
line: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
column: z.int().min(0).max(Number.MAX_SAFE_INTEGER),
}),
map: z.unknown().optional(),
url: z.unknown().optional(),