Capacity management and reservation system to prevent overbooking
| Tier | domain |
| Role | unclassified (baselined) |
| Path | crates/domain/reservations |
| Edition | 2021 |
| Targets | domain_reservations, pool_lock_tenant_key |
| Public items | 0 across 0 modules |
| Tests | 61 |
What it is for
domain-reservations: Capacity management and reservation system
Overview
This crate provides a reservation system to prevent overbooking and overselling. It manages capacity pools, temporary holds, and confirmed reservations with automatic expiration and concurrency safety.
Layer
Domain - depends on: foundation-basemodels
Key Concepts
- CapacityPool - A scarce resource with limited availability (seats, rooms, etc.)
- Hold - A temporary reservation that expires if not converted
- Reservation - A confirmed booking that consumes capacity
Key Types
CapacityPool- Defines a scarce resource with capacityHold- Temporary hold on capacity with expirationReservation- Confirmed reservationReservationService- High-level business operations
Example
use domain_reservations::{
ReservationService, CreatePoolRequest, CreateHoldRequest, CreateReservationRequest
};
let service = ReservationService::new(pool);
// Create a capacity pool (e.g., 50 seats)
let (pool, event) = service.create_pool(CreatePoolRequest {
tenant_id,
name: "General Admission".to_string(),
description: Some("Standard seating".to_string()),
total_capacity: 50,
..Default::default()
}).await?;
// Create a hold (temporary reservation)
let (hold, events) = service.create_hold(CreateHoldRequest {
tenant_id,
pool_id: pool.id,
party_id: user_id,
quantity: 2,
duration_minutes: Some(15),
..Default::default()
}).await?;
// Convert hold to confirmed reservation
let (reservation, events) = service.convert_hold(hold.id).await?;
// Or create direct reservation (without hold)
let (reservation, events) = service.create_reservation(CreateReservationRequest {
tenant_id,
pool_id: pool.id,
party_id: user_id,
quantity: 3,
..Default::default()
}).await?;
println!("Confirmation: {}", reservation.confirmation_code);
Capabilities
No public items.
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
No public modules: the crate root is its whole surface.
Public surface
No public items.
No pub use re-exports: every item above is declared in this crate.
Boundary
Reaches into foundation.
Shares tier domain with 41 other crates: domain-agreements, domain-ai-report, domain-billing, domain-catalog, domain-classify, domain-comments, domain-competitive-intel, domain-contact, … (41 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | domain |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/domain/reservations |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_domain["domain"] --> n_foundation["foundation"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-basemodels` | foundation | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, serde | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
tokio | ^1 | full, test-util | no | always |
uuid | ^1 | v4, serde | no | always |
Build. None.
Depended on by. 2 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_conversation["application-conversation"] -->|uses| SELF n_application_reservations["application-reservations"] -->|uses| SELF SELF["domain-reservations"] SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | domain_reservations | `src/lib.rs` |
| test | pool_lock_tenant_key | `tests/pool_lock_tenant_key.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
2 workspace crates depend on this one: application-conversation, application-reservations.
Verification
| Kind | Count |
|---|---|
| Unit tests | 57 |
| Integration tests | 4 |
| Examples | 0 |
| Doctests | 0 |
What the tests establish, by name:
distinct_tenants_never_block_each_other_on_the_same_pool_id—tests/pool_lock_tenant_key.rslock_key_folds_every_bit_of_the_uuid—tests/pool_lock_tenant_key.rspools_sharing_a_uuid_prefix_do_not_collide_within_one_tenant—tests/pool_lock_tenant_key.rsvendored_forge_engine_copy_is_byte_identical_to_the_canonical_migration—tests/pool_lock_tenant_key.rstest_already_cancelled—src/errors.rstest_concurrent_modification—src/errors.rstest_hold_duration_exceeded—src/errors.rstest_hold_expired—src/errors.rstest_hold_not_valid—src/errors.rstest_insufficient_capacity—src/errors.rstest_pool_not_accepting—src/errors.rstest_pool_not_found—src/errors.rstest_validation_error—src/errors.rstest_capacity_changed_event—src/events.rstest_event_serialization—src/events.rstest_hold_converted_event—src/events.rstest_hold_created_event—src/events.rstest_pool_created_event—src/events.rstest_reservation_cancelled_event—src/events.rstest_reservation_created_event—src/events.rstest_capacity_pool_for_entity—src/lib.rstest_capacity_pool_status_transitions—src/lib.rstest_capacity_pool_with_overbooking—src/lib.rstest_capacity_pool_workflow—src/lib.rstest_confirmation_code_uniqueness—src/lib.rstest_entity_ref—src/lib.rstest_hold_conversion—src/lib.rstest_hold_creation—src/lib.rstest_hold_expiration—src/lib.rstest_hold_extend—src/lib.rs- _… 31 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 0 | 0 |
Public modules with a //! block | 0 | 0 |
Metrics
| Metric | Value |
|---|---|
| Rust source files | 6 |
| Source lines | 3188 |
| Code lines | 2369 |
| Public API items | 0 |
| Public modules | 0 |
| Tests | 61 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 8 |
| Workspace reverse dependencies | 2 |
pie showData
title Rust source composition
"Code" : 2369
"Blank or comment" : 819
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.