Skip to content

Implement durable asynchronous API-cost webhook delivery & migrate APICostMonitor to SQLAlchemy - #863

Merged
groupthinking merged 1 commit into
mainfrom
durable-async-webhooks-sqlalchemy-9314257410577574552
Jul 17, 2026
Merged

Implement durable asynchronous API-cost webhook delivery & migrate APICostMonitor to SQLAlchemy#863
groupthinking merged 1 commit into
mainfrom
durable-async-webhooks-sqlalchemy-9314257410577574552

Conversation

@google-labs-jules

Copy link
Copy Markdown
Contributor

Implement durable asynchronous API-cost webhook delivery and migrate APICostMonitor to SQLAlchemy. All raw SQLite connection management inside APICostMonitor has been fully refactored to context-managed SQLAlchemy ORM session transactions. A robust webhook delivery outbox state machine has been added with duplicate prevention, failed-delivery retry, recovery from crashes/task cancellations, and retry boundaries. All 85 unit tests pass cleanly.

Fixes #861


PR created automatically by Jules for task 9314257410577574552 started by @groupthinking

…SQLAlchemy

- Defined SQLAlchemy ORM models for APIUsage, DailyBudget, and WebhookOutbox.
- Replaced raw sqlite3 connections and cursors in APICostMonitor with context-managed SQLAlchemy sessions.
- Designed a durable outbox state machine to claim, process, and retry budget alert webhooks.
- Included automatic recovery of stale processing items stuck due to cancellation or crashes.
- Added comprehensive unit tests in test_api_cost_monitor.py verifying duplicate prevention, retries, and crash recovery.
@google-labs-jules

Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-uvai Canceled Canceled Open in v0 Jul 17, 2026 9:53am

@github-actions

Copy link
Copy Markdown

🔍 PR Validation

⚠️ PR title should follow conventional commits format
⚠️ Large PR detected (1282 lines changed)

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Snapshot Warnings

⚠️: No snapshots were found for the head SHA e40345b.
Ensure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice.

Scanned Files

None

@groupthinking
groupthinking merged commit 80ec83b into main Jul 17, 2026
21 of 24 checks passed
@groupthinking
groupthinking deleted the durable-async-webhooks-sqlalchemy-9314257410577574552 branch July 17, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Execution: durable API-cost outbox and canonical usage tracking (PR #869)

1 participant