Skip to content

refactor: Wave 2 god-file splits — decode/protocol/config/conditions + tdbe::time lift (refs #500)#506

Merged
userFRM merged 1 commit into
mainfrom
refactor/wave2-mega-splits
May 7, 2026
Merged

refactor: Wave 2 god-file splits — decode/protocol/config/conditions + tdbe::time lift (refs #500)#506
userFRM merged 1 commit into
mainfrom
refactor/wave2-mega-splits

Conversation

@userFRM
Copy link
Copy Markdown
Owner

@userFRM userFRM commented May 7, 2026

What

Wave 2 of the audit-sweep refactor (#500). Five structural changes in one squashed commit:

Split Old New LoC delta
A. decode crates/thetadatadx/src/decode.rs (2177) mdds/decode/{error,headers,transport,extract,cell,v3}.rs structural, public API unchanged
A'. tdbe::time DST primitives buried in decode.rs crates/tdbe/src/time.rs new canonical module reused by mdds/fpss/flatfiles
B. fpss::protocol fpss/protocol.rs (1613) fpss/protocol/{contract,wire,subscription}.rs structural, public API unchanged
C. config config.rs (1396, 30 flat fields) config/{mod,mdds,fpss,reconnect,retry,auth,metrics,runtime,env}.rs nested sub-configs; field-read accessors preserved; field-write callers migrate to nested form
D. conditions conditions.rs (2749 hand-written tables) conditions/{mod,tables_generated}.rs + crates/tdbe/data/{trade,quote}_conditions.toml (149 + 75 entries) TOML-driven codegen via new crates/tdbe/build.rs; round-trip pin test on 12 known entries

Why

Five god-files (over 1300 LoC each) violated the Bloomberg/LSEG-grade engineering bar called out in the 2026-05-06 audit. Splitting them along responsibility lines, lifting cross-crate primitives, and replacing hand-written static tables with TOML-driven codegen brings the codebase in line with institutional norms.

How

  • Decode split + tdbe::time lift — Eastern-time / DST math (8 functions) lifted from decode.rs into tdbe::time. Every consumer in crates/thetadatadx/ rewired to import from tdbe::time::*. Public re-exports preserved at thetadatadx::mdds::decode::* so downstream code resolves identically.
  • Protocol split — 30+ public symbols + 988 lines of tests redistributed across contract.rs / wire.rs / subscription.rs. Tests follow the symbols they cover. fpss::protocol::* re-exports keep external callers green.
  • Config nested — 30 flat fields → 7 nested typed sub-configs. mdds.connect_timeout_secs (default 10s) added — covers the prior LOW finding 3.1. Field-read accessors preserved on DirectConfig for back-compat (config.mdds_host() still works). Field-write callers (78 callsites across crates/thetadatadx/src/{fpss/connection,fpss/mod,macros,mdds/client,observability,unified}, ffi/src/{auth,streaming}, sdks/python/src/lib.rs) migrated to nested form. TOML on-disk shape was already nested; loader rewritten to populate new structs — no migration burden for ~/.thetadatadx/config.toml users.
  • Conditions codegen — 149 trade conditions + 75 quote conditions extracted to TOML. crates/tdbe/build.rs reads both files and emits tables_generated.rs with compile-time const arrays. 13 trade descriptions with embedded \" characters use TOML literal triple-strings ('''...'''); zero workarounds needed. New condition_tables_pin test pins 12 known entries (trade 0/30/40/60/61/90/120/148, quote 0/17/50/74) against the live arrays.

Version

Bumps thetadatadx 8.0.35 → 8.0.36 and tdbe 0.12.9 → 0.12.10. Single atomic bump via scripts/bump_version.py 8.0.36. `check_version_sync.py` reports `version sync: ok`.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace — every existing test + new round-trip pin
  • cargo deny check
  • cargo run -p thetadatadx --bin generate_sdk_surfaces --features config-file -- --check
  • cargo check --manifest-path tools/{cli,mcp,server}/Cargo.toml --locked
  • cargo clippy --manifest-path tools/mcp/Cargo.toml --all-targets -- -D warnings
  • cargo test --manifest-path tools/mcp/Cargo.toml --no-run
  • cargo check --manifest-path sdks/{python,typescript}/Cargo.toml --locked
  • cargo build -p tdbe --release (build.rs codegen runs at release-build time)
  • python3 scripts/check_version_sync.py

Refs #500.

…+ tdbe::time lift (closes #500-wave2)

Five structural changes:

1. crates/thetadatadx/src/decode.rs (2177 LoC) split into mdds/decode/
   {error,headers,transport,extract,cell,v3}. Public API unchanged via
   mdds::decode::* re-exports.

2. Eastern-time + DST primitives lifted into tdbe::time as the canonical
   module reused by mdds, fpss, flatfiles. tdbe 0.12.9 → 0.12.10.

3. crates/thetadatadx/src/fpss/protocol.rs (1613 LoC) split into
   fpss/protocol/{contract,wire,subscription}. mod.rs keeps constants
   + re-exports; contract.rs holds Contract + Display + FromStr + OCC-21
   parser; wire.rs holds payload builders/parsers; subscription.rs holds
   SubscriptionKind.

4. crates/thetadatadx/src/config.rs (1396 LoC, 30 flat fields) refactored
   into 7 nested typed sub-configs. DirectConfig now contains mdds, fpss,
   reconnect, retry, auth, metrics, runtime. Field-read accessors
   preserved for back-compat; field-write callers migrate to nested form
   (config.fpss.queue_depth = …). Adds mdds.connect_timeout_secs default
   10s.

5. crates/tdbe/src/conditions.rs (2749 LoC) refactored to TOML-driven
   codegen. Source-of-truth at crates/tdbe/data/{trade,quote}_conditions.toml
   (149 + 75 entries). build.rs reads them and emits
   tdbe/src/conditions/tables_generated.rs with compile-time const arrays.
   Public surface unchanged; new condition_tables_pin test pins 12 known
   entries against the const arrays for round-trip protection.

Bumps thetadatadx 8.0.35 → 8.0.36 and tdbe 0.12.9 → 0.12.10. All workspace
+ sub-manifest CI gates green locally.
@userFRM userFRM merged commit de1c714 into main May 7, 2026
32 checks passed
@userFRM userFRM deleted the refactor/wave2-mega-splits branch May 7, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant