Skip to content

fix(aggregator): consume feed charges outside the saas gate (#3124) - #3171

Merged
dezren39 merged 2 commits into
mainfrom
queue/4590-3124-saas-gate-charges
Oct 31, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/4590-3124-saas-gate-charges

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Fixes #3124.

liveSource.usage() consumed the fleet feed's charge evidence (feed.charges) and the unmatched-charge attention flags (feed.chargesAttention) only inside the if (feed?.saas && feed.saas.length) gate. A feed carrying valid charges but no saas section — or the quota-view fallback path, or the fixtures fallback — silently dropped every auto-matched charge.

Per the pinned form from triage task 4544:

  • Compute feedCharges + feedChargeFlags once, before the branch.
  • Feed-saas path: unchanged behaviour, now using the hoisted values.
  • Quota-view fallback: feed charges merge ahead of prose-extracted charges (deduped on the full row identity) and the unmatched-charge flags are appended to attention.
  • Fixtures fallback: keeps the feed charges + flags when a feed exists (and clears the empty-charges note); fixtures only stand in for sections that never arrived.
  • Services/payg/subscriptions fallback behaviour untouched.

Tests (laptop, bun test in pm-stack/aggregator):

Queue task 4590 (lane C). Sibling fix #3122 (task 4542) touches the charges producer's surfaced-keys persistence, not this consumer.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 17:48
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1a854258-e07c-4a8f-8309-36e02a0fbe50
Commits

Reviewing files that changed from the base of the PR and between 4bab46e and 4ea1b99.

Files selected for processing: 2
  • pm-stack/aggregator/src/sources/live.ts
  • pm-stack/aggregator/test/charges-feed-gate.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T17:55:29.922064Z 4ea1b99 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8815eb87d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pm-stack/aggregator/src/sources/live.ts Outdated
services: applySupabaseExport(applyCloudflareExport(extractSaasServices(doc), cfExport), supabaseExport),
payg: extractPaygLines(doc, registryText),
charges: extractCharges(doc, registryText),
charges: [...feedCharges, ...extractCharges(doc, registryText).filter((c) => !feedChargeKeys.has(chargeKey(c)))],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reuse charge-level deduplication for the fallback merge

When a feed without SaaS data contains an auto-collected charge also recorded in the local quota view, full-row equality fails to recognize the duplicate: feed rows use sources such as Plaid or Gmail alert, whereas extractCharges() uses descriptive evidence strings and may have different labels or dates. This merge therefore displays the same charge twice and inflates the total calculated in render.ts's chargesStripHtml(). The existing mergeChargeRows() in charges-collect.ts already handles these differences and gives automatic evidence precedence; reuse that charge-level merge instead of reintroducing duplicate prose evidence.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4ea1b99 — correct catch. The fallback merge now reuses mergeChargeRows(feedCharges, extractCharges(...)) from charges-collect.ts: charge-level matching (amount + 3-day window + normalized merchant containment) with the automatic feed evidence taking precedence, instead of my full-row-identity dedupe. Added a regression test where the same charge exists in both the feed (source plaid, dated 2026-10-27) and the quota-view prose (extractor row dated 2026-10-25 with a descriptive source string): usage() returns exactly one row, the feed's. Targeted suites pass (charges-feed-gate, charges-collect, usage, supabase-export: 54/54).

@dezren39

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 4ea1b996ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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

Labels

None yet

Projects

None yet

1 participant