Return the verdict from run_cycle's judge–interrupt loop #113
@@ -19,25 +19,29 @@ def run_cycle(root, task, premises, models, paths):
|
|||||||
path = transcript_file(session)
|
path = transcript_file(session)
|
||||||
if not path:
|
if not path:
|
||||||
return Stop(1, f"claude left no transcript for session {session.id}")
|
return Stop(1, f"claude left no transcript for session {session.id}")
|
||||||
|
verdict = judge_through_interrupts(root, task, premises, models, session, path, paths)
|
||||||
|
if isinstance(verdict, Stop):
|
||||||
|
return verdict
|
||||||
|
if verdict["finished"]:
|
||||||
|
if failure := archive(root, path, f"Task: {task}\n\nVerdict: finished", paths):
|
||||||
|
return Stop(1, failure.reason)
|
||||||
|
delete_session(session)
|
||||||
|
return Continue()
|
||||||
|
|
||||||
|
|
||||||
|
def judge_through_interrupts(root, task, premises, models, session, path, paths):
|
||||||
# The interrupt appends to this transcript, so each pass judges and archives it anew.
|
# The interrupt appends to this transcript, so each pass judges and archives it anew.
|
||||||
while True:
|
while True:
|
||||||
entries = read(path)
|
entries = read(path)
|
||||||
if isinstance(entries, Failure):
|
if isinstance(entries, Failure):
|
||||||
return Stop(1, entries.reason)
|
return Stop(1, entries.reason)
|
||||||
verdict = judge(root, task, premises, render(entries), models.judge)
|
verdict = judge(root, task, premises, render(entries), models.judge)
|
||||||
if isinstance(verdict, Stop):
|
if isinstance(verdict, Stop) or not verdict["interrupt"]:
|
||||||
return verdict
|
return verdict
|
||||||
if not verdict["interrupt"]:
|
|
||||||
break
|
|
||||||
if failure := archive(root, path, f"Task: {task}\n\nVerdict: interrupt\n\n{verdict['question']}", paths):
|
if failure := archive(root, path, f"Task: {task}\n\nVerdict: interrupt\n\n{verdict['question']}", paths):
|
||||||
return Stop(1, failure.reason)
|
return Stop(1, failure.reason)
|
||||||
if stop := interrupt(root, session.id, models.worker, path, verdict["question"], paths):
|
if stop := interrupt(root, session.id, models.worker, path, verdict["question"], paths):
|
||||||
return stop
|
return stop
|
||||||
if verdict["finished"]:
|
|
||||||
if failure := archive(root, path, f"Task: {task}\n\nVerdict: finished", paths):
|
|
||||||
return Stop(1, failure.reason)
|
|
||||||
delete_session(session)
|
|
||||||
return Continue()
|
|
||||||
|
|
||||||
|
|
||||||
def archive(root, path, note, paths):
|
def archive(root, path, note, paths):
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ The rebuild lifts every dimension: each item below is one chunk on a worktree ba
|
|||||||
|
|
||||||
The places the panel on `rebuild` at 37edc9a named (`docs/decisions.md`), capping dimension first:
|
The places the panel on `rebuild` at 37edc9a named (`docs/decisions.md`), capping dimension first:
|
||||||
|
|
||||||
- **Return the verdict from `run_cycle`'s judge–interrupt loop, so nothing reads `verdict` after it.** Three seats; `archive`'s skip on an existing copy holds only because each interrupt appends a turn.
|
|
||||||
- **Name the minute `strike` sleeps, and the exec `reload_if_edited` may not return from, where each is called.** Four seats and three.
|
- **Name the minute `strike` sleeps, and the exec `reload_if_edited` may not return from, where each is called.** Four seats and three.
|
||||||
- **Let `render` join a human entry's text without relying on `user_entry_kind` having checked every part.** Three seats.
|
- **Let `render` join a human entry's text without relying on `user_entry_kind` having checked every part.** Three seats.
|
||||||
- **Give failure one spelling: `Failure.reason` and `Retry.failure`, `replace_file`'s raw `OSError`, and `typed`/`said` named for what they test.** Keep `LoopState`'s fields: they are main's `--reloaded` state (`docs/decisions.md`).
|
- **Give failure one spelling: `Failure.reason` and `Retry.failure`, `replace_file`'s raw `OSError`, and `typed`/`said` named for what they test.** Keep `LoopState`'s fields: they are main's `--reloaded` state (`docs/decisions.md`).
|
||||||
|
|||||||
Reference in New Issue
Block a user