Skip to content

v4: add ordered random amount allocator - #44

Draft
Phloraxx wants to merge 1 commit into
v4/sqlite-corefrom
v4/amount-allocator
Draft

v4: add ordered random amount allocator#44
Phloraxx wants to merge 1 commit into
v4/sqlite-corefrom
v4/amount-allocator

Conversation

@Phloraxx

Copy link
Copy Markdown
Owner

Scope

Second stacked PayGate v4 implementation slice. Depends on PR #43.

Behavior

  • for a ₹N request, choose cryptographically at random among free ₹N.01…₹N.99
  • only when the entire base bucket is unavailable, choose randomly from ₹(N+1).01…₹(N+1).99
  • never overflow while even one base-bucket candidate is free
  • .00 is never generated
  • release due hard reservations inside the same immediate SQLite transaction
  • soft recent-use avoidance prefers older/unseen values but cannot create fake exhaustion or force overflow
  • return a clean capacity error only when both configured buckets are unavailable

Tests

Covers random base selection, one-free-slot no-overflow, full-base overflow, recent-use fallback, old-value preference, due-release behavior, full two-bucket exhaustion, invalid requested paise, race tests and vet.

Safety

No production route/runtime wiring. The allocator requires storage.ImmediateTx, so selection cannot accidentally happen outside the payment write transaction.

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.

1 participant