Decode the worker's stream leniently, name UserEntryKind's members only, and restore the section-headers decision's citation
This commit is contained in:
@@ -67,7 +67,7 @@ def run_cycle(root, task, premises, chosen, paths, env):
|
||||
return stop
|
||||
if verdict["finished"]:
|
||||
archive(root, path, f"Task: {task}\n\nVerdict: finished", paths)
|
||||
delete_session(path)
|
||||
delete_session(session)
|
||||
return Continue()
|
||||
|
||||
|
||||
@@ -254,14 +254,15 @@ def interrupt(root, session_id, chosen, path, question, paths, env):
|
||||
if not (sys.stdin.isatty() and sys.stdout.isatty()):
|
||||
return Stop(2, "stdin or stdout is not a terminal")
|
||||
trust(paths.claude_json, checkouts(root))
|
||||
before = read(path)
|
||||
if isinstance(before, Failure):
|
||||
return Stop(1, before.reason)
|
||||
entries = read(path)
|
||||
if isinstance(entries, Failure):
|
||||
return Stop(1, entries.reason)
|
||||
before = human_turns(entries)
|
||||
subprocess.run(["claude", "--model", model_for(env, "LOOP_CLAUDE_WORKER_MODEL", chosen), "--permission-mode", "bypassPermissions", "--resume", str(session_id)], cwd=root)
|
||||
after = read(path)
|
||||
if isinstance(after, Failure):
|
||||
return Stop(1, f"could not tell whether you typed anything: {after.reason}")
|
||||
if human_turns(after) <= human_turns(before):
|
||||
entries = read(path)
|
||||
if isinstance(entries, Failure):
|
||||
return Stop(1, f"could not tell whether you typed anything: {entries.reason}")
|
||||
if human_turns(entries) <= before:
|
||||
return Stop(2, "the interrupt ended without the human typing anything")
|
||||
return None
|
||||
|
||||
|
||||
@@ -31,7 +31,10 @@ def transcript_file(session):
|
||||
return hit[0] if hit else ""
|
||||
|
||||
|
||||
def delete_session(path):
|
||||
def delete_session(session):
|
||||
path = transcript_file(session)
|
||||
if not path:
|
||||
return
|
||||
for sibling in glob.glob(glob.escape(path.removesuffix(".jsonl")) + "*"):
|
||||
try:
|
||||
shutil.rmtree(sibling) if os.path.isdir(sibling) else os.remove(sibling)
|
||||
|
||||
@@ -5,15 +5,15 @@ from loop_claude.outcome import Failure
|
||||
|
||||
|
||||
class UserEntryKind(enum.Enum):
|
||||
"""Who wrote a "user" entry: the human wrote HUMAN, Claude Code every other kind; the value is the tell."""
|
||||
"""Who wrote a "user" entry: the human wrote HUMAN, Claude Code every other kind."""
|
||||
|
||||
COMMAND = "string content starting with <"
|
||||
CTRL_C = "a text part starting with [Request interrupted"
|
||||
EMPTY = "no content"
|
||||
HUMAN = "typed by the human"
|
||||
META = "isMeta"
|
||||
NON_TEXT = "a part that is not text, such as a tool result"
|
||||
SDK_PROMPT = "promptSource sdk: the claude -p prompt"
|
||||
COMMAND = enum.auto()
|
||||
CTRL_C = enum.auto()
|
||||
EMPTY = enum.auto()
|
||||
HUMAN = enum.auto()
|
||||
META = enum.auto()
|
||||
NON_TEXT = enum.auto()
|
||||
SDK_PROMPT = enum.auto()
|
||||
|
||||
|
||||
def read(path):
|
||||
|
||||
@@ -6,7 +6,7 @@ from loop_claude.transcript import parse, parts, said
|
||||
|
||||
def run_worker(root, args):
|
||||
try:
|
||||
proc = subprocess.Popen(["claude", *args], cwd=root, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, text=True)
|
||||
proc = subprocess.Popen(["claude", *args], cwd=root, encoding="utf-8", errors="replace", stdin=subprocess.DEVNULL, stdout=subprocess.PIPE)
|
||||
except OSError as failure:
|
||||
return Failure(f"could not start claude: {failure.strerror}")
|
||||
with proc:
|
||||
|
||||
@@ -262,7 +262,7 @@ class DeleteTranscriptFiles(unittest.TestCase):
|
||||
pathlib.Path(root, f"{SESSION_ID}.orphaned-1-ab.jsonl").write_text("{}\n")
|
||||
located = session.Session(uuid.UUID(SESSION_ID), "A name", projects)
|
||||
self.assertEqual(session.transcript_file(located), transcript)
|
||||
session.delete_session(transcript)
|
||||
session.delete_session(located)
|
||||
self.assertEqual(os.listdir(root), [])
|
||||
self.assertEqual(session.transcript_file(located), "")
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@
|
||||
|
||||
## loop-claude: the section headers stay
|
||||
|
||||
2026-09-26, larv-review, declining a prose-pass deletion under `CLAUDE.md` → "Comments and documentation". Serves goal 4. Two seats of the 2026-09-26 panel credit Navigation 8 to `# ~/.claude.json` and its siblings, now in `bin/loop_claude/cycle.py`, indexing it by the file or format each group touches. Valid until the modules the rebuild splits out of `cycle.py` take over that index.
|
||||
2026-09-26, larv-review, declining a prose-pass deletion under `CLAUDE.md` → "Comments and documentation". Serves goal 4. Two seats of the 2026-09-26 panel credit Navigation 8 to `# The transcript file` and its siblings, indexing what is now `bin/loop_claude/cycle.py` by the file or format each group touches. Valid until the modules the rebuild splits out of `cycle.py` take over that index; a header stays in it until its group moves.
|
||||
|
||||
## vocabulary: the concept words are defined under `CLAUDE.md` → "Vocabulary" and cited by a bare link
|
||||
|
||||
|
||||
Reference in New Issue
Block a user