Commit Graph

6 Commits (1cc15352c656da14dbbd7c90390963a9ce62b6c1)

Author SHA1 Message Date
Gud Boi 1cc15352c6 Test shared IB quote restart after both consumers exit
Piker 72d0bdad tested quote restart in a real actor, and
piker 4af885d9 tested two callers against a stubbed channel
cache. Exercise both lifetimes together on Tractor 8fe574c1,
pinned by piker cb5e81d4. Tractor 4dfcf6f6 fixed teardown
when the asyncio producer echoes the bridge's expected
`TrioTaskExited` signal.

Deats,
- Give both consumers the same marked quote through one IB
  subscription. Close each consumer first in turn and send a
  second quote to the survivor.
- Check the final close releases the ticker callback and
  producer. Reopen the subscription, receive a fresh quote,
  then ask the same Tractor actor for its process ID. A
  matching ID confirms the actor still answers after teardown.
- Capture unhandled asyncio completion-callback errors
  separately from exceptions that fail the restart call.
  Run the real bridge with an offline IB market-data source.

(this patch was generated in some part by `Codex` using
`GPT-6` (`OpenAI`))
2026-12-02 17:23:29 -05:00
Gud Boi a5501a787d Explain the IB broadcast test's cursor ownership
Piker 4af885d9 originally described a concurrent cache hit.
The test opens two nested contexts in a single Trio task and
stubs `maybe_open_context()` to return one retained channel.

Deats,
- Trace the cache miss to the raw channel and each hit to a separate
  `BroadcastReceiver` with its own buffer. Identify the root
  broadcast receiver as `LinkedTaskChannel._broadcaster`.
  Each `chan.subscribe()` yields a child sharing its buffer.
- Explain why the stub checks the requested factory and key.
- Explain the subscriber counts after each exit. The stub keeps
  `chan._broadcaster` while the two callers unsubscribe.
  The second quote checks that the outer cursor still works.
- Type the fixture, channel payloads and context-manager yields.
  Preserve the original assertions and their order.

(this patch was generated in some part by `Codex` using
`GPT-6` (`OpenAI`))
2026-12-02 16:49:10 -05:00
Gud Boi a4d83e2a36 Restore shared IB quote ownership on the landing pin
Two consumers of one IB contract can race for the same tick
when the first owns the raw quote channel. Restore the
symbol-keyed channel from piker 4af885d9 (INUSE eb0514c3).
The feed hunk has the same patch ID as the original.

Deats,
- Keep one upstream subscription until the last caller exits.
  Each caller gets its own child from `chan.subscribe()`.
- Restore the original broadcast test under `tests/providers/`.
  Its contents match the original blob byte for byte.

Why revisit the backout,
- Piker 635314c7 first replayed the patch. Piker 72d0bdad
  backed it out after quote restart could kill the actor on
  Tractor b64c89f0. Retain that commit's restart regression.
- Piker cb5e81d4 advanced the lock to Tractor 8fe574c1.
  The feed-reuse slice already uses that revision.

Original-piker-commit: 4af885d90f
Prompt-IO: ai/prompt-io/opencode/20260813T230744Z_ddac3553_prompt_io.md

(this original patch was generated in some part by `opencode`
using `gpt-5.6-sol` (`openai`))
(this commit msg was generated in some part by `Codex` using
`GPT-6` (`OpenAI`))
2026-12-02 15:40:42 -05:00
Gud Boi 84292898ac Retry incomplete IB schedule coverage
A one-day MNQ schedule reply can start in the next session,
leaving the gap's earlier trading hours uncovered. Widen
`Client.history_schedule()` lookbacks up to 31 days, keeping the
requested end fixed and sharing one timeout across attempts.
Preserve unknown coverage when widening cannot cover the range.
Share `SECONDS_PER_DAY` between query and reservation arithmetic,
with one explanation of elapsed versus calendar/session days.

Replay the captured MNQ replies through the allocator: reserve
51,824 candidate slots while excluding the maintenance closure.
Cover bounded retries and timeout cancellation, and document the
query contract. This does not repair existing SHM or parquet.

Prompt-IO: ai/prompt-io/codex/20260924T232405Z_441358e2_schedule_coverage_prompt_io.md

(this patch was generated in some part by `codex` using
`gpt-6` (`openai`))
2026-11-13 17:30:25 -05:00
Gud Boi 81e8ba3ca8 Use IB schedules to reserve missing SHM history
Interrupted backfill can leave stored observations separated by
missing trading time. Query dated IB sessions before prepending
stored history and reserve synthetic samples only during covered
open sessions. Keep venue closures compressed and preserve the
indexes of already published rows.

Deats,
- Add `Client.history_schedule()` with UTC coverage, extended hours,
  bounded duration, timeout, and rejection of ambiguous DST times.
- Keep schedule normalization in `venues` and allocation in
  `.tsp._reserve`, with the project AGPL headers.
- Expose schedule and synthetic-range queries through `datad.ib`.
- Bound reservations by available SHM capacity and inspect only the
  newest 32 gaps by default via `newest_gaps`. Zero disables
  queries; leave unknown and oversized ranges unresolved.
- Record synthetic ranges separately from OHLCV. Automatic storage
  writes retain provider observations; placeholders copy close.
- Group the new tests under `tests/providers`.
- Cover request formatting, DST, failure and capacity cases, plus
  real SHM/NativeDB startup placement with a fake provider.
- Document a common CLI/chart segment-repair interface and defer
  coordinated insertion, repair execution, and reader integration.

Validation: 55 targeted tests passed in the working tree; live IB
schedule coverage remains unqualified. After the module moves,
33 affected tests passed again; the local review follow-up passed
18 affected cases, including four new request-budget cases.
The commit runner repeats
lint and isolated regression checks against this exact boundary.

Prompt-IO: ai/prompt-io/codex/20260924T185456Z_1da9b760_schedule_prompt_io.md

(this patch was generated in some part by `codex` using
`gpt-6` (`openai`))
2026-11-13 17:30:24 -05:00
Gud Boi 5f75a37923 Fix IB idle timer arithmetic for packet nanoseconds
Override `NonShittyWrapper._setTimer()` to compute packet silence
in seconds from integer epoch nanoseconds, avoiding upstream's
`datetime` subtraction error after `tcpDataArrived()`. Delegate
pre-traffic datetime and sentinel handling upstream.

Preserve the packet timestamp on expiry and clear the timer before
`timeoutEvent` emission so listeners can safely rearm it. Add three
offline regressions under `tests/providers/` for rescheduling, single
expiry, datetime and sentinel states, disabling, and reentrant
listener rearming. Document the wrapper overrides on the class.

This fixes an explicitly armed packet-idle timer; heartbeat, default
arming, and reconnect behavior are outside this change.

Prompt-IO: ai/prompt-io/opencode/20260924_ib_idle_timer.md

(this patch was generated in some part by `opencode` using
`gpt-6-astra` (`openai`))
2026-11-13 17:17:58 -05:00