diff --git a/bin/loop_claude/cycle/run.py b/bin/loop_claude/cycle/run.py index c8d26336..2f544116 100644 --- a/bin/loop_claude/cycle/run.py +++ b/bin/loop_claude/cycle/run.py @@ -2,7 +2,7 @@ import dataclasses import typing from loop_claude.cycle.states import Active, Archived, Closing, Ended, Event, HumanAnswered, Interrupting, Judging, QUOTED_ANSWERS_PER_CYCLE, Ruled, State, transition, WorkerRan, Working -from loop_claude.cycle.archive import archive, FINISHED, UNFINISHED +from loop_claude.transcript_archive import archive, FINISHED, UNFINISHED from loop_claude.claude_code.session import delete_session, Session, session_open, transcript_file from loop_claude.effects import Effects from failure import Failure diff --git a/bin/loop_claude/cycle/archive.py b/bin/loop_claude/transcript_archive.py similarity index 97% rename from bin/loop_claude/cycle/archive.py rename to bin/loop_claude/transcript_archive.py index 4fa9ab04..bc04daaa 100644 --- a/bin/loop_claude/cycle/archive.py +++ b/bin/loop_claude/transcript_archive.py @@ -14,7 +14,7 @@ from loop_claude.claude_code.session import session_files FINISHED = "Verdict: finished" UNFINISHED = "Verdict: unfinished" -FINISHED_AT = re.compile(rf"^(\S+) {re.escape(FINISHED)}$", re.MULTILINE) +FINISHED_AT = re.compile(rf"^(\d{{4}}-\d\d-\d\dT\d\d:\d\d:\d\dZ) {re.escape(FINISHED)}$", re.MULTILINE) @dataclasses.dataclass(frozen=True) diff --git a/bin/reading_cost.py b/bin/reading_cost.py index 52790664..5bedf9d8 100644 --- a/bin/reading_cost.py +++ b/bin/reading_cost.py @@ -32,7 +32,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) from loop_claude.claude_code.entries import assistant_parts, parse_entry, tool_call from failure import Failure -from loop_claude.cycle.archive import finished_chunks, FinishedChunk +from loop_claude.transcript_archive import finished_chunks, FinishedChunk from loop_claude.paths import paths_from from loop_claude.project.checkout import project_key from shell_reads import Reads, resolved, shell_reads @@ -147,18 +147,11 @@ def measure(threads: list[bytes], checkout: Checkout, home: str) -> Reading | No commit = commit_time(worker) if commit is None: return None - tokens = 0 - reads = Reads([], []) - for thread in (worker, *subagents): - read_before = [entry for entry in thread if entry.get("type") == "assistant" and str(entry.get("timestamp", "")) < commit] - tokens += tokens_in(read_before) - for entry in read_before: - for part in assistant_parts(entry): - found = reads_of(part, str(entry.get("cwd") or "/"), home) - reads.read.extend(found.read) - reads.added.extend(found.added) - roots = [checkout.root, *reads.added] - return Reading(tokens, collections.Counter(place for path in reads.read if (place := relative(path, roots)) in checkout.tracked)) + before = [[entry for entry in thread if entry.get("type") == "assistant" and str(entry.get("timestamp", "")) < commit] for thread in (worker, *subagents)] + reads = [reads_of(part, str(entry.get("cwd") or "/"), home) for thread in before for entry in thread for part in assistant_parts(entry)] + roots = [checkout.root, *(added for found in reads for added in found.added)] + places = collections.Counter(place for found in reads for path in found.read if (place := relative(path, roots)) in checkout.tracked) + return Reading(sum(map(tokens_in, before)), places) def entries_of(raw: bytes) -> list[dict]: diff --git a/bin/shell_reads.py b/bin/shell_reads.py index f14ba4f6..89d0c833 100644 --- a/bin/shell_reads.py +++ b/bin/shell_reads.py @@ -20,15 +20,16 @@ class Reads: def shell_reads(command: str, cwd: str, home: str) -> Reads: - reads = Reads([], []) + read: list[str] = [] + added: list[str] = [] base = cwd for tokens in shell_lines(command): for words in segments(tokens): if words[0] == "cd" and len(words) == 2: base = resolved(base, words[1], home) - reads.read.extend(resolved(base, word, home) for word in operands(words)) - reads.added.extend(resolved(base, path, home) for path in worktree_added(words)) - return reads + read += [resolved(base, word, home) for word in operands(words)] + added += [resolved(base, path, home) for path in worktree_added(words)] + return Reads(read, added) def shell_lines(command: str) -> typing.Iterator[list[str]]: diff --git a/bin/test_loop_claude.py b/bin/test_loop_claude.py index 300be867..c30c727f 100644 --- a/bin/test_loop_claude.py +++ b/bin/test_loop_claude.py @@ -16,12 +16,13 @@ import uuid sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) -from loop_claude.cycle import archive, interrupt, judge, retry, run, states, worker +from loop_claude import transcript_archive as archive from loop_claude.project import checkout, model_choice, records from loop_claude.effects import Effects from loop_claude.claude_code import entries, session, transcript, trust from failure import Failure from loop_claude.cycle.judge_reply import Finished, Interrupt, QuotedAnswer, Unfinished, verdict_from +from loop_claude.cycle import interrupt, judge, retry, run, states, worker from loop_claude.cycle.retry import Limited from loop_claude.loop import main, reload from loop_claude import paths diff --git a/bin/test_reading_cost.py b/bin/test_reading_cost.py index f61474dd..8a61ed20 100644 --- a/bin/test_reading_cost.py +++ b/bin/test_reading_cost.py @@ -12,7 +12,7 @@ import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) -from loop_claude.cycle.archive import archive, FINISHED, finished_chunks, FinishedChunk, UNFINISHED +from loop_claude.transcript_archive import archive, FINISHED, finished_chunks, FinishedChunk, UNFINISHED from reading_cost import Checkout, Reading from failure import Failure from test_loop_claude_black_box import host_env diff --git a/docs/comprehension-history.md b/docs/comprehension-history.md index d975b6e2..36b343a5 100644 --- a/docs/comprehension-history.md +++ b/docs/comprehension-history.md @@ -109,3 +109,54 @@ Inherited architect, would restructure first: - `bin/loop_claude/project/checkout.py:32` `read_utf8` - `agents/stability-reviewer.md:3`, `agents/systems-architect.md:3`: house style - `workflow-bench/bench.py:26`: not runnable from the repo + +## 2026-10-08T14:28:39Z, PR #225 at 13d8b16 + +| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall | +|---|---|---|---|---|---| +| Junior A | 7 | 6 | 7 | 6 | 6.5 | +| Mid A | 7 | 6.5 | 7 | 6 | 6.5 | +| Maintainability senior | 7.5 | 7 | 7.5 | 7 | 7 | +| Inherited architect | 7 | 6.5 | 6.5 | 7 | 7 | +| Mean | 7.13 | 6.50 | 7.00 | 6.50 | 6.75 | + +Junior A, hardest first: + +- `skills/larv-review/SKILL.md:79` "Architecture": Floor, Ratchet, Fresh, Suspended, and the history paragraph at `:95` +- `skills/larv-review/SKILL.md:53` "Round cap", with `:64` "Re-entry" +- `bin/loop_claude/cycle/judge.py:31` `run_judge`, with `grounded`, `verbatim` and `plain` +- `bin/loop_claude/cycle/states.py:69` `transition`, with `cycle/run.py:55` `step` and `:104` `question_for` +- `bin/loop_claude/claude_code/entries.py:28` `written_by_human` +- `bin/loop_claude/cycle/archive.py:28` `archive`, with `copy_for` and `finished_chunks` +- `bin/reading_cost.py:145` `measure`, with `bin/shell_reads.py:52` `segments` and `:67` `operands` +- `bin/rank_todo.py:408` `rank_details` + +Mid A, hardest first: + +- `skills/larv-review/SKILL.md:53` "Round cap", with "History", "Ratchet", "Fresh" and "Suspended" +- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`, with `QUOTE_SOURCES`, `ANSWER_DESTINATIONS` and `ANSWERS_RECORDED` +- `bin/loop_claude/cycle/states.py:69` `transition` +- `bin/loop_claude/cycle/archive.py:28` `archive`, with `finished_chunks` and `FINISHED_AT` +- `bin/reading_cost.py:145` `measure`, with `located`, `relative` and `commit_time` +- `bin/shell_reads.py:67` `operands` +- `bin/loop_claude/claude_code/entries.py:28` `written_by_human` +- `bin/rank_todo.py:408` `rank_details` + +Maintainability senior, hardest first: + +- `skills/larv-review/SKILL.md:79` "Architecture" +- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`, with `cycle/worker.py:41` `worker_args` +- `bin/loop_claude/cycle/judge.py:31` `run_judge` +- `bin/loop_claude/claude_code/entries.py:28` `written_by_human` +- `bin/loop_claude/cycle/archive.py:17` `FINISHED_AT`, with `finished_chunks` and `cycle/run.py:110` `close` +- `bin/reading_cost.py:145` `measure`, with `located` +- `bin/shell_reads.py:67` `operands` +- `bin/rank_todo.py:408` `rank_details`, with `read_scoring` + +Inherited architect, would restructure first: + +- `skills/larv-review/SKILL.md:53` "Round cap", and `:88` "Architecture" from History to Suspended +- `bin/loop_claude/cycle/archive.py:109` `finished_chunks`, with `bin/reading_cost.py:106` `located` and `bin/loop_claude/project/checkout.py:7` `checkout_root` +- `bin/` flat folder: tools, shared modules and tests +- `bin/loop_claude/project/checkout.py:32` `read_utf8`, `claude_code/transcript.py:27` `render`, `judge_reply.py:87` `Verdict` beside `states.py:24` `ruling` +- `bin/loop_claude/loop/main.py:9` the recorded-answers rule, beside `judge_reply.py:11` `ANSWERS_RECORDED` diff --git a/todo.md b/todo.md index 3e9674a5..03996a80 100644 --- a/todo.md +++ b/todo.md @@ -89,7 +89,7 @@ The README line covers the bench's transcripts in `workflow-bench/logs/` too (go ### 62. Lift Locality, Self-sufficiency and the overall to the comprehension floor, at the places the seats name. -Raised by the principles audit of PR #215 against KISS, in `principles/technical-principles.md`, and goal 1.1: the `comprehension floor:` entry in `docs/decisions.md` lists seven decisions to ship under the floor, and 0.1.0 waits on the floor. PR #215's last run put Locality at 6.63 and Self-sufficiency and the overall at 6.88. Its seats named, under Locality: the judge's contract spread over `cycle/judge_reply.py`, `cycle/worker.py` and `cycle/run.py`; `remaining`, which is `Unfinished.evidence` under another name, threaded through `loop/main.py`, `loop/reload.py`'s `LoopRun`, `cycle/run.py` and `worker_args`; the `quoted_answers` cap held by case order in `cycle/states.py`'s `transition` and restated in `run.py`'s `question_for`; the four outcome texts `run.py` builds inline for `archive`. Under Self-sufficiency: `skills/larv-review/SKILL.md`, which needs `CLAUDE.md` → "Vocabulary" open beside it; the archive layout, defined only in `bin/loop_claude/loop/main.py`'s docstring and not at `cycle/archive.py`; `JUDGE_RULES`' precedence in `cycle/judge_reply.py`, restated by `verdict_from`'s branch order and the `Reply` field descriptions; the `sys.path` insert in `bin/loop-claude` that the `from failure import` lines rely on, unstated at the import sites. +Raised by the principles audit of PR #215 against KISS, in `principles/technical-principles.md`, and goal 1.1: the `comprehension floor:` entry in `docs/decisions.md` lists seven decisions to ship under the floor, and 0.1.0 waits on the floor. PR #215's last run put Locality at 6.63 and Self-sufficiency and the overall at 6.88. Its seats named, under Locality: the judge's contract spread over `cycle/judge_reply.py`, `cycle/worker.py` and `cycle/run.py`; `remaining`, which is `Unfinished.evidence` under another name, threaded through `loop/main.py`, `loop/reload.py`'s `LoopRun`, `cycle/run.py` and `worker_args`; the `quoted_answers` cap held by case order in `cycle/states.py`'s `transition` and restated in `run.py`'s `question_for`; the four outcome texts `run.py` builds inline for `archive`. Under Self-sufficiency: `skills/larv-review/SKILL.md`, which needs `CLAUDE.md` → "Vocabulary" open beside it; the archive layout, defined only in `bin/loop_claude/loop/main.py`'s docstring and not at `transcript_archive.py`; `JUDGE_RULES`' precedence in `cycle/judge_reply.py`, restated by `verdict_from`'s branch order and the `Reply` field descriptions; the `sys.path` insert in `bin/loop-claude` that the `from failure import` lines rely on, unstated at the import sites. ### 21. Give `settings.json`'s model one writer, and sort its keys. @@ -121,6 +121,8 @@ Raised by the architect on PR #225 and by the inherited architect of PR #224's s The key names the project's session, archive folder and models entry. `project_key` drops the leading `/`, so `~/code/a` and `/a` share all three, and one loop can resume or delete the other's session. +`bin/reading_cost.py` keys the archive by the main checkout, the parent of git's common dir, since it runs in a chunk's worktree; `loop-claude` keys it by `--show-toplevel`, so a loop started inside a worktree archives where `reading_cost.py` never looks. Derive both keys one way. + ### 67. Point stability-reviewer at the technical principles in place of its own restatement of them. DRY, in `principles/technical-principles.md`: `agents/stability-reviewer.md` restates principles in its own words, and the copy has drifted: it asks for "properly randomised UUIDs" where the principle requires UUID v7.