IB's 10349 TIF-preset notice made `ib_async` synthesize a
`Cancelled` status for an order which subsequently filled. EMS
then discarded its `Order`, recreated `Error(req=None)` for the
separate error callback, and crashed while routing the fill.
Treat 2181 (unsupported SmartRouting opt-out) and 10349 (preset
sets TIF to DAY) as notices: preserve diagnostic callbacks without
manufacturing order failures or relaying them as `BrokerdError`.
Leave actual cancellation handling, including code 202, intact.
Also,
- snapshot `ib_async.Trade` order/status fields and its fill list
at callback time so queued events cannot observe later state;
- retain canceled/closed dialogs in `DarkBook._closed` while the
order-ID mapping exists, keeping `Order.symbol` for late-fill
routing and `Order.account` for commands after a reopen;
- keep late errors out of `_active` and reactivate retained dialogs
only on a subsequent pending/open status;
- cover cancel/close/error/fill sequences, continued msg handling,
callback snapshots and notice-vs-cancellation behavior offline.
Explain the `ib_async.wrapper.Wrapper.error()` state mutations
apart from EMS request retention; name the retained request fields
needed by client routing and reopened dialogs.
Human-tested live/dark fills and order cancellation on an IB paper
Gateway. Exact-tree offline checks are retained in the commit plan.
(this patch was generated in some part by `opencode` using
`gpt-6.1-sol` (`openai`))
Propagate the authoritative `disconnectedEvent` as a
`ConnectionError` so proxy callers and trade consumers fail loudly
instead of waiting on a dead socket. Preserve the last `apiError`
text as the reason without treating numeric farm/order errors as
socket failures.
Deats,
- Disconnect the one-shot callback before sending the exception.
- Raise when `recv_trade_updates()` loses its socket, and relay
disconnect exceptions through both Trio-side consumers.
- Exercise real `eventkit` error/disconnect callbacks and preserve
the supplied commission fill while testing bridge termination.
- Record the aborted integration stage as historical provenance;
its test passes do not validate this post-abort boundary.
Prompt-IO: ai/prompt-io/opencode/20260916_ib_connectivity_integration.md
(this patch was generated in some part by `opencode` using
`gpt-6-astra` (`openai`))
Keep each commission callback's exact `Fill` paired with its
report, so overlapping executions on one contract cannot borrow
each other's fees. Cache positions by account and `conId`, queue
commissioned fills by execution ID until a position arrives, and
accept zero commissions. Reject mismatched execution/report IDs.
Keep `Execution.execId` authoritative when flattening ledger
entries; an empty commission ID must not erase a valid fill. Add
regressions for empty commission IDs, reversed fee arrival, and
positions arriving before or after overlapping executions.
The human live-tested fills and reports the accounting fix works.
Exact-boundary automated checks remain pending; the earlier nine
passes covered the mixed working tree. Included Prompt-IO logs
retain whole-session context, including separate roaming work.
Prompt-IO: ai/prompt-io/opencode/20260916T194052Z_749ca1f0_prompt_io.md
(this patch was generated in some part by `opencode` using
`gpt-6-astra` (`openai`))