Repository navigation
v1.1.3 — codebase cleanup, executor safety, dependencies hardened
🧹 Code health — the big cleanup
A month of accumulated low-value code removed in one pass, with no behaviour change except the four cases listed at the bottom. Net −687 lines in the refactor commit alone.
- Dead code gone: RL policy, audit module, their tests, the
[rl_training]config section and a dead wrapper inTradingMemoryService - Deduplicated copy-pasted blocks: dashboard WS auth + log pump, support/resistance resolution, RAG knowledge refresh, writable-config meta lookup
MarketSnapshotdataclass replaced the 19-field argument blob threaded through brain / brain_context / analysis_engine- Largest functions split into named steps: dashboard app factory (435 → 37 lines), brain decision summary, chart generation, PositionExtractor
- ~17 blanket
except Exceptionguards around pure arithmetic/formatting removed; the rest narrowed to what can actually be raised - Comments and docstrings: perf-narration (
# Bolt: …,# Optimization: …) and code-restating comments stripped (73 → 3 long comments); 15 bloated docstrings compressed, −239 lines ofArgs:/Returns:boilerplate, keeping the domain facts and the returned-dict key lists - Dashboard
main.js: now guards missing DOM nodes, logs the previously swallowed brain-status failure, and routes every poller/listener through a rejection handler (try { updateAll(); } catchcould never fire — async call, not awaited)
🛡️ Executor safety
- Entry notional clamped to the executor's limit; a rejected entry rolls back instead of leaving a ghost position
- Position query URL fixed (was requesting
/decision/position→ 404) - Stale
latest_decision.jsoncleared after a successful HTTP forward, so a restarted executor cannot re-read an old decision - Disabling the executor in config now also stops the file fallback from being written
- Post-mortem journal linked to the CLOSE row in trade history
🤖 Analysis and behaviour
- Contract repair: an AI response missing its JSON block is recovered instead of silently degrading
- EV fees now scale with position notional, not portfolio capital
- Removed staged/conditional entry framing — decisions are made on the latest closed candle only
- R/R gate loosened, confirmed breakouts acted on
- Startup tickers validated against live symbols; provider name reported accurately in the logs
- DeepSeek official API support + provider transport consolidation
🔌 Operations
- In-place reload via SHIFT+R (graceful shutdown → launcher restart)
- Version-aware launcher dependency check
🔒 Dependencies and security
- Requirement floors raised to the versions this environment actually runs and was tested with:
accelerate>=1.15.0,chromadb>=1.5.9,python-dotenv>=1.2.2,requests>=2.34.2,torch>=2.13.0,transformers>=5.14.1,urllib3>=2.7.0. The previous floors (chromadb>=1.0.0,transformers>=4.46.0,urllib3>=2.2.2, …) still allowed a fresh install to resolve to versions carrying 30+ advisories. - accelerate 1.14.0 → 1.15.0 in the environment: fixes CVE-2026-69112 (path traversal / denial of service when loading sharded checkpoints). Verified after the bump: the brain's vector store opens (3 collections), a full add/query/delete cycle passes on a copy, and
bge-base-en-v1.5encodes 768-dimensional embeddings. - chromadb carries four advisories (CVE-2026-45829 / 45830 / 45831 / 45833) that no release fixes — 1.5.9 is the newest on PyPI and every version sits inside the affected range. All four are server-mode issues (HTTP API, RBAC, cross-tenant access), while this project only ever uses an embedded
PersistentClientagainst a local directory, so they are not reachable here. Recorded with the reasoning in.trivyignore.
⚙️ CI
- Removed both auto-fix workflows — one opened zero pull requests across 25 branches (the repo does not allow Actions to create PRs and the failure was swallowed by
|| echo ...), the other never had a real issue to fix. All 25 deadci/auto-fix-*branches deleted. - Repaired the Codacy scan — it had been failing at its init step for days because Codacy's own installer calls an undefined
fatal— got the first successful run, then removed it too: 711 findings of which 319 wereno-undefon browser globals that the engine cannot be configured to accept, 371 complexity metrics, and 8 logger false positives on token counts. The repository now runs no CI workflows: dead weight removed rather than kept green. - Website Dependabot alerts cleared (9)
⚖️ Deliberate behaviour changes (4)
- No-JSON response → HOLD instead of a guessed decision
- Non-numeric
confidence→ 50 / MEDIUM position_size > 1→ rejected instead of silently clamped- Trend is no longer inferred from free text
Verified: 1402 passed / 0 failed / 17 skipped · pyright 0 errors · ruff clean over src and start.py, and no new findings over tests/scripts (49 → 39 across the release).
🧱 Refactor pass — 1000-line cap, god-class splits, no behaviour change (PR #13)
- Every module and class is now under 1000 lines.
start.py1397 → 502,src/dashboard/routers/brain.py1238 → 702,src/trading/trading_strategy.py1209 → 480,tests/test_trading_strategy_branches.py1522 → 996. Each split moves method bodies verbatim into mixins the existing classes already inherit, so no call site, MRO or test seam changed (strategy._open_new_position, the brain helpers, the launcher imports ofstart.pyall keep working). - New modules (all well under the cap):
src/composition/provisioners.py+src/composition/startup_support.py(the 9 provisioning stages and the env/GPU/dialog/banner helpers),src/trading/executor_reconciliation.py(position verification, verdict journal, phantom rollback),src/trading/position_management.py(entry, SL/TP updates, existing-position decisions),src/dashboard/decision_presenter.py(the pure view-model builders out of the brain router). _open_new_position(235 lines) decomposed into_reject_intent/_store_risk_frictions/_check_entry_thresholdsplus the entry body; the three exit-check entry points now share_close_on_exit.- Comments: every prose
#comment removed — 1 980 full-line + 339 trailing. Only machine directives remain (# noqa,# type: ignore,# pylint:,# pragma:); removing those would re-break the lint and type gates. - Docstrings:
Args:/Raises:boilerplate that restated signatures removed across 75 files (2 136 lines);Returns:sections and returned-dict key documentation kept. - Last type introspection on known types removed: 8 ×
getattr(self.config, KEY, default)(each key is a realConfigproperty whose own default already matched), 3 ×hasattronCoinGeckoAPI.symbol_to_id_map/RagEngine.news_manager/TradingStrategy.guard_pipeline, andgetattr(decision, "order_id", None). Notry/exceptwas added anywhere; the config stubs in 8 test files now declare the six attributes production reads directly, at the loader's own defaults. - Fixed:
_provision_dashboard_layerderivedconfig/config.inifromPath(__file__).parent, which resolved insidesrc/composition/once the method moved — now anchored on aPROJECT_ROOTconstant. - Left alone deliberately:
notifiers/filehandler.pyFILE_MESSAGE_EXPIRY, where the two defaults disagree (0= never expire vs the loader's604800= 7 days). That is a behaviour decision, not a cleanup.
Verified: 1402 passed / 0 failed / 17 skipped · pyright 0 errors / 0 warnings · ruff clean over src, start.py.
Full diff: v1.1.2...v1.1.3