Files
reverse-engineering-anything/src/domain/browserScenarioCaptureLimits.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

68 lines
3.0 KiB
TypeScript

import { z } from "zod";
const positiveSafeInteger = z.int().safe().positive();
export const DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS = {
max_events: 10_000,
max_event_allocation_bytes: 4 * 1024 * 1024,
max_total_event_allocation_bytes: 16 * 1024 * 1024,
max_network_transactions: 1024,
max_network_body_bytes: 64 * 1024,
max_network_body_allocation_bytes: 1024 * 1024,
max_network_header_allocation_bytes: 1024 * 1024,
max_network_metadata_allocation_bytes: 1024 * 1024,
} as const;
/** Caller-selected retained-output budgets; byte values are allocation-cost estimates. */
export const browserScenarioCaptureLimitsValuesSchema = z.strictObject({
max_events: positiveSafeInteger,
max_event_allocation_bytes: positiveSafeInteger,
max_total_event_allocation_bytes: positiveSafeInteger,
max_network_transactions: positiveSafeInteger,
max_network_body_bytes: positiveSafeInteger,
max_network_body_allocation_bytes: positiveSafeInteger,
max_network_header_allocation_bytes: positiveSafeInteger,
max_network_metadata_allocation_bytes: positiveSafeInteger,
});
/** Input budgets default omitted values; output evidence uses the values schema above. */
export const browserScenarioCaptureLimitsSchema =
browserScenarioCaptureLimitsValuesSchema.extend({
max_events:
browserScenarioCaptureLimitsValuesSchema.shape.max_events.default(
DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS.max_events,
),
max_event_allocation_bytes:
browserScenarioCaptureLimitsValuesSchema.shape.max_event_allocation_bytes.default(
DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS.max_event_allocation_bytes,
),
max_total_event_allocation_bytes:
browserScenarioCaptureLimitsValuesSchema.shape.max_total_event_allocation_bytes.default(
DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS.max_total_event_allocation_bytes,
),
max_network_transactions:
browserScenarioCaptureLimitsValuesSchema.shape.max_network_transactions.default(
DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS.max_network_transactions,
),
max_network_body_bytes:
browserScenarioCaptureLimitsValuesSchema.shape.max_network_body_bytes.default(
DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS.max_network_body_bytes,
),
max_network_body_allocation_bytes:
browserScenarioCaptureLimitsValuesSchema.shape.max_network_body_allocation_bytes.default(
DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS.max_network_body_allocation_bytes,
),
max_network_header_allocation_bytes:
browserScenarioCaptureLimitsValuesSchema.shape.max_network_header_allocation_bytes.default(
DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS.max_network_header_allocation_bytes,
),
max_network_metadata_allocation_bytes:
browserScenarioCaptureLimitsValuesSchema.shape.max_network_metadata_allocation_bytes.default(
DEFAULT_BROWSER_SCENARIO_CAPTURE_LIMITS.max_network_metadata_allocation_bytes,
),
});
export type BrowserScenarioCaptureLimits = z.infer<
typeof browserScenarioCaptureLimitsValuesSchema
>;