An independent review of the phase found nine defects. The ones that
could lose money or orders:
- Exits at the close of equity_meanrev are now planned orders written in
the same transaction that claims the decision, so a restart can neither
lose them nor send them twice. A sell with a deadline starts aggressive.
- Resume also finds a planned order not yet linked to its execution
(restart between sending and linking) and closes it before re-planning.
- An account is "ready" only after adopting the guard's stops, checking
the key, reconciling, resuming and aligning stops. Until then nothing is
decided on it or sent to it, and the loop retries its startup each
minute. The guard's note is deleted only when every stop it placed is in
the ledger.
- Each account's turn is cut after 45 s (60 s for a retried startup), so a
slow broker no longer silences the heartbeat until the guard kills a
healthy engine; the beat is also withheld when the scheduler has been
silent for 30 minutes.
Smaller ones: a stock decision made after the open is marked late; the
Telegram loops survive unexpected errors; a long absence is shown on the
Panoramica until "Ho visto" (SPEC 5.6); plain-http heartbeats are only
accepted to home-network addresses; the soak report gives a daily close
30 minutes to be decided before expecting it.
ADR 0012 point 12 records these choices; #51 and the two screen criteria
are ticked in the roadmap.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
At the start the host measures how long the bot was away from the last
job that finished, records the absence and writes it in the diary; one
longer than a day is kept for the Panoramica until the user has seen it.
A job can now say how a run missed while the bot was off is treated: the
nightly backup, the exchange rates, the market calendar and the cleanup
run once at the restart, queued, however late; a job with a deadline is
skipped past it and the diary says so. Corporate actions are read before
the reconciliation puts any stop back. A decision the engine makes late
because of an absence is written in the diary as recovered, as are the
orders it releases late; entries that moved too far or expired are
dropped with their reason.
Tests switch the bot off for 3 hours, 20 hours and 3 days with a manual
clock and check each of those rows.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The live engine makes each decision at its time of SPEC 5.5 through the
same DecideOnce call the backtest uses, so live and backtest cannot drift:
the crypto close at 00:05 UTC, the stock signals 20 minutes after the
close, the meanrev exits 5 minutes before it, the stock orders and the
daily stops at the open. Each decision has a run key written in the same
transaction as its decision rows, planned orders and diary lines, and each
planned order's id gives the order key, so a restart never decides or
sends anything twice. Entries recovered late are dropped when the price
has moved too far.
The engine runs from the scheduler once the accounts are reconciled. The
IEX stream follows held stocks, planned orders and SPY during the session,
and the stock simulator's day orders now expire at the close.
Tests: parity with the backtest for crypto_trend (40 days) and
equity_meanrev (6 weeks), and a 14-day run with the network down, a lost
answer, a restart mid-order and the database unreachable, ending
reconciled with no duplicate orders, on SQLite and PostgreSQL.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>