Files
nt8-sdk/tools/logtriage/README.md
mo d84949caa3 chore: checkpoint remaining pre-gate worktree changes
- governance: stage v7.0 review prompts, run book, roadmap/current-status/decision updates, and sprint board state

- adapters: capture DASH/trailing-drawdown/state-telemetry strategy work already present in the worktree

- tools: capture dashboard console/KPI parser updates, logtriage notes, and runnersweep output

Build: previously clean | Tests: previously 511 passing | Includes all open staged files
2026-08-21 14:53:15 -04:00

71 lines
3.6 KiB
Markdown

# logtriage
`logtriage` is a standalone Python CLI for triaging NT8 SDK runtime artifacts without referencing any NinjaTrader assembly or changing deployed NT8 output.
Python was chosen instead of a .NET console app because it keeps the tool fully outside `NT8-SDK.sln`, requires no solution or publish changes, and avoids any chance of being pulled into `NinjaTrader.Custom.dll` deployment.
## Inputs
The script reads these files from a directory:
- `session_*.log`
- `trades_*.jsonl`
- `provenance_*.json`
- `settings_*.txt`
Default input directory:
`%USERPROFILE%\Documents\NinjaTrader 8\log\nt8-sdk`
## Output
Text mode prints:
1. A per-day table with:
`Date | Account | Instrument | BarType | DaysToLoad | DailyBars | WarmupOK | Signals | Submits | Fills | NetPnL | KillSwitch | VerboseLog | ConfigHash(8) | TestMode`
2. A `DIAGNOSTICS` section flagging:
`SILENT DAY`, `PARALLEL INSTANCE`, `NO CONFIG CAPTURE`, `GATE CONFIG VIOLATION`, `CONFIG DRIFT`, and `PROVENANCE DEFECT`
`--json` emits machine-readable output for dashboard ingestion, including session rows, diagnostics, and per-trade records enriched with source file and line metadata.
### REJECT / REJECT SUMMARY parsing
Each session row now also includes:
- `reject_summaries`: every `REJECT SUMMARY: reason=<Reason> count=<count>` line encountered, in file order, as `{date, reason, count, line}`. Because GAP-035 writes these as periodic cumulative snapshots (first live rejection at/after 10:00 ET, then every 15 bar-minutes, plus a final snapshot at session end), this is a history of counts over the session, not a single tally.
- `reject_records`: every `REJECT: reason=<Reason> detail=<Detail> bar=<time>` line, as `{date, reason, detail, bar, line}`. GAP-035 logs at most one of these per unique reason per session.
- `reject_summary_final`: the last observed count per reason, i.e. `{reason: count}` derived from `reject_summaries` — this is the number to cite for "how many times did X block a trade this session."
The `SILENT DAY` diagnostic now includes a `Rejections: <reason>=<count>, ...` breakdown in its message (and a machine-readable `reject_totals` field) whenever `reject_summary_final` data is available for the day, so a silent day is self-explanatory instead of just flagged.
Parsing uses `parse_key_values()`, which bounds each value by the next known key marker (`reason=`, `detail=`, `bar=`, `count=`) rather than splitting on whitespace or `=`, since `detail` text can itself contain `=` (e.g. the `GradeFilter` factor breakdown `Factors=<factor>=<score>x<weight>;...`). This is the canonical parser; `tools/dashboard/server.py` no longer keeps its own copy.
## Usage
Run against the default NT8 SDK log directory:
```powershell
python tools/logtriage/logtriage.py
```
Run against a specific archive directory:
```powershell
python tools/logtriage/logtriage.py "C:\logs\nt8-sdk-archive"
```
Emit JSON for another tool or dashboard:
```powershell
python tools/logtriage/logtriage.py --json | Out-File -Encoding utf8 triage.json
```
## Notes
- The tool is read-only.
- It does not import or reference any NinjaTrader or NT8 SDK assembly.
- Session rows are built from `session_*.log` and enriched with nearest same-day `settings_*.txt` and `provenance_*.json` snapshots.
- JSON session rows include `config_hash`, `config_hash_8`, and `code_version` when present in settings or provenance artifacts.
- JSON output includes `trade_records` copied from `trades_*.jsonl` with added `date`, `path`, and `line` fields for dashboard traceability.
- Trade provenance defects are scanned directly from `trades_*.jsonl` rows.