stock-bot/design/development/architecture/decisions/001-ownership.md
2026-11-27 00:12:48 -05:00

1.8 KiB
Raw Blame History

ADR-001 — Application versus financial authority

Status: user-mandated direction; the detailed backlog still awaits approval.

Selected approach

TypeScript owns product/application logic, strategy authoring, signal/regime composition and research orchestration. Rust owns authoritative financial state transitions, deterministic replay, matching and risk. Keep a modular monolith, existing durable dispatch/runner, shared public contracts and existing web product.

Rationale and evidence

Historical TypeScript applyFill (orchestrator/src/execution/model.ts, retired in pre-M0 cleanup) and Rust process_fill were competing authorities. Consolidation removes behavioral drift; moving all authoring to Rust would reduce flexibility without proving a throughput benefit.

Alternatives and tradeoffs

  • All TypeScript: simpler language footprint, conflicts with required native financial authority.
  • All Rust: less runtime crossing, conflicts with flexible TS development goals.
  • Separate services per stage: more operational overhead without demonstrated need.

Migration consequences

Preserve all existing recovery/data/registry/calculation behavior. Keep explicit legacy readers and paths until cutover tests pass, but never auto-fallback from a failed canonical run to legacy economics. Gates: F01–F08, S01–S03, R05; delete duplicate execution only in S06.

Skeptical revision

Do not port reviewed statistical reporting to Rust solely for language uniformity. F08 consumes Rust financial postings/session marks through one existing TS calculation path; this is analysis, not competing cash/fill accounting. C06 uses a fail-closed legacy composition guard instead of building another soon-to-be-retired research runtime. One canonical SMA path is sufficient for initial cutover.