# TA9 Shadow Logging Specification

Non-intervention rule:
- Shadow Logging must never call `trade.PositionClose`.
- Shadow Logging must never call `CloseAllEaPositions`.
- Shadow Logging must not set `tradeActionDone`.
- Shadow Logging must not set close intent state.
- Shadow Logging must not mutate basket lifecycle except local shadow counters.

Events:
- CLOSE_PRIORITY_SNAPSHOT
- TA9_RAW_CANDIDATE
- TA9_SAFE_CANDIDATE
- TA9_SUPPRESSED
- EXISTING_CLOSE_SELECTED
- HARDSTOP_SELECTED
- CLOSE_ORDER_ATTEMPT
- CLOSE_ORDER_RESULT
- CLOSE_RETRY
- SNAPSHOT_PARITY_ERROR

Logging volume control:
- Emit CLOSE_PRIORITY_SNAPSHOT at first TA9 raw/safe state change per basket/eval stage.
- Emit TA9_RAW_CANDIDATE only on first raw match or when raw state changes false->true.
- Emit TA9_SAFE_CANDIDATE only on first safe match or when safe state changes false->true.
- Emit TA9_SUPPRESSED on suppression reason changes.
- Always emit SNAPSHOT_PARITY_ERROR.
- Always emit a basket-end aggregate row.
- Do not emit every tick unless parity error or close event occurs.

Required implementation location for shadow only:
- Source: KOUCHA_GOLD_KIWAMI_SURVIVAL_TICK.mq5
- Function: OnTick()
- Slot: after the BEFORE_HARDSTOP_EVALUATION stage trace at lines 2155-2163 and before the existing disabled S2 call at lines 2164-2171.
- The shadow evaluator must use the same `PositionState ps` and must compute a shared snapshot, including actual `hardStop = IsHardStopTriggeredByBasis(ps, marginLevel)`.

Safety:
- If HardStopNow=true, log TA9_SUPPRESSED / HARDSTOP_NOW_TRUE.
- If HTE/Recovery/BasketClose currently eligible, log TA9_SUPPRESSED with the current eligible reason.
- If distance<=0, log TA9_SUPPRESSED / DISTANCE_NOT_POSITIVE.
- If distance<=0 but HardStopNow=false, log SNAPSHOT_PARITY_ERROR.
