Phase 2: persistence + safety controls
Aggiunge la persistenza SQLite, l'audit log a hash chain, il kill switch coordinato e i CLI di gestione documentati in docs/05-data-model.md e docs/07-risk-controls.md. 197 test pass, 1 skipped (sqlite3 CLI mancante), copertura totale 97%. State (`state/`): - 0001_init.sql con positions, instructions, decisions, dvol_history, manual_actions, system_state. - db.py: connect con WAL + foreign_keys + transaction ctx, runner forward-only basato su PRAGMA user_version. - models.py: record Pydantic, Decimal preservato come TEXT. - repository.py: CRUD typed con singola connessione passata, cache aware, posizioni concorrenti. Safety (`safety/`): - audit_log.py: AuditLog append-only con SHA-256 chain e fsync, verify_chain riconosce ogni manomissione (payload, prev_hash, hash, JSON, separatori). - kill_switch.py: arm/disarm transazionali, idempotenti, accoppiati all'audit chain. Config (`config/loader.py` + `strategy.yaml`): - Loader YAML con deep-merge di strategy.local.yaml. - Verifica config_hash SHA-256 (riga config_hash esclusa). - File golden strategy.yaml + esempio override. Scripts: - dead_man.sh: watchdog shell indipendente da Python. - backup.py: VACUUM INTO orario con retention 30 giorni. CLI: - audit verify (exit 2 su tampering). - kill-switch arm/disarm/status su SQLite reale. - state inspect con tabella posizioni aperte. - config hash, config validate. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
# strategy.local.yaml — local override (gitignored).
|
||||
#
|
||||
# Copy to strategy.local.yaml and edit only the keys you need to
|
||||
# change. Top-level sections are deep-merged onto strategy.yaml at
|
||||
# load time; the merged result is logged as OVERRIDE_APPLIED.
|
||||
#
|
||||
# Typical use cases:
|
||||
# * Halve cap_per_trade in dry-run.
|
||||
# * Force max_concurrent_positions to 0 to freeze entries without
|
||||
# stopping the engine.
|
||||
# * Lower kelly_fraction temporarily after a drawdown.
|
||||
|
||||
# Example: emergency entry freeze.
|
||||
# sizing:
|
||||
# max_concurrent_positions: 0
|
||||
Reference in New Issue
Block a user