Answer the stability and product-owner reviews' first round

This commit is contained in:
2026-10-02 16:04:47 +02:00
parent 990963d586
commit b9f65aac20
8 changed files with 35 additions and 18 deletions
+13 -3
View File
@@ -30,15 +30,14 @@ def archive(project_key: str, path: str, note: str, paths: Paths) -> Failure | N
return None
# Claude Code only appends to a session folder's files, so overwriting a copy loses nothing.
def mirror(source: pathlib.Path, dest: pathlib.Path) -> Failure | None:
for file in sorted(source.rglob("*")):
copy = dest / file.relative_to(source)
try:
if not file.is_file():
continue
data = file.read_bytes()
if copy.is_file() and copy.read_bytes() == data:
copy = copy_for(dest / file.relative_to(source), data)
if copy is None:
continue
make_private(copy.parent)
except OSError as failure:
@@ -46,3 +45,14 @@ def mirror(source: pathlib.Path, dest: pathlib.Path) -> Failure | None:
if unwritten := replace_file(copy, data):
return Failure(f"could not archive the transcript: {copy}: {unwritten.reason}")
return None
# Every chunk of a project reuses its session id, so a name can recur with other content: only a file that grew from its copy replaces it.
def copy_for(copy: pathlib.Path, data: bytes) -> pathlib.Path | None:
if not copy.is_file():
return copy
kept = copy.read_bytes()
if data.startswith(kept):
return copy if data != kept else None
beside = copy.with_name(f"{copy.name}.{hashlib.sha256(data).hexdigest()}")
return None if beside.exists() else beside
+2 -2
View File
@@ -7,7 +7,7 @@ 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, Answered, Archived, Ended, Event, Finishing, Interrupting, Judging, Ruled, State, WorkerRan, Working, transition
from loop_claude.cycle.states import Active, Answered, Archived, Closing, Ended, Event, Interrupting, Judging, Ruled, State, WorkerRan, Working, transition
from loop_claude.cycle.verdicts import Finished, Unfinished
from loop_claude.cycle.worker import run_worker, worker_args
from loop_claude.effects import Effects
@@ -57,7 +57,7 @@ def step(cycle: Cycle, state: Active) -> Event | Stop:
return rule(cycle, transcript_path)
case Interrupting(transcript_path, question):
return ask(cycle, transcript_path, question)
case Finishing(transcript_path, verdict):
case Closing(transcript_path, verdict):
return close(cycle, transcript_path, verdict)
case _:
typing.assert_never(state)
+4 -4
View File
@@ -20,7 +20,7 @@ class Interrupting:
@dataclasses.dataclass(frozen=True)
class Finishing:
class Closing:
transcript_path: str
verdict: Finished | Unfinished
@@ -30,7 +30,7 @@ class Ended:
"""The cycle is over."""
Active = Working | Judging | Interrupting | Finishing
Active = Working | Judging | Interrupting | Closing
State = Active | Ended
@@ -64,10 +64,10 @@ def transition(state: State, event: Event) -> State:
case Judging(transcript_path), Ruled(Interrupt(question=question)):
return Interrupting(transcript_path, question)
case Judging(transcript_path), Ruled(Finished() | Unfinished() as verdict):
return Finishing(transcript_path, verdict)
return Closing(transcript_path, verdict)
# The human works in the interrupt's claude session, so the judge rules again on the transcript it leaves.
case Interrupting(transcript_path), Answered():
return Judging(transcript_path)
case Finishing(), Archived():
case Closing(), Archived():
return Ended()
raise ValueError(f"no transition from {state} on {event}")
+2 -1
View File
@@ -15,7 +15,8 @@ relative to ~/code, or to / outside it. The session is deleted when its chunk fi
interrupt, and as every cycle ends, Ctrl-C and a failure included, the session's transcript is
copied to $LOOP_CLAUDE_TRANSCRIPTS/<key>/<sha256>.jsonl (default ~/.claude/loop-claude-transcripts),
the verdict or the stop beside it in <sha256>.verdict.md, and the files of its session folder, the
subagents' transcripts among them, to <key>/<session id>/.
subagents' transcripts among them, to <key>/<session id>/; a file that does not extend its earlier
copy, such as one an earlier chunk left, lands beside it as <name>.<sha256>.
Every claude loop-claude starts runs the project's model, saved per <key> in
~/.claude/loop-claude-models.json and read each cycle; a project without an entry, as on its first