Commit 0e41d5b
authored
refactor: unify the three skip filters and make one-shot narrowing structural (#738)
* refactor: unify the three skip filters and make one-shot narrowing structural
Closes the remaining one-shot/decoder follow-ups in
plans/claude-md-knowledge-graph.md.
TickDecoder::MESSAGE_TYPE becomes RESPONSE_MESSAGE_IDS and the tick
driver filters with the same is_undeclared helper as the two
subscription drivers — one skip decision, not three. A tick type
declares one entry; the arity was the only difference.
New request_helpers::expect_proto(expected, decode_proto) pairs the
message type a one-shot asked for with its payload decoder. Narrowing
was opt-in: each domain hand-wrote a decode_*_message wrapper for it and
24 sites had none, decoding whatever arrived on the shared channel. 44
call sites now narrow by construction; 30 decoder functions deleted (8
dispatchers, 22 require_proto wrappers). The two wsh wrappers stay —
dual-use with a StreamDecoder.
Converts the last seven hand-rolled folds: head_timestamp,
histogram_data, market_depth_exchanges, historical_schedule (all
sync+async) plus the four option-computation sites via a new
fold_one_shot_mut that fold_one_shot delegates to. Only
historical_data's fetch stays hand-rolled — it reads two frames.
Behaviour: those four APIs retry a connection reset 3 times instead of
unboundedly (async head_timestamp recursed, the others looped), and
sync/async now agree on what a closed stream means.
Two test fixtures were carrying wrong message-type prefixes (MarketRule
87 vs 93, news providers a non-numeric literal) — invisible until
narrowing read the field no assertion depended on.
* refactor: gate the one-shot pairing, sweep the sites the first pass missed
/simplify findings.
The sweep had missed wsh (4 sites) and next_valid_order_id (2), so the
"every one-shot narrows" claim was false while they existed.
next_valid_order_id is the instructive one: it reads the shared
RequestIds channel through fold_one_shot with a bare decoder — adopting
the fold helper reads as adopting the convention, and isn't.
Nothing gated the (IncomingMessages, decoder) pair. A review mutated
three sites to mismatched pairs and only incidental round-trip tests
failed. Adds test_expect_proto_sites_match_the_roster: every site
scraped from src/, checked against a PAIRS roster both directions, each
pair required exactly twice so sync and async cannot drift. The same
mutation now fails by name.
Deletes 22 tests that were retargeted onto expect_proto in the previous
commit. In each the decoder argument is never invoked — expect_type or
require_proto fails first — so they asserted only the combinator's own
behaviour and would pass with |_| Ok(()). Three canonical tests plus the
roster replace them.
Reverts one thing from the previous commit: removing expect_type from
the two single-type StreamDecoder::decode impls. A decoder with no match
has no `_ =>` arm, so expect_type IS its backstop —
test_response_message_ids_match_decode_arms went red immediately. The
misleading doc comment that invited the removal was the actual defect.
Adds docs/rules/wire/one-shot-narrowing.md — the convention had shipped
as a doc comment on a pub(crate) fn, which rules-check cannot see.
Records on proto-only-decoding that TickDecoder got the const's name but
not its gate, with the follow-up to close it.
expect_type's error now names the expected type; it was the only runtime
signal for a mispairing and withheld the identifying fact.1 parent 97fe6ff commit 0e41d5b
50 files changed
Lines changed: 754 additions & 688 deletions
File tree
- docs/rules/wire
- plans
- src
- accounts
- common/decoders
- common
- config
- builder
- common
- contracts
- common/decoders
- market_data
- historical
- common
- decoders
- realtime
- common/decoders
- news
- common
- orders
- common/decoders
- scanner
- common
- wsh
- common
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
| |||
109 | 117 | | |
110 | 118 | | |
111 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
0 commit comments