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
This commit is contained in:
2026-08-21 14:53:15 -04:00
parent 28c30bca82
commit d84949caa3
31 changed files with 4844 additions and 142 deletions

View File

@@ -28,6 +28,18 @@ Text mode prints:
`--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:

View File

@@ -44,6 +44,34 @@ TEST_MODE_RE = re.compile(r"\|\s*<(TEST MODE ACTIVE|LIVE MODE)>", re.IGNORECASE)
KEY_VALUE_RE = re.compile(r"^([^:]+?)\s*:\s*(.*)$")
T = TypeVar("T")
REJECT_KEYS: Tuple[str, ...] = ("reason", "detail", "bar", "count")
def parse_key_values(text: str, keys: Sequence[str] = REJECT_KEYS) -> Dict[str, str]:
"""Extract key=value pairs from REJECT/REJECT SUMMARY payload text.
Values may contain spaces or even '=' characters of their own (e.g. the
GradeFilter detail's Factors=<factor>=<score>x<weight>;... breakdown),
so each value is bounded by the next known key marker rather than by
whitespace or a naive split on '='. This is the canonical parser for
these line formats; tools/dashboard/server.py delegates to it instead
of keeping its own copy.
"""
values: Dict[str, str] = {}
for index, key in enumerate(keys):
marker = key + "="
start = text.find(marker)
if start < 0:
continue
value_start = start + len(marker)
value_end = len(text)
for later_key in keys[index + 1:]:
later = text.find(" " + later_key + "=", value_start)
if later >= 0:
value_end = min(value_end, later)
values[key] = text[value_start:value_end].strip()
return values
def parse_args(argv: Sequence[str]) -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Summarize NT8 SDK session artifacts.")
@@ -136,6 +164,9 @@ class SessionSummary:
settings_captured: bool = False
session_id: Optional[str] = None
source_files: Dict[str, str] = field(default_factory=dict)
reject_summaries: List[Dict[str, Any]] = field(default_factory=list)
reject_records: List[Dict[str, Any]] = field(default_factory=list)
reject_summary_final: Dict[str, int] = field(default_factory=dict)
def to_dict(self) -> Dict[str, Any]:
return {
@@ -162,6 +193,9 @@ class SessionSummary:
"session_id": self.session_id,
"timestamp": self.timestamp.isoformat(),
"source_files": self.source_files,
"reject_summaries": self.reject_summaries,
"reject_records": self.reject_records,
"reject_summary_final": self.reject_summary_final,
}
@@ -294,6 +328,35 @@ def parse_session_file(path: Path) -> SessionSummary:
if "FILL " in line:
summary.fills += 1
if "REJECT SUMMARY:" in line:
parts = parse_key_values(line.split("REJECT SUMMARY:", 1)[1])
reason = parts.get("reason")
if reason:
count_text = parts.get("count")
count_value = 0
if count_text is not None:
try:
count_value = int(count_text)
except ValueError:
count_value = 0
summary.reject_summaries.append(
{"date": summary.date, "reason": reason, "count": count_value, "line": line}
)
summary.reject_summary_final[reason] = count_value
elif "REJECT:" in line:
parts = parse_key_values(line.split("REJECT:", 1)[1])
reason = parts.get("reason")
if reason:
summary.reject_records.append(
{
"date": summary.date,
"reason": reason,
"detail": parts.get("detail", ""),
"bar": parts.get("bar"),
"line": line,
}
)
pnl_match = PNL_RE.search(line)
if pnl_match:
summary.net_pnl = parse_float(pnl_match.group(1))
@@ -541,12 +604,24 @@ def build_diagnostics(
if session_rows:
day_activity = sum(row.signals + row.submits + row.fills for row in session_rows)
if day_activity == 0:
reject_totals: Dict[str, int] = {}
for row in session_rows:
for reason, count in row.reject_summary_final.items():
reject_totals[reason] = max(reject_totals.get(reason, 0), count)
message = "SESSION START present with zero SIGNAL/SUBMIT/FILL lines for the day."
if reject_totals:
breakdown = ", ".join(
"{0}={1}".format(reason, count)
for reason, count in sorted(reject_totals.items(), key=lambda item: -item[1])
)
message += " Rejections: " + breakdown
diagnostics.append(
{
"date": date,
"code": "SILENT DAY",
"message": "SESSION START present with zero SIGNAL/SUBMIT/FILL lines for the day.",
"message": message,
"sessions": [row.path.name for row in session_rows],
"reject_totals": reject_totals,
}
)