Repository navigation
Description
aggregator(produce-charge-candidates): unknown/misspelled/joined/duplicate arguments silently ignored — a typo'd --strat writes candidates for the wrong (default) period, a typo'd --skip-gmal runs the Gmail read anyway, all exit 0
Summary
pm-stack/aggregator/scripts/produce-charge-candidates.ts probes argv token-by-token only: argValue() does process.argv.indexOf(flag) (:112) and the Gmail opt-out is process.argv.includes("--skip-gmail") (:454). There is no unknown-argument rejection. The value half of this script's argument contract was hardened by #3333 (trailing/flag-like values, real-calendar dates, end >= start), but the unknown-token half was left — the same residual pattern fixed in the sibling scripts by #6961 (append-usage-snapshots), #6967 (compact-usage-snapshots), #6973 (backfill-usage-snapshots), #7097 (generate-digest), #7254 (collect-github-billing), and #7289 (post-alert). Part of the #3352 "unknown means stop" family.
Evidence (verified this run, main 688f44dbe0)
Laptop probe ~/git/fleet/probe-charge-unknown-args — the real script copied verbatim (md5 5763f90fa815740affa56238690bad88, identical to the laptop primary at 688f44dbe0; src/charges-match.ts md5-matched too), Bun, PLAID_CLI/GMAIL_CLI pointed at stubs that log their arguments, CHARGE_CANDIDATES_PATH pointed at a probe-local file:
| Case | Result |
|---|---|
control: --skip-gmail --start 2026-09-01 --end 2026-09-30 --out <probe>/control.json |
exit 0; period 2026-09-01..2026-09-30; Plaid queried --start-date 2026-09-01 --end-date 2026-09-30; Gmail not called |
typo'd flag: --strat 2026-09-01 --end 2026-12-31 --skip-gmail |
exit 0; period silently became 2026-11-01..2026-12-31 (the default current-month start); Plaid queried for the wrong period; candidates file written for it |
joined flag: --start=2026-09-01 --end 2026-12-31 --skip-gmail |
exit 0; same wrong default period 2026-11-01..2026-12-31 written |
typo'd opt-out: --skip-gmal --start 2026-09-01 --end 2026-09-30 |
exit 0; the Gmail read the operator asked to skip ran anyway (two gmail +triage calls logged) |
duplicate flag: --start 2026-09-01 --start 2026-10-01 --end 2026-12-31 --skip-gmail |
exit 0; first --start silently wins (period 2026-09-01..2026-12-31), no complaint |
unknown token: --bogus with otherwise valid flags |
exit 0; silently ignored |
Why it matters
This producer writes charges-candidates.json, the live input the fleet-feed collector consumes for charge matching. The dangerous direction is silent: an operator who typos the period produces — and overwrites the candidates file with — a batch for the default period while believing they produced the requested one, and an operator who typos the Gmail opt-out triggers the connector reads they explicitly asked to skip. Nothing in the output line looks wrong; it prints the substituted period as if it were requested. The sibling scripts were all fixed for exactly this class because a misspelled flag must be a usage error, never a silent change of behavior.
Acceptance criteria
- Any argv token that is not a known flag (
--start,--end,--out,--skip-gmail) or a known flag's value is a usage error: exit 2 with a message naming the token, before any connector call or file write (mirrorsrejectUnknownArgs()inpost-alert.ts/generate-digest.ts). - Joined forms (
--start=2026-09-01) and duplicated value flags are likewise usage errors, not silently ignored / first-wins. - Known flags keep working unchanged in both modes: live mode explicit periods and staged mode (
CHARGE_INPUTS_DIRset), where--start/--endremain accepted-but-ignored per the staged-manifest contract pinned by the existing test "staged manifest period remains authoritative over CLI period flags". - Regression tests in
test/produce-charge-candidates.test.ts(the existingliveHarness/expectCliUsageErrorharness) cover: unknown token, typo'd--strat, joined--start=, duplicate--start, and typo'd--skip-gmal— each asserting exit 2, no Plaid/Gmail stub calls, and no candidates file written or overwritten; the new tests fail on the pre-fix script. - The existing
produce-charge-candidatessuite stays green.
Activity
developing-today commentedon Nov 8, 2026
CODE-2255
dezren39 commentedon Nov 8, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 8, 2026
🤖 Agent note · picked up
dezren39 commentedon Nov 8, 2026
🤖 Agent note · done (duplicate — fixed via the parallel lane's issue)
rejectUnknownArgs()now runs at the top ofmain()inscripts/produce-charge-candidates.ts, before any I/O.