Answer product-owner round 1: 0 🔴, 1 🟡 (0 misread); stamp the transcript and trust lines through say

This commit is contained in:
2026-10-28 18:47:39 +01:00
parent 6e171fe2c0
commit c583900199
5 changed files with 18 additions and 18 deletions
+6 -6
View File
@@ -1,30 +1,30 @@
import json import json
import pathlib import pathlib
import sys import typing
from failure import Failure from failure import Failure
from file_writes import replace_json from file_writes import replace_json
# A failure only warns: claude still opens, and the human answers Claude Code's trust dialog. # A failure only warns: claude still opens, and the human answers Claude Code's trust dialog.
def trust(config: pathlib.Path, roots: list[str]) -> None: def trust(config: pathlib.Path, roots: list[str], note: typing.Callable[[str], None]) -> None:
try: try:
with open(config, encoding="utf-8") as handle: with open(config, encoding="utf-8") as handle:
data = json.load(handle) data = json.load(handle)
except (OSError, ValueError) as failure: except (OSError, ValueError) as failure:
print(f"could not read {config}: {getattr(failure, 'strerror', failure)}", file=sys.stderr) note(f"could not read {config}: {getattr(failure, 'strerror', failure)}")
return return
marked = mark_trusted(data, roots) marked = mark_trusted(data, roots)
if isinstance(marked, Failure): if isinstance(marked, Failure):
print(f"could not read {config}: {marked.reason}", file=sys.stderr) note(f"could not read {config}: {marked.reason}")
return return
updated, untrusted = marked updated, untrusted = marked
if not untrusted: if not untrusted:
return return
if unwritten := replace_json(config, updated, indent=2): if unwritten := replace_json(config, updated, indent=2):
print(f"could not write {config}: {unwritten.reason}", file=sys.stderr) note(f"could not write {config}: {unwritten.reason}")
return return
print("trusted for the interrupt: " + ", ".join(untrusted), file=sys.stderr) note("trusted for the interrupt: " + ", ".join(untrusted))
# Claude Code's config: {"projects": {"/home/me/code/log": {"hasTrustDialogAccepted": true, ...}}, ...} # Claude Code's config: {"projects": {"/home/me/code/log": {"hasTrustDialogAccepted": true, ...}}, ...}
+2 -2
View File
@@ -34,7 +34,7 @@ def put_question(question: str, answer_here: bool, effects: Effects) -> str | Ta
try: try:
answer = effects.input(ASK_ANSWER).strip() answer = effects.input(ASK_ANSWER).strip()
except EOFError: except EOFError:
print(file=sys.stderr) # Ends the prompt's line; it says nothing, so it gets no time. print(file=sys.stderr) # Ends the prompt's line. It isn't a message, so it gets no time.
return needs_human(ANSWER_QUESTION, "the input ended") return needs_human(ANSWER_QUESTION, "the input ended")
if not answer: if not answer:
return needs_human(ANSWER_QUESTION, "nothing was typed") return needs_human(ANSWER_QUESTION, "nothing was typed")
@@ -57,7 +57,7 @@ def talk(root: str, session_id: uuid.UUID, worker: Rung, path: str, paths: Paths
def hand_over(rung: Rung, args: list[str], root: str, paths: Paths, env: dict[str, str], effects: Effects) -> Failure | None: def hand_over(rung: Rung, args: list[str], root: str, paths: Paths, env: dict[str, str], effects: Effects) -> Failure | None:
"""Marks the checkout and each of its worktrees trusted, then runs claude on the terminal in root, on rung, with env added to its environment; the failure is why claude could not start.""" """Marks the checkout and each of its worktrees trusted, then runs claude on the terminal in root, on rung, with env added to its environment; the failure is why claude could not start."""
trust(paths.claude_json, worktrees(root, effects)) trust(paths.claude_json, worktrees(root, effects), lambda text: say(text, effects))
try: try:
effects.claude_on_terminal([*rung.flags(), "--permission-mode", "bypassPermissions", *args], root, env) effects.claude_on_terminal([*rung.flags(), "--permission-mode", "bypassPermissions", *args], root, env)
except OSError as failure: except OSError as failure:
+4 -4
View File
@@ -82,7 +82,7 @@ def stopped(cycle: Cycle, stop: Stop, why: str) -> Stop:
def archived_stop(project_archive: pathlib.Path, session: Session, task: str, route: Route, stop: Stop, why: str, effects: Effects) -> Stop: def archived_stop(project_archive: pathlib.Path, session: Session, task: str, route: Route, stop: Stop, why: str, effects: Effects) -> Stop:
"""stop, once archived with the route the worker holds. A failed archive exits 1 whatever the stop; when the stop was this archive failing, its reason is said once.""" """stop, once archived with the route the worker holds. A failed archive exits 1 whatever the stop; when the stop was this archive failing, its reason is said once."""
path = transcript_file(session) path = transcript_file(session)
failure = archive(project_archive, path, task, outcomes.stopped(route.worker_line(), why), effects.now()) if path else None failure = archive(project_archive, path, task, outcomes.stopped(route.worker_line(), why), effects.now(), lambda text: say(text, effects)) if path else None
return Stop(1, f"{failure.reason}\n{stop.reason}".rstrip()) if failure and failure.reason != stop.reason else stop return Stop(1, f"{failure.reason}\n{stop.reason}".rstrip()) if failure and failure.reason != stop.reason else stop
@@ -155,7 +155,7 @@ def rule(cycle: Cycle, transcript_path: str) -> Ruled | Stop:
def keep_rejection(cycle: Cycle, transcript_path: str, rejected: Rejected) -> Stop | None: def keep_rejection(cycle: Cycle, transcript_path: str, rejected: Rejected) -> Stop | None:
"""Archives a judge reply loop-claude rejected, so the archive shows what the judge returned before a retry or an exit 1.""" """Archives a judge reply loop-claude rejected, so the archive shows what the judge returned before a retry or an exit 1."""
if unkept := archive(cycle.project_archive, transcript_path, cycle.task, outcomes.rejected(rejected.reason, rejected.reply, str(judge_of(cycle))), cycle.effects.now()): if unkept := archive(cycle.project_archive, transcript_path, cycle.task, outcomes.rejected(rejected.reason, rejected.reply, str(judge_of(cycle))), cycle.effects.now(), lambda text: say(text, cycle.effects)):
return Stop(1, unkept.reason) return Stop(1, unkept.reason)
return None return None
@@ -183,7 +183,7 @@ def ran_on(cycle: Cycle, step_up: StepUp | None) -> Route:
def archive_stepped(cycle: Cycle, transcript_path: str, outcome: str, step_up: StepUp | None) -> Failure | None: def archive_stepped(cycle: Cycle, transcript_path: str, outcome: str, step_up: StepUp | None) -> Failure | None:
"""Archives the outcome of a ruling, then the step-up it made, if it made one. The first failure is returned.""" """Archives the outcome of a ruling, then the step-up it made, if it made one. The first failure is returned."""
for kept in (outcome, outcomes.stepped_up(step_up.after.worker_line())) if step_up else (outcome,): for kept in (outcome, outcomes.stepped_up(step_up.after.worker_line())) if step_up else (outcome,):
if failure := archive(cycle.project_archive, transcript_path, cycle.task, kept, cycle.effects.now()): if failure := archive(cycle.project_archive, transcript_path, cycle.task, kept, cycle.effects.now(), lambda text: say(text, cycle.effects)):
return failure return failure
return None return None
@@ -196,7 +196,7 @@ def question_for(ruling: Interrupt | QuotedAnswer) -> str:
def close(cycle: Cycle, transcript_path: str, verdict: Finished | Unfinished) -> Archived | Stop: def close(cycle: Cycle, transcript_path: str, verdict: Finished | Unfinished) -> Archived | Stop:
outcome = outcomes.finished(cycle.route.worker_line(), verdict.evidence, str(judge_of(cycle))) if isinstance(verdict, Finished) else outcomes.unfinished(cycle.route.worker_line(), verdict.evidence, str(judge_of(cycle)), verdict.escalation) outcome = outcomes.finished(cycle.route.worker_line(), verdict.evidence, str(judge_of(cycle))) if isinstance(verdict, Finished) else outcomes.unfinished(cycle.route.worker_line(), verdict.evidence, str(judge_of(cycle)), verdict.escalation)
if failure := archive(cycle.project_archive, transcript_path, cycle.task, outcome, cycle.effects.now()): if failure := archive(cycle.project_archive, transcript_path, cycle.task, outcome, cycle.effects.now(), lambda text: say(text, cycle.effects)):
return Stop(1, failure.reason) return Stop(1, failure.reason)
if isinstance(verdict, Finished) and (failure := delete_session(cycle.session)): if isinstance(verdict, Finished) and (failure := delete_session(cycle.session)):
return Stop(1, failure.reason) return Stop(1, failure.reason)
+2 -2
View File
@@ -247,7 +247,7 @@ def archive_step(archive_folder: pathlib.Path, session: Session, task: str, befo
if after is None or after.worker_line() == before.worker_line(): if after is None or after.worker_line() == before.worker_line():
return None return None
path = transcript_file(session) path = transcript_file(session)
failure = archive(archive_folder, path, task, outcomes.stepped_up(after.worker_line()), effects.now()) if path else None failure = archive(archive_folder, path, task, outcomes.stepped_up(after.worker_line()), effects.now(), lambda text: say(text, effects)) if path else None
return Stop(1, failure.reason) if failure else None return Stop(1, failure.reason) if failure else None
@@ -286,7 +286,7 @@ def fetched_plan(root: str) -> DefaultPlan | Failure:
def plan_item(plan: DefaultPlan | Failure, effects: Effects) -> Item | None: def plan_item(plan: DefaultPlan | Failure, effects: Effects) -> Item | None:
"""The item that routes a chunk, chunk_pick.chunk_item's pick from the default branch; None without one, so the chunk runs on the project's rung.""" """The item that routes a chunk, chunk_pick.chunk_item's pick from the default branch; None without one, so the chunk runs on the project's rung."""
# It says why through effects, as every loop-claude function that prints does; todo.md item 51 moves all of them to one injected effect, and splitting this one off first would only be undone. # It prints the reason itself, through effects, like the other loop-claude functions that print. todo.md item 51 moves them all to one injected effect, so changing this one alone would be undone.
if isinstance(plan, Failure): if isinstance(plan, Failure):
item: Item | Failure | None = plan item: Item | Failure | None = plan
elif isinstance(plan.todo, Failure): elif isinstance(plan.todo, Failure):
+4 -4
View File
@@ -1,7 +1,7 @@
import hashlib import hashlib
import os import os
import pathlib import pathlib
import sys import typing
from transcript_archive.location import chunk_folder, outcomes_of from transcript_archive.location import chunk_folder, outcomes_of
from failure import Failure from failure import Failure
@@ -11,8 +11,8 @@ from transcript_archive.outcomes import TASK
from utc_stamp import utc from utc_stamp import utc
def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, at: float) -> Failure | None: def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, at: float, note: typing.Callable[[str], None] = lambda text: None) -> Failure | None:
"""Keeps the transcript at path, its outcomes file and its session's files in project_archive, in the layout this package's docstring gives; the failure that stopped it, or None. The outcome is stamped and appended to the outcomes file, which opens with the task only when the copy is new.""" """Keeps the transcript at path, its outcomes file and its session's files in project_archive, in the layout this package's docstring gives; the failure that stopped it, or None. The outcome is stamped and appended to the outcomes file, which opens with the task only when the copy is new. Where a new copy lands, note is told where."""
try: try:
with open(path, "rb") as handle: with open(path, "rb") as handle:
raw = handle.read() raw = handle.read()
@@ -32,7 +32,7 @@ def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, a
for dest, data in ((outcomes, f"{TASK}{task}\n\n{stamped}\n".encode()), (copy, raw)): for dest, data in ((outcomes, f"{TASK}{task}\n\n{stamped}\n".encode()), (copy, raw)):
if unwritten := replace_file(dest, data): if unwritten := replace_file(dest, data):
return unarchived(dest, unwritten.reason) return unarchived(dest, unwritten.reason)
print(f"transcript: {copy}", file=sys.stderr) note(f"transcript: {copy}")
return None return None