Make the judge's prompt readable on its own, ask once before the full scan, and sort imports by their first binding

This commit is contained in:
2026-10-03 16:02:02 +02:00
parent e9365c26fc
commit ce1ee9b6d2
19 changed files with 81 additions and 62 deletions
+2 -2
View File
@@ -3,11 +3,11 @@ import os
import pathlib
import sys
from loop_claude.claude_code.session import session_files
from loop_claude.claude_code.transcript import first_timestamped_line
from loop_claude.failure import Failure
from loop_claude.claude_code.transcript import first_timestamped_line
from loop_claude.file_writes import make_private, replace_file
from loop_claude.paths import Paths
from loop_claude.claude_code.session import session_files
def archive(project_key: str, path: str, task: str, outcome: str, paths: Paths) -> Failure | None:
+3 -3
View File
@@ -1,13 +1,13 @@
import sys
import uuid
from loop_claude.claude_code.transcript import human_turns, read_transcript
from loop_claude.claude_code.trust import trust
from loop_claude.effects import Effects
from loop_claude.failure import Failure
from loop_claude.claude_code.transcript import human_turns, read_transcript
from loop_claude.stop import needs_human, needs_terminal, Stop
from loop_claude.paths import Paths
from loop_claude.claude_code.trust import trust
from loop_claude.project.checkout import worktrees
from loop_claude.stop import Stop, needs_human, needs_terminal
ANSWER_QUESTION = "answer the question above"
+8 -6
View File
@@ -3,12 +3,12 @@ import json
import re
import typing
from loop_claude.effects import Effects
from loop_claude.failure import Failure
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
from loop_claude.claude_code.entries import hit_limit, limit_said, parse_entry, structured_output
from loop_claude.cycle.limited import Limited
from loop_claude.cycle.retry import retried
from loop_claude.cycle.verdicts import Finished, Interrupt, QuotedAnswer, Unfinished, Verdict
from loop_claude.effects import Effects
from loop_claude.failure import Failure
from loop_claude.stop import Stop
# At 3 to 4 characters a token, 100,000 to 133,000 tokens, which leaves a 200,000-token context room for the reply; the largest session rendered here was 364,000 characters on 2026-10-03.
@@ -21,9 +21,9 @@ JUDGE_RULES = (
"- it carried on under an assumption that decides the deliverable, that the human could "
"reasonably reject and that neither README.md nor the project's records settle; a caveat about "
"transient state it then handled is not one\n"
"- it is blocked on something only the human can supply: a credential, a version bump, a release "
"ready to cut, a choice outside the repo\n"
"- it flags that the goals, the plan or the task itself is unclear, missing or in need of change\n"
"- it is blocked on something only the human can supply: a credential, a version bump, the go-ahead "
"to publish a release, a choice outside the repo\n"
"- it flags that the goals, the plan in todo.md or the task itself is unclear, missing or in need of change\n"
"- it chose between alternatives that neither README.md nor the project's records discriminate "
"between - neither rules the rejected one out - and the choice materially changes the deliverable\n"
"interrupt=false otherwise. Bookkeeping the agent settled silently - what to document, wording, "
@@ -36,6 +36,7 @@ JUDGE_RULES = (
"Where README.md or the project's records answer the agent's own question and no [loop] line has "
"quoted that answer yet, set interrupt=false, put that question in question and quote the passage that answers it in answer, verbatim; the agent is "
"then given that passage in place of the human's reply.\n"
"The chunk is the one piece of work the task asks for, shipped as one pull request. "
"finished=true when the chunk is complete: merged, or nothing remains that the agent could do on "
"its own. finished=false when work remains that a further run can continue: an open PR, a review "
"not yet run, CI not yet reported."
@@ -60,6 +61,7 @@ JUDGE_SCHEMA = {
def judge(root: str, task: str, premises: str, records: str, rendered_transcript: str, model: str, effects: Effects) -> Verdict | Stop:
# --json-schema has claude check its reply against the schema and return it as the json result's structured_output.
# No tools, so the verdict rests on the transcript grounded() checks it against; no persistence, so its runs stay out of the session picker.
args = [
"-p",
+1 -1
View File
@@ -1,9 +1,9 @@
import sys
import typing
from loop_claude.cycle.limited import Limited
from loop_claude.effects import Effects
from loop_claude.failure import Failure
from loop_claude.cycle.limited import Limited
from loop_claude.stop import Stop
T = typing.TypeVar("T")
+9 -9
View File
@@ -1,20 +1,20 @@
import dataclasses
import typing
from loop_claude.claude_code.session import Session, delete_session, session_open, transcript_file
from loop_claude.claude_code.transcript import read_transcript, render
from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, HumanAnswered, Interrupting, Judging, Ruled, State, transition, WorkerRan, Working
from loop_claude.cycle.archive import archive
from loop_claude.cycle.interrupt import interrupt
from loop_claude.cycle.judge import judge
from loop_claude.cycle.retry import retried
from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, HumanAnswered, Interrupting, Judging, Ruled, State, WorkerRan, Working, transition
from loop_claude.cycle.verdicts import Finished, QuotedAnswer, Unfinished
from loop_claude.cycle.worker import run_worker, worker_args
from loop_claude.claude_code.session import delete_session, Session, session_open, transcript_file
from loop_claude.effects import Effects
from loop_claude.failure import Failure
from loop_claude.paths import Paths
from loop_claude.cycle.verdicts import Finished, QuotedAnswer, Unfinished
from loop_claude.cycle.interrupt import interrupt
from loop_claude.cycle.judge import judge
from loop_claude.project.model_choice import Models
from loop_claude.paths import Paths
from loop_claude.project.records import QUOTE_SOURCES
from loop_claude.claude_code.transcript import read_transcript, render
from loop_claude.cycle.retry import retried
from loop_claude.cycle.worker import run_worker, worker_args
from loop_claude.stop import Stop
+5 -4
View File
@@ -1,11 +1,11 @@
from loop_claude.claude_code.entries import assistant_parts, ends_stream, hit_limit, limit_said, parse_entry, rejected_until
from loop_claude.claude_code.session import Session
from loop_claude.claude_code.transcript import part_line
from loop_claude.cycle.limited import Limited
from loop_claude.cycle.verdicts import QuotedAnswer
from loop_claude.effects import Effects
from loop_claude.failure import Failure
from loop_claude.cycle.limited import Limited
from loop_claude.claude_code.transcript import part_line
from loop_claude.project.records import QUOTE_SOURCES
from loop_claude.cycle.verdicts import QuotedAnswer
from loop_claude.claude_code.session import Session
PRINTED_TOOL_INPUT = 160
@@ -46,6 +46,7 @@ def worker_args(task: str, session: Session, model: str, resuming: bool, answere
start = ["-p", "Continue the task; the previous run stopped before it was finished.", "--resume", str(session.id)]
else:
start = ["-p", f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one.", "--name", session.name, "--session-id", str(session.id)]
# --session-id starts a session under the id loop-claude keeps, which --resume continues; -p needs --verbose for stream-json, one JSON event a line, the last a result event.
return [
*start,
"--output-format", "stream-json",
+5 -5
View File
@@ -71,15 +71,15 @@ import pathlib
import sys
import typing
from loop_claude.claude_code.session import session_for
from loop_claude.cycle.run import Cycle, run_cycle
from loop_claude.effects import Effects
from loop_claude.loop.reload import RELOAD_FLAG, LoopRun, decode_handed, exec_if_edited, fingerprint
from loop_claude.paths import Paths
from loop_claude.project.checkout import checkout_root, project_key
from loop_claude.cycle.run import Cycle, run_cycle
from loop_claude.loop.reload import decode_handed, exec_if_edited, fingerprint, LoopRun, RELOAD_FLAG
from loop_claude.effects import Effects
from loop_claude.project.model_choice import get_or_ask_models
from loop_claude.paths import Paths
from loop_claude.project.premises import read_premises
from loop_claude.project.records import read_records
from loop_claude.claude_code.session import session_for
from loop_claude.stop import Stop
+2 -2
View File
@@ -7,9 +7,9 @@ import typing
from loop_claude.claude_code.model_catalog import catalog_models
from loop_claude.effects import Effects
from loop_claude.failure import Failure
from loop_claude.file_writes import replace_json
from loop_claude.stop import needs_human, needs_terminal, Stop
from loop_claude.paths import Paths
from loop_claude.stop import Stop, needs_human, needs_terminal
from loop_claude.file_writes import replace_json
@dataclasses.dataclass(frozen=True)
+1 -1
View File
@@ -1,5 +1,5 @@
from loop_claude.markdown_sections import sections
from loop_claude.project.checkout import read_checkout_file
from loop_claude.markdown_sections import sections
from loop_claude.stop import Stop