This document freezes the v1 semantic boundary for the quota-core experiment.
quota-core is not a framework launch. It is a second deterministic engine experiment that stays
inside the current allocdb workspace.
The experiment exists to answer one architecture question:
- can the AllocDB execution discipline support a second domain without weakening determinism, replay, boundedness, or fail-closed recovery
The repository decision for v1 is fixed:
- keep the repository identity as
allocdb - add
crates/quota-coreas a sibling engine crate - do not create a new repo
- do not extract a shared runtime crate first
- do not rename public docs around a generic framework story yet
This keeps the engine experiment honest. The second engine must survive under the same constraints as the first one before any extraction or repackaging work begins.
quota-core inherits the same trusted-core rules as allocdb-core:
- same snapshot plus same WAL must produce the same state and results
- the state machine must not read wall-clock time
- hot-path structures must stay explicitly bounded
- replay must use the same apply logic as live execution
- recovery must fail closed on corruption or monotonicity violations
- steady-state execution should avoid hidden allocation growth
The quota experiment is not allowed to relax those rules just because the domain is different.
The first slice is intentionally narrow.
BucketIdBucketRecordOperationRecord
CreateBucketDebit
Credit is excluded from the initial public semantic surface. If test or repair support is needed,
it should be added later as an explicitly scoped administrative command rather than assumed in v1.
limitbalancelast_refill_slotrefill_rate_per_slot
The initial command contracts should stay concrete and boring.
Purpose:
- create one bounded quota bucket with an initial balance and limit
Required fields:
bucket_idlimitinitial_balancerefill_rate_per_slotoperation_idrequest_slot
Rules:
initial_balancemust satisfy0 <= initial_balance <= limitrefill_rate_per_slotmay be zero, which means the bucket never refills- creating an existing bucket returns a deterministic
AlreadyExistsresult - duplicate retry with the same
operation_idand identical payload returns the cached outcome - reusing the same
operation_idwith different payload returnsOperationConflict
Purpose:
- attempt to deduct one amount from one bucket exactly once within the configured dedupe window
Required fields:
bucket_idamountoperation_idrequest_slot
Rules:
amountmust be strictly positive- refill is derived only from persisted bucket state plus
request_slot - debit succeeds only when
balance >= amount - successful debit reduces balance exactly once
- insufficient balance returns a deterministic
InsufficientFundsresult - duplicate retry with the same
operation_idand identical payload returns the cached outcome - reusing the same
operation_idwith different payload returnsOperationConflict
The initial result surface is:
OkAlreadyExistsBucketTableFullBucketNotFoundInsufficientFundsOperationConflictOperationTableFullSlotOverflow
This list is intentionally small. New result codes should be added only when a bounded operating condition cannot be expressed clearly with the current set.
The following are explicitly out of scope for v1:
- bucket hierarchy
- tenancy or project policy
- rate scheduling or queueing
- billing or chargeback semantics
- rich read APIs
- batching or group commit
- generic runtime extraction
- a new repo or public framework identity
The experiment does not move on to refill or extraction until these are true:
CreateBucketandDebitare replay-equivalent- duplicate retry behavior is proven for success and failure paths
- operation-table pressure returns deterministic rejection
- crash/restart does not invent or lose debits
- copied runtime substrate in
quota-coreremains local and does not push abstractions back intoallocdb-core
Stop and reassess if any of these happen:
- quota requires a materially different runtime contract from AllocDB
- the runtime copies diverge immediately for domain reasons
- the experiment starts widening into policy or product work before v1 semantics are proven
- extraction pressure appears before the copied substrate and domain semantics stabilize