Skip to content

v1.1.5 - cycle checkpoint, approval gate, prompt hardening, verifiable suite

Choose a tag to compare

@qrak qrak released this 20 Oct 21:01
· 185 commits to master since this release

What changed since v1.1.4

28 commits, 182 files, +11,557 / −5,682. Grouped by area; each line is a commit in this range.

Trading loop and safety

  • Cycle checkpoint — one checkpoint persisted per cycle; a duplicate intent is suppressed by decision hash before any local booking, so a restart cannot open the same position twice.
  • Human approval gate (opt-in, require_approval_above_usdc) — above the threshold an order waits for approval; /api/admin/approvals serves approve/reject, and an expired request counts as a refusal.
  • Prompt budget policy — PromptBudgetPolicy + a shared TokenCounter size the whole request before every provider call; protected sections are untouchable, lower-priority context is trimmed instead of the call failing.
  • Execution quality per entry — Position/TradeDecision carry the entry fill quality, persisted through PersistenceManager and SQLite; divergent fills are excluded from statistics and from brain lessons.
  • Brain evidence — historical MAE evidence and post-mortem lessons feed the prompt; entry trend direction is stored separately from the exit market regime; executor handler shuts down gracefully.
  • Read-only MCP server over trade history (mode=ro + query_only).

Executor and reconciliation

  • Incomplete fill evidence on entry intents no longer books a position.
  • Entry fill handling and reconciliation reworked; late UPDATE confirmations are settled instead of silently dropped.
  • Executor connection failures now surface with warnings and a defined path back, instead of a bare exception.

Analyzer and prompts

  • Canonical TTM squeeze — Carter's published pairing: KC(20, 1.5 × Wilder ATR), one smoothing shared by band and printed ATR; the detector returns the run length and a fired event instead of a flag.
  • Pattern-state durations — MACD histogram, volatility trend, Bollinger squeeze and accumulation/distribution report how long a state has held ("for N bars"), re-evaluated per bar.
  • Explicit labels — "momentum shift", "breakout imminent", "(strong signal)" and "reversal confirmation" removed; the prompt legend names the calculator's fixed windows and every detector threshold.
  • R/R narrative false positive fixed — RR_CHECK spans are stripped before counting quoted ratios, so risk=819.51 is no longer read as a second, unverified R/R that warned on every cycle.
  • Prompt injection hardening — external news/Reddit text is treated as data: instruction-shaped lines quarantined, code fences defused, invisible characters stripped, block wrapped in per-cycle nonce markers.
  • Reddit assessments quoting title IDs as decimal strings are accepted instead of discarding the whole sentiment block; one-shot corrective retry when a parsed decision breaks the contract.

Dashboard and observability

  • Cycle journal — append-only metrics/cycles.jsonl with latency p50/p95 and signal mix, summarised by GET /api/performance/cycles.
  • Per-provider circuit breaker — 3 consecutive failures open the circuit for 120 s, then a half-open probe; when every circuit is open the primary gets one fail-open attempt.
  • Per-visitor limits — /api/* rate limiting, the WebSocket cap and the admin login limiter resolve the visitor through resolve_client_ip(), so Cloudflare-tunnel traffic is limited per visitor; the header is trusted only on a loopback peer. Writes have their own budget and 429s carry Retry-After.
  • Load shedding — heavy endpoints are capped in concurrency; excess work is refused immediately and a slow GET is cancelled, so a flood cannot queue unbounded work in the event loop that runs the analysis cycle.
  • Shared price refresh — /api/brain/refresh-price shares one exchange attempt across all dashboard callers for 10 s.
  • Chart revision URLs stay stable between polls and rotate on analysis, so a late response cannot replace a newer image; news previews are lightweight and no longer ship the full payload.

Data freshness

  • CoinGecko — the source's own updated_at travels with the payload as source_updated_at, a warning fires when it is older than 48 h, and a response served from the HTTP cache without an expiry is warned about once per endpoint. The timestamp is shown in the Market Overview prompt block.

Dependencies, CI and docs

  • constraints.txt for the eight non-imported floors/caps; aiosqlite, scipy and bitsandbytes dropped from requirements.txt (nothing imports them, they arrive through used dependencies). Every launcher passes the constraints file.
  • CI — a unit-test workflow (ruff + pytest -m "not integration"), live/Playwright suites marked integration so CI stays offline, config.ini seeded from the tracked template, and ruff pinned after 0.17 promoted rules and flagged 178 untouched lines.
  • gitignore cleanup: dead boilerplate and unanchored lib/ pattern removed, local-only files (scripts/start_script_{develop,futures}.ps1, .hermes/, .agents/) now ignored for every clone, not just this one.
  • Older changelog entries archived into docs/; README and the site re-measured (79 Numba indicator functions, real pre-execution checks instead of an "R:R gate", provider deepseek), the duplicated architecture article deleted, the private executor repo no longer linked.
  • Dead suites deleted — test_shutdown_real.py (zero assertions) and test_admin_live.py (needed the production admin password); CSP/HSTS coverage moved to tests/domain_infra/test_dashboard_brain.py. The suite now runs with 0 skipped.
  • Four untested paths closed by mutation testing: narrative R/R tolerance (2.35 claimed vs verified 1.953), BUY bracket ordering (stop < entry < target), position_size > 1, and a fill divergence above 1% (a 50% tolerance had passed all 182 tests in that file).
  • Agent documentation trimmed 117.6 KB → 70.0 KB, with false statements corrected (paper-only execution while [executor_api] enabled = true, a 1.50 R:R gate against min_rr_entry = 0.0, Gemini as the provider while provider = deepseek).

Verification

  • Full Windows-venv suite: 2419 passed, 0 skipped, 0 failed (~160 s)
  • CI gate pytest -m "not integration": 2385 passed, 34 deselected
  • Mutation probe: 9 realistic mutants in src/ — 5 killed before the new assertions, 9 killed after
  • ruff check src start.py scripts clean; GitHub Actions tests and CodeQL green on this commit