Compare commits
117 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| affe56b074 | |||
| dd30a1199a | |||
| a984e98e0a | |||
| dd56ad8fdd | |||
| 28d027ffef | |||
| c1133edf39 | |||
| efed78bf5e | |||
| 642a8bc80b | |||
| 8da25d8c55 | |||
| acbe3ec8b5 | |||
| 1c5551a145 | |||
| 56ac929634 | |||
| e2cb4a26f8 | |||
| fb764a7549 | |||
| 9c2f982741 | |||
| 05efbb1d8a | |||
| 53ed5150be | |||
| 77fef49fce | |||
| c7f6099945 | |||
| 45276fc3bf | |||
| 243cd676f8 | |||
| 0050cd6772 | |||
| a9ec529158 | |||
| 083cc782d0 | |||
| 08c5625ac7 | |||
| 37db225514 | |||
| 5cc37dd861 | |||
| a69cfd2624 | |||
| 84aa3e6b20 | |||
| 737d58ad9f | |||
| e67c882a08 | |||
| e58c98a30f | |||
| 527aef3495 | |||
| 1fca6137c2 | |||
| 6240f82857 | |||
| 7d440c6ee1 | |||
| 8a2dbd70f1 | |||
| 382472bd39 | |||
| c7c5ec083f | |||
| d95c8548aa | |||
| 50249b1a59 | |||
| 7d3906181b | |||
| 3efbca09f0 | |||
| ccf9c00e9c | |||
| 3bac4c4df4 | |||
| 8055a33b48 | |||
| 4c8dbe8da2 | |||
| d3071455d8 | |||
| dbe7bd3abd | |||
| 51949a06dd | |||
| 96aebc74a0 | |||
| c1978a4738 | |||
| fbe753e1b5 | |||
| 26826685e2 | |||
| 9ae7b07620 | |||
| c28fac088d | |||
| 88f1671388 | |||
| eb4dc7ab72 | |||
| 12ed8053df | |||
| 1881190be9 | |||
| a3ecbacaab | |||
| fc3170e0ec | |||
| 6b8f55136b | |||
| 12d6d75462 | |||
| c7333c05ee | |||
| 8c9bf090f1 | |||
| 946daf5e3f | |||
| 60353275f6 | |||
| 1fc91a5535 | |||
| f35e525b9c | |||
| 35907caefa | |||
| 5e5eea21e5 | |||
| da1ef19795 | |||
| f33704872f | |||
| 5062a97158 | |||
| 24efce674c | |||
| aa062da0bd | |||
| 471350d388 | |||
| 13d8b167a7 | |||
| 1b8142e7e5 | |||
| cefb297e14 | |||
| f199118e74 | |||
| 9ea4f0abf6 | |||
| 7b86497a93 | |||
| a483e8d637 | |||
| aff4ba6651 | |||
| 4f0f801ba0 | |||
| 897c6e9552 | |||
| c2c5d4b885 | |||
| 7426f84aff | |||
| 894f99e55b | |||
| a58a0a8262 | |||
| c14707da54 | |||
| 3f5e0bb1ae | |||
| 6750d24c6d | |||
| d983d0ef11 | |||
| 961d8e6bfb | |||
| 6bb432f52a | |||
| 88d146aeda | |||
| 17b46d80e8 | |||
| 8154026efc | |||
| 9bf32c6b44 | |||
| 2f2fb60626 | |||
| 8260a54969 | |||
| 1d39416481 | |||
| 8e2cfa59a9 | |||
| 94dd717b51 | |||
| 95fd2588c0 | |||
| fe916873f6 | |||
| 5ce2feec1a | |||
| 04a92346a3 | |||
| d489ad75a1 | |||
| 44acfee149 | |||
| 4a4dadeec7 | |||
| ee9da2fb07 | |||
| fb8ba8a187 | |||
| e360c0ca87 |
@@ -19,12 +19,21 @@
|
||||
!bin/
|
||||
!bin/failure.py
|
||||
!bin/file_writes.py
|
||||
!bin/larv-review
|
||||
!bin/larv_review/
|
||||
!bin/larv_review/*.py
|
||||
!bin/loop-claude
|
||||
!bin/loop_claude/
|
||||
!bin/loop_claude/**/
|
||||
!bin/loop_claude/**/*.py
|
||||
!bin/markdown_sections.py
|
||||
!bin/metric-bench
|
||||
!bin/metric_bench/
|
||||
!bin/metric_bench/*.py
|
||||
!bin/rank_todo.py
|
||||
!bin/reading-cost
|
||||
!bin/reading_cost/
|
||||
!bin/reading_cost/*.py
|
||||
!bin/statusline.py
|
||||
!bin/test_*.py
|
||||
!docs/
|
||||
|
||||
@@ -11,19 +11,22 @@ Decisions live in `docs/decisions.md`:
|
||||
- comprehension floor: every dimension and the overall at 7.0 or above, and 0.1.0 waits on it
|
||||
- loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes
|
||||
- review: a pass gets at most three rounds per chunk; instead of a fourth, the run asks the human
|
||||
- review: a fix for a 🟢 or ❓ re-enters review like any fix
|
||||
- review: a project decision may suspend the scoring run for the plan items it names
|
||||
- review: a fix for a 🔴 or 🟡 reruns the pass that found it and each pass whose trigger names fixes like it; a fix for a 🟢, a ❓ or a prose finding reruns none
|
||||
- review: a paired ruling against the last measured commit decides the ratchet; the four-seat scoring run checks the floor when a release's items run out or an item names the floor
|
||||
- review: a project decision may suspend the comprehension check for the plan items it names
|
||||
- review: a pass skips only on a precedent: a decision, or a plan item crediting the pass, that the repo held before the chunk began
|
||||
- loop-claude: the archive keeps the raw transcript, and a failed archive stops the loop
|
||||
- loop-claude: a `claude` that cannot start is a failed worker run, retried
|
||||
- review: an ask no user answers leaves the PR unmerged
|
||||
- loop-claude: every claude it starts bypasses permissions inside its sandbox
|
||||
- review: `/security-review` is the security pass of record
|
||||
- review: `/security-review` is the security pass of record, except where the full scan runs on the same change and replaces it
|
||||
- review: the premises chunk's whole review is the human's approval
|
||||
- workflow-bench/: the remote may show the bench cases' names and commit SHAs
|
||||
- settings.json: Claude Code runs in auto mode with the dangerous-mode prompt skipped
|
||||
- the repo may name bender, bender-infra and ai-sandbox
|
||||
- todo.md: one table of items scored by the formula and goal weights it states, held to its bar, ranked by `bin/rank_todo.py`
|
||||
- reading cost: larv-review measures each finished chunk from loop-claude's archive and appends the figure to `docs/reading-cost.md` in the next chunk's PR
|
||||
- reading cost: a rise is the last 5 chunks' median above the 5 before them, and files or refreshes one plan item
|
||||
|
||||
## Working rules
|
||||
|
||||
@@ -31,7 +34,7 @@ Decisions live in `docs/decisions.md`:
|
||||
|
||||
## Scoring run
|
||||
|
||||
The project values for `skills/comprehension-panel/scoring-run.md`:
|
||||
The project values for `skills/comprehension-panel/seat-prompts.md`:
|
||||
|
||||
- `{language}`: Python
|
||||
- `{kind}`: a Claude Code configuration with an agent loop and review skills
|
||||
|
||||
+12
-3
@@ -2,14 +2,23 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- larv-review skips the comprehension scoring run for a chunk whose plan items a project decision names. The decision also names the later item whose scoring run ends the suspension. Neither the comprehension floor nor the ratchet can block a skipped chunk, its summary cites the decision, and a chunk shipping its release's last item is always measured.
|
||||
- The stability reviewer keeps its scratch work in a directory it creates for the run, deletes that directory afterwards, and deletes nothing else.
|
||||
- larv-review's mechanical rules run in the new, tested `bin/larv-review`: the paired ruling's base (`ruling-base`), each pass's round count (`round-count`), the scoring run's trigger (`needs-scoring-run <item ID>...`), and the vote count, means and history format (`record-ruling` and `record-scoring`, which read a seats file and append to `docs/comprehension-history.md`). The skill says when to run each and what its answer means. A seats file line the tool cannot read fails the run, so a mistyped vote never counts as same. The base search compares the history before and after each merged change, so it no longer depends on how a line is worded, and orders a change's rulings by their headings' times. A release whose last plan item moves to another release is due a scoring run too, once work has landed towards it. A seats file must name commits the checkout holds. Scores a `comprehension floor:` decision entry still holds move into the history through `record-scoring`, as a `Mean:` line. When origin cannot be fetched, the tool reads it as last fetched and says so.
|
||||
- The new `bin/metric-bench` benches cheap static metrics of a project's Python against the places its comprehension history names as hardest: cognitive complexity, length, shared state and change spread, each scored by how well it ranks the named functions above the rest. No metric enters review yet.
|
||||
- larv-review blocks a merge when simulated readers rule that the PR makes the project read worse than the last measured commit: the default branch's newest merged change that added a scoring run to `docs/comprehension-history.md`, or whose last ruling there is better. A ruling of same leaves that commit in place, so a worse ruling may name places earlier chunks wrote. In each architecture pass Mid A and the inherited architect vote better, same or worse; when they disagree, the maintainability senior and Junior A vote too. A ruling needs a lead of two or more votes, else it is same, and a vote that names no place counts as same. A worse ruling never ships: after three rounds larv-review asks you for another round, a no leaves the PR unmerged, and so does an unattended run. The four-seat scoring run checks the comprehension floor only when a chunk ships or removes a release's last plan item, or ships an item naming the floor; between those runs the floor blocks nothing. A score under the floor blocks the merge until fixed or until you decide to ship; a decision in `docs/decisions.md` that lets every chunk ship under the floor counts as yours.
|
||||
- larv-review reruns fewer passes after a fix. A fix reruns the pass whose 🔴 or 🟡 it answers, plus stability when the fix changes behaviour, security when it opens an untrusted-input boundary or touches authn/authz, secrets or crypto, and architecture when it carries an architectural decision. A rerun reviews only what changed since that pass last reviewed. A fix for a 🟢, a ❓ or any prose finding reruns no pass, and prose takes one round.
|
||||
- larv-review runs one security pass on each change: the full scan alone when it runs, else `/security-review`.
|
||||
- larv-review runs the new `bin/reading-cost`, which measures each chunk `loop-claude` finished from its archive: the new input tokens the worker and its subagents took in before the worker's first commit, and the files git tracks that they read most. It appends each figure the project's `docs/reading-cost.md` lacks. Once 10 chunks are measured, and the last 5 chunks' median is above the 5 before them, larv-review files one plan item naming the files read most, or refreshes it. The chunk that ships it runs `reading-cost --reset`, so the trend counts only chunks that finished after it.
|
||||
- larv-review appends every paired ruling and scoring run to the project's `docs/comprehension-history.md`: the commit the seats read, a ruling's base, each seat's vote or scores, and the places each seat named. The PR summary gives each ruling with its base and votes. The `comprehension floor:` entry in `docs/decisions.md` keeps only the decisions to ship under the floor; a project's next scoring run moves the last scores the entry still holds into the history. The seats do not read the history.
|
||||
- The README's goals put quality with the fewest interrupts first, as goal 1; sharing the setup, backups and leaking nothing follow as goals 2–4.
|
||||
- larv-review reruns the comprehension check before merge when any commit since its last run changes more than `docs/decisions.md`, `docs/comprehension-history.md`, `docs/reading-cost.md`, `todo.md` or `CHANGELOG.md`, so the recorded result is the merged commit's. A result that blocks the merge is never filed in `todo.md`. A rerun counts toward the three-round cap only when it reports a block that no decision of yours covers.
|
||||
- larv-review skips the comprehension check for a chunk whose plan items a project decision names. The decision also names the later item whose check ends the suspension. A skipped chunk cannot be blocked for reading worse or for the floor, and its summary cites the decision. A chunk that ships or removes a release's last plan item, or ships an item naming the floor, still gets the scoring run.
|
||||
- README → Install and Update give the commands that check the latest tag out into `~/.claude`: on a new machine, whether or not Claude Code has already created the directory, and on one already on an older tag.
|
||||
- A session commits changes Claude Code made to `settings.json` only once their diff holds no credential, and asks you to move any credential out of the file first.
|
||||
- A technical principle, "Sane defaults, where a default serves better than an explicit ask". A default suits a value most callers want, does no harm when wrong, and can be seen and changed. It lives at the program's edge, such as a CLI; a library still asks for data, the clock and randomness.
|
||||
- larv-review's principles audit reads only the files under `~/.claude/principles/` that apply to the project, launching a file's auditor when unsure. A file's `Applies to` line says what it covers; one without the line covers every project. The summary names each file left out. After its first round, the architecture pass reruns the scoring run and only the reviewers whose 🔴 or 🟡 the fixes answer, unless the fixes carry an architectural decision.
|
||||
- larv-review's principles audit reads only the files under `~/.claude/principles/` that apply to the project, launching a file's auditor when unsure. A file's `Applies to` line says what it covers; one without the line covers every project. The summary names each file left out. After its first round, the architecture pass reruns only the reviewers whose 🔴 or 🟡 the fixes answer, unless the fixes carry an architectural decision.
|
||||
- When `loop-claude`'s judge rules a chunk unfinished, the resumed worker is shown the passage the judge quoted as the work remaining. A loop started before this change exits 1 at its next reload; rerun it.
|
||||
- larv-review's architecture pass and full security scan get short names, `Architecture` and `Full scan`. Each round's commit is titled with its pass's name in lower case: `Answer full scan round 1: …`.
|
||||
- larv-review's comprehension floor now says, without another file open, what the scoring run measures. A project's `docs/decisions.md` keeps the last scoring run's scores, and a later run scoring below them blocks the merge until fixed. After three rounds larv-review asks you; an unattended run leaves the PR unmerged with the question. A PR under the floor that scores no lower than the last run merges once you decide to ship. A decision in `docs/decisions.md` that lets every chunk ship under the floor counts as yours. A project without those scores gets them at its next scoring run.
|
||||
- `loop-claude`'s judge reads your `~/.claude/CLAUDE.md` beside the project's `AGENTS.md` and `docs/decisions.md`. It no longer interrupts for a choice that file settles, and it answers the worker's questions from it.
|
||||
- `loop-claude`'s judge holds a chunk open until each answer you typed in it that a later chunk could need is recorded. An answer counts as recorded once the README's goals or audience, `AGENTS.md`, `docs/decisions.md` or `~/.claude/CLAUDE.md` hold it. It also counts once the transcript shows the worker writing it into the README's goals or audience, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. The worker writing to `~/.claude/CLAUDE.md` does not count, since new rules there are yours. The resumed worker is told this rule.
|
||||
- `loop-claude` archives each answer the judge quotes, with the question it answers and its UTC time, in `<sha256>.outcomes.md`.
|
||||
|
||||
@@ -34,10 +34,10 @@ How work proceeds in any repo, unless the repo's `AGENTS.md` says otherwise. The
|
||||
|
||||
## Quality
|
||||
|
||||
Quality is proven by review. Every change is reviewed as a diff. The whole project is measured when a change carries an architectural decision, and before each release, because a project can drift from the principles one clean diff at a time. A project decision may suspend only the comprehension panel's scoring run (`larv-review` §3 → "Architecture" → "Suspended"). `larv-review` §3 says which review runs when. Quality has three parts. When two pull against each other, the earlier one wins.
|
||||
Quality is proven by review. Every change is reviewed as a diff. The whole project is measured when a change carries an architectural decision, and before each release, because a project can drift from the principles one clean diff at a time. `larv-review` §3 says which review runs when. Quality has three parts. When two pull against each other, the earlier one wins.
|
||||
|
||||
1. **Correct.** The work does what the goals and the plan say, and tests prove it.
|
||||
2. **True to the technical principles** (`~/.claude/principles/technical-principles.md`). The `comprehension-panel` skill scores KISS; a score under the comprehension floor (`larv-review` §3 → "Architecture") blocks a merge. **Comprehension never falls:** a chunk starts from the last panel recorded on the default branch, and when its own panel scores any dimension or the overall lower, even within the panel's noise, improve what the readers named and score again. An equal score passes. After three such rounds, stop and ask the human.
|
||||
2. **True to the technical principles** (`~/.claude/principles/technical-principles.md`). The `comprehension-panel` skill measures KISS in `larv-review`'s comprehension check (§3 → "Architecture"), which a project decision may suspend, unlike any other review. **Comprehension never falls:** when readers comparing the chunk with the last commit the panel scored or ruled better rule that it reads worse, improve what they named and rule again. After three such rounds, stop and ask the human. At a release's end, or for an item naming it, a score under the comprehension floor blocks a merge.
|
||||
3. **Plainly written**, per "Prose".
|
||||
|
||||
## Prose
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
# Claude Code configuration
|
||||
|
||||
My personal `~/.claude`, version controlled: `CLAUDE.md` and `AGENTS.md` for instructions, the words under `CLAUDE.md` → "Vocabulary"; `agents/` and `skills/`; `principles/` for what the reviewer agents hold projects to; `docs/` for decisions; `settings.json` for the harness and `.claude/settings.json` for the harness inside this repo; `CHANGELOG.md` and `todo.md`; the tools in `bin/`; and `workflow-bench/`, the scripts and prompts of the 2026-09-30 bench of larv-review.
|
||||
My personal `~/.claude`, version controlled: `CLAUDE.md` and `AGENTS.md` for instructions, the words under `CLAUDE.md` → "Vocabulary"; `agents/` and `skills/`; `principles/` for what the reviewer agents hold projects to; `docs/` for decisions and the comprehension history; `settings.json` for the harness and `.claude/settings.json` for the harness inside this repo; `CHANGELOG.md` and `todo.md`; the tools in `bin/`; and `workflow-bench/`, the scripts and prompts of the 2026-09-30 bench of larv-review.
|
||||
|
||||
## Goals
|
||||
|
||||
1. Make my claude setup shareable between computers.
|
||||
2. Keep my claude setup and the transcripts of unattended runs, the bench's included, backed up.
|
||||
3. Leak nothing to the remote — no credentials, no transcripts, no memory files.
|
||||
4. Get the highest quality out of Claude Code while interrupting me the least, so development scales.
|
||||
1. Get the highest quality out of Claude Code while interrupting me the least, so development scales.
|
||||
1. Proven, stellar output quality: code, documentation and plans.
|
||||
2. Decide by the project's goals when confident; ask me when not, and never the same thing twice.
|
||||
3. The same rules in every project and every session.
|
||||
4. Add cost only where it meaningfully raises quality; otherwise work to lower cost.
|
||||
5. Delivery speed.
|
||||
2. Make my claude setup shareable between computers.
|
||||
3. Keep my claude setup and the transcripts of unattended runs, the bench's included, backed up.
|
||||
4. Leak nothing to the remote — no credentials, no transcripts, no memory files.
|
||||
|
||||
## Audience
|
||||
|
||||
@@ -65,8 +65,13 @@ Rename `## Unreleased` in `CHANGELOG.md` to the version, commit, tag that commit
|
||||
|
||||
## Tools
|
||||
|
||||
Install puts only `loop-claude` on `PATH`; call the others by their path, such as `~/.claude/bin/metric-bench`, from the project's checkout.
|
||||
|
||||
- `larv-review <command>` holds larv-review's mechanical rules: the paired ruling's base and vote count, each pass's round count, the scoring run's trigger and the comprehension history's format; `larv-review --help` states them.
|
||||
- `loop-claude <task>` runs a project's next chunk cycle after cycle; `loop-claude --help` states its contract.
|
||||
- `metric-bench [history]` benches cheap static metrics of a project's Python against the places its comprehension history names as hardest; `metric-bench --help` states the metrics and the scores.
|
||||
- `rank_todo.py [--check] [todo.md]` scores and ranks a project's `todo.md`; `rank_todo.py --help` states the format.
|
||||
- `reading-cost [--reset] [record]` appends a figure for each chunk `loop-claude` finished to a project's `docs/reading-cost.md`, and says whether the figures rise; `reading-cost --help` states the measure.
|
||||
- `statusline.py` renders Claude Code's status line; `settings.json` → `statusLine` runs it.
|
||||
|
||||
Test on the host, with `uv` on `PATH` to fetch mypy and the Python version Install names (`docs/decisions.md` → `bin/`): `python3 -m unittest discover -s bin -p 'test_*.py'`
|
||||
|
||||
@@ -21,7 +21,7 @@ Also report a sentence contradicting another, a claim the code shows false, and
|
||||
|
||||
## Growth
|
||||
|
||||
Report the lines each file gained and lost. From round 2, a fix that added words without naming what a reader could not understand without them is a finding.
|
||||
Report the lines each file gained and lost. A line an earlier pass's fix added that names no reader need is a finding.
|
||||
|
||||
## Scopes
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ You are an elite stability-focused code reviewer with deep expertise in defensiv
|
||||
1. **Scope the change.** You review every PR; a fresh invocation has no prior context, so determine the diff yourself. Diff the PR branch against its base (`gh pr diff`, or `git merge-base <base> HEAD` then `git diff`), and review the changed lines **plus enough surrounding code and callers** to judge correctness — read the whole changed file when practical; a diff alone hides whether a caller breaks. Read the PR description and, when the project uses an issue tracker (project-specific — check its docs) and the change references a ticket, that ticket: the diff is judged against its stated intent, and a scope mismatch in either direction is a finding — claimed-but-unimplemented, and implemented-but-unasked (#2).
|
||||
2. **Read every file in the shared principles** at `~/.claude/principles/`. These are mandatory org guidelines; all code MUST comply with each that applies. A file's `Applies to` line says what it covers; one without the line covers every change. Re-read each time — they change. Flag violations prominently.
|
||||
3. **Read README.md, AGENTS.md and `docs/decisions.md`** in the current project for project-specific conventions, build instructions, tooling, and the accepted trade-offs a reviewer should honor rather than re-flag. Note the documented test, lint, and static-analysis commands — you will run them.
|
||||
4. **Verify, don't just read.** Run the test suite and static analysis/linters through the project's container tooling, unless a decision puts them on the host; tear down test containers afterwards. A full-suite run catches broken callers that diff-reading misses. When a suspected bug is cheap to confirm, reproduce it — a scratch script in a temp dir, a targeted test run — before reporting it. Leave the working tree exactly as you found it. Anything you could not run goes in Coverage & Verification, never silently skipped.
|
||||
4. **Verify, don't just read.** Run the test suite and static analysis/linters through the project's container tooling, unless a decision puts them on the host; tear down test containers afterwards. A full-suite run catches broken callers that diff-reading misses. When a suspected bug is cheap to confirm, reproduce it — a scratch script, a targeted test run — before reporting it. Put scratch work in a directory you create for this run, and delete it when done; delete nothing else, since a directory the prompt names may hold other agents' files. Leave the working tree exactly as you found it. Anything you could not run goes in Coverage & Verification, never silently skipped.
|
||||
5. **Two passes minimum, then hunt absences.**
|
||||
- *Breadth:* every hunk in every changed file, no skimming. Track which files you have covered; batch large diffs, never truncate the review.
|
||||
- *Depth:* trace the riskiest data paths end-to-end (input → logic → persistence/response), the interactions between changed pieces, and between the change and config (timeout hierarchies, retries × idempotency, queue worker counts, env parity).
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from larv_review import main
|
||||
|
||||
sys.exit(main.main(sys.argv[1:]))
|
||||
@@ -0,0 +1,96 @@
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from failure import Failure
|
||||
from larv_review.history import HistoryChange
|
||||
|
||||
HISTORY = "docs/comprehension-history.md"
|
||||
|
||||
|
||||
def git(*args: str) -> str | Failure:
|
||||
try:
|
||||
ran = subprocess.run(["git", *args], capture_output=True, text=True)
|
||||
except (OSError, ValueError) as failure:
|
||||
return Failure(f"git could not start: {failure}")
|
||||
return ran.stdout if ran.returncode == 0 else Failure(f"git {' '.join(args)}: {ran.stderr.strip()}")
|
||||
|
||||
|
||||
def top() -> str | Failure:
|
||||
found = git("rev-parse", "--show-toplevel")
|
||||
return found if isinstance(found, Failure) else found.strip()
|
||||
|
||||
|
||||
def default_branch(stale_ok: bool) -> tuple[str, str | None] | Failure:
|
||||
"""The default branch's ref, `origin/<branch>` after a fetch with that remote, else the local main or master, and a note for stderr. With stale_ok, a failed fetch reads origin as last fetched, and the note says so."""
|
||||
remotes = git("remote")
|
||||
if isinstance(remotes, Failure):
|
||||
return remotes
|
||||
if "origin" in remotes.split():
|
||||
fetch = git("fetch", "--quiet", "origin")
|
||||
if isinstance(fetch, Failure) and not stale_ok:
|
||||
return fetch
|
||||
note = f"reading origin as last fetched: {fetch.reason}" if isinstance(fetch, Failure) else None
|
||||
default = git("symbolic-ref", "--short", "refs/remotes/origin/HEAD")
|
||||
named = default.strip() if not isinstance(default, Failure) else origin_head()
|
||||
return named if isinstance(named, Failure) else (named, note)
|
||||
for branch in ("main", "master"):
|
||||
if not isinstance(git("rev-parse", "--quiet", "--verify", f"refs/heads/{branch}"), Failure):
|
||||
return branch, None
|
||||
return Failure("no origin remote, and no main or master branch to take as the default branch")
|
||||
|
||||
|
||||
def origin_head() -> str | Failure:
|
||||
"""The default branch origin names, for a clone made by `git init` and `git remote add`, which records none."""
|
||||
listed = git("ls-remote", "--symref", "origin", "HEAD")
|
||||
if isinstance(listed, Failure):
|
||||
return listed
|
||||
if named := re.match(r"ref: refs/heads/(\S+)\tHEAD", listed):
|
||||
return f"origin/{named.group(1)}"
|
||||
return Failure("origin names no default branch; set it with `git remote set-head origin --auto`")
|
||||
|
||||
|
||||
def commit_exists(commit: str) -> bool:
|
||||
return not isinstance(git("rev-parse", "--quiet", "--verify", f"{commit}^{{commit}}"), Failure)
|
||||
|
||||
|
||||
def file_at(revision: str, path: str) -> str | Failure:
|
||||
"""A file's text at a revision, empty where the revision is not a commit, such as a root commit's parent, or holds no such file."""
|
||||
if not commit_exists(revision):
|
||||
return ""
|
||||
listed = git("ls-tree", "--name-only", revision, "--", path)
|
||||
if isinstance(listed, Failure):
|
||||
return listed
|
||||
return git("show", f"{revision}:{path}") if listed.strip() else ""
|
||||
|
||||
|
||||
def history_changes(default: str) -> list[HistoryChange] | Failure:
|
||||
"""Each merged change on the default branch that touched the history, newest first; a merge commit counts as one change against its first parent."""
|
||||
shallow = git("rev-parse", "--is-shallow-repository")
|
||||
if isinstance(shallow, Failure):
|
||||
return shallow
|
||||
if shallow.strip() == "true":
|
||||
return Failure("a shallow clone lacks the commits the base search reads; run `git fetch --unshallow origin`")
|
||||
commits = git("log", "--first-parent", "--format=%H", default, "--", HISTORY)
|
||||
if isinstance(commits, Failure):
|
||||
return commits
|
||||
changes = []
|
||||
for commit in commits.split():
|
||||
before = file_at(f"{commit}^1", HISTORY)
|
||||
if isinstance(before, Failure):
|
||||
return before
|
||||
after = file_at(commit, HISTORY)
|
||||
if isinstance(after, Failure):
|
||||
return after
|
||||
changes.append(HistoryChange(commit, before, after))
|
||||
return changes
|
||||
|
||||
|
||||
def landed_since_release(default: str) -> bool | Failure:
|
||||
"""Whether the default branch holds a commit after its newest `v*` tag, or any commit when it has none."""
|
||||
# Sorts v1.0.0-rc.1 below v1.0.0.
|
||||
tags = git("-c", "versionsort.suffix=-", "tag", "--list", "v*", "--merged", default, "--sort=-v:refname")
|
||||
if isinstance(tags, Failure):
|
||||
return tags
|
||||
newest = tags.split()[:1]
|
||||
count = git("rev-list", "--count", f"{newest[0]}..{default}" if newest else default)
|
||||
return count if isinstance(count, Failure) else int(count) > 0
|
||||
@@ -0,0 +1,137 @@
|
||||
import dataclasses
|
||||
import re
|
||||
import time
|
||||
|
||||
from larv_review.seats import ARCHITECT, DIMENSIONS, MEAN, Seat
|
||||
from failure import Failure
|
||||
from markdown_sections import sections
|
||||
|
||||
DATED = re.compile(r"^[0-9]{4}-[0-9]{2}-[0-9]{2}(?:T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)?, ")
|
||||
DECIDED_BY = "decided by"
|
||||
HARDEST_FIRST = "hardest first"
|
||||
HEADING = re.compile(r"^([^,]+), (.+) at ([0-9a-f]{7,40})(?:, against ([0-9a-f]{7,40}))?$")
|
||||
# `path:line` or `:line`, then the unit's name where one follows.
|
||||
PLACE = re.compile(r"`([^`\s]*):\d+`(?: `(\w+)`)?")
|
||||
RESTRUCTURE_FIRST = "would restructure first"
|
||||
RULING = re.compile(r"^Ruling: (better|same|worse)$", re.M)
|
||||
SEAT_PLACES = re.compile(rf"^.+, ({DECIDED_BY}|{HARDEST_FIRST}|{RESTRUCTURE_FIRST}):$")
|
||||
STAMP = "%Y-%m-%dT%H:%M:%SZ"
|
||||
TITLE = "# Comprehension history\n"
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Place:
|
||||
path: str
|
||||
name: str | None
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Entry:
|
||||
"""One paired ruling, which names the commit it was against and its ruling, or one scoring run, which names neither."""
|
||||
heading: str
|
||||
time: str
|
||||
commit: str
|
||||
against: str | None
|
||||
ruling: str | None
|
||||
places: list[Place]
|
||||
|
||||
@property
|
||||
def paired(self) -> bool:
|
||||
return self.against is not None
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Heading:
|
||||
title: str
|
||||
commit: str
|
||||
against: str | None
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class HistoryChange:
|
||||
"""A merged change on the default branch that touched the history, and the history before and after it."""
|
||||
commit: str
|
||||
before: str
|
||||
after: str
|
||||
|
||||
|
||||
def entries(history: str) -> list[Entry]:
|
||||
"""Each paired ruling and scoring run in a comprehension history, in the order the file holds them; a section whose heading names no commit is left out."""
|
||||
found = []
|
||||
for heading, bodies in sections(history).items():
|
||||
if named := HEADING.match(heading):
|
||||
body = "\n".join(bodies)
|
||||
ruling = RULING.search(body)
|
||||
found.append(Entry(heading, named.group(1), named.group(3), named.group(4), ruling.group(1) if ruling else None, seat_places(body)))
|
||||
return found
|
||||
|
||||
|
||||
def seat_places(body: str) -> list[Place]:
|
||||
places = []
|
||||
listing = False
|
||||
for line in body.splitlines():
|
||||
if SEAT_PLACES.match(line):
|
||||
listing = True
|
||||
elif listing and line.startswith("- "):
|
||||
places += bullet_places(line)
|
||||
elif not line.startswith(" "):
|
||||
listing = False
|
||||
return places
|
||||
|
||||
|
||||
def bullet_places(bullet: str) -> list[Place]:
|
||||
"""A `:line` with no path is in the file named before it in the bullet."""
|
||||
places = []
|
||||
path = ""
|
||||
for match in PLACE.finditer(bullet):
|
||||
path = match.group(1) or path
|
||||
if path:
|
||||
places.append(Place(path, match.group(2)))
|
||||
return places
|
||||
|
||||
|
||||
def heading(at: float, read: str, paired: bool, moved: bool) -> Heading | Failure:
|
||||
"""An entry's heading, matched by HEADING: when the seats finished, in UTC, and what they read. A run moved from a decision entry opens instead with the date or time that entry gives."""
|
||||
if moved and not DATED.match(read):
|
||||
return Failure(f"a seats file holding a {MEAN} line alone opens with YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ, then `, `: {read}")
|
||||
if DATED.match(read) and not moved:
|
||||
return Failure(f"only a seats file holding a {MEAN} line alone opens with a date: {read}")
|
||||
title = read if moved else f"{time.strftime(STAMP, time.gmtime(at))}, {read}"
|
||||
if (named := HEADING.match(title)) and bool(named.group(4)) == paired:
|
||||
return Heading(title, named.group(3), named.group(4))
|
||||
return Failure(f"the seats file's first line is not `<PR or branch> at <commit>{', against <base>' if paired else ''}`: {read}")
|
||||
|
||||
|
||||
def appended(history: str, entry: str) -> str:
|
||||
"""The history with entry added last; an empty history gets the file's title first."""
|
||||
text = history.rstrip("\n") + "\n" if history.strip() else TITLE
|
||||
return f"{text}\n{entry}"
|
||||
|
||||
|
||||
def ruling_entry(title: str, seats: list[Seat], counted: dict[str, str], ruled: str) -> str:
|
||||
"""A paired ruling's entry; a seat's vote that counted as same for naming no place says so."""
|
||||
votes = [[seat.name, vote_text(seat, counted[seat.name])] for seat in seats]
|
||||
return entry_text(title, [f"Ruling: {ruled}"], [["Seat", "Vote"], *votes], [(f"{seat.name}, {DECIDED_BY}:", seat.places) for seat in seats])
|
||||
|
||||
|
||||
def vote_text(seat: Seat, counted: str) -> str:
|
||||
return counted if counted == seat.said else f"same (voted {seat.said}, naming no place)"
|
||||
|
||||
|
||||
def scoring_entry(title: str, seats: list[Seat], scores: dict[str, list[str]], means: list[str]) -> str:
|
||||
"""A scoring run's entry; a run moved from a decision entry has its means alone."""
|
||||
rows = [[seat, *values] for seat, values in scores.items()] + [[MEAN, *means]]
|
||||
labels = [(f"{seat.name}, {RESTRUCTURE_FIRST if seat.name == ARCHITECT else HARDEST_FIRST}:", seat.places) for seat in seats]
|
||||
return entry_text(title, [], [["Seat", *DIMENSIONS], *rows], labels)
|
||||
|
||||
|
||||
def entry_text(title: str, lines: list[str], table: list[list[str]], seats: list[tuple[str, list[str]]]) -> str:
|
||||
"""The heading, any lines such as `Ruling: same`, a table whose first row is its header, and under each seat's label its places, one bullet each."""
|
||||
header, *rows = table
|
||||
parts = [f"## {title}", *lines, "\n".join([row_text(header), "|" + "---|" * len(header), *map(row_text, rows)])]
|
||||
parts += [f"{label}\n\n" + "\n".join(f"- {place}" for place in places) for label, places in seats if places]
|
||||
return "\n\n".join(parts) + "\n"
|
||||
|
||||
|
||||
def row_text(cells: list[str]) -> str:
|
||||
return "| " + " | ".join(cells) + " |"
|
||||
@@ -0,0 +1,241 @@
|
||||
"""Hold larv-review's mechanical rules: the paired ruling's base and vote count, each pass's rounds, the scoring run's trigger, and the comprehension history's format.
|
||||
|
||||
usage: larv-review ruling-base | round-count | needs-scoring-run [<item ID>...] | record-ruling <seats file> | record-scoring <seats file>
|
||||
|
||||
Run it inside a project checkout or one of its worktrees. ruling-base, round-count and
|
||||
needs-scoring-run first fetch origin, when the checkout has that remote, and take origin's default
|
||||
branch, or else the local main or master, as the default branch. When the fetch fails, round-count
|
||||
reads origin as last fetched and says so on stderr; the other two exit 1. The history is
|
||||
docs/comprehension-history.md in the checkout.
|
||||
|
||||
ruling-base prints the commit a paired ruling reads against, then which of these found it. The last
|
||||
measured commit is the default branch's newest merged change that adds a scoring run to the
|
||||
history, or whose last added paired ruling, by heading time, is better; a merge commit counts as
|
||||
one change against its first parent. With none, the base is the one the history's first paired
|
||||
ruling names; with no ruling either, it is the merge base of HEAD and the default branch.
|
||||
|
||||
round-count prints each pass's count: the highest <n> among the titles opening
|
||||
`Answer <pass> round <n>:` of commits the default branch does not hold. It marks each pass at the
|
||||
cap of {cap} rounds, and each name in such a title that is not a pass.
|
||||
|
||||
needs-scoring-run takes the IDs of the todo.md items the chunk ships, none when it ships none, and
|
||||
prints why the chunk is due a scoring run, or `No scoring run due.` It is due when the chunk ships
|
||||
an item whose tagline names the comprehension floor, or when it leaves a release with no item in
|
||||
the checkout's todo.md, less the shipped items, and work has landed towards that release. Work has
|
||||
landed when the chunk ships one of the release's items, or when the release is the earliest the
|
||||
default branch's todo.md names and the default branch has a commit after its newest v* tag, or has
|
||||
no v* tag.
|
||||
|
||||
record-ruling and record-scoring read a seats file: a first line naming what the seats read,
|
||||
`<PR or branch> at <commit>`, ending `, against <base>` for a paired ruling, then each seat's
|
||||
line, each followed by its places, one `- ` bullet each, as the history writes them. A seat's line
|
||||
opens with its label, written exactly: `Junior A:`, `Mid A:`, `Maintainability senior:` or
|
||||
`Inherited architect:`.
|
||||
|
||||
PR #231 at abc1234, against def5678
|
||||
|
||||
Mid A: worse
|
||||
|
||||
- `bin/x.py:12` `run`: three branches to hold at once
|
||||
|
||||
Inherited architect: worse
|
||||
|
||||
- `bin/x.py:12` `run`: ...
|
||||
|
||||
record-ruling takes Mid A's and the inherited architect's votes, better, same or worse; a better or
|
||||
worse vote naming no place in backticks, `path:line`, counts as same, and the printed votes say so.
|
||||
When the two counted votes differ, it appends nothing and prints `Split:`, saying to add the
|
||||
maintainability senior's and Junior A's lines. Otherwise the ruling is the vote that leads each
|
||||
other vote by two or more, else same; it prints `Ruling:` and appends the ruling.
|
||||
|
||||
record-scoring takes Junior A's, Mid A's, the maintainability senior's and the inherited
|
||||
architect's lines in that order, or a `Mean:` line alone for a run moved from a decision entry.
|
||||
Each line is `Navigation <n>, Locality <n>, Shape <n>, Self-sufficiency <n>, Overall <n>`, each
|
||||
score from 1 to 10 and the overall at most 1 above the line's lowest dimension. Its first line
|
||||
names no `, against`. It appends the seats' scores and their means, rounded half up to two
|
||||
decimals, and prints the means and each one under the floor of {floor}.
|
||||
|
||||
Each record is appended to the history, created when missing, under a heading of the current UTC
|
||||
time and the seats file's first line. A file holding a `Mean:` line alone opens with the date or
|
||||
time its decision entry gives, and that line alone is the heading. Each commit the line names
|
||||
must be in the checkout. Each run appends, so record a ruling or a run once.
|
||||
|
||||
Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it cannot read or that
|
||||
breaks the shape above, or when git cannot start, finds no checkout or no default branch, cannot
|
||||
fetch origin for ruling-base or needs-scoring-run, or cannot read or write the history or todo.md.
|
||||
"""
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
import typing
|
||||
|
||||
from larv_review.history import appended, heading, ruling_entry, scoring_entry, vote_text
|
||||
from larv_review.rules import base, CAP, FLOOR, means, PASSES, plan_items, round_counts, ruling, scoring_run_due, under_floor, votes
|
||||
from larv_review.git import commit_exists, default_branch, file_at, git, HISTORY, history_changes, landed_since_release, top
|
||||
from larv_review.seats import DIMENSIONS, MEAN, Report, report, score_line, scores
|
||||
from failure import Failure
|
||||
from rank_todo import ITEMS_HEADER
|
||||
from file_writes import replace_file
|
||||
|
||||
USAGE = "usage: larv-review ruling-base | round-count | needs-scoring-run [<item ID>...] | record-ruling <seats file> | record-scoring <seats file>"
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
if argv in (["-h"], ["--help"]):
|
||||
print(__doc__.strip().format(cap=CAP, floor=FLOOR))
|
||||
return 0
|
||||
command, *given = argv or [""]
|
||||
if command == "ruling-base" and not given:
|
||||
done = with_default_branch(ruling_base, stale_ok=False)
|
||||
elif command == "round-count" and not given:
|
||||
done = with_default_branch(round_count, stale_ok=True)
|
||||
elif command == "needs-scoring-run" and all(re.fullmatch(r"[0-9]+", id_) for id_ in given):
|
||||
done = with_default_branch(lambda default: needs_scoring_run(default, [int(id_) for id_ in given]), stale_ok=False)
|
||||
elif command == "record-ruling" and len(given) == 1:
|
||||
done = record_ruling(pathlib.Path(given[0]))
|
||||
elif command == "record-scoring" and len(given) == 1:
|
||||
done = record_scoring(pathlib.Path(given[0]))
|
||||
elif command == "needs-scoring-run":
|
||||
print(f"needs-scoring-run takes item IDs, the numbers in todo.md's ID column: {' '.join(given)}", file=sys.stderr)
|
||||
return 1
|
||||
elif not argv:
|
||||
print(USAGE, file=sys.stderr)
|
||||
return 1
|
||||
else:
|
||||
print(f"unknown arguments {' '.join(argv)}; {USAGE}", file=sys.stderr)
|
||||
return 1
|
||||
if isinstance(done, Failure):
|
||||
print(done.reason, file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def with_default_branch(command: typing.Callable[[str], Failure | None], stale_ok: bool) -> Failure | None:
|
||||
default = default_branch(stale_ok)
|
||||
if isinstance(default, Failure):
|
||||
return default
|
||||
branch, note = default
|
||||
if note:
|
||||
print(note, file=sys.stderr)
|
||||
return command(branch)
|
||||
|
||||
|
||||
def ruling_base(default: str) -> Failure | None:
|
||||
changes = history_changes(default)
|
||||
if isinstance(changes, Failure):
|
||||
return changes
|
||||
history = file_at(default, HISTORY)
|
||||
if isinstance(history, Failure):
|
||||
return history
|
||||
if found := base(changes, history):
|
||||
print("\n".join(found))
|
||||
return None
|
||||
merge_base = git("merge-base", "HEAD", default)
|
||||
if isinstance(merge_base, Failure):
|
||||
return merge_base
|
||||
print(f"{merge_base.strip()}\nthe merge base of HEAD and {default}")
|
||||
return None
|
||||
|
||||
|
||||
def round_count(default: str) -> Failure | None:
|
||||
titles = git("log", "--format=%s", f"{default}..HEAD")
|
||||
if isinstance(titles, Failure):
|
||||
return titles
|
||||
for name, count in round_counts(titles.splitlines()).items():
|
||||
print(f"{name}: {count}{', at the cap' if count >= CAP else ''}{'' if name in PASSES else ', not a pass: check the commit title'}")
|
||||
return None
|
||||
|
||||
|
||||
def needs_scoring_run(default: str, ids: list[int]) -> Failure | None:
|
||||
checkout = top()
|
||||
if isinstance(checkout, Failure):
|
||||
return checkout
|
||||
before = file_at(default, "todo.md")
|
||||
if isinstance(before, Failure):
|
||||
return before
|
||||
try:
|
||||
after = pathlib.Path(checkout, "todo.md").read_text(encoding="utf-8")
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read todo.md: {failure}")
|
||||
# While a chunk reshapes todo.md into one table, the default branch's todo.md has no items table.
|
||||
planned = plan_items(before) if ITEMS_HEADER in before.splitlines() else []
|
||||
if isinstance(planned, Failure):
|
||||
return Failure(f"{default}'s todo.md: {planned.reason}")
|
||||
chunk = plan_items(after)
|
||||
if isinstance(chunk, Failure):
|
||||
return Failure(f"the checkout's todo.md: {chunk.reason}")
|
||||
landed = landed_since_release(default)
|
||||
if isinstance(landed, Failure):
|
||||
return landed
|
||||
reasons = scoring_run_due(planned, chunk, ids, landed)
|
||||
if isinstance(reasons, Failure):
|
||||
return reasons
|
||||
print(f"Scoring run due: the chunk {' and '.join(reasons)}." if reasons else "No scoring run due.")
|
||||
return None
|
||||
|
||||
|
||||
def record_ruling(seats_file: pathlib.Path) -> Failure | None:
|
||||
read = read_seats(seats_file, paired=True)
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
title, given = read
|
||||
counted = votes(given.seats)
|
||||
if isinstance(counted, Failure):
|
||||
return counted
|
||||
tally = ", ".join(f"{seat.name} {vote_text(seat, counted[seat.name])}" for seat in given.seats)
|
||||
ruled = ruling(list(counted.values()))
|
||||
if ruled is None:
|
||||
print(f"Split: {tally}. Launch the maintainability senior and Junior A together, add their lines to the seats file, and run this again.")
|
||||
return None
|
||||
print(f"Ruling: {ruled}. Votes as counted: {tally}.")
|
||||
return append(ruling_entry(title, given.seats, counted, ruled))
|
||||
|
||||
|
||||
def record_scoring(seats_file: pathlib.Path) -> Failure | None:
|
||||
read = read_seats(seats_file, paired=False)
|
||||
if isinstance(read, Failure):
|
||||
return read
|
||||
title, given = read
|
||||
found = scores(given.seats) if given.moved_mean is None else {}
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
moved = [] if given.moved_mean is None else score_line(MEAN, given.moved_mean)
|
||||
if isinstance(moved, Failure):
|
||||
return moved
|
||||
mean = means(list(found.values()) or [moved])
|
||||
under = under_floor(mean)
|
||||
print(f"Means: {', '.join(f'{name} {value}' for name, value in zip(DIMENSIONS, mean))}. {f'Under the floor of {FLOOR}: ' + ', '.join(under) if under else f'None under the floor of {FLOOR}'}.")
|
||||
return append(scoring_entry(title, given.seats, found, [str(value) for value in mean]))
|
||||
|
||||
|
||||
def read_seats(seats_file: pathlib.Path, paired: bool) -> tuple[str, Report] | Failure:
|
||||
"""The seats file, and the heading its record goes under, once each commit it names is in the checkout."""
|
||||
try:
|
||||
given = report(seats_file.read_text(encoding="utf-8"))
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read {seats_file}: {failure}")
|
||||
if isinstance(given, Failure):
|
||||
return given
|
||||
named = heading(time.time(), given.read, paired, given.moved_mean is not None)
|
||||
if isinstance(named, Failure):
|
||||
return named
|
||||
if unknown := [commit for commit in (named.commit, named.against) if commit and not commit_exists(commit)]:
|
||||
return Failure(f"the seats file names {', '.join(unknown)}, which is no commit in this checkout")
|
||||
return named.title, given
|
||||
|
||||
|
||||
def append(entry: str) -> Failure | None:
|
||||
checkout = top()
|
||||
if isinstance(checkout, Failure):
|
||||
return checkout
|
||||
history = pathlib.Path(checkout, HISTORY)
|
||||
try:
|
||||
text = history.read_text(encoding="utf-8") if history.exists() else ""
|
||||
history.parent.mkdir(parents=True, exist_ok=True)
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read {history}: {failure}")
|
||||
if unwritten := replace_file(history, appended(text, entry).encode()):
|
||||
return Failure(f"could not write {history}: {unwritten.reason}")
|
||||
print(f"Appended to {history}.")
|
||||
return None
|
||||
@@ -0,0 +1,123 @@
|
||||
import decimal
|
||||
import re
|
||||
|
||||
from larv_review.seats import DIMENSIONS, FIRST_SEATS, Seat, SPLIT_SEATS
|
||||
from larv_review.history import entries, Entry, HistoryChange, PLACE
|
||||
from failure import Failure
|
||||
from rank_todo import Item, ITEMS_HEADER, parse_row, table_rows
|
||||
|
||||
CAP = 3
|
||||
FLOOR = decimal.Decimal("7.0")
|
||||
PASSES = ("architecture", "full scan", "security", "stability", "product-owner", "prose")
|
||||
ROUND = re.compile(r"^Answer (.+?) round ([0-9]+):")
|
||||
VOTES = ("better", "same", "worse")
|
||||
|
||||
|
||||
def votes(seats: list[Seat]) -> dict[str, str] | Failure:
|
||||
"""Each seat's vote as it counts: a better or worse vote naming no `path:line` place counts as same."""
|
||||
names = [seat.name for seat in seats]
|
||||
if names[:2] != list(FIRST_SEATS) or names[2:] not in ([], list(SPLIT_SEATS)):
|
||||
return Failure(f"a paired ruling's seats are {' and '.join(FIRST_SEATS)}, then, when their votes differ, {' and '.join(SPLIT_SEATS)}, in that order; the file has {', '.join(names) or 'none'}")
|
||||
if unknown := [seat for seat in seats if seat.said not in VOTES]:
|
||||
return Failure(f"{unknown[0].name}'s vote {unknown[0].said!r} is not better, same or worse")
|
||||
counted = {seat.name: seat.said if names_a_place(seat) else "same" for seat in seats}
|
||||
first, second, *more = counted.values()
|
||||
if more and first == second:
|
||||
return Failure(f"{' and '.join(FIRST_SEATS)} both count as {first}, which settles the ruling; drop the other seats' lines")
|
||||
return counted
|
||||
|
||||
|
||||
def names_a_place(seat: Seat) -> bool:
|
||||
return any(PLACE.search(place) for place in seat.places)
|
||||
|
||||
|
||||
def ruling(counted: list[str]) -> str | None:
|
||||
"""The vote that leads each other vote by two or more, else same; None when only the first two seats voted and they differ, so two more must vote."""
|
||||
if len(counted) == 2 and counted[0] != counted[1]:
|
||||
return None
|
||||
for vote in VOTES:
|
||||
if all(counted.count(vote) >= counted.count(other) + 2 for other in VOTES if other != vote):
|
||||
return vote
|
||||
return "same"
|
||||
|
||||
|
||||
def means(lines: list[list[str]]) -> list[decimal.Decimal]:
|
||||
"""The mean of each score across the lines, in DIMENSIONS' order, rounded half up to two decimals."""
|
||||
return [mean([decimal.Decimal(score) for score in column]) for column in zip(*lines)]
|
||||
|
||||
|
||||
def mean(values: list[decimal.Decimal]) -> decimal.Decimal:
|
||||
return (sum(values, decimal.Decimal(0)) / len(values)).quantize(decimal.Decimal("0.01"), decimal.ROUND_HALF_UP)
|
||||
|
||||
|
||||
def under_floor(found: list[decimal.Decimal]) -> list[str]:
|
||||
return [f"{name} {value}" for name, value in zip(DIMENSIONS, found) if value < FLOOR]
|
||||
|
||||
|
||||
def round_counts(titles: list[str]) -> dict[str, int]:
|
||||
"""Each pass's highest round among the branch's `Answer <pass> round <n>:` commit titles; a pass with none has 0, and a title naming no known pass adds its name."""
|
||||
counts = dict.fromkeys(PASSES, 0)
|
||||
for title in titles:
|
||||
if named := ROUND.match(title):
|
||||
counts[named.group(1)] = max(counts.get(named.group(1), 0), int(named.group(2)))
|
||||
return counts
|
||||
|
||||
|
||||
def measured_commit(changes: list[HistoryChange]) -> str | None:
|
||||
"""The newest change, of changes given newest first, that adds a scoring run to the history, or whose last added paired ruling is better."""
|
||||
for change in changes:
|
||||
held = {entry.heading for entry in entries(change.before)}
|
||||
added = [entry for entry in entries(change.after) if entry.heading not in held]
|
||||
rulings = sorted((entry for entry in added if entry.paired), key=lambda entry: entry.time)
|
||||
if any(not entry.paired for entry in added) or rulings and rulings[-1].ruling == "better":
|
||||
return change.commit
|
||||
return None
|
||||
|
||||
|
||||
def first_ruling(history: str) -> Entry | None:
|
||||
rulings = sorted((entry for entry in entries(history) if entry.paired), key=lambda entry: entry.time)
|
||||
return rulings[0] if rulings else None
|
||||
|
||||
|
||||
def base(changes: list[HistoryChange], history: str) -> tuple[str, str] | None:
|
||||
"""The commit a paired ruling reads against, and which fallback found it; None leaves the merge base of HEAD and the default branch. history is the default branch's."""
|
||||
if found := measured_commit(changes):
|
||||
return found, "the last measured commit"
|
||||
if (first := first_ruling(history)) and first.against:
|
||||
return first.against, "the base the history's first paired ruling names"
|
||||
return None
|
||||
|
||||
|
||||
def plan_items(todo: str) -> list[Item] | Failure:
|
||||
"""Each row of a todo.md's items table, read as `rank_todo.py` reads it."""
|
||||
table = table_rows(todo.splitlines(), ITEMS_HEADER)
|
||||
if isinstance(table, Failure):
|
||||
return table
|
||||
items = []
|
||||
for row in table.rows:
|
||||
item = parse_row(row)
|
||||
if isinstance(item, Failure):
|
||||
return item
|
||||
items.append(item)
|
||||
return items
|
||||
|
||||
|
||||
def scoring_run_due(before: list[Item], after: list[Item], ships: list[int], landed: bool) -> list[str] | Failure:
|
||||
"""Why the chunk takes a scoring run, empty when it does not. before is the default branch's plan, after the chunk's, ships the IDs it ships, and landed whether the default branch holds a commit after its newest release tag. Work has landed towards an emptied release when the chunk ships one of its items, or when it is the next release, the earliest before names, and landed holds."""
|
||||
plan = {item.id: item for item in before + after}
|
||||
if unknown := sorted(set(ships) - set(plan)):
|
||||
return Failure(f"neither plan holds item {', '.join(map(str, unknown))}")
|
||||
shipped = [plan[id_] for id_ in ships]
|
||||
reasons = [f"ships item {item.id}, which names the comprehension floor" for item in shipped if "comprehension floor" in item.tagline.lower()]
|
||||
next_release = min((item.release for item in before), default=None)
|
||||
for release in emptied(before, after, shipped):
|
||||
if any(item.release == release for item in shipped) or (release == next_release and landed):
|
||||
reasons.append(f"leaves release {'.'.join(map(str, release))} with no plan item")
|
||||
return reasons
|
||||
|
||||
|
||||
def emptied(before: list[Item], after: list[Item], shipped: list[Item]) -> list[tuple[int, int, int]]:
|
||||
"""Each release the default branch's plan or a shipped item names that the chunk's plan, less the shipped items, names no longer."""
|
||||
named = {item.release for item in before + shipped}
|
||||
left = {item.release for item in after if item.id not in {ship.id for ship in shipped}}
|
||||
return sorted(named - left)
|
||||
@@ -0,0 +1,83 @@
|
||||
import dataclasses
|
||||
import decimal
|
||||
import re
|
||||
|
||||
from failure import Failure
|
||||
|
||||
ARCHITECT = "Inherited architect"
|
||||
DIMENSIONS = ("Navigation", "Locality", "Shape", "Self-sufficiency", "Overall")
|
||||
JUNIOR = "Junior A"
|
||||
# A scoring run moved from a `comprehension floor:` decision entry kept only the seats' means.
|
||||
MEAN = "Mean"
|
||||
MID = "Mid A"
|
||||
SCORES = re.compile(", ".join(rf"{name} ([0-9]+(?:\.[0-9]+)?)" for name in DIMENSIONS))
|
||||
SENIOR = "Maintainability senior"
|
||||
|
||||
FIRST_SEATS = (MID, ARCHITECT)
|
||||
SCORING_SEATS = (JUNIOR, MID, SENIOR, ARCHITECT)
|
||||
SEAT_LINE = re.compile(rf"^({'|'.join(SCORING_SEATS)}): (.+)$")
|
||||
SPLIT_SEATS = (SENIOR, JUNIOR)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Seat:
|
||||
name: str
|
||||
said: str
|
||||
places: list[str]
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Report:
|
||||
"""A seats file: what the seats read, `<PR or branch> at <commit>`, with `, against <base>` for a paired ruling, then each seat's line and its places, or, for a run moved from a decision entry, its Mean line alone."""
|
||||
read: str
|
||||
seats: list[Seat]
|
||||
moved_mean: str | None
|
||||
|
||||
|
||||
def report(text: str) -> Report | Failure:
|
||||
lines = [line for line in text.splitlines() if line.strip()]
|
||||
if not lines:
|
||||
return Failure("the seats file is empty; its first line names what the seats read: <PR or branch> at <commit>")
|
||||
seats: list[Seat] = []
|
||||
moved_mean = None
|
||||
for line in lines[1:]:
|
||||
if line.startswith(f"{MEAN}: ") and not seats and moved_mean is None:
|
||||
moved_mean = line[len(MEAN) + 2:].strip()
|
||||
elif moved_mean is not None:
|
||||
return Failure(f"a {MEAN} line stands alone in its seats file: {line}")
|
||||
elif seat := SEAT_LINE.match(line):
|
||||
if seat.group(1) in [known.name for known in seats]:
|
||||
return Failure(f"{seat.group(1)} appears twice in the seats file")
|
||||
seats.append(Seat(seat.group(1), seat.group(2).strip(), []))
|
||||
elif seats and line.startswith("- "):
|
||||
seats[-1].places.append(line[2:].strip())
|
||||
elif seats and seats[-1].places and line.startswith(" "):
|
||||
seats[-1].places[-1] += " " + line.strip()
|
||||
else:
|
||||
return Failure(f"the seats file has a line that is neither a seat's line, opening with one of {', '.join(SCORING_SEATS)} and a colon, nor one of its places: {line}")
|
||||
return Report(lines[0].strip(), seats, moved_mean)
|
||||
|
||||
|
||||
def scores(seats: list[Seat]) -> dict[str, list[str]] | Failure:
|
||||
"""Each seat's five scores as written, in DIMENSIONS' order."""
|
||||
if [seat.name for seat in seats] != list(SCORING_SEATS):
|
||||
return Failure(f"a scoring run's seats are {', '.join(SCORING_SEATS)}, in that order, or a {MEAN} line alone; the file has {', '.join(seat.name for seat in seats) or 'none'}")
|
||||
found = {}
|
||||
for seat in seats:
|
||||
values = score_line(seat.name, seat.said)
|
||||
if isinstance(values, Failure):
|
||||
return values
|
||||
found[seat.name] = values
|
||||
return found
|
||||
|
||||
|
||||
def score_line(name: str, said: str) -> list[str] | Failure:
|
||||
"""A line's five scores as written, each from 1 to 10 and the overall at most 1 above the lowest dimension."""
|
||||
if not (written := SCORES.fullmatch(said)):
|
||||
return Failure(f"{name}'s line is not {', '.join(score + ' <score>' for score in DIMENSIONS)}: {said}")
|
||||
values = [decimal.Decimal(value) for value in written.groups()]
|
||||
if not all(1 <= value <= 10 for value in values):
|
||||
return Failure(f"{name}'s scores are not each from 1 to 10: {said}")
|
||||
if values[-1] > min(values[:-1]) + 1:
|
||||
return Failure(f"{name}'s overall exceeds the lowest dimension by more than 1; ask the seat to rescore: {said}")
|
||||
return list(written.groups())
|
||||
@@ -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
|
||||
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
|
||||
@@ -109,7 +109,7 @@ def question_for(ruling: Interrupt | QuotedAnswer) -> str:
|
||||
|
||||
def close(cycle: Cycle, transcript_path: str, verdict: Finished | Unfinished) -> Archived | Stop:
|
||||
finished = isinstance(verdict, Finished)
|
||||
if failure := archive(cycle.project_key, transcript_path, cycle.task, f"Verdict: {'finished' if finished else 'unfinished'}\n\nEvidence:\n{quoted(verdict.evidence)}", cycle.effects.now(), cycle.paths):
|
||||
if failure := archive(cycle.project_key, transcript_path, cycle.task, f"{FINISHED if finished else UNFINISHED}\n\nEvidence:\n{quoted(verdict.evidence)}", cycle.effects.now(), cycle.paths):
|
||||
return Stop(1, failure.reason)
|
||||
if finished and (failure := delete_session(cycle.session)):
|
||||
return Stop(1, failure.reason)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import dataclasses
|
||||
import hashlib
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
|
||||
@@ -10,6 +12,20 @@ from file_writes import make_private, replace_file
|
||||
from loop_claude.paths import Paths
|
||||
from loop_claude.claude_code.session import session_files
|
||||
|
||||
FINISHED = "Verdict: finished"
|
||||
UNFINISHED = "Verdict: unfinished"
|
||||
STAMP = "%Y-%m-%dT%H:%M:%SZ"
|
||||
STAMPED = r"\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ"
|
||||
FINISHED_AT = re.compile(rf"^({STAMPED}) {re.escape(FINISHED)}$", re.MULTILINE)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class FinishedChunk:
|
||||
folder: str
|
||||
finished: str
|
||||
transcript: pathlib.Path
|
||||
subagents: list[pathlib.Path]
|
||||
|
||||
|
||||
def archive(project_key: str, path: str, task: str, outcome: str, at: float, paths: Paths) -> Failure | None:
|
||||
try:
|
||||
@@ -25,7 +41,7 @@ def archive(project_key: str, path: str, task: str, outcome: str, at: float, pat
|
||||
return unkept
|
||||
copy = folder / f"{hashlib.sha256(raw).hexdigest()}.jsonl"
|
||||
outcomes = copy.with_suffix(".outcomes.md")
|
||||
stamped = f"{time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(at))} {outcome}"
|
||||
stamped = f"{utc(at)} {outcome}"
|
||||
if copy.exists() and outcomes.exists():
|
||||
return add_outcome(outcomes, stamped)
|
||||
# The copy lands last, so a copy on disk always has its outcomes and its session's files beside it.
|
||||
@@ -85,3 +101,21 @@ def copy_for(copy: pathlib.Path, data: bytes) -> pathlib.Path | None:
|
||||
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
|
||||
|
||||
|
||||
def utc(at: float) -> str:
|
||||
return time.strftime(STAMP, time.gmtime(at))
|
||||
|
||||
|
||||
# One per chunk folder, its latest finished copy, in the order they finished.
|
||||
def finished_chunks(project_archive: pathlib.Path) -> list[FinishedChunk] | Failure:
|
||||
found = []
|
||||
try:
|
||||
for folder in sorted(path for path in project_archive.glob("*") if path.is_dir()):
|
||||
copies = sorted((stamps[-1], outcomes) for outcomes in folder.glob("*.outcomes.md") if (stamps := FINISHED_AT.findall(outcomes.read_text(encoding="utf-8"))))
|
||||
if copies:
|
||||
finished, outcomes = copies[-1]
|
||||
found.append(FinishedChunk(folder.name, finished, outcomes.with_name(outcomes.name.removesuffix(".outcomes.md") + ".jsonl"), sorted(folder.glob("session/*/subagents/*.jsonl"))))
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read the archive {project_archive}: {failure}")
|
||||
return sorted(found, key=lambda chunk: (chunk.finished, chunk.folder))
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from metric_bench import main
|
||||
|
||||
sys.exit(main.main(sys.argv[1:]))
|
||||
@@ -0,0 +1,100 @@
|
||||
from typing import Callable
|
||||
import collections
|
||||
import dataclasses
|
||||
import os
|
||||
import statistics
|
||||
|
||||
from larv_review.history import Place
|
||||
from metric_bench.python_units import Unit
|
||||
|
||||
METRICS: dict[str, Callable[[Unit, dict[str, int]], int]] = {
|
||||
"cognitive complexity": lambda unit, spread: unit.cognitive,
|
||||
"length": lambda unit, spread: unit.length,
|
||||
"shared state": lambda unit, spread: unit.shared_state,
|
||||
"change spread": lambda unit, spread: spread.get(unit.path, 0),
|
||||
}
|
||||
|
||||
|
||||
# Code Maat's default --max-changeset-size: a sweep across the tree couples every file to every other.
|
||||
LARGEST_CHANGESET = 30
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Score:
|
||||
auc: float
|
||||
top_k: float
|
||||
constant: bool
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class RunScores:
|
||||
units: int
|
||||
named: int
|
||||
unmeasured: int
|
||||
scores: dict[str, Score]
|
||||
|
||||
|
||||
def co_changed(log: str) -> dict[str, int]:
|
||||
"""For each file, how many other files changed in a commit with it, commits of more than LARGEST_CHANGESET files left out; log is `git log --format=tformat:@@ --name-only`."""
|
||||
partners: dict[str, set[str]] = collections.defaultdict(set)
|
||||
for commit in log.split("@@\n"):
|
||||
files = set(filter(None, commit.split("\n")))
|
||||
if len(files) > LARGEST_CHANGESET:
|
||||
continue
|
||||
for path in files:
|
||||
partners[path] |= files - {path}
|
||||
return {path: len(others) for path, others in partners.items()}
|
||||
|
||||
|
||||
def bench(units: list[Unit], places: list[Place], unresolved: int, spread: dict[str, int]) -> RunScores | None:
|
||||
"""How well each metric ranks the units the seats named above the rest; None when the named units are none or all of them. unresolved counts the places that named no tracked file."""
|
||||
names = {(place.path, place.name) for place in places}
|
||||
named = [unit for unit in units if (unit.path, unit.name) in names]
|
||||
if not named or len(named) == len(units):
|
||||
return None
|
||||
rest = [unit for unit in units if (unit.path, unit.name) not in names]
|
||||
found = {(unit.path, unit.name) for unit in named}
|
||||
unmeasured = unresolved + len({place for place in places if (place.path, place.name) not in found})
|
||||
scores = {}
|
||||
for metric, value in METRICS.items():
|
||||
named_values = [value(unit, spread) for unit in named]
|
||||
rest_values = [value(unit, spread) for unit in rest]
|
||||
scores[metric] = Score(auc(named_values, rest_values), top_k(named_values, rest_values), len(set(named_values + rest_values)) == 1)
|
||||
return RunScores(len(units), len(named), unmeasured, scores)
|
||||
|
||||
|
||||
def auc(named: list[int], rest: list[int]) -> float:
|
||||
"""The chance a named unit outranks one not named, a tie counting half: 0.5 is a coin toss, 1.0 a perfect ranking."""
|
||||
wins = sum((a > b) + 0.5 * (a == b) for a in named for b in rest)
|
||||
return wins / (len(named) * len(rest))
|
||||
|
||||
|
||||
def top_k(named: list[int], rest: list[int]) -> float:
|
||||
"""The share of the metric's k highest units the seats named, k being how many they named. Units tied at the cut share its remaining slots evenly, as a random order of them would."""
|
||||
k = len(named)
|
||||
cut = sorted(named + rest, reverse=True)[k - 1]
|
||||
above = sum(value > cut for value in named)
|
||||
slots = k - above - sum(value > cut for value in rest)
|
||||
tied_named = sum(value == cut for value in named)
|
||||
tied = tied_named + sum(value == cut for value in rest)
|
||||
return (above + slots * tied_named / tied) / k
|
||||
|
||||
|
||||
def medians(runs: list[RunScores]) -> dict[str, Score]:
|
||||
return {metric: Score(statistics.median(run.scores[metric].auc for run in runs), statistics.median(run.scores[metric].top_k for run in runs), all(run.scores[metric].constant for run in runs)) for metric in METRICS}
|
||||
|
||||
|
||||
def resolved(places: list[Place], tracked: list[str]) -> tuple[list[Place], list[Place]]:
|
||||
"""Entries written before paths were written from the repository's root shorten a path once they have named its folder: `cycle/run.py` after `bin/loop_claude/cycle/states.py`. Each place resolves to the one tracked file it names, or, where several match, the one in the folder of the place resolved before it; a place naming no file, or several, is dropped. Returns the resolved places and the dropped ones."""
|
||||
found = []
|
||||
dropped = []
|
||||
before = ""
|
||||
for place in places:
|
||||
candidates = [place.path] if place.path in tracked else [path for path in tracked if path.endswith("/" + place.path)]
|
||||
nearest = [path for path in candidates if path.startswith(os.path.dirname(before) + "/")] if len(candidates) > 1 else candidates
|
||||
if len(nearest) == 1:
|
||||
before = nearest[0]
|
||||
found.append(Place(before, place.name))
|
||||
else:
|
||||
dropped.append(place)
|
||||
return found, dropped
|
||||
@@ -0,0 +1,153 @@
|
||||
"""Bench cheap static metrics against the places a project's comprehension panel named as hardest.
|
||||
|
||||
usage: metric-bench [history]
|
||||
|
||||
history defaults to docs/comprehension-history.md in the checkout it runs in, and the bench reads
|
||||
the checkout that holds the history. For each scoring run in it, at the commit the panel read, it
|
||||
measures each module-level function and each method of a module-level class in the Python files git
|
||||
tracks, leaving out test_*.py, *_test.py and anything under a tests/ folder:
|
||||
|
||||
- cognitive complexity: SonarSource's white paper, read for Python;
|
||||
- length: lines;
|
||||
- shared state: attributes on self that another method of the class also writes, plus names
|
||||
declared global or nonlocal;
|
||||
- change spread: how many other files changed in a commit with the unit's file, up to that commit,
|
||||
leaving out commits of more than 30 files.
|
||||
|
||||
It then prints, for each metric, how well it ranks the units the panel named above the rest: AUC
|
||||
(0.5 is a coin toss, 1.0 a perfect ranking) and top k (the share of the metric's k highest units
|
||||
the panel named, k being how many it named; Chance is what top k scores at random). A metric that
|
||||
gave every unit one value reads "constant". A last row gives the medians. Unmeasured counts the
|
||||
distinct places that name no Python function or method, such as a section of a markdown file, or no
|
||||
single tracked file.
|
||||
|
||||
Below the table it names:
|
||||
- each run it skipped because its commit is not in the checkout;
|
||||
- each run it could not score because its places name no measured unit, or every one;
|
||||
- each file left out of its run because it does not parse on this Python.
|
||||
|
||||
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, the history
|
||||
cannot be read, or no scoring run could be scored.
|
||||
"""
|
||||
import pathlib
|
||||
import statistics
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from metric_bench.bench import bench, co_changed, medians, METRICS, resolved, RunScores, Score
|
||||
from larv_review.history import entries, Entry
|
||||
from failure import Failure
|
||||
from metric_bench.python_units import measured, python_units, Unit
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
if argv in (["-h"], ["--help"]):
|
||||
print(__doc__.strip())
|
||||
return 0
|
||||
if len(argv) > 1 or argv[:1] and argv[0].startswith("-"):
|
||||
print(f"unknown arguments {' '.join(argv)}; usage: metric-bench [history]", file=sys.stderr)
|
||||
return 1
|
||||
read = read_history(pathlib.Path(argv[0]).resolve() if argv else None)
|
||||
if isinstance(read, Failure):
|
||||
return failed(read)
|
||||
top, history, text = read
|
||||
benched = bench_runs(text, top)
|
||||
if isinstance(benched, Failure):
|
||||
return failed(benched)
|
||||
rows, notes = benched
|
||||
if not rows:
|
||||
return failed(Failure(f"no scoring run in {history} could be scored; its format is what ~/.claude/bin/larv-review writes{noted(notes)}"))
|
||||
print(table(rows) + noted(notes))
|
||||
return 0
|
||||
|
||||
|
||||
def read_history(given: pathlib.Path | None) -> tuple[str, pathlib.Path, str] | Failure:
|
||||
"""The checkout that holds the history, the history's path and its text."""
|
||||
if given and not given.parent.is_dir():
|
||||
return Failure(f"could not read {given}: no folder {given.parent}")
|
||||
found = git(["rev-parse", "--show-toplevel"], str(given.parent) if given else None)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
history = given or pathlib.Path(found.strip(), "docs", "comprehension-history.md")
|
||||
if not given and not history.exists():
|
||||
return Failure(f"no comprehension history at {history}; larv-review writes one at a project's first paired ruling or scoring run")
|
||||
try:
|
||||
return found.strip(), history, history.read_text(encoding="utf-8")
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read {history}: {failure}")
|
||||
|
||||
|
||||
def bench_runs(text: str, top: str) -> tuple[list[tuple[str, RunScores]], list[str]] | Failure:
|
||||
"""Each scored run's heading and scores, and a note for each run skipped or not scored and each file left out."""
|
||||
rows = []
|
||||
notes = []
|
||||
for run in [entry for entry in entries(text) if not entry.paired]:
|
||||
if isinstance(missing := git(["cat-file", "-e", f"{run.commit}^{{commit}}"], top), Failure):
|
||||
notes.append(f"Skipped, its commit is not in {top}: {run.heading} ({missing.reason})")
|
||||
continue
|
||||
scored = run_scores(run, top)
|
||||
if isinstance(scored, Failure):
|
||||
return scored
|
||||
scores, unparsed = scored
|
||||
notes += [f"Left out of {run.heading}: {reason}" for reason in unparsed]
|
||||
if scores:
|
||||
rows.append((run.heading, scores))
|
||||
else:
|
||||
notes.append(f"Not scored, its places name no measured unit or every one: {run.heading}")
|
||||
return rows, notes
|
||||
|
||||
|
||||
def noted(notes: list[str]) -> str:
|
||||
return "\n\n" + "\n".join(notes) if notes else ""
|
||||
|
||||
|
||||
def run_scores(run: Entry, top: str) -> tuple[RunScores | None, list[str]] | Failure:
|
||||
"""The run's scores, and why each file that does not parse was left out."""
|
||||
listed = git(["ls-tree", "-r", "-z", "--name-only", run.commit], top)
|
||||
if isinstance(listed, Failure):
|
||||
return listed
|
||||
tracked = list(filter(None, listed.split("\0")))
|
||||
units: list[Unit] = []
|
||||
unparsed = []
|
||||
for path in filter(measured, tracked):
|
||||
source = git(["show", f"{run.commit}:{path}"], top)
|
||||
if isinstance(source, Failure):
|
||||
return source
|
||||
found = python_units(path, source)
|
||||
if isinstance(found, Failure):
|
||||
unparsed.append(found.reason)
|
||||
else:
|
||||
units += found
|
||||
log = git(["-c", "core.quotePath=false", "log", "--no-merges", "--format=tformat:@@", "--name-only", run.commit], top)
|
||||
if isinstance(log, Failure):
|
||||
return log
|
||||
places, dropped = resolved(run.places, tracked)
|
||||
return bench(units, places, len(set(dropped)), co_changed(log)), unparsed
|
||||
|
||||
|
||||
def table(rows: list[tuple[str, RunScores]]) -> str:
|
||||
head = ["Scoring run", "Units", "Named", "Unmeasured", "Chance", *METRICS]
|
||||
lines = ["| " + " | ".join(head) + " |", "|" + "---|" * len(head)]
|
||||
for heading, run in rows:
|
||||
lines.append("| " + " | ".join([heading, str(run.units), str(run.named), str(run.unmeasured), f"top k {run.named / run.units:.2f}", *(cell(run.scores[metric]) for metric in METRICS)]) + " |")
|
||||
medianed = medians([run for _, run in rows])
|
||||
chance = statistics.median(run.named / run.units for _, run in rows)
|
||||
lines.append("| " + " | ".join(["Median", "", "", "", f"top k {chance:.2f}", *(cell(medianed[metric]) for metric in METRICS)]) + " |")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def cell(score: Score) -> str:
|
||||
return "constant" if score.constant else f"AUC {score.auc:.2f}, top k {score.top_k:.2f}"
|
||||
|
||||
|
||||
def git(args: list[str], cwd: str | None) -> str | Failure:
|
||||
try:
|
||||
ran = subprocess.run(["git", *args], capture_output=True, cwd=cwd, encoding="utf-8", errors="replace")
|
||||
except OSError as failure:
|
||||
return Failure(f"could not start git: {failure.strerror}")
|
||||
return ran.stdout if ran.returncode == 0 else Failure(f"git {' '.join(args)}: {ran.stderr.strip()}")
|
||||
|
||||
|
||||
def failed(failure: Failure) -> int:
|
||||
print(failure.reason, file=sys.stderr)
|
||||
return 1
|
||||
@@ -0,0 +1,127 @@
|
||||
import ast
|
||||
import collections
|
||||
import dataclasses
|
||||
import sys
|
||||
|
||||
from failure import Failure
|
||||
|
||||
FUNCTION = (ast.FunctionDef, ast.AsyncFunctionDef)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Unit:
|
||||
path: str
|
||||
name: str
|
||||
cognitive: int
|
||||
length: int
|
||||
shared_state: int
|
||||
|
||||
|
||||
def measured(path: str) -> bool:
|
||||
"""A Python file outside the tests."""
|
||||
folders, _, name = path.rpartition("/")
|
||||
return name.endswith(".py") and not name.startswith("test_") and not name.endswith("_test.py") and "tests" not in folders.split("/")
|
||||
|
||||
|
||||
def python_units(path: str, source: str) -> list[Unit] | Failure:
|
||||
"""Each module-level function and each method of a module-level class in source, with its metrics."""
|
||||
try:
|
||||
tree = ast.parse(source)
|
||||
except (SyntaxError, ValueError) as failure:
|
||||
return Failure(f"{path} does not parse on Python {sys.version_info[0]}.{sys.version_info[1]}: {failure}")
|
||||
units = []
|
||||
for node in tree.body:
|
||||
if isinstance(node, FUNCTION):
|
||||
units.append(unit(path, node, 0))
|
||||
elif isinstance(node, ast.ClassDef):
|
||||
shared = shared_writes(node)
|
||||
units += [unit(path, method, shared[method.name]) for method in node.body if isinstance(method, FUNCTION)]
|
||||
return units
|
||||
|
||||
|
||||
def unit(path: str, node: ast.FunctionDef | ast.AsyncFunctionDef, shared: int) -> Unit:
|
||||
globals_written = sum(len(statement.names) for statement in ast.walk(node) if isinstance(statement, ast.Global | ast.Nonlocal))
|
||||
return Unit(path, node.name, cognitive(node), (node.end_lineno or node.lineno) - node.lineno + 1, shared + globals_written)
|
||||
|
||||
|
||||
def shared_writes(cls: ast.ClassDef) -> collections.Counter[str]:
|
||||
"""For each method, how many of the attributes it writes on self another method of the class writes too."""
|
||||
writers = collections.defaultdict(set)
|
||||
for method in cls.body:
|
||||
if isinstance(method, FUNCTION):
|
||||
for node in ast.walk(method):
|
||||
for target in written(node):
|
||||
if isinstance(target, ast.Attribute) and isinstance(target.value, ast.Name) and target.value.id == "self":
|
||||
writers[target.attr].add(method.name)
|
||||
return collections.Counter(method for methods in writers.values() if len(methods) > 1 for method in methods)
|
||||
|
||||
|
||||
def written(node: ast.AST) -> list[ast.expr]:
|
||||
if isinstance(node, ast.Assign):
|
||||
targets = node.targets
|
||||
elif isinstance(node, ast.AugAssign | ast.AnnAssign | ast.For | ast.AsyncFor | ast.comprehension):
|
||||
targets = [node.target]
|
||||
elif isinstance(node, ast.withitem) and node.optional_vars:
|
||||
targets = [node.optional_vars]
|
||||
else:
|
||||
return []
|
||||
return [leaf for target in targets for leaf in assigned(target)]
|
||||
|
||||
|
||||
def assigned(target: ast.expr) -> list[ast.expr]:
|
||||
"""What a target writes: each part of an unpacking, and for `x[i] = …` the x."""
|
||||
if isinstance(target, ast.Tuple | ast.List):
|
||||
return [leaf for element in target.elts for leaf in assigned(element)]
|
||||
if isinstance(target, ast.Starred | ast.Subscript):
|
||||
return assigned(target.value)
|
||||
return [target]
|
||||
|
||||
|
||||
# SonarSource's "Cognitive Complexity" white paper (G. Ann Campbell, 2017), read for Python: a comprehension counts as a loop and each of its `if` clauses as a condition.
|
||||
def cognitive(function: ast.FunctionDef | ast.AsyncFunctionDef) -> int:
|
||||
return inside(function.body, 0, function.name)
|
||||
|
||||
|
||||
# One case per node type, as the white paper gives one rule per structure.
|
||||
def score(node: ast.AST, nesting: int, name: str) -> int:
|
||||
"""The cognitive complexity `node` adds, its children included, at nesting depth `nesting`; a call to `name`, the function's own, counts as recursion."""
|
||||
if isinstance(node, ast.If):
|
||||
return 1 + nesting + branches(node, nesting, name)
|
||||
if isinstance(node, ast.For | ast.AsyncFor | ast.While):
|
||||
head = node.test if isinstance(node, ast.While) else node.iter
|
||||
return 1 + nesting + score(head, nesting, name) + inside(node.body, nesting + 1, name) + (1 + inside(node.orelse, nesting + 1, name) if node.orelse else 0)
|
||||
if isinstance(node, ast.Try | ast.TryStar):
|
||||
handlers = sum(1 + nesting + inside(handler.body, nesting + 1, name) for handler in node.handlers)
|
||||
return inside(node.body + node.orelse + node.finalbody, nesting, name) + handlers
|
||||
if isinstance(node, ast.Match):
|
||||
return 1 + nesting + score(node.subject, nesting, name) + sum(inside(case.body, nesting + 1, name) for case in node.cases)
|
||||
if isinstance(node, ast.IfExp):
|
||||
return 1 + nesting + inside([node.test, node.body, node.orelse], nesting + 1, name)
|
||||
if isinstance(node, ast.ListComp | ast.SetComp | ast.DictComp | ast.GeneratorExp):
|
||||
return sum(1 + nesting + len(generator.ifs) for generator in node.generators) + inside(list(ast.iter_child_nodes(node)), nesting + 1, name)
|
||||
if isinstance(node, ast.FunctionDef | ast.AsyncFunctionDef | ast.Lambda):
|
||||
return inside(node.body if isinstance(node.body, list) else [node.body], nesting + 1, name)
|
||||
return (isinstance(node, ast.BoolOp) or called(node) == name) + inside(list(ast.iter_child_nodes(node)), nesting, name)
|
||||
|
||||
|
||||
def called(node: ast.AST) -> str | None:
|
||||
"""The function a call names, or the method it calls on self."""
|
||||
if not isinstance(node, ast.Call):
|
||||
return None
|
||||
if isinstance(node.func, ast.Name):
|
||||
return node.func.id
|
||||
if isinstance(node.func, ast.Attribute) and isinstance(node.func.value, ast.Name) and node.func.value.id == "self":
|
||||
return node.func.attr
|
||||
return None
|
||||
|
||||
|
||||
def inside(nodes: list, nesting: int, name: str) -> int:
|
||||
return sum(score(node, nesting, name) for node in nodes)
|
||||
|
||||
|
||||
def branches(node: ast.If, nesting: int, name: str) -> int:
|
||||
"""An if's test and bodies; an elif or else adds 1 at no extra depth."""
|
||||
total = score(node.test, nesting, name) + inside(node.body, nesting + 1, name)
|
||||
if len(node.orelse) == 1 and isinstance(node.orelse[0], ast.If):
|
||||
return total + 1 + branches(node.orelse[0], nesting, name)
|
||||
return total + (1 + inside(node.orelse, nesting + 1, name) if node.orelse else 0)
|
||||
+10
-2
@@ -375,6 +375,16 @@ def cells(row: str, count: int) -> list[str] | Failure:
|
||||
|
||||
|
||||
def parse_item(row: str, weights: dict[str, float]) -> Item | Failure:
|
||||
item = parse_row(row)
|
||||
if isinstance(item, Failure):
|
||||
return item
|
||||
if unknown := [goal for goal in item.goals if goal not in weights]:
|
||||
return Failure(f"item {item.id} cites goal {', '.join(unknown)}, which the goal weights do not list")
|
||||
return item
|
||||
|
||||
|
||||
def parse_row(row: str) -> Item | Failure:
|
||||
"""An item row, every cell checked but the goals it cites."""
|
||||
found = cells(row, 10)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
@@ -393,8 +403,6 @@ def parse_item(row: str, weights: dict[str, float]) -> Item | Failure:
|
||||
return Failure(f"item {id_}'s {name} {value!r} is not a whole number from 1 to 10")
|
||||
scores[name] = int(value)
|
||||
cited = tuple(goal.strip() for goal in goals.split(","))
|
||||
if unknown := [goal for goal in cited if goal not in weights]:
|
||||
return Failure(f"item {id_} cites goal {', '.join(unknown)}, which the goal weights do not list")
|
||||
major, minor, patch = (int(part) for part in release.split("."))
|
||||
return Item(int(id_), (major, minor, patch), exempt, tagline, scores, cited)
|
||||
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from reading_cost import main
|
||||
|
||||
sys.exit(main.main(sys.argv[1:]))
|
||||
@@ -0,0 +1,20 @@
|
||||
import pathlib
|
||||
import typing
|
||||
|
||||
from failure import Failure
|
||||
from loop_claude.transcript_archive import FinishedChunk
|
||||
from loop_claude.paths import paths_from
|
||||
from loop_claude.project.checkout import project_key
|
||||
|
||||
|
||||
def project_archive(checkout_root: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> pathlib.Path:
|
||||
paths = paths_from(home, env)
|
||||
return paths.transcript_archive / project_key(checkout_root, paths.code)
|
||||
|
||||
|
||||
def read_threads(chunk: FinishedChunk) -> list[bytes] | Failure:
|
||||
"""The worker's transcript, then each subagent's."""
|
||||
try:
|
||||
return [path.read_bytes() for path in (chunk.transcript, *chunk.subagents)]
|
||||
except OSError as failure:
|
||||
return Failure(f"could not read {failure.filename}: {failure.strerror}")
|
||||
@@ -0,0 +1,71 @@
|
||||
import collections
|
||||
import re
|
||||
import statistics
|
||||
|
||||
from failure import Failure
|
||||
from loop_claude.transcript_archive import FinishedChunk, STAMPED
|
||||
from reading_cost.measure import Reading
|
||||
from markdown_sections import sections
|
||||
|
||||
FIGURE = re.compile(rf"^Reading cost, chunk (\w+), finished ({STAMPED})$")
|
||||
PLACE = re.compile(r"^- `(.+)` (\d+)$")
|
||||
PLACES_KEPT = 10
|
||||
RESET = "Reading cost reset, "
|
||||
RESET_AT = re.compile(rf"^{RESET}({STAMPED})$")
|
||||
TOKENS = re.compile(r"^(\d+) new input tokens before the first commit\.$")
|
||||
WINDOW = 5
|
||||
|
||||
|
||||
def unheld(chunks: list[FinishedChunk], record: str) -> list[FinishedChunk]:
|
||||
held = {match.group(1) for heading in sections(record) if (match := FIGURE.match(heading))}
|
||||
return [chunk for chunk in chunks if chunk_id(chunk) not in held]
|
||||
|
||||
|
||||
def chunk_id(chunk: FinishedChunk) -> str:
|
||||
return chunk.folder[:12]
|
||||
|
||||
|
||||
def figure(chunk: FinishedChunk, reading: Reading) -> str:
|
||||
places = "".join(f"- `{path}` {times}\n" for path, times in ranked(reading.places))
|
||||
return f"## Reading cost, chunk {chunk_id(chunk)}, finished {chunk.finished}\n\n{reading.tokens} new input tokens before the first commit.\n" + (f"\nRead most (opens and searches):\n\n{places}" if places else "")
|
||||
|
||||
|
||||
# The figures after the last reset, in the order their chunks finished: each machine appends its own archive's chunks.
|
||||
def readings_of(record: str) -> list[Reading] | Failure:
|
||||
dated = []
|
||||
resets = [""]
|
||||
for heading, bodies in sections(record).items():
|
||||
if reset := RESET_AT.match(heading):
|
||||
resets.append(reset.group(1))
|
||||
elif named := FIGURE.match(heading):
|
||||
lines = bodies[0].splitlines() if bodies else []
|
||||
tokens = [int(match.group(1)) for line in lines if (match := TOKENS.match(line))]
|
||||
if len(tokens) != 1:
|
||||
return Failure(f"the figure under \"## {heading}\" holds no single tokens line; restore it from git history")
|
||||
dated.append((named.group(2), heading, Reading(tokens[0], collections.Counter({match.group(1): int(match.group(2)) for line in lines if (match := PLACE.match(line))}))))
|
||||
elif heading.startswith("Reading cost"):
|
||||
return Failure(f"\"## {heading}\" names no chunk and UTC time, or no reset time; restore it from git history")
|
||||
return [reading for finished, _, reading in sorted(dated, key=lambda item: item[:2]) if finished > max(resets)]
|
||||
|
||||
|
||||
def ranked(places: collections.Counter[str]) -> list[tuple[str, int]]:
|
||||
return sorted(places.items(), key=lambda item: (-item[1], item[0]))[:PLACES_KEPT]
|
||||
|
||||
|
||||
def merged(record: str, figures: list[str]) -> str:
|
||||
return record.rstrip("\n") + "\n\n" + "\n".join(figures)
|
||||
|
||||
|
||||
def trend(readings: list[Reading]) -> str:
|
||||
if len(readings) < 2 * WINDOW:
|
||||
return f"{len(readings)} chunks measured since the last reset; the trend needs {2 * WINDOW}."
|
||||
last, earlier = median_tokens(readings[-WINDOW:]), median_tokens(readings[-2 * WINDOW:-WINDOW])
|
||||
medians = f"the last {WINDOW} chunks' median is {last} new input tokens before their first commit, the {WINDOW} before them {earlier}."
|
||||
if last <= earlier:
|
||||
return f"Not rising: {medians}"
|
||||
read_most = "".join(f"\n- `{path}` {times}" for path, times in ranked(sum((reading.places for reading in readings[-WINDOW:]), collections.Counter())))
|
||||
return f"Rising: {medians}\n\nRead most over the last {WINDOW} (opens and searches):\n{read_most}"
|
||||
|
||||
|
||||
def median_tokens(readings: list[Reading]) -> int:
|
||||
return round(statistics.median(reading.tokens for reading in readings))
|
||||
@@ -0,0 +1,132 @@
|
||||
"""Measure each chunk loop-claude finished, append the figures to a project's record, and say whether they rise.
|
||||
|
||||
usage: reading-cost [--reset] [record]
|
||||
|
||||
Run it inside a project checkout or one of its worktrees. record defaults to docs/reading-cost.md
|
||||
there, created when missing. It reads loop-claude's archive of the project,
|
||||
$LOOP_CLAUDE_TRANSCRIPTS/<key> (default ~/.claude/loop-claude-transcripts), <key> being the
|
||||
checkout's path relative to ~/code, or to / outside it. For each finished chunk the record does not
|
||||
yet hold, it measures what the worker and its subagents read before the worker's first commit: their
|
||||
new input tokens (uncached and cache-written; cache reads excluded), and how often they opened or
|
||||
searched each file git tracks in the checkout. A chunk whose worker never committed is not measured.
|
||||
Each figure is appended under a "## Reading cost, chunk <id>, finished <UTC time>" heading, in the
|
||||
order the chunks finished.
|
||||
|
||||
--reset also appends a "## Reading cost reset, <UTC time>" heading: the trend then counts only
|
||||
figures of chunks that finished after it.
|
||||
|
||||
It then compares the median tokens of the record's last 5 figures with the 5 before them, in the
|
||||
order their chunks finished, and prints "Rising:" or "Not rising:" with both medians. Rising, it
|
||||
lists the files the last 5 chunks read most. With fewer than 10 figures, it says so.
|
||||
|
||||
Exit 1, saying why, on unknown arguments, or when git cannot start or finds no checkout, the
|
||||
archive or the record cannot be read or written, or a figure in the record cannot be read back.
|
||||
"""
|
||||
import dataclasses
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
from reading_cost.measure import Checkout, measure, Reading
|
||||
from failure import Failure
|
||||
from reading_cost.figures import figure, merged, readings_of, RESET, trend, unheld
|
||||
from loop_claude.transcript_archive import finished_chunks, utc
|
||||
from reading_cost.archive import project_archive, read_threads
|
||||
from file_writes import replace_file
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Updated:
|
||||
appended: int
|
||||
readings: list[Reading]
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
reset = argv[:1] == ["--reset"]
|
||||
given = argv[1:] if reset else argv
|
||||
if given in (["-h"], ["--help"]):
|
||||
print(__doc__.strip())
|
||||
return 0
|
||||
if len(given) > 1 or given[:1] and given[0].startswith("-"):
|
||||
print(f"unknown arguments {' '.join(given)}; usage: reading-cost [--reset] [record]", file=sys.stderr)
|
||||
return 1
|
||||
checkout = located()
|
||||
if isinstance(checkout, Failure):
|
||||
return failed(checkout)
|
||||
home = pathlib.Path.home()
|
||||
archive = project_archive(checkout.root, home, os.environ)
|
||||
record = pathlib.Path(given[0]) if given else pathlib.Path(checkout.top, "docs", "reading-cost.md")
|
||||
updated = update(record, archive, checkout, str(home), utc(time.time()) if reset else None)
|
||||
if isinstance(updated, Failure):
|
||||
return failed(updated)
|
||||
print(f"Appended {updated.appended} reading-cost figure{'' if updated.appended == 1 else 's'} from {archive}{' and a reset' if reset else ''} to {record}.")
|
||||
print(trend(updated.readings))
|
||||
return 0
|
||||
|
||||
|
||||
def update(record: pathlib.Path, archive: pathlib.Path, checkout: Checkout, home: str, reset_at: str | None) -> Updated | Failure:
|
||||
text = read_record(record)
|
||||
if isinstance(text, Failure):
|
||||
return text
|
||||
figures = new_figures(text, archive, checkout, home)
|
||||
if isinstance(figures, Failure):
|
||||
return figures
|
||||
marks = [*figures, f"## {RESET}{reset_at}\n"] if reset_at else figures
|
||||
text = merged(text, marks) if marks else text
|
||||
readings = readings_of(text)
|
||||
if isinstance(readings, Failure):
|
||||
return readings
|
||||
if marks and (unwritten := write_record(record, text)):
|
||||
return unwritten
|
||||
return Updated(len(figures), readings)
|
||||
|
||||
|
||||
def new_figures(record: str, archive: pathlib.Path, checkout: Checkout, home: str) -> list[str] | Failure:
|
||||
chunks = finished_chunks(archive)
|
||||
if isinstance(chunks, Failure):
|
||||
return chunks
|
||||
figures = []
|
||||
for chunk in unheld(chunks, record):
|
||||
threads = read_threads(chunk)
|
||||
if isinstance(threads, Failure):
|
||||
return threads
|
||||
if reading := measure(threads, checkout, home):
|
||||
figures.append(figure(chunk, reading))
|
||||
return figures
|
||||
|
||||
|
||||
def write_record(record: pathlib.Path, text: str) -> Failure | None:
|
||||
try:
|
||||
record.parent.mkdir(parents=True, exist_ok=True)
|
||||
except OSError as failure:
|
||||
return Failure(f"could not write {record}: {failure.strerror}")
|
||||
unwritten = replace_file(record, text.encode())
|
||||
return Failure(f"could not write {record}: {unwritten.reason}") if unwritten else None
|
||||
|
||||
|
||||
def failed(failure: Failure) -> int:
|
||||
print(failure.reason, file=sys.stderr)
|
||||
return 1
|
||||
|
||||
|
||||
def located() -> Checkout | Failure:
|
||||
try:
|
||||
found = subprocess.run(["git", "rev-parse", "--path-format=absolute", "--show-toplevel", "--git-common-dir"], capture_output=True, text=True)
|
||||
if found.returncode != 0:
|
||||
return Failure(found.stderr.strip())
|
||||
top, common = found.stdout.splitlines()
|
||||
listed = subprocess.run(["git", "ls-files", "-z"], capture_output=True, cwd=top, text=True)
|
||||
except (OSError, ValueError) as failure:
|
||||
return Failure(f"could not find the checkout: {failure}")
|
||||
if listed.returncode != 0:
|
||||
return Failure(listed.stderr.strip())
|
||||
# The common dir is the checkout's .git, whichever worktree runs this.
|
||||
return Checkout(str(pathlib.Path(common).parent), top, frozenset(filter(None, listed.stdout.split("\0"))))
|
||||
|
||||
|
||||
def read_record(record: pathlib.Path) -> str | Failure:
|
||||
try:
|
||||
return record.read_text(encoding="utf-8") if record.exists() else "# Reading cost\n"
|
||||
except (OSError, UnicodeDecodeError) as failure:
|
||||
return Failure(f"could not read {record}: {failure}")
|
||||
@@ -0,0 +1,80 @@
|
||||
import collections
|
||||
import dataclasses
|
||||
import re
|
||||
|
||||
from loop_claude.claude_code.entries import assistant_parts, parse_entry, tool_call
|
||||
from reading_cost.shell_reads import Reads, resolved, shell_reads
|
||||
|
||||
COMMIT = re.compile(r"(^|[\s;&|(])git\s+(-C\s+\S+\s+)?commit\b")
|
||||
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Reading:
|
||||
"""What the worker and its subagents took in before the worker's first commit."""
|
||||
tokens: int
|
||||
places: collections.Counter[str]
|
||||
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Checkout:
|
||||
root: str
|
||||
top: str
|
||||
tracked: frozenset[str]
|
||||
|
||||
|
||||
def measure(threads: list[bytes], checkout: Checkout, home: str) -> Reading | None:
|
||||
worker, *subagents = [entries_of(thread) for thread in threads]
|
||||
commit = commit_time(worker)
|
||||
if commit is None:
|
||||
return None
|
||||
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]:
|
||||
return [entry for line in raw.splitlines() if (entry := parse_entry(line))]
|
||||
|
||||
|
||||
def commit_time(worker: list[dict]) -> str | None:
|
||||
for entry in worker:
|
||||
for part in assistant_parts(entry):
|
||||
name, arguments = call_of(part)
|
||||
if name == "Bash" and COMMIT.search(str(arguments.get("command", ""))):
|
||||
return str(entry.get("timestamp", ""))
|
||||
return None
|
||||
|
||||
|
||||
def tokens_in(entries: list[dict]) -> int:
|
||||
# Claude Code writes one entry per content block of a message, each with the message's usage.
|
||||
usages = {str(message.get("id") or entry.get("uuid")): message.get("usage") for entry in entries if isinstance(message := entry.get("message"), dict)}
|
||||
return sum(count(usage, "input_tokens") + count(usage, "cache_creation_input_tokens") for usage in usages.values() if isinstance(usage, dict))
|
||||
|
||||
|
||||
# A count Claude Code left out or wrote as another type adds nothing, so one odd entry leaves the rest of the figure standing.
|
||||
def count(usage: dict, field: str) -> int:
|
||||
value = usage.get(field)
|
||||
return value if isinstance(value, int) else 0
|
||||
|
||||
|
||||
def call_of(part: object) -> tuple[object, dict]:
|
||||
call = tool_call(part)
|
||||
return (call[0], call[1]) if call and isinstance(call[1], dict) else (None, {})
|
||||
|
||||
|
||||
def reads_of(part: object, cwd: str, home: str) -> Reads:
|
||||
name, arguments = call_of(part)
|
||||
path = arguments.get("file_path") if name == "Read" else arguments.get("path") if name == "Grep" else None
|
||||
if path:
|
||||
return Reads([resolved(cwd, str(path), home)], [])
|
||||
return shell_reads(str(arguments.get("command", "")), cwd, home) if name == "Bash" else Reads([], [])
|
||||
|
||||
|
||||
# Relative to the deepest root holding it, so the checkout and each worktree name a file alike.
|
||||
def relative(path: str, roots: list[str]) -> str | None:
|
||||
holding = [root for root in roots if path.startswith(root.rstrip("/") + "/")]
|
||||
return path[len(max(holding, key=len).rstrip("/")) + 1:] if holding else None
|
||||
@@ -0,0 +1,91 @@
|
||||
"""The files a shell command reads, and the worktrees it adds, as absolute paths."""
|
||||
import dataclasses
|
||||
import posixpath
|
||||
import re
|
||||
import shlex
|
||||
import typing
|
||||
|
||||
NOT_A_PATH = re.compile(r"[*?\[\]{}$\\'\",=()<>|;&]|://|^\d+$")
|
||||
# Their first operand is a pattern or a program, unless -e or -f gives it.
|
||||
PATTERN_FIRST = {"awk", "egrep", "grep", "rg", "sed"}
|
||||
READERS = {"awk", "bat", "cat", "egrep", "grep", "head", "less", "more", "nl", "rg", "sed", "tail", "wc"}
|
||||
WORKTREE_OPTIONS_WITH_VALUE = {"-b", "-B", "--reason"}
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Reads:
|
||||
read: list[str]
|
||||
added: list[str]
|
||||
|
||||
|
||||
def shell_reads(command: str, cwd: str, home: str) -> 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)
|
||||
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]]:
|
||||
"""Each line's tokens, skipping a heredoc's body, which feeds a program."""
|
||||
ends = None
|
||||
for line in command.splitlines():
|
||||
if ends is not None:
|
||||
ends = None if line.strip() == ends else ends
|
||||
continue
|
||||
try:
|
||||
lexer = shlex.shlex(line, posix=True, punctuation_chars=True)
|
||||
lexer.whitespace_split = True
|
||||
tokens = list(lexer)
|
||||
except ValueError:
|
||||
continue
|
||||
# The lexer splits <<-EOF into << and -EOF.
|
||||
ends = next((tokens[index + 1].removeprefix("-") for index, token in enumerate(tokens[:-1]) if token == "<<"), None)
|
||||
yield tokens
|
||||
|
||||
|
||||
def segments(tokens: list[str]) -> list[list[str]]:
|
||||
found: list[list[str]] = [[]]
|
||||
target = False
|
||||
for token in tokens:
|
||||
if target:
|
||||
target = False
|
||||
elif all(char in "();<>|&" for char in token):
|
||||
# A redirect's target is not an operand, so it does not count as a read.
|
||||
target = "<" in token or ">" in token
|
||||
found.append([])
|
||||
else:
|
||||
found[-1].append(token)
|
||||
return [words for words in found if words]
|
||||
|
||||
|
||||
def operands(words: list[str]) -> list[str]:
|
||||
program = posixpath.basename(words[0])
|
||||
if program not in READERS or (program == "sed" and any(word.startswith("-i") for word in words)):
|
||||
return []
|
||||
given = [word for word in words[1:] if not word.startswith("-")]
|
||||
if program in PATTERN_FIRST and not {"-e", "-f"} & set(words):
|
||||
given = given[1:]
|
||||
return [word for word in given if ("/" in word or re.search(r"\.[A-Za-z0-9]+$", word)) and not NOT_A_PATH.search(word)]
|
||||
|
||||
|
||||
# git worktree add [-b <branch>] <path> [<commit>]
|
||||
def worktree_added(words: list[str]) -> list[str]:
|
||||
if words[:1] != ["git"] or "worktree" not in words or words[words.index("worktree") + 1:][:1] != ["add"]:
|
||||
return []
|
||||
after = iter(words[words.index("worktree") + 2:])
|
||||
for word in after:
|
||||
if word in WORKTREE_OPTIONS_WITH_VALUE:
|
||||
next(after, None)
|
||||
elif not word.startswith("-"):
|
||||
return [word]
|
||||
return []
|
||||
|
||||
|
||||
def resolved(base: str, path: str, home: str) -> str:
|
||||
return posixpath.normpath(posixpath.join(base, home + path[1:] if path == "~" or path.startswith("~/") else path))
|
||||
@@ -8,7 +8,7 @@ CITATION = re.compile(r'`?CLAUDE\.md`? → ("[^"]+"(?:,? (?:and )?"[^"]+")*)')
|
||||
HEADING = re.compile(r"^#+ (.+?)(?: \(.*\))?$", re.MULTILINE)
|
||||
LEAD = re.compile(r"^(?:- )?\*\*(.+?)(?:\*\*|[:.](?=\*\*| )| —)", re.MULTILINE)
|
||||
NAME = re.compile(r'"([^"]+)"')
|
||||
STRAY = re.compile(r'CLAUDE\.md(?!`? → ")[^\n"]{1,5}"')
|
||||
STRAY = re.compile(r'CLAUDE\.md(?!`? → "|:\d)[^\n"]{1,5}"')
|
||||
|
||||
|
||||
class Citations(unittest.TestCase):
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
import decimal
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from larv_review.history import appended, entries, HistoryChange, Place, ruling_entry
|
||||
from larv_review.rules import base, first_ruling, means, measured_commit, plan_items, round_counts, ruling, scoring_run_due, under_floor, votes
|
||||
from failure import Failure
|
||||
from test_loop_claude_black_box import host_env
|
||||
from rank_todo import Item
|
||||
from larv_review.seats import report, score_line, scores, Seat
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parent / "larv-review"
|
||||
SCORING = "## 2026-10-08T12:00:00Z, PR #1 at aaaaaaa\n\n| Seat | Overall |\n|---|---|\n| Mean | 7.00 |\n"
|
||||
|
||||
|
||||
def paired(time: str, verdict: str, commit: str = "bbbbbbb") -> str:
|
||||
return f"## {time}, PR #2 at {commit}, against aaaaaaa\n\nRuling: {verdict}\n"
|
||||
|
||||
|
||||
def item(id_: int, release: tuple[int, int, int], tagline: str = "**Do it.**") -> Item:
|
||||
return Item(id_, release, "", tagline, {"R": 1, "S": 1, "A": 1, "G": 1}, ("1",))
|
||||
|
||||
|
||||
def todo(*rows: str) -> str:
|
||||
return "## Items\n\n| ID | Release | Exempt | Item | R | S | A | G | Goals | Score |\n|---|---|---|---|---|---|---|---|---|---|\n" + "".join(f"{row}\n" for row in rows)
|
||||
|
||||
|
||||
class Seats(unittest.TestCase):
|
||||
def test_reads_each_seats_line_and_places_and_joins_a_wrapped_place(self):
|
||||
given = report("PR #2 at abc1234, against def5678\n\nMid A: worse\n\n- `a.py:1` `f`: hard\n to read\n\nInherited architect: same\n")
|
||||
self.assertEqual(given.read, "PR #2 at abc1234, against def5678")
|
||||
self.assertEqual(given.seats, [Seat("Mid A", "worse", ["`a.py:1` `f`: hard to read"]), Seat("Inherited architect", "same", [])])
|
||||
|
||||
def test_refuses_a_line_that_is_neither_a_seat_nor_a_place_and_a_seat_twice(self):
|
||||
self.assertIsInstance(report("PR #2 at abc1234\n\nMid A worse\n"), Failure)
|
||||
self.assertIsInstance(report("PR #2 at abc1234\n\nMid A: worse\n\nMid A: same\n"), Failure)
|
||||
self.assertIsInstance(report(""), Failure)
|
||||
|
||||
def test_counts_a_vote_naming_no_place_as_same(self):
|
||||
seats = [Seat("Mid A", "worse", ["the whole skill"]), Seat("Inherited architect", "better", ["`a.py:3` `f`: shorter"])]
|
||||
self.assertEqual(votes(seats), {"Mid A": "same", "Inherited architect": "better"})
|
||||
|
||||
def test_refuses_two_more_seats_once_the_first_two_agree(self):
|
||||
seats = [Seat(name, vote, ["`f.py:1` `f`: x"]) for name, vote in (("Mid A", "worse"), ("Inherited architect", "worse"), ("Maintainability senior", "better"), ("Junior A", "better"))]
|
||||
self.assertIsInstance(votes(seats), Failure)
|
||||
|
||||
def test_takes_the_first_two_seats_then_the_other_two_in_order(self):
|
||||
first = [Seat("Mid A", "same", []), Seat("Inherited architect", "same", [])]
|
||||
self.assertIsInstance(votes(first[::-1]), Failure)
|
||||
self.assertIsInstance(votes(first + [Seat("Junior A", "same", [])]), Failure)
|
||||
self.assertIsInstance(votes([first[0], Seat("Inherited architect", "worst", [])]), Failure)
|
||||
|
||||
def test_rules_by_a_lead_of_two_and_splits_two_seats_that_differ(self):
|
||||
cases = [
|
||||
(["worse", "worse"], "worse"),
|
||||
(["same", "same"], "same"),
|
||||
(["worse", "same"], None),
|
||||
(["worse", "better", "worse", "worse"], "worse"),
|
||||
(["worse", "same", "worse", "same"], "same"),
|
||||
(["worse", "same", "worse", "better"], "same"),
|
||||
(["better", "same", "better", "better"], "better"),
|
||||
]
|
||||
for counted, expected in cases:
|
||||
with self.subTest(counted):
|
||||
self.assertEqual(ruling(counted), expected)
|
||||
|
||||
def test_reads_four_seats_scores_and_refuses_an_overall_above_the_lowest_by_more_than_one(self):
|
||||
line = "Navigation 7, Locality 6.5, Shape 7, Self-sufficiency 6.5, Overall 7"
|
||||
seats = [Seat(name, line, []) for name in ("Junior A", "Mid A", "Maintainability senior", "Inherited architect")]
|
||||
self.assertEqual(scores(seats)["Mid A"], ["7", "6.5", "7", "6.5", "7"])
|
||||
self.assertIsInstance(scores(seats[:3]), Failure)
|
||||
self.assertIsInstance(scores([*seats[:3], Seat("Inherited architect", line.replace("Overall 7", "Overall 8"), [])]), Failure)
|
||||
self.assertIsInstance(scores([*seats[:3], Seat("Inherited architect", line.replace("Shape 7", "Shape 11"), [])]), Failure)
|
||||
self.assertEqual(score_line("Mean", "Navigation 7.38, Locality 7.38, Shape 8, Self-sufficiency 8, Overall 8.38")[-1], "8.38")
|
||||
|
||||
def test_rounds_each_mean_half_up_and_names_each_under_the_floor(self):
|
||||
found = means([["7.5", "6.5", "7", "7", "7"], ["7.5", "7", "7", "6.5", "7"], ["7", "6.5", "7", "6.5", "6.5"], ["7.5", "6.5", "7", "6.5", "7"]])
|
||||
self.assertEqual([str(mean) for mean in found], ["7.38", "6.63", "7.00", "6.63", "6.88"])
|
||||
self.assertEqual(under_floor(found), ["Locality 6.63", "Self-sufficiency 6.63", "Overall 6.88"])
|
||||
self.assertEqual(under_floor([decimal.Decimal("7.00")] * 5), [])
|
||||
|
||||
|
||||
class History(unittest.TestCase):
|
||||
def test_reads_back_what_it_writes(self):
|
||||
seats = [Seat("Mid A", "worse", ["`bin/a.py:3` `f`: hard, with `:9` `g`"]), Seat("Inherited architect", "worse", [])]
|
||||
ruled = ruling_entry("2026-10-08T18:37:21Z, PR #2 at bbbbbbb, against aaaaaaa", seats, {"Mid A": "worse", "Inherited architect": "same"}, "worse")
|
||||
history = appended(appended("", SCORING), ruled)
|
||||
self.assertTrue(history.startswith("# Comprehension history\n\n## 2026-10-08T12:00:00Z"))
|
||||
self.assertNotIn("Inherited architect, decided by:", history)
|
||||
self.assertIn("| Inherited architect | same (voted worse, naming no place) |", history)
|
||||
found = entries(history)
|
||||
self.assertEqual([(entry.commit, entry.against, entry.ruling) for entry in found], [("aaaaaaa", None, None), ("bbbbbbb", "aaaaaaa", "worse")])
|
||||
self.assertEqual(found[1].places, [Place("bin/a.py", "f"), Place("bin/a.py", "g")])
|
||||
self.assertEqual([entry.paired for entry in found], [False, True])
|
||||
|
||||
|
||||
class Base(unittest.TestCase):
|
||||
def test_takes_the_newest_change_adding_a_scoring_run_or_ending_on_a_better_ruling(self):
|
||||
older = HistoryChange("old", "", SCORING)
|
||||
same = HistoryChange("same", SCORING, SCORING + paired("2026-10-08T13:00:00Z", "same"))
|
||||
self.assertEqual(measured_commit([same, older]), "old")
|
||||
# The file holds the later ruling first, as a merge conflict resolved the other way would.
|
||||
better = HistoryChange("better", SCORING, SCORING + paired("2026-10-08T14:00:00Z", "better") + paired("2026-10-08T13:00:00Z", "worse"))
|
||||
self.assertEqual(measured_commit([better, older]), "better")
|
||||
worse_last = HistoryChange("worse", SCORING, SCORING + paired("2026-10-08T13:00:00Z", "better") + paired("2026-10-08T14:00:00Z", "worse"))
|
||||
self.assertEqual(measured_commit([worse_last, older]), "old")
|
||||
self.assertIsNone(measured_commit([same]))
|
||||
|
||||
def test_falls_back_to_the_first_rulings_base_then_to_none(self):
|
||||
ruled = paired("2026-10-08T13:00:00Z", "worse")
|
||||
self.assertEqual(base([HistoryChange("c", "", ruled)], ruled), ("aaaaaaa", "the base the history's first paired ruling names"))
|
||||
self.assertIsNone(base([], ""))
|
||||
self.assertEqual(base([HistoryChange("c", "", SCORING)], SCORING), ("c", "the last measured commit"))
|
||||
|
||||
def test_finds_the_earliest_ruling_by_its_time(self):
|
||||
ruled = first_ruling(paired("2026-10-08T14:00:00Z", "same", "ccccccc") + paired("2026-10-08T13:00:00Z", "worse"))
|
||||
self.assertEqual(ruled and ruled.commit, "bbbbbbb")
|
||||
self.assertIsNone(first_ruling(SCORING))
|
||||
|
||||
|
||||
class Rounds(unittest.TestCase):
|
||||
def test_counts_each_passs_highest_round(self):
|
||||
counts = round_counts(["Answer prose round 1: x", "Answer full scan round 2: y", "Answer full scan round 1: z", "Answer stability: no round", "Answer stabilty round 1: typo", "Answer security round 1: rename round 2: x", "Rescore: w"])
|
||||
self.assertEqual((counts["prose"], counts["full scan"], counts["stability"], counts["architecture"], counts["stabilty"], counts["security"]), (1, 2, 0, 0, 1, 1))
|
||||
|
||||
|
||||
class ScoringRunDue(unittest.TestCase):
|
||||
def test_reads_each_rows_id_release_and_tagline(self):
|
||||
self.assertEqual(plan_items(todo("| 3 | 0.1.0 | | **Do it.** | 1 | 1 | 1 | 1 | 1 | 9.0 |")), [item(3, (0, 1, 0))])
|
||||
self.assertIsInstance(plan_items("# todo\n"), Failure)
|
||||
self.assertIsInstance(plan_items(todo("| 0 | 0.1.0 | | **Do it.** | 1 | 1 | 1 | 1 | 1 | 9.0 |")), Failure)
|
||||
|
||||
def test_is_due_for_an_item_naming_the_floor(self):
|
||||
plan = [item(1, (0, 1, 0), "**Lift the project to the Comprehension floor.**"), item(2, (0, 1, 0))]
|
||||
self.assertEqual(scoring_run_due(plan, plan, [1], True), ["ships item 1, which names the comprehension floor"])
|
||||
self.assertIsInstance(scoring_run_due(plan, plan, [9], True), Failure)
|
||||
|
||||
def test_is_due_when_the_chunk_ships_a_releases_last_item(self):
|
||||
plan = [item(1, (0, 1, 0)), item(2, (0, 2, 0))]
|
||||
self.assertEqual(scoring_run_due(plan, plan, [1], False), ["leaves release 0.1.0 with no plan item"])
|
||||
self.assertEqual(scoring_run_due(plan, plan + [item(3, (0, 1, 0))], [1], True), [])
|
||||
|
||||
def test_is_due_when_the_chunk_removes_the_next_releases_last_item_after_work_landed(self):
|
||||
before = [item(1, (0, 1, 0)), item(2, (0, 1, 0)), item(3, (0, 2, 0))]
|
||||
after = [item(2, (0, 1, 0)), item(3, (0, 2, 0))]
|
||||
self.assertEqual(scoring_run_due(before, after, [2], True), ["leaves release 0.1.0 with no plan item"])
|
||||
self.assertEqual(scoring_run_due(before, after, [], True), [])
|
||||
emptied = [item(3, (0, 2, 0))]
|
||||
self.assertEqual(scoring_run_due(before, emptied, [2], False), ["leaves release 0.1.0 with no plan item"])
|
||||
self.assertEqual(scoring_run_due(before, emptied, [], True), ["leaves release 0.1.0 with no plan item"])
|
||||
self.assertEqual(scoring_run_due(before, emptied, [], False), [])
|
||||
|
||||
def test_is_not_due_when_a_later_release_loses_its_last_item_unshipped(self):
|
||||
before = [item(1, (0, 1, 0)), item(3, (0, 2, 0))]
|
||||
self.assertEqual(scoring_run_due(before, before[:1], [], True), [])
|
||||
|
||||
|
||||
class LarvReviewTool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
root = pathlib.Path(os.path.realpath(temp.name))
|
||||
self.env = {**host_env(), "GIT_CONFIG_GLOBAL": os.devnull, "HOME": str(root)}
|
||||
self.checkout = root / "proj"
|
||||
subprocess.run(["git", "init", "-q", "--bare", "-b", "main", str(root / "origin.git")], check=True, env=self.env)
|
||||
subprocess.run(["git", "clone", "-q", str(root / "origin.git"), str(self.checkout)], check=True, env=self.env, capture_output=True)
|
||||
self.commit("start", {"todo.md": todo("| 1 | 0.1.0 | | **Do it.** | 1 | 1 | 1 | 1 | 1 | 9.0 |", "| 2 | 0.2.0 | | **Then this.** | 1 | 1 | 1 | 1 | 1 | 9.0 |", "| 3 | 0.2.0 | | **And this.** | 1 | 1 | 1 | 1 | 1 | 9.0 |")})
|
||||
self.git("push", "-q", "origin", "HEAD:main")
|
||||
self.git("remote", "set-head", "origin", "main")
|
||||
self.git("switch", "-q", "-c", "chunk")
|
||||
self.start = self.git("rev-parse", "--short", "HEAD").strip()
|
||||
|
||||
def git(self, *args):
|
||||
return subprocess.run(["git", "-c", "user.name=t", "-c", "user.email=t@t", *args], cwd=self.checkout, check=True, env=self.env, capture_output=True, text=True).stdout
|
||||
|
||||
def commit(self, title, files=None):
|
||||
for name, text in (files or {}).items():
|
||||
(self.checkout / name).parent.mkdir(parents=True, exist_ok=True)
|
||||
(self.checkout / name).write_text(text)
|
||||
self.git("add", name)
|
||||
self.git("commit", "-q", "--allow-empty", "-m", title)
|
||||
|
||||
def run_tool(self, *args):
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=self.checkout, env=self.env, text=True)
|
||||
|
||||
def seats_file(self, text):
|
||||
path = self.checkout.parent / "seats.md"
|
||||
path.write_text(textwrap.dedent(text))
|
||||
return str(path)
|
||||
|
||||
def test_takes_the_merge_base_until_a_merged_change_records_a_scoring_run(self):
|
||||
start = self.git("rev-parse", "HEAD").strip()
|
||||
self.commit("work")
|
||||
ran = self.run_tool("ruling-base")
|
||||
self.assertEqual((ran.returncode, ran.stdout.splitlines()[0]), (0, start), ran.stderr)
|
||||
self.git("switch", "-q", "-c", "measured", "main")
|
||||
self.commit("Merge a scoring run", {"docs/comprehension-history.md": "# Comprehension history\n\n" + SCORING})
|
||||
self.git("push", "-q", "origin", "HEAD:main")
|
||||
measured = self.git("rev-parse", "HEAD").strip()
|
||||
self.git("switch", "-q", "chunk")
|
||||
self.assertEqual(self.run_tool("ruling-base").stdout.splitlines()[0], measured)
|
||||
|
||||
def test_counts_rounds_on_this_branch_alone(self):
|
||||
self.commit("Answer stability round 1: a")
|
||||
self.commit("Answer stability round 2: b")
|
||||
self.commit("Answer prose round 1: c")
|
||||
self.commit("Answer stability round 3: d")
|
||||
ran = self.run_tool("round-count")
|
||||
self.assertIn("stability: 3, at the cap\n", ran.stdout)
|
||||
self.assertIn("prose: 1\n", ran.stdout)
|
||||
self.assertIn("architecture: 0\n", ran.stdout)
|
||||
|
||||
def test_says_whether_a_scoring_run_is_due_and_refuses_an_unknown_item(self):
|
||||
self.assertEqual(self.run_tool("needs-scoring-run", "1").stdout, "Scoring run due: the chunk leaves release 0.1.0 with no plan item.\n")
|
||||
self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n")
|
||||
unknown = self.run_tool("needs-scoring-run", "9")
|
||||
self.assertEqual(unknown.returncode, 1)
|
||||
self.assertIn("item 9", unknown.stderr)
|
||||
self.assertEqual(self.run_tool("needs-scoring-run").stdout, "No scoring run due.\n")
|
||||
self.assertIn("todo.md's ID column", self.run_tool("needs-scoring-run", "item-85").stderr)
|
||||
|
||||
def test_records_a_ruling_once_four_seats_settle_a_split(self):
|
||||
lines = """\
|
||||
PR #2 at {start}, against {start}
|
||||
|
||||
Mid A: worse
|
||||
|
||||
- `bin/a.py:3` `f`: three branches
|
||||
|
||||
Inherited architect: same
|
||||
"""
|
||||
lines = lines.replace("{start}", self.start)
|
||||
split = self.run_tool("record-ruling", self.seats_file(lines))
|
||||
self.assertEqual(split.returncode, 0, split.stderr)
|
||||
self.assertTrue(split.stdout.startswith("Split: Mid A worse, Inherited architect same."))
|
||||
history = self.checkout / "docs" / "comprehension-history.md"
|
||||
self.assertFalse(history.exists())
|
||||
lines += "\n\t\t\tMaintainability senior: worse\n\n\t\t\t- `bin/a.py:3` `f`: hard\n\n\t\t\tJunior A: worse\n"
|
||||
ran = self.run_tool("record-ruling", self.seats_file(lines))
|
||||
self.assertEqual(ran.stdout.splitlines()[0], "Ruling: same. Votes as counted: Mid A worse, Inherited architect same, Maintainability senior worse, Junior A same (voted worse, naming no place).")
|
||||
recorded = entries(history.read_text())
|
||||
self.assertEqual([(entry.commit, entry.against, entry.ruling) for entry in recorded], [(self.start, self.start, "same")])
|
||||
self.assertEqual(recorded[0].places, [Place("bin/a.py", "f")] * 2)
|
||||
self.assertIn("| Junior A | same (voted worse, naming no place) |", history.read_text())
|
||||
|
||||
def test_records_a_scoring_run_with_its_means(self):
|
||||
line = "Navigation 7, Locality 6.5, Shape 7, Self-sufficiency 6.5, Overall 7"
|
||||
seats = "".join(f"\n{seat}: {line}\n\n- `bin/a.py:3` `f`: long\n" for seat in ("Junior A", "Mid A", "Maintainability senior", "Inherited architect"))
|
||||
ran = self.run_tool("record-scoring", self.seats_file(f"PR #2 at {self.start}\n" + seats))
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
self.assertIn("Under the floor of 7.0: Locality 6.50, Self-sufficiency 6.50.", ran.stdout)
|
||||
text = (self.checkout / "docs" / "comprehension-history.md").read_text()
|
||||
self.assertIn("| Mean | 7.00 | 6.50 | 7.00 | 6.50 | 7.00 |", text)
|
||||
self.assertIn("Inherited architect, would restructure first:", text)
|
||||
self.assertEqual([entry.places for entry in entries(text)], [[Place("bin/a.py", "f")] * 4])
|
||||
|
||||
def test_refuses_a_ruling_file_that_names_no_base_or_a_commit_the_checkout_lacks(self):
|
||||
ran = self.run_tool("record-ruling", self.seats_file(f"PR #2 at {self.start}\n\nMid A: same\n\nInherited architect: same\n"))
|
||||
self.assertEqual(ran.returncode, 1)
|
||||
self.assertIn("against <base>", ran.stderr)
|
||||
lacking = self.run_tool("record-ruling", self.seats_file(f"PR #2 at {self.start}, against abcdef1\n\nMid A: same\n\nInherited architect: same\n"))
|
||||
self.assertEqual(lacking.returncode, 1)
|
||||
self.assertIn("abcdef1, which is no commit", lacking.stderr)
|
||||
|
||||
def test_moves_a_dated_mean_from_a_decision_entry_as_a_scoring_run(self):
|
||||
mean = "Mean: Navigation 7.38, Locality 6.63, Shape 7.0, Self-sufficiency 6.88, Overall 6.88\n"
|
||||
ran = self.run_tool("record-scoring", self.seats_file(f"2026-10-04, PR #1 merged at {self.start}\n\n{mean}"))
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
text = (self.checkout / "docs" / "comprehension-history.md").read_text()
|
||||
self.assertIn(f"## 2026-10-04, PR #1 merged at {self.start}\n\n| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |\n|---|---|---|---|---|---|\n| Mean | 7.38 | 6.63 | 7.00 | 6.88 | 6.88 |\n", text)
|
||||
|
||||
def test_states_its_rules_and_finds_origins_default_branch_where_the_clone_recorded_none(self):
|
||||
helped = self.run_tool("--help")
|
||||
self.assertEqual(helped.returncode, 0, helped.stderr)
|
||||
self.assertIn("cap of 3 rounds", helped.stdout)
|
||||
self.git("remote", "set-head", "origin", "--delete")
|
||||
self.assertEqual(self.run_tool("needs-scoring-run", "2").stdout, "No scoring run due.\n")
|
||||
|
||||
def test_refuses_a_dated_first_line_except_for_a_mean_alone_and_a_mean_without_one(self):
|
||||
mean = "Mean: Navigation 7, Locality 7, Shape 7, Self-sufficiency 7, Overall 7\n"
|
||||
self.assertEqual(self.run_tool("record-scoring", self.seats_file(f"PR #1 at {self.start}\n\n{mean}")).returncode, 1)
|
||||
ruled = self.run_tool("record-ruling", self.seats_file(f"2026-10-08, PR #2 at {self.start}, against {self.start}\n\nMid A: same\n\nInherited architect: same\n"))
|
||||
self.assertEqual(ruled.returncode, 1)
|
||||
self.assertIn("only a seats file holding a Mean line alone", ruled.stderr)
|
||||
|
||||
def test_takes_a_local_main_without_origin_and_reads_origin_as_last_fetched_when_the_fetch_fails(self):
|
||||
self.commit("Answer prose round 1: a")
|
||||
self.git("remote", "set-url", "origin", str(self.checkout.parent / "gone.git"))
|
||||
offline = self.run_tool("round-count")
|
||||
self.assertEqual(offline.returncode, 0, offline.stderr)
|
||||
self.assertIn("reading origin as last fetched", offline.stderr)
|
||||
self.assertIn("prose: 1\n", offline.stdout)
|
||||
self.git("remote", "remove", "origin")
|
||||
self.assertIn("prose: 1\n", self.run_tool("round-count").stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -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
|
||||
|
||||
@@ -18,6 +18,11 @@ import unittest
|
||||
BIN = pathlib.Path(__file__).resolve().parent
|
||||
TASK = "Do the next chunk."
|
||||
|
||||
|
||||
# A git hook's GIT_DIR, the host's LOOP_CLAUDE_* or PYTHONPATH would point the program under test at the host's own state.
|
||||
def host_env() -> dict[str, str]:
|
||||
return {name: value for name, value in os.environ.items() if not name.startswith(("GIT_", "LOOP_CLAUDE_", "PYTHON"))}
|
||||
|
||||
# Plays claude from FAKE_CLAUDE_SCENARIO, one step per call, logging each call; a step for another role,
|
||||
# or none left, is Ctrl-C to loop-claude, which otherwise loops forever.
|
||||
FAKE_CLAUDE = """#!{python}
|
||||
@@ -155,7 +160,7 @@ class Checkout:
|
||||
self.root.mkdir(parents=True)
|
||||
(self.root / "README.md").write_text(PREMISES)
|
||||
self.script = BIN / "loop-claude"
|
||||
self.env = {name: value for name, value in os.environ.items() if not name.startswith(("GIT_", "LOOP_CLAUDE_", "PYTHON"))}
|
||||
self.env = host_env()
|
||||
fake = self.temp / "fake-bin"
|
||||
fake.mkdir()
|
||||
(fake / "claude").write_text(FAKE_CLAUDE.format(python=sys.executable))
|
||||
|
||||
@@ -0,0 +1,249 @@
|
||||
import ast
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from metric_bench.bench import auc, bench, co_changed, resolved, top_k
|
||||
from metric_bench.python_units import cognitive, measured, python_units, Unit
|
||||
from larv_review.history import entries, Place
|
||||
from failure import Failure
|
||||
from test_loop_claude_black_box import host_env
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parent / "metric-bench"
|
||||
|
||||
|
||||
def scored(source: str) -> int:
|
||||
function = ast.parse(textwrap.dedent(source)).body[0]
|
||||
assert isinstance(function, ast.FunctionDef)
|
||||
return cognitive(function)
|
||||
|
||||
|
||||
class Cognitive(unittest.TestCase):
|
||||
def test_scores_the_white_papers_sum_of_primes_without_its_labelled_continue(self):
|
||||
self.assertEqual(scored("""
|
||||
def sum_of_primes(limit):
|
||||
total = 0
|
||||
for i in range(1, limit + 1):
|
||||
for j in range(2, i):
|
||||
if i % j == 0:
|
||||
break
|
||||
total += i
|
||||
return total
|
||||
"""), 6)
|
||||
|
||||
def test_counts_elif_and_else_flat_and_a_nested_ternary_by_its_depth(self):
|
||||
self.assertEqual(scored("""
|
||||
def f(a):
|
||||
if a:
|
||||
return 1 if a > 1 else 2
|
||||
elif a is None:
|
||||
return 3
|
||||
else:
|
||||
return 4
|
||||
"""), 5)
|
||||
|
||||
def test_counts_each_boolean_operator_sequence_a_handler_a_match_and_recursion(self):
|
||||
self.assertEqual(scored("""
|
||||
def f(a, b, c):
|
||||
try:
|
||||
if a and b and c or a:
|
||||
match a:
|
||||
case 1:
|
||||
return f(b, c, a)
|
||||
except ValueError:
|
||||
pass
|
||||
"""), 1 + 2 + 2 + 1 + 1)
|
||||
|
||||
def test_nests_a_while_a_lambda_and_an_inner_function(self):
|
||||
self.assertEqual(scored("""
|
||||
def f(a):
|
||||
while a:
|
||||
g = lambda b: 1 if b else 2
|
||||
def h():
|
||||
if a:
|
||||
pass
|
||||
"""), 1 + 3 + 3)
|
||||
|
||||
def test_counts_a_call_to_itself_on_self_as_recursion(self):
|
||||
self.assertEqual(scored("""
|
||||
def walk(self, node):
|
||||
return self.walk(node.child)
|
||||
"""), 1)
|
||||
|
||||
def test_counts_a_comprehension_as_a_loop_and_its_conditions(self):
|
||||
self.assertEqual(scored("""
|
||||
def f(rows):
|
||||
return [row for row in rows if row if row > 1]
|
||||
"""), 3)
|
||||
|
||||
|
||||
class Units(unittest.TestCase):
|
||||
def test_measures_functions_and_methods_with_the_state_methods_share(self):
|
||||
units = python_units("a.py", textwrap.dedent("""
|
||||
COUNT = 0
|
||||
|
||||
def bump():
|
||||
global COUNT
|
||||
COUNT += 1
|
||||
|
||||
class Box:
|
||||
def __init__(self):
|
||||
self.size = 0
|
||||
|
||||
def grow(self):
|
||||
self.size += 1
|
||||
self.name = "x"
|
||||
|
||||
def rename(self):
|
||||
self.name, self.other = "y", 1
|
||||
self.buf[self.size] = 0
|
||||
"""))
|
||||
self.assertEqual(units, [Unit("a.py", "bump", 0, 3, 1), Unit("a.py", "__init__", 0, 2, 1), Unit("a.py", "grow", 0, 3, 2), Unit("a.py", "rename", 0, 3, 1)])
|
||||
|
||||
def test_measures_python_files_outside_the_tests(self):
|
||||
self.assertEqual([path for path in ["a.py", "bin/test_a.py", "a_test.py", "tests/b.py", "e2e-tests/c.py", "README.md"] if measured(path)], ["a.py", "e2e-tests/c.py"])
|
||||
|
||||
def test_a_source_that_does_not_parse_is_a_failure_naming_it(self):
|
||||
failure = python_units("a.py", "def (")
|
||||
assert isinstance(failure, Failure)
|
||||
self.assertIn("a.py does not parse on Python", failure.reason)
|
||||
|
||||
|
||||
class Places(unittest.TestCase):
|
||||
HISTORY = textwrap.dedent("""
|
||||
# Comprehension history
|
||||
|
||||
## 2026-10-08T12:50:49Z, PR #224 at a58a0a8
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Mean | 7 | 7 | 7 | 7 | 7 |
|
||||
|
||||
Junior A, hardest first:
|
||||
|
||||
- `skills/x/SKILL.md:77` "Architecture"
|
||||
- `bin/tool/cycle/states.py:69` `transition`, with `cycle/run.py:55` `step` and `:90` `close`
|
||||
|
||||
Inherited architect, would restructure first:
|
||||
|
||||
- `bin/tool/cycle/judge.py:31` `run_judge`
|
||||
|
||||
## 2026-10-08T18:37:21Z, PR #228 at 2682668, against 8c9bf09
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- `bin/tool/cycle/run.py:1` `step`
|
||||
""")
|
||||
|
||||
def test_reads_each_scoring_runs_places_and_leaves_paired_rulings_out(self):
|
||||
runs = [entry for entry in entries(self.HISTORY) if not entry.paired]
|
||||
self.assertEqual([(run.heading, run.commit) for run in runs], [("2026-10-08T12:50:49Z, PR #224 at a58a0a8", "a58a0a8")])
|
||||
self.assertEqual(runs[0].places, [Place("skills/x/SKILL.md", None), Place("bin/tool/cycle/states.py", "transition"), Place("cycle/run.py", "step"), Place("cycle/run.py", "close"), Place("bin/tool/cycle/judge.py", "run_judge")])
|
||||
|
||||
def test_resolves_a_shortened_path_to_the_file_nearest_the_one_before_it(self):
|
||||
tracked = ["bin/tool/cycle/states.py", "bin/tool/cycle/run.py", "bin/other/cycle/run.py"]
|
||||
places = [Place("bin/tool/cycle/states.py", "transition"), Place("cycle/run.py", "step"), Place("gone.py", "x")]
|
||||
self.assertEqual(resolved(places, tracked), ([Place("bin/tool/cycle/states.py", "transition"), Place("bin/tool/cycle/run.py", "step")], [Place("gone.py", "x")]))
|
||||
|
||||
def test_a_full_path_wins_over_a_file_in_the_folder_before_it(self):
|
||||
self.assertEqual(resolved([Place("pkg/x.py", "a"), Place("main.py", "f")], ["pkg/x.py", "main.py", "pkg/main.py"])[0][-1], Place("main.py", "f"))
|
||||
|
||||
def test_resolves_a_shortened_path_after_a_repeated_place_by_the_repeat(self):
|
||||
tracked = ["bin/a/main.py", "bin/b/main.py", "bin/b/bench.py"]
|
||||
places = [Place("bin/a/main.py", "main"), Place("bin/b/bench.py", "bench"), Place("bin/a/main.py", "main"), Place("main.py", "figures")]
|
||||
self.assertEqual(resolved(places, tracked)[0][-1], Place("bin/a/main.py", "figures"))
|
||||
|
||||
def test_drops_a_shortened_path_two_files_match_with_no_place_before_it(self):
|
||||
self.assertEqual(resolved([Place("cycle/run.py", "step")], ["bin/tool/cycle/run.py", "bin/other/cycle/run.py"]), ([], [Place("cycle/run.py", "step")]))
|
||||
|
||||
|
||||
class Bench(unittest.TestCase):
|
||||
def test_auc_is_one_for_a_perfect_ranking_and_counts_a_tie_half(self):
|
||||
self.assertEqual(auc([5, 4], [1, 2]), 1.0)
|
||||
self.assertEqual(auc([3], [3]), 0.5)
|
||||
|
||||
def test_co_changed_counts_each_files_distinct_partners_past_a_sweep(self):
|
||||
sweep = "".join(f"f{i}.py\n" for i in range(31))
|
||||
self.assertEqual(co_changed(f"@@\na.py\nmy b.py\n@@\na.py\nc.py\n@@\na.py\n@@\n{sweep}"), {"a.py": 2, "my b.py": 1, "c.py": 1})
|
||||
|
||||
def test_top_k_shares_the_seats_at_a_tied_cut_evenly(self):
|
||||
self.assertEqual(top_k([0, 0], [0, 0, 0, 0]), 1 / 3)
|
||||
self.assertEqual(top_k([5, 1], [1, 1]), 2 / 3)
|
||||
|
||||
def test_scores_the_named_units_and_counts_places_no_unit_measures(self):
|
||||
units = [Unit("a.py", "hard", 9, 40, 0), Unit("a.py", "easy", 1, 5, 0), Unit("b.py", "plain", 2, 6, 0)]
|
||||
run = bench(units, [Place("a.py", "hard"), Place("doc.md", None)], 2, {"a.py": 1})
|
||||
assert run is not None
|
||||
self.assertEqual((run.units, run.named, run.unmeasured), (3, 1, 3))
|
||||
self.assertEqual((run.scores["cognitive complexity"].auc, run.scores["cognitive complexity"].top_k), (1.0, 1.0))
|
||||
self.assertEqual((run.scores["shared state"].auc, run.scores["shared state"].top_k), (0.5, 1 / 3))
|
||||
|
||||
def test_a_run_naming_no_unit_or_every_unit_is_not_scored(self):
|
||||
self.assertIsNone(bench([Unit("a.py", "f", 1, 1, 0)], [Place("doc.md", None)], 0, {}))
|
||||
self.assertIsNone(bench([Unit("a.py", "f", 1, 1, 0)], [Place("a.py", "f")], 0, {}))
|
||||
|
||||
|
||||
class BlackBox(unittest.TestCase):
|
||||
def project(self, history: str) -> str:
|
||||
directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(directory.cleanup)
|
||||
top = directory.name
|
||||
env = host_env()
|
||||
for args in (["init", "-q"], ["config", "user.email", "t@t"], ["config", "user.name", "t"]):
|
||||
subprocess.run(["git", *args], cwd=top, check=True, env=env)
|
||||
pathlib.Path(top, "a.py").write_text("def hard(a):\n\tif a:\n\t\tfor x in a:\n\t\t\tif x:\n\t\t\t\treturn x\n\n\ndef easy():\n\treturn 1\n")
|
||||
pathlib.Path(top, "test_a.py").write_text("def test_hard():\n\tif 1:\n\t\tpass\n")
|
||||
subprocess.run(["git", "add", "."], cwd=top, check=True, env=env)
|
||||
subprocess.run(["git", "commit", "-qm", "a"], cwd=top, check=True, env=env)
|
||||
commit = subprocess.run(["git", "rev-parse", "--short", "HEAD"], cwd=top, check=True, capture_output=True, text=True, env=env).stdout.strip()
|
||||
os.makedirs(pathlib.Path(top, "docs"))
|
||||
pathlib.Path(top, "docs", "comprehension-history.md").write_text(history.replace("COMMIT", commit))
|
||||
return top
|
||||
|
||||
def run_tool(self, top: str, *args: str) -> subprocess.CompletedProcess:
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], cwd=top, capture_output=True, text=True, env=host_env())
|
||||
|
||||
def test_prints_each_metrics_score_on_each_run_and_the_medians(self):
|
||||
top = self.project("# Comprehension history\n\n## 2026-10-08T12:50:49Z, PR #1 at COMMIT\n\nJunior A, hardest first:\n\n- `a.py:1` `hard`\n")
|
||||
ran = self.run_tool(top)
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
self.assertIn("| 2026-10-08T12:50:49Z, PR #1 at ", ran.stdout)
|
||||
self.assertIn("| 2 | 1 | 0 | top k 0.50 | AUC 1.00, top k 1.00 | AUC 1.00, top k 1.00 | constant | constant |", ran.stdout)
|
||||
self.assertIn("| Median |", ran.stdout)
|
||||
|
||||
def test_exits_1_when_no_run_names_a_measured_unit(self):
|
||||
top = self.project("# Comprehension history\n\n## 2026-10-08T12:50:49Z, PR #1 at COMMIT\n\nJunior A, hardest first:\n\n- `README.md:1` \"Install\"\n")
|
||||
ran = self.run_tool(top)
|
||||
self.assertEqual((ran.returncode, ran.stdout), (1, ""))
|
||||
self.assertIn("no scoring run in", ran.stderr)
|
||||
|
||||
def test_exits_1_naming_a_history_it_cannot_read_and_unknown_arguments(self):
|
||||
top = self.project("")
|
||||
self.assertIn("could not read", self.run_tool(top, str(pathlib.Path(top, "missing.md"))).stderr)
|
||||
pathlib.Path(top, "docs", "comprehension-history.md").unlink()
|
||||
self.assertIn("no comprehension history at", self.run_tool(top).stderr)
|
||||
self.assertIn("could not read", self.run_tool(top, str(pathlib.Path(top, "gone", "x.md"))).stderr)
|
||||
self.assertEqual(self.run_tool(top, "--x").returncode, 1)
|
||||
|
||||
def test_skips_and_names_a_run_whose_commit_the_checkout_lacks(self):
|
||||
top = self.project("# Comprehension history\n\n## 2026-10-07T12:00:00Z, PR #0 at 0123456\n\nJunior A, hardest first:\n\n- `a.py:1` `hard`\n\n## 2026-10-08T12:50:49Z, PR #1 at COMMIT\n\nJunior A, hardest first:\n\n- `a.py:1` `hard`\n")
|
||||
ran = self.run_tool(top)
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
self.assertIn("Skipped, its commit is not in", ran.stdout)
|
||||
self.assertIn("PR #0 at 0123456", ran.stdout.split("Skipped")[1])
|
||||
|
||||
def test_names_a_run_it_cannot_score_below_the_table(self):
|
||||
top = self.project("# Comprehension history\n\n## 2026-10-07T12:00:00Z, PR #0 at COMMIT\n\nJunior A, hardest first:\n\n- `README.md:1` \"Install\"\n\n## 2026-10-08T12:50:49Z, PR #1 at COMMIT\n\nJunior A, hardest first:\n\n- `a.py:1` `hard`\n")
|
||||
ran = self.run_tool(top)
|
||||
self.assertIn("Not scored, its places name no measured unit or every one: 2026-10-07T12:00:00Z, PR #0", ran.stdout)
|
||||
|
||||
def test_reads_the_checkout_that_holds_a_history_named_from_elsewhere(self):
|
||||
top = self.project("# Comprehension history\n\n## 2026-10-08T12:50:49Z, PR #1 at COMMIT\n\nJunior A, hardest first:\n\n- `a.py:1` `hard`\n")
|
||||
ran = self.run_tool(tempfile.gettempdir(), str(pathlib.Path(top, "docs", "comprehension-history.md")))
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
@@ -0,0 +1,161 @@
|
||||
import collections
|
||||
import contextlib
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent))
|
||||
|
||||
from loop_claude.transcript_archive import archive, FINISHED, FINISHED_AT, finished_chunks, FinishedChunk, UNFINISHED, utc
|
||||
from reading_cost.measure import Checkout, Reading
|
||||
from failure import Failure
|
||||
from reading_cost import figures, measure
|
||||
from test_loop_claude_black_box import host_env
|
||||
from loop_claude.paths import paths_from
|
||||
from reading_cost.shell_reads import Reads, shell_reads
|
||||
|
||||
TOOL = pathlib.Path(__file__).resolve().parent / "reading-cost"
|
||||
|
||||
|
||||
def said(timestamp, message_id, command=None, tokens=0, cwd="/c/p", **call):
|
||||
part = {"type": "tool_use", "name": "Bash", "input": {"command": command}} if command else {"type": "tool_use", **call}
|
||||
return {"type": "assistant", "timestamp": timestamp, "cwd": cwd, "message": {"id": message_id, "content": [part], "usage": {"input_tokens": tokens, "cache_creation_input_tokens": 2 * tokens, "cache_read_input_tokens": 1000}}}
|
||||
|
||||
|
||||
def jsonl(entries):
|
||||
return b"".join(json.dumps(entry).encode() + b"\n" for entry in entries)
|
||||
|
||||
|
||||
def folder_name():
|
||||
return hashlib.sha256(os.urandom(8)).hexdigest()
|
||||
|
||||
|
||||
class ShellReads(unittest.TestCase):
|
||||
def test_reads_operands_past_a_cd_and_skips_patterns_redirect_targets_and_heredoc_bodies(self):
|
||||
command = "cd ../w && sed -n 1,5p src/a.py | grep -n x\ngrep -rn 'def x' bin/t.py > out.txt\npython3 - <<'EOF'\ncat secret.py\nEOF\ncat ~/README.md\nsed -i s/a/b/ c.py"
|
||||
self.assertEqual(shell_reads(command, "/c/p", "/h"), Reads(["/c/w/src/a.py", "/c/w/bin/t.py", "/h/README.md"], []))
|
||||
|
||||
def test_ends_a_dashed_heredoc_at_its_marker(self):
|
||||
self.assertEqual(shell_reads("cat <<-EOF > x.md\ncat secret.py\nEOF\ncat a.py", "/c/p", "/h"), Reads(["/c/p/a.py"], []))
|
||||
|
||||
def test_names_the_worktree_a_git_worktree_add_makes(self):
|
||||
self.assertEqual(shell_reads("git worktree add -q -b topic ../p-topic origin/main", "/c/p", "/h"), Reads([], ["/c/p-topic"]))
|
||||
|
||||
|
||||
class Measure(unittest.TestCase):
|
||||
def test_counts_each_message_once_and_the_tracked_files_read_before_the_first_commit(self):
|
||||
worker = [
|
||||
said("1", "m1", tokens=10, name="Read", input={"file_path": "/c/p/README.md"}),
|
||||
said("2", "m1", tokens=10, name="Read", input={"file_path": "/c/p/.env"}),
|
||||
said("3", "m2", command="git worktree add ../w && cd ../w && cat src/a.py && cd src && cat b.py"),
|
||||
said("4", "m3", command="cd /tmp && cat x.py"),
|
||||
said("5", "m4", command="git -C ../w commit -m 'x'", tokens=100),
|
||||
said("6", "m5", tokens=100, name="Read", input={"file_path": "/c/p/late.py"}),
|
||||
]
|
||||
subagent = [said("2", "s1", tokens=1, name="Grep", input={"path": "/c/w/src/a.py"}), said("7", "s2", tokens=100, name="Read", input={"file_path": "/c/p/late.py"})]
|
||||
checkout = Checkout("/c/p", "/c/w", frozenset({"README.md", "late.py", "src/a.py", "src/b.py", "x.py"}))
|
||||
self.assertEqual(measure.measure([jsonl(worker), jsonl(subagent)], checkout, "/h"), Reading(33, collections.Counter({"src/a.py": 2, "README.md": 1, "src/b.py": 1})))
|
||||
|
||||
def test_measures_nothing_for_a_worker_that_never_committed(self):
|
||||
self.assertIsNone(measure.measure([jsonl([said("1", "m1", command="git log --grep commit")])], Checkout("/c/p", "/c/p", frozenset()), "/h"))
|
||||
|
||||
def test_skips_a_usage_that_is_not_a_count(self):
|
||||
self.assertEqual(measure.tokens_in([{"message": {"id": "m", "usage": {"input_tokens": "7", "cache_creation_input_tokens": 2}}}]), 2)
|
||||
|
||||
|
||||
class Figures(unittest.TestCase):
|
||||
def test_rises_only_above_the_five_before_and_needs_ten(self):
|
||||
flat = [Reading(100, collections.Counter({"a.py": 1}))] * 10
|
||||
self.assertEqual(figures.trend(flat[:9]), "9 chunks measured since the last reset; the trend needs 10.")
|
||||
self.assertTrue(figures.trend(flat).startswith("Not rising: the last 5 chunks' median is 100 new input tokens"))
|
||||
self.assertTrue(figures.trend(flat[:9] + [Reading(3000000, collections.Counter())]).startswith("Not rising:"))
|
||||
self.assertEqual(figures.trend(flat[:5] + [Reading(101, collections.Counter({"b.py": 2}))] * 5), "Rising: the last 5 chunks' median is 101 new input tokens before their first commit, the 5 before them 100.\n\nRead most over the last 5 (opens and searches):\n\n- `b.py` 10")
|
||||
|
||||
def test_a_figure_reads_back_as_the_reading_it_was_written_from_and_a_damaged_one_fails(self):
|
||||
reading = Reading(7, collections.Counter({"b.py": 1, "a.py": 3}))
|
||||
written = figures.figure(FinishedChunk("abcdef0123456789", "2026-10-08T00:00:00Z", pathlib.Path(), []), reading)
|
||||
self.assertEqual(written, "## Reading cost, chunk abcdef012345, finished 2026-10-08T00:00:00Z\n\n7 new input tokens before the first commit.\n\nRead most (opens and searches):\n\n- `a.py` 3\n- `b.py` 1\n")
|
||||
self.assertEqual(figures.readings_of(written), [reading])
|
||||
self.assertEqual(figures.readings_of(written.replace("7 new", "seven new")), Failure('the figure under "## Reading cost, chunk abcdef012345, finished 2026-10-08T00:00:00Z" holds no single tokens line; restore it from git history'))
|
||||
for damaged in (written.replace(", finished", ""), "## Reading cost reset, x\n"):
|
||||
with self.subTest(damaged=damaged):
|
||||
self.assertIsInstance(figures.readings_of(damaged), Failure)
|
||||
|
||||
|
||||
def test_counts_only_figures_finished_after_the_last_reset_in_the_order_they_finished(self):
|
||||
def written(chunk, finished, tokens):
|
||||
return figures.figure(FinishedChunk(chunk, finished, pathlib.Path(), []), Reading(tokens, collections.Counter()))
|
||||
history = "\n".join([written("a", "2026-10-01T00:00:00Z", 1), written("c", "2026-10-03T00:00:00Z", 3), "## Reading cost reset, 2026-10-02T00:00:00Z\n", written("b", "2026-10-04T00:00:00Z", 2)])
|
||||
self.assertEqual(figures.readings_of(history), [Reading(3, collections.Counter()), Reading(2, collections.Counter())])
|
||||
|
||||
def test_the_archive_stamps_what_it_reads_back(self):
|
||||
self.assertRegex(f"{utc(1790000000)} {FINISHED}", FINISHED_AT)
|
||||
|
||||
|
||||
class ReadingCostTool(unittest.TestCase):
|
||||
def setUp(self):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
self.home = pathlib.Path(os.path.realpath(temp.name))
|
||||
self.env = {**host_env(), "GIT_CONFIG_GLOBAL": os.devnull, "HOME": str(self.home)}
|
||||
self.checkout = self.home / "code" / "proj"
|
||||
self.checkout.mkdir(parents=True)
|
||||
(self.checkout / "a.py").write_text("")
|
||||
self.git("init", "-q")
|
||||
self.git("add", "a.py")
|
||||
self.git("-c", "user.name=t", "-c", "user.email=t@t", "commit", "-q", "-m", "x")
|
||||
self.paths = paths_from(self.home, {})
|
||||
|
||||
def git(self, *args):
|
||||
subprocess.run(["git", *args], cwd=self.checkout, check=True, env=self.env)
|
||||
|
||||
def archive_chunk(self, at, outcome=FINISHED):
|
||||
transcript = self.home / ".claude" / "projects" / "-proj" / f"{folder_name()}.jsonl"
|
||||
(transcript.with_suffix("") / "subagents").mkdir(parents=True)
|
||||
worker = [said("1", "m1", tokens=10, cwd=str(self.checkout), name="Read", input={"file_path": str(self.checkout / "a.py")}), said("2", "m2", command="git commit -m x")]
|
||||
transcript.write_bytes(jsonl([{"timestamp": str(at)}, *worker]))
|
||||
(transcript.with_suffix("") / "subagents" / "agent-a.jsonl").write_bytes(jsonl([said("1", "s1", tokens=1)]))
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
self.assertIsNone(archive("proj", str(transcript), "Do it.", f"{outcome}\n\nEvidence:\n> merged", at, self.paths))
|
||||
|
||||
def run_tool(self, cwd, *args):
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=cwd, env=self.env, text=True)
|
||||
|
||||
def test_appends_each_finished_chunk_once_in_the_order_they_finished_from_a_worktree(self):
|
||||
self.archive_chunk(1790000200)
|
||||
self.archive_chunk(1790000100)
|
||||
self.archive_chunk(1790000000, UNFINISHED)
|
||||
chunks = finished_chunks(self.paths.transcript_archive / "proj")
|
||||
self.assertEqual([chunk.finished for chunk in chunks], ["2026-09-21T14:15:00Z", "2026-09-21T14:16:40Z"])
|
||||
worktree = self.home / "code" / "proj-wt"
|
||||
self.git("worktree", "add", "-q", str(worktree))
|
||||
ran = self.run_tool(worktree)
|
||||
self.assertEqual(ran.returncode, 0, ran.stderr)
|
||||
history = worktree / "docs" / "reading-cost.md"
|
||||
self.assertEqual(ran.stdout, f"Appended 2 reading-cost figures from {self.home / '.claude' / 'loop-claude-transcripts' / 'proj'} to {history}.\n2 chunks measured since the last reset; the trend needs 10.\n")
|
||||
figure = "## Reading cost, chunk {}, finished {}\n\n33 new input tokens before the first commit.\n\nRead most (opens and searches):\n\n- `a.py` 1\n"
|
||||
self.assertEqual(history.read_text(), "# Reading cost\n\n" + "\n".join(figure.format(chunk.folder[:12], chunk.finished) for chunk in chunks))
|
||||
self.assertTrue(self.run_tool(worktree).stdout.startswith(f"Appended 0 reading-cost figures from"))
|
||||
self.assertEqual(history.read_text().count("## Reading cost"), 2)
|
||||
reset = self.run_tool(worktree, "--reset")
|
||||
self.assertEqual(reset.stdout, f"Appended 0 reading-cost figures from {self.home / '.claude' / 'loop-claude-transcripts' / 'proj'} and a reset to {history}.\n0 chunks measured since the last reset; the trend needs 10.\n")
|
||||
self.assertRegex(history.read_text(), r"\n## Reading cost reset, \d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ\n$")
|
||||
|
||||
def test_refuses_an_option_it_does_not_know(self):
|
||||
ran = self.run_tool(self.checkout, "--rest")
|
||||
self.assertEqual((ran.returncode, ran.stdout), (1, ""))
|
||||
|
||||
def test_exits_1_outside_a_checkout(self):
|
||||
ran = self.run_tool(self.home)
|
||||
self.assertEqual(ran.returncode, 1)
|
||||
self.assertIn("not a git repository", ran.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+1
-1
@@ -11,5 +11,5 @@ class Types(unittest.TestCase):
|
||||
self.assertIsNotNone(floor, "README.md's Install names `Python 3.N or newer`")
|
||||
if shutil.which("uv") is None:
|
||||
self.fail("uv on PATH fetches mypy; see README.md's Test line")
|
||||
ran = subprocess.run(["uv", "tool", "run", "--python", "%d.%d" % floor, "mypy==2.3.1", "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "-m", "rank_todo", "-m", "statusline", "-p", "loop_claude"], capture_output=True, cwd=ROOT / "bin", text=True)
|
||||
ran = subprocess.run(["uv", "tool", "run", "--python", "%d.%d" % floor, "mypy==2.3.1", "--cache-dir=/dev/null", "--check-untyped-defs", "--disallow-untyped-defs", "-p", "larv_review", "-p", "loop_claude", "-p", "metric_bench", "-m", "rank_todo", "-p", "reading_cost", "-m", "statusline"], capture_output=True, cwd=ROOT / "bin", text=True)
|
||||
self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr)
|
||||
|
||||
@@ -0,0 +1,530 @@
|
||||
# Comprehension history
|
||||
|
||||
## 2026-10-04T18:28:07Z, PR #215 merged at 5baedb5
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Mean | 7.38 | 6.63 | 7.00 | 6.88 | 6.88 |
|
||||
|
||||
## 2026-10-08T12:50:49Z, PR #224 at a58a0a8
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Junior A | 7 | 6.5 | 7 | 6.5 | 7 |
|
||||
| Mid A | 7.5 | 7 | 7 | 7 | 7 |
|
||||
| Maintainability senior | 7.5 | 6.5 | 7 | 6.5 | 7 |
|
||||
| Inherited architect | 7.5 | 7 | 7 | 7 | 7 |
|
||||
| Mean | 7.38 | 6.75 | 7.00 | 6.75 | 7.00 |
|
||||
|
||||
Junior A, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:77` "Architecture": Ratchet, the history move, Fresh, Suspended
|
||||
- `skills/larv-review/SKILL.md:51` "Round cap", with "Re-entry"
|
||||
- `bin/loop_claude/cycle/judge_reply.py:90` `verdict_from`, `cycle/judge.py:31` `run_judge`, `cycle/states.py:69` `transition`
|
||||
- `bin/loop_claude/cycle/states.py:9` the `quoted_answers` counter
|
||||
- `bin/loop_claude/cycle/archive.py:14` `archive`
|
||||
- `bin/loop_claude/claude_code/entries.py:28` `written_by_human`
|
||||
- `bin/loop_claude/loop/reload.py:50` `exec_if_edited`
|
||||
- `CLAUDE.md:22` (Todo items), with `bin/rank_todo.py:235` `check_citations`
|
||||
|
||||
Mid A, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:86` "Architecture"
|
||||
- `bin/loop_claude/cycle/states.py:69` `transition`, with `cycle/run.py:55` `step`
|
||||
- `bin/loop_claude/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:14` `archive`
|
||||
- `bin/rank_todo.py:161` `rank`, `:408` `rank_details`
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`
|
||||
|
||||
Maintainability senior, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:77` "Architecture"
|
||||
- `skills/larv-review/SKILL.md:56` "Round cap" → "Count"
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`
|
||||
- `bin/loop_claude/cycle/states.py:69` `transition`, with `cycle/run.py:104` `question_for`
|
||||
- `bin/loop_claude/cycle/archive.py:14` `archive`
|
||||
- `bin/loop_claude/claude_code/entries.py:28` `written_by_human`
|
||||
- `bin/loop_claude/loop/reload.py:50` `exec_if_edited`
|
||||
- `bin/rank_todo.py:161` `rank`, `:408` `rank_details`
|
||||
|
||||
Inherited architect, would restructure first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:51` "Round cap" and `:77` "Architecture"
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`
|
||||
- `bin/` flat folder: tools, shared modules and repo checks
|
||||
- `bin/loop_claude/project/checkout.py:32` `read_utf8`
|
||||
- `bin/loop_claude/loop/main.py:127` `remaining`, `cycle/run.py:96` `ruling`
|
||||
|
||||
## 2026-10-08T13:03:40Z, PR #224 at 9ea4f0a
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Junior A | 7 | 6.5 | 7 | 6 | 6.5 |
|
||||
| Mid A | 7 | 6.5 | 7 | 6.5 | 7 |
|
||||
| Maintainability senior | 7 | 6.5 | 7 | 6.5 | 6.5 |
|
||||
| Inherited architect | 7 | 6.5 | 7 | 7 | 7 |
|
||||
| Mean | 7.00 | 6.50 | 7.00 | 6.50 | 6.75 |
|
||||
|
||||
Junior A, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:77` "Architecture", with `:51` "Round cap"
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`, `:90` `verdict_from`
|
||||
- `bin/loop_claude/cycle/archive.py:14` `archive`
|
||||
- `bin/loop_claude/loop/reload.py:50` `exec_if_edited`
|
||||
- `bin/rank_todo.py:187` `read_scoring`, `:408` `rank_details`
|
||||
- `bin/loop_claude/claude_code/entries.py:28` `written_by_human`
|
||||
- `bin/loop_claude/cycle/run.py:69` `work`
|
||||
- `bin/loop-claude:7` the `sys.path` insert
|
||||
|
||||
Mid A, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:86` "Architecture"
|
||||
- `skills/larv-review/SKILL.md:51` "Round cap" → "Count"
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`
|
||||
- `bin/loop_claude/cycle/archive.py:14` `archive`
|
||||
- `bin/loop_claude/claude_code/entries.py:28` `written_by_human`
|
||||
- `bin/rank_todo.py:408` `rank_details`
|
||||
- `bin/loop_claude/cycle/states.py:69` `transition`
|
||||
- `bin/loop_claude/loop/reload.py:50` `exec_if_edited`
|
||||
|
||||
Maintainability senior, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:51` "Round cap", with `:77` "Architecture"
|
||||
- `bin/loop_claude/cycle/states.py:69` `transition`
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`, `cycle/judge.py:31` `run_judge`
|
||||
- `bin/loop_claude/cycle/archive.py:14` `archive`
|
||||
- `bin/loop_claude/claude_code/entries.py:28` `written_by_human`
|
||||
- `bin/rank_todo.py:408` `rank_details`
|
||||
- `bin/loop_claude/loop/reload.py:50` `exec_if_edited`
|
||||
- `bin/loop_claude/loop/main.py:1` the `--help` docstring
|
||||
|
||||
Inherited architect, would restructure first:
|
||||
|
||||
- `bin/loop_claude/cycle/judge.py:53` `judge_prompt` and `judge_reply.py:12` `JUDGE_RULES`: one home for the judge's prompt
|
||||
- `bin/` flat folder: shared modules and tests
|
||||
- `skills/larv-review/SKILL.md:27` §3: bold labels to addressable headings
|
||||
- `bin/loop_claude/loop/main.py:5` `--help` and `cycle/retry.py:40`: numbers restating constants
|
||||
- `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`
|
||||
|
||||
## 2026-10-08T15:54:46Z, PR #225 at 1fc91a5
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Junior A | 7 | 6 | 6.5 | 6 | 6.5 |
|
||||
| Mid A | 7 | 6.5 | 7 | 6.5 | 7 |
|
||||
| Maintainability senior | 7.5 | 6.5 | 7 | 6.5 | 7 |
|
||||
| Inherited architect | 7 | 6 | 6.5 | 7 | 6.5 |
|
||||
| Mean | 7.13 | 6.25 | 6.75 | 6.50 | 6.75 |
|
||||
|
||||
Junior A, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:53` "Round cap", through "Re-entry", "Fresh" and "Suspended"
|
||||
- `bin/loop_claude/cycle/states.py:69` `transition`, with `cycle/run.py:55` `step`
|
||||
- `bin/reading_cost.py:180` `measure`
|
||||
- `bin/reading_cost.py:242` `readings_of`, with `:171` `unheld` and `:236` `figure`
|
||||
- `bin/loop_claude/cycle/judge.py:31` `run_judge`
|
||||
- `bin/loop_claude/transcript_archive.py:29` `archive`, with `copy_for` and `finished_chunks`
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`
|
||||
- `bin/rank_todo.py:408` `rank_details`
|
||||
|
||||
Mid A, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:53` "Round cap", with "Architecture" from Floor to Suspended
|
||||
- `bin/loop_claude/cycle/judge.py:31` `run_judge`
|
||||
- `bin/loop_claude/cycle/states.py:69` `transition`
|
||||
- `bin/reading_cost.py:180` `measure`, and `:242` `readings_of`
|
||||
- `bin/loop_claude/transcript_archive.py:29` `archive`, `:95` `copy_for` and `:110` `finished_chunks`
|
||||
- `bin/loop_claude/claude_code/entries.py:28` `written_by_human`
|
||||
- `bin/loop_claude/loop/reload.py:50` `exec_if_edited`
|
||||
- `bin/rank_todo.py:408` `rank_details`
|
||||
|
||||
Maintainability senior, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:79` "Architecture"
|
||||
- `skills/larv-review/SKILL.md:95` the move of an old entry's scores into the history
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`
|
||||
- `bin/loop_claude/cycle/judge.py:31` `run_judge`
|
||||
- `bin/reading_cost.py:180` `measure`, and `:242` `readings_of`
|
||||
- `bin/loop_claude/transcript_archive.py:18` `FINISHED_AT`, with `finished_chunks` and `cycle/run.py:110` `close`
|
||||
- `bin/reading_cost.py:141` `located`, beside `bin/loop_claude/project/checkout.py:7` `checkout_root`
|
||||
- `bin/shell_reads.py:52` `segments`, and `:67` `operands`
|
||||
|
||||
Inherited architect, would restructure first:
|
||||
|
||||
- `bin/` by kind: tools, shared modules and tests
|
||||
- `bin/loop_claude/transcript_archive.py:110` `finished_chunks`, read by `bin/reading_cost.py` through four `loop_claude` modules
|
||||
- `docs/comprehension-history.md`, written by `bin/reading_cost.py:242` and by `skills/larv-review/SKILL.md:92`'s prose
|
||||
- `skills/larv-review/SKILL.md:53` "Round cap"
|
||||
- `bin/loop_claude/cycle/judge_reply.py:87` `Verdict` beside `states.py` `ruling`, and `project/checkout.py:32` `read_utf8`
|
||||
|
||||
## 2026-10-08T17:29:52Z, PR #225 at 8c9bf09
|
||||
|
||||
| Seat | Navigation | Locality | Shape | Self-sufficiency | Overall |
|
||||
|---|---|---|---|---|---|
|
||||
| Junior A | 7 | 6.5 | 7 | 6.5 | 6.5 |
|
||||
| Mid A | 7 | 7 | 7 | 6.5 | 7 |
|
||||
| Maintainability senior | 7.5 | 6.5 | 7 | 7 | 7 |
|
||||
| Inherited architect | 7.5 | 7 | 7 | 7.5 | 7 |
|
||||
| Mean | 7.25 | 6.75 | 7.00 | 6.88 | 6.88 |
|
||||
|
||||
Junior A, hardest first:
|
||||
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`, with `Reply` and `verdict_from`
|
||||
- `bin/loop_claude/cycle/judge.py:31` `run_judge`, with `grounded`, `verbatim` and `plain`
|
||||
- `bin/loop_claude/cycle/states.py:69` `transition`
|
||||
- `bin/loop_claude/transcript_archive.py:30` `archive`, `copy_for` and `finished_chunks`
|
||||
- `bin/reading_cost/measure.py:27` `measure`, with `bin/reading_cost/main.py:113` `located`
|
||||
- `skills/larv-review/SKILL.md:95` the old entry's scores, and `:108` "Fresh"
|
||||
- `bin/reading_cost/shell_reads.py:21` `shell_reads`, with `operands`, `segments` and `shell_lines`
|
||||
- `bin/loop_claude/claude_code/entries.py:28` `written_by_human`
|
||||
|
||||
Mid A, hardest first:
|
||||
|
||||
- `skills/larv-review/SKILL.md:53` "Round cap", through "Architecture", "Fresh" and "Suspended"
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`, and `:90` `verdict_from`
|
||||
- `bin/loop_claude/cycle/states.py:69` `transition`, with `cycle/run.py:35` `run_cycle` and `:104` `question_for`
|
||||
- `bin/loop_claude/transcript_archive.py:30` `archive`, `copy_for` and `finished_chunks`
|
||||
- `bin/loop_claude/claude_code/entries.py:28` `written_by_human`
|
||||
- `bin/reading_cost/figures.py:34` `readings_of`
|
||||
- `bin/reading_cost/shell_reads.py:52` `segments`, and `:67` `operands`
|
||||
- `bin/reading_cost/main.py:113` `located`, beside `bin/loop_claude/project/checkout.py:7` `checkout_root`
|
||||
|
||||
Maintainability senior, hardest first:
|
||||
|
||||
- `bin/loop_claude/transcript_archive.py:30` `archive`, and `:111` `finished_chunks`
|
||||
- `bin/reading_cost/figures.py:34` `readings_of`
|
||||
- `bin/reading_cost/shell_reads.py:52` `segments`, and `:67` `operands`
|
||||
- `bin/loop_claude/cycle/judge.py:31` `run_judge`
|
||||
- `bin/reading_cost/main.py:113` `located`, and `measure.py:21` `Checkout`
|
||||
- `skills/larv-review/SKILL.md:53` "Round cap", and `:108` "Fresh" and "Suspended"
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`
|
||||
- `bin/rank_todo.py:408` `rank_details`
|
||||
|
||||
Inherited architect, would restructure first:
|
||||
|
||||
- `bin/loop_claude/claude_code/` and the read side of `bin/loop_claude/transcript_archive.py`, into a package both tools import
|
||||
- `skills/larv-review/SKILL.md:58` "Count", with a checker
|
||||
- `bin/loop_claude/cycle/judge_reply.py:12` `JUDGE_RULES`, beside `judge.py:53` `judge_prompt`
|
||||
- `bin/loop_claude/project/checkout.py:7` `checkout_root` and `bin/reading_cost/main.py:113` `located`, and `checkout.py:32` `read_utf8`
|
||||
- `bin/failure.py`, `bin/file_writes.py` and `bin/markdown_sections.py`, into one package
|
||||
|
||||
## 2026-10-08T18:37:21Z, PR #228 at 2682668, against 8c9bf09
|
||||
|
||||
Ruling: worse
|
||||
|
||||
| Seat | Vote |
|
||||
|---|---|
|
||||
| Mid A | worse |
|
||||
| Inherited architect | worse |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:91` "Paired ruling": the base, its fallbacks, a two-stage vote and a tie rule in one paragraph
|
||||
- `skills/comprehension-panel/scoring-run.md:1` and `:67` "Paired ruling": one file name over two kinds of prompt
|
||||
- `skills/comprehension-panel/SKILL.md:102` "The paired ruling": the procedure spread over three files
|
||||
- `skills/larv-review/SKILL.md:89` "Architecture": the comprehension check, paired ruling, scoring run, ratchet and floor to hold at once
|
||||
- `skills/larv-review/SKILL.md:105` "History": two record shapes in one bullet
|
||||
- `skills/larv-review/SKILL.md:66` "Re-entry", better: "Rerun" names its mechanism
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:89` "Architecture": two mechanisms, each with its own trigger and seats, and a three-way rule for the base
|
||||
- `skills/larv-review/SKILL.md:105` "History": two entry shapes, and which commit of a paired entry is the next base
|
||||
- `CHANGELOG.md:5` against `:11`, `:16`, `:19`: two accounts of what blocks a merge
|
||||
- `CLAUDE.md:37` and `:40` "Quality": "comprehension check" undefined, and one sentence packing the floor and the ruling
|
||||
- `skills/comprehension-panel/scoring-run.md:1` "Paired ruling": the name no longer says what is inside
|
||||
- `AGENTS.md:15`: the new decision title packs both mechanisms and the vote rule
|
||||
- `skills/larv-review/SKILL.md:35` and `:64` "Re-entry", better: a rerun traces from the table alone
|
||||
|
||||
## 2026-10-08T18:46:12Z, PR #228 at fbe753e, against c7333c0
|
||||
|
||||
Ruling: same
|
||||
|
||||
| Seat | Vote |
|
||||
|---|---|
|
||||
| Mid A | worse |
|
||||
| Inherited architect | better |
|
||||
| Maintainability senior | same |
|
||||
| Junior A | worse |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:89` "Architecture": two kinds of run under one umbrella, each with its own trigger, and a vote rule to work through by example
|
||||
- `skills/larv-review/SKILL.md:93` "Base": the comparison point found by how earlier chunks appended to the history
|
||||
- `skills/larv-review/SKILL.md:35` the Architecture row: a forward reference to the scoring run's trigger
|
||||
- `CLAUDE.md:37` and `:40` "Quality": one concept under several names, and "the last measured commit" undefined
|
||||
- `skills/comprehension-panel/SKILL.md:102` "The paired ruling": who votes is left to the caller
|
||||
- `skills/comprehension-panel/seat-prompts.md:1`, better: the name tells the truth, and `{forbidden}` serves both briefs
|
||||
- `skills/larv-review/SKILL.md:64` "Re-entry", better: the rerun rule is explicit
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:64` "Re-entry", better: why a pass ran a fourth time is answered in one paragraph
|
||||
- `skills/larv-review/SKILL.md:33` the pass table, better: each pass's rule for fixes sits in its own Trigger cell
|
||||
- `skills/larv-review/SKILL.md:37` and `:123` "Security", better: when each security pass runs
|
||||
- `skills/larv-review/SKILL.md:93` "Base": base selection depends at a distance on the wording of a line in the history format
|
||||
- `skills/larv-review/SKILL.md:35` the Architecture row: a pointer 60 lines down
|
||||
- `skills/larv-review/SKILL.md:95` "Ruling": the vote margin worked out by hand
|
||||
- `CLAUDE.md:37` and `AGENTS.md:16`: one concept, three names
|
||||
|
||||
Maintainability senior, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:89` "Paired ruling": the base defined by an action, and the vote arithmetic
|
||||
- `skills/larv-review/SKILL.md:35` and `:97`: a forward reference, though one definition
|
||||
- `skills/larv-review/SKILL.md:64` "Re-entry", better: deterministic reruns
|
||||
- `skills/larv-review/SKILL.md:59` "Later rounds", better: every rerun reviews only its diff
|
||||
- `skills/comprehension-panel/seat-prompts.md:3`, better: the briefs cannot drift apart
|
||||
- `AGENTS.md:35` "Scoring run": the heading no longer matches its use
|
||||
- `CLAUDE.md:40`: "last measured commit" defined only in larv-review
|
||||
|
||||
Junior A, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:91` "Paired ruling": the base, the escalation and the vote rule in three rereads
|
||||
- `skills/larv-review/SKILL.md:35` the Architecture row: a forward reference to a two-condition rule
|
||||
- `skills/larv-review/SKILL.md:35`, `:51`, `:89`, `CLAUDE.md:37`: four names for the comprehension machinery
|
||||
- `skills/larv-review/SKILL.md:36` the Full scan and Security rows: read together now
|
||||
- `skills/comprehension-panel/seat-prompts.md:8`: placeholders nesting placeholders
|
||||
|
||||
## 2026-10-08T18:57:27Z, PR #228 at 50249b1, against 12d6d75
|
||||
|
||||
Ruling: worse
|
||||
|
||||
| Seat | Vote |
|
||||
|---|---|
|
||||
| Mid A | worse |
|
||||
| Inherited architect | worse |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:93` "Base": a `git log` command, a two-way condition, a forward reference to the history's format and two fallbacks
|
||||
- `skills/larv-review/SKILL.md:89` "Architecture": two kinds of run, four sub-bullets and a vote rule; the section's fan-out roughly doubled
|
||||
- `skills/larv-review/SKILL.md:35`, `:98` and `:120`: one trigger written out three times
|
||||
- `CLAUDE.md:40` "Quality": "the last commit the panel scored or ruled better" reads two ways
|
||||
- `AGENTS.md:35` "Scoring run": the heading no longer names what it feeds
|
||||
- `CHANGELOG.md:5`: ten sentences in one entry
|
||||
- `skills/larv-review/SKILL.md:66` "Re-entry", `:37` and `:124` "Security", `skills/comprehension-panel/seat-prompts.md:7`, better
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:93` "Base": finding the base at 3am takes git archaeology across merge commits
|
||||
- `CHANGELOG.md:5` against `skills/larv-review/SKILL.md:93` and `:107`: only the changelog says a ruling of same leaves the base, so a chunk may be told to fix places it never touched
|
||||
- `skills/larv-review/SKILL.md:95` "Seats" and `:96` "Ruling": the vote table built in the head
|
||||
- `CLAUDE.md:40` "Quality": a folded noun phrase in the charter
|
||||
- `skills/larv-review/SKILL.md:35`, `:98` and `:120`: the trigger three times, and seven concepts where there were three
|
||||
- `AGENTS.md:35` "Scoring run": the heading not renamed with the file
|
||||
- `skills/larv-review/SKILL.md:64` "Re-entry" and `:40` the Prose row, `:37` and `:124` "Security", better
|
||||
|
||||
## 2026-10-08T19:48:05Z, PR #229 at 8a2dbd7, against 12d6d75
|
||||
|
||||
Ruling: worse
|
||||
|
||||
| Seat | Vote |
|
||||
|---|---|
|
||||
| Mid A | worse |
|
||||
| Inherited architect | worse |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:93` "Paired ruling" → "Base": the base found by a prose `git log` search with two fallbacks
|
||||
- `skills/larv-review/SKILL.md:95` "Seats" and "Ruling": vote arithmetic written as prose, with no example
|
||||
- `skills/larv-review/SKILL.md:89` "Architecture": two kinds of run, each with its own trigger, seats and block
|
||||
- `CLAUDE.md:40` "Quality": a clause folded into a noun phrase
|
||||
- `bin/metric_bench/places.py:7` `RUN`, `SEAT_PLACES`, `PLACE` and `:30` `scoring_runs`: a second reader of a format defined only in prose, linked from neither side
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:93` "Paired ruling" → "Base": "worse than what?" means running the base search in your head
|
||||
- `skills/larv-review/SKILL.md:95` "Seats" and "Ruling": a two-stage panel and vote arithmetic with nothing to run or test it
|
||||
- `skills/larv-review/SKILL.md:35`, `:98` "Scoring run" and `:120` "Suspended": the scoring run's trigger written out in four places
|
||||
- `skills/larv-review/SKILL.md:36` the Full scan and Security rows: each row's trigger depends on the other
|
||||
- `bin/metric_bench/places.py:7` `RUN`, `SEAT_PLACES`, `PLACE`: a regex reader of the history linked from neither side
|
||||
- `bin/metric_bench/places.py:59` `resolved`: a result that depends on the place resolved before it
|
||||
- `bin/metric_bench/python_units.py:69` `Cognitive`: nesting bookkeeping spread over its methods
|
||||
|
||||
## 2026-10-08T21:14:15Z, PR #229 at 5cc37dd, against 12d6d75
|
||||
|
||||
Ruling: worse
|
||||
|
||||
| Seat | Vote |
|
||||
|---|---|
|
||||
| Mid A | worse |
|
||||
| Inherited architect | worse |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:93` "Paired ruling" → "Base": a rule over git history, a `git log` command and two fallbacks to hold at once
|
||||
- `CLAUDE.md:40` "Quality": a garden-path sentence read three times
|
||||
- `skills/larv-review/SKILL.md:89` "Architecture": two kinds of run, each with its own trigger, meeting "Fresh", "Suspended" and "Round cap"
|
||||
- `bin/metric_bench/places.py:60` `resolved`: order-dependent, readable only with the history format in mind
|
||||
- `bin/metric_bench/main.py:43` `main`, better: the shape of `bin/reading_cost/main.py`, one for one
|
||||
- `skills/larv-review/SKILL.md:111` "History", better: the format and its reader name each other
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- `skills/larv-review/SKILL.md:93` "Paired ruling" → "Base": the ratchet's outcome rests on state spread across many past commits
|
||||
- `skills/larv-review/SKILL.md:89` "Architecture": one mechanism became two, with different triggers and blocks
|
||||
- `CLAUDE.md:40` "Quality": a clause folded into a noun phrase
|
||||
- `bin/metric_bench/places.py:7` `RUN`, `SEAT_PLACES`, `PLACE` and `:60` `resolved`: a regex reader of a prose format, and a historical quirk to know first
|
||||
- `AGENTS.md:35` "Scoring run": the section's name no longer covers its use by paired rulings
|
||||
- `skills/larv-review/SKILL.md:64` "Re-entry", better: which passes a fix reruns is explicit
|
||||
|
||||
## 2026-10-08T23:12:17Z, PR #231 at 53ed515, against 12d6d75
|
||||
|
||||
Ruling: better
|
||||
|
||||
| Seat | Vote |
|
||||
|---|---|
|
||||
| Mid A | better |
|
||||
| Inherited architect | better |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- `bin/larv_review/rules.py:64` `round_counts`, with `:10` `CAP` and `bin/larv_review/main.py:118` `round_count`, better: a fourth round leads cold to one named function, where the base had only `skills/larv-review/SKILL.md:58` "Count" to carry out by hand
|
||||
- `bin/larv_review/main.py:1` the module docstring, better: the base, round count, trigger, vote rule and seats file are written beside the code that carries them out
|
||||
- `bin/larv_review/rules.py:41` `ruling` and `:27` `votes`, better: the vote rule is a short pure function, changeable without the skill text in mind
|
||||
- `bin/larv_review/git.py:4` the import of `HistoryChange` from rules, with `:50` `history_changes`: the git layer takes its result type from the rules module, so the direction among the three modules is not obvious
|
||||
- `bin/larv_review/history.py:85` `resolved` and `:56` `scoring_runs`: they serve only metric-bench, so old-history path logic sits in the review tool's module
|
||||
- `bin/metric_bench/main.py:143` `git` against `bin/larv_review/git.py:9` `git`: two private git runners with different error handling
|
||||
- `bin/larv_review/rules.py:106` `scoring_run_due`: the densest new unit, two plans, shipped IDs and a flag held at once
|
||||
- `skills/larv-review/SKILL.md:93` "Paired ruling" and `:100` "Scoring run": more vocabulary, though each mechanical step now names a subcommand
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- `bin/larv_review/rules.py:64` `round_counts`, with `bin/larv_review/main.py:118` `round_count`, better: the 3am question leads to `round-count` and one pure function, where the base's `skills/larv-review/SKILL.md:58` "Count" was prose to carry out against `git log`
|
||||
- `bin/larv_review/rules.py:106` `scoring_run_due`, better: the trigger is a checkable function that prints its reason, though dense in its `and`/`or` binding and set arithmetic
|
||||
- `bin/larv_review/main.py:1` the module docstring, better: the history format and ratchet have one tested home; `skills/larv-review/SKILL.md:42` now points at `--help` for the rules
|
||||
- `bin/larv_review/history.py:85` `resolved`, `:56` `scoring_runs` and `:61` `seat_places`: a parser only metric-bench uses, under the review tool's name; where it rots first
|
||||
- `bin/larv_review/git.py:4` the import of `HistoryChange` from rules, and `bin/metric_bench/main.py:143` `git`: a reversed dependency and two git runners
|
||||
- `bin/larv_review/seats.py:7` `SCORING_SEATS` and `SEAT_LINE`, with `bin/larv_review/rules.py:11` `FIRST_SEATS`: seat names spelled in four places
|
||||
- `bin/larv_review/main.py:164` `record` and `bin/larv_review/history.py:52` `entries`: positional regex groups that need `HEADING` open beside them
|
||||
|
||||
## 2026-10-08T23:40:09Z, PR #231 at efed78b, against 12d6d75
|
||||
|
||||
Ruling: worse
|
||||
|
||||
| Seat | Vote |
|
||||
|---|---|
|
||||
| Mid A | worse |
|
||||
| Inherited architect | worse |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- `bin/larv_review/rules.py:105` `scoring_run_due`: set arithmetic over two plans, an `earliest` release and a `landed` flag built in `git.py`, with `or` and `and` unparenthesised, where the base's trigger was one clause at `skills/larv-review/SKILL.md:35`
|
||||
- `bin/larv_review/rules.py:66` `measured_commit` and `:82` `base`: the base comes from diffing the history around each merged change, held with `history.py` `entries` and `git.py` `history_changes` at once
|
||||
- `bin/larv_review/rules.py:16` `votes` and `:34` `ruling`, with `bin/larv_review/seats.py:16` `FIRST_SEATS`: fixed seat order, a split, a lead of two and a placeless vote stacked, where `skills/larv-review/SKILL.md:93` only points at `--help`
|
||||
- `bin/larv_review/main.py:220` `read_seats`: `named.group(3, 4)` depends on `HEADING`'s group positions in `bin/larv_review/history.py:13`
|
||||
- `bin/larv_review/history.py:95` `resolved` and `:66` `scoring_runs`: used only by `bin/metric_bench/main.py:40`, so metric-bench reaches into another tool's package
|
||||
- `bin/larv_review/rules.py:57` `round_counts`, better: the round count is a small named function where the base had prose at `skills/larv-review/SKILL.md:58`
|
||||
- `bin/larv_review/history.py:129` `ruling_entry`, better: the history's format has one owner in code
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- `bin/larv_review/rules.py:105` `scoring_run_due`: set arithmetic whose inputs are built in three other files, where the base's trigger was one table cell at `skills/larv-review/SKILL.md:35`
|
||||
- `bin/larv_review/rules.py:66` `measured_commit` and `:82` `base`: `against is None` doubles as the type tag of `bin/larv_review/history.py:30` `Entry`; the hardest unit at 3am
|
||||
- `bin/larv_review/main.py:220` `read_seats`, with `bin/larv_review/history.py:111` `heading`: a raw `re.Match` whose groups another file reads by position
|
||||
- `bin/larv_review/seats.py:10` `MEAN`, with `bin/larv_review/history.py:111` `heading`: a fake seat standing for a legacy import, threaded through every scoring path
|
||||
- `bin/larv_review/history.py:95` `resolved` and `:66` `scoring_runs`: metric-bench's legacy path rules inside larv-review's package, and two `git` helpers at `bin/metric_bench/main.py:143` and `bin/larv_review/git.py:10`
|
||||
- `bin/larv_review/main.py:1` the module docstring, with `bin/larv_review/rules.py:83` `base`: the base rule stated in several places in different words
|
||||
- `bin/larv_review/rules.py:57` `round_counts`, better: the fourth-round symptom leads to a tested function
|
||||
|
||||
## 2026-10-08T23:48:44Z, PR #231 at c1133ed, against 12d6d75
|
||||
|
||||
Ruling: same
|
||||
|
||||
| Seat | Vote |
|
||||
|---|---|
|
||||
| Mid A | better |
|
||||
| Inherited architect | worse |
|
||||
| Maintainability senior | better |
|
||||
| Junior A | worse |
|
||||
|
||||
Mid A, decided by:
|
||||
|
||||
- `bin/larv_review/rules.py:57` `round_counts`, with `bin/larv_review/main.py:141` `round_count`, better: the fourth-round symptom leads to a short function, where the base had only `skills/larv-review/SKILL.md:58` "Count"
|
||||
- `bin/larv_review/main.py:1` the module docstring, better: each rule stated once beside the code that enforces it, where the base had `skills/larv-review/SKILL.md:92` "History"
|
||||
- `bin/larv_review/history.py:12` `HEADING`, `:58` `entries` and `:128` `entry_text`, better: the history is read and written in one module
|
||||
- `bin/larv_review/main.py:195` `record_scoring`, with `bin/larv_review/seats.py:37` `report` and `bin/larv_review/history.py:93` `heading`: the moved Mean path threads through three files
|
||||
- `bin/larv_review/rules.py:105` `scoring_run_due`, `:119` `emptied` and `:66` `measured_commit`: dense rules that lean on long docstrings
|
||||
- `bin/metric_bench/main.py:38` and `bin/larv_review/git.py:5`: imports across packages
|
||||
|
||||
Inherited architect, decided by:
|
||||
|
||||
- `bin/metric_bench/main.py:38` and `bin/metric_bench/bench.py:7`, with `bin/larv_review/history.py:22` `Place` and `:69` `seat_places`: metric-bench reads its input through larv-review's history module
|
||||
- `bin/larv_review/rules.py:66` `measured_commit`, `:82` `base` and `bin/larv_review/main.py:124` `ruling_base`: three fallbacks to hold at once, where the base's ratchet was one sentence at `skills/larv-review/SKILL.md:100`
|
||||
- `bin/larv_review/rules.py:105` `scoring_run_due` and `:119` `emptied`, with `bin/larv_review/git.py:88` `landed_since_release`: the trigger spread over three files and the help
|
||||
- `bin/larv_review/rules.py:7` the imports, with `bin/rank_todo.py:386` `parse_row`: rank_todo is now a library for larv-review too
|
||||
- `bin/larv_review/seats.py:30` `Report` and `:37` `report`, and `bin/metric_bench/python_units.py:20` `measured`: names that cost a re-read
|
||||
- `bin/larv_review/rules.py:57` `round_counts`, better: the 3am question answerable in code
|
||||
|
||||
Maintainability senior, decided by:
|
||||
|
||||
- `bin/larv_review/rules.py:57` `round_counts`, with `bin/larv_review/main.py:141` `round_count`, better: the 3am symptom lands on a tested unit, where the base had `skills/larv-review/SKILL.md:58` "Count"
|
||||
- `bin/larv_review/main.py:1` the module docstring, better: the base search, round count, trigger and seats file stated once, where the base had `skills/larv-review/SKILL.md:92` "History" and `:100` "Ratchet"
|
||||
- `bin/larv_review/rules.py:66` `measured_commit`, with `bin/larv_review/git.py:66` `history_changes`: the costliest new unit to hold
|
||||
- `bin/larv_review/rules.py:105` `scoring_run_due` and `:119` `emptied`: exact and checkable, but read twice
|
||||
- `bin/larv_review/rules.py:1` the module: six concerns, and `votes` depends on `PLACE` from `bin/larv_review/history.py:14`
|
||||
- `bin/larv_review/main.py:195` `record_scoring`: two inputs threaded through sentinels
|
||||
|
||||
Junior A, decided by:
|
||||
|
||||
- `bin/larv_review/main.py:195` `record_scoring`, with `bin/larv_review/seats.py:44` `report` and `bin/larv_review/history.py:93` `heading`: two modes woven through one function and three files
|
||||
- `bin/larv_review/rules.py:105` `scoring_run_due`, with `:119` `emptied`: needs the release rules from `CLAUDE.md` and `bin/larv_review/git.py:88` `landed_since_release`
|
||||
- `bin/larv_review/rules.py:66` `measured_commit`: `or` and `and` mixed without parentheses, and a new concept to learn first
|
||||
- `bin/larv_review/git.py:5` and `bin/metric_bench/main.py:38`: the git layer depends on the history type, and metric-bench on larv-review's package
|
||||
- `bin/larv_review/main.py:1` the module docstring: one home, but a wall of rules leaning on terms defined elsewhere
|
||||
- `bin/larv_review/rules.py:16` `votes`: a seat protocol reconstructed only from `skills/larv-review/SKILL.md:97`
|
||||
+45
-29
@@ -2,25 +2,25 @@
|
||||
|
||||
## larv-review: a project under the comprehension floor is fixed at the lowest dimension
|
||||
|
||||
2026-09-20, lilleman. Serves goal 4. Across six projects scored with the four seats, Locality or Self-sufficiency was the lowest dimension at every seat and Navigation at none, so a layout fix would not lift a project under the floor. Valid while the scoring run keeps those four seats.
|
||||
2026-09-20, lilleman. Serves goal 1. Across six projects scored with the four seats, Locality or Self-sufficiency was the lowest dimension at every seat and Navigation at none, so a layout fix would not lift a project under the floor. Valid while the scoring run keeps those four seats.
|
||||
|
||||
## loop-claude: a judge decides each interrupt and each quoted answer from the transcript, the README's premises, `AGENTS.md`, `docs/decisions.md` and `~/.claude/CLAUDE.md`, and holds a chunk open while an answer the human typed in it is recorded nowhere; the worker's own account of which goal settles a choice decides nothing
|
||||
|
||||
2026-09-21, lilleman. Serves goal 4. Asked to name the goal behind each choice, the worker cites a real goal for a choice that goal does not settle, and under-reports its own decisions; the judge's bar is whether the README discriminates between the alternatives. Valid while the worker's self-report stays unreliable.
|
||||
2026-09-21, lilleman. Serves goal 1. Asked to name the goal behind each choice, the worker cites a real goal for a choice that goal does not settle, and under-reports its own decisions; the judge's bar is whether the README discriminates between the alternatives. Valid while the worker's self-report stays unreliable.
|
||||
|
||||
2026-10-01, lilleman: the judge reads `docs/decisions.md` and `AGENTS.md` too, so an answer recorded there is not asked again (goal 4.2); its bar becomes whether the README or those files discriminate. 2026-10-03, implemented: when the README's premises or those files answer the worker's question, the judge quotes the answer verbatim and the worker resumes with it. The judge then sees the quote as a `[loop]` line. The worker asking it again shows the quote did not settle it, and the judge sends it to the human. A backstop of three quoted answers per cycle bounds what the judge misses, such as a reworded repeat or a worker asking without end, so the worker cannot loop unattended (goal 4.4); the fourth question that the README's premises or those files answer in one cycle goes to the human with the judge's quote. An interrupt does not reset the count, so every later question those files answer in that cycle also goes to the human. Valid while the worker writes records only in a worktree, as `CLAUDE.md` → "Working with the codebase" has it, so the records the judge reads from the checkout root are merged ones.
|
||||
2026-10-01, lilleman: the judge reads `docs/decisions.md` and `AGENTS.md` too, so an answer recorded there is not asked again (goal 1.2); its bar becomes whether the README or those files discriminate. 2026-10-03, implemented: when the README's premises or those files answer the worker's question, the judge quotes the answer verbatim and the worker resumes with it. The judge then sees the quote as a `[loop]` line. The worker asking it again shows the quote did not settle it, and the judge sends it to the human. A backstop of three quoted answers per cycle bounds what the judge misses, such as a reworded repeat or a worker asking without end, so the worker cannot loop unattended (goal 1.4); the fourth question that the README's premises or those files answer in one cycle goes to the human with the judge's quote. An interrupt does not reset the count, so every later question those files answer in that cycle also goes to the human. Valid while the worker writes records only in a worktree, as `CLAUDE.md` → "Working with the codebase" has it, so the records the judge reads from the checkout root are merged ones.
|
||||
|
||||
2026-10-03, lilleman: the judge is to read `~/.claude/CLAUDE.md` whole too. The worker follows that file, so a question it answers should not reach the human (goal 4.2). Reading the whole file is safe, because the judge may quote only words that appear in it. A list of sections would need keeping current. Implemented the same day.
|
||||
2026-10-03, lilleman: the judge is to read `~/.claude/CLAUDE.md` whole too. The worker follows that file, so a question it answers should not reach the human (goal 1.2). Reading the whole file is safe, because the judge may quote only words that appear in it. A list of sections would need keeping current. Implemented the same day.
|
||||
|
||||
2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 4.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, `~/.claude/CLAUDE.md` included, or where the transcript shows the worker writing it into `README.md`'s premises, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. A worker's write to `~/.claude/CLAUDE.md` does not count: `CLAUDE.md` → "Maintaining this file" leaves new rules in it to the human. The judge cannot read a code comment or `todo.md`. Yet `CLAUDE.md` → "Working loop", "Ask, don't guess" puts a standing choice made in one place in a comment there. And the human's approval of a release's items, which "Working loop" requires, is the set of rows `todo.md` names for that release. The judge also reads the records once a cycle from the main checkout. That checkout may not yet hold an answer the worker wrote and merged. A judge that refused any of these would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a worker whose chunk is held open knows it.
|
||||
2026-10-03, lilleman: the judge rules a chunk finished only once every answer the human typed in it is recorded. A finished chunk's session is deleted, and its answers with it, so an answer recorded nowhere would be asked again in a later chunk (goal 1.2). Implemented the same day by claude, which settled two choices the ruling left open. First, an answer counts as recorded where the files the judge reads hold it, `~/.claude/CLAUDE.md` included, or where the transcript shows the worker writing it into `README.md`'s premises, `AGENTS.md`, `docs/decisions.md`, `todo.md` or a code comment. A worker's write to `~/.claude/CLAUDE.md` does not count: `CLAUDE.md` → "Maintaining this file" leaves new rules in it to the human. The judge cannot read a code comment or `todo.md`. Yet `CLAUDE.md` → "Working loop", "Ask, don't guess" puts a standing choice made in one place in a comment there. And the human's approval of a release's items, which "Working loop" requires, is the set of rows `todo.md` names for that release. The judge also reads the records once a cycle from the main checkout. That checkout may not yet hold an answer the worker wrote and merged. A judge that refused any of these would hold the chunk open every cycle. Second, only an answer a later chunk could need must be recorded, so an approval such as "merge it" holds nothing open. The worker's resume prompt states the rule, so a worker whose chunk is held open knows it.
|
||||
|
||||
## loop-claude: one session per project, its id derived from the checkout's path relative to `~/code`, or to `/` outside it
|
||||
|
||||
2026-09-21, lilleman; revised 2026-09-30 by lilleman. Serves goal 4. One fixed id per project keeps the session picker at one entry per project and makes any transcript under that id loop-claude's own to delete. A checkout outside `~/code` mirroring a path inside it shares that id, and a second loop on it is not refused. Once `todo.md` item 5 lands, the id comes from the full path, so no two checkouts share one, and `loop-claude` refuses to start while another session on that id is active. Moving the checkout orphans its open sessions, archive folder and models entry: sessions stay in the picker until the human deletes them, migration code not being worth a one-human audience. Valid while claude takes `--session-id` and resumes by it.
|
||||
2026-09-21, lilleman; revised 2026-09-30 by lilleman. Serves goal 1. One fixed id per project keeps the session picker at one entry per project and makes any transcript under that id loop-claude's own to delete. A checkout outside `~/code` mirroring a path inside it shares that id, and a second loop on it is not refused. Once `todo.md` item 5 lands, the id comes from the full path, so no two checkouts share one, and `loop-claude` refuses to start while another session on that id is active. Moving the checkout orphans its open sessions, archive folder and models entry: sessions stay in the picker until the human deletes them, migration code not being worth a one-human audience. Valid while claude takes `--session-id` and resumes by it.
|
||||
|
||||
## loop-claude: before an interrupt, it marks the checkout and each of its worktrees trusted in `~/.claude.json`
|
||||
|
||||
2026-09-21, lilleman; the lost-write risk accepted 2026-09-24 by larv-review. Serves goal 4. A write by another claude inside `trust`'s read-modify-write window is lost.
|
||||
2026-09-21, lilleman; the lost-write risk accepted 2026-09-24 by larv-review. Serves goal 1. A write by another claude inside `trust`'s read-modify-write window is lost.
|
||||
|
||||
2026-09-24, lilleman, extending it to every worktree. `claude --resume` re-enters the worktree the worker last entered, recorded in the transcript's `worktree-state` entry, and Claude Code asks trust per path, so trusting the checkout alone still lands the human in the dialog; trusting every worktree `git worktree list` names spares reading which one from the transcript. Valid while resume re-enters a recorded worktree and trust is kept per path.
|
||||
|
||||
@@ -28,17 +28,15 @@
|
||||
|
||||
## bin/: the tests rerun themselves on a `uv`-fetched Python at README Install's floor
|
||||
|
||||
2026-09-26, larv-review. Serves goal 1. The suite reruns itself on a `uv`-fetched interpreter of the version Install names: `ast.parse(feature_version=)` on the host's Python accepts the nested f-string 186181a fixed, a compile check passes a call newer than the floor, like 3.12's `itertools.batched`, and a `python3.N` on `PATH` is installed by hand on every machine and again at each bump. Valid while `uv` can fetch the floor interpreter and no machine taking the checkout ships an older Python.
|
||||
2026-09-26, larv-review. Serves goal 2. The suite reruns itself on a `uv`-fetched interpreter of the version Install names: `ast.parse(feature_version=)` on the host's Python accepts the nested f-string 186181a fixed, a compile check passes a call newer than the floor, like 3.12's `itertools.batched`, and a `python3.N` on `PATH` is installed by hand on every machine and again at each bump. Valid while `uv` can fetch the floor interpreter and no machine taking the checkout ships an older Python.
|
||||
|
||||
## bin/: the tools and their tests run on the host's Python, with no container
|
||||
|
||||
2026-09-24, larv-review. Serves goals 1 and 4. The tools drive the host's claude CLI and read the host's session files, which a container cannot see; the tests run on the same host Python the tools meet. Valid while claude runs on the host.
|
||||
2026-09-24, larv-review. Serves goals 1 and 2. The tools drive the host's claude CLI and read the host's session files, which a container cannot see; the tests run on the same host Python the tools meet. Valid while claude runs on the host.
|
||||
|
||||
## comprehension floor: every dimension and the overall at 7.0 or above, and 0.1.0 waits on it
|
||||
|
||||
2026-09-27, lilleman, restating the 2026-09-24 target and extending it to the overall. Serves goal 4. Valid while the scoring run keeps its four seats. The decisions to ship under the floor, listed below, stand until `todo.md` item 62 lifts the project to it.
|
||||
|
||||
The last scoring run, which the next may not score below (`CLAUDE.md` → "Quality"): PR #215, 2026-10-04, Navigation 7.38, Locality 6.63, Shape 7.0, Self-sufficiency 6.88, overall 6.88.
|
||||
2026-09-27, lilleman, restating the 2026-09-24 target and extending it to the overall. Serves goal 1. Valid while the scoring run keeps its four seats. The decisions to ship under the floor, listed below, stand until `todo.md` item 62 lifts the project to it.
|
||||
|
||||
lilleman decided to ship each of these under the floor on the day listed. Each line gives its last scores (Navigation, Locality, Shape, Self-sufficiency, overall):
|
||||
|
||||
@@ -50,63 +48,81 @@ lilleman decided to ship each of these under the floor on the day listed. Each l
|
||||
- 2026-10-03, PR #202: 7.5, 7.0, 7.0, 6.75, 7.0.
|
||||
- 2026-10-03, PR #208: 7.5, 7.0, 7.13, 6.63, 6.88.
|
||||
- 2026-10-04, PR #215: 7.38, 6.63, 7.0, 6.88, 6.88.
|
||||
- 2026-10-08, PR #224: 7.00, 6.50, 7.00, 6.50, 6.75. lilleman shipped it below the ratchet as well: its 20 lines of skill prose left the code as it was, so the fall is the panel's noise between runs, which the paired ruling cancels.
|
||||
- 2026-10-08, PR #225: 7.25, 6.75, 7.00, 6.88, 6.88. Above PR #224's run on every score but Shape, which held.
|
||||
- 2026-10-08, PR #228: no scoring run; its last paired ruling, against 12d6d75, was worse, 2 votes to 0. lilleman shipped it below the ratchet: the seats blamed the new ratchet's own rules, since moved into the tested `bin/larv-review`.
|
||||
- 2026-10-08, PR #229: no scoring run; its last paired ruling, against 12d6d75, was worse, 2 votes to 0. lilleman shipped it below the ratchet for PR #228's reason: the seats' decisive places were still PR #228's rules, since moved into `bin/larv-review`.
|
||||
|
||||
## loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes
|
||||
|
||||
2026-09-26, lilleman. Serves goal 4. Claude Code rewrites the user settings' `model` whenever one is picked inside a session, so a loop reading settings runs whatever was picked last; `~/.claude/loop-claude-models.json` has loop-claude as its one writer, and every claude it starts gets that model as `--model`. The file is per machine, outside the synced allowlist, since a tracked file the loop writes would dirty the checkout. 2026-10-02, lilleman: goal 1 shares the setup across machines, and a project's model is each machine's own choice, so a new machine asks once per project, which is not asking the same thing twice (goal 4.2). Valid while Claude Code keeps rewriting the settings' model from inside a session.
|
||||
2026-09-26, lilleman. Serves goal 1. Claude Code rewrites the user settings' `model` whenever one is picked inside a session, so a loop reading settings runs whatever was picked last; `~/.claude/loop-claude-models.json` has loop-claude as its one writer, and every claude it starts gets that model as `--model`. The file is per machine, outside the synced allowlist, since a tracked file the loop writes would dirty the checkout. 2026-10-02, lilleman: goal 2 shares the setup across machines, and a project's model is each machine's own choice, so a new machine asks once per project, which is not asking the same thing twice (goal 1.2). Valid while Claude Code keeps rewriting the settings' model from inside a session.
|
||||
|
||||
## review: a pass gets at most three rounds per chunk; instead of a fourth, the run asks the human
|
||||
|
||||
2026-09-28, lilleman. Serves goal 4. One counter per pass per chunk, so no fix bounces between two passes without end. Valid while one human answers the ask, in the session or from the unmerged PR.
|
||||
2026-09-28, lilleman. Serves goal 1. One counter per pass per chunk, so no fix bounces between two passes without end. Valid while one human answers the ask, in the session or from the unmerged PR.
|
||||
|
||||
## review: a fix for a 🟢 or ❓ re-enters review like any fix
|
||||
## review: a fix for a 🔴 or 🟡 reruns the pass that found it and each pass whose trigger names fixes like it; a fix for a 🟢, a ❓ or a prose finding reruns none
|
||||
|
||||
2026-09-30, lilleman. Serves goal 4: no human reads an unattended chunk before it merges, so every change it makes, a nit's wording included, is reviewed. In the 2026-09-30 bench this cost four of nine rounds in one run and drove two passes to the round cap. Valid while a pass is the only reader of a fix before merge.
|
||||
2026-10-08, lilleman, replacing the 2026-09-30 rule that every fix, a nit's included, re-enters review. Serves goal 1.4. An audit of the four costliest archived chunks (2026-10-08) found nearly every finding that mattered in a pass's first round; later rounds mostly re-checked the last fix, reworded what an earlier round wrote, or contradicted another round on the same line. A round 2 caught real bugs only where a fix changed behaviour, so stability still reruns on every fix that does, and security on every fix that opens an untrusted-input boundary or touches authn/authz, secrets or crypto. Valid while round-2 reviews of nit and prose fixes keep changing nothing a user would notice.
|
||||
|
||||
## review: a project decision may suspend the scoring run for the plan items it names
|
||||
## review: a paired ruling against the last measured commit decides the ratchet; the four-seat scoring run checks the floor when a release's items run out or an item names the floor
|
||||
|
||||
2026-10-04, lilleman. Serves goal 4.4. In a restructure, each step's scoring run measures code the next step deletes. It costs a run and, below the floor, blocks the step, yet says nothing about what the restructure buys. The scoring run after the last step measures that. Valid while such a decision names its items and the plan item that ends it.
|
||||
2026-10-08, lilleman. Serves goals 1.1 and 1.4. Two independent four-seat runs moved up to 0.4 on near-identical code, so a fall within that noise forced rounds that changed nothing (PR #224). A seat reading both versions judges the difference on the same material, so the noise the versions share cancels. No conventional significance level lets a sign test settle with four votes, so the human chose a lead of two votes over every other ruling, same included. Two seats that agree settle it, so a PR that leaves the reading as it was costs two seats. A third seat alone can never settle it, so the third and fourth launch together. The base is the default branch's newest merged change that adds a scoring run to the history, or whose last added paired ruling is better. The human chose the last measured commit on the architect's finding that with a merge base as the base, chunks without an architecture pass, and a suspended restructure's steps, could each lower comprehension unseen. A ruling of same leaves the base where it was, or a run of small falls each ruled same would add up unseen. A scoring run moves it too: otherwise a project never ruled better would compare against its first ruling forever, and a release's floor check is where the human sees the absolute level. Reading the default branch one merged change at a time keeps the rule working for merge commits and squash merges alike: a branch's own early ruling of better never counts, only the merged change's last ruling. The scoring run also runs on a chunk shipping an item that names the floor, so the chunk that lifts a project to the floor can prove it. A chunk that removes a release's last item without shipping it runs it too, so no release ends unmeasured. Valid while seats reading both versions agree more often than two absolute runs do.
|
||||
|
||||
## review: a project decision may suspend the comprehension check for the plan items it names
|
||||
|
||||
2026-10-04, lilleman. Serves goal 1.4. In a restructure, each step's scoring run measures code the next step deletes. It costs a run and, below the floor, blocks the step, yet says nothing about what the restructure buys. The scoring run after the last step measures that. 2026-10-08: the paired ruling replaced the scoring run in most chunks, and the suspension covers it too; the ruling after the last step compares with the commit measured before the first step. Valid while such a decision names its items and the plan item that ends it.
|
||||
|
||||
## review: a pass skips only on a precedent: a decision, or a plan item crediting the pass, that the repo held before the chunk began
|
||||
|
||||
2026-09-30, lilleman. Serves goal 4: a decision the chunk writes is the chunk's own and unreviewed, and an unattended run has no human to catch it. Valid while a pass is the only reader of a chunk before merge.
|
||||
2026-09-30, lilleman. Serves goal 1: a decision the chunk writes is the chunk's own and unreviewed, and an unattended run has no human to catch it. Valid while a pass is the only reader of a chunk before merge.
|
||||
|
||||
## loop-claude: the archive keeps the raw transcript, and a failed archive stops the loop
|
||||
|
||||
2026-09-28, lilleman. Serves goals 2 and 4: saving each transcript locally is the first step of backing it up, and it shows afterwards what an unattended run did. A copy of the `.jsonl`, deduplicated by content hash, with its outcomes beside it; a rendering drops tool results, and a second-resolution stamp names two states within one second as one file. A failed archive exits 1, since a loop that loses its record silently fails the backup goal. Valid while transcripts stay small enough to copy whole.
|
||||
2026-09-28, lilleman. Serves goals 1 and 3: saving each transcript locally is the first step of backing it up, and it shows afterwards what an unattended run did. A copy of the `.jsonl`, deduplicated by content hash, with its outcomes beside it; a rendering drops tool results, and a second-resolution stamp names two states within one second as one file. A failed archive exits 1, since a loop that loses its record silently fails the backup goal. Valid while transcripts stay small enough to copy whole.
|
||||
|
||||
## loop-claude: a `claude` that cannot start is a failed worker run, retried
|
||||
|
||||
2026-09-28, larv-review, declining a product-owner nit to exit at once when `claude` is missing. Serves goal 4. Claude Code's updater repoints `~/.local/bin/claude` at each new version under running loops, and a start that meets it mid-update fails with the same error as a broken install; the retry costs two minutes on the second and saves an unattended loop on the first. Valid while Claude Code updates by repointing its link.
|
||||
2026-09-28, larv-review, declining a product-owner nit to exit at once when `claude` is missing. Serves goal 1. Claude Code's updater repoints `~/.local/bin/claude` at each new version under running loops, and a start that meets it mid-update fails with the same error as a broken install; the retry costs two minutes on the second and saves an unattended loop on the first. Valid while Claude Code updates by repointing its link.
|
||||
|
||||
## review: an ask no user answers leaves the PR unmerged
|
||||
|
||||
2026-09-30, claude. Serves goal 4: the round cap, a BLOCK's restructure, Stage 0's questions and a goal conflict are the human's call, and an unmerged PR is what brings it to them; merging would make the call for them. Where an option reviews more — run the pass, fix under the floor, fix a finding no goal lets the run decline — the run takes it; a ❓, or a fix changing a goal or a decision, is filed in `todo.md`, which reaches the human without holding the chunk. Valid while a human reads every unmerged PR an unattended run leaves.
|
||||
2026-09-30, claude. Serves goal 1: the round cap, a BLOCK's restructure, Stage 0's questions and a goal conflict are the human's call, and an unmerged PR is what brings it to them; merging would make the call for them. Where an option reviews more — run the pass, fix under the floor, fix a finding no goal lets the run decline — the run takes it; a ❓, or a fix changing a goal or a decision, is filed in `todo.md`, which reaches the human without holding the chunk. Valid while a human reads every unmerged PR an unattended run leaves.
|
||||
|
||||
## loop-claude: every claude it starts bypasses permissions inside its sandbox
|
||||
|
||||
2026-09-30, lilleman. Applies "Always grant explicit access to data": the sandbox `loop-claude` runs in is where access is granted, so the worker and the interrupt run with `bypassPermissions`. The worker may read `~/.claude/.credentials.json`: it holds Claude Code's own credentials, which claude reads to run anyway. Its one seam to production is the forge: what it pushes or merges can publish through CI. Valid while `loop-claude` runs only in the sandbox README → Install names.
|
||||
|
||||
## review: `/security-review` is the security pass of record
|
||||
## review: `/security-review` is the security pass of record, except where the full scan runs on the same change and replaces it
|
||||
|
||||
2026-09-20, lilleman. Serves goal 4.1. Its value is a tuned exclusion list and a ≥0.8 confidence floor, which a hand-written reviewer would reproduce worse. Valid while `/security-review` ships both.
|
||||
2026-09-20, lilleman. Serves goal 1.1. Its value is a tuned exclusion list and a ≥0.8 confidence floor, which a hand-written reviewer would reproduce worse. Valid while `/security-review` ships both.
|
||||
|
||||
2026-10-08, lilleman. Serves goal 1.4: run beside the full scan, `/security-review` started seconds apart from it each round and returned a near-identical report. Valid while the full scan covers what `/security-review` reports.
|
||||
|
||||
## review: the premises chunk's whole review is the human's approval
|
||||
|
||||
2026-09-20, lilleman. Serves goal 4.1. A reviewer's finding on that chunk could only be declined by citing the goals the chunk exists to write. Valid while every decline must name a goal or a technical principle.
|
||||
2026-09-20, lilleman. Serves goal 1.1. A reviewer's finding on that chunk could only be declined by citing the goals the chunk exists to write. Valid while every decline must name a goal or a technical principle.
|
||||
|
||||
## workflow-bench/: the remote may show the bench cases' names and commit SHAs
|
||||
|
||||
2026-10-02, lilleman. Serves goal 3, which keeps credentials, transcripts and memory files off the remote; a private project's name and commit ids are none of those. Valid while the bench names only cases and commits, never their code or results.
|
||||
2026-10-02, lilleman. Serves goal 4, which keeps credentials, transcripts and memory files off the remote; a private project's name and commit ids are none of those. Valid while the bench names only cases and commits, never their code or results.
|
||||
|
||||
## todo.md: one table of items scored by the formula and goal weights it states, held to its bar, ranked by `bin/rank_todo.py`
|
||||
|
||||
2026-10-02, lilleman. Serves goal 4: findings were filed faster than chunks closed them, so the plan grew without telling what mattered. Each item is scored as `CLAUDE.md` → "Todo items" says; this repo's formula counts value highest and size least. An item under the bar is not kept; this repo's bar started at 10 and was set to 9 the same day, purging the 17 items under it. An Exempt cell keeps a row past the bar where a rule needs it kept. lilleman retired the two decisions whose plans the purge removed: the stats line in the transcript archive, and three benches before a workflow change merges. A finding under the bar is recorded nowhere, so a later review may raise it again, and the run rescores it. That costs one scoring; a ledger of dropped findings would regrow the list the bar caps. larv-review's "Round cap" → "Done" counts a finding named under the bar as settled, so one raised again holds no pass open. `rank_todo.py --check` is part of larv-review's gate, since only a check keeps the stored Score from going stale. The format is mandatory in every project, as the premises are (goal 4.3); the formula, bar and weights are each project's own. A script ranks the table so a re-rank after each addition or edit is deterministic and cheap. A 🟡 against a technical principle is exempt as `principle`, because its audience value scores low and the bar would drop every one. A 🟢 against a principle is scored like any other finding. Valid while one human sets the bar and reads the ranking, and while the items marked `principle` stay few enough to rank.
|
||||
2026-10-02, lilleman. Serves goal 1: findings were filed faster than chunks closed them, so the plan grew without telling what mattered. Each item is scored as `CLAUDE.md` → "Todo items" says; this repo's formula counts value highest and size least. An item under the bar is not kept; this repo's bar started at 10 and was set to 9 the same day, purging the 17 items under it. An Exempt cell keeps a row past the bar where a rule needs it kept. lilleman retired the two decisions whose plans the purge removed: the stats line in the transcript archive, and three benches before a workflow change merges. A finding under the bar is recorded nowhere, so a later review may raise it again, and the run rescores it. That costs one scoring; a ledger of dropped findings would regrow the list the bar caps. larv-review's "Round cap" → "Done" counts a finding named under the bar as settled, so one raised again holds no pass open. `rank_todo.py --check` is part of larv-review's gate, since only a check keeps the stored Score from going stale. The format is mandatory in every project, as the premises are (goal 1.3); the formula, bar and weights are each project's own. A script ranks the table so a re-rank after each addition or edit is deterministic and cheap. A 🟡 against a technical principle is exempt as `principle`, because its audience value scores low and the bar would drop every one. A 🟢 against a principle is scored like any other finding. 2026-10-08, lilleman: the goal weights in `todo.md` depart from an even spread by position, which would weigh goal 4, leaking nothing, at 0.11. Valid while one human sets the bar and reads the ranking, and while the items marked `principle` stay few enough to rank.
|
||||
|
||||
## settings.json: Claude Code runs in auto mode with the dangerous-mode prompt skipped
|
||||
|
||||
2026-10-04, lilleman, answering the principles audit of PR #215. Serves goal 4: this setup is meant to run in a sandbox and to work autonomously, so tool access is granted by the sandbox, as "Always grant explicit access to data" in `principles/technical-principles.md` asks. Valid while every machine taking this checkout is such a sandbox.
|
||||
2026-10-04, lilleman, answering the principles audit of PR #215. Serves goal 1: this setup is meant to run in a sandbox and to work autonomously, so tool access is granted by the sandbox, as "Always grant explicit access to data" in `principles/technical-principles.md` asks. Valid while every machine taking this checkout is such a sandbox.
|
||||
|
||||
## the repo may name bender, bender-infra and ai-sandbox
|
||||
|
||||
2026-10-04, lilleman, answering the principles audit of PR #215. Serves goal 3, which keeps credentials, transcripts and memory files off the remote; the names of the host, its infrastructure project and the sandbox VM are none of those. Valid while the repo names them without their addresses or credentials.
|
||||
2026-10-04, lilleman, answering the principles audit of PR #215. Serves goal 4, which keeps credentials, transcripts and memory files off the remote; the names of the host, its infrastructure project and the sandbox VM are none of those. Valid while the repo names them without their addresses or credentials.
|
||||
|
||||
## reading cost: larv-review measures each finished chunk from loop-claude's archive and appends the figure to `docs/reading-cost.md` in the next chunk's PR
|
||||
|
||||
2026-10-08, lilleman. Serves goal 1.1: comprehension measured from real work, at no model cost (goal 1.4). loop-claude archives from the main checkout, outside any PR, so a tracked file it wrote there would dirty that checkout. So `bin/reading-cost` measures each finished chunk `docs/reading-cost.md` lacks from the archive, in the next chunk's worktree. A PR that never merges then loses no figure, and loop-claude needs no change. The figures keep a file of their own, so `docs/comprehension-history.md` keeps one writer, the comprehension check. Serves goal 4 by naming only files git tracks, and token counts. Rejected: loop-claude opening a PR of its own, one more PR per chunk and a tie to the forge; the worker measuring its own transcript before merging, which misses the chunk's tail. The figure counts new input tokens, uncached and cache-written, because workers read mostly through Bash and subagents, where parsed paths alone miss what they read. Valid while loop-claude archives every finished chunk with its subagents' transcripts.
|
||||
|
||||
## reading cost: a rise is the last 5 chunks' median above the 5 before them, and files or refreshes one plan item
|
||||
|
||||
2026-10-08, lilleman. Serves goal 1.1: comprehension never falls, so any rise counts. Per-chunk figures are noisy: a flat trend rises about every other chunk. So a rise refreshes the item and never refiles it, and a chunk that sees no rise leaves the item as it is. The chunk that ships the item resets the trend, so later figures do not refile it for work that chunk already did (goal 1.4). A median, because one chunk that ran a panel of readers before its first commit measured 2.99M tokens against a typical 80k–370k, and a mean let it decide the trend alone. No published standard sets this threshold. Valid while figures arrive once per chunk.
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# Reading cost
|
||||
|
||||
## Reading cost, chunk 049a6293013b, finished 2026-10-04T10:18:42Z
|
||||
|
||||
115833 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `bin/test_loop_claude.py` 6
|
||||
- `bin/test_loop_claude_black_box.py` 6
|
||||
- `docs/decisions.md` 3
|
||||
- `todo.md` 3
|
||||
- `bin/loop_claude/loop/main.py` 2
|
||||
- `AGENTS.md` 1
|
||||
- `CHANGELOG.md` 1
|
||||
- `README.md` 1
|
||||
- `bin/loop-claude` 1
|
||||
- `bin/loop_claude/cycle/judge_reply.py` 1
|
||||
|
||||
## Reading cost, chunk 3654f457da26, finished 2026-10-04T15:04:37Z
|
||||
|
||||
62197 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `docs/decisions.md` 4
|
||||
- `skills/comprehension-panel/SKILL.md` 4
|
||||
- `CLAUDE.md` 2
|
||||
- `AGENTS.md` 1
|
||||
- `CHANGELOG.md` 1
|
||||
- `README.md` 1
|
||||
- `skills/comprehension-panel/scoring-run.md` 1
|
||||
- `skills/larv-review/SKILL.md` 1
|
||||
- `todo.md` 1
|
||||
|
||||
## Reading cost, chunk 12210530d1d1, finished 2026-10-04T15:17:47Z
|
||||
|
||||
80898 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `bin/test_loop_claude.py` 8
|
||||
- `bin/test_loop_claude_black_box.py` 5
|
||||
- `bin/loop_claude/loop/main.py` 4
|
||||
- `bin/loop-claude` 2
|
||||
- `todo.md` 2
|
||||
- `CHANGELOG.md` 1
|
||||
- `README.md` 1
|
||||
- `bin/loop_claude/cycle/judge.py` 1
|
||||
- `bin/loop_claude/cycle/judge_reply.py` 1
|
||||
- `bin/loop_claude/cycle/run.py` 1
|
||||
|
||||
## Reading cost, chunk 8f69670791e6, finished 2026-10-04T18:30:08Z
|
||||
|
||||
49451 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `docs/decisions.md` 2
|
||||
- `CHANGELOG.md` 1
|
||||
- `README.md` 1
|
||||
- `agents/principles-auditor.md` 1
|
||||
- `principles/frontend.md` 1
|
||||
- `principles/logging.md` 1
|
||||
- `principles/rest-apis.md` 1
|
||||
- `principles/technical-principles.md` 1
|
||||
- `skills/larv-review/SKILL.md` 1
|
||||
- `skills/larv-review/review-findings.md` 1
|
||||
|
||||
## Reading cost, chunk 3979e0345234, finished 2026-10-04T20:25:40Z
|
||||
|
||||
56802 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `README.md` 2
|
||||
- `docs/decisions.md` 2
|
||||
- `todo.md` 2
|
||||
- `.gitignore` 1
|
||||
- `AGENTS.md` 1
|
||||
- `CHANGELOG.md` 1
|
||||
- `agents/stability-reviewer.md` 1
|
||||
- `agents/systems-architect.md` 1
|
||||
- `principles/technical-principles.md` 1
|
||||
- `skills/larv-review/SKILL.md` 1
|
||||
|
||||
## Reading cost, chunk b4eea97f6667, finished 2026-10-07T10:37:56Z
|
||||
|
||||
46081 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `README.md` 2
|
||||
- `agents/stability-reviewer.md` 2
|
||||
- `CHANGELOG.md` 1
|
||||
- `agents/systems-architect.md` 1
|
||||
- `skills/larv-review/SKILL.md` 1
|
||||
- `todo.md` 1
|
||||
|
||||
## Reading cost, chunk 90755de2f601, finished 2026-10-08T13:29:17Z
|
||||
|
||||
50762 new input tokens before the first commit.
|
||||
|
||||
Read most (opens and searches):
|
||||
|
||||
- `docs/decisions.md` 3
|
||||
- `.gitignore` 1
|
||||
- `AGENTS.md` 1
|
||||
- `CHANGELOG.md` 1
|
||||
- `README.md` 1
|
||||
- `skills/larv-review/SKILL.md` 1
|
||||
- `skills/larv-review/review-findings.md` 1
|
||||
- `todo.md` 1
|
||||
@@ -61,9 +61,9 @@
|
||||
- An import sorts on its first binding, not its path, so moving or renaming a module reorders nothing. Where lines already group by kind — type imports, host packages — the key sorts within each group.
|
||||
* Keep It Simple, Stupid (KISS): keep solutions simple, so a reader new to the project understands each part on one read.
|
||||
- Keep a size or complexity limit only while the comprehension panel's readers (`~/.claude/skills/comprehension-panel/`) find the code it flags hard.
|
||||
* Don't Repeat Yourself (DRY): one authoritative home per piece of knowledge, one obvious way per need.
|
||||
* Don't Repeat Yourself (DRY) is a guide, not an absolute rule. It aims at one authoritative home per piece of knowledge, one obvious way per need. Before applying it, ask whether the code would be easier to understand, easier to reason about, or easier to maintain if DRY were broken; if so, break it, so long as the spellings cannot disagree (below). A surface people write — a template, data, an API — may accept a second spelling where that makes it easier to use.
|
||||
- A value, rule, definition or concept lives in one place, and everywhere else derives it from there or points at it. A copy that can drift is a second spelling: derive it from its owner, or, for config a human writes, reject it where it is read and name the owner.
|
||||
- Before adding a way to do something, find the existing one and use it. The same goes for tests: extend an existing test with an assertion before writing a new one. Where two spellings serve the same caller for the same need, keep one and reject the other as early as possible — at load, parse or compile — with an error naming the one to use: `token {p} renders a level that {p.first} reads a path into; name the fields you want instead`.
|
||||
- Before adding a way to do something, find the existing one and use it. The same goes for tests: extend an existing test with an assertion before writing a new one. Where two spellings serve the same caller for the same need, keep one and reject the other as early as possible — at load, parse or compile — with an error naming the one to use: `token {p} renders a level that {p.first} reads a path into; name the fields you want instead`. A second spelling that makes a surface people write easier to use stays (above).
|
||||
- Different needs may have different ways. A public API may offer a convenience beside the general form — a one-line call for the common case over the primitive for the rest — where each serves a caller or scenario its docs name, and the convenience is built from the primitive. Code that looks alike but encodes different knowledge is not a second spelling: merging it is the wrong abstraction.
|
||||
- Two spellings that can disagree are a correctness bug, whatever the reason for having both: derive one from the other, or reject the combination.
|
||||
* All critical flows should have good traces, from where something was initiated until it completed.
|
||||
|
||||
@@ -95,9 +95,17 @@ the end. Tell everyone not to manufacture confusion.
|
||||
|
||||
A scoring run needs four seats — Junior A, Mid A, the maintainability senior and the inherited
|
||||
architect — plus the calibration seat ("The score") when more than one project is in play. Build
|
||||
the four seats' prompts from `scoring-run.md`, filled in from the project's `AGENTS.md` → "Scoring
|
||||
the four seats' prompts from `seat-prompts.md`, filled in from the project's `AGENTS.md` → "Scoring
|
||||
run". Change neither between runs, or the scores are not comparable. A project without that
|
||||
section gets it at its first scoring run.
|
||||
section gets it at its first scoring run or paired ruling.
|
||||
|
||||
## The paired ruling
|
||||
|
||||
A paired ruling asks whether a change makes a project read better, the same or worse. Each seat
|
||||
reads both versions, so what the two versions share cannot move the ruling. Check out the older
|
||||
version as a detached worktree in your scratchpad, and remove it afterwards. Build each seat's
|
||||
prompt from `seat-prompts.md` → "Paired ruling"; the seats and the rule for adding one are the
|
||||
caller's.
|
||||
|
||||
## What the seven report
|
||||
|
||||
|
||||
+34
-5
@@ -1,10 +1,12 @@
|
||||
# The scoring run's seat prompts
|
||||
# The comprehension seats' prompts
|
||||
|
||||
Each seat's prompt is the four parts below, in order: the opening, the seat's background, the shared brief, and the report for its kind of seat. Copy the text verbatim and replace each `{placeholder}`:
|
||||
A scoring-run seat's prompt is the opening, the seat's background, the shared brief, and the report for its kind of seat, in that order. Copy the text verbatim and replace each `{placeholder}`:
|
||||
|
||||
- `{checkout}` and `{branch}`: the worktree the seats read, and its branch.
|
||||
- `{main}`: the project's main checkout.
|
||||
- `{files}`: every tracked non-test file but `todo.md` and `docs/decisions.md`, from `git -C {checkout} ls-files`, listed as one recursive glob per top-level source directory, such as `bin/loop_claude/**/*.py`.
|
||||
- `{forbidden}`: `todo.md, docs/decisions.md, docs/comprehension-history.md or docs/reading-cost.md (the plan, the decision log, past panels' records and past chunks' reading cost)`.
|
||||
- `{git}`: `git -C {checkout} ls-files`, and for a paired seat also `git -C {base checkout} ls-files`, each in backticks.
|
||||
- `{files}`: every tracked non-test file but those `{forbidden}` names, from `git -C {checkout} ls-files`, listed as one recursive glob per top-level source directory, such as `bin/loop_claude/**/*.py`.
|
||||
- `{preloaded}`: the files the harness pre-loads into a seat, found per `SKILL.md` → "What makes the result trustworthy".
|
||||
- `{anchors}` and `{dimensions}`: the six anchor bullets and the four dimension bullets in `SKILL.md` → "The score", verbatim, without bold and each on one line.
|
||||
- `{language}`, `{kind}`, `{domain}`, `{domain docs}` and `{3am question}`: the project's `AGENTS.md` → "Scoring run".
|
||||
@@ -12,7 +14,7 @@ Each seat's prompt is the four parts below, in order: the opening, the seat's ba
|
||||
## Opening
|
||||
|
||||
```
|
||||
You are one seat of a comprehension panel. Tools: Read, Grep, Glob, and Bash only for `git -C {checkout} ls-files` and `ls`. Never write, edit, run, build or test anything.
|
||||
You are one seat of a comprehension panel. Tools: Read, Grep, Glob, and Bash only for {git} and `ls`. Never write, edit, run, build or test anything.
|
||||
```
|
||||
|
||||
## Backgrounds
|
||||
@@ -27,7 +29,7 @@ You are one seat of a comprehension panel. Tools: Read, Grep, Glob, and Bash onl
|
||||
```
|
||||
Target: the project checked out at {checkout} (branch `{branch}`). Read ONLY there — never {main}, which is a different version.
|
||||
|
||||
Depth 1, the whole project: read README.md, AGENTS.md and CLAUDE.md (the charter), then every non-test tracked file: {files}. Do NOT open todo.md or docs/decisions.md (the plan and decision log), nor any review output. You may open a test file when the code does not answer a question; say when you did.
|
||||
Depth 1, the whole project: read README.md, AGENTS.md and CLAUDE.md (the charter), then every non-test tracked file: {files}. Do NOT open {forbidden}, nor any review output. You may open a test file when the code does not answer a question; say when you did.
|
||||
|
||||
Your harness pre-loads these files into your context before your first tool call, from a DIFFERENT version (main): {preloaded}. Treat the worktree's own copies as the ones under review. A pre-loaded AGENTS.md may list decision titles; do not use them as evidence.
|
||||
|
||||
@@ -63,3 +65,30 @@ Enforce this order:
|
||||
3. Read enough implementation to check the map (depth 1: every non-test file is in scope, but your job is shape).
|
||||
Report: the verbatim map; where it was wrong and how costly each correction was; level-by-level fan-out with the worst level named; names that mislead, concepts with two names, one name over two concepts, areas you could not name; what you would restructure, ranked, with files and costs; what the structure gets right. The 3am question: {3am question} — walking in cold, how long to the right file and unit? Where does it rot first, and where would the next two features land? Close with Navigation, Locality, Shape, Self-sufficiency and overall, each with one sentence naming its anchor and the concrete thing holding it there.
|
||||
```
|
||||
|
||||
## Paired ruling
|
||||
|
||||
A paired seat's prompt is the opening, the seat's background, and the paired brief below. Its placeholders besides those above:
|
||||
|
||||
- `{base}` and `{head}`: the commits of the older and the newer version; `{base checkout}`: the worktree holding `{base}`.
|
||||
- `{changed}`: the output of `git -C {checkout} diff --name-status {base} {head}`, less the files `{forbidden}` names.
|
||||
|
||||
```
|
||||
Target: two versions of one project. The older, commit {base}, is checked out at {base checkout}; the newer, commit {head}, at {checkout}. Read ONLY there — never {main}, which is a different version.
|
||||
|
||||
Depth 1, the whole project in both versions: read README.md, AGENTS.md and CLAUDE.md (the charter), then every non-test tracked file at {checkout}: {files}. These files differ between the versions; read each at {base checkout} too, where it exists there:
|
||||
{changed}
|
||||
Do NOT open {forbidden}, nor any review output. You may open a test file when the code does not answer a question; say when you did.
|
||||
|
||||
Your harness pre-loads these files into your context before your first tool call, from main, which may match either version or neither: {preloaded}. Treat the two worktrees' own copies as the ones under review. A pre-loaded AGENTS.md may list decision titles; do not use them as evidence.
|
||||
|
||||
No running anything, no builds, no tests, no edits of any kind.
|
||||
|
||||
Rule whether the project as a whole reads better, the same or worse at {head} than at {base}, judged on these four dimensions:
|
||||
{dimensions}
|
||||
Same means a reader of either version would find it as easy to understand and change. Do not manufacture a difference.
|
||||
|
||||
Report, in this shape:
|
||||
1. Your ruling: better, same or worse.
|
||||
2. The places that decided it, most decisive first. Each: path:line and the unit's name, in the version the place is in, and one or two sentences on what reads easier or harder there than in the other version. A better or worse ruling with no named place is discarded.
|
||||
```
|
||||
+42
-19
@@ -24,45 +24,50 @@ Words: `~/.claude/CLAUDE.md` → "Vocabulary". What a reviewer reports: ~/.claud
|
||||
|
||||
Follow `~/.claude/CLAUDE.md` → "Git, commits, and PRs". Never commit to the default branch. Commit, push with upstream set, and open a **draft** PR so CI cycles while the review runs. No remote → review locally and say so in the summary.
|
||||
|
||||
**Reading cost.** Run `~/.claude/bin/reading-cost` in the chunk's worktree and commit what it appends to `docs/reading-cost.md`; the commit re-enters no pass. Resolve a merge conflict in that file by putting the default branch's figures first and dropping a figure for a chunk the default branch already holds. On `Rising:`, file a plan item titled `**Lower the reading cost of the files a chunk reads most before its first commit.**`, scored per `~/.claude/CLAUDE.md` → "Todo items" with the tool's medians and files as its detail; where the plan already holds it, refresh its detail instead. The item names the next release, or the one after when this chunk ships the next release's last item. On exit 1, repair what its message names and run it again; when the message names no repair, file it as a `question` item, or refresh the question item an earlier run filed, and go on. Leave the plan as it is on any other output. The chunk that ships that item runs the tool with `--reset` instead, so the next rise is measured on chunks that finished after it.
|
||||
|
||||
## 3. Passes
|
||||
|
||||
A pass is one kind of review, a row of the table, named by its first column. Its trigger says when it runs on a change it has not seen; its reviewer reports the findings.
|
||||
|
||||
| Pass | Reviewer | Trigger |
|
||||
|------|----------|----------------------------------------|
|
||||
| Architecture | systems-architect, then principles-auditor and the scoring run | ships its release's last item, or carries an architectural decision: a new, restructured or moved component, module, service or boundary; a new dependency or first use of an infrastructure pattern (queue, cron, cache, websocket, …); a new or changed external contract (routes, request/response shapes, events, webhooks, published file formats, CLI flags and exit codes); a schema change beyond an additive column |
|
||||
| Security | `/security-review` | changes code or config; a fix, only where it opens an untrusted-input boundary or touches authn/authz, secrets or crypto |
|
||||
| Architecture | systems-architect, then principles-auditor and the comprehension check | is due a scoring run ("Architecture" → "Scoring run"); or carries an architectural decision: a new, restructured or moved component, module, service or boundary; a new dependency or first use of an infrastructure pattern (queue, cron, cache, websocket, …); a new or changed external contract (routes, request/response shapes, events, webhooks, published file formats, CLI flags and exit codes); a schema change beyond an additive column; a fix, only where it carries an architectural decision |
|
||||
| Full scan | the `claude-security` plugin at high effort: `/claude-security scan this branch's changes at high` | touches authn/authz, secrets or crypto, opens an untrusted-input boundary, or adds an external surface |
|
||||
| Security | `/security-review` | changes code or config, unless the full scan runs on the same change; a fix, only where it opens an untrusted-input boundary or touches authn/authz, secrets or crypto, and the full scan does not rerun on it |
|
||||
| Stability | stability-reviewer | changes code, config or tests; a fix, only where it changes behaviour: what the code or its tests do |
|
||||
| Product-owner | product-owner-reviewer | changes an external surface: API, CLI, UI, error or deprecation text a consumer reads, README and docs an outside reader lands on |
|
||||
| Prose | prose-reviewer | every chunk; a fix, where it touches prose |
|
||||
| Prose | prose-reviewer | every chunk, one round |
|
||||
|
||||
A comment is prose, not code. Passes run in this order: line-level polish on code the architect wants restructured, or on a call the security pass will rewrite, is wasted work.
|
||||
|
||||
Give a reviewer without Bash the branch diff and `git ls-files`'s output in its prompt: some harnesses grant it Read alone.
|
||||
|
||||
`~/.claude/bin/larv-review` holds this section's mechanical rules: the round count, the paired ruling's base and vote count, the scoring run's trigger and the history's format. Run it in the chunk's worktree; `~/.claude/bin/larv-review --help` states each rule. On exit 1, repair what its message names and run it again; when you cannot, ask the user.
|
||||
|
||||
**Precedent, then ask** — for the architecture pass and the full scan:
|
||||
|
||||
- **Skip.** A precedent is a `docs/decisions.md` entry, or a plan item crediting the pass, that the repo held before the chunk began. Where one holds the decision this change executes, skip the pass and cite that entry or item.
|
||||
- **Departure.** A change that departs from the precedent is unreviewed, however thorough the precedent is.
|
||||
- **Ask.** Fired and not skipped → ask the user whether to run it, with the evidence and your recommendation; no user reachable → run it. For the full scan, give the evidence and your recommendation, then launch it: the plugin asks the user to confirm its cost, and that prompt is the ask.
|
||||
- **Audit.** A precedent or the user's no skips only the architect, never the principles audit: no precedent checked the code this chunk writes. The scoring run skips only as "Architecture" → "Suspended" says.
|
||||
- **Audit.** A precedent or the user's no skips only the architect, never the principles audit: no precedent checked the code this chunk writes. The comprehension check skips only as "Architecture" → "Suspended" says.
|
||||
|
||||
**Round cap.**
|
||||
|
||||
- **Round.** A round is one launch of a pass's reviewer: the first, each re-entry, and the rerun after the architect returns Stage 0 questions ("Architecture" below).
|
||||
- **Architecture round.** The architecture pass's first round is the architect (unless skipped), the principles audit and the scoring run, which "Architecture" → "Suspended" may skip. A later round relaunches the scoring run, where one ran, and each reviewer whose 🔴 or 🟡 the previous round's fixes answer. Where those fixes carry an architectural decision, the whole round runs again, the architect included.
|
||||
- **Round.** A round is one launch of a pass's reviewer: the first, each re-entry, and the rerun after the architect returns Stage 0 questions ("Architecture" below). A rescore is a round only as "Architecture" → "Fresh" says.
|
||||
- **Architecture round.** The architecture pass's first round is the architect (unless skipped), the principles audit and the comprehension check, which "Architecture" → "Suspended" may skip. A later round relaunches each reviewer whose 🔴 or 🟡 the previous round's fixes answer, the comprehension check only as "Architecture" → "Fresh" says. Where those fixes carry an architectural decision, the architect and the principles audit run again.
|
||||
- **Auto-reviewer.** The external auto-reviewer (§4) is a pass of its own, each review it posts a round.
|
||||
- **Count.** Close each round with one commit that holds the round's fixes and is titled `Answer <pass> round <n>: …`, `<pass>` being the pass's name in lower case, such as `full scan`. A round that changed nothing gets an empty commit (`git commit --allow-empty`). Push the commits when §4 runs next, where there is a remote. A pass's count is the highest `<n>` among titles holding `Answer <pass> round <n>:` in `git log origin/<default branch>..HEAD` after a `git fetch`, or in `git log <default branch>..HEAD` with no remote. The auto-reviewer's count is the number of its reviews on the PR.
|
||||
- **Later rounds.** From round 2, prompt an agent under `~/.claude/agents/` with its own last round's findings verbatim and what changed since: `git diff <the commit that round reviewed> HEAD`, since the fixes may be unpushed.
|
||||
- **Done.** A pass is done when its latest round leaves no 🔴 or 🟡 standing: none was reported, or each was shown factually wrong, declined, filed, or named under the bar per "Findings". Resolve that round's 🟢s and ❓s per "Findings" too.
|
||||
- **Count.** Close each round with one commit that holds the round's fixes and is titled `Answer <pass> round <n>: …`, `<pass>` being the pass's name in lower case, such as `full scan`. A round that changed nothing gets an empty commit (`git commit --allow-empty`). Push the commits when §4 runs next, where there is a remote. `~/.claude/bin/larv-review round-count` prints each pass's count and marks a pass at the cap. The auto-reviewer's count is the number of its reviews on the PR, less its reviews of a `Rescore:` commit.
|
||||
- **Later rounds.** A rerun pass reviews only what changed since it last reviewed: `git diff <the commit it last reviewed, or else the commit before this round's fixes> HEAD`, since the fixes may be unpushed. The comprehension check's seats still read the whole project. From round 2, prompt an agent under `~/.claude/agents/` with its own last round's findings verbatim too.
|
||||
- **Done.** A pass is done when its latest round leaves no 🔴 or 🟡 standing: none was reported, or each was shown factually wrong, declined, filed, or named under the bar per "Findings", or, for the prose pass, fixed. Resolve that round's 🟢s and ❓s per "Findings" too.
|
||||
- **Cap.** A pass takes at most three rounds per chunk. Instead of a fourth, list what is open and ask the user. For the auto-reviewer, ask before the push that would summon its fourth, and hold the fixes unpushed until the answer.
|
||||
- **Answer.** A yes grants that pass one more round, after which the ask repeats; a no leaves the PR unmerged.
|
||||
|
||||
**Re-entry.**
|
||||
|
||||
- **Fix.** A fix is a change no pass has seen, a 🟢's or ❓'s included.
|
||||
- **Rerun.** A round's fixes re-enter together: run, in table order, each pass whose trigger they fire, a done pass included, and each pass whose 🔴 or 🟡 they answer; a pass at its cap gets "Round cap" → "Cap"'s ask instead. Then §4.
|
||||
- **Fix.** A fix is a change no pass has seen.
|
||||
- **Rerun.** A round's fixes for 🔴 and 🟡 findings outside the prose pass re-enter together. Run, in table order, each pass whose 🔴 or 🟡 they answer, and each pass whose trigger has an "a fix, only where …" clause they meet, a done pass included. A pass at its cap gets "Round cap" → "Cap"'s ask instead. Then §4.
|
||||
- **No rerun.** A fix for a 🟢, a ❓ or any prose finding reruns no pass. Its commit still calls for a rescore per "Architecture" → "Fresh".
|
||||
|
||||
**Findings.** A reviewer rates each finding 🔴 must fix, 🟡 should fix, 🟢 nit, ❓ question, or 🔀 escalation naming the reviewer whose concern it is.
|
||||
|
||||
@@ -83,24 +88,42 @@ Launch systems-architect: review the system as a whole entered through this chan
|
||||
|
||||
Then the principles audit: one principles-auditor for the README's goals, and one per file in `~/.claude/principles/` whose `Applies to` line the project meets, judged from the README, `git ls-files` and the branch diff. A file without the line applies to every project. Unsure → launch it.
|
||||
|
||||
Then the comprehension floor, which the scoring run measures. Four simulated readers — Junior A, Mid A, the maintainability senior and the inherited architect — each read the whole project, not the diff, and score it from 1 to 10 overall and on four dimensions: Navigation, Locality, Shape and Self-sufficiency. A seat's overall may not exceed its lowest dimension by more than 1. Each score is the mean of the four seats, to two decimals. Launch the seats per `~/.claude/skills/comprehension-panel/SKILL.md` → "The scoring run".
|
||||
Then the comprehension check: simulated readers, launched per `~/.claude/skills/comprehension-panel/SKILL.md`, each read the whole project, not the diff. It has two kinds of run.
|
||||
|
||||
The project's `docs/decisions.md` keeps one entry whose title opens `comprehension floor:`. It holds the last scoring run's scores, and each decision to ship under the floor, with its scores.
|
||||
**Paired ruling**, in every architecture pass. Each seat votes whether the project reads better, the same or worse at this branch's head than at the base.
|
||||
|
||||
- **Base.** The last measured commit, which `~/.claude/bin/larv-review ruling-base` prints.
|
||||
- **Head.** Before each ruling, merge `origin/<default branch>` into this branch unless the head already holds it, so the seats see only this branch's change on top of the base.
|
||||
- **Seats.** Mid A and the inherited architect. Write what they read and their replies into a seats file in your scratchpad, in the shape `~/.claude/bin/larv-review --help` shows, and run `~/.claude/bin/larv-review record-ruling <file>`. On `Split:`, launch the maintainability senior and Junior A together, add their lines, and run it again.
|
||||
- **Ruling.** The `Ruling:` line `record-ruling` prints and appends to the history.
|
||||
|
||||
**Scoring run**, when `~/.claude/bin/larv-review needs-scoring-run <the IDs of the items the chunk ships, if any>` prints `Scoring run due:`. Run `needs-scoring-run` before removing the chunk's items from `todo.md`. Junior A, Mid A, the maintainability senior and the inherited architect each score the project at the head from 1 to 10 overall and on four dimensions: Navigation, Locality, Shape and Self-sufficiency. Write their lines into a seats file and run `~/.claude/bin/larv-review record-scoring <file>`, which appends the run to the history and prints the four seats' means.
|
||||
|
||||
The chunk does not merge while either holds:
|
||||
|
||||
- **Floor.** Any dimension or the overall is below 7.0.
|
||||
- **Ratchet.** Any score is below the entry's last scoring run as it stands on the default branch, even within the panel's noise. An equal score passes, and so does every run while the default branch has no entry.
|
||||
- **Ratchet.** The paired ruling is worse.
|
||||
- **Floor.** `record-scoring` names a mean under the floor of 7.0.
|
||||
|
||||
Fix the places the seats name under the lowest dimension and under each dimension that fell. When only the floor holds, the user may decide to ship instead. A decision that lets every chunk ship under the floor, held in the project's `docs/decisions.md` before the chunk began, counts as theirs while it stands. A decision to ship listed in the `comprehension floor:` entry covers only the chunk it names. No user reachable → fix. A fall is never shipped without the user: after three rounds, "Round cap" → "Cap" asks them.
|
||||
Each is a 🔴 of the comprehension check. It is never filed, and stands until a later run clears it or, for the floor, a decision to ship answers it.
|
||||
|
||||
Put each run's five scores in the summary, and replace the entry's last scoring run with them on this branch. List in the entry each decision to ship under the floor, and file its places in `todo.md` per `~/.claude/CLAUDE.md` → "Todo items". A project without the entry gets it at its first scoring run, titled `comprehension floor: every dimension and the overall at 7.0 or above` and applying KISS (`~/.claude/principles/technical-principles.md`).
|
||||
Fix a worse ruling at the places the seats voting worse name, and the floor at the places the seats name under the lowest dimension. Under the floor alone, the user may decide to ship instead. A decision that lets every chunk ship under the floor, held in the project's `docs/decisions.md` before the chunk began, counts as theirs while it stands. A decision to ship listed in the `comprehension floor:` entry covers only the chunk it names. No user reachable → fix. A worse ruling never ships: after three rounds, "Round cap" → "Cap" asks the user for another round.
|
||||
|
||||
**Suspended.** A decision in the project's `docs/decisions.md`, held before the chunk began, may name plan items to ship without a scoring run. A named item counts as `todo.md` worded it before the chunk began. The decision must name the later plan item whose chunk ends the suspension with a scoring run. A chunk may ship named items only with each other. Such a chunk skips the scoring run, so neither the floor nor the ratchet can block it, and its summary cites the decision. A chunk shipping its release's last item runs the scoring run, even when every item it ships is named.
|
||||
Two files of the project keep the records:
|
||||
|
||||
- **History.** `docs/comprehension-history.md` keeps every paired ruling and scoring run, which `larv-review` appends; never edit one. Appending re-enters no pass. Resolve a merge conflict in the file by putting the default branch's entries first.
|
||||
- **Entry.** `docs/decisions.md` keeps one entry whose title opens `comprehension floor:`. It holds each decision to ship under the floor, with its scores.
|
||||
|
||||
A `comprehension floor:` entry written before the history may still hold a scoring run's five scores. The next scoring run moves them, and only them, into the history as its first run. Write a seats file of two lines and run `~/.claude/bin/larv-review record-scoring` on it. The first line is `<the date or time the entry gives>, <what the entry names the run by> at <commit>`, the commit being the one the entry names, or else the one that wrote those scores into it. The second is `Mean:` and the five scores, in the shape `--help` shows. The rest of the entry stays.
|
||||
|
||||
Put each ruling with its base and votes, and each run's five scores, in the summary. List in the entry each decision to ship under the floor, and file its places in `todo.md` per `~/.claude/CLAUDE.md` → "Todo items". A project without the entry gets it at its first scoring run, titled `comprehension floor: every dimension and the overall at 7.0 or above` and applying KISS (`~/.claude/principles/technical-principles.md`).
|
||||
|
||||
**Fresh.** Where the chunk ran a comprehension check, the architecture pass is done only once its last paired ruling, and its last scoring run where it ran one, read the commit to merge. They may predate commits that change only `docs/decisions.md`, `docs/comprehension-history.md`, `docs/reading-cost.md`, `todo.md` or `CHANGELOG.md`. Any other commit after them, a prose fix included, because the seats read the docs, calls for a rescore: the comprehension check again, once every other pass is done, the auto-reviewer included. A rescore reporting a 🔴 that no decision to ship answers is an architecture round. Any other rescore is not a round: append only its results to the history, in a commit titled `Rescore: …`. A `Rescore:` commit re-enters no pass: push it and wait for the forge's checks (§4 step 3), not for an auto-review.
|
||||
|
||||
**Suspended.** A decision in the project's `docs/decisions.md`, held before the chunk began, may name plan items to ship without a comprehension check. A named item counts as `todo.md` worded it before the chunk began. The decision must name the later plan item whose chunk ends the suspension with a comprehension check. A chunk may ship named items only with each other. Such a chunk skips the comprehension check, so neither the ratchet nor the floor can block it, and its summary cites the decision. A chunk due a scoring run runs it, even when every item it ships is named.
|
||||
|
||||
### Security
|
||||
|
||||
`/security-review` over the branch diff is the pass of record. Launch a general-purpose subagent that invokes it through the Skill tool, edits nothing, and replies with the skill's report, or that the skill is unavailable. Invoked in your own context, the skill ends your turn on that report.
|
||||
`/security-review` over the branch diff is the pass of record, except where the full scan runs on the same change and replaces it. Where the full scan fires but does not run — skipped on a precedent, declined at its cost prompt, or unavailable — `/security-review` runs. Launch a general-purpose subagent that invokes it through the Skill tool, edits nothing, and replies with the skill's report, or that the skill is unavailable. Invoked in your own context, the skill ends your turn on that report.
|
||||
|
||||
A verified HIGH inside this chunk's blast radius is fixed here, outside it on its own branch and PR with this chunk waiting behind it. Say which.
|
||||
|
||||
|
||||
@@ -6,43 +6,49 @@
|
||||
|
||||
`Bar = 9`
|
||||
|
||||
`Next ID = 72`
|
||||
`Next ID = 86`
|
||||
|
||||
| Goal | W |
|
||||
|---|---|
|
||||
| 1 | 1.00 |
|
||||
| 2 | 0.89 |
|
||||
| 3 | 0.78 |
|
||||
| 4 | 0.67 |
|
||||
| 4.1 | 0.56 |
|
||||
| 4.2 | 0.44 |
|
||||
| 4.3 | 0.33 |
|
||||
| 4.4 | 0.22 |
|
||||
| 4.5 | 0.11 |
|
||||
| 1.1 | 0.99 |
|
||||
| 1.2 | 0.98 |
|
||||
| 1.3 | 0.97 |
|
||||
| 1.4 | 0.96 |
|
||||
| 1.5 | 0.95 |
|
||||
| 2 | 0.90 |
|
||||
| 3 | 0.85 |
|
||||
| 4 | 0.80 |
|
||||
|
||||
## Items
|
||||
|
||||
| ID | Release | Exempt | Item | R | S | A | G | Goals | Score |
|
||||
|---|---|---|---|---|---|---|---|---|---|
|
||||
| 1 | 0.1.0 | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 3 | 5 | 8 | 9 | 2, 3 | 27.8 |
|
||||
| 60 | 0.1.0 | | **Rerun the scoring run before merge whenever a fix landed after the last scoring run, and count a score under the floor or the ratchet as the scoring run's 🔴.** | 3 | 3 | 6 | 7 | 4.1 | 16.1 |
|
||||
| 62 | 0.1.0 | defect | **Lift Locality, Self-sufficiency and the overall to the comprehension floor, at the places the seats name.** | 4 | 6 | 6 | 8 | 4.1 | 15.5 |
|
||||
| 65 | 0.1.0 | | **Archive each judge reply the loop rejects.** | 3 | 4 | 4 | 5 | 2 | 12.9 |
|
||||
| 21 | 0.1.0 | | **Give `settings.json`'s model one writer, and sort its keys.** | 3 | 3 | 6 | 7 | 4.3 | 12.9 |
|
||||
| 49 | 0.1.0 | principle | **Check that `AGENTS.md` lists exactly the titles of `docs/decisions.md`.** | 1 | 2 | 5 | 6 | 4.3 | 12.5 |
|
||||
| 12 | 0.1.0 | | **Run the test suite in CI on every PR, or record in `docs/decisions.md` why the local run is enough.** | 2 | 4 | 4 | 6 | 4.1 | 11.7 |
|
||||
| 59 | 0.1.0 | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 3 | 3 | 6 | 6 | 4.4 | 10.9 |
|
||||
| 5 | 0.1.0 | decision | **Key a project on its checkout's full path, and refuse to start while another session uses that key.** | 5 | 5 | 5 | 6 | 4.1 | 10.5 |
|
||||
| 66 | 0.1.0 | principle | **Hold systems-architect's method thresholds only while the comprehension panel finds the flagged code hard.** | 3 | 3 | 4 | 5 | 4.1 | 9.9 |
|
||||
| 4 | 0.1.0 | | **Name each chunk's archive folder by the chunk's start time, so `<key>/` lists chunks in the order they ran.** | 3 | 2 | 4 | 3 | 2 | 9.8 |
|
||||
| 50 | 0.1.0 | principle | **Grant the bench's runs only the tools a review needs, in place of skipping every permission.** | 2 | 2 | 3 | 4 | 3 | 9.7 |
|
||||
| 69 | 0.1.0 | principle | **Measure test coverage, so a chunk that lowers it is seen.** | 3 | 4 | 4 | 5 | 4.1 | 9.6 |
|
||||
| 29 | 0.1.0 | | **Make the contributor a standing member of every project's audience, unless its `## Audience` says maintainability does not matter.** | 2 | 2 | 3 | 5 | 4.1, 4.4 | 9.1 |
|
||||
| 68 | 0.1.0 | principle | **Test `workflow-bench/compare.py`'s blinding and `bench.py`'s run plan.** | 2 | 4 | 3 | 5 | 4.1 | 8.6 |
|
||||
| 67 | 0.1.0 | principle | **Point stability-reviewer at the technical principles in place of its own restatement of them.** | 2 | 3 | 4 | 5 | 4.3 | 8.6 |
|
||||
| 52 | 0.1.0 | principle | **Record why this checkout lives in Claude Code's own directory, or move it out and link it in.** | 6 | 6 | 3 | 5 | 1 | 8.5 |
|
||||
| 6 | 0.1.0 | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 5 | 5 | 4 | 5 | 4.1 | 7.4 |
|
||||
| 51 | 0.1.0 | principle | **Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.** | 3 | 5 | 3 | 5 | 4.1 | 7.4 |
|
||||
| 1 | 0.1.0 | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 3 | 5 | 8 | 9 | 3, 4 | 27.0 |
|
||||
| 62 | 0.1.0 | defect | **Lift Locality, Self-sufficiency and the overall to the comprehension floor, at the places the seats name.** | 4 | 6 | 6 | 8 | 1.1 | 22.3 |
|
||||
| 21 | 0.1.0 | | **Give `settings.json`'s model one writer, and sort its keys.** | 3 | 3 | 6 | 7 | 1.3 | 21.8 |
|
||||
| 49 | 0.1.0 | principle | **Check that `AGENTS.md` lists exactly the titles of `docs/decisions.md`.** | 1 | 2 | 5 | 6 | 1.3 | 20.1 |
|
||||
| 59 | 0.1.0 | | **Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.** | 3 | 3 | 6 | 6 | 1.4 | 19.8 |
|
||||
| 12 | 0.1.0 | | **Run the test suite in CI on every PR, or record in `docs/decisions.md` why the local run is enough.** | 2 | 4 | 4 | 6 | 1.1 | 16.9 |
|
||||
| 80 | 0.1.0 | | **State in README → Install that every machine taking this checkout must be a sandbox, as `settings.json`'s auto mode assumes.** | 1 | 1 | 5 | 5 | 4 | 16.8 |
|
||||
| 83 | 0.1.0 | | **Group `bin/` by tool, so each tool's modules and tests sit together.** | 3 | 4 | 4 | 6 | 1.1 | 15.9 |
|
||||
| 5 | 0.1.0 | decision | **Key a project on its checkout's full path, and refuse to start while another session uses that key.** | 5 | 5 | 5 | 6 | 1.1 | 15.6 |
|
||||
| 84 | 0.1.0 | | **Check, at each release's scoring run, that seats in a paired ruling agree more often than two scoring runs on near-identical code do, as the paired-ruling decision assumes.** | 2 | 2 | 4 | 5 | 1.4 | 15.1 |
|
||||
| 67 | 0.1.0 | principle | **Point stability-reviewer at the technical principles in place of its own restatement of them.** | 2 | 3 | 4 | 5 | 1.3 | 14.9 |
|
||||
| 66 | 0.1.0 | principle | **Hold systems-architect's method thresholds only while the comprehension panel finds the flagged code hard.** | 3 | 3 | 4 | 5 | 1.1 | 14.2 |
|
||||
| 69 | 0.1.0 | principle | **Measure test coverage, so a chunk that lowers it is seen.** | 3 | 4 | 4 | 5 | 1.1 | 13.9 |
|
||||
| 29 | 0.1.0 | | **Make the contributor a standing member of every project's audience, unless its `## Audience` says maintainability does not matter.** | 2 | 2 | 3 | 5 | 1.1, 1.4 | 13.4 |
|
||||
| 68 | 0.1.0 | principle | **Test `workflow-bench/compare.py`'s blinding and `bench.py`'s run plan.** | 2 | 4 | 3 | 5 | 1.1 | 12.9 |
|
||||
| 65 | 0.1.0 | | **Archive each judge reply the loop rejects.** | 3 | 4 | 4 | 5 | 3 | 12.5 |
|
||||
| 82 | 0.1.0 | principle | **Sort `AGENTS.md`'s decision titles and `docs/decisions.md`'s entries by title.** | 1 | 2 | 3 | 4 | 1.3 | 12.3 |
|
||||
| 73 | 0.1.0 | | **Have each reviewer write its full report to a file and return the worker only its findings' one-line summaries.** | 3 | 4 | 4 | 4 | 1.4 | 11.7 |
|
||||
| 6 | 0.1.0 | decision | **Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.** | 5 | 5 | 4 | 5 | 1.1 | 11.7 |
|
||||
| 51 | 0.1.0 | principle | **Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.** | 3 | 5 | 3 | 5 | 1.1 | 11.7 |
|
||||
| 50 | 0.1.0 | principle | **Grant the bench's runs only the tools a review needs, in place of skipping every permission.** | 2 | 2 | 3 | 4 | 4 | 9.9 |
|
||||
| 81 | 0.1.0 | principle | **Have `workflow-bench/bench.py` return each run's failure as a value, so one failed clone does not hide the later runs' results.** | 2 | 2 | 3 | 4 | 4 | 9.9 |
|
||||
| 4 | 0.1.0 | | **Name each chunk's archive folder by the chunk's start time, so `<key>/` lists chunks in the order they ran.** | 3 | 2 | 4 | 3 | 3 | 9.6 |
|
||||
| 52 | 0.1.0 | principle | **Record why this checkout lives in Claude Code's own directory, or move it out and link it in.** | 6 | 6 | 3 | 5 | 2 | 7.5 |
|
||||
| 77 | 0.2.0 | | **Teach `bin/metric-bench` Go and TypeScript, rerun it once two projects' comprehension histories name places, and bring into review only a metric that tracks the panel.** | 3 | 6 | 6 | 7 | 1.1, 1.4 | 21.4 |
|
||||
|
||||
## Details
|
||||
|
||||
@@ -52,19 +58,13 @@ It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost
|
||||
|
||||
2026-10-02, the human: ai-sandbox is the VM `loop-claude` will run on, hosted on the server bender. bender-infra, the infrastructure-as-code project that manages bender, will back up ai-sandbox's data volume once ai-sandbox is rebuilt. The item waits for the human to say the rebuild has landed; do not remind them. Before writing the README line, check that `~/.claude` lives on that volume and that the backup is private and encrypted at rest.
|
||||
|
||||
The README line covers the bench's transcripts in `workflow-bench/logs/` too (goal 2).
|
||||
|
||||
### 60. Rerun the scoring run before merge whenever a fix landed after the last scoring run, and count a score under the floor or the ratchet as the scoring run's 🔴.
|
||||
|
||||
Raised by the systems-architect review of PR #215. A stability, product-owner, prose or auto-reviewer fix reruns no scoring run unless it carries an architectural decision or answers an architecture 🔴 or 🟡. It merges unscored, so the `comprehension floor:` entry records scores for an earlier commit, and the next chunk's ratchet inherits a fall it did not cause. "Round cap" → "Done" and "Re-entry" → "Rerun" count only 🔴 and 🟡, and nothing makes a score under the floor one. A commit that only edits `docs/decisions.md`, `todo.md` or `CHANGELOG.md` needs no rerun.
|
||||
The README line covers the bench's transcripts in `workflow-bench/logs/` too (goal 3).
|
||||
|
||||
### 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 4.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.
|
||||
|
||||
### 65. Archive each judge reply the loop rejects.
|
||||
|
||||
Goal 2, raised by the principles audit of PR #215: the judge runs with `--no-session-persistence`, and the first two rejected replies reach only stderr, so the archive cannot answer the 3am question of why the loop rejected a verdict.
|
||||
PR #225's last run, at 8c9bf09, put Locality at 6.75 and Self-sufficiency and the overall at 6.88. Its seats named: the judge's policy spread over `loop/main.py`'s docstring, `cycle/judge_reply.py`'s `JUDGE_RULES`, `cycle/judge.py`'s `judge_prompt` and `cycle/worker.py`'s `worker_args`; `loop_claude/claude_code/` and the read side of `transcript_archive.py`, which `bin/reading_cost/` also imports; two meanings of a checkout's root in `project/checkout.py`'s `checkout_root` and `reading_cost/main.py`'s `located`; and `skills/larv-review/SKILL.md` §3's round count, which only prose enforces.
|
||||
|
||||
### 21. Give `settings.json`'s model one writer, and sort its keys.
|
||||
|
||||
@@ -76,49 +76,72 @@ Every write Claude Code makes to the file rewrites `"model"`, `claude plugin ins
|
||||
|
||||
DRY, in `principles/technical-principles.md`: the list is copied by hand, and sessions work from the copy.
|
||||
|
||||
### 59. Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.
|
||||
|
||||
Raised by the product-owner review of PR #211. The resumed worker gets the judge's quote of the work remaining, but a worker that still thinks the chunk done can answer each cycle the same way, and each cycle costs a worker and a judge run (goal 1.4).
|
||||
|
||||
### 12. Run the test suite in CI on every PR, or record in `docs/decisions.md` why the local run is enough.
|
||||
|
||||
The repo has no CI, so larv-review's gate is the local run, and larv-review's Gate skips even that when the last stability round left the suite green: an unattended chunk can merge on the worker's own word.
|
||||
|
||||
### 59. Bound a run of unfinished verdicts on one chunk, so a worker and judge that disagree cannot cycle unattended without end.
|
||||
### 80. State in README → Install that every machine taking this checkout must be a sandbox, as `settings.json`'s auto mode assumes.
|
||||
|
||||
Raised by the product-owner review of PR #211. The resumed worker gets the judge's quote of the work remaining, but a worker that still thinks the chunk done can answer each cycle the same way, and each cycle costs a worker and a judge run (goal 4.4).
|
||||
Raised by the principles audit of PR #224. The `settings.json` decision is valid while every machine taking this checkout is a sandbox, but Install asks for a sandbox only for `loop-claude`, so a new machine is never told.
|
||||
|
||||
### 83. Group `bin/` by tool, so each tool's modules and tests sit together.
|
||||
|
||||
Raised by the architect on PR #225 and by the inherited architect of PR #224's scoring run: `bin/` is one flat folder of tools, the modules they share and the repo's checks, with `loop_claude`'s tests beside them instead of beside the package. `loop_claude/claude_code/` parses Claude Code's own formats and `bin/reading_cost/measure.py` imports it too, so it is a package of its own.
|
||||
|
||||
### 5. Key a project on its checkout's full path, and refuse to start while another session uses that key.
|
||||
|
||||
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` 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` never looks. Derive both keys one way.
|
||||
|
||||
### 84. Check, at each release's scoring run, that seats in a paired ruling agree more often than two scoring runs on near-identical code do, as the paired-ruling decision assumes.
|
||||
|
||||
Raised by the principles audit of PR #228: the `review: a paired ruling …` entry in `docs/decisions.md` is valid only while that holds, and `docs/comprehension-history.md` keeps every vote, yet nothing reads the agreement rate. Scoring runs on near-identical code are rare now, so compare with those already in the history, such as PR #224's and PR #225's, or make a second run for the check.
|
||||
|
||||
### 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.
|
||||
|
||||
### 66. Hold systems-architect's method thresholds only while the comprehension panel finds the flagged code hard.
|
||||
|
||||
KISS, in `principles/technical-principles.md`, which keeps a limit only while readers find the flagged code hard. `agents/systems-architect.md` makes cyclomatic 7 and 24 lines gate rules from the first commit, a 🔴 unless a reason is stated.
|
||||
|
||||
### 4. Name each chunk's archive folder by the chunk's start time, so `<key>/` lists chunks in the order they ran.
|
||||
|
||||
Today the folder is the SHA-256 of the transcript's first timestamped line, which tells the human nothing; that line carries the start time. Drop the fallback to the first line, which every chunk of a project shares, and give the tests' fake transcripts ISO timestamps.
|
||||
|
||||
### 50. Grant the bench's runs only the tools a review needs, in place of skipping every permission.
|
||||
|
||||
"Always grant explicit access to data", in `principles/technical-principles.md`: `workflow-bench/bench.py` starts claude with `--dangerously-skip-permissions`, and no rule confines it to a sandbox, so a run on the host reaches the host's credentials and other checkouts.
|
||||
|
||||
### 69. Measure test coverage, so a chunk that lowers it is seen.
|
||||
|
||||
"Test coverage should not decline", in `principles/technical-principles.md`: nothing reports coverage, so a chunk that deletes a test or adds untested code passes unseen.
|
||||
|
||||
### 29. Make the contributor a standing member of every project's audience, unless its `## Audience` says maintainability does not matter.
|
||||
|
||||
State that in `CLAUDE.md`'s goals-and-audience rule, and have larv-review's comprehension floor name the contributor as the reader it serves. The floor then gates every chunk while the contributor stands, and a project that drops them skips it.
|
||||
State that in `CLAUDE.md`'s goals-and-audience rule, and have larv-review's comprehension floor name the contributor as the reader it serves. The floor's block then applies to a project whose audience includes the contributor, and a project that drops them skips it.
|
||||
|
||||
### 68. Test `workflow-bench/compare.py`'s blinding and `bench.py`'s run plan.
|
||||
|
||||
"Most, if not all, code should have automated tests", in `principles/technical-principles.md`: `compare.blind()` keeps the comparison blind, and a version name it misses invalidates the bench silently.
|
||||
|
||||
### 67. Point stability-reviewer at the technical principles in place of its own restatement of them.
|
||||
### 65. Archive each judge reply the loop rejects.
|
||||
|
||||
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.
|
||||
Goal 3, raised by the principles audit of PR #215: the judge runs with `--no-session-persistence`, and the first two rejected replies reach only stderr, so the archive cannot answer the 3am question of why the loop rejected a verdict.
|
||||
|
||||
### 52. Record why this checkout lives in Claude Code's own directory, or move it out and link it in.
|
||||
### 82. Sort `AGENTS.md`'s decision titles and `docs/decisions.md`'s entries by title.
|
||||
|
||||
"One owner per value" and "Prefer the vendor-neutral option", in `principles/technical-principles.md`: git, Claude Code and loop-claude all write `~/.claude`, kept apart only by the `.gitignore` allowlist, and the repo's records live in a vendor directory.
|
||||
"Deterministic order", in `principles/technical-principles.md`, raised by the principles audit of PR #224: their order carries no meaning, so two chunks adding a decision conflict at the end, and a reader cannot find a title by scanning.
|
||||
|
||||
### 73. Have each reviewer write its full report to a file and return the worker only its findings' one-line summaries.
|
||||
|
||||
2026-10-08, lilleman: rescored from A10/G8 to A4/G4 on the measurement below, so other items that lower token use go first.
|
||||
|
||||
Measured over the 68 transcripts in loop-claude's archive on 2026-10-08, matching each Agent call to its tool result and to any `<task-notification>` naming its tool-use id. No report reached the worker twice: 813 arrived once as the hand-back, and 363 once as a notification after Claude Code ran the agent in the background. Reports took a median 19k tokens per chunk, 8% of the worker's peak context (24% at most). Lines carrying a severity mark are 9–24% of a reviewer's report, and the worker would still open the file for each 🔴 or 🟡 it fixes. A third of the report volume is the comprehension seats', whose votes and places the worker copies into the history. File reads fill more of the worker's context: `sed -n` output is 30% of its Bash results and `grep` output 11%, which `reading-cost` targets.
|
||||
|
||||
The reports would live in the session's scratchpad, such as `<scratchpad>/larv-review/prose-round-1.md`, so no project's checkout sees them. A later round gets the path of that pass's earlier report in place of the findings pasted in. How a report reaches the file:
|
||||
|
||||
- **Write access.** Grant each reviewer Write. No reviewer under `agents/` holds it today, an agent's tool list cannot confine Write to one folder, and `~/.claude/CLAUDE.md` → "Working with the codebase" denies edits to a reviewer that only reads. Check whether a PreToolUse hook can tell a subagent's call from the worker's and deny a Write outside the scratchpad.
|
||||
- **A wrapper.** A general-purpose subagent launches the reviewer, saves the report and returns only the summary lines. Claude Code's documentation says a subagent cannot start another; drop this route unless a test shows one can.
|
||||
|
||||
This risks goal 1.1: a worker fixing from a one-line summary can miss context it needs.
|
||||
|
||||
### 6. Move what `loop-claude` writes out of `~/.claude.json`, and ask the human about each write that must stay.
|
||||
|
||||
@@ -127,3 +150,49 @@ Claude Code owns that file and writes it. `trust` reads it, changes it and write
|
||||
### 51. Hand loop-claude's terminal output to an injected effect, so no storage or retry function prints.
|
||||
|
||||
"Functional core, imperative shell", in `principles/technical-principles.md`: `archive`, `trust`, `retried`, the worker, `interrupt` and `model_choice` print to stderr themselves, and the tests swap the global stream.
|
||||
|
||||
### 50. Grant the bench's runs only the tools a review needs, in place of skipping every permission.
|
||||
|
||||
"Always grant explicit access to data", in `principles/technical-principles.md`: `workflow-bench/bench.py` starts claude with `--dangerously-skip-permissions`, and no rule confines it to a sandbox, so a run on the host reaches the host's credentials and other checkouts.
|
||||
|
||||
### 81. Have `workflow-bench/bench.py` return each run's failure as a value, so one failed clone does not hide the later runs' results.
|
||||
|
||||
"Errors as values", in `principles/technical-principles.md`, raised by the principles audit of PR #224: `bench.py` raises `KeyError` and `CalledProcessError`, and `pool.map` re-raises the first while the other threads run on unreported.
|
||||
|
||||
### 4. Name each chunk's archive folder by the chunk's start time, so `<key>/` lists chunks in the order they ran.
|
||||
|
||||
Today the folder is the SHA-256 of the transcript's first timestamped line, which tells the human nothing; that line carries the start time. Drop the fallback to the first line, which every chunk of a project shares, and give the tests' fake transcripts ISO timestamps. `bin/reading-cost` takes a chunk's id from the folder's first 12 characters and skips a chunk whose id `docs/reading-cost.md` holds, so give it a way to match a figure written under the old name.
|
||||
|
||||
### 52. Record why this checkout lives in Claude Code's own directory, or move it out and link it in.
|
||||
|
||||
"One owner per value" and "Prefer the vendor-neutral option", in `principles/technical-principles.md`: git, Claude Code and loop-claude all write `~/.claude`, kept apart only by the `.gitignore` allowlist, and the repo's records live in a vendor directory.
|
||||
|
||||
### 77. Teach `bin/metric-bench` Go and TypeScript, rerun it once two projects' comprehension histories name places, and bring into review only a metric that tracks the panel.
|
||||
|
||||
2026-10-08, lilleman: no metric enters review until a rerun on more data shows it tracking the panel.
|
||||
|
||||
Before the rerun, set the AUC and top-k lift over chance that count as tracking, from a published threshold, so the rerun ends in a decision. The rerun needs places from a project in Go or TypeScript, the languages most other projects use, so the bench first measures those languages, run through each project's own tooling. Function and file length stay warnings to look into, never limits: a plain long function can be simple, and a hard one may need five-line pieces.
|
||||
|
||||
On 2026-10-08 only this repo's history named places: five scoring runs, all that day. The medians:
|
||||
|
||||
| Metric | AUC | Top k |
|
||||
|---|---|---|
|
||||
| Cognitive complexity | 0.66 | 0.26 |
|
||||
| Length | 0.74 | 0.18 |
|
||||
| Shared state | constant | constant |
|
||||
| Change spread | 0.67 | 0.18 |
|
||||
|
||||
AUC is 0.5 for a coin toss, and top k scores 0.10 by chance. Shared state cannot be judged here: every unit in `bin/` scores 0 on it. Every run's first place was a section of `skills/larv-review/SKILL.md`, which no code metric sees.
|
||||
|
||||
On 2026-10-09 a question bench asked a headless claude, allowed only Read, Grep and Glob, three questions a script answers from the syntax tree: which units call a unit, which units it calls, and which test files refer to it. It asked them about every unit the history names whose name is unique, plus as many units the history does not name. Five of the history's six scoring runs named such a unit. The tool is in commit 083cc78; it was deleted after the run.
|
||||
|
||||
Claude's misses ranked the named units at a coin toss. Top k scores 0.50 by chance on these units:
|
||||
|
||||
| Metric | AUC | Top k |
|
||||
|---|---|---|
|
||||
| Question misses | 0.49 | 0.50 |
|
||||
| Cognitive complexity | 0.66 | 0.59 |
|
||||
| Length | 0.75 | 0.69 |
|
||||
| Change spread | 0.57 | 0.54 |
|
||||
|
||||
Claude's answers overlapped the truth by a median Jaccard index of 0.76. A run took in 62,643 new input tokens and cost $0.70; it did not record which model answered. Grep answers these questions whatever the code's shape, so no question enters review; a new question bench would need questions that take understanding the code, not finding it.
|
||||
|
||||
@@ -16,7 +16,7 @@ Report: write it to `{report}`.
|
||||
- Launch every agent in the foreground (`run_in_background: false`): background agents die when this headless turn ends.
|
||||
- No remote and no forge: skip the PR, CI, the external auto-reviewer and the merge; review locally.
|
||||
- Do not run the repo's test suites. A targeted probe is fine, in the repo's own container tooling.
|
||||
- Skip the comprehension floor's scoring run; say so in the report.
|
||||
- Skip the comprehension check; say so in the report.
|
||||
- No human is reachable. Where the process names a no-human branch, take it; where it names none, take your recommendation and list the question in the report.
|
||||
- Commit each round's fixes on `chunk`, messages prefixed `{case} - review: `. Touch nothing outside this repository except the report.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user