fix(audit): require integer gateway window padding

Enforce non-negative integer padding_ms/--window-padding-ms across gateway window helper and live baseline capture CLI, with regression coverage for invalid values. Architecture/protocol diagrams reviewed; no updates were needed for this validation-only change.
This commit is contained in:
William Valentin
2026-02-27 13:18:37 -08:00
parent bf79f734f1
commit 0decf34760
4 changed files with 42 additions and 9 deletions
+2 -5
View File
@@ -39,7 +39,7 @@ function usage(): string {
' --backend <native|pi_embedded|...[,..]> Restrict sample to selected backends (via backend.route timeline)',
' --exclude-session-substring <text[,..]> Exclude sessions containing any substring (default: probe)',
' --auto-gateway-cancel-window Auto-select latest gateway cancel/cancelled session window',
' --window-padding-ms <number> Milliseconds added before/after auto-selected window (default: 250)',
' --window-padding-ms <integer> Milliseconds added before/after auto-selected window (default: 250)',
' --raw-identifiers Keep raw session/sender/request IDs (default: anonymized)',
' --tag <YYYY-MM-DD> Output file tag (default: current date UTC)',
' --sample-out <path> Output JSONL sample path override',
@@ -202,10 +202,7 @@ async function main(): Promise<void> {
const backendTargets = parseBackendTargets(values.backend);
const excludeSessionSubstrings = parseCsv(values['exclude-session-substring']) ?? ['probe'];
const autoGatewayCancelWindow = Boolean(values['auto-gateway-cancel-window']);
const windowPaddingMs = parseOptionalNumber(values['window-padding-ms'], '--window-padding-ms');
if (windowPaddingMs !== undefined && windowPaddingMs < 0) {
throw new Error('--window-padding-ms must be greater than or equal to 0.');
}
const windowPaddingMs = parseOptionalInteger(values['window-padding-ms'], '--window-padding-ms');
if (autoGatewayCancelWindow && (values.since || values.until)) {
throw new Error('--auto-gateway-cancel-window cannot be combined with --since/--until.');