From f51900106faac50237ae7d0f501ff9e195e3fdb7 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 09:36:57 +0200 Subject: [PATCH 01/11] Rewrite the status line in Python, and test it --- .gitignore | 2 +- README.md | 4 +- bin/statusline.py | 122 +++++++++++++++++++++++++++++++++++++++++ bin/test_statusline.py | 89 ++++++++++++++++++++++++++++++ bin/test_types.py | 4 +- settings.json | 2 +- statusline.sh | 115 -------------------------------------- todo.md | 1 - 8 files changed, 217 insertions(+), 122 deletions(-) create mode 100755 bin/statusline.py create mode 100644 bin/test_statusline.py delete mode 100755 statusline.sh diff --git a/.gitignore b/.gitignore index 808964d7..da30a316 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,6 @@ !CLAUDE.md !README.md !settings.json -!statusline.sh !todo.md !.claude/ @@ -22,6 +21,7 @@ !bin/loop_claude/ !bin/loop_claude/**/ !bin/loop_claude/**/*.py +!bin/statusline.py !bin/test_*.py !docs/ !docs/*.md diff --git a/README.md b/README.md index 85228e4d..974426c8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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 every project to; `docs/` for decisions; `settings.json` for the harness and `.claude/settings.json` for the harness inside this repo; `statusline.sh`; `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 every project 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/`, the status line among them; and `workflow-bench/`, the scripts and prompts of the 2026-09-30 bench of larv-review. ## Goals @@ -20,7 +20,7 @@ Me, on my own machines, which take tagged releases. Nobody else depends on it. ## Install -Check out the latest tag in `~/.claude`, with Python 3.11 or newer as `python3` on `PATH`, and `jq` and GNU `date` for `statusline.sh`. Link the tool onto `PATH`: `ln -s ~/.claude/bin/loop-claude ~/.local/bin/loop-claude`. Run it only in a sandbox with no direct access to a production environment, such as a dedicated VM: every claude it starts, the interrupt included, skips every permission prompt. +Check out the latest tag in `~/.claude`, with Python 3.11 or newer as `python3` on `PATH`. Link the tool onto `PATH`: `ln -s ~/.claude/bin/loop-claude ~/.local/bin/loop-claude`. Run it only in a sandbox with no direct access to a production environment, such as a dedicated VM: every claude it starts, the interrupt included, skips every permission prompt. ## Release diff --git a/bin/statusline.py b/bin/statusline.py new file mode 100755 index 00000000..3babd0de --- /dev/null +++ b/bin/statusline.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python3 +import datetime +import json +import math +import os +import subprocess +import sys +import time +import typing + +CYAN = "\033[36m" +DIM = "\033[2m" +GREEN = "\033[32m" +RED = "\033[31m" +RESET = "\033[0m" +YELLOW = "\033[33m" + + +def field(status: object, *path: str) -> object: + for key in path: + if not isinstance(status, dict): + return None + status = status.get(key) + return status + + +def number(status: object, *path: str) -> float | None: + found = field(status, *path) + return found if isinstance(found, (int, float)) and not isinstance(found, bool) and math.isfinite(found) else None + + +def text(status: object, *path: str) -> str: + found = field(status, *path) + return found if isinstance(found, str) else "" + + +def directory(status: object) -> str: + return text(status, "workspace", "current_dir") or text(status, "cwd") + + +def usage_color(percent: int) -> str: + return RED if percent >= 80 else YELLOW if percent >= 50 else GREEN + + +def humanize_tokens(count: int) -> str: + if count >= 1_000_000: + return f"{count // 1_000_000}.{count % 1_000_000 // 100_000}M" + if count >= 1000: + return f"{count // 1000}k" + return str(count) + + +def reset_suffix(epoch: float, now: int, zone: datetime.tzinfo | None) -> str: + at = datetime.datetime.fromtimestamp(round(epoch), zone) + seconds = max(0, round(epoch) - now) + if seconds >= 86400: + left = f"{seconds // 86400}d{seconds % 86400 // 3600}h" + elif seconds >= 3600: + left = f"{seconds // 3600}h{seconds % 3600 // 60}m" + else: + left = f"{seconds // 60}m" + clock = at.strftime("%H:%M" if at.date() == datetime.datetime.fromtimestamp(now, zone).date() else "%a %H:%M") + return f" {DIM}{left} left ({clock}){RESET}" + + +def usage(label: str, percent: float, suffix: str) -> str: + rounded = round(percent) + return f"{DIM}{label}{RESET} {usage_color(rounded)}{rounded}%{RESET}{suffix}" + + +def limit(status: object, label: str, window: str, now: int, zone: datetime.tzinfo | None) -> list[str]: + percent = number(status, "rate_limits", window, "used_percentage") + if percent is None: + return [] + resets = number(status, "rate_limits", window, "resets_at") + return [usage(label, percent, "" if resets is None else reset_suffix(resets, now, zone))] + + +def render(status: object, branch: str, home: str, now: int, zone: datetime.tzinfo | None) -> str: + where = [] + shown = directory(status) + if shown: + if home and (shown == home or shown.startswith(home + "/")): + shown = "~" + shown[len(home):] + where.append(f"{CYAN}{shown}{RESET}") + if branch: + where.append(f"{DIM}{branch}{RESET}") + model = text(status, "model", "display_name") + if model: + where.append(f"{DIM}{model}{RESET}") + + load = [] + context = number(status, "context_window", "used_percentage") + if context is not None: + used, size = number(status, "context_window", "total_input_tokens"), number(status, "context_window", "context_window_size") + tokens = "" if used is None or size is None else f" {DIM}{humanize_tokens(int(used))}/{humanize_tokens(int(size))}{RESET}" + load.append(usage("ctx", context, tokens)) + load += limit(status, "5h", "five_hour", now, zone) + limit(status, "7d", "seven_day", now, zone) + + return "\n".join(f"{DIM} | {RESET}".join(row) for row in (where, load) if row) + + +def current_branch(where: str) -> str: + if not where: + return "" + try: + found = subprocess.run(["git", "-C", where, "branch", "--show-current"], capture_output=True, text=True) + except OSError: + return "" + return found.stdout.strip() if found.returncode == 0 else "" + + +def main(stdin: typing.TextIO, env: typing.Mapping[str, str]) -> str: + try: + status = json.load(stdin) + except ValueError: + status = None + return render(status, current_branch(directory(status)), env.get("HOME", ""), int(time.time()), None) + + +if __name__ == "__main__": + sys.stdout.write(main(sys.stdin, os.environ)) diff --git a/bin/test_statusline.py b/bin/test_statusline.py new file mode 100644 index 00000000..00f9357e --- /dev/null +++ b/bin/test_statusline.py @@ -0,0 +1,89 @@ +import datetime +import json +import pathlib +import subprocess +import sys +import tempfile +import unittest + +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) + +import statusline +from statusline import CYAN, DIM, GREEN, RED, RESET, YELLOW + +NOW = int(datetime.datetime(2026, 10, 2, 12, 0, tzinfo=datetime.timezone.utc).timestamp()) +SEP = f"{DIM} | {RESET}" +UTC = datetime.timezone.utc + + +def render(status, branch="", home="/home/me"): + return statusline.render(status, branch, home, NOW, UTC) + + +class Render(unittest.TestCase): + def test_shows_every_field_on_two_rows(self): + status = { + "context_window": {"context_window_size": 1_000_000, "total_input_tokens": 85_000, "used_percentage": 42.5}, + "model": {"display_name": "Opus"}, + "rate_limits": {"five_hour": {"resets_at": NOW + 5000, "used_percentage": 63}, "seven_day": {"resets_at": NOW + 300_000, "used_percentage": 91.2}}, + "workspace": {"current_dir": "/home/me/code/a"}, + } + self.assertEqual(render(status, "main"), "\n".join([ + SEP.join([f"{CYAN}~/code/a{RESET}", f"{DIM}main{RESET}", f"{DIM}Opus{RESET}"]), + SEP.join([ + f"{DIM}ctx{RESET} {GREEN}42%{RESET} {DIM}85k/1.0M{RESET}", + f"{DIM}5h{RESET} {YELLOW}63%{RESET} {DIM}1h23m left (13:23){RESET}", + f"{DIM}7d{RESET} {RED}91%{RESET} {DIM}3d11h left (Mon 23:20){RESET}", + ]), + ])) + + def test_shows_nothing_for_an_empty_or_unparsed_status(self): + self.assertEqual(render({}), "") + self.assertEqual(render(None), "") + + def test_skips_a_field_of_the_wrong_type(self): + status = {"context_window": {"used_percentage": "42"}, "cwd": 7, "model": {"display_name": None}, "rate_limits": {"five_hour": {"used_percentage": True}}} + self.assertEqual(render(status), "") + + def test_falls_back_to_cwd_and_shows_the_branch_only_beside_a_directory(self): + self.assertEqual(render({"cwd": "/srv"}, "main"), SEP.join([f"{CYAN}/srv{RESET}", f"{DIM}main{RESET}"])) + self.assertEqual(render({"model": {"display_name": "Opus"}}, "main"), f"{DIM}Opus{RESET}") + + def test_abbreviates_home_only_at_a_path_boundary(self): + self.assertEqual(render({"cwd": "/home/me"}), f"{CYAN}~{RESET}") + self.assertEqual(render({"cwd": "/home/meg"}), f"{CYAN}/home/meg{RESET}") + self.assertEqual(render({"cwd": "/home/me"}, home=""), f"{CYAN}/home/me{RESET}") + + def test_omits_the_token_counts_unless_both_are_known(self): + self.assertEqual(render({"context_window": {"total_input_tokens": 5, "used_percentage": 1}}), f"{DIM}ctx{RESET} {GREEN}1%{RESET}") + + def test_omits_the_reset_unless_known(self): + self.assertEqual(render({"rate_limits": {"five_hour": {"used_percentage": 50}}}), f"{DIM}5h{RESET} {YELLOW}50%{RESET}") + + def test_colors_usage_by_threshold(self): + self.assertEqual([statusline.usage_color(p) for p in (49, 50, 79, 80)], [GREEN, YELLOW, YELLOW, RED]) + + def test_humanizes_token_counts(self): + self.assertEqual([statusline.humanize_tokens(n) for n in (999, 1000, 999_999, 1_250_000)], ["999", "1k", "999k", "1.2M"]) + + def test_counts_a_past_reset_as_zero_left(self): + self.assertEqual(statusline.reset_suffix(NOW - 60, NOW, UTC), f" {DIM}0m left (11:59){RESET}") + + +class Script(unittest.TestCase): + def run_script(self, stdin): + return subprocess.run([sys.executable, str(pathlib.Path(statusline.__file__))], capture_output=True, env={"HOME": "/nonexistent", "PATH": "/usr/bin:/bin"}, input=stdin, text=True) + + def test_prints_the_status_without_a_trailing_newline(self): + ran = self.run_script(json.dumps({"cwd": "/nonexistent/a", "model": {"display_name": "Opus"}})) + self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, SEP.join([f"{CYAN}~/a{RESET}", f"{DIM}Opus{RESET}"]), "")) + + def test_prints_nothing_for_input_that_is_not_json(self): + ran = self.run_script("not json") + self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, "", "")) + + def test_shows_the_branch_of_the_directory(self): + with tempfile.TemporaryDirectory() as checkout: + subprocess.run(["git", "init", "-q", "-b", "trunk", checkout], check=True) + ran = self.run_script(json.dumps({"cwd": checkout})) + self.assertEqual(ran.stdout, SEP.join([f"{CYAN}{checkout}{RESET}", f"{DIM}trunk{RESET}"])) diff --git a/bin/test_types.py b/bin/test_types.py index 17500139..8e2c84dc 100644 --- a/bin/test_types.py +++ b/bin/test_types.py @@ -6,10 +6,10 @@ from test_python_floor import ROOT, readme_floor class Types(unittest.TestCase): - def test_mypy_passes_on_loop_claude_at_the_floor(self): + def test_mypy_passes_on_the_tools_at_the_floor(self): floor = readme_floor() 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", "-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", "-m", "statusline", "-p", "loop_claude"], capture_output=True, cwd=ROOT / "bin", text=True) self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr) diff --git a/settings.json b/settings.json index f839ed0b..f7dfa605 100644 --- a/settings.json +++ b/settings.json @@ -13,7 +13,7 @@ "disableClaudeAiConnectors": true, "statusLine": { "type": "command", - "command": "~/.claude/statusline.sh", + "command": "~/.claude/bin/statusline.py", "refreshInterval": 30 }, "enabledPlugins": { diff --git a/statusline.sh b/statusline.sh deleted file mode 100755 index 3ec20c86..00000000 --- a/statusline.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash -set -uo pipefail - -input=$(cat) - -# @sh quotes every value, so the JSON reaches eval as data. -eval "$(printf '%s' "$input" | jq -r ' - @sh "dir=\(.workspace.current_dir // .cwd // "")", - @sh "model=\(.model.display_name // "")", - @sh "ctx_pct=\(.context_window.used_percentage // "")", - @sh "ctx_used=\(.context_window.total_input_tokens // "")", - @sh "ctx_size=\(.context_window.context_window_size // "")", - @sh "five=\(.rate_limits.five_hour.used_percentage // "")", - @sh "five_reset=\(.rate_limits.five_hour.resets_at // "")", - @sh "week=\(.rate_limits.seven_day.used_percentage // "")", - @sh "week_reset=\(.rate_limits.seven_day.resets_at // "")" -')" - -DIM=$'\033[2m' -RESET=$'\033[0m' -CYAN=$'\033[36m' -GREEN=$'\033[32m' -YELLOW=$'\033[33m' -RED=$'\033[31m' - -usage_color() { - local pct=${1%%.*} - if [ "$pct" -ge 80 ]; then printf '%s' "$RED" - elif [ "$pct" -ge 50 ]; then printf '%s' "$YELLOW" - else printf '%s' "$GREEN" - fi -} - -humanize_tokens() { - local n=$1 - if [ "$n" -ge 1000000 ]; then printf '%d.%dM' "$(( n / 1000000 ))" "$(( n % 1000000 / 100000 ))" - elif [ "$n" -ge 1000 ]; then printf '%dk' "$(( n / 1000 ))" - else printf '%d' "$n" - fi -} - -reset_suffix() { - local epoch=$1 secs at fmt - epoch=$(printf '%.0f' "$epoch") - secs=$(( epoch - $(date +%s) )) - [ "$secs" -lt 0 ] && secs=0 - - if [ "$secs" -ge 86400 ]; then - printf ' %s%dd%dh left' "$DIM" "$(( secs / 86400 ))" "$(( secs % 86400 / 3600 ))" - elif [ "$secs" -ge 3600 ]; then - printf ' %s%dh%dm left' "$DIM" "$(( secs / 3600 ))" "$(( secs % 3600 / 60 ))" - else - printf ' %s%dm left' "$DIM" "$(( secs / 60 ))" - fi - - fmt='%H:%M' - [ "$(date -d "@$epoch" +%F 2>/dev/null)" != "$(date +%F)" ] && fmt='%a %H:%M' - at=$(date -d "@$epoch" "+$fmt" 2>/dev/null) - [ -n "$at" ] && printf ' (%s)' "$at" - printf '%s' "$RESET" -} - -row1=() -row2=() - -home=${HOME:-} -if [ -n "$dir" ]; then - shortdir=$dir - [ -n "$home" ] && shortdir=${dir/#$home/\~} - row1+=("${CYAN}${shortdir}${RESET}") - - branch=$(git -C "$dir" branch --show-current 2>/dev/null) - [ -n "$branch" ] && row1+=("${DIM}${branch}${RESET}") -fi - -[ -n "$model" ] && row1+=("${DIM}${model}${RESET}") - -if [ -n "$ctx_pct" ]; then - pct=$(printf '%.0f' "$ctx_pct") - tokens="" - [ -n "$ctx_used" ] && [ -n "$ctx_size" ] && tokens=" ${DIM}$(humanize_tokens "$ctx_used")/$(humanize_tokens "$ctx_size")${RESET}" - row2+=("${DIM}ctx${RESET} $(usage_color "$pct")${pct}%${RESET}${tokens}") -fi - -if [ -n "$five" ]; then - pct=$(printf '%.0f' "$five") - left="" - [ -n "$five_reset" ] && left=$(reset_suffix "$five_reset") - row2+=("${DIM}5h${RESET} $(usage_color "$pct")${pct}%${RESET}${left}") -fi - -if [ -n "$week" ]; then - pct=$(printf '%.0f' "$week") - left="" - [ -n "$week_reset" ] && left=$(reset_suffix "$week_reset") - row2+=("${DIM}7d${RESET} $(usage_color "$pct")${pct}%${RESET}${left}") -fi - -join_parts() { - local sep="${DIM} | ${RESET}" out="" part - for part in "$@"; do - [ -n "$out" ] && out+="$sep" - out+="$part" - done - printf '%s' "$out" -} - -out="" -# ${a[@]+"${a[@]}"}: before bash 4.4 an empty array is unset under set -u. -for line in "$(join_parts ${row1[@]+"${row1[@]}"})" "$(join_parts ${row2[@]+"${row2[@]}"})"; do - [ -z "$line" ] && continue - [ -n "$out" ] && out+=$'\n' - out+="$line" -done -printf '%s' "$out" diff --git a/todo.md b/todo.md index 72d03cac..df3496df 100644 --- a/todo.md +++ b/todo.md @@ -2,7 +2,6 @@ ## 0.1.0 -- **Rewrite `statusline.sh` in Python, and test it.** It needs `jq` and GNU `date` on every machine, `eval`s jq output, has three near-identical usage blocks and no test. Goal 1. - **Put the scoring run's four seat prompts in `skills/comprehension-panel/`.** Each run copies them from the last run's handoff folder outside the repo, so another machine cannot rerun a comparable panel. Goal 1. - **Archive the transcript as each cycle ends.** Today only an interrupt or a finished chunk archives it, so after a failed exit or Ctrl-C the transcript stays unarchived until the chunk finishes, and is never archived if it does not. Goal 2. - **Archive a finished chunk's subagent transcripts before `delete_session` removes them.** Today only `.jsonl` is copied, so every reviewer's full run in an unattended chunk is lost. Goal 2. -- 2.52.0 From e1707183fdc18e700fc200be2b3fc2d527f552cb Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 12:16:33 +0200 Subject: [PATCH 02/11] Answer the architecture pass's first round --- bin/statusline.py | 102 +++++++++++++++++++++++++++-------------- bin/test_statusline.py | 20 ++++++-- todo.md | 10 ++++ 3 files changed, 92 insertions(+), 40 deletions(-) diff --git a/bin/statusline.py b/bin/statusline.py index 3babd0de..c36ffbcc 100755 --- a/bin/statusline.py +++ b/bin/statusline.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import dataclasses import datetime import json import math @@ -6,7 +7,6 @@ import os import subprocess import sys import time -import typing CYAN = "\033[36m" DIM = "\033[2m" @@ -16,26 +16,59 @@ RESET = "\033[0m" YELLOW = "\033[33m" -def field(status: object, *path: str) -> object: +@dataclasses.dataclass(frozen=True) +class Limit: + percent: float + resets_at: float | None + + +@dataclasses.dataclass(frozen=True) +class Status: + context_percent: float | None + context_size: float | None + context_used: float | None + directory: str + five_hour: Limit | None + model: str + seven_day: Limit | None + + +def field(raw: object, *path: str) -> object: for key in path: - if not isinstance(status, dict): + if not isinstance(raw, dict): return None - status = status.get(key) - return status + raw = raw.get(key) + return raw -def number(status: object, *path: str) -> float | None: - found = field(status, *path) - return found if isinstance(found, (int, float)) and not isinstance(found, bool) and math.isfinite(found) else None +def number(raw: object, *path: str) -> float | None: + found = field(raw, *path) + if isinstance(found, bool) or not isinstance(found, (int, float)): + return None + return found if isinstance(found, int) or math.isfinite(found) else None -def text(status: object, *path: str) -> str: - found = field(status, *path) +def text(raw: object, *path: str) -> str: + found = field(raw, *path) return found if isinstance(found, str) else "" -def directory(status: object) -> str: - return text(status, "workspace", "current_dir") or text(status, "cwd") +def limit(raw: object, window: str) -> Limit | None: + percent = number(raw, "rate_limits", window, "used_percentage") + return None if percent is None else Limit(percent, number(raw, "rate_limits", window, "resets_at")) + + +# The input's fields: https://code.claude.com/docs/en/statusline +def parse(raw: object) -> Status: + return Status( + context_percent=number(raw, "context_window", "used_percentage"), + context_size=number(raw, "context_window", "context_window_size"), + context_used=number(raw, "context_window", "total_input_tokens"), + directory=text(raw, "workspace", "current_dir") or text(raw, "cwd"), + five_hour=limit(raw, "five_hour"), + model=text(raw, "model", "display_name"), + seven_day=limit(raw, "seven_day"), + ) def usage_color(percent: int) -> str: @@ -51,7 +84,10 @@ def humanize_tokens(count: int) -> str: def reset_suffix(epoch: float, now: int, zone: datetime.tzinfo | None) -> str: - at = datetime.datetime.fromtimestamp(round(epoch), zone) + try: + at = datetime.datetime.fromtimestamp(round(epoch), zone) + except (OSError, OverflowError, ValueError): + return "" seconds = max(0, round(epoch) - now) if seconds >= 86400: left = f"{seconds // 86400}d{seconds % 86400 // 3600}h" @@ -63,39 +99,35 @@ def reset_suffix(epoch: float, now: int, zone: datetime.tzinfo | None) -> str: return f" {DIM}{left} left ({clock}){RESET}" -def usage(label: str, percent: float, suffix: str) -> str: +def usage_segment(label: str, percent: float, suffix: str) -> str: rounded = round(percent) return f"{DIM}{label}{RESET} {usage_color(rounded)}{rounded}%{RESET}{suffix}" -def limit(status: object, label: str, window: str, now: int, zone: datetime.tzinfo | None) -> list[str]: - percent = number(status, "rate_limits", window, "used_percentage") - if percent is None: +def limit_segment(label: str, window: Limit | None, now: int, zone: datetime.tzinfo | None) -> list[str]: + if window is None: return [] - resets = number(status, "rate_limits", window, "resets_at") - return [usage(label, percent, "" if resets is None else reset_suffix(resets, now, zone))] + return [usage_segment(label, window.percent, "" if window.resets_at is None else reset_suffix(window.resets_at, now, zone))] -def render(status: object, branch: str, home: str, now: int, zone: datetime.tzinfo | None) -> str: +def render(status: Status, branch: str, home: str, now: int, zone: datetime.tzinfo | None) -> str: where = [] - shown = directory(status) - if shown: + if status.directory: + shown = status.directory if home and (shown == home or shown.startswith(home + "/")): shown = "~" + shown[len(home):] where.append(f"{CYAN}{shown}{RESET}") if branch: where.append(f"{DIM}{branch}{RESET}") - model = text(status, "model", "display_name") - if model: - where.append(f"{DIM}{model}{RESET}") + if status.model: + where.append(f"{DIM}{status.model}{RESET}") load = [] - context = number(status, "context_window", "used_percentage") - if context is not None: - used, size = number(status, "context_window", "total_input_tokens"), number(status, "context_window", "context_window_size") + if status.context_percent is not None: + used, size = status.context_used, status.context_size tokens = "" if used is None or size is None else f" {DIM}{humanize_tokens(int(used))}/{humanize_tokens(int(size))}{RESET}" - load.append(usage("ctx", context, tokens)) - load += limit(status, "5h", "five_hour", now, zone) + limit(status, "7d", "seven_day", now, zone) + load.append(usage_segment("ctx", status.context_percent, tokens)) + load += limit_segment("5h", status.five_hour, now, zone) + limit_segment("7d", status.seven_day, now, zone) return "\n".join(f"{DIM} | {RESET}".join(row) for row in (where, load) if row) @@ -110,13 +142,13 @@ def current_branch(where: str) -> str: return found.stdout.strip() if found.returncode == 0 else "" -def main(stdin: typing.TextIO, env: typing.Mapping[str, str]) -> str: +def main() -> str: try: - status = json.load(stdin) + status = parse(json.load(sys.stdin)) except ValueError: - status = None - return render(status, current_branch(directory(status)), env.get("HOME", ""), int(time.time()), None) + return f"{RED}warning: statusline.py could not parse its input as JSON{RESET}" + return render(status, current_branch(status.directory), os.environ.get("HOME", ""), int(time.time()), None) if __name__ == "__main__": - sys.stdout.write(main(sys.stdin, os.environ)) + sys.stdout.write(main()) diff --git a/bin/test_statusline.py b/bin/test_statusline.py index 00f9357e..35b24c58 100644 --- a/bin/test_statusline.py +++ b/bin/test_statusline.py @@ -1,5 +1,6 @@ import datetime import json +import os import pathlib import subprocess import sys @@ -17,7 +18,7 @@ UTC = datetime.timezone.utc def render(status, branch="", home="/home/me"): - return statusline.render(status, branch, home, NOW, UTC) + return statusline.render(statusline.parse(status), branch, home, NOW, UTC) class Render(unittest.TestCase): @@ -37,10 +38,15 @@ class Render(unittest.TestCase): ]), ])) - def test_shows_nothing_for_an_empty_or_unparsed_status(self): + def test_shows_nothing_for_an_empty_status(self): self.assertEqual(render({}), "") + self.assertEqual(render([]), "") self.assertEqual(render(None), "") + def test_skips_infinity_and_keeps_an_integer_too_big_for_a_float(self): + self.assertEqual(render({"context_window": {"used_percentage": float("inf")}}), "") + self.assertEqual(render({"context_window": {"used_percentage": 10**400}}), f"{DIM}ctx{RESET} {RED}{10**400}%{RESET}") + def test_skips_a_field_of_the_wrong_type(self): status = {"context_window": {"used_percentage": "42"}, "cwd": 7, "model": {"display_name": None}, "rate_limits": {"five_hour": {"used_percentage": True}}} self.assertEqual(render(status), "") @@ -66,21 +72,25 @@ class Render(unittest.TestCase): def test_humanizes_token_counts(self): self.assertEqual([statusline.humanize_tokens(n) for n in (999, 1000, 999_999, 1_250_000)], ["999", "1k", "999k", "1.2M"]) + def test_omits_a_reset_out_of_the_clocks_range(self): + self.assertEqual(render({"rate_limits": {"seven_day": {"resets_at": 1790618085238, "used_percentage": 1}}}), f"{DIM}7d{RESET} {GREEN}1%{RESET}") + self.assertEqual(render({"rate_limits": {"seven_day": {"resets_at": 1e20, "used_percentage": 1}}}), f"{DIM}7d{RESET} {GREEN}1%{RESET}") + def test_counts_a_past_reset_as_zero_left(self): self.assertEqual(statusline.reset_suffix(NOW - 60, NOW, UTC), f" {DIM}0m left (11:59){RESET}") class Script(unittest.TestCase): def run_script(self, stdin): - return subprocess.run([sys.executable, str(pathlib.Path(statusline.__file__))], capture_output=True, env={"HOME": "/nonexistent", "PATH": "/usr/bin:/bin"}, input=stdin, text=True) + return subprocess.run([statusline.__file__], capture_output=True, env={"HOME": "/nonexistent", "PATH": os.environ["PATH"]}, input=stdin, text=True) def test_prints_the_status_without_a_trailing_newline(self): ran = self.run_script(json.dumps({"cwd": "/nonexistent/a", "model": {"display_name": "Opus"}})) self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, SEP.join([f"{CYAN}~/a{RESET}", f"{DIM}Opus{RESET}"]), "")) - def test_prints_nothing_for_input_that_is_not_json(self): + def test_warns_on_the_status_line_for_input_that_is_not_json(self): ran = self.run_script("not json") - self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, "", "")) + self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, f"{RED}warning: statusline.py could not parse its input as JSON{RESET}", "")) def test_shows_the_branch_of_the_directory(self): with tempfile.TemporaryDirectory() as checkout: diff --git a/todo.md b/todo.md index df3496df..05f25f9f 100644 --- a/todo.md +++ b/todo.md @@ -15,19 +15,29 @@ - **Give principles-auditor and prose-reviewer a way to list the project's files.** In the 2026-09-30 audit run their `tools: Read, Grep, Glob` gave them only Read. Each read the files that imports and `.gitignore` named, and listed the files it could not reach. Goal 4.1. - **Give the reviewer agents only the tools they need.** `systems-architect.md`, `product-owner-reviewer.md` and `stability-reviewer.md` have no `tools:` line, so each can edit the branch it reviews; `review-findings.md` says a reviewer edits nothing. Goal 4.1. - **Measure test coverage in the suite, and fail on a drop.** Nothing measures it, so "Test coverage should not decline" cannot be held. Goal 4.1. +- **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 §4 rule 1 skips even that when the last stability round left the suite green: an unattended chunk can merge on the worker's own word. Goal 4.1. - **Make larv-review §3 applicable on its own, cite its rules by name, and say where a pass's round count is recorded.** Applying one rule of "Round cap", "Re-entry" or "Findings" takes `review-findings.md`, `CLAUDE.md` → "Vocabulary" and the decision log open beside it. The rules cite each other by number ("Round cap" rule 6), so a renumbering breaks a citation silently. Nothing says where a pass's round count is recorded, so a resumed or compacted session loses it. Goal 4.1. - **Read transcript and stream entries into typed values where they are read.** `read_transcript` and `run_worker` pass raw `dict`s, so about ten accessors in `entries.py` re-check shapes deep inside and mypy cannot check `render`, `human_turns` or `run_worker`. Goal 4.1. - **Inject output and storage into `Effects`, and test what each step prints.** `print` and `open` are called directly across `bin/loop_claude/`, so the stderr lines of the CLI contract can be checked only through the black-box tests. Goal 4.1. +- **Move the judge's transcript rendering from `claude_code/transcript.py` into `cycle/`.** `render`, `part_line` and `JUDGED_TOOL_INPUT` shape what the judge sees, so its input is split from `JUDGED_TRANSCRIPT_TAIL` across two packages, and `claude_code/` no longer holds only Claude Code's shapes as its docstring says. Goal 4.1. - **Give each cycle phase one name across its state, step and event.** Today `Judging` runs `rule` and yields `Ruled`, and `Finishing` runs `close`, which also deletes the session, and yields `Archived`. Goal 4.1. - **Enable the `claude-security` plugin in `settings.json`, or drop larv-review's full-scan row.** No machine has it enabled, so every chunk that fires the pass skips it. Goal 4.1. - **Give `settings.json`'s model one writer, and sort its keys.** Claude Code rewrites `"model"` in this tracked file whenever a model is picked, so one `/model` dirties the checkout and overrides the synced choice. Goal 4.3. - **Say in `systems-architect.md` that a REST API's `/v1/` prefix is not versioning machinery to defer.** Its "defer the versioning story" can be read against `principles/rest-apis.md`, which requires the prefix from the start. Goal 4.3. - **Launch a principles auditor only for a principles file the project shows applies, and rerun only the reviewer whose finding a fix answers.** On this repo the frontend, REST and logging auditors each read the whole project to report "does not apply", and one 🟢 fix reruns ten whole-project reads. Goal 4.4. +- **Cut `systems-architect.md`'s, `stability-reviewer.md`'s and `product-owner-reviewer.md`'s descriptions to one line.** Claude Code loads every agent description into every session; larv-review launches these agents by name, so their worked examples cost tokens in every project and buy nothing. Goal 4.4. - **Record each finished chunk's cost and review numbers on one stats line.** Goal 4.4. - Have `loop-claude` write the line to one file at the root of the transcript archive. The line names the project, the commit the chunk started from and the archived transcript's hash. It holds the worker's tokens from the transcript, the judge's from its JSON output, and the chunk's cycles and interrupts, which the loop counts. - End larv-review with a machine-readable summary, and have `loop-claude` copy it from the transcript onto the line: agents launched and rounds per pass; findings per pass by severity, inside the chunk's diff and outside it; and the comprehension scores when the panel ran. - **Write a `workflow-review` skill that reads the stats and files each change it proposes to the workflow as a plan item, and have `AGENTS.md` run it on the chunk shipping a release's last item.** The workflow is `CLAUDE.md`, `principles/`, the skills, the agents and `loop-claude`. The skill's signals: findings outside the chunk's diff and comprehension scores per release, both from the stats; fixes after merge, from git; and the human's corrections, from the archived transcripts. Goal 4.4. - **Bench about one chunk in ten against an open PR that changes the workflow, and have a blind claude rule which run better serves this repo's goal 4.** Redo the chunk under the PR, from the commit it started from. The ruling claude is not told which run is which. `loop-claude` picks the chunk at random, small diffs and big ones alike; with no such PR open, no bench runs. The same outcome with less code and prose, in the chunk or in the workflow, also counts as better. The PR merges only once three benches rule it better. A bench that rules it worse closes the PR and records, in `docs/workflow-learnings.md`, what the PR changed and why it lost. The ruling and both runs' numbers go on the chunk's stats line. Start from `workflow-bench/`, written for the 2026-09-30 bench's four fixed cases. Needs the stats line. Goals 4.1 and 4.4. +- **Make the small fixes filed by the 2026-10-02 principles audit against `workflow-bench/`.** The bench item starts from it. Goals 2 and 4.1. + - Test `judge.py`'s `blind` and `bench.py`'s rate-limit parsing, and run mypy on both. + - Let `judge.py` import `bench` without `BENCH_SOURCES` set; today reading it at import raises a bare `KeyError`. + - Key `CASES`, `PREFIX` and `TRUTH_END` in one table, sorted. + - Report a failed `git` per run; today `check=True` aborts `main` and drops every other run's result. + - Take the model from a flag or env var, and inject the clock, sleep and shuffle. + - Keep the bench's run logs where the transcript archive's backup reaches them. - **Make the small changes filed against the review's rules.** Goals 4.1 and 4.4. - Make the contributor a standing member of every project's audience. A project drops them only where 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. - **Make the small fixes filed by the 2026-10-01 principles audit against `bin/`.** Goal 4.1. -- 2.52.0 From f49bd7018b89fd291b83627bcb8ae95dc9b81d60 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 12:19:14 +0200 Subject: [PATCH 03/11] Answer the architecture pass's second round --- bin/statusline.py | 31 ++++++++++++++++++++----------- bin/test_statusline.py | 9 +++++---- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/bin/statusline.py b/bin/statusline.py index c36ffbcc..73ec13e7 100755 --- a/bin/statusline.py +++ b/bin/statusline.py @@ -19,7 +19,7 @@ YELLOW = "\033[33m" @dataclasses.dataclass(frozen=True) class Limit: percent: float - resets_at: float | None + resets_at: datetime.datetime | None @dataclasses.dataclass(frozen=True) @@ -53,9 +53,18 @@ def text(raw: object, *path: str) -> str: return found if isinstance(found, str) else "" +def instant(epoch: float | None) -> datetime.datetime | None: + if epoch is None: + return None + try: + return datetime.datetime.fromtimestamp(round(epoch), datetime.timezone.utc) + except (OSError, OverflowError, ValueError): + return None + + def limit(raw: object, window: str) -> Limit | None: percent = number(raw, "rate_limits", window, "used_percentage") - return None if percent is None else Limit(percent, number(raw, "rate_limits", window, "resets_at")) + return None if percent is None else Limit(percent, instant(number(raw, "rate_limits", window, "resets_at"))) # The input's fields: https://code.claude.com/docs/en/statusline @@ -83,19 +92,16 @@ def humanize_tokens(count: int) -> str: return str(count) -def reset_suffix(epoch: float, now: int, zone: datetime.tzinfo | None) -> str: - try: - at = datetime.datetime.fromtimestamp(round(epoch), zone) - except (OSError, OverflowError, ValueError): - return "" - seconds = max(0, round(epoch) - now) +def reset_suffix(resets_at: datetime.datetime, now: int, zone: datetime.tzinfo | None) -> str: + at = resets_at.astimezone(zone) + seconds = max(0, int(resets_at.timestamp()) - now) if seconds >= 86400: left = f"{seconds // 86400}d{seconds % 86400 // 3600}h" elif seconds >= 3600: left = f"{seconds // 3600}h{seconds % 3600 // 60}m" else: left = f"{seconds // 60}m" - clock = at.strftime("%H:%M" if at.date() == datetime.datetime.fromtimestamp(now, zone).date() else "%a %H:%M") + clock = at.strftime("%H:%M" if at.date() == datetime.datetime.fromtimestamp(now, datetime.timezone.utc).astimezone(zone).date() else "%a %H:%M") return f" {DIM}{left} left ({clock}){RESET}" @@ -144,9 +150,12 @@ def current_branch(where: str) -> str: def main() -> str: try: - status = parse(json.load(sys.stdin)) + raw = json.load(sys.stdin) except ValueError: - return f"{RED}warning: statusline.py could not parse its input as JSON{RESET}" + raw = None + if not isinstance(raw, dict): + return f"{RED}warning: statusline.py could not parse its input as a JSON object{RESET}" + status = parse(raw) return render(status, current_branch(status.directory), os.environ.get("HOME", ""), int(time.time()), None) diff --git a/bin/test_statusline.py b/bin/test_statusline.py index 35b24c58..9f6758c8 100644 --- a/bin/test_statusline.py +++ b/bin/test_statusline.py @@ -77,7 +77,7 @@ class Render(unittest.TestCase): self.assertEqual(render({"rate_limits": {"seven_day": {"resets_at": 1e20, "used_percentage": 1}}}), f"{DIM}7d{RESET} {GREEN}1%{RESET}") def test_counts_a_past_reset_as_zero_left(self): - self.assertEqual(statusline.reset_suffix(NOW - 60, NOW, UTC), f" {DIM}0m left (11:59){RESET}") + self.assertEqual(statusline.reset_suffix(datetime.datetime.fromtimestamp(NOW - 60, UTC), NOW, UTC), f" {DIM}0m left (11:59){RESET}") class Script(unittest.TestCase): @@ -88,9 +88,10 @@ class Script(unittest.TestCase): ran = self.run_script(json.dumps({"cwd": "/nonexistent/a", "model": {"display_name": "Opus"}})) self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, SEP.join([f"{CYAN}~/a{RESET}", f"{DIM}Opus{RESET}"]), "")) - def test_warns_on_the_status_line_for_input_that_is_not_json(self): - ran = self.run_script("not json") - self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, f"{RED}warning: statusline.py could not parse its input as JSON{RESET}", "")) + def test_warns_on_the_status_line_for_input_that_is_not_a_json_object(self): + for stdin in ("not json", "[]"): + ran = self.run_script(stdin) + self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, f"{RED}warning: statusline.py could not parse its input as a JSON object{RESET}", "")) def test_shows_the_branch_of_the_directory(self): with tempfile.TemporaryDirectory() as checkout: -- 2.52.0 From 4530b40b88ab9007421a011552e71a9301674c3e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 14:14:35 +0200 Subject: [PATCH 04/11] Answer the architecture pass's third round --- AGENTS.md | 1 + README.md | 1 + bin/statusline.py | 34 +++++++++++++++++----------------- bin/test_statusline.py | 12 ++++++++---- docs/decisions.md | 6 +++++- 5 files changed, 32 insertions(+), 22 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index dcddecb9..4e9192d1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,3 +22,4 @@ Decisions live in `docs/decisions.md`: - review: `/security-review` is the security pass of record - 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 +- statusline.py: a field absent, null or of the wrong type drops its segment silently; only input that is not a JSON object warns diff --git a/README.md b/README.md index 974426c8..917f17f0 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Rename `## Unreleased` in `CHANGELOG.md` to the version, commit, and tag that co ## Tools - `loop-claude ` runs a project's next chunk cycle after cycle; `loop-claude --help` states its contract. +- `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'` diff --git a/bin/statusline.py b/bin/statusline.py index 73ec13e7..42e5be0b 100755 --- a/bin/statusline.py +++ b/bin/statusline.py @@ -53,30 +53,30 @@ def text(raw: object, *path: str) -> str: return found if isinstance(found, str) else "" -def instant(epoch: float | None) -> datetime.datetime | None: +def instant(epoch: float | None, zone: datetime.tzinfo | None) -> datetime.datetime | None: if epoch is None: return None try: - return datetime.datetime.fromtimestamp(round(epoch), datetime.timezone.utc) + return datetime.datetime.fromtimestamp(round(epoch), datetime.timezone.utc).astimezone(zone) except (OSError, OverflowError, ValueError): return None -def limit(raw: object, window: str) -> Limit | None: +def limit(raw: dict[str, object], window: str, zone: datetime.tzinfo | None) -> Limit | None: percent = number(raw, "rate_limits", window, "used_percentage") - return None if percent is None else Limit(percent, instant(number(raw, "rate_limits", window, "resets_at"))) + return None if percent is None else Limit(percent, instant(number(raw, "rate_limits", window, "resets_at"), zone)) # The input's fields: https://code.claude.com/docs/en/statusline -def parse(raw: object) -> Status: +def parse(raw: dict[str, object], zone: datetime.tzinfo | None) -> Status: return Status( context_percent=number(raw, "context_window", "used_percentage"), context_size=number(raw, "context_window", "context_window_size"), context_used=number(raw, "context_window", "total_input_tokens"), directory=text(raw, "workspace", "current_dir") or text(raw, "cwd"), - five_hour=limit(raw, "five_hour"), + five_hour=limit(raw, "five_hour", zone), model=text(raw, "model", "display_name"), - seven_day=limit(raw, "seven_day"), + seven_day=limit(raw, "seven_day", zone), ) @@ -92,16 +92,15 @@ def humanize_tokens(count: int) -> str: return str(count) -def reset_suffix(resets_at: datetime.datetime, now: int, zone: datetime.tzinfo | None) -> str: - at = resets_at.astimezone(zone) - seconds = max(0, int(resets_at.timestamp()) - now) +def reset_suffix(at: datetime.datetime, now: int) -> str: + seconds = max(0, int(at.timestamp()) - now) if seconds >= 86400: left = f"{seconds // 86400}d{seconds % 86400 // 3600}h" elif seconds >= 3600: left = f"{seconds // 3600}h{seconds % 3600 // 60}m" else: left = f"{seconds // 60}m" - clock = at.strftime("%H:%M" if at.date() == datetime.datetime.fromtimestamp(now, datetime.timezone.utc).astimezone(zone).date() else "%a %H:%M") + clock = at.strftime("%H:%M" if at.date() == datetime.datetime.fromtimestamp(now, at.tzinfo).date() else "%a %H:%M") return f" {DIM}{left} left ({clock}){RESET}" @@ -110,13 +109,13 @@ def usage_segment(label: str, percent: float, suffix: str) -> str: return f"{DIM}{label}{RESET} {usage_color(rounded)}{rounded}%{RESET}{suffix}" -def limit_segment(label: str, window: Limit | None, now: int, zone: datetime.tzinfo | None) -> list[str]: +def limit_segment(label: str, window: Limit | None, now: int) -> list[str]: if window is None: return [] - return [usage_segment(label, window.percent, "" if window.resets_at is None else reset_suffix(window.resets_at, now, zone))] + return [usage_segment(label, window.percent, "" if window.resets_at is None else reset_suffix(window.resets_at, now))] -def render(status: Status, branch: str, home: str, now: int, zone: datetime.tzinfo | None) -> str: +def render(status: Status, branch: str, home: str, now: int) -> str: where = [] if status.directory: shown = status.directory @@ -133,7 +132,7 @@ def render(status: Status, branch: str, home: str, now: int, zone: datetime.tzin used, size = status.context_used, status.context_size tokens = "" if used is None or size is None else f" {DIM}{humanize_tokens(int(used))}/{humanize_tokens(int(size))}{RESET}" load.append(usage_segment("ctx", status.context_percent, tokens)) - load += limit_segment("5h", status.five_hour, now, zone) + limit_segment("7d", status.seven_day, now, zone) + load += limit_segment("5h", status.five_hour, now) + limit_segment("7d", status.seven_day, now) return "\n".join(f"{DIM} | {RESET}".join(row) for row in (where, load) if row) @@ -155,8 +154,9 @@ def main() -> str: raw = None if not isinstance(raw, dict): return f"{RED}warning: statusline.py could not parse its input as a JSON object{RESET}" - status = parse(raw) - return render(status, current_branch(status.directory), os.environ.get("HOME", ""), int(time.time()), None) + # Zone None: astimezone converts to the machine's own zone, daylight saving included. + status = parse(raw, None) + return render(status, current_branch(status.directory), os.environ.get("HOME", ""), int(time.time())) if __name__ == "__main__": diff --git a/bin/test_statusline.py b/bin/test_statusline.py index 9f6758c8..979b32e5 100644 --- a/bin/test_statusline.py +++ b/bin/test_statusline.py @@ -18,7 +18,7 @@ UTC = datetime.timezone.utc def render(status, branch="", home="/home/me"): - return statusline.render(statusline.parse(status), branch, home, NOW, UTC) + return statusline.render(statusline.parse(status, UTC), branch, home, NOW) class Render(unittest.TestCase): @@ -40,8 +40,6 @@ class Render(unittest.TestCase): def test_shows_nothing_for_an_empty_status(self): self.assertEqual(render({}), "") - self.assertEqual(render([]), "") - self.assertEqual(render(None), "") def test_skips_infinity_and_keeps_an_integer_too_big_for_a_float(self): self.assertEqual(render({"context_window": {"used_percentage": float("inf")}}), "") @@ -75,9 +73,15 @@ class Render(unittest.TestCase): def test_omits_a_reset_out_of_the_clocks_range(self): self.assertEqual(render({"rate_limits": {"seven_day": {"resets_at": 1790618085238, "used_percentage": 1}}}), f"{DIM}7d{RESET} {GREEN}1%{RESET}") self.assertEqual(render({"rate_limits": {"seven_day": {"resets_at": 1e20, "used_percentage": 1}}}), f"{DIM}7d{RESET} {GREEN}1%{RESET}") + east = statusline.parse({"rate_limits": {"seven_day": {"resets_at": 253402300000, "used_percentage": 1}}}, datetime.timezone(datetime.timedelta(hours=2))) + self.assertIsNone(east.seven_day.resets_at) + + def test_shows_the_reset_in_the_given_zone(self): + status = statusline.parse({"rate_limits": {"five_hour": {"resets_at": NOW + 3600, "used_percentage": 1}}}, datetime.timezone(datetime.timedelta(hours=2))) + self.assertEqual(statusline.render(status, "", "", NOW), f"{DIM}5h{RESET} {GREEN}1%{RESET} {DIM}1h0m left (15:00){RESET}") def test_counts_a_past_reset_as_zero_left(self): - self.assertEqual(statusline.reset_suffix(datetime.datetime.fromtimestamp(NOW - 60, UTC), NOW, UTC), f" {DIM}0m left (11:59){RESET}") + self.assertEqual(statusline.reset_suffix(datetime.datetime.fromtimestamp(NOW - 60, UTC), NOW), f" {DIM}0m left (11:59){RESET}") class Script(unittest.TestCase): diff --git a/docs/decisions.md b/docs/decisions.md index 8633ee30..c729054d 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -30,7 +30,7 @@ ## 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. The 2026-09-28 run, Junior A, Mid A, the maintainability senior and the inherited architect at depth 1 over every non-test file, blind to `todo.md` and this log, scored Navigation 7.25, Locality 6.0, Shape 6.5, Self-sufficiency 6.25, overall 6.25; on 2026-09-26 they were 7.75, 6.25, 7.0, 6.75, 6.75. Every seat scored Locality 6, and three of four named `run_cycle`'s three-way return and larv-review's re-entry rules, split across the passes on 2026-09-28. The same seats on `rebuild` scored 7.5, 6.63, 6.88, 6.5, 7.0 at 37edc9a, later that day, 7.5, 6.75, 6.88, 6.75, 7.0 at 7f9de5c, 7.38, 6.25, 6.88, 6.75, 6.88 at 2f9ab2f on 2026-09-29, Locality lowest again and every seat naming the reload state and the two retry counters, and 7.5, 7.0, 7.25, 6.75, 7.13 at 2c74bbc later that day, Self-sufficiency lowest and every seat naming the round's definition split across larv-review's two files, and 7.38, 6.75, 7.25, 6.5, 6.88 at 8585257 on 2026-10-01, lowering every dimension but Shape, and the overall, Self-sufficiency lowest and every seat naming larv-review §3's round rules; the places it named under Self-sufficiency and Locality are filed in `todo.md` under 0.1.0, and a later scoring run may not score any dimension or the overall below its best run on `rebuild`, 2026-10-01, lilleman. `rebuild` merged into main under the floor at 8585257's scores, 2026-10-01, lilleman. The 2026-10-01 run on PR #182 (the loop state machine) scored 7.5, 6.5, 6.88, 6.25, 6.38; lilleman shipped that PR under the floor and below `rebuild`'s best run the same day, its places filed in `todo.md` under 0.1.0. The 2026-10-02 run on PR #187 (`loop_claude`'s names, the exit contract) scored 7.75, 7.25, 7.38, 6.88, 7.25 at 70362d0, every seat naming larv-review §3 under Self-sufficiency, and 7.63, 7.13, 7.38, 7.0, 7.13 at 1971dba later that day, the first run at the floor, with no dimension or the overall below its best run on `rebuild`. Valid until the next scoring run, which uses the same four seats. +2026-09-27, lilleman, restating the 2026-09-24 target and extending it to the overall. Serves goal 4. The 2026-09-28 run, Junior A, Mid A, the maintainability senior and the inherited architect at depth 1 over every non-test file, blind to `todo.md` and this log, scored Navigation 7.25, Locality 6.0, Shape 6.5, Self-sufficiency 6.25, overall 6.25; on 2026-09-26 they were 7.75, 6.25, 7.0, 6.75, 6.75. Every seat scored Locality 6, and three of four named `run_cycle`'s three-way return and larv-review's re-entry rules, split across the passes on 2026-09-28. The same seats on `rebuild` scored 7.5, 6.63, 6.88, 6.5, 7.0 at 37edc9a, later that day, 7.5, 6.75, 6.88, 6.75, 7.0 at 7f9de5c, 7.38, 6.25, 6.88, 6.75, 6.88 at 2f9ab2f on 2026-09-29, Locality lowest again and every seat naming the reload state and the two retry counters, and 7.5, 7.0, 7.25, 6.75, 7.13 at 2c74bbc later that day, Self-sufficiency lowest and every seat naming the round's definition split across larv-review's two files, and 7.38, 6.75, 7.25, 6.5, 6.88 at 8585257 on 2026-10-01, lowering every dimension but Shape, and the overall, Self-sufficiency lowest and every seat naming larv-review §3's round rules; the places it named under Self-sufficiency and Locality are filed in `todo.md` under 0.1.0, and a later scoring run may not score any dimension or the overall below its best run on `rebuild`, 2026-10-01, lilleman. `rebuild` merged into main under the floor at 8585257's scores, 2026-10-01, lilleman. The 2026-10-01 run on PR #182 (the loop state machine) scored 7.5, 6.5, 6.88, 6.25, 6.38; lilleman shipped that PR under the floor and below `rebuild`'s best run the same day, its places filed in `todo.md` under 0.1.0. The 2026-10-02 run on PR #187 (`loop_claude`'s names, the exit contract) scored 7.75, 7.25, 7.38, 6.88, 7.25 at 70362d0, every seat naming larv-review §3 under Self-sufficiency, and 7.63, 7.13, 7.38, 7.0, 7.13 at 1971dba later that day, the first run at the floor, with no dimension or the overall below its best run on `rebuild`. The 2026-10-02 runs on PR #191 (the status line in Python) scored 7.5, 7.0, 7.13, 6.88, 7.13, then 7.25, 6.75, 7.25, 6.88, 7.0, then 7.63, 6.88, 7.38, 7.0, 7.13; every seat rated the status line easy and named under Locality and Self-sufficiency `Effects` leaving file I/O direct, the reload handover, `entries.py`'s heuristics and larv-review §3, each filed in `todo.md` under 0.1.0, and lilleman shipped that PR under the floor the same day. Valid until the next scoring run, which uses the same four seats. ## loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes @@ -83,3 +83,7 @@ ## 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. + +## statusline.py: a field absent, null or of the wrong type drops its segment silently; only input that is not a JSON object warns + +2026-10-02, Claude in PR #191, declining the logging audit's 🟢. Applies KISS (`principles/technical-principles.md`). Claude Code's status schema is likelier to drift by renaming or removing a field, which a type warning cannot catch, and absent or null fields are normal (no `rate_limits` for API users); the warning would need a schema table for the rarer case. Valid while Claude Code documents the status input's fields. -- 2.52.0 From a11c4a443b786a52b34df764811d0718edef4307 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 14:16:45 +0200 Subject: [PATCH 05/11] Date now and a reset each in its own UTC offset --- bin/statusline.py | 13 ++++++------- bin/test_statusline.py | 14 ++++++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/bin/statusline.py b/bin/statusline.py index 42e5be0b..e593164e 100755 --- a/bin/statusline.py +++ b/bin/statusline.py @@ -6,7 +6,6 @@ import math import os import subprocess import sys -import time CYAN = "\033[36m" DIM = "\033[2m" @@ -92,15 +91,15 @@ def humanize_tokens(count: int) -> str: return str(count) -def reset_suffix(at: datetime.datetime, now: int) -> str: - seconds = max(0, int(at.timestamp()) - now) +def reset_suffix(at: datetime.datetime, now: datetime.datetime) -> str: + seconds = max(0, int((at - now).total_seconds())) if seconds >= 86400: left = f"{seconds // 86400}d{seconds % 86400 // 3600}h" elif seconds >= 3600: left = f"{seconds // 3600}h{seconds % 3600 // 60}m" else: left = f"{seconds // 60}m" - clock = at.strftime("%H:%M" if at.date() == datetime.datetime.fromtimestamp(now, at.tzinfo).date() else "%a %H:%M") + clock = at.strftime("%H:%M" if at.date() == now.date() else "%a %H:%M") return f" {DIM}{left} left ({clock}){RESET}" @@ -109,13 +108,13 @@ def usage_segment(label: str, percent: float, suffix: str) -> str: return f"{DIM}{label}{RESET} {usage_color(rounded)}{rounded}%{RESET}{suffix}" -def limit_segment(label: str, window: Limit | None, now: int) -> list[str]: +def limit_segment(label: str, window: Limit | None, now: datetime.datetime) -> list[str]: if window is None: return [] return [usage_segment(label, window.percent, "" if window.resets_at is None else reset_suffix(window.resets_at, now))] -def render(status: Status, branch: str, home: str, now: int) -> str: +def render(status: Status, branch: str, home: str, now: datetime.datetime) -> str: where = [] if status.directory: shown = status.directory @@ -156,7 +155,7 @@ def main() -> str: return f"{RED}warning: statusline.py could not parse its input as a JSON object{RESET}" # Zone None: astimezone converts to the machine's own zone, daylight saving included. status = parse(raw, None) - return render(status, current_branch(status.directory), os.environ.get("HOME", ""), int(time.time())) + return render(status, current_branch(status.directory), os.environ.get("HOME", ""), datetime.datetime.now().astimezone()) if __name__ == "__main__": diff --git a/bin/test_statusline.py b/bin/test_statusline.py index 979b32e5..d0890733 100644 --- a/bin/test_statusline.py +++ b/bin/test_statusline.py @@ -12,7 +12,8 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent)) import statusline from statusline import CYAN, DIM, GREEN, RED, RESET, YELLOW -NOW = int(datetime.datetime(2026, 10, 2, 12, 0, tzinfo=datetime.timezone.utc).timestamp()) +NOW = datetime.datetime(2026, 10, 2, 12, 0, tzinfo=datetime.timezone.utc) +EPOCH = int(NOW.timestamp()) SEP = f"{DIM} | {RESET}" UTC = datetime.timezone.utc @@ -26,7 +27,7 @@ class Render(unittest.TestCase): status = { "context_window": {"context_window_size": 1_000_000, "total_input_tokens": 85_000, "used_percentage": 42.5}, "model": {"display_name": "Opus"}, - "rate_limits": {"five_hour": {"resets_at": NOW + 5000, "used_percentage": 63}, "seven_day": {"resets_at": NOW + 300_000, "used_percentage": 91.2}}, + "rate_limits": {"five_hour": {"resets_at": EPOCH + 5000, "used_percentage": 63}, "seven_day": {"resets_at": EPOCH + 300_000, "used_percentage": 91.2}}, "workspace": {"current_dir": "/home/me/code/a"}, } self.assertEqual(render(status, "main"), "\n".join([ @@ -76,12 +77,17 @@ class Render(unittest.TestCase): east = statusline.parse({"rate_limits": {"seven_day": {"resets_at": 253402300000, "used_percentage": 1}}}, datetime.timezone(datetime.timedelta(hours=2))) self.assertIsNone(east.seven_day.resets_at) + def test_dates_now_and_the_reset_each_in_its_own_offset(self): + cest, cet = datetime.timezone(datetime.timedelta(hours=2)), datetime.timezone(datetime.timedelta(hours=1)) + now = datetime.datetime(2026, 10, 25, 0, 30, tzinfo=cest) + self.assertEqual(statusline.reset_suffix(datetime.datetime(2026, 10, 25, 5, 0, tzinfo=cet), now), f" {DIM}5h30m left (05:00){RESET}") + def test_shows_the_reset_in_the_given_zone(self): - status = statusline.parse({"rate_limits": {"five_hour": {"resets_at": NOW + 3600, "used_percentage": 1}}}, datetime.timezone(datetime.timedelta(hours=2))) + status = statusline.parse({"rate_limits": {"five_hour": {"resets_at": EPOCH + 3600, "used_percentage": 1}}}, datetime.timezone(datetime.timedelta(hours=2))) self.assertEqual(statusline.render(status, "", "", NOW), f"{DIM}5h{RESET} {GREEN}1%{RESET} {DIM}1h0m left (15:00){RESET}") def test_counts_a_past_reset_as_zero_left(self): - self.assertEqual(statusline.reset_suffix(datetime.datetime.fromtimestamp(NOW - 60, UTC), NOW), f" {DIM}0m left (11:59){RESET}") + self.assertEqual(statusline.reset_suffix(NOW - datetime.timedelta(minutes=1), NOW), f" {DIM}0m left (11:59){RESET}") class Script(unittest.TestCase): -- 2.52.0 From 0370adf1fc9a9e35d4a97a5e79dd16ce14fc28d6 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 14:18:19 +0200 Subject: [PATCH 06/11] Record the scoring runs and file the places they named --- docs/decisions.md | 2 +- todo.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/decisions.md b/docs/decisions.md index c729054d..89693ce3 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -30,7 +30,7 @@ ## 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. The 2026-09-28 run, Junior A, Mid A, the maintainability senior and the inherited architect at depth 1 over every non-test file, blind to `todo.md` and this log, scored Navigation 7.25, Locality 6.0, Shape 6.5, Self-sufficiency 6.25, overall 6.25; on 2026-09-26 they were 7.75, 6.25, 7.0, 6.75, 6.75. Every seat scored Locality 6, and three of four named `run_cycle`'s three-way return and larv-review's re-entry rules, split across the passes on 2026-09-28. The same seats on `rebuild` scored 7.5, 6.63, 6.88, 6.5, 7.0 at 37edc9a, later that day, 7.5, 6.75, 6.88, 6.75, 7.0 at 7f9de5c, 7.38, 6.25, 6.88, 6.75, 6.88 at 2f9ab2f on 2026-09-29, Locality lowest again and every seat naming the reload state and the two retry counters, and 7.5, 7.0, 7.25, 6.75, 7.13 at 2c74bbc later that day, Self-sufficiency lowest and every seat naming the round's definition split across larv-review's two files, and 7.38, 6.75, 7.25, 6.5, 6.88 at 8585257 on 2026-10-01, lowering every dimension but Shape, and the overall, Self-sufficiency lowest and every seat naming larv-review §3's round rules; the places it named under Self-sufficiency and Locality are filed in `todo.md` under 0.1.0, and a later scoring run may not score any dimension or the overall below its best run on `rebuild`, 2026-10-01, lilleman. `rebuild` merged into main under the floor at 8585257's scores, 2026-10-01, lilleman. The 2026-10-01 run on PR #182 (the loop state machine) scored 7.5, 6.5, 6.88, 6.25, 6.38; lilleman shipped that PR under the floor and below `rebuild`'s best run the same day, its places filed in `todo.md` under 0.1.0. The 2026-10-02 run on PR #187 (`loop_claude`'s names, the exit contract) scored 7.75, 7.25, 7.38, 6.88, 7.25 at 70362d0, every seat naming larv-review §3 under Self-sufficiency, and 7.63, 7.13, 7.38, 7.0, 7.13 at 1971dba later that day, the first run at the floor, with no dimension or the overall below its best run on `rebuild`. The 2026-10-02 runs on PR #191 (the status line in Python) scored 7.5, 7.0, 7.13, 6.88, 7.13, then 7.25, 6.75, 7.25, 6.88, 7.0, then 7.63, 6.88, 7.38, 7.0, 7.13; every seat rated the status line easy and named under Locality and Self-sufficiency `Effects` leaving file I/O direct, the reload handover, `entries.py`'s heuristics and larv-review §3, each filed in `todo.md` under 0.1.0, and lilleman shipped that PR under the floor the same day. Valid until the next scoring run, which uses the same four seats. +2026-09-27, lilleman, restating the 2026-09-24 target and extending it to the overall. Serves goal 4. The 2026-09-28 run, Junior A, Mid A, the maintainability senior and the inherited architect at depth 1 over every non-test file, blind to `todo.md` and this log, scored Navigation 7.25, Locality 6.0, Shape 6.5, Self-sufficiency 6.25, overall 6.25; on 2026-09-26 they were 7.75, 6.25, 7.0, 6.75, 6.75. Every seat scored Locality 6, and three of four named `run_cycle`'s three-way return and larv-review's re-entry rules, split across the passes on 2026-09-28. The same seats on `rebuild` scored 7.5, 6.63, 6.88, 6.5, 7.0 at 37edc9a, later that day, 7.5, 6.75, 6.88, 6.75, 7.0 at 7f9de5c, 7.38, 6.25, 6.88, 6.75, 6.88 at 2f9ab2f on 2026-09-29, Locality lowest again and every seat naming the reload state and the two retry counters, and 7.5, 7.0, 7.25, 6.75, 7.13 at 2c74bbc later that day, Self-sufficiency lowest and every seat naming the round's definition split across larv-review's two files, and 7.38, 6.75, 7.25, 6.5, 6.88 at 8585257 on 2026-10-01, lowering every dimension but Shape, and the overall, Self-sufficiency lowest and every seat naming larv-review §3's round rules; the places it named under Self-sufficiency and Locality are filed in `todo.md` under 0.1.0, and a later scoring run may not score any dimension or the overall below its best run on `rebuild`, 2026-10-01, lilleman. `rebuild` merged into main under the floor at 8585257's scores, 2026-10-01, lilleman. The 2026-10-01 run on PR #182 (the loop state machine) scored 7.5, 6.5, 6.88, 6.25, 6.38; lilleman shipped that PR under the floor and below `rebuild`'s best run the same day, its places filed in `todo.md` under 0.1.0. The 2026-10-02 run on PR #187 (`loop_claude`'s names, the exit contract) scored 7.75, 7.25, 7.38, 6.88, 7.25 at 70362d0, every seat naming larv-review §3 under Self-sufficiency, and 7.63, 7.13, 7.38, 7.0, 7.13 at 1971dba later that day, the first run at the floor, with no dimension or the overall below its best run on `rebuild`. The 2026-10-02 runs on PR #191 (the status line in Python) scored 7.5, 7.0, 7.13, 6.88, 7.13, then 7.25, 6.75, 7.25, 6.88, 7.0, then 7.63, 6.88, 7.38, 7.0, 7.13, then 7.63, 7.0, 7.25, 6.75, 7.25; every seat rated the status line easy and named under Locality and Self-sufficiency `Effects` leaving file I/O direct, the reload handover, `entries.py`'s heuristics, the judge's rules and loop-claude's Claude Code flags needing outside documents, and larv-review §3, each filed in `todo.md` under 0.1.0, and lilleman shipped that PR under the floor the same day. Valid until the next scoring run, which uses the same four seats. ## loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes diff --git a/todo.md b/todo.md index 05f25f9f..a02bc410 100644 --- a/todo.md +++ b/todo.md @@ -20,6 +20,7 @@ - **Read transcript and stream entries into typed values where they are read.** `read_transcript` and `run_worker` pass raw `dict`s, so about ten accessors in `entries.py` re-check shapes deep inside and mypy cannot check `render`, `human_turns` or `run_worker`. Goal 4.1. - **Inject output and storage into `Effects`, and test what each step prints.** `print` and `open` are called directly across `bin/loop_claude/`, so the stderr lines of the CLI contract can be checked only through the black-box tests. Goal 4.1. - **Move the judge's transcript rendering from `claude_code/transcript.py` into `cycle/`.** `render`, `part_line` and `JUDGED_TOOL_INPUT` shape what the judge sees, so its input is split from `JUDGED_TRANSCRIPT_TAIL` across two packages, and `claude_code/` no longer holds only Claude Code's shapes as its docstring says. Goal 4.1. +- **Make `JUDGE_RULES` and the Claude Code flags `loop-claude` passes readable without `CLAUDE.md` or Claude Code's docs open.** The 2026-10-02 scoring runs on PR #191 named both under Self-sufficiency: the judge's rules use "chunk", "premises" and "a release ready to cut" from `CLAUDE.md` with no link, and `--resume`, `--session-id`, `--no-session-persistence`, `--json-schema` and stream-json's result event go unexplained in `worker.py` and `judge.py`. Goal 4.1. - **Give each cycle phase one name across its state, step and event.** Today `Judging` runs `rule` and yields `Ruled`, and `Finishing` runs `close`, which also deletes the session, and yields `Archived`. Goal 4.1. - **Enable the `claude-security` plugin in `settings.json`, or drop larv-review's full-scan row.** No machine has it enabled, so every chunk that fires the pass skips it. Goal 4.1. - **Give `settings.json`'s model one writer, and sort its keys.** Claude Code rewrites `"model"` in this tracked file whenever a model is picked, so one `/model` dirties the checkout and overrides the synced choice. Goal 4.3. -- 2.52.0 From 7ba3d0325b8d64b01f62c36913486527ef57fb95 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 14:23:33 +0200 Subject: [PATCH 07/11] Survive a git branch name that is not UTF-8 --- bin/statusline.py | 2 +- bin/test_statusline.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bin/statusline.py b/bin/statusline.py index e593164e..00451d14 100755 --- a/bin/statusline.py +++ b/bin/statusline.py @@ -140,7 +140,7 @@ def current_branch(where: str) -> str: if not where: return "" try: - found = subprocess.run(["git", "-C", where, "branch", "--show-current"], capture_output=True, text=True) + found = subprocess.run(["git", "-C", where, "branch", "--show-current"], errors="replace", stderr=subprocess.DEVNULL, stdout=subprocess.PIPE, text=True) except OSError: return "" return found.stdout.strip() if found.returncode == 0 else "" diff --git a/bin/test_statusline.py b/bin/test_statusline.py index d0890733..07d94e92 100644 --- a/bin/test_statusline.py +++ b/bin/test_statusline.py @@ -103,8 +103,9 @@ class Script(unittest.TestCase): ran = self.run_script(stdin) self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, f"{RED}warning: statusline.py could not parse its input as a JSON object{RESET}", "")) - def test_shows_the_branch_of_the_directory(self): - with tempfile.TemporaryDirectory() as checkout: - subprocess.run(["git", "init", "-q", "-b", "trunk", checkout], check=True) - ran = self.run_script(json.dumps({"cwd": checkout})) - self.assertEqual(ran.stdout, SEP.join([f"{CYAN}{checkout}{RESET}", f"{DIM}trunk{RESET}"])) + def test_shows_the_branch_of_the_directory_even_when_it_is_not_utf_8(self): + for branch, shown in ((b"trunk", "trunk"), (b"f\xe5", "f\ufffd")): + with tempfile.TemporaryDirectory() as checkout: + subprocess.run([b"git", b"init", b"-q", b"-b", branch, checkout.encode()], check=True) + ran = self.run_script(json.dumps({"cwd": checkout})) + self.assertEqual((ran.stdout, ran.stderr), (SEP.join([f"{CYAN}{checkout}{RESET}", f"{DIM}{shown}{RESET}"]), "")) -- 2.52.0 From f34320270c6979d251b3666be69c79c8c19b0268 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 14:26:54 +0200 Subject: [PATCH 08/11] Answer the stability, product-owner and prose reviews --- AGENTS.md | 2 +- README.md | 4 ++-- bin/statusline.py | 7 ++++++- bin/test_statusline.py | 6 +++--- docs/decisions.md | 6 +++--- todo.md | 11 ++++++----- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 4e9192d1..0f929337 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,4 +22,4 @@ Decisions live in `docs/decisions.md`: - review: `/security-review` is the security pass of record - 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 -- statusline.py: a field absent, null or of the wrong type drops its segment silently; only input that is not a JSON object warns +- statusline.py: a field absent, null or of the wrong type is left out silently; only input that is not a JSON object warns diff --git a/README.md b/README.md index 917f17f0..9ba08ac4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 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 every project 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/`, the status line among them; 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 every project 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. ## Goals @@ -20,7 +20,7 @@ Me, on my own machines, which take tagged releases. Nobody else depends on it. ## Install -Check out the latest tag in `~/.claude`, with Python 3.11 or newer as `python3` on `PATH`. Link the tool onto `PATH`: `ln -s ~/.claude/bin/loop-claude ~/.local/bin/loop-claude`. Run it only in a sandbox with no direct access to a production environment, such as a dedicated VM: every claude it starts, the interrupt included, skips every permission prompt. +Check out the latest tag in `~/.claude`, with Python 3.11 or newer as `python3` on `PATH`. Link `loop-claude` onto `PATH`: `ln -s ~/.claude/bin/loop-claude ~/.local/bin/loop-claude`. Run `loop-claude` only in a sandbox with no direct access to a production environment, such as a dedicated VM: every claude it starts, the interrupt included, skips every permission prompt. ## Release diff --git a/bin/statusline.py b/bin/statusline.py index 00451d14..9fc3fe32 100755 --- a/bin/statusline.py +++ b/bin/statusline.py @@ -2,6 +2,7 @@ import dataclasses import datetime import json +import locale import math import os import subprocess @@ -152,7 +153,11 @@ def main() -> str: except ValueError: raw = None if not isinstance(raw, dict): - return f"{RED}warning: statusline.py could not parse its input as a JSON object{RESET}" + return f"{RED}warning: statusline.py's input is not a JSON object{RESET}" + try: + locale.setlocale(locale.LC_TIME, "") + except locale.Error: + pass # Zone None: astimezone converts to the machine's own zone, daylight saving included. status = parse(raw, None) return render(status, current_branch(status.directory), os.environ.get("HOME", ""), datetime.datetime.now().astimezone()) diff --git a/bin/test_statusline.py b/bin/test_statusline.py index 07d94e92..6460f565 100644 --- a/bin/test_statusline.py +++ b/bin/test_statusline.py @@ -77,7 +77,7 @@ class Render(unittest.TestCase): east = statusline.parse({"rate_limits": {"seven_day": {"resets_at": 253402300000, "used_percentage": 1}}}, datetime.timezone(datetime.timedelta(hours=2))) self.assertIsNone(east.seven_day.resets_at) - def test_dates_now_and_the_reset_each_in_its_own_offset(self): + def test_counts_time_left_across_an_offset_change(self): cest, cet = datetime.timezone(datetime.timedelta(hours=2)), datetime.timezone(datetime.timedelta(hours=1)) now = datetime.datetime(2026, 10, 25, 0, 30, tzinfo=cest) self.assertEqual(statusline.reset_suffix(datetime.datetime(2026, 10, 25, 5, 0, tzinfo=cet), now), f" {DIM}5h30m left (05:00){RESET}") @@ -101,9 +101,9 @@ class Script(unittest.TestCase): def test_warns_on_the_status_line_for_input_that_is_not_a_json_object(self): for stdin in ("not json", "[]"): ran = self.run_script(stdin) - self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, f"{RED}warning: statusline.py could not parse its input as a JSON object{RESET}", "")) + self.assertEqual((ran.returncode, ran.stdout, ran.stderr), (0, f"{RED}warning: statusline.py's input is not a JSON object{RESET}", "")) - def test_shows_the_branch_of_the_directory_even_when_it_is_not_utf_8(self): + def test_shows_a_branch_name_that_is_not_utf_8(self): for branch, shown in ((b"trunk", "trunk"), (b"f\xe5", "f\ufffd")): with tempfile.TemporaryDirectory() as checkout: subprocess.run([b"git", b"init", b"-q", b"-b", branch, checkout.encode()], check=True) diff --git a/docs/decisions.md b/docs/decisions.md index 89693ce3..0b2c7abd 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -30,7 +30,7 @@ ## 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. The 2026-09-28 run, Junior A, Mid A, the maintainability senior and the inherited architect at depth 1 over every non-test file, blind to `todo.md` and this log, scored Navigation 7.25, Locality 6.0, Shape 6.5, Self-sufficiency 6.25, overall 6.25; on 2026-09-26 they were 7.75, 6.25, 7.0, 6.75, 6.75. Every seat scored Locality 6, and three of four named `run_cycle`'s three-way return and larv-review's re-entry rules, split across the passes on 2026-09-28. The same seats on `rebuild` scored 7.5, 6.63, 6.88, 6.5, 7.0 at 37edc9a, later that day, 7.5, 6.75, 6.88, 6.75, 7.0 at 7f9de5c, 7.38, 6.25, 6.88, 6.75, 6.88 at 2f9ab2f on 2026-09-29, Locality lowest again and every seat naming the reload state and the two retry counters, and 7.5, 7.0, 7.25, 6.75, 7.13 at 2c74bbc later that day, Self-sufficiency lowest and every seat naming the round's definition split across larv-review's two files, and 7.38, 6.75, 7.25, 6.5, 6.88 at 8585257 on 2026-10-01, lowering every dimension but Shape, and the overall, Self-sufficiency lowest and every seat naming larv-review §3's round rules; the places it named under Self-sufficiency and Locality are filed in `todo.md` under 0.1.0, and a later scoring run may not score any dimension or the overall below its best run on `rebuild`, 2026-10-01, lilleman. `rebuild` merged into main under the floor at 8585257's scores, 2026-10-01, lilleman. The 2026-10-01 run on PR #182 (the loop state machine) scored 7.5, 6.5, 6.88, 6.25, 6.38; lilleman shipped that PR under the floor and below `rebuild`'s best run the same day, its places filed in `todo.md` under 0.1.0. The 2026-10-02 run on PR #187 (`loop_claude`'s names, the exit contract) scored 7.75, 7.25, 7.38, 6.88, 7.25 at 70362d0, every seat naming larv-review §3 under Self-sufficiency, and 7.63, 7.13, 7.38, 7.0, 7.13 at 1971dba later that day, the first run at the floor, with no dimension or the overall below its best run on `rebuild`. The 2026-10-02 runs on PR #191 (the status line in Python) scored 7.5, 7.0, 7.13, 6.88, 7.13, then 7.25, 6.75, 7.25, 6.88, 7.0, then 7.63, 6.88, 7.38, 7.0, 7.13, then 7.63, 7.0, 7.25, 6.75, 7.25; every seat rated the status line easy and named under Locality and Self-sufficiency `Effects` leaving file I/O direct, the reload handover, `entries.py`'s heuristics, the judge's rules and loop-claude's Claude Code flags needing outside documents, and larv-review §3, each filed in `todo.md` under 0.1.0, and lilleman shipped that PR under the floor the same day. Valid until the next scoring run, which uses the same four seats. +2026-09-27, lilleman, restating the 2026-09-24 target and extending it to the overall. Serves goal 4. The 2026-09-28 run, Junior A, Mid A, the maintainability senior and the inherited architect at depth 1 over every non-test file, blind to `todo.md` and this log, scored Navigation 7.25, Locality 6.0, Shape 6.5, Self-sufficiency 6.25, overall 6.25; on 2026-09-26 they were 7.75, 6.25, 7.0, 6.75, 6.75. Every seat scored Locality 6, and three of four named `run_cycle`'s three-way return and larv-review's re-entry rules, split across the passes on 2026-09-28. The same seats on `rebuild` scored 7.5, 6.63, 6.88, 6.5, 7.0 at 37edc9a, later that day, 7.5, 6.75, 6.88, 6.75, 7.0 at 7f9de5c, 7.38, 6.25, 6.88, 6.75, 6.88 at 2f9ab2f on 2026-09-29, Locality lowest again and every seat naming the reload state and the two retry counters, and 7.5, 7.0, 7.25, 6.75, 7.13 at 2c74bbc later that day, Self-sufficiency lowest and every seat naming the round's definition split across larv-review's two files, and 7.38, 6.75, 7.25, 6.5, 6.88 at 8585257 on 2026-10-01, lowering every dimension but Shape, and the overall, Self-sufficiency lowest and every seat naming larv-review §3's round rules; the places it named under Self-sufficiency and Locality are filed in `todo.md` under 0.1.0, and a later scoring run may not score any dimension or the overall below its best run on `rebuild`, 2026-10-01, lilleman. `rebuild` merged into main under the floor at 8585257's scores, 2026-10-01, lilleman. The 2026-10-01 run on PR #182 (the loop state machine) scored 7.5, 6.5, 6.88, 6.25, 6.38; lilleman shipped that PR under the floor and below `rebuild`'s best run the same day, its places filed in `todo.md` under 0.1.0. The 2026-10-02 run on PR #187 (`loop_claude`'s names, the exit contract) scored 7.75, 7.25, 7.38, 6.88, 7.25 at 70362d0, every seat naming larv-review §3 under Self-sufficiency, and 7.63, 7.13, 7.38, 7.0, 7.13 at 1971dba later that day, the first run at the floor, with no dimension or the overall below its best run on `rebuild`. The 2026-10-02 runs on PR #191 (the status line in Python) scored 7.5, 7.0, 7.13, 6.88, 7.13; 7.25, 6.75, 7.25, 6.88, 7.0; 7.63, 6.88, 7.38, 7.0, 7.13; and 7.63, 7.0, 7.25, 6.75, 7.25. Every seat rated the status line easy. The places they named under Locality and Self-sufficiency are filed in `todo.md` under 0.1.0, except `entries.py`'s heuristics over Claude Code's transcript format, which the seats scored as the problem's own difficulty. lilleman decided the same day to ship that PR under the floor. Valid until the next scoring run, which uses the same four seats. ## loop-claude: each project's model lives in `~/.claude/loop-claude-models.json`, which only loop-claude writes @@ -84,6 +84,6 @@ 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. -## statusline.py: a field absent, null or of the wrong type drops its segment silently; only input that is not a JSON object warns +## statusline.py: a field absent, null or of the wrong type is left out silently; only input that is not a JSON object warns -2026-10-02, Claude in PR #191, declining the logging audit's 🟢. Applies KISS (`principles/technical-principles.md`). Claude Code's status schema is likelier to drift by renaming or removing a field, which a type warning cannot catch, and absent or null fields are normal (no `rate_limits` for API users); the warning would need a schema table for the rarer case. Valid while Claude Code documents the status input's fields. +2026-10-02, larv-review in PR #191, declining the logging audit's 🟢 to warn on a field of the wrong type. Applies KISS (`principles/technical-principles.md`). Absent and null fields are normal: API users get no `rate_limits`. Claude Code's schema changes more often by renaming or removing a field than by changing a field's type, and a type warning catches neither. Warning on types would need a table of the schema to catch only the rarer change. Valid while `parse` reads the fields one by one, with no schema table. diff --git a/todo.md b/todo.md index a02bc410..cbef185e 100644 --- a/todo.md +++ b/todo.md @@ -15,12 +15,13 @@ - **Give principles-auditor and prose-reviewer a way to list the project's files.** In the 2026-09-30 audit run their `tools: Read, Grep, Glob` gave them only Read. Each read the files that imports and `.gitignore` named, and listed the files it could not reach. Goal 4.1. - **Give the reviewer agents only the tools they need.** `systems-architect.md`, `product-owner-reviewer.md` and `stability-reviewer.md` have no `tools:` line, so each can edit the branch it reviews; `review-findings.md` says a reviewer edits nothing. Goal 4.1. - **Measure test coverage in the suite, and fail on a drop.** Nothing measures it, so "Test coverage should not decline" cannot be held. Goal 4.1. -- **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 §4 rule 1 skips even that when the last stability round left the suite green: an unattended chunk can merge on the worker's own word. Goal 4.1. +- **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. Goal 4.1. - **Make larv-review §3 applicable on its own, cite its rules by name, and say where a pass's round count is recorded.** Applying one rule of "Round cap", "Re-entry" or "Findings" takes `review-findings.md`, `CLAUDE.md` → "Vocabulary" and the decision log open beside it. The rules cite each other by number ("Round cap" rule 6), so a renumbering breaks a citation silently. Nothing says where a pass's round count is recorded, so a resumed or compacted session loses it. Goal 4.1. - **Read transcript and stream entries into typed values where they are read.** `read_transcript` and `run_worker` pass raw `dict`s, so about ten accessors in `entries.py` re-check shapes deep inside and mypy cannot check `render`, `human_turns` or `run_worker`. Goal 4.1. - **Inject output and storage into `Effects`, and test what each step prints.** `print` and `open` are called directly across `bin/loop_claude/`, so the stderr lines of the CLI contract can be checked only through the black-box tests. Goal 4.1. -- **Move the judge's transcript rendering from `claude_code/transcript.py` into `cycle/`.** `render`, `part_line` and `JUDGED_TOOL_INPUT` shape what the judge sees, so its input is split from `JUDGED_TRANSCRIPT_TAIL` across two packages, and `claude_code/` no longer holds only Claude Code's shapes as its docstring says. Goal 4.1. -- **Make `JUDGE_RULES` and the Claude Code flags `loop-claude` passes readable without `CLAUDE.md` or Claude Code's docs open.** The 2026-10-02 scoring runs on PR #191 named both under Self-sufficiency: the judge's rules use "chunk", "premises" and "a release ready to cut" from `CLAUDE.md` with no link, and `--resume`, `--session-id`, `--no-session-persistence`, `--json-schema` and stream-json's result event go unexplained in `worker.py` and `judge.py`. Goal 4.1. +- **Move the judge's transcript rendering from `claude_code/transcript.py` into `cycle/`.** `render`, `part_line` and `JUDGED_TOOL_INPUT` shape what the judge sees, so what the judge sees is shaped in two packages: those three in `claude_code/`, and `JUDGED_TRANSCRIPT_TAIL` in `cycle/judge.py`; and `claude_code/` no longer holds only Claude Code's shapes as its docstring says. Goal 4.1. +- **Make `JUDGE_RULES` and the Claude Code flags `loop-claude` passes readable without `CLAUDE.md` or Claude Code's docs open.** The 2026-10-02 scoring runs on PR #191 named both under Self-sufficiency: the judge's rules use "chunk" and "a release ready to cut" from `CLAUDE.md` with no link, and `--resume`, `--session-id`, `--no-session-persistence`, `--json-schema` and stream-json's result event go unexplained in `worker.py` and `judge.py`. Goal 4.1. +- **Encode and decode the reload handover in `loop/reload.py` alone.** `LoopRun` is built in `loop/main.py`'s `loop_run_from` and decoded in `reload.py`'s `decode_handed`, so a field change means holding both files and two script versions; the 2026-10-02 scoring runs on PR #191 named it under Locality. Goal 4.1. - **Give each cycle phase one name across its state, step and event.** Today `Judging` runs `rule` and yields `Ruled`, and `Finishing` runs `close`, which also deletes the session, and yields `Archived`. Goal 4.1. - **Enable the `claude-security` plugin in `settings.json`, or drop larv-review's full-scan row.** No machine has it enabled, so every chunk that fires the pass skips it. Goal 4.1. - **Give `settings.json`'s model one writer, and sort its keys.** Claude Code rewrites `"model"` in this tracked file whenever a model is picked, so one `/model` dirties the checkout and overrides the synced choice. Goal 4.3. @@ -32,10 +33,10 @@ - End larv-review with a machine-readable summary, and have `loop-claude` copy it from the transcript onto the line: agents launched and rounds per pass; findings per pass by severity, inside the chunk's diff and outside it; and the comprehension scores when the panel ran. - **Write a `workflow-review` skill that reads the stats and files each change it proposes to the workflow as a plan item, and have `AGENTS.md` run it on the chunk shipping a release's last item.** The workflow is `CLAUDE.md`, `principles/`, the skills, the agents and `loop-claude`. The skill's signals: findings outside the chunk's diff and comprehension scores per release, both from the stats; fixes after merge, from git; and the human's corrections, from the archived transcripts. Goal 4.4. - **Bench about one chunk in ten against an open PR that changes the workflow, and have a blind claude rule which run better serves this repo's goal 4.** Redo the chunk under the PR, from the commit it started from. The ruling claude is not told which run is which. `loop-claude` picks the chunk at random, small diffs and big ones alike; with no such PR open, no bench runs. The same outcome with less code and prose, in the chunk or in the workflow, also counts as better. The PR merges only once three benches rule it better. A bench that rules it worse closes the PR and records, in `docs/workflow-learnings.md`, what the PR changed and why it lost. The ruling and both runs' numbers go on the chunk's stats line. Start from `workflow-bench/`, written for the 2026-09-30 bench's four fixed cases. Needs the stats line. Goals 4.1 and 4.4. -- **Make the small fixes filed by the 2026-10-02 principles audit against `workflow-bench/`.** The bench item starts from it. Goals 2 and 4.1. +- **Make the small fixes filed by the 2026-10-02 principles audit against `workflow-bench/`.** The bench item above starts from `workflow-bench/`. Goals 2 and 4.1. - Test `judge.py`'s `blind` and `bench.py`'s rate-limit parsing, and run mypy on both. - Let `judge.py` import `bench` without `BENCH_SOURCES` set; today reading it at import raises a bare `KeyError`. - - Key `CASES`, `PREFIX` and `TRUTH_END` in one table, sorted. + - Merge `CASES`, `PREFIX` and `TRUTH_END` into one table keyed by case, sorted. - Report a failed `git` per run; today `check=True` aborts `main` and drops every other run's result. - Take the model from a flag or env var, and inject the clock, sleep and shuffle. - Keep the bench's run logs where the transcript archive's backup reaches them. -- 2.52.0 From 3da416bd702f6f1d42b11fd69b18cdd7564c4f01 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 14:28:18 +0200 Subject: [PATCH 09/11] Describe the reload handover item by what main.py holds --- todo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/todo.md b/todo.md index cbef185e..5e0ac5c0 100644 --- a/todo.md +++ b/todo.md @@ -21,7 +21,7 @@ - **Inject output and storage into `Effects`, and test what each step prints.** `print` and `open` are called directly across `bin/loop_claude/`, so the stderr lines of the CLI contract can be checked only through the black-box tests. Goal 4.1. - **Move the judge's transcript rendering from `claude_code/transcript.py` into `cycle/`.** `render`, `part_line` and `JUDGED_TOOL_INPUT` shape what the judge sees, so what the judge sees is shaped in two packages: those three in `claude_code/`, and `JUDGED_TRANSCRIPT_TAIL` in `cycle/judge.py`; and `claude_code/` no longer holds only Claude Code's shapes as its docstring says. Goal 4.1. - **Make `JUDGE_RULES` and the Claude Code flags `loop-claude` passes readable without `CLAUDE.md` or Claude Code's docs open.** The 2026-10-02 scoring runs on PR #191 named both under Self-sufficiency: the judge's rules use "chunk" and "a release ready to cut" from `CLAUDE.md` with no link, and `--resume`, `--session-id`, `--no-session-persistence`, `--json-schema` and stream-json's result event go unexplained in `worker.py` and `judge.py`. Goal 4.1. -- **Encode and decode the reload handover in `loop/reload.py` alone.** `LoopRun` is built in `loop/main.py`'s `loop_run_from` and decoded in `reload.py`'s `decode_handed`, so a field change means holding both files and two script versions; the 2026-10-02 scoring runs on PR #191 named it under Locality. Goal 4.1. +- **Encode, decode and check the reload handover in `loop/reload.py` alone.** `reload.py` encodes `LoopRun` and decodes it, but `main.py`'s `loop_run_from` checks the decoded fields and words the error, so changing `LoopRun`'s fields means editing both files. The 2026-10-02 scoring runs on PR #191 named it under Locality. Goal 4.1. - **Give each cycle phase one name across its state, step and event.** Today `Judging` runs `rule` and yields `Ruled`, and `Finishing` runs `close`, which also deletes the session, and yields `Archived`. Goal 4.1. - **Enable the `claude-security` plugin in `settings.json`, or drop larv-review's full-scan row.** No machine has it enabled, so every chunk that fires the pass skips it. Goal 4.1. - **Give `settings.json`'s model one writer, and sort its keys.** Claude Code rewrites `"model"` in this tracked file whenever a model is picked, so one `/model` dirties the checkout and overrides the synced choice. Goal 4.3. -- 2.52.0 From 96a3f845d147a12f3fc9453efa4539e8cf2a8a84 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 14:48:24 +0200 Subject: [PATCH 10/11] Keep the reset's weekday English on every machine --- AGENTS.md | 1 + bin/statusline.py | 5 ----- docs/decisions.md | 4 ++++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 0f929337..1d470c80 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -23,3 +23,4 @@ Decisions live in `docs/decisions.md`: - 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 - statusline.py: a field absent, null or of the wrong type is left out silently; only input that is not a JSON object warns +- statusline.py: the reset's weekday is English on every machine diff --git a/bin/statusline.py b/bin/statusline.py index 9fc3fe32..a8fe12e1 100755 --- a/bin/statusline.py +++ b/bin/statusline.py @@ -2,7 +2,6 @@ import dataclasses import datetime import json -import locale import math import os import subprocess @@ -154,10 +153,6 @@ def main() -> str: raw = None if not isinstance(raw, dict): return f"{RED}warning: statusline.py's input is not a JSON object{RESET}" - try: - locale.setlocale(locale.LC_TIME, "") - except locale.Error: - pass # Zone None: astimezone converts to the machine's own zone, daylight saving included. status = parse(raw, None) return render(status, current_branch(status.directory), os.environ.get("HOME", ""), datetime.datetime.now().astimezone()) diff --git a/docs/decisions.md b/docs/decisions.md index 0b2c7abd..bcdc66a3 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -87,3 +87,7 @@ ## statusline.py: a field absent, null or of the wrong type is left out silently; only input that is not a JSON object warns 2026-10-02, larv-review in PR #191, declining the logging audit's 🟢 to warn on a field of the wrong type. Applies KISS (`principles/technical-principles.md`). Absent and null fields are normal: API users get no `rate_limits`. Claude Code's schema changes more often by renaming or removing a field than by changing a field's type, and a type warning catches neither. Warning on types would need a table of the schema to catch only the rarer change. Valid while `parse` reads the fields one by one, with no schema table. + +## statusline.py: the reset's weekday is English on every machine + +2026-10-02, lilleman in PR #191, answering the product-owner review: the old `date +%a` followed `LC_TIME`; Python's `%a` does only after `setlocale`, which made the pure `reset_suffix` read process-wide state. Serves goal 1: the status line reads the same on every machine. Valid while the status line is read by its author alone. -- 2.52.0 From ec3b584cedc2bde9a288a12b6f4d92a1e61b8b1b Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Fri, 2 Oct 2026 14:49:31 +0200 Subject: [PATCH 11/11] Say at the strftime call why the weekday stays English --- AGENTS.md | 1 - bin/statusline.py | 1 + docs/decisions.md | 4 ---- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 1d470c80..0f929337 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -23,4 +23,3 @@ Decisions live in `docs/decisions.md`: - 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 - statusline.py: a field absent, null or of the wrong type is left out silently; only input that is not a JSON object warns -- statusline.py: the reset's weekday is English on every machine diff --git a/bin/statusline.py b/bin/statusline.py index a8fe12e1..f80e1987 100755 --- a/bin/statusline.py +++ b/bin/statusline.py @@ -99,6 +99,7 @@ def reset_suffix(at: datetime.datetime, now: datetime.datetime) -> str: left = f"{seconds // 3600}h{seconds % 3600 // 60}m" else: left = f"{seconds // 60}m" + # %a stays English on every machine; setlocale would make this read process-wide state. clock = at.strftime("%H:%M" if at.date() == now.date() else "%a %H:%M") return f" {DIM}{left} left ({clock}){RESET}" diff --git a/docs/decisions.md b/docs/decisions.md index bcdc66a3..0b2c7abd 100644 --- a/docs/decisions.md +++ b/docs/decisions.md @@ -87,7 +87,3 @@ ## statusline.py: a field absent, null or of the wrong type is left out silently; only input that is not a JSON object warns 2026-10-02, larv-review in PR #191, declining the logging audit's 🟢 to warn on a field of the wrong type. Applies KISS (`principles/technical-principles.md`). Absent and null fields are normal: API users get no `rate_limits`. Claude Code's schema changes more often by renaming or removing a field than by changing a field's type, and a type warning catches neither. Warning on types would need a table of the schema to catch only the rarer change. Valid while `parse` reads the fields one by one, with no schema table. - -## statusline.py: the reset's weekday is English on every machine - -2026-10-02, lilleman in PR #191, answering the product-owner review: the old `date +%a` followed `LC_TIME`; Python's `%a` does only after `setlocale`, which made the pure `reset_suffix` read process-wide state. Serves goal 1: the status line reads the same on every machine. Valid while the status line is read by its author alone. -- 2.52.0