Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
# (so they are not surfaced as an "unrecognized" synonym). Any outcome token in
# neither set is surfaced under provenance.unrecognized_outcomes.
_HONEST_RED_OUTCOME_TOKENS = (
"repair_triggered", "task_failed", "replan", "reverted", "revert",
"blocked", "terminated", "aborted", "failed",
"repair_triggered", "task_failed", "approval_requested", "replanned",
"replan", "reverted", "revert", "blocked", "terminated", "aborted", "failed",
)
_KNOWN_OUTCOME_TOKENS = frozenset(_SUCCESS_OUTCOME_TOKENS) | frozenset(_HONEST_RED_OUTCOME_TOKENS)

Expand Down
17 changes: 17 additions & 0 deletions scripts/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import metrics

from loop import emit

_REPO = Path(__file__).resolve().parent.parent
_EXAMPLE = _REPO / "examples" / "coverage-repair"

Expand Down Expand Up @@ -687,3 +689,18 @@ def test_baseline_refuses_when_a_counted_rp_record_is_unanchored(tmp_path):
ok, _sc, reasons = metrics.build_baseline(ws, "ws")
assert ok is False
assert any("anchor" in r.lower() for r in reasons)


def test_every_emitted_outcome_token_is_recognized(tmp_path):
# Round-trip: every token emit.append_iteration will write must be a token
# metrics.py recognizes — none may leak into provenance.unrecognized_outcomes.
# Iterate the real tuple so a new emit outcome can't silently drift unrecognized.
ws = tmp_path / "ws"
emit.open_contract(ws)
# Drop the scaffold-seeded RUNLOG (it carries the {{ITERATION_OUTCOME}} placeholder,
# issue #40) so append_iteration writes a clean header and only real outcome tokens.
(ws / "RUNLOG.md").unlink()
for iteration_id, outcome in enumerate(emit._ITERATION_OUTCOMES, start=1):
emit.append_iteration(ws, iteration_id=iteration_id, outcome=outcome)
sc = metrics.compute_metrics(ws)
assert sc["provenance"]["unrecognized_outcomes"] == []
Loading