GeezerVison is showing github.com — aggregator(charges-producer): staged mode falls back to the live Gmail CLI when gmail-triage.json is short — the whole Gmail source is silently dropped and the run exits 0 · Issue #4660 · developing-today/code
aggregator(charges-producer): staged mode falls back to the live Gmail CLI when gmail-triage.json is short — the whole Gmail source is silently dropped and the run exits 0 #4660DescriptionProblem
The charge-candidates producer's new staged mode (#4641, commit 7757c2e) is supposed to run on the laptop, where the Plaid/Gmail connector CLIs do not live, reading only staged inputs. But the Gmail triage loop falls back to the live CLI for any query whose staged response is missing:
pm-stack/aggregator/scripts/produce-charge-candidates.ts:286-298 — stagedResponses[i] ?? (await run(GMAIL_CLI, ["gmail", "+triage", ...])). gmail-triage.json is documented as "the two +triage responses, in query order", but nothing checks that both are present.
- On the laptop the default
GMAIL_CLI (/opt/hatch/bin/hatch_gws_cli) does not exist, so the fallback throws ENOENT, gmailCandidates rejects as a whole, and main's catch (:402, "gmail read failed …; plaid candidates only") swallows it: the run exits 0 and writes a candidates file with the entire Gmail source missing — including messages the staging did deliver.
- This contradicts the staged contract the same change documents at
:66-69 (stagedText): "a stale or absent staging must fail visibly, never silently produce an empty batch." A short staging is exactly stale/absent staging, and the batch it produces is silently partial instead: the daily collector consumes it as the period's complete candidate set, so that period's Gmail charges simply never match.
The Plaid path does not have this flaw: a missing plaid-transactions.json throws out of plaidCandidates, which main does not catch, so the run fails visibly. The Gmail triage path is the inconsistent one. (Missing gmail-bodies.json is different and correct by design: bodies are requested via gmail-body-requests.json for a later run.)
Evidence (verified this run, laptop probe at origin/main 17610f5)
Probe: ~/git/fleet/probe-2026-11-02-laneB-chargestaged/ on the laptop — the producer extracted verbatim from origin/main (script md5 70bff805), staged inputs for period 2026-11-01..2026-11-02 with one Plaid transaction (Coffee Shop $12.34) and one Gmail receipt ("Your Bakery order receipt $9.99").
- CONTROL —
gmail-triage.json = both responses staged: exit 0, 2 candidates (gmail Bakery $9.99 + plaid Coffee Shop $12.34), gmail skipped 0.
- PROBE —
gmail-triage.json = only the first of the two responses staged: stderr producer: gmail read failed (ENOENT: no such file or directory, posix_spawn '/opt/hatch/bin/hatch_gws_cli'); plaid candidates only, exit 0, output file contains only the Plaid candidate. The staged Gmail message was discarded along with the unstaged query.
Related: #4641 (the staged-mode split this defect ships in), #2448 (a different whole-batch Gmail discard, fixed — same failure shape, different cause).
Acceptance criteria
- In staged mode (
CHARGE_INPUTS_DIR set), the producer never invokes the Plaid/Gmail CLIs, for any input.
- A
gmail-triage.json that is missing, unparseable, or holds fewer responses than the producer issues queries fails the run visibly (non-zero exit, no candidates file written or the file clearly marked failed) instead of producing a plaid-only batch with exit 0.
- With complete staging, output is unchanged from today (control case above: both sources' candidates present).
- Live mode (env unset) is unchanged.
- A regression test or scripted fixture covers the short-staging case.
Activityadded kind/bugSomething isn't working (prefixed form of the classic bug label) task/triageQueue packet kind: verify, reproduce, and route this item effort/sSmall: expected under 2 hours of work on Nov 2, 2026dezren39 commented on Nov 2, 2026 🤖 Agent note · filed
- Agent: new-issue-creator job (lane B, new-issue-creator-code-b)
- Session / ID: cron new-issue-creator-code-b, run 2026-11-02 17:20 CST
- Found via: filed this run
- Task: Filed after verifying on the laptop (probe
probe-2026-11-02-laneB-chargestaged @ origin/main 17610f5): with only 1 of the 2 staged Gmail triage responses present, staged mode shells out to the absent live Gmail CLI, the whole Gmail source is dropped, and the producer still exits 0 writing a plaid-only candidates file.
- Expectation: effort/s — triage confirms the staged-mode CLI fallback and routes the fix (staged mode never invokes the CLIs; short staging fails visibly).
- Links: queue packet
creator-b-2026-11-02-1720/packets/packet-4660-triage.json (enqueued to repo-health-code-pilot)
dezren39 commented on Nov 3, 2026 🤖 Agent note · picked up (resume)
dezren39 commented on Nov 3, 2026
Agent note — done (queue worker, lane code-e)
- Agent: queue worker (repo-worker-code), lane code-e
- Session / ID: queue task 6625, completed 2026-11-03
- Outcome: merged PR fix(aggregator): staged mode never falls back to the live Gmail CLI; short staging fails visibly (#4660) #4671 (merge 10e4ec1); issue auto-closed by the PR. Resumed from the prior lane's implementation_complete checkpoint — branch and tests were already pushed; this lane opened the PR once the GitHub write throttle cleared, dispositioned Codex, and merged.
- Validation: bun test test/produce-charge-candidates.test.ts — 26 pass, 0 fail (prior lane, laptop; includes the 2 new staged-mode regression tests: short staging fails non-zero with no candidates file, complete staging yields both candidates). Codex review of 9d93373: no findings. PR guard check never left QUEUED (fleet runner backlog); merged under standing merge authority.
dezren39 commented on Nov 3, 2026 🤖 Agent note · done
- Agent: queue worker (repo-worker-code), lane L (code-l)
- Session / ID: task 6614
- Found via: queue claim
- Task: Triage of issue aggregator(charges-producer): staged mode falls back to the live Gmail CLI when gmail-triage.json is short — the whole Gmail source is silently dropped and the run exits 0 #4660 — staged charges producer falls back to the live Gmail CLI on short staging.
- Verdict: CONFIRMED as scoped. Re-verified fresh 2026-11-02T23:35Z against current main
17610f5553de6bbb4d3204a29f9e588bd59c5af6 (unchanged from the creator probe): pm-stack/aggregator/scripts/produce-charge-candidates.ts:286-298 parses gmail-triage.json into stagedResponses and uses stagedResponses[i] ?? live run(GMAIL_CLI, +triage) with no length check (the queries array has exactly 2 entries); main at :388-404 catches the resulting gmail failure and writes a plaid-only candidates file with exit 0. One sharpening for the fix: in staged mode any gmail error is swallowed by that catch today — missing and unparseable staging included, not just short staging — so the fix must make staged-mode gmail failures fail the run, not only add the length check. The Plaid path is safe only because stagedText throws on a missing file in staged mode, and the gmail body-read path (:334-341) is already INPUTS_DIR-guarded; both are named out of scope in the fix packet.
- Routing: implementation follow-up enqueued as task 6625 (small_fix, acceptance criteria from issue aggregator(charges-producer): staged mode falls back to the live Gmail CLI when gmail-triage.json is short — the whole Gmail source is silently dropped and the run exits 0 #4660 intact, plus the staged-mode catch fix above). No PR opened in this triage task, per its scope.
- Expectation: effort/s fix; done = short/missing/unparseable staging fails visibly (non-zero, no complete candidates file), complete-staging control unchanged, live mode unchanged, regression fixture for the short case.
- Links: task 6625; issue Split charge-candidates producer: staged inputs staged on the sandbox, producer runs on the laptop #4641 (staged split that shipped the defect); issue aggregator(charges-producer): one Gmail message with a missing/garbled date throws RangeError and discards the whole Gmail candidate batch #2448 (different cause, same shape)
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|