Skip to content

aggregator(produce-charge-candidates): unknown/misspelled/joined/duplicate args silently ignored — typo'd --skip-gmial runs Gmail, typo'd/joined --start silently defaults the period #7302

Closed

Description

@dezren39

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 via process.argv.indexOf(flag) and takes the next token.
  • --skip-gmail is checked via process.argv.includes(...) in main() (: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 with ENOENT on charge-inputs-manifest.json at 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/includes construction (code-read, matching the sibling bugs): a typo'd --skip-gmial silently runs the Gmail read path the operator meant to skip; a typo'd --strat 2024-01-01 or a joined --start=2024-01-01 silently falls back to the default current-month period; a duplicate --start silently 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/--end remain 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 expectCliUsageError harness asserts exit 2, the message, no Plaid/Gmail stub calls, and no output file written) and the aggregator test suite stays green.

Activity

  1. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    effort/xsTrivial: expected under 30 minutes of work
    app/aggregatorPackage/app: aggregator (pm-stack in this repo)
    on Nov 8, 2026
  3. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

    • Agent: new-issue-creator-code-b (new-issue-creator job, lane B)
    • Session / ID: cron new-issue-creator-code-b run 2026-11-07 22:50 CST
    • Found via: filed this run; self-assigned during new-issue-creator-code-b run (guarded self-solve, lifecycle protocol §4 — trivial, clearly scoped, mirrors the settled sibling rejectUnknownArgs fixes)
    • Task: Add rejectUnknownArgs() to produce-charge-candidates.ts (exit 2 before any connector call, staged read, or file write) plus regression tests via the existing expectCliUsageError harness.
    • Expectation: effort/xs — done when the fix PR is merged, the new tests fail pre-fix and pass post-fix, and the aggregator suite stays green.
    • Links: branch creator-b/7302-produce-charges-argv (laptop worktree); probe evidence in the issue body.
  4. added
    work/self-assignedAn agent grabbed this item directly, outside the queue
    and removed on Nov 8, 2026
  5. added a commit that references this issue on Nov 8, 2026
  6. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/aggregatorPackage/app: aggregator (pm-stack in this repo)effort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions