Answer principles round 1: 0 🔴, 3 🟡 (0 misread); return withdraw's failure as a warning, check every field read_ask reads, test loop-inbox's /talk end, move TALK to waiting.py

This commit is contained in:
2026-10-29 00:09:05 +01:00
parent ba8a0df807
commit 4d6926e790
6 changed files with 124 additions and 24 deletions
+9 -4
View File
@@ -3,7 +3,7 @@ import sys
import typing
import uuid
from loop_claude.waiting import answered, Ask, Asking, claude_ended, ClaudeCommand, ClaudeOpening, OpenInInbox, OpenOnTerminal, POLL_SECONDS, publish, Typed, withdraw
from loop_claude.waiting import answered, Ask, Asking, claude_ended, ClaudeCommand, ClaudeOpening, OpenInInbox, OpenOnTerminal, POLL_SECONDS, publish, TALK, Typed, withdraw
from loop_claude.effects import Effects, say
from failure import Failure
from claude_code.transcript import human_turns, read_transcript
@@ -16,7 +16,6 @@ from loop_claude.project.checkout import worktrees
ANSWER_QUESTION = "answer the question above"
# TALK and ASK_ANSWER were picked on 2026-10-17 by a bench of three readers seated as the README's audience, as ~/.claude/CLAUDE.md → "Working loop" → "Bench a syntax with the people who write it." has it.
TALK = "/talk"
ASK_ANSWER = f"Answer ({TALK} opens claude, Enter stops the loop): "
@@ -52,7 +51,7 @@ def put_question(question: str, answer_here: bool, session: WorkerSession, paths
finally:
# A Talk keeps ask listed, under its id, for talk to show loop-inbox where claude opens.
if not isinstance(answer, Talk):
withdraw(paths.waiting, ask.session)
withdrawn(paths, ask, effects)
def first_answer(ask: Ask, paths: Paths, effects: Effects) -> str | Talk | Stop:
@@ -82,12 +81,18 @@ def shown(paths: Paths, ask: Ask, effects: Effects) -> None:
say(f"loop-inbox cannot show this question: {unshown.reason}", effects)
def withdrawn(paths: Paths, ask: Ask, effects: Effects) -> None:
"""Takes ask out of loop-inbox. A failure only warns: loop-inbox drops the ask once the loop's process ends."""
if unwithdrawn := withdraw(paths.waiting, ask.session):
say(f"loop-inbox may still list this question: {unwithdrawn.reason}", effects)
def talk(chosen: Talk, session: WorkerSession, paths: Paths, effects: Effects) -> Stop | None:
"""Holds the loop while the human answers in the worker's claude session, listed in loop-inbox as open where it is; the human must type something there."""
try:
return human_typed(session.transcript_path, lambda: opened(chosen, session, paths, effects))
finally:
withdraw(paths.waiting, chosen.ask.session)
withdrawn(paths, chosen.ask, effects)
def opened(chosen: Talk, session: WorkerSession, paths: Paths, effects: Effects) -> Stop | None: