diff --git a/pm-stack/aggregator/src/saas-extract.ts b/pm-stack/aggregator/src/saas-extract.ts index 82b32d9b52..6a433ba624 100644 --- a/pm-stack/aggregator/src/saas-extract.ts +++ b/pm-stack/aggregator/src/saas-extract.ts @@ -448,7 +448,7 @@ const githubMetrics: MetricExtractor = (section) => { const modalMetrics: MetricExtractor = (section) => { const plan = bullet(section, /\*\*Plan \/ price \/ allowance:\*\*/); const usage = bullet(section, /\*\*Usage \/ dates:\*\*/); - const credits = /\$(\d+(?:\.\d+)?) monthly compute-credit/.exec(plan); + const credits = /\$([\d,]+(?:\.\d+)?) monthly compute-credit/.exec(plan); // Monthly console read (§2.2, #1111): the Usage bullet carries the // dated used figure, e.g. "$12.50 compute credits used on 2026-10-24" // or "used $12.50". Plan bullet holds the $30/mo grant (the limit). @@ -456,18 +456,18 @@ const modalMetrics: MetricExtractor = (section) => { // deliberately NOT numbers: no fallback below matches a bare number, // so they stay null instead of masquerading as dollars (Codex P2). const usedMatch = - /\$(\d+(?:\.\d+)?)\s*(?:monthly\s*)?compute\s+credits?\s*used/i.exec(usage) ?? - /(\d+(?:\.\d+)?)\s*credits?\s*used/i.exec(usage) ?? - /used[:\s]+\$(\d+(?:\.\d+)?)/i.exec(usage) ?? - /used[:\s]+(\d+(?:\.\d+)?)\s*credits?\b/i.exec(usage); - const used = usedMatch ? Number(usedMatch[1]) : null; + /\$([\d,]+(?:\.\d+)?)\s*(?:monthly\s*)?compute\s+credits?\s*used/i.exec(usage) ?? + /([\d,]+(?:\.\d+)?)\s*credits?\s*used/i.exec(usage) ?? + /used[:\s]+\$([\d,]+(?:\.\d+)?)/i.exec(usage) ?? + /used[:\s]+([\d,]+(?:\.\d+)?)\s*credits?\b/i.exec(usage); + const used = usedMatch ? Number(usedMatch[1].replace(/,/g, "")) : null; return [ metric({ id: "compute-credits", label: "Compute credits / month", unit: "usd", used, - limit: credits ? Number(credits[1]) : 30, + limit: credits ? Number(credits[1].replace(/,/g, "")) : 30, highlight: true, note: used != null @@ -483,14 +483,14 @@ const modalMetrics: MetricExtractor = (section) => { * read 2026-10-26)". No metrics until a dated count is recorded. */ const bitwardenMetrics: MetricExtractor = (section) => { const usage = bullet(section, /\*\*Usage \/ dates:\*\*/); - const secrets = /(\d+)\s*secrets?/i.exec(usage); - const projects = /(\d+)\s*projects?/i.exec(usage); + const secrets = /([\d,]+)\s*secrets?/i.exec(usage); + const projects = /([\d,]+)\s*projects?/i.exec(usage); return [ metric({ id: "secrets-count", label: "Secrets", unit: "count", - used: secrets ? Number(secrets[1]) : null, + used: secrets ? Number(secrets[1].replace(/,/g, "")) : null, highlight: true, note: "bws count-only read (§2.2); names/values never enter the hub.", }), @@ -498,7 +498,7 @@ const bitwardenMetrics: MetricExtractor = (section) => { id: "projects-count", label: "Projects", unit: "count", - used: projects ? Number(projects[1]) : null, + used: projects ? Number(projects[1].replace(/,/g, "")) : null, highlight: true, note: "bws count-only read (§2.2); names/values never enter the hub.", }), diff --git a/pm-stack/aggregator/test/usage.test.ts b/pm-stack/aggregator/test/usage.test.ts index 914d97ff4f..b4e1756a03 100644 --- a/pm-stack/aggregator/test/usage.test.ts +++ b/pm-stack/aggregator/test/usage.test.ts @@ -141,6 +141,20 @@ describe("saas extraction (Part b)", () => { expect(modal.measuredAt).toBe("2026-10-24"); }); + test("modal: grouped dollar amounts are parsed for allowance and usage", () => { + const view = VIEW.replace( + "- **Plan / price / allowance:** Starter $0/mo, Drew confirmed 2026-10-22; $30 monthly compute-credit grant, per-second billing past credits.", + "- **Plan / price / allowance:** Starter $0/mo, Drew confirmed 2026-10-22; $1,250 monthly compute-credit grant, per-second billing past credits.", + ).replace( + "- **Usage / dates:** Percentage/pace unknown; monthly grant, exact reset/credit expiry date unknown.", + "- **Usage / dates:** $1,234.56 compute credits used on 2026-10-24; monthly grant, exact reset unknown.", + ); + const modal = new Map(extractSaasServices(view).map((s) => [s.id, s])).get("modal")!; + const credits = modal.metrics.find((m) => m.id === "compute-credits")!; + expect(credits.limit).toBe(1250); + expect(credits.used).toBe(1234.56); + }); + test("modal: percentage read is not mistaken for dollars", () => { const view = VIEW.replace( "- **Usage / dates:** Percentage/pace unknown; monthly grant, exact reset/credit expiry date unknown.", @@ -171,8 +185,29 @@ describe("saas extraction (Part b)", () => { expect(bw.measuredAt).toBe("2026-10-26"); }); + test("bitwarden: grouped count-only values preserve the full counts", () => { + const view = `${VIEW} +### Bitwarden +- **Plan / price / allowance:** Secrets Manager; plan/price unknown. +- **Usage / dates:** 1,121 secrets, 1,000 projects (bws count-only read 2026-10-26). +- **PAYG estimate:** not applicable — flat account-tooling plan. +- **Last checked:** bws count-only read 2026-10-26. +`; + const bw = new Map(extractSaasServices(view).map((s) => [s.id, s])).get("bitwarden")!; + const m = new Map(bw.metrics.map((x) => [x.id, x])); + expect(m.get("secrets-count")?.used).toBe(1121); + expect(m.get("projects-count")?.used).toBe(1000); + }); + test("bitwarden: no dated count stays an empty shell, names/values never parsed", () => { - const bw = byId.get("bitwarden")!; + const view = `${VIEW} +### Bitwarden +- **Plan / price / allowance:** Secrets Manager; plan/price unknown. +- **Usage / dates:** Count unavailable; names and values are never recorded. +- **PAYG estimate:** not applicable — flat account-tooling plan. +- **Last checked:** tracker. +`; + const bw = new Map(extractSaasServices(view).map((s) => [s.id, s])).get("bitwarden")!; expect(bw.metrics).toEqual([]); }); });