From 08855e8055ce5780199ffbf1dbbb55b9f155bc71 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Wed, 28 Oct 2026 18:33:31 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20architecture=20round=201:=201=20?= =?UTF-8?q?=F0=9F=94=B4,=202=20=F0=9F=9F=A1=20(0=20misread);=20render=20th?= =?UTF-8?q?e=20stamp=20through=20Effects.local=5Ftime?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- bin/loop_claude/effects.py | 3 ++- bin/loop_claude/loop/main.py | 1 + bin/loop_claude/terminal.py | 8 +++----- bin/loop_claude/test_loop_claude.py | 26 ++++++++++++++------------ 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bc2bde0..868506b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -- `loop-claude` now opens every message it prints with the machine's local time, as in `2026-10-28 11:46:01`, so you can see when each happened, such as how long a question has waited. A message of several lines, such as a question, carries the time on its first line only. +- `loop-claude` now opens every message it prints with the machine's local time, as in `2026-10-28 11:46:01`, so you can see when each happened, such as how long a question has waited. A message of several lines, such as a question, carries the time on its first line only. The time a usage-limit wait ends at now also shows seconds, and no zone name. - larv-review now gives each review pass at most two rounds per chunk, where it gave three and then asked for more, and no longer asks: the fixes answering a pass's second round merge once the gate passes. rule-hook's new `round-cap` rule refuses a round commit that would take a pass past round 2, such as `Answer stability round 3: …`, and takes no override. It counts the pass's earlier round commits on the branch, so a third commit titled round 2 is refused too. `larv-review round-count` marks a pass at two rounds as at the cap. - rule-hook has a new rule, `repeat-read`, and now runs before each Read call too. It blocks a Read, or a Bash `cat`, `head` or `sed -n ',p'` of one file, when every line it asks for is already in the agent's context, and the block names those lines. The rule takes no override. - A line is in context when an earlier read's result in the agent's own transcript showed it since the last compaction, as the file holds it now. A subagent is judged on its own transcript, not its session's. diff --git a/bin/loop_claude/effects.py b/bin/loop_claude/effects.py index 831cbd3a..27d37637 100644 --- a/bin/loop_claude/effects.py +++ b/bin/loop_claude/effects.py @@ -37,6 +37,7 @@ class Effects: execv: typing.Callable[[str, list[str]], None] git: Git input: typing.Callable[[str], str] + # A time of day in the machine's zone, as `2026-10-28 11:46:01`. local_time: typing.Callable[[float], str] # The machine's memory; None where it cannot be read. memory: typing.Callable[[], Memory | None] @@ -68,7 +69,7 @@ def system_effects() -> Effects: execv=os.execv, git=git_repo.git, input=input, - local_time=lambda seconds: time.strftime("%Y-%m-%d %H:%M %Z", time.localtime(seconds)), + local_time=lambda seconds: time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(seconds)), memory=read_memory, now=time.time, on_terminal=lambda: sys.stdin.isatty() and sys.stdout.isatty(), diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index 02352798..33ca0d7f 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -287,6 +287,7 @@ def fetched_plan(root: str) -> DefaultPlan | Failure: def plan_item(plan: DefaultPlan | Failure, effects: Effects) -> Item | None: """The item that routes a chunk, chunk_pick.chunk_item's pick from the default branch; None without one, so the chunk runs on the project's rung.""" + # It says why through effects, as every loop-claude function that prints does; todo.md item 51 moves all of them to one injected effect, and splitting this one off first would only be undone. if isinstance(plan, Failure): item: Item | Failure | None = plan elif isinstance(plan.todo, Failure): diff --git a/bin/loop_claude/terminal.py b/bin/loop_claude/terminal.py index 05b9ec91..9ebaa0b2 100644 --- a/bin/loop_claude/terminal.py +++ b/bin/loop_claude/terminal.py @@ -1,13 +1,11 @@ import sys -import time from loop_claude.effects import Effects -# The spelling `YYYY-MM-DD HH:MM:SS` in local time, never UTC, is lilleman's call of 2026-10-28. +# The spelling `YYYY-MM-DD HH:MM:SS` in local time, never UTC, is lilleman's call of 2026-10-28; Effects.local_time renders it. def say(text: str, effects: Effects, *, stdout: bool = False) -> None: - """Prints text on stderr, or on stdout where stdout, opening its first line with the machine's local time as `2026-10-28 11:46:01`, so the human sees when it happened. Blank lines before the text stay blank, and only its first line gets the time.""" + """Prints text on stderr, or on stdout where stdout, opening its first line with the machine's local time, so the human sees when it happened. Blank lines before the text stay blank, and only its first line gets the time.""" body = text.lstrip("\n") blanks = text[: len(text) - len(body)] - stamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(effects.now())) - print(f"{blanks}{stamp} {body}", file=sys.stdout if stdout else sys.stderr, flush=True) + print(f"{blanks}{effects.local_time(effects.now())} {body}", file=sys.stdout if stdout else sys.stderr, flush=True) diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 10a35b6e..76fa9808 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -20,7 +20,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from routing_figures import archive, measure from loop_claude.project import checkout, model_choice, records from chunk_pick import DefaultPlan, LastCut -from loop_claude.effects import Effects, PYTHON_TIMEOUT, run_python +from loop_claude.effects import Effects, PYTHON_TIMEOUT, run_python, system_effects from claude_code import entries, reply, session from loop_claude import escalation_mark, paths, routing, terminal from failure import Failure @@ -47,17 +47,8 @@ OPUS_179_AT_6 = '{"model": "claude-opus-5-5", "effort": "medium", "item": 179, " CWD = pathlib.Path("/c") NOW = 1790000000 -# How a line said at NOW opens in a zone two hours ahead of UTC, which setUpModule sets: a stamp in UTC would read 14:13:20. -STAMP = "2026-09-21 16:13:20" - - -def setUpModule(): - zone = unittest.mock.patch.dict(os.environ, {"TZ": "XXX-2"}) - zone.start() - # Cleanups run last in, first out: the zone is restored before the clock rereads it. - unittest.addModuleCleanup(time.tzset) - unittest.addModuleCleanup(zone.stop) - time.tzset() +# How a line said at NOW opens, with FakeEffects' local_time. +STAMP = f"<{NOW}>" def assistant(*parts): @@ -1118,6 +1109,17 @@ class ChunkFacts(unittest.TestCase): self.assertEqual((resumed.made("python"), facts), ([], "")) +class LocalTime(unittest.TestCase): + def test_renders_seconds_in_the_machines_zone(self): + # A POSIX zone two hours ahead of UTC, so a time in UTC would read 14:13:20. Cleanups run last in, first out: the zone is restored before the clock rereads it. + self.addCleanup(time.tzset) + zone = unittest.mock.patch.dict(os.environ, {"TZ": "XXX-2"}) + zone.start() + self.addCleanup(zone.stop) + time.tzset() + self.assertEqual(system_effects().local_time(NOW), "2026-09-21 16:13:20") + + class PythonEffect(unittest.TestCase): def test_runs_a_script_in_the_given_directory(self): with tempfile.TemporaryDirectory() as cwd: