Inventory: stock placement (item ↔ location junction with quantity, status, history)
| Tier | domain |
| Role | unclassified (baselined) |
| Path | crates/domain/inventory |
| Edition | 2021 |
| Targets | domain_inventory |
| Public items | 17 across 0 modules |
| Tests | 6 |
What it is for
Inventory library crates.
Provides the canonical item ↔ location junction (StockPlacement) that ERP-style systems need: a single SKU can sit in multiple bins with per-placement quantities, status, and history.
# Loose coupling
StockPlacement stores plain Uuid references for item_id and location_id rather than importing domain-catalog::CatalogItem or domain-storage-locations::StorageLocation. This keeps the crate dependency-light: a consumer that has its own catalog or location representation can still use this junction.
# Schema
See migrations/001_stock_placements.sql for the canonical table definition. The Rust struct mirrors that table; consumers should run the migration (or copy it into their own migration runner) before reading or writing StockPlacement values.
# Status semantics
Active: currently in this location, counted in totals.Reserved: earmarked for a downstream operation (order, internal
transfer, QC hold). The metadata JSON should carry the reservation source — see RESERVED_METADATA_RECOMMENDED for a documented shape. Reserved placements ARE counted in "Total Stock" but are NOT "Available to Sell".
Removed: terminal/audit state. The placement no longer represents
real inventory at the location, but the row is kept for history. Soft-deleted placements (deleted_at IS NOT NULL) are removed from query consideration entirely.
Capabilities
crate root
Inventory library crates.
| Item |
|---|
pub const RESERVED_METADATA_RECOMMENDED: & str |
PlacementStatus
Inventory library crates.
| Item |
|---|
pub enum PlacementStatus |
PlacementStatus :: const fn as_str(self) -> & 'static str |
PlacementStatus :: fn parse(s : & str) -> Option <Self> |
PlacementStatus :: fn counts_in_total(self) -> bool |
PlacementStatus :: fn is_sellable(self) -> bool |
PlacementStatus :: fn is_terminal(self) -> bool |
PlacementStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
StockPlacement
Inventory library crates.
| Item |
|---|
pub struct StockPlacement |
StockPlacement :: fn new(item_id : Uuid, location_id : Uuid, quantity : i32) -> Self |
StockPlacement :: fn with_status(mut self, status : PlacementStatus) -> Self |
StockPlacement :: fn with_metadata(mut self, metadata : serde_json::Value) -> Self |
StockPlacement :: fn is_live_active(& self) -> bool |
StockPlacement :: fn id(& self) -> Uuid |
StockPlacement :: fn created_at(& self) -> DateTime <Utc> |
StockPlacement :: fn updated_at(& self) -> DateTime <Utc> |
StockPlacement :: fn deleted_at(& self) -> Option <DateTime <Utc>> |
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
`crate root`
| Item | What it is |
|---|---|
pub const RESERVED_METADATA_RECOMMENDED: & str | Recommended JSON shape for the metadata field on Reserved placements |
pub enum PlacementStatus | Status of a stock placement |
PlacementStatus :: const fn as_str(self) -> & 'static str | Canonical SQL string form (active, reserved, removed). |
PlacementStatus :: fn parse(s : & str) -> Option <Self> | Parse from the SQL string form |
PlacementStatus :: fn counts_in_total(self) -> bool | True iff this placement contributes to "Total Stock" reporting. |
PlacementStatus :: fn is_sellable(self) -> bool | True iff this placement is available for new orders / picks. |
PlacementStatus :: fn is_terminal(self) -> bool | True iff this placement is the terminal audit state. |
PlacementStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub struct StockPlacement | One placement of a catalog item at a storage location |
StockPlacement :: fn new(item_id : Uuid, location_id : Uuid, quantity : i32) -> Self | Create a new Active placement. |
StockPlacement :: fn with_status(mut self, status : PlacementStatus) -> Self | Builder: set status (default is Active). |
StockPlacement :: fn with_metadata(mut self, metadata : serde_json::Value) -> Self | Builder: set metadata. |
StockPlacement :: fn is_live_active(& self) -> bool | True iff this placement is active and not soft-deleted. |
StockPlacement :: fn id(& self) -> Uuid | — |
StockPlacement :: fn created_at(& self) -> DateTime <Utc> | — |
StockPlacement :: fn updated_at(& self) -> DateTime <Utc> | — |
StockPlacement :: fn deleted_at(& self) -> Option <DateTime <Utc>> | — |
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/inventory |
| 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 |
|---|---|---|---|---|
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio-test | ^0.4 | — | no | always |
Build. None.
Depended on by. Nothing in this workspace.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR SELF["domain-inventory"] 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_inventory | `src/lib.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 | none detected |
| 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
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 6 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 3 | 0 | 0 |
What the tests establish, by name:
builder_with_status_and_metadata—src/lib.rsnew_placement_defaults—src/lib.rsserde_roundtrip—src/lib.rsstatus_parse_roundtrips—src/lib.rsstatus_serializes_snake_case—src/lib.rsstatus_total_and_sellable_semantics—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 12 | 17 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 12
"No rustdoc detected" : 5
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 276 |
| Code lines | 177 |
| Public API items | 17 |
| Public modules | 0 |
| Tests | 6 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 6 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"constant" : 1
"enum" : 1
"method" : 14
"struct" : 1
pie showData
title Rust source composition
"Code" : 177
"Blank or comment" : 99
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.