piker/.agents/skills/piker-clearing-expert/test-map.md

2.8 KiB
Raw Permalink Blame History

Clearing And Accounting Test Map

Deterministic first-pass tests

Use the narrowest test that owns the broken contract:

Area First target
Ledger/account persistence targeted node in tests/test_accounting.py
EMS bad-backend handling tests/test_ems.py::test_ems_err_on_bad_broker
IB request/response routing tests/test_ib_method_proxy.py
IB history normalization tests/test_ib_history.py
Service/actor startup targeted node in tests/test_services.py

Known missing high-value regressions include paper partial-fill IDs, status-before-ack handling, minimized_clears() sign-transition round trips, nested ledger dirty detection, and symcache alias reload.

For SymbologyCache.search() and paper ledger qualification, cover:

  • real Asset and MktPair values;
  • a native-ID alias and canonical FQME key;
  • the actual TransactionLedger.write_config() path;
  • persisted TOML fields after the round trip;
  • no use of live APIs or user configuration.

Side-effectful tests

Do not run these without explicit authorization and the repository test harness guidance:

  • paper EMS tests which open live market/symbology feeds;
  • live Binance/Kraken feed suites;
  • IB account tests using configured accounts;
  • tests which write tracked ledger/account fixtures;
  • broker dialogs requiring credentials or venue connectivity.

After any accounting test using tests/_inputs, inspect its diff. Some context managers can rewrite fixture ledgers on exit.

Regression design

Prefer a direct contract regression over a full actor test when the failure is synchronous and deterministic. Use an actor-level test when the bug depends on:

  • ack/cancel or fill/status interleaving;
  • context cancellation or stream ownership;
  • actor-local state/cache separation;
  • daemon selection or startup;
  • publication ordering across EMS and broker streams.

Every regression should document the original failure, triggering state, violated invariant, arrangement, and proof of the fix.

Verification layers

  1. git diff --cached --check for the exact staged boundary.
  2. Ruff with the repositorys intended rule profile.
  3. A deterministic unit/filesystem regression.
  4. Adjacent accounting or EMS tests which do not require live state.
  5. Explicitly authorized backend/actor integration tests.

Do not interpret a passing ellipsis-body or hard-skipped test as behavioral coverage. Read the selected node before using it as a gate.

Manual reconciliation check

For production-only failures, compare one fill end to end:

BrokerdFill
  -> normalized Transaction
  -> ledger record
  -> Position._events[tid]
  -> Position.cumsize / ppu
  -> account TOML
  -> BrokerdPosition
  -> UI summary

All identities, sign, price, and account values should remain explainable at each arrow. A mismatch identifies the owning boundary for the next focused test.