Day 158 — Invariants that must hold for every strategy and every input
Monday, 11 January 2027 · Week 23 of 52 · The research harness · Study day · 60 min
Example-based tests check the cases you thought of, and invariants check the ones you did not, which is the difference between a suite that passes and a suite that protects you.
What you should be able to do tonight
- State five invariants your engine must satisfy for any strategy and any data, and assert them.
- Find at least one input on which an invariant fails, and either fix the engine or document the limitation.
Tasks 60 min
35 min Write the invariants as tests run over randomised strategies and randomised data: the accounting identity, cash never negative beyond the allowed margin, position changes always explained by a fill, no fill outside the session’s price range, and costs always non-negative. Run each over many random inputs rather than one.
25 min Push until something breaks: feed the engine a session with zero volume, a price of zero, a missing bar mid-series, and a strategy that orders more than exists. Each should either be handled or fail loudly. A silent pass on any of them is a bug waiting for phase 10.
Resources
Deliverable
Five invariant tests over randomised inputs, plus a documented outcome for each of the four adversarial inputs.
Checkpoint
Name an invariant your engine satisfies for every possible strategy, and say what bug it would catch.
Prepare for tomorrow
Ten minutes tonight so Day 159, Tuesday, 12 January 2027 starts clean. This is what the evening email sends you.
Try to reproduce a number from milestone 3 exactly, using only what is committed.
Note every step where you had to remember something rather than read it.
That list is tomorrow’s work.