Answer stability round 1: 0 🔴, 2 🟡 (0 misread); inject home into the goals file lookup and rename readme in ranking

This commit is contained in:
2026-11-13 00:29:22 +01:00
parent ad6118d19f
commit 7b6201cab6
27 changed files with 110 additions and 96 deletions
+1 -1
View File
@@ -252,7 +252,7 @@ def answer_checked(verdict: Verdict, quotable: str) -> Verdict:
def judge_prompt(brief: Brief) -> tuple[str, Grounds]:
"""The prompt, and what the judge's quotes are checked against."""
head = (
f"From the goals file:\n{brief.premises}\n\n"
f"From the goals file, {brief.premises}\n\n"
f"The records: the project's working rules and decisions, then the human's rules for every project:\n{brief.records or 'none'}\n\n"
f"The task the worker was given:\n{brief.task}\n\n"
"What the worker did and said, what the human typed on [human] lines and what loop-claude told it on [loop] lines, latest last:\n"
+1 -1
View File
@@ -33,7 +33,7 @@ def fresh(task: str, premises: str, route: Route, project: Rung | None, facts: s
"""A chunk's first prompt; facts is preflight_facts' or preflight_failed's text."""
routed = f"{routed_by(route, project)} {recount(route)}" if route.item else " ".join(rung_sentences(route, project))
opening = f"{routed}\n\n" if routed else ""
return f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one. {READING_RULE} {NAME_THE_ITEMS}\n\n{opening}{facts}\n\nThe chunk's todo.md items, or else the task above, set its scope. The goals below, {AFTER_CODE_HEALTH}, choose between ways to deliver that scope, and never widen it.\n\nFrom the goals file:\n{premises}"
return f"{task}\n\nContinue any open draft PR or worktree for the chunk before creating a new one. {READING_RULE} {NAME_THE_ITEMS}\n\n{opening}{facts}\n\nThe chunk's todo.md items, or else the task above, set its scope. The goals below, {AFTER_CODE_HEALTH}, choose between ways to deliver that scope, and never widen it.\n\nFrom the goals file, {premises}"
def routed_by(route: Route, project: Rung | None) -> str:
+1 -1
View File
@@ -72,7 +72,7 @@ def run_loop(argv: list[str], env: typing.Mapping[str, str], paths: Paths, launc
def next_cycle(loop_run: LoopRun, loop: Loop) -> Cycle | Stop:
"""The cycle loop_run runs next, from the premises, the records and the project's models read afresh, and the route the chunk runs on; the stop where one of them cannot be read."""
premises = read_premises(loop.root)
premises = read_premises(loop.root, loop.paths.home)
if isinstance(premises, Failure):
return Stop(1, premises.reason)
records = read_records(loop.root, loop.paths.claude_dir)
+8 -8
View File
@@ -3,13 +3,13 @@ HELP = """Run a task as headless claude cycles; a judge interrupts only when a d
usage: loop-claude <task>
Run it anywhere inside a project checkout whose goals file has ## Goals and ## Audience, the
premises: the file its config, ~/.claude-projects/<key>/config.toml, sets as goals-and-audience,
which `project-config goals-and-audience` prints. The task runs at the checkout root. Each cycle a
worker runs the task. A chunk's first worker prompt also quotes the premises. They, with code health
(~/.claude/CLAUDE.md → "Shared goal") ranked first unless the goals file voids it, choose between
ways to deliver the chunk's todo.md items, or else the task, and never widen them. A judge then
reads the transcript's end, the premises, and the records: the project's AGENTS.md and
docs/decisions.md, and the human's ~/.claude/CLAUDE.md, ~/.claude/rules/*.md and
premises. The goals file is the one the project's config, ~/.claude-projects/<key>/config.toml, sets
as goals-and-audience; `project-config goals-and-audience` prints it. The task runs at the checkout
root. Each cycle a worker runs the task. A chunk's first worker prompt also quotes the premises.
They, with code health (~/.claude/CLAUDE.md → "Shared goal") ranked first unless the goals file
voids it, choose between ways to deliver the chunk's todo.md items, or else the task, and never
widen them. A judge then reads the transcript's end, the premises, and the records: the project's
AGENTS.md and docs/decisions.md, and the human's ~/.claude/CLAUDE.md, ~/.claude/rules/*.md and
~/.claude/skills/larv-review/standards/*.md, where they exist. It rules whether the chunk, the work
of one PR, is finished. A chunk stays unfinished until each answer the human typed in it that a
later chunk could need is recorded: the premises or the records hold it, or the transcript shows the
@@ -100,7 +100,7 @@ Exit 1, saying why, when:
- git cannot start or finds no checkout
- the goals file, or AGENTS.md, docs/decisions.md, ~/.claude/CLAUDE.md, ~/.claude/rules/*.md or
~/.claude/skills/larv-review/standards/*.md where they exist, cannot be read or is not UTF-8
- no config names the checkout, or the goals file holds no premises
- no config names the checkout, its config cannot be read, or the goals file holds no premises
- the models file cannot be read or written
- claude leaves no transcript
- a transcript cannot be read or archived
+9 -7
View File
@@ -1,12 +1,14 @@
import pathlib
from failure import Failure
from project_config.main import goals_file
from loop_claude.project.text_file import read_utf8
from records.markdown_text import sections
def read_premises(root: str) -> str | Failure:
"""## Goals and ## Audience in the file root's project config names for them; a Failure where no config names it, it cannot be read, or it lacks either, or holds one twice or empty."""
path = goals_file(root)
def read_premises(root: str, home: pathlib.Path) -> str | Failure:
"""The goals file's path, then its ## Goals and ## Audience; the goals file is the one that the config under home of root's project names. A Failure where no config names root's checkout, the file cannot be read, or the file lacks a section, holds one twice or leaves one empty."""
path = goals_file(root, home)
if isinstance(path, Failure):
return Failure(f"{path.reason} - no premises.")
text = read_utf8(str(path.parent), path.name, "no premises")
@@ -16,9 +18,9 @@ def read_premises(root: str) -> str | Failure:
for name in ("Goals", "Audience"):
bodies = found.get(name, [])
if not bodies:
return Failure(f"{path.name} has no ## {name} heading - no premises.")
return Failure(f"{path} has no ## {name} heading - no premises.")
if len(bodies) > 1:
return Failure(f"{path.name} has ## {name} more than once - no premises.")
return Failure(f"{path} has ## {name} more than once - no premises.")
if not bodies[0]:
return Failure(f"{path.name} has no text under ## {name} - no premises.")
return f"## Goals\n{found['Goals'][0]}\n\n## Audience\n{found['Audience'][0]}"
return Failure(f"{path} has no text under ## {name} - no premises.")
return f"{path}:\n## Goals\n{found['Goals'][0]}\n\n## Audience\n{found['Audience'][0]}"
+5 -5
View File
@@ -342,10 +342,10 @@ class Premises(unittest.TestCase):
readmes = {
None: "README.md in {root}: No such file or directory - no premises.",
b"# P\n## Goals\n1. g\xff\n## Audience\nme\n": "README.md in {root} is not UTF-8 on line 3 - no premises.",
b"# P\n## Audience\nme\n": "README.md has no ## Goals heading - no premises.",
b"# P\n## Goals\n1. g\n": "README.md has no ## Audience heading - no premises.",
b"# P\n## Goals\n\n## Audience\nme\n": "README.md has no text under ## Goals - no premises.",
b"# P\n## Goals\n1. g\n## Audience\nme\n## Audience\nyou\n": "README.md has ## Audience more than once - no premises.",
b"# P\n## Audience\nme\n": "{root}/README.md has no ## Goals heading - no premises.",
b"# P\n## Goals\n1. g\n": "{root}/README.md has no ## Audience heading - no premises.",
b"# P\n## Goals\n\n## Audience\nme\n": "{root}/README.md has no text under ## Goals - no premises.",
b"# P\n## Goals\n1. g\n## Audience\nme\n## Audience\nyou\n": "{root}/README.md has ## Audience more than once - no premises.",
}
(checkout.root / "sub").mkdir()
for text, said in readmes.items():
@@ -424,7 +424,7 @@ class Cycles(unittest.TestCase):
self.assertIsNone(argument(workers[1], "--name"))
self.assertEqual(argument(workers[2], "--session-id"), session)
self.assertTrue(argument(workers[0], "-p").startswith(f"{TASK}\n\nContinue any open draft PR"))
self.assertTrue(argument(workers[0], "-p").endswith("The chunk's todo.md items, or else the task above, set its scope. The goals below, " 'which rank after code health (~/.claude/CLAUDE.md → "Shared goal") unless the goals file voids it' ", choose between ways to deliver that scope, and never widen it.\n\nFrom the goals file:\n## Goals\n1. Work.\n\n## Audience\nMe."))
self.assertTrue(argument(workers[0], "-p").endswith("The chunk's todo.md items, or else the task above, set its scope. The goals below, " 'which rank after code health (~/.claude/CLAUDE.md → "Shared goal") unless the goals file voids it' ", choose between ways to deliver that scope, and never widen it.\n\nFrom the goals file, " f"{checkout.root}/README.md:\n## Goals\n1. Work.\n\n## Audience\nMe."))
self.assertIn("main or master", argument(workers[0], "-p"))
self.assertNotIn(TASK, argument(workers[1], "-p"))
self.assertIn("Even then, it is finished only once every answer the human typed in it", argument(workers[1], "-p"))
+2 -2
View File
@@ -520,7 +520,7 @@ Spent since 2026-09-21T14:13:20Z, in tokens of input, cache write 5m, cache writ
self.assertEqual(len(judge_prompts), 2)
self.assertNotIn("the second", judge_prompts[0])
self.assertIn("[human] the second", judge_prompts[1])
self.assertIn("From the goals file:\n## Goals", judge_prompts[0])
self.assertIn("From the goals file, ## Goals", judge_prompts[0])
self.assertIn("The task the worker was given:\nDo it.", judge_prompts[0])
def test_a_question_the_records_answer_resumes_the_worker_with_the_answer_three_times_a_cycle(self):
@@ -2026,7 +2026,7 @@ class HelpLimits(unittest.TestCase):
class ExitContract(unittest.TestCase):
def test_every_exit_1_stop_has_its_clause_in_help(self):
read, git, premises_ = "a transcript cannot be read or archived", "git cannot start or finds no checkout", "no config names the checkout, or the goals file holds no premises"
read, git, premises_ = "a transcript cannot be read or archived", "git cannot start or finds no checkout", "no config names the checkout, its config cannot be read, or the goals file holds no premises"
models_ = "the models file cannot be read or written"
names = (*records.RECORD_FILES, records.HUMAN_RULE_NAMES[0], *(f"{folder}*.md" for folder in records.HUMAN_RULE_NAMES[1:]))
unreadable = f"the goals file, or {', '.join(names[:-1])} or {names[-1]} where they exist, cannot be read or is not UTF-8"