Work in progress: Bash output ceiling and refusing Reads of session transcripts
This commit is contained in:
+22
-13
@@ -1,6 +1,6 @@
|
||||
"""Replay a review pass's archived rounds on the rungs below the project's, to find which rungs may run its reviewer: docs/decisions.md → `routing: a review pass runs below the project's rung only on a rung whose replay of its rounds finds a share of their 🔴 and 🟡 findings no more than a margin below the project's rung's own replay`.
|
||||
|
||||
usage: review-replay <pass> <model> [--omit-claude-md]
|
||||
usage: review-replay <pass> <model> [--omit-claude-md | --bash-ceiling | --read-limit]
|
||||
|
||||
<pass> is one of architecture, principles, overrides, stability, product-owner or prose.
|
||||
<model> is a project model on the routing ladder this setup ships, such as claude-opus-5-5. The tool replays the
|
||||
@@ -45,8 +45,16 @@ replay, and runs no SubagentStart hook there. So the replay without CLAUDE.md tu
|
||||
instruction files off in its settings and opens the prompt with what the hook hands a reviewer, and
|
||||
closes it with the header's line on the project principles.
|
||||
|
||||
--bash-ceiling and --read-limit run the same comparison for the output limits loop-claude hands the worker's
|
||||
claude, which a subagent inherits (bin/claude_code/output_limits.py): the replay with the change starts under
|
||||
BASH_MAX_OUTPUT_LENGTH, which saves a longer Bash result to a file and hands the reviewer its path and the
|
||||
first 2,000 characters, or under CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS, which fails a Read of more tokens
|
||||
than that. It passes where it missed no more of the findings both of the first two found than the most an
|
||||
unchanged replay missed. It doesn't count what the replays read: each run's stream, with every tool result,
|
||||
is in the archive.
|
||||
|
||||
It keeps each run, a reviewer's tool calls included, and the report it prints in loop-claude's archive, in
|
||||
replays/review-replay-<pass>-<model>[-omit-claude-md]-<UTC stamp>/ under ~/.claude/loop-claude-transcripts
|
||||
replays/review-replay-<pass>-<model>[-<flag without its dashes>]-<UTC stamp>/ under ~/.claude/loop-claude-transcripts
|
||||
or $LOOP_CLAUDE_TRANSCRIPTS. A run's .jsonl file starts with a line holding claude's arguments, working
|
||||
directory, prompt, exit code and stderr, then holds claude's stream-json output; result.md holds the report.
|
||||
|
||||
@@ -64,7 +72,8 @@ 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 review_replay.replay import codes_found, findings_replayed
|
||||
from review_replay.omit_comparison import compared
|
||||
from review_replay.change_comparison import compared
|
||||
from review_replay.changes import Change, CHANGES
|
||||
from loop_effects.effects import Effects
|
||||
from failure import Failure
|
||||
from model_routing.ladder import Ladder, Rung
|
||||
@@ -74,8 +83,7 @@ from review_replay.recall import recall_report, recalled
|
||||
from review_rules.review_passes import ReviewedPass, REVIEWERS
|
||||
|
||||
TOOL = "review-replay"
|
||||
OMIT = "--omit-claude-md"
|
||||
USAGE = f"{TOOL} <pass> <model> [{OMIT}], <pass> one of {', '.join(REVIEWERS)} and <model> a model on the routing ladder"
|
||||
USAGE = f"{TOOL} <pass> <model> [{' | '.join(change.flag for change in CHANGES)}], <pass> one of {', '.join(REVIEWERS)} and <model> a model on the routing ladder"
|
||||
LATEST = 10
|
||||
|
||||
|
||||
@@ -87,7 +95,7 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff
|
||||
read = arguments_or_exit(TOOL, argv, __doc__, USAGE, lambda argv: pass_and_model(ladder, argv))
|
||||
if isinstance(read, int):
|
||||
return read
|
||||
reviewed, project, without = read
|
||||
reviewed, project, change = read
|
||||
rounds = archived_rounds(REVIEWERS[reviewed], project.model, archive_root(home, env), home)
|
||||
if isinstance(rounds, Failure):
|
||||
return failed(TOOL, rounds.reason)
|
||||
@@ -97,15 +105,15 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff
|
||||
chosen = sample(list(codes), LATEST)
|
||||
folder = replay_folder(archive_root(home, env), TOOL, argv, effects.now())
|
||||
effects = archiving(effects, folder)
|
||||
if without:
|
||||
report = compared(reviewed, project, chosen, lambda found, bare: findings_replayed(found, codes[found], project, project, home, effects, bare))
|
||||
if change:
|
||||
report = compared(reviewed, project, chosen, change, lambda found, applied: findings_replayed(found, codes[found], project, project, home, effects, applied))
|
||||
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, False)
|
||||
matched = findings_replayed(found, codes[found], rung, project, home, effects, None)
|
||||
if isinstance(matched, Failure):
|
||||
print(f" {found.root} {found.at} on {rung} failed: {matched.reason}", file=sys.stderr, flush=True)
|
||||
return matched
|
||||
@@ -117,10 +125,11 @@ def main(argv: list[str], env: typing.Mapping[str, str], home: pathlib.Path, eff
|
||||
return 0
|
||||
|
||||
|
||||
def pass_and_model(ladder: Ladder, argv: list[str]) -> tuple[ReviewedPass, Rung, bool] | None:
|
||||
"""The pass, the project's rung on ladder of the model, and whether OMIT follows, as argv names them in `<pass> <model> [--omit-claude-md]`; None for any other argv."""
|
||||
if argv[2:] not in ([], [OMIT]) or len(argv) < 2:
|
||||
def pass_and_model(ladder: Ladder, argv: list[str]) -> tuple[ReviewedPass, Rung, Change | None] | None:
|
||||
"""The pass, the project's rung on ladder of the model, and the change a flag names, as argv names them in `<pass> <model> [<flag>]`; None for any other argv."""
|
||||
change = next((each for each in CHANGES if argv[2:] == [each.flag]), None)
|
||||
if argv[2:] and change is None or len(argv) < 2:
|
||||
return None
|
||||
reviewed = next((kind for kind in REVIEWERS if kind == argv[0]), None)
|
||||
project = ladder.project_rung(argv[1])
|
||||
return (reviewed, project.rung, argv[2:] == [OMIT]) if reviewed and project else None
|
||||
return (reviewed, project.rung, change) if reviewed and project else None
|
||||
|
||||
Reference in New Issue
Block a user