perf(ops): streamline log capture and git error reporting

Co-authored-by: genichin <4282227+genichin@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-09-13 16:12:55 +09:00
committed by Hermes Agent
co-authored by genichin
parent 619feff5f4
commit 8378e03dcc
3 changed files with 43 additions and 17 deletions
+25 -16
View File
@@ -15,6 +15,7 @@ import hashlib
import json
import shutil
import subprocess
from collections import deque
from datetime import UTC, date, datetime
from pathlib import Path
from typing import Any
@@ -56,11 +57,18 @@ def find_ledger_gap_slots(
def _run_git(checkout_dir: Path, *args: str) -> str:
return subprocess.check_output(
["git", *args],
cwd=str(checkout_dir),
text=True,
).strip()
command = ["git", *args]
try:
return subprocess.check_output(
command,
cwd=str(checkout_dir),
text=True,
).strip()
except subprocess.CalledProcessError as exc:
joined = " ".join(command)
raise RuntimeError(
f"git command failed in checkout={checkout_dir}: {joined}"
) from exc
def _porcelain_paths(status_output: str) -> list[str]:
@@ -125,17 +133,18 @@ def _capture_command(command: list[str], checkout_dir: Path) -> dict:
def _capture_broker_side_effect_logs(log_path: Path) -> dict:
if not log_path.exists():
return {"path": str(log_path), "exists": False, "matches": []}
matches: list[str] = []
for line in log_path.read_text(encoding="utf-8", errors="replace").splitlines():
lowered = line.lower()
if (
"event=order_submit" in lowered
or "event=order_fill" in lowered
or "event=order_reject" in lowered
or "cancel" in lowered
):
matches.append(line)
return {"path": str(log_path), "exists": True, "matches": matches[-200:]}
matches: deque[str] = deque(maxlen=200)
with log_path.open("r", encoding="utf-8", errors="replace") as fp:
for line in fp:
lowered = line.lower()
if (
"event=order_submit" in lowered
or "event=order_fill" in lowered
or "event=order_reject" in lowered
or "cancel" in lowered
):
matches.append(line.rstrip("\n"))
return {"path": str(log_path), "exists": True, "matches": list(matches)}
def collect_release_provenance(