GeezerVison is showing github.com — feat(usage-hub): v3 invoice reconciliation — Cloudflare Nov 2 first, monthly billed-vs-estimated · Issue #1056 · developing-today/code
feat(usage-hub): v3 invoice reconciliation — Cloudflare Nov 2 first, monthly billed-vs-estimated #1056DescriptionPart of epic #1047. Hub design §5 v3.
Invoice reconciliation for the Usage & billing hub:
- First target: the Cloudflare invoice landing Nov 2, 2026 — it is authoritative for the Oct 24-25 Workers AI / AI Gateway accrual, where the two estimates disagree ($29.60 budget-alert vs $45.10 gateway-attribution). Reconcile, record the settled figure in the snapshot store as source=invoice, and correct the PAYG card.
- Meta PAYG: reconcile the Oct 19-25 accrual ($23.92 accrued / $23.91 collected, Visa ending 7535) the same way.
- Generalize: a monthly "billed vs estimated" pass folded into stewardship — every PAYG line shows estimate vs invoiced with the variance, and estimates older than one invoice cycle are flagged.
Acceptance: Nov 2 Cloudflare figure reconciled and visible on /quota; the monthly pass exists in the stewardship body/docs with the first run logged.
Activitydeveloping-today commented on Oct 27, 2026 dezren39 commented on Oct 29, 2026 dezren39 commented on Oct 29, 2026 🤖 Agent note · done
Verdict: CONFIRMED — no invoice reconciliation exists at HEAD a3cdf6c9a35df1ff8b88b7a02d62e5c04ca4c94a. The two Cloudflare estimates still stand unresolved, no invoice-source record has ever been written, and stewardship has no billed-vs-estimated pass.
Evidence (fresh reads of current main, not the issue text):
pm-stack/aggregator/src/saas-extract.ts, extractPaygLines: the Cloudflare AI Gateway line carries accruedUsd: null and an estimate pair (budget-alert vs gateway-attribution) with the note "Budget alert vs gateway cost attribution disagree — both shown; the Nov 2 invoice is authoritative", and unbilledUsd computed as the high estimate × 1.2. The function's own header comment: "the Cloudflare gateway accrual the two sources price differently — shown, not resolved."
- The Meta PAYG line in the same function is an Oct 25 console read (accrued / collected,
sourceClass: "console") — shown, but never settled as an invoice-class record.
pm-stack/aggregator/src/snapshots.ts already allows source: "invoice" in its SOURCES set — but a grep of the aggregator's writers (saas-extract.ts, snapshot-records.ts, quota-gather-map.ts) finds no writer that emits an invoice record and no reconciliation logic; render.ts mentions invoice only as a display label for the source class.
- The stewardship skill (
~/workspace/custom-skills/stewardship/SKILL.md, CHARTER.md) contains no invoice or billed-vs-estimated step at all — the monthly pass this issue asks to fold in does not exist.
Routing: follow-up enqueued as queue task 2989 (small_fix, dedupe repo-health:v1:fix:developing-today/code:issue:1056, packet queue-packets/packet-1056-fix.json) with not_before 2026-11-02T12:00Z, because its first target — the Cloudflare invoice — does not exist before Nov 2. The packet pins: settled Cloudflare figure recorded with source: "invoice" and the PAYG card corrected to the invoiced figure with both estimates and the variance kept visible; the Meta Oct 19–25 line reconciled the same way; the monthly billed-vs-estimated pass written into the stewardship skill with a stale-estimate flag (period ended >1 invoice cycle ago, no invoice record) rendered on the card; read-only throughout — no payments, billing changes, or token creation (the #1048 billing-API 403 means the invoice document/console is the expected source, and the packet says so). This issue stays open and is labelled queue/queued for that task.
dezren39 commented on Nov 15, 2026 agent-note:v1
state: picked-up
task: 2989
lane: any-a (repo-worker-code)
Resuming from checkpoint implementation_complete / awaiting_ci: PR #10433 is open and MERGEABLE; its dispatched CI run 43683898187 has sat queued with no runner pickup since 2026-11-15T06:05Z. Codex gate already dispositioned on the PR (review failed on Codex usage limits, zero findings). This shift will disposition the 5 undispositioned CodeRabbit findings (4 minor in the new reconciliation code + 1 major: feed path in live.ts returns before settlement reconciliation), fix the valid ones in the worktree, re-run the aggregator targeted tests on the laptop, push, and then merge/close per the standing criteria. dezren39 commented on Nov 15, 2026 agent-note:v1
state: done
task: 2989
lane: any-a (repo-worker-code)
outcome: fixed_merged — PR #10433 MERGED (squash 5b419f0, 2026-11-15T07:27:54Z).
What landed across the two shifts on this task: the Nov 2 Cloudflare invoice settled the Oct 24–25 gateway accrual at $46.86 (snapshot-store record, source: invoice); Meta PAYG Oct 19–25 reconciled (accrued $23.92 vs settled $23.91, variance −$0.01); the aggregator renders settled figures with both estimates + variance and flags stale estimates (>1 invoice cycle, unreconciled); the stewardship monthly billed-vs-estimated pass is documented (SKILL.md §B.7) with its first run logged in the stewardship cycle log (2026-11-15).
This shift additionally dispositioned all 5 CodeRabbit findings on PR #10433 (commit 249603e, replied on each thread): settlement selection compares timestamps as instants; the Meta remainder is computed against the authoritative settlement; the gateway note derives the closer estimate from the actual variances; PaygLine.settledTs preserves the settlement instant through write-back; and the live.ts feed path now reconciles feed-built PAYG lines via applyPaygSettlements before attention flags are built. Codex gate was dispositioned earlier on the PR (review failed on Codex usage limits, zero findings).
Verification: bun test test/usage.test.ts 64 pass / 0 fail (5 new tests); full aggregator suite 2499 pass / 20 fail / 1 error vs clean-main baseline 2493 / 21 / 1 (no new failures; failing names are the known pre-existing set in unrelated areas); bunx tsc --noEmit clean. The dispatched CI run 43683898187 sat queued with no runner pickup since 2026-11-15T06:05Z — laptop verification stands in per the packet's tests line. Read-only throughout: no payment, billing change, or token creation.
Redeploy: the amd NixOS switch from the primary clone at the merge commit is IN FLIGHT on the laptop (detached; log /tmp/lane-any-a-20261115-0110/switch.log; generation was system-555 when last checked). First attempt hung childless for 17 min and was killed; the retry is progressing through cache fetches/build. Whoever reads this next: confirm readlink /nix/var/nix/profiles/system advanced past system-555-link and pm-aggregator.service restarted on the new closure; if the switch failed, re-run nixos-rebuild switch --flake ~/git/code#amd from the clean primary. dezren39 commented on Nov 15, 2026 Read-only deployment verification: amd is on system generation 556 and pm-aggregator.service is active with a new start at 08:23:49 UTC. The deployed /api/quota.json gateway PAYG row now has the expected invoice settlement (settledUsd $46.86, settledSource invoice), a settlement timestamp, and the estimate. This confirms the deployed payload, not a separate visual-card test. No deployment or billing action taken.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|