From 653e1b8ff2a0534478bebdbf9ed88d7ea294c72e Mon Sep 17 00:00:00 2001 From: fleet lane code-b Date: Sat, 14 Nov 2026 10:09:47 -0600 Subject: [PATCH] fix(pm-stack): validate args before the sync-decision-events kill switch (#9794) parseArgs() now runs ahead of the DECISION_EVENTS_SYNC=0 return in main(), so a disabled invocation with a typo flag exits 2 with the usage error instead of silently succeeding - the operator-script contract from root AGENTS.md (Codex P1 on PR #9341). Verified: disabled+invalid -> 2, disabled+valid -> 0 no-op, enabled paths unchanged. --- pm-stack/aggregator/scripts/sync-decision-events.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pm-stack/aggregator/scripts/sync-decision-events.ts b/pm-stack/aggregator/scripts/sync-decision-events.ts index d54c6a6831..1ea54c860c 100644 --- a/pm-stack/aggregator/scripts/sync-decision-events.ts +++ b/pm-stack/aggregator/scripts/sync-decision-events.ts @@ -98,11 +98,16 @@ function parseArgs(): { files: string[]; outboxDir?: string; target?: string; st } async function main(): Promise { + // Parse first, kill switch second (#9794): the operator-script + // contract (root AGENTS.md) requires every unaccounted-for + // argument to produce a non-zero usage error, and a disabled + // invocation is not exempt — a typo'd flag must exit 2, not + // silently succeed because the sync is switched off. + const opts = parseArgs(); if (process.env.DECISION_EVENTS_SYNC === "0") { console.log("sync-decision-events: disabled by DECISION_EVENTS_SYNC=0"); return 0; } - const opts = parseArgs(); const files = opts.files.length > 0 ? [...opts.files] : [defaultDecisionEventsOutboxFile()]; if (opts.outboxDir) { const entries = await readdir(opts.outboxDir).catch(() => [] as string[]);