From 3ad67d4c57a4d96d9ba76eded069d84f8c57cafa Mon Sep 17 00:00:00 2001 From: Devid HW Date: Sat, 25 Apr 2026 09:14:44 +0700 Subject: [PATCH] docs: fix inaccuracies found during documentation accuracy review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CHANGELOG: inactivity_kill_secs default is disabled (None), not 120 - TROUBLESHOOTING: clarify inactivity_kill_secs is opt-in (must be passed explicitly); correct "default 120" claim - MCP_TOOLS: inactivity_kill_secs is disabled by default; add note that Wine/macOS may not exit naturally even with ShutdownTerminal=1 - handlers/backtest.rs: remove stale comment claiming inactivity watchdog is "intentionally skipped when shutdown=true" — replaced with accurate description of the new 30s HTML-wait + kill behavior Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 4 ++-- docs/MCP_TOOLS.md | 12 ++++++++---- docs/TROUBLESHOOTING.md | 5 +++-- src/tools/handlers/backtest.rs | 9 +++++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac3309e..7c3f82b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,8 +17,8 @@ `find_active_tester_agent_log` now prefers `Agent-127.0.0.1` and tiebreaks by file size. ### Added -- `launch_backtest` exposes `shutdown` (default `true`) and `inactivity_kill_secs` (default `120`) - as explicit tool parameters. +- `launch_backtest` exposes `shutdown` (default `true`) and `inactivity_kill_secs` (default: disabled; + set to e.g. `120` to enable the inactivity watchdog) as explicit tool parameters. - Report DB stores deals in SQLite; all analytics tools resolve by `report_id` / `report_dir` / latest. ### Verified diff --git a/docs/MCP_TOOLS.md b/docs/MCP_TOOLS.md index e7c7809..e5d62e1 100644 --- a/docs/MCP_TOOLS.md +++ b/docs/MCP_TOOLS.md @@ -189,10 +189,14 @@ Fire-and-forget mode: compile → clean → launch MT5 backtest, return immediat skip_clean?: boolean; // Skip cache cleaning timeout?: number; // Max time in seconds (default: 900) gui?: boolean; // Enable MT5 visualization - shutdown?: boolean; // Shut down MT5 after test (default: true) - inactivity_kill_secs?: number; // Kill MT5 if tester log silent for N seconds (default: 120). - // After silence, pipeline waits 30s for HTML then kills MT5. - // Set to 0 to disable. Useful to abort stalled EAs. + shutdown?: boolean; // Shut down MT5 after test (default: true). + // NOTE: on Wine/macOS terminal64.exe may not exit naturally + // even with ShutdownTerminal=1. Use inactivity_kill_secs too. + inactivity_kill_secs?: number; // Kill MT5 if tester log hasn't grown for N seconds + // (default: disabled / not set). Recommended: 120. + // After silence, pipeline polls for HTML report for 30s, + // then kills MT5 unconditionally. If HTML present → extracted; + // otherwise falls back to journal extraction (no P&L data). } ``` diff --git a/docs/TROUBLESHOOTING.md b/docs/TROUBLESHOOTING.md index 1d03089..4a06851 100644 --- a/docs/TROUBLESHOOTING.md +++ b/docs/TROUBLESHOOTING.md @@ -82,8 +82,9 @@ growing (test done), waits 30 seconds polling for the HTML file, then kills `ter unconditionally. If the HTML appears during the wait it is extracted; otherwise journal extraction provides deal counts and final balance (but no per-deal P&L). -**To maximise HTML report chances:** Use `inactivity_kill_secs=120` (default) with `shutdown=true` -(default). This gives MT5 120s of quiet time + 30s of HTML-wait before the kill. +**To maximise HTML report chances:** Pass `inactivity_kill_secs=120` explicitly (it is disabled by +default). With `shutdown=true` (default) this gives MT5 120s of quiet time + 30s of HTML-wait before +the kill. ``` launch_backtest(expert: "MyEA", shutdown: true, inactivity_kill_secs: 120) diff --git a/src/tools/handlers/backtest.rs b/src/tools/handlers/backtest.rs index ddc4368..b953733 100644 --- a/src/tools/handlers/backtest.rs +++ b/src/tools/handlers/backtest.rs @@ -338,10 +338,11 @@ pub async fn handle_launch_backtest(handler: &crate::tools::handlers::ToolHandle skip_clean: args.get("skip_clean").and_then(|v| v.as_bool()).unwrap_or(false), skip_analyze: true, // Not needed for launch mode deep_analyze: false, - // ShutdownTerminal=1 (default): MT5 writes the HTML report and exits cleanly. - // The background monitor's post-exit scan finds the report within 10s. - // The inactivity watchdog is intentionally skipped when shutdown=true so it - // doesn't race with MT5's report write right before natural exit. + // On Wine/macOS, ShutdownTerminal=1 does NOT reliably cause terminal64.exe to exit. + // When inactivity_kill_secs is set, the monitor waits that many seconds after the + // tester log goes quiet, then polls for the HTML report for 30 s, then kills MT5. + // If no inactivity_kill_secs is given (default None → disabled), the monitor relies + // solely on timeout (900 s) or natural MT5 exit for completion detection. shutdown: args.get("shutdown").and_then(|v| v.as_bool()).unwrap_or(true), kill_existing: false, timeout: args.get("timeout").and_then(|v| v.as_u64()).unwrap_or(900),