Skip to content

Orion Tasking — Reconciler Audit Logging Branch

To: Orion (he/him) From: Vesper (she/her) CC: Atlas, Katja (Captain) Date: 2026-04-19 Priority: Implement after feat/wallet-truth-reconciliation merges, before fix/reconciler-disappeared-order-conservative.


Background

Atlas's system integrity addendum mandated a "observe → understand → then fix" sequence for the phantom-fill issue. Before we change the reconciler's behavior for disappeared orders (FLAG-037), we need to log every disappeared-order event so we can characterize the real frequency, size distribution, and cause. This branch adds that logging without changing any reconciler behavior.


Branch: feat/reconciler-disappeared-order-audit-log

Scope

One change only: in _handle_disappeared_active_order() (ledger_reconciler.py:633–687), before the existing _apply_full_fill() call, write a structured log entry and a DB record.

Do not change any existing behavior. The phantom-fill path (_apply_full_fill) still fires exactly as before. This branch is pure observability — no behavioral change, no new halts, no new state machine transitions.

Log entry (structured, every disappeared-order event)

[RECONCILER_ANOMALY] disappeared_order detected
  order_id:        {order.order_id}
  side:            {order.side}
  quantity_rlusd:  {order.quantity}
  xrp_equivalent:  {order.quantity / last_mid_price:.4f}
  age_seconds:     {(now - order.created_at).seconds}
  last_status:     {order.status}
  offer_sequence:  {order.offer_sequence}
  cancel_tx_hash:  {order.cancel_tx_hash or 'NONE'}
  action:          PHANTOM_FILL_APPLIED (pre-FLAG-037 behavior)
  session_id:      {current_session_id}

Log at WARNING level. This will be noisy if the event is frequent — that is intentional. We want to see it.

New DB table: reconciler_anomaly_log

CREATE TABLE IF NOT EXISTS reconciler_anomaly_log (
    id               INTEGER PRIMARY KEY AUTOINCREMENT,
    session_id       INTEGER REFERENCES sessions(session_id),
    detected_at      TEXT NOT NULL,
    order_id         TEXT NOT NULL,
    side             TEXT NOT NULL,
    quantity_rlusd   REAL,
    xrp_equivalent   REAL,
    age_seconds      INTEGER,
    last_status      TEXT,
    offer_sequence   INTEGER,
    cancel_tx_hash   TEXT,
    action_taken     TEXT NOT NULL,   -- 'phantom_fill_applied' (pre-FLAG-037)
    notes            TEXT
);

Add via additive migration in state_manager.py, same pattern as other schema additions.

Dashboard addition (minimal)

Add a reconciler_anomaly_count field to the session sidebar or diagnostics panel — count of disappeared-order events in the current session. Zero is the expected value; anything above zero warrants operator attention.


What This Is Not

  • Not a behavioral change to the reconciler
  • Not a halt or degraded trigger
  • Not a fix for the phantom-fill bug (that is FLAG-037)
  • Not a change to apply_fill() or inventory_manager.py

Deliverable

Standard delivery format. Vesper reviews before merge. This branch is short — the logging addition is the entire scope.

After this merges, we will have at least one session's worth of data on disappeared-order frequency before FLAG-037 changes the behavior. That data informs the FLAG-037 design.

— Vesper