PINK kernel fix-of-fixes: slot-PnL repair plumbing
Review of PINK_ACCOUNTING_EXEC_FIX execution found the Phase 3.2 repair path triply broken: (1) !closed guard blocked repair on terminal fills — the common price-less case; (2) wrapper on_account_event was a raw FFI passthrough so repairs never settled into published capital; (3) live FILL_SETTLED carried no slot_id and realized_pnl=0 (pre-folded) — repair was dead code. Fixes: repair allowed on closed slots (flag+dedup keep it idempotent); wrapper settles the baseline diff on FILL_SETTLED-with-slot_id; dedicated repair_realized_pnl field avoids double-folding the K-ledger; _FakeKernelAccount fixture mirrors the Phase 1 anchor_to_exchange contract. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -672,6 +672,14 @@ class PinkDirectRuntime:
|
||||
"realized_pnl": 0.0, # already folded above
|
||||
"fee": event.fee, # negative = rebate
|
||||
"is_maker": event.is_maker,
|
||||
# Slot-level PnL repair plumbing (Phase 3.2): the
|
||||
# kernel repairs a price-less exit leg
|
||||
# (realized_skipped_no_price) from the exchange's
|
||||
# realized figure. Separate field so the K-fold is
|
||||
# never double-counted; slot 0 = single-slot kernel
|
||||
# and the fill ownership filter already passed.
|
||||
"slot_id": 0,
|
||||
"repair_realized_pnl": float(event.realized_pnl or 0.0),
|
||||
})
|
||||
# Gap 2: log settled fee with WS_SETTLED provenance so
|
||||
# downstream can reconcile against the ESTIMATED_TAKER row.
|
||||
|
||||
Reference in New Issue
Block a user