Repository navigation
Description
Problem
pm-stack/aggregator/scripts/produce-charge-candidates.ts — the producer that writes the charge candidates the daily collector matches against real money movement — has no unknown-argument rejection. Argv is probed token-by-token only:
argValue()(produce-charge-candidates.ts:112-114) finds a flag viaprocess.argv.indexOf(flag)and takes the next token.--skip-gmailis checked viaprocess.argv.includes(...)inmain()(:454).
Every other aggregator operator script has been given a strict rejectUnknownArgs() contract that exits 2 before any I/O (append-usage-snapshots #6961, compact-usage-snapshots #6967, backfill-usage-snapshots #6973, generate-digest #7097, collect-github-billing #7254, post-alert #7289, collect-fleet-feed #3352/#3509). This producer — the one that calls the Plaid and Gmail connector CLIs and writes charges-candidates.json — is the remaining exception.
Evidence (verified this run, laptop @ cf39c3a)
Staged mode against an empty CHARGE_INPUTS_DIR (any argv rejection would exit 2 with a usage error before touching the staged files):
bun run scripts/produce-charge-candidates.ts --bogus-flag→ proceeds into staged I/O and dies withENOENToncharge-inputs-manifest.jsonat produce-charge-candidates.ts:424 — the unknown flag was silently ignored, exactly like the control run with the valid--skip-gmail.- By the same
indexOf/includesconstruction (code-read, matching the sibling bugs): a typo'd--skip-gmialsilently runs the Gmail read path the operator meant to skip; a typo'd--strat 2024-01-01or a joined--start=2024-01-01silently falls back to the default current-month period; a duplicate--startsilently takes the first value.
Why it matters
This script's output feeds the charges auto-matcher (admission rule #3161: a candidate exists only where money demonstrably moved). A silently wrong period or an unexpectedly-run Gmail pass produces a plausible-looking candidates file for the wrong window under a success-style run — the operator has no signal anything was mistyped. The sibling fixes established that "exit 2 before any connector call or file write" is the house contract for exactly this failure mode; the existing test file already has the harness for it (liveHarness() + expectCliUsageError() in test/produce-charge-candidates.test.ts, used for the date validations).
Acceptance criteria
- Unknown, misspelled, joined (
--start=...), duplicate, and positional arguments exit 2 with a usage error before any connector CLI call, staged-file read, or candidates-file write (in both live and staged modes;--start/--endremain accepted-and-ignored in staged mode, as documented). - Documented forms keep working:
[--start YYYY-MM-DD] [--end YYYY-MM-DD] [--out <path>] [--skip-gmail], with the existing value validations (aggregator(charges-producer): staged mode never validates the manifest period — a field-less manifest writes a candidates file with period {} and exits 0 #4663, real-calendar-date, ordering) unchanged. - Regression tests added (the existing
expectCliUsageErrorharness asserts exit 2, the message, no Plaid/Gmail stub calls, and no output file written) and the aggregator test suite stays green.
Activity
developing-today commentedon Nov 8, 2026
CODE-2256
dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up
Merge pull request #7304 from developing-today/creator-b/7302-produce…
dezren39 commentedon Nov 8, 2026
🤖 Agent note · done