PositionEvent schema + action enum (Buy/Sell/Close, unsigned volume) #114

Closed
opened 2026-06-22 16:30:50 +02:00 by Brummel · 1 comment
Owner

Fix the canonical Rust representation of C10's derived position-event table, living in aura-engine alongside RunMetrics/ColumnarTrace (it is a post-run reduction, same home as summarize):

  • event_ts: Timestamp
  • action: i64 — Buy / Sell / Close (a closed three-value enum mapped to i64). Direction IS the action, volume is unsigned — no signed-volume trick (ledger-forbidden).
  • position_id: i64 (monotonic, assigned at open)
  • instrument_id: i64
  • volume: f64 (lots, unsigned)

Pin the serde shape and the i64 action encoding. A Close references an existing position_id and may be partial via its own volume. One event_ts may carry >1 row (a reversal emits Close then open at the same event_ts) — document close-before-open ordering. No open_ts stored (it is the opening event's event_ts; ledger-forbidden to store it). No friction logic here — pure schema.

depends on: nothing
context: every downstream piece (derivation, broker audit, persistence) wires to this shape; pinning it stops column-order/encoding disagreement (the silent-wiring hazard SimBroker's load-bearing slot order already warns about).

Fix the canonical Rust representation of C10's derived position-event table, living in `aura-engine` alongside `RunMetrics`/`ColumnarTrace` (it is a post-run reduction, same home as `summarize`): - `event_ts: Timestamp` - `action: i64` — Buy / Sell / Close (a closed three-value enum mapped to i64). **Direction IS the action**, volume is unsigned — no signed-volume trick (ledger-forbidden). - `position_id: i64` (monotonic, assigned at open) - `instrument_id: i64` - `volume: f64` (lots, unsigned) Pin the serde shape and the i64 action encoding. A `Close` references an existing `position_id` and may be partial via its own `volume`. **One `event_ts` may carry >1 row** (a reversal emits Close then open at the same `event_ts`) — document close-before-open ordering. No `open_ts` stored (it is the opening event's `event_ts`; ledger-forbidden to store it). No friction logic here — pure schema. depends on: nothing context: every downstream piece (derivation, broker audit, persistence) wires to this shape; pinning it stops column-order/encoding disagreement (the silent-wiring hazard SimBroker's load-bearing slot order already warns about).
Brummel added this to the Realistic broker & position-event table (C10 A-side) milestone 2026-06-22 16:30:50 +02:00
Brummel added the feature label 2026-06-22 16:30:50 +02:00
Author
Owner

Delivered in cycle 0063 (commit b91c89f): PositionAction { Buy, Sell, Close } + PositionEvent live in aura-engine beside RunMetrics (crates/aura-engine/src/report.rs:220-267), serde-encoded as a bare i64 0/1/2 via From/TryFrom (out-of-range rejected on read), with the reversal-at-same-event_ts round-trip pinned in crates/aura-engine/tests/position_event_table.rs. Acceptance met; the delivering commit used refs not closes, so the issue stayed open. Closing as done.

Delivered in cycle 0063 (commit b91c89f): PositionAction { Buy, Sell, Close } + PositionEvent live in aura-engine beside RunMetrics (crates/aura-engine/src/report.rs:220-267), serde-encoded as a bare i64 0/1/2 via From/TryFrom (out-of-range rejected on read), with the reversal-at-same-event_ts round-trip pinned in crates/aura-engine/tests/position_event_table.rs. Acceptance met; the delivering commit used refs not closes, so the issue stayed open. Closing as done.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Brummel/Aura#114