feat: apply rel-001 feedback cleanup
This commit is contained in:
+7
-7
@@ -261,14 +261,14 @@
|
||||
|
||||
## Entity: `LedgerTrade`
|
||||
|
||||
- Purpose: record idempotent trade execution entries submitted by trex-basic via POST /v1/assets/{asset_id}/ledger/trades
|
||||
- Source of Truth: ledger_trades table (added by migration 20260502_0014)
|
||||
- Lifecycle: inserted once per unique (asset_id, order_id, execution_id) tuple; never updated or deleted
|
||||
- Purpose: record idempotent trade execution entries submitted by trex-basic via POST /v1/portfolios/{portfolio_id}/ledger/trades
|
||||
- Source of Truth: ledger_trades table (added by migration 20260502_0014; column `asset_id` renamed to `portfolio_id` by migration 20260601_0024 — REQ-033 / dcy-005 FR-1)
|
||||
- Lifecycle: inserted once per unique (portfolio_id, order_id, execution_id) tuple; never updated or deleted
|
||||
|
||||
### Key Fields
|
||||
|
||||
- ledger_entry_id :: bigint (Identity) :: auto-generated sequential primary key
|
||||
- asset_id :: text :: portfolio_id (UUID-format text after BAT-006) referencing the trading portfolio
|
||||
- portfolio_id :: text :: portfolios.portfolio_id (UUID-format text) referencing the trading portfolio (renamed from `asset_id` by REQ-033)
|
||||
- order_id :: text :: broker-assigned order identifier
|
||||
- execution_id :: text :: broker-assigned execution/fill identifier
|
||||
- side :: text :: "buy" or "sell"
|
||||
@@ -281,14 +281,14 @@
|
||||
|
||||
### Uniqueness Constraints
|
||||
|
||||
- uq_ledger_trades_idempotency :: UNIQUE (asset_id, order_id, execution_id) :: idempotency guarantee; duplicate inserts are detected and return HTTP 200 + status="duplicate"
|
||||
- idx_ledger_trades_asset_executed :: INDEX (asset_id, executed_at) :: time-range query optimization
|
||||
- uq_ledger_trades_idempotency :: UNIQUE (portfolio_id, order_id, execution_id) :: idempotency guarantee; duplicate inserts are detected and return HTTP 200 + status="duplicate"
|
||||
- idx_ledger_trades_asset_executed :: INDEX (portfolio_id, executed_at) :: time-range query optimization (constraint/index objects retain their original names; only the underlying column was renamed)
|
||||
|
||||
### State Rules
|
||||
|
||||
- Rows are immutable after insertion; no UPDATE path exists.
|
||||
- Payload conflict detection: if unique key matches but payload differs → HTTP 409 Conflict.
|
||||
- asset_id is TEXT (not a FK) but must correspond to a valid portfolios.portfolio_id before insertion.
|
||||
- portfolio_id is TEXT (not a FK) but must correspond to a valid portfolios.portfolio_id before insertion.
|
||||
|
||||
## Shared Consistency Rules
|
||||
|
||||
|
||||
Reference in New Issue
Block a user