diff --git a/docs/WATCH.md b/docs/WATCH.md index 19d0565..64cb864 100644 --- a/docs/WATCH.md +++ b/docs/WATCH.md @@ -140,7 +140,28 @@ Interval : PT4H # 10:03 / 14:03 / 18:03 / 22:03 / 02:03 / 06:03 1. **同一秒扎堆** —— 真实一轮至少跑几十秒,几行全在 `HH:MM:SS` 同一秒就是测试 2. **内容自相矛盾** —— 比如"powershell not found",而 powershell 明明在 3. **对不上报告** —— 去 `~/lc_mcp/modules/` 找同一时刻的 `convert_*.json`; - 真实的运行一定有报告(`elapsed_s` 不为 0),mock 产生的没有 + 真实的运行一定有报告,且 `elapsed_s` 不为 0 确认是残留就直接删掉,别让它留在"病史"里。 +> ⚠️ 第 3 条要注意时间对应关系:**日志的结论行写在一轮结束时,报告的 `started` +> 是开始时**,两者天然差一个 `elapsed_s`。正确的关系是 +> `报告.started + elapsed ≈ 日志结论时刻`(实测 6/6 吻合)。 +> 直接拿两个时间戳比会全部"对不上",反而误判成异常 —— 我自己第一次就这么错过了。 + +### 交叉核对脚本(可直接抄) + +```powershell +$dir = "$env:USERPROFILE\lc_mcp\modules" +$runs = Get-Content "$dir\convert.log" -Encoding UTF8 | Where-Object { $_ -match '=== ' } | + ForEach-Object { if ($_ -match '^\[(.+?)\]\s*===\s*(.+?)\s*\((\w+)\), 耗时 (\d+)s ===') { + [pscustomobject]@{ end=[datetime]$Matches[1]; result=$Matches[2]; secs=[int]$Matches[4] } } } +Get-ChildItem "$dir\convert_*.json" | ForEach-Object { + $r = Get-Content $_.FullName -Encoding UTF8 | ConvertFrom-Json + $expect = ([datetime]$r.started).AddSeconds($r.elapsed_s) + $m = $runs | Where-Object { [math]::Abs(($_.end - $expect).TotalSeconds) -lt 5 } | Select-Object -First 1 + if ($m -and $m.secs -eq $r.elapsed_s) { "OK $($r.started)" } else { "MISMATCH $($_.Name)" } +} +``` + +