{
  "version": "exchange-state-management.workflow.v1",
  "fixtures": [
    {
      "name": "startup_hydrated_position_queues_work_before_service_ready",
      "intent": "REST-hydrated open positions queue reconciliation before service readiness.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "mode": "dry_run",
          "configuredSymbols": ["BTCUSDT"]
        },
        "accountState": {
          "serviceReady": false,
          "positions": [],
          "openOrders": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "rest_hydration",
          "subject": "startup",
          "payload": {
            "positions": [
              {
                "symbol": "BTCUSDT",
                "managedSide": "LONG",
                "size": "0.01",
                "entryPrice": "65000"
              }
            ],
            "openOrders": []
          }
        },
        {
          "type": "start",
          "payload": {
            "privateStreamReady": false
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG"
          }
        ],
        "actionFamily": "protective",
        "logs": [
          {
            "event": "startup_position_queued_before_service_ready"
          }
        ],
        "accountState": {
          "serviceReady": false
        }
      },
      "forbid": ["exposure_increasing_dca_before_protection_trusted"]
    },
    {
      "name": "blank_symbols_auto_detects_open_positions",
      "intent": "Blank configured symbols auto-detect eligible open positions instead of using a sample default.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "ETHUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "mode": "dry_run",
          "configuredSymbols": []
        },
        "accountState": {
          "positions": [],
          "openOrders": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "rest_hydration",
          "subject": "startup",
          "payload": {
            "positions": [
              {
                "symbol": "ETHUSDT",
                "managedSide": "LONG",
                "size": "0.5",
                "entryPrice": "3000"
              }
            ],
            "openOrders": []
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "ETHUSDT",
            "managedSide": "LONG"
          }
        ],
        "actionFamily": "protective",
        "logs": [
          {
            "event": "auto_detect_position_queued",
            "symbol": "ETHUSDT"
          }
        ]
      },
      "forbid": ["sample_symbol_defaulted", "btc_default_used_for_blank_symbols"]
    },
    {
      "name": "absent_symbols_auto_detects_open_positions",
      "intent": "Missing configuredSymbols has the same auto-detect behavior as an explicit blank list.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "SOLUSDT",
        "managedSide": "SHORT"
      },
      "initial": {
        "config": {
          "mode": "dry_run"
        },
        "accountState": {
          "positions": [],
          "openOrders": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "position",
          "payload": {
            "symbol": "SOLUSDT",
            "managedSide": "SHORT",
            "size": "3",
            "entryPrice": "150"
          }
        },
        {
          "type": "timer",
          "atMs": 50,
          "payload": {
            "reason": "event_burst_wait"
          }
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "SOLUSDT",
            "managedSide": "SHORT"
          }
        ],
        "actionFamily": "protective",
        "logs": [
          {
            "event": "auto_detect_position_queued",
            "symbol": "SOLUSDT"
          }
        ]
      },
      "forbid": ["require_symbol_allowlist_for_detected_position", "sample_symbol_defaulted"]
    },
    {
      "name": "blank_symbols_no_positions_noops_without_mutation",
      "intent": "Auto-detect mode does not place orders when no eligible open position exists.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "ANY",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "mode": "dry_run",
          "configuredSymbols": []
        },
        "accountState": {
          "positions": [],
          "openOrders": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "rest_hydration",
          "subject": "startup",
          "payload": {
            "positions": [],
            "openOrders": []
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        }
      ],
      "expect": {
        "actionFamily": "noop",
        "affectedScopes": [],
        "intents": [],
        "logs": [
          {
            "event": "auto_detect_no_positions_noop"
          }
        ]
      },
      "forbid": ["live_submit", "place_for_sample_symbol", "sample_symbol_defaulted"]
    },
    {
      "name": "symbol_allowlist_manages_matching_detected_positions_only",
      "intent": "Configured symbols are an allowlist, not the source of synthetic positions.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "mode": "dry_run",
          "configuredSymbols": ["BTCUSDT"]
        },
        "accountState": {
          "positions": [],
          "openOrders": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "rest_hydration",
          "subject": "startup",
          "payload": {
            "positions": [
              {
                "symbol": "BTCUSDT",
                "managedSide": "LONG",
                "size": "0.01",
                "entryPrice": "65000"
              },
              {
                "symbol": "ETHUSDT",
                "managedSide": "LONG",
                "size": "0.5",
                "entryPrice": "3000"
              }
            ],
            "openOrders": []
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG"
          }
        ],
        "actionFamily": "protective",
        "logs": [
          {
            "event": "allowlist_position_queued",
            "symbol": "BTCUSDT"
          },
          {
            "event": "out_of_scope_position_ignored",
            "symbol": "ETHUSDT"
          }
        ]
      },
      "forbid": [
        "submit_for_unconfigured_symbol",
        "affected_unconfigured_symbol",
        "synthetic_position_from_allowlist"
      ]
    },
    {
      "name": "sample_symbol_not_used_as_runtime_default",
      "intent": "Examples such as BTCUSDT never become implicit runtime defaults.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "mode": "dry_run",
          "configuredSymbols": []
        },
        "accountState": {
          "positions": [],
          "openOrders": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "start",
          "payload": {
            "exampleSymbolInDocs": "BTCUSDT"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        }
      ],
      "expect": {
        "actionFamily": "noop",
        "affectedScopes": [],
        "intents": [],
        "logs": [
          {
            "event": "no_detected_position_noop"
          }
        ]
      },
      "forbid": [
        "configuredSymbols_defaulted_to_BTCUSDT",
        "place_for_BTCUSDT_without_detected_position"
      ]
    },
    {
      "name": "order_confirmation_does_not_imply_position_trust",
      "intent": "Order trust and position trust are separate subjects.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "DCA",
        "step": 1
      },
      "initial": {
        "config": {
          "requiresPositionTrustAfterFill": true
        },
        "accountState": {
          "trust": {
            "order": true,
            "position": false
          },
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01",
              "entryPrice": "65000"
            }
          ],
          "openOrders": [
            {
              "customOrderId": "dca-1",
              "role": "DCA",
              "step": 1
            }
          ]
        },
        "orderContextStore": {
          "dca-1": {
            "role": "DCA",
            "step": 1
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "dca-1",
            "action": "place"
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "customOrderId": "dca-1",
            "status": "Filled"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        }
      ],
      "expect": {
        "actionFamily": "blocked",
        "blocks": [
          {
            "reason": "position_trust_required_after_order_update"
          }
        ],
        "logs": [
          {
            "event": "order_trust_updated_position_trust_pending"
          }
        ]
      },
      "forbid": ["reprotect_from_stale_position", "place_next_dca_before_position_update"]
    },
    {
      "name": "native_position_dca_fill_waits_for_position_update",
      "intent": "Native-position products re-protect from position evidence, not fill/order evidence alone.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "DCA",
        "step": 1
      },
      "initial": {
        "config": {
          "positionModel": "native_exchange_position"
        },
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01",
              "entryPrice": "65000",
              "trusted": true
            }
          ],
          "openOrders": [
            {
              "customOrderId": "dca-1",
              "role": "DCA",
              "step": 1
            }
          ]
        },
        "orderContextStore": {
          "dca-1": {
            "role": "DCA",
            "step": 1
          }
        },
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "execution",
          "payload": {
            "customOrderId": "dca-1",
            "execQty": "0.01"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        },
        {
          "type": "private_event",
          "subject": "position",
          "payload": {
            "symbol": "BTCUSDT",
            "managedSide": "LONG",
            "size": "0.02",
            "entryPrice": "64000"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 50
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG"
          }
        ],
        "logs": [
          {
            "event": "position_trust_required_before_replan"
          },
          {
            "event": "position_trust_updated_replan_allowed"
          }
        ]
      },
      "forbid": ["reprotect_from_pre_fill_entry", "place_next_dca_before_position_update"]
    },
    {
      "name": "native_position_tp_sl_fill_waits_for_position_update",
      "intent": "TP/SL fills wait for matching position/accountstate evidence before cleanup or re-protection.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "TP"
      },
      "initial": {
        "config": {
          "positionModel": "native_exchange_position"
        },
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01",
              "entryPrice": "65000",
              "trusted": true
            }
          ],
          "openOrders": [
            {
              "customOrderId": "tp-1",
              "role": "TP"
            }
          ]
        },
        "orderContextStore": {
          "tp-1": {
            "role": "TP"
          }
        },
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "customOrderId": "tp-1",
            "status": "Filled"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        },
        {
          "type": "private_event",
          "subject": "position",
          "payload": {
            "symbol": "BTCUSDT",
            "managedSide": "LONG",
            "size": "0"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 50
        }
      ],
      "expect": {
        "actionFamily": "cleanup",
        "logs": [
          {
            "event": "order_fill_waiting_for_position_trust"
          },
          {
            "event": "position_flat_confirmed_cleanup_allowed"
          }
        ]
      },
      "forbid": ["cleanup_from_order_fill_only", "reprotect_closed_position_before_position_update"]
    },
    {
      "name": "spot_local_position_state_substitutes_for_native_position_rows",
      "intent": "Products without native position rows derive local position state explicitly.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "spot",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "positionModel": "local_position_state",
          "localPositionStateEnabled": true
        },
        "accountState": {
          "balances": [
            {
              "asset": "BTC",
              "free": "0.01"
            }
          ],
          "localPositionState": {
            "BTCUSDT": {
              "size": "0.01",
              "entryPrice": "65000",
              "trusted": true
            }
          }
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "execution",
          "payload": {
            "symbol": "BTCUSDT",
            "side": "BUY",
            "execQty": "0.005",
            "execPrice": "64000"
          }
        },
        {
          "type": "private_event",
          "subject": "balance",
          "payload": {
            "asset": "BTC",
            "free": "0.015"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 50
        }
      ],
      "expect": {
        "actionFamily": "protective",
        "logs": [
          {
            "event": "local_position_state_updated"
          }
        ],
        "accountState": {
          "localPositionState": {
            "BTCUSDT": {
              "trusted": true
            }
          }
        }
      },
      "forbid": [
        "fake_derivative_position_row",
        "plan_spot_from_order_fill_without_position_trust"
      ]
    },
    {
      "name": "long_dca_equal_sl_rejected",
      "intent": "LONG DCA and SL cannot normalize to the same or crossed price.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "tpPercent": "0.03",
          "dcaPercent": "0.02",
          "slPercent": "0.02"
        },
        "accountState": {
          "filters": {
            "tickSize": "0.1"
          },
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01",
              "entryPrice": "65000"
            }
          ]
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "protective"
        }
      ],
      "expect": {
        "actionFamily": "blocked",
        "blocks": [
          {
            "reason": "invalid_risk_geometry",
            "side": "LONG"
          }
        ],
        "logs": [
          {
            "event": "risk_geometry_rejected",
            "required": "for long positions, TP is above entry, DCA is below entry, and SL is below DCA"
          }
        ]
      },
      "forbid": ["live_submit", "place_dca_at_stop_loss_price"]
    },
    {
      "name": "short_dca_equal_sl_rejected",
      "intent": "SHORT DCA and SL cannot normalize to the same or crossed price.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "SHORT"
      },
      "initial": {
        "config": {
          "tpPercent": "0.03",
          "dcaPercent": "0.02",
          "slPercent": "0.02"
        },
        "accountState": {
          "filters": {
            "tickSize": "0.1"
          },
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "SHORT",
              "size": "0.01",
              "entryPrice": "65000"
            }
          ]
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "protective"
        }
      ],
      "expect": {
        "actionFamily": "blocked",
        "blocks": [
          {
            "reason": "invalid_risk_geometry",
            "side": "SHORT"
          }
        ],
        "logs": [
          {
            "event": "risk_geometry_rejected",
            "required": "for short positions, TP is below entry, DCA is above entry, and SL is above DCA"
          }
        ]
      },
      "forbid": ["live_submit", "place_dca_at_stop_loss_price"]
    },
    {
      "name": "private_event_records_scope_and_schedules_reconcile",
      "intent": "Private account events update accountstate and schedule scoped workflow work.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "waitForRelatedEventsMs": 50,
          "maxDelayMs": 250,
          "configuredSymbols": ["BTCUSDT"]
        },
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01"
            }
          ],
          "openOrders": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "symbol": "BTCUSDT",
            "customOrderId": "oid-a",
            "status": "New"
          }
        },
        {
          "type": "timer",
          "atMs": 50,
          "payload": {
            "reason": "event_burst_wait"
          }
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG"
          }
        ],
        "actionFamily": "protective",
        "logs": [
          {
            "event": "private_event_applied"
          },
          {
            "event": "reconcile_scheduled"
          }
        ]
      },
      "forbid": ["affected_scope_without_drain"]
    },
    {
      "name": "private_event_burst_waits_for_related_events",
      "intent": "Event bursts update state immediately, wait briefly for related events, then trigger planning once.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "waitForRelatedEventsMs": 50,
          "maxDelayMs": 250
        },
        "accountState": {
          "eventVersion": 0
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "atMs": 1,
          "subject": "position",
          "payload": {
            "version": 1
          }
        },
        {
          "type": "private_event",
          "atMs": 10,
          "subject": "position",
          "payload": {
            "version": 2
          }
        },
        {
          "type": "private_event",
          "atMs": 20,
          "subject": "order",
          "payload": {
            "version": 3
          }
        },
        {
          "type": "timer",
          "atMs": 70,
          "payload": {
            "reason": "event_burst_wait"
          }
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG"
          }
        ],
        "actionFamily": "protective",
        "logs": [
          {
            "event": "event_burst_reconcile",
            "rawEventCount": 3
          }
        ]
      },
      "forbid": ["planner_run_per_raw_event"]
    },
    {
      "name": "opaque_custom_id_registry_routes_exchange_echoes",
      "intent": "Opaque exchange custom IDs route through one order-context store.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "TP"
      },
      "initial": {
        "config": {
          "customIds": "opaque_registry_only"
        },
        "accountState": {
          "openOrders": []
        },
        "orderContextStore": {
          "oid-random-001": {
            "symbol": "BTCUSDT",
            "managedSide": "LONG",
            "role": "TP",
            "slotKey": "BTCUSDT:LONG:TP"
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "oid-random-001",
            "action": "place"
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "customOrderId": "oid-random-001",
            "status": "New"
          }
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG",
            "role": "TP"
          }
        ],
        "pendingConfirmations": [],
        "logs": [
          {
            "event": "custom_id_registry_lookup_hit",
            "role": "TP"
          }
        ]
      },
      "forbid": ["parse_slot_state_from_custom_id"]
    },
    {
      "name": "pending_confirmation_does_not_unlock_dependent_action_family",
      "intent": "Accepted mutations stay provisional until private stream evidence or scoped recovery hydration confirms them.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "requiresProtectiveBeforeDca": true
        },
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01"
            }
          ],
          "openOrders": []
        },
        "orderContextStore": {
          "sl-001": {
            "role": "SL"
          },
          "tp-001": {
            "role": "TP"
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "sl-001",
            "action": "place"
          },
          {
            "customOrderId": "tp-001",
            "action": "place"
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "rest_accept",
          "subject": "place_protective",
          "payload": {
            "customOrderIds": ["sl-001", "tp-001"]
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        }
      ],
      "expect": {
        "actionFamily": "blocked",
        "pendingConfirmations": [
          {
            "customOrderId": "sl-001",
            "action": "place"
          },
          {
            "customOrderId": "tp-001",
            "action": "place"
          }
        ],
        "blocks": [
          {
            "reason": "protective_confirmation_pending"
          }
        ]
      },
      "forbid": ["dca_unlocked_by_rest_acceptance"]
    },
    {
      "name": "context_write_failure_blocks_submission",
      "intent": "A failed durable order-context write blocks exchange submission for that slot.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "SL"
      },
      "initial": {
        "config": {
          "contextPersistence": true
        },
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01",
              "entryPrice": "65000"
            }
          ],
          "openOrders": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "protective",
          "payload": {
            "desiredOrder": {
              "customOrderId": "sl-context-fail",
              "role": "SL"
            },
            "contextWriteResult": "failed"
          }
        }
      ],
      "expect": {
        "actionFamily": "blocked",
        "intents": [],
        "pendingConfirmations": [],
        "blocks": [
          {
            "reason": "context_write_failed",
            "role": "SL"
          }
        ],
        "logs": [
          {
            "event": "context_store_write_failed",
            "role": "SL"
          }
        ]
      },
      "forbid": [
        "submit_without_context",
        "pending_confirmation_without_context",
        "duplicate_submit_after_context_write_failure"
      ]
    },
    {
      "name": "private_confirmation_before_rest_accept_is_consumed",
      "intent": "Private confirmation before REST acceptance clears without stale pending state.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "SL"
      },
      "initial": {
        "config": {},
        "accountState": {
          "openOrders": []
        },
        "orderContextStore": {
          "sl-early": {
            "role": "SL",
            "slotKey": "BTCUSDT:LONG:SL"
          }
        },
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "customOrderId": "sl-early",
            "status": "New",
            "role": "SL"
          }
        },
        {
          "type": "rest_accept",
          "subject": "place",
          "payload": {
            "customOrderId": "sl-early"
          }
        }
      ],
      "expect": {
        "accountState": {
          "openOrders": [
            {
              "customOrderId": "sl-early",
              "status": "New",
              "trusted": true
            }
          ]
        },
        "pendingConfirmations": [],
        "logs": [
          {
            "event": "early_private_confirmation_consumed"
          }
        ]
      },
      "forbid": ["stale_pending_confirmation", "private_row_downgraded_by_rest_accept"]
    },
    {
      "name": "pending_place_blocks_duplicate_place",
      "intent": "A pending place confirmation blocks another place for the same slot.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "DCA",
        "step": 1
      },
      "initial": {
        "config": {},
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01"
            }
          ],
          "openOrders": []
        },
        "orderContextStore": {
          "dca-pending-place": {
            "role": "DCA",
            "step": 1,
            "slotKey": "BTCUSDT:LONG:DCA:1"
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "dca-pending-place",
            "action": "place",
            "slotKey": "BTCUSDT:LONG:DCA:1"
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "dca",
          "payload": {
            "desiredSlotKey": "BTCUSDT:LONG:DCA:1"
          }
        }
      ],
      "expect": {
        "actionFamily": "blocked",
        "intents": [],
        "pendingConfirmations": [
          {
            "customOrderId": "dca-pending-place",
            "action": "place"
          }
        ],
        "blocks": [
          {
            "reason": "pending_place_confirmation",
            "role": "DCA",
            "step": 1
          }
        ]
      },
      "forbid": ["duplicate_place_for_pending_slot", "new_custom_id_for_pending_place"]
    },
    {
      "name": "pending_cancel_blocks_duplicate_cancel",
      "intent": "A pending cancel confirmation blocks another cancel for the same target.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "TP"
      },
      "initial": {
        "config": {},
        "accountState": {
          "positions": [],
          "openOrders": [
            {
              "customOrderId": "tp-pending-cancel",
              "role": "TP",
              "owner": "app"
            }
          ]
        },
        "orderContextStore": {
          "tp-pending-cancel": {
            "role": "TP",
            "slotKey": "BTCUSDT:LONG:TP"
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "tp-pending-cancel",
            "action": "cancel"
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "cleanup"
        }
      ],
      "expect": {
        "actionFamily": "blocked",
        "intents": [],
        "pendingConfirmations": [
          {
            "customOrderId": "tp-pending-cancel",
            "action": "cancel"
          }
        ],
        "blocks": [
          {
            "reason": "pending_cancel_confirmation",
            "role": "TP"
          }
        ]
      },
      "forbid": ["duplicate_cancel_for_pending_target", "cancel_retry_without_state_change"]
    },
    {
      "name": "terminal_event_during_cancel_or_amend_is_benign_race",
      "intent": "Terminal private proof makes a later missing-target cancel/amend response benign.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "TP"
      },
      "initial": {
        "config": {},
        "accountState": {
          "openOrders": [
            {
              "customOrderId": "tp-old",
              "role": "TP",
              "status": "New"
            }
          ]
        },
        "orderContextStore": {
          "tp-old": {
            "role": "TP",
            "slotKey": "BTCUSDT:LONG:TP"
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "tp-old",
            "action": "cancel"
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "customOrderId": "tp-old",
            "status": "Cancelled"
          }
        },
        {
          "type": "rest_reject",
          "subject": "cancel",
          "payload": {
            "customOrderId": "tp-old",
            "class": "unknown_order"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        }
      ],
      "expect": {
        "pendingConfirmations": [],
        "recoveryRequired": false,
        "actionFamily": "protective",
        "logs": [
          {
            "event": "terminal_race_acknowledged"
          }
        ]
      },
      "forbid": ["broad_recovery_with_terminal_proof"]
    },
    {
      "name": "reconnect_queues_known_scopes_for_recovery_even_when_quiet",
      "intent": "Reconnect schedules scoped recovery for known scopes without waiting for later events.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {},
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01"
            }
          ],
          "openOrders": [
            {
              "customOrderId": "tp-001"
            }
          ]
        },
        "orderContextStore": {
          "tp-001": {
            "role": "TP",
            "slotKey": "BTCUSDT:LONG:TP"
          }
        },
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "reconnect",
          "subject": "private_stream",
          "payload": {
            "gapPossible": true
          }
        },
        {
          "type": "planner_tick",
          "atMs": 1
        },
        {
          "type": "rest_hydration",
          "subject": "scoped_recovery",
          "payload": {
            "positions": "refreshed",
            "openOrders": "refreshed",
            "fills": "refreshed",
            "readiness": "refreshed"
          }
        }
      ],
      "expect": {
        "recoveryRequired": false,
        "syncRequiredSubjects": [],
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG"
          }
        ],
        "logs": [
          {
            "event": "reconnect_recovery_queued"
          },
          {
            "event": "recovery_hydration_completed"
          }
        ]
      },
      "forbid": ["live_mutation_before_recovery_hydration"]
    },
    {
      "name": "slot_filter_failures_are_blocked_not_silent_or_retried",
      "intent": "Filter and sizing failures produce explicit blocks, not silent no-ops or retry loops.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "DCA",
        "step": 1
      },
      "initial": {
        "config": {
          "filters": {
            "minQty": "0.001",
            "minNotional": "5"
          }
        },
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.0001"
            }
          ]
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "dca",
          "payload": {
            "desiredQty": "0",
            "desiredNotional": "0"
          }
        }
      ],
      "expect": {
        "actionFamily": "blocked",
        "blocks": [
          {
            "reason": "slot_filter_failure",
            "role": "DCA",
            "filter": "min_qty_or_notional"
          }
        ],
        "logs": [
          {
            "event": "slot_blocked",
            "qty": "0",
            "minQty": "0.001"
          }
        ]
      },
      "forbid": ["silent_noop", "tight_retry_loop", "submit_locally_invalid_order"]
    },
    {
      "name": "flat_position_cleans_app_owned_orders",
      "intent": "Flat positions remove leftover app-owned orders without touching manual orders.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "takeoverUnownedOrders": false
        },
        "accountState": {
          "positions": [],
          "openOrders": [
            {
              "customOrderId": "tp-001",
              "owner": "app"
            },
            {
              "customOrderId": "manual-1",
              "owner": "external"
            }
          ]
        },
        "orderContextStore": {
          "tp-001": {
            "role": "TP",
            "slotKey": "BTCUSDT:LONG:TP"
          }
        },
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "cleanup"
        },
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "customOrderId": "tp-001",
            "status": "Cancelled"
          }
        }
      ],
      "expect": {
        "actionFamily": "noop",
        "accountState": {
          "positions": [],
          "openOrders": [
            {
              "customOrderId": "manual-1",
              "owner": "external"
            }
          ]
        },
        "logs": [
          {
            "event": "flat_cleanup_completed"
          }
        ]
      },
      "forbid": ["manual_order_cancelled", "managed_order_left_active_after_flat"]
    },
    {
      "name": "side_flip_cleans_old_side_before_new_side_work",
      "intent": "A one-way side flip cleans old-side app-owned orders before new-side protection or DCA.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "SHORT"
      },
      "initial": {
        "config": {
          "positionMode": "one-way"
        },
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "SHORT",
              "size": "-0.01",
              "entryPrice": "65000"
            }
          ],
          "openOrders": [
            {
              "customOrderId": "old-long-dca",
              "role": "DCA",
              "managedSide": "LONG",
              "owner": "app"
            }
          ]
        },
        "orderContextStore": {
          "old-long-dca": {
            "role": "DCA",
            "managedSide": "LONG",
            "slotKey": "BTCUSDT:LONG:DCA:1"
          }
        },
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "side_flip"
        },
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "customOrderId": "old-long-dca",
            "status": "Cancelled"
          }
        },
        {
          "type": "planner_tick",
          "subject": "after_cleanup"
        }
      ],
      "expect": {
        "actionFamily": "protective",
        "intents": [
          {
            "action": "place",
            "role": "SL",
            "managedSide": "SHORT"
          },
          {
            "action": "place",
            "role": "TP",
            "managedSide": "SHORT"
          }
        ],
        "pendingConfirmations": [],
        "logs": [
          {
            "event": "side_flip_cleanup_selected",
            "oldManagedSide": "LONG",
            "newManagedSide": "SHORT"
          },
          {
            "event": "cleanup_confirmation_applied",
            "customOrderId": "old-long-dca"
          },
          {
            "event": "new_side_work_unblocked_after_cleanup",
            "managedSide": "SHORT"
          }
        ]
      },
      "forbid": [
        "new_side_protective_before_old_side_cleanup",
        "new_side_dca_before_old_side_cleanup",
        "old_side_order_left_active_after_flip"
      ]
    },
    {
      "name": "rest_acceptance_does_not_downgrade_trusted_private_order",
      "intent": "REST acceptance cannot replace a more authoritative private active-order row.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "TP"
      },
      "initial": {
        "config": {},
        "accountState": {
          "openOrders": [
            {
              "customOrderId": "tp-002",
              "price": "66500",
              "qty": "0.01",
              "trusted": true
            }
          ]
        },
        "orderContextStore": {
          "tp-002": {
            "role": "TP"
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "tp-002",
            "action": "place"
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "rest_accept",
          "subject": "place",
          "payload": {
            "customOrderId": "tp-002",
            "partialFields": true
          }
        }
      ],
      "expect": {
        "accountState": {
          "openOrders": [
            {
              "customOrderId": "tp-002",
              "price": "66500",
              "qty": "0.01",
              "trusted": true
            }
          ]
        },
        "pendingConfirmations": [],
        "logs": [
          {
            "event": "rest_accept_matched_existing_private_order"
          }
        ]
      },
      "forbid": ["trusted_open_order_downgraded"]
    },
    {
      "name": "terminal_order_status_is_not_open_order_confirmation",
      "intent": "Terminal or transition statuses clear/terminalize latches but do not confirm active protection.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "SL"
      },
      "initial": {
        "config": {},
        "accountState": {
          "openOrders": []
        },
        "orderContextStore": {
          "sl-terminal": {
            "role": "SL"
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "sl-terminal",
            "action": "place"
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "customOrderId": "sl-terminal",
            "status": "Rejected"
          }
        }
      ],
      "expect": {
        "actionFamily": "blocked",
        "pendingConfirmations": [],
        "blocks": [
          {
            "reason": "protective_slot_terminal",
            "role": "SL"
          }
        ],
        "logs": [
          {
            "event": "terminal_order_status_routed"
          }
        ]
      },
      "forbid": ["active_order_confirmed_from_terminal_status"]
    },
    {
      "name": "execution_fill_is_not_open_order_confirmation",
      "intent": "Execution rows update fills and record affected scopes but do not confirm active open orders.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "TP"
      },
      "initial": {
        "config": {},
        "accountState": {
          "fills": []
        },
        "orderContextStore": {
          "tp-fill": {
            "role": "TP",
            "slotKey": "BTCUSDT:LONG:TP"
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "tp-fill",
            "action": "place"
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "execution",
          "payload": {
            "customOrderId": "tp-fill",
            "execId": "fill-1",
            "execQty": "0.005"
          }
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG",
            "role": "TP"
          }
        ],
        "accountState": {
          "fills": [
            {
              "customOrderId": "tp-fill",
              "execId": "fill-1"
            }
          ]
        },
        "pendingConfirmations": [
          {
            "customOrderId": "tp-fill",
            "action": "place"
          }
        ]
      },
      "forbid": ["active_order_confirmation_cleared_from_execution_only"]
    },
    {
      "name": "default_dca_active_order_does_not_advance_next_step",
      "intent": "Default non-ladder DCA keeps one active next-step order and amends it if needed.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "DCA",
        "step": 1
      },
      "initial": {
        "config": {
          "dcaMode": "single_next_step"
        },
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01"
            }
          ],
          "openOrders": [
            {
              "customOrderId": "dca-1",
              "role": "DCA",
              "step": 1,
              "price": "62000"
            }
          ]
        },
        "orderContextStore": {
          "dca-1": {
            "role": "DCA",
            "step": 1
          }
        },
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "dca",
          "payload": {
            "newDesiredPrice": "62100"
          }
        }
      ],
      "expect": {
        "actionFamily": "dca",
        "intents": [
          {
            "action": "amend",
            "role": "DCA",
            "step": 1
          }
        ],
        "logs": [
          {
            "event": "single_dca_slot_amend_selected"
          }
        ]
      },
      "forbid": ["place_dca_step_2_while_step_1_active"]
    },
    {
      "name": "decimal_and_default_equivalent_active_order_does_not_replace",
      "intent": "Equivalent active orders do not churn because of display precision or hydrated defaults.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {},
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "10",
              "entryPrice": "0.2000"
            }
          ],
          "openOrders": [
            {
              "customOrderId": "tp-decimal",
              "role": "TP",
              "kind": "regular_LIMIT",
              "side": "SELL",
              "quantity": "10.000",
              "price": "0.2100",
              "timeInForce": "GTC",
              "reduceOnly": false,
              "owner": "app"
            },
            {
              "customOrderId": "sl-default",
              "role": "SL",
              "kind": "stop_market_close_position",
              "side": "SELL",
              "triggerPrice": "0.1840",
              "quantity": "0",
              "price": "0",
              "reduceOnly": false,
              "closePosition": true,
              "owner": "app"
            }
          ]
        },
        "orderContextStore": {
          "tp-decimal": {
            "role": "TP",
            "slotKey": "BTCUSDT:LONG:TP"
          },
          "sl-default": {
            "role": "SL",
            "slotKey": "BTCUSDT:LONG:SL"
          }
        },
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "convergence",
          "payload": {
            "desiredSlots": [
              {
                "role": "TP",
                "kind": "regular_LIMIT",
                "side": "SELL",
                "quantity": "10",
                "price": "0.21"
              },
              {
                "role": "SL",
                "kind": "stop_market_close_position",
                "side": "SELL",
                "triggerPrice": "0.184",
                "closePosition": true
              }
            ]
          }
        }
      ],
      "expect": {
        "actionFamily": "noop",
        "intents": [],
        "logs": [
          {
            "event": "slot_equivalence_suppressed_replace",
            "roles": ["TP", "SL"]
          }
        ]
      },
      "forbid": [
        "replace_due_to_decimal_format_only",
        "replace_due_to_non_actionable_default",
        "cancel_recreate_equivalent_slot"
      ]
    },
    {
      "name": "startup_adopts_active_contexts_and_prunes_absent_contexts",
      "intent": "Startup uses trusted active orders to adopt current contexts and prune stale ones.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "contextPersistence": true
        },
        "accountState": {
          "openOrders": []
        },
        "orderContextStore": {
          "tp-live": {
            "role": "TP"
          },
          "tp-stale": {
            "role": "TP"
          }
        },
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "rest_hydration",
          "subject": "startup_open_orders",
          "payload": {
            "openOrders": [
              {
                "customOrderId": "tp-live",
                "role": "TP"
              }
            ]
          }
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG"
          }
        ],
        "logs": [
          {
            "event": "context_adopted",
            "customOrderId": "tp-live"
          },
          {
            "event": "context_pruned",
            "customOrderId": "tp-stale"
          }
        ]
      },
      "forbid": ["recover_slot_meaning_by_parsing_custom_id"]
    },
    {
      "name": "ambiguous_event_routes_bounded_fallback_then_exact_scope",
      "intent": "Ambiguous private rows use bounded fallback and later exact routing from normalized position state.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "UNKNOWN"
      },
      "initial": {
        "config": {
          "configuredSymbols": ["BTCUSDT"]
        },
        "accountState": {
          "positions": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "order",
          "payload": {
            "symbol": "BTCUSDT",
            "customOrderId": "unknown-1"
          }
        },
        {
          "type": "private_event",
          "subject": "position",
          "payload": {
            "symbol": "BTCUSDT",
            "managedSide": "LONG",
            "size": "0.01"
          }
        }
      ],
      "expect": {
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG"
          }
        ],
        "logs": [
          {
            "event": "bounded_fallback_scope_marked"
          },
          {
            "event": "exact_scope_resolved_from_position"
          }
        ]
      },
      "forbid": ["broad_product_wide_planning"]
    },
    {
      "name": "pending_confirmation_timeout_enters_scoped_recovery",
      "intent": "Confirmation timeout enters scoped recovery instead of duplicate placement.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG",
        "role": "SL"
      },
      "initial": {
        "config": {
          "confirmationTimeoutMs": 5000
        },
        "accountState": {
          "positions": [
            {
              "symbol": "BTCUSDT",
              "managedSide": "LONG",
              "size": "0.01"
            }
          ]
        },
        "orderContextStore": {
          "sl-timeout": {
            "role": "SL"
          }
        },
        "pendingConfirmations": [
          {
            "customOrderId": "sl-timeout",
            "action": "place",
            "createdAtMs": 0
          }
        ],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "timer",
          "atMs": 5001,
          "payload": {
            "reason": "confirmation_timeout"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 5001
        }
      ],
      "expect": {
        "recoveryRequired": true,
        "actionFamily": "recovery",
        "logs": [
          {
            "event": "pending_confirmation_timeout",
            "action": "place"
          }
        ]
      },
      "forbid": ["duplicate_place_before_recovery"]
    },
    {
      "name": "recovery_hydration_blocks_normal_actions_until_trust_restored",
      "intent": "Recovery-required state hydrates first and blocks normal actions until trust is restored.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {},
        "accountState": {
          "recoveryRequired": true,
          "syncRequiredSubjects": ["positions", "openOrders", "fills", "balances", "readiness"]
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "planner_tick",
          "subject": "normal_action_family_attempt"
        },
        {
          "type": "rest_hydration",
          "subject": "scoped_recovery",
          "payload": {
            "positions": [],
            "openOrders": [],
            "fills": [],
            "balances": [],
            "readiness": {
              "readyToTrade": true
            }
          }
        },
        {
          "type": "planner_tick",
          "subject": "after_recovery"
        }
      ],
      "expect": {
        "recoveryRequired": false,
        "syncRequiredSubjects": [],
        "affectedScopes": [
          {
            "exchange": "generic",
            "product": "linear",
            "symbol": "BTCUSDT",
            "managedSide": "LONG"
          }
        ],
        "logs": [
          {
            "event": "normal_action_family_blocked_by_recovery"
          },
          {
            "event": "recovery_hydration_completed"
          }
        ]
      },
      "forbid": [
        "cleanup_or_protective_or_dca_during_untrusted_recovery",
        "increase_exposure_during_recovery"
      ]
    },
    {
      "name": "configured_symbol_allowlist_blocks_out_of_scope_events",
      "intent": "Configured symbol allowlists prevent unrelated scopes from reaching planning.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "ETHUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "configuredSymbols": ["BTCUSDT"]
        },
        "accountState": {
          "positions": []
        },
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "private_event",
          "subject": "position",
          "payload": {
            "symbol": "ETHUSDT",
            "managedSide": "LONG",
            "size": "1"
          }
        },
        {
          "type": "planner_tick",
          "atMs": 50
        }
      ],
      "expect": {
        "actionFamily": "noop",
        "affectedScopes": [],
        "logs": [
          {
            "event": "out_of_scope_event_ignored_for_planning",
            "symbol": "ETHUSDT"
          }
        ]
      },
      "forbid": ["affected_unconfigured_symbol", "submit_for_unconfigured_symbol"]
    },
    {
      "name": "dry_run_status_doctor_cannot_submit_live_orders",
      "intent": "Dry-run and inspection commands stay safe even when live credentials exist.",
      "requiredForLiveCapableDemo": true,
      "scope": {
        "exchange": "generic",
        "product": "linear",
        "symbol": "BTCUSDT",
        "managedSide": "LONG"
      },
      "initial": {
        "config": {
          "liveCredentialsPresent": true,
          "command": "doctor"
        },
        "accountState": {},
        "orderContextStore": {},
        "pendingConfirmations": [],
        "clockMs": 0
      },
      "steps": [
        {
          "type": "operator_command",
          "subject": "doctor",
          "payload": {
            "requestedMode": "inspect"
          }
        },
        {
          "type": "planner_tick",
          "subject": "safe_command"
        }
      ],
      "expect": {
        "actionFamily": "noop",
        "logs": [
          {
            "event": "safe_command_forced_read_only",
            "command": "doctor"
          }
        ],
        "intents": []
      },
      "forbid": ["live_submit", "live_amend", "live_cancel", "dry_run_context_pollution"]
    }
  ]
}
