agent_harness -> rein_aharness (package + all imports), CLI command agent-harness -> rein-aharness, Docker image tag, k8s namespace/labels/ names, Makefile targets, deploy script env var/paths. In-repo identity strings (hub event source, metrics harness field, default assignee, argparse prog name, commit author identity) updated to match. Historical documents left untouched on purpose: docs/adr/ADR-001-agent-harness-architecture.md, docs/architecture.md (dated v0.1 snapshot), workplans/HARNESS-WP-0001 (completed under the old name), and the SSH host alias "forgejo-agent-harness" (external ~/.ssh/config entry, not owned here). Verified: 47/47 tests pass, CLI runs correctly from a fresh venv, `make image` builds and the resulting container runs correctly. deploy/README.md gained an explicit rename cutover checklist for what this session cannot safely do unattended -- moving the host-side secrets dir and checkout on railiance01, and not deleting the old k8s namespace until the new one is confirmed working. The actual live cutover (running that checklist against the real Railiance deployment) is not attempted here -- real production surgery on binky-control's live automation, needs the operator present. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from rein_aharness.metrics import record_execution, regenerate_summary
|
|
|
|
|
|
def test_record_execution_writes_jsonl_and_summary(tmp_path: Path) -> None:
|
|
path = record_execution(
|
|
tmp_path,
|
|
"coach",
|
|
success=True,
|
|
execution_time_s=12.5,
|
|
tokens=100,
|
|
committed=True,
|
|
head_after="abc123",
|
|
reason=None,
|
|
metadata={"task_title": "hello"},
|
|
)
|
|
assert path.is_file()
|
|
lines = path.read_text(encoding="utf-8").strip().splitlines()
|
|
assert len(lines) == 1
|
|
rec = json.loads(lines[0])
|
|
assert rec["agent"] == "coach"
|
|
assert rec["success"] is True
|
|
assert rec["tokens"] == 100
|
|
assert rec["harness"] == "rein-aharness"
|
|
assert rec["metadata"]["task_title"] == "hello"
|
|
|
|
summary = json.loads(
|
|
(tmp_path / ".kaizen" / "metrics" / "coach" / "summary.json").read_text()
|
|
)
|
|
assert summary["execution_count"] == 1
|
|
assert summary["success_rate"] == 1.0
|
|
assert summary["avg_execution_time_s"] == 12.5
|
|
|
|
|
|
def test_summary_aggregates_multiple(tmp_path: Path) -> None:
|
|
record_execution(tmp_path, "coach", success=True, execution_time_s=10)
|
|
record_execution(tmp_path, "coach", success=False, execution_time_s=20)
|
|
summary = json.loads(
|
|
(tmp_path / ".kaizen" / "metrics" / "coach" / "summary.json").read_text()
|
|
)
|
|
assert summary["execution_count"] == 2
|
|
assert summary["success_rate"] == 0.5
|
|
assert summary["avg_execution_time_s"] == 15.0
|
|
|
|
|
|
def test_regenerate_summary_empty() -> None:
|
|
assert regenerate_summary("x", [])["execution_count"] == 0
|