Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s
CI / tests (pull_request) Successful in 3m43s
This commit is contained in:
+13
-12
@@ -67,22 +67,22 @@ none. Exit 1, saying why, on bad arguments, an unreadable archive or models file
|
||||
round to replay, or a usage limit.
|
||||
"""
|
||||
import pathlib
|
||||
import sys
|
||||
import typing
|
||||
|
||||
from transcript_archive.location import archive_root
|
||||
from review_replay.rounds import archived_rounds, Round, sample
|
||||
from rung_replay.archive import archiving, print_report, replay_folder
|
||||
from rung_replay.command import arguments_or_exit, failed, limited_exit
|
||||
from rung_replay.archive import archiving, replay_folder
|
||||
from rung_replay.command import arguments_or_exit, failed, limited_exit, print_report, say
|
||||
from rung_replay.search import AT_ONCE
|
||||
from review_replay.changes import Change, CHANGES
|
||||
from review_replay.replay import codes_found, findings_replayed
|
||||
from review_replay.change_comparison import compared
|
||||
from loop_effects.effects import Effects
|
||||
from review_replay.recall import ENOUGH_ROUNDS, recall_report, recalled
|
||||
from failure import Failure
|
||||
from model_routing.ladder import Ladder, Rung
|
||||
from claude_code.reply import Limited
|
||||
from model_routing.ladder_file import read_ladder, SHIPPED
|
||||
from review_replay.recall import recall_report, recalled
|
||||
from review_rules.review_passes import ReviewedPass, REVIEWERS
|
||||
|
||||
TOOL = "review-replay"
|
||||
@@ -90,7 +90,8 @@ USAGE = f"{TOOL} <pass> <model> [{' | '.join(change.flag for change in CHANGES)}
|
||||
LATEST = 10
|
||||
|
||||
|
||||
def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, effects: Effects) -> int:
|
||||
# A test sets the three limits: the fewest rounds a rung is tried on, the rounds replayed at once, and the folder each clone is made in, the system's temporary folder where None.
|
||||
def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, effects: Effects, *, enough_rounds: int = ENOUGH_ROUNDS, at_once: int = AT_ONCE, scratch: pathlib.Path | None = None) -> int:
|
||||
# The shipped ladder, not a project's: the replay spans every project on the model.
|
||||
ladder = read_ladder(SHIPPED)
|
||||
if isinstance(ladder, Failure):
|
||||
@@ -105,29 +106,29 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff
|
||||
rounds = archived_rounds(REVIEWERS[reviewed], project.model, archive_root(home, env), home)
|
||||
if isinstance(rounds, Failure):
|
||||
return failed(TOOL, rounds.reason)
|
||||
codes = codes_found(rounds, effects)
|
||||
codes = codes_found(rounds, effects, say)
|
||||
if not codes:
|
||||
return failed(TOOL, f"no archived {reviewed} round of projects on {project.model} in {archive_root(home, env)} holds a 🔴 or 🟡 on code it can find")
|
||||
chosen = sample(list(codes), LATEST)
|
||||
folder = replay_folder(archive_root(home, env), TOOL, argv, effects.now())
|
||||
effects = archiving(effects, folder)
|
||||
effects = archiving(effects, folder, say)
|
||||
if change:
|
||||
report = compared(reviewed, project, chosen, change, lambda found, applied: findings_replayed(found, codes[found], project, project, home, effects, applied))
|
||||
report = compared(reviewed, project, chosen, change, lambda found, applied: findings_replayed(found, codes[found], project, project, home, effects, applied, scratch), say, at_once)
|
||||
if isinstance(report, Limited):
|
||||
return limited_exit(TOOL, report)
|
||||
print_report(folder, report)
|
||||
return 0
|
||||
|
||||
def replay_one(found: Round, rung: Rung) -> set[int] | Failure | Limited:
|
||||
matched = findings_replayed(found, codes[found], rung, project, home, effects, None)
|
||||
matched = findings_replayed(found, codes[found], rung, project, home, effects, None, scratch)
|
||||
if isinstance(matched, Failure):
|
||||
print(f" {found.root} {found.at} on {rung} failed: {matched.reason}", file=sys.stderr, flush=True)
|
||||
say(f" {found.root} {found.at} on {rung} failed: {matched.reason}")
|
||||
return matched
|
||||
|
||||
recall = recalled(chosen, ladder, project, replay_one, f"{reviewed} rounds")
|
||||
recall = recalled(chosen, ladder, project, replay_one, f"{reviewed} rounds", say, at_once, enough_rounds)
|
||||
if isinstance(recall, Limited):
|
||||
return limited_exit(TOOL, recall)
|
||||
print_report(folder, recall_report(reviewed, project, recall))
|
||||
print_report(folder, recall_report(reviewed, project, recall, enough_rounds))
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user