Conversation
Add connected-worker and configured-slot counts to allocated-resource metering so Autumn can SetUsage those gauges the same way as crons.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryExtends tenant allocated-resource aggregation with live non-operator worker counts and configured slot capacity. It also emits allocated-resource change notifications after relevant worker mutations and expands repository coverage.
Confidence Score: 4/5The PR appears safe to merge, with only a non-blocking comment clarification needed. The worker predicates align with existing live-worker metering semantics, slot capacities are aggregated through the tenant-scoped worker relation, and the accepted concern is limited to how the query-plan constraint is documented. Files Needing Attention: pkg/repository/sqlcv1/allocated_resources.sql, pkg/repository/sqlcv1/allocated_resources.sql.go Reviews (1): Last reviewed commit: "Merge origin/main into feat/meter-alloca..." | Re-trigger Greptile |
| -- Active workers are collected once and reused for both counts so the | ||
| -- tenant-filtered path can use Worker_tenantId_lastHeartbeatAt_idx | ||
| -- instead of scanning historical v1_worker_slot_config rows. |
There was a problem hiding this comment.
State Current Query Constraint
This comment contrasts the query with an alternative implementation rather than documenting the current tenant-first query-plan constraint, making the invariant less clear for future maintainers.
| -- Active workers are collected once and reused for both counts so the | |
| -- tenant-filtered path can use Worker_tenantId_lastHeartbeatAt_idx | |
| -- instead of scanning historical v1_worker_slot_config rows. | |
| -- Keep the tenant filter in active_workers so tenant-scoped queries use | |
| -- Worker_tenantId_lastHeartbeatAt_idx before joining worker slot rows. |
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Description
Extend per-tenant allocated-resource counts with currently connected workers and their configured slot capacity, so cloud billing can SetUsage those gauges the same way as crons, scheduled runs, and webhooks.
Type of change
What's Changed
v1_worker_slot_configChecklist
Changes have been:
Testing
CountAllocatedResourcesByTenantnow asserts a live worker is counted and a stale/paused worker is not. Plan checked on a production shard: tenant-filtered worker+slot path usesWorker_tenantId_lastHeartbeatAt_idx.🤖 AI Disclosure
I acknowledge that an LLM was used in the creation of this Pull Request, in accordance with Hatchet's AI_POLICY.md.
Details: Implemented the SQL, repository callbacks, generated sqlc, and tests.