Skip to content

feat: implement distributed budget locking and database migration hea… - #173

Merged
mergekeeper[bot] merged 1 commit into
ASTROIDX556:mainfrom
Queen-T16:feat/distributed-budget-locks-and-migration-health-check
Aug 31, 2026
Merged

feat: implement distributed budget locking and database migration hea…#173
mergekeeper[bot] merged 1 commit into
ASTROIDX556:mainfrom
Queen-T16:feat/distributed-budget-locks-and-migration-health-check

Conversation

@Queen-T16

Copy link
Copy Markdown
Contributor

…lth check

Closes #72: Introduce @UseBudgetLock decorator and BudgetLockInterceptor for Redis-backed distributed locking on budget mutations. Integrate distributed locks into BudgetService.allocate(), consume(), and assertWithinBudget() to prevent race conditions and double-spending when concurrent agents allocate funds or deduct from shared budgets. Lock keys are scoped per-budget with TTLs to prevent deadlocks, and lock release is guaranteed via finally blocks. Add unit tests simulating concurrent lock contention.

Closes #71: Add DatabaseMigrationHealthIndicator that queries the _prisma_migrations table to detect pending migrations. Expose a GET /health/database endpoint that returns 503 when migrations are pending or the database is unreachable, critical for Kubernetes liveness/readiness probes. Include a configurable toggle (HEALTH_CHECK_MIGRATIONS_ENABLED) and unit tests for both synced and pending migration states.

🤖 Generated with Codebuff

Summary

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • CI / tooling

Related issue

Closes #

Checklist

  • npm run build passes
  • npm test passes
  • npm run lint passes
  • npm run typecheck passes
  • No secrets added to tracked files
  • PR description explains the why, not just the what

…lth check

Closes ASTROIDX556#72: Introduce @UseBudgetLock decorator and BudgetLockInterceptor
for Redis-backed distributed locking on budget mutations. Integrate
distributed locks into BudgetService.allocate(), consume(), and
assertWithinBudget() to prevent race conditions and double-spending when
concurrent agents allocate funds or deduct from shared budgets. Lock keys
are scoped per-budget with TTLs to prevent deadlocks, and lock release
is guaranteed via finally blocks. Add unit tests simulating concurrent
lock contention.

Closes ASTROIDX556#71: Add DatabaseMigrationHealthIndicator that queries the
_prisma_migrations table to detect pending migrations. Expose a
GET /health/database endpoint that returns 503 when migrations are
pending or the database is unreachable, critical for Kubernetes
liveness/readiness probes. Include a configurable toggle
(HEALTH_CHECK_MIGRATIONS_ENABLED) and unit tests for both synced and
pending migration states.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Queen-T16 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mergekeeper

mergekeeper Bot commented Aug 31, 2026

Copy link
Copy Markdown

MergeKeeper review

Scope: in scope for linked issue #72.
Verdict: clean

The PR successfully implements distributed budget locking via Redis and the database migration health indicator for the NestJS health module, meeting all requirements and acceptance criteria for issues #72 and #71.

Reviewed commit: aef4788ca337a7314b321d13a1da58e7ca3fdabe.
CI and merge eligibility are checked separately.

@mergekeeper mergekeeper 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.

Approved

The PR successfully implements distributed budget locking via Redis and the database migration health indicator for the NestJS health module, meeting all requirements and acceptance criteria for issues #72 and #71.

@mergekeeper
mergekeeper Bot merged commit 4ac1dfe into ASTROIDX556:main Aug 31, 2026
4 checks passed
@mergekeeper

mergekeeper Bot commented Aug 31, 2026

Copy link
Copy Markdown

Merged

Merged with squash.

lewistemple22 pushed a commit to lewistemple22/astroid-api that referenced this pull request Aug 31, 2026
…lth check (ASTROIDX556#173)

Closes ASTROIDX556#72: Introduce @UseBudgetLock decorator and BudgetLockInterceptor
for Redis-backed distributed locking on budget mutations. Integrate
distributed locks into BudgetService.allocate(), consume(), and
assertWithinBudget() to prevent race conditions and double-spending when
concurrent agents allocate funds or deduct from shared budgets. Lock keys
are scoped per-budget with TTLs to prevent deadlocks, and lock release
is guaranteed via finally blocks. Add unit tests simulating concurrent
lock contention.

Closes ASTROIDX556#71: Add DatabaseMigrationHealthIndicator that queries the
_prisma_migrations table to detect pending migrations. Expose a
GET /health/database endpoint that returns 503 when migrations are
pending or the database is unreachable, critical for Kubernetes
liveness/readiness probes. Include a configurable toggle
(HEALTH_CHECK_MIGRATIONS_ENABLED) and unit tests for both synced and
pending migration states.

🤖 Generated with Codebuff

Co-authored-by: Queen-T16 <308741155+Queen-T16@users.noreply.github.com>
Co-authored-by: Codebuff <noreply@codebuff.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement distributed locking for concurrent agent budget allocation updates Add database migration health check indicator to NestJS health module

1 participant