piker/ai/prompt-io/opencode/20260916T194052Z_749ca1f0_p...

46 lines
1.8 KiB
Markdown
Raw Normal View History

---
model: openai/gpt-6-astra
service: opencode
timestamp: 2026-09-16T19:40:52Z
git_ref: 749ca1f0
diff_cmd: git diff HEAD -- piker/brokers/ib tests/test_ib_trade_events.py tests/test_ib_method_proxy.py
---
## Human instructions and evidence
Fix silent IB socket loss after network roaming, reported as
`[Errno 104] Connection reset by peer`. Also investigate a live
MNQ accounting crash in `emit_pp_update()` with empty normalized
ledger entries. The human supplied debugger evidence that a commission
for execution 4261 was paired with execution 4262 on the same contract
and account, and explicitly requested implementation and regression
tests. They asked to retain the roaming task and continue working
through follow-up messages.
## Generated changes
> `git diff HEAD -- piker/brokers/ib/broker.py`
Preserve the callback-supplied fill with its commission. Track positions
by account and contract ID and pending commissioned fills by execution.
Reject mismatched commission/execution IDs. Propagate socket closure
instead of returning normally from the trade-event bridge.
> `git diff HEAD -- piker/brokers/ib/ledger.py`
Keep Execution.execId authoritative when flattening commission fields.
> `git diff HEAD -- piker/brokers/ib/api.py`
Relay the authoritative disconnected event as ConnectionError, retaining
the most recent API error text, and raise it from the proxy reader.
Automatic session reconnect/resynchronization remains unimplemented.
> `git diff HEAD -- tests/test_ib_trade_events.py tests/test_ib_method_proxy.py`
Cover overlapping executions, zero commissions, position-before/after
commission ordering, empty commission IDs, and eventkit socket loss.
Nine focused tests passed, including the actual eventkit callback
bridge and its disconnect exception. Focused Ruff checks and
`git diff --check` also passed.