Answer product-owner round 1: 0 🔴, 1 🟡 (0 misread); name the file prepare-scoring cannot read, and say a scoring run's means only once it is recorded

This commit is contained in:
2026-11-13 03:17:14 +01:00
parent 5331a34000
commit 4b3ac621b8
3 changed files with 22 additions and 14 deletions
+6 -6
View File
@@ -39,7 +39,7 @@ def record_ruling(votes_file: pathlib.Path, home: pathlib.Path, now: float) -> s
def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home: pathlib.Path, now: float, say: Say, warn: Say) -> Failure | None:
"""Records the scoring run in the scores file and ranks the plan again. It says each result as it holds, since a later step may fail with the run already recorded."""
"""Records the scoring run the scores file holds in the comprehension history, and ranks the plan again. It says each result as soon as it has it, since a later step may fail after the run is recorded."""
read = read_seats(scores_file, False, home, now)
if isinstance(read, Failure):
return read
@@ -60,15 +60,15 @@ def record_scoring(default: str, scores_file: pathlib.Path, ids: list[int], home
if isinstance(todo, Failure):
return todo
_, plan = todo
appended_to = append(given.read, scoring_entry(named.title, scoring), home)
if isinstance(appended_to, Failure):
return appended_to
say(appended_to)
say(f"Means: {', '.join(f'{name} {value}' for name, value in zip(DIMENSIONS, scoring.means))}.")
if under := under_floor(scoring.means):
say(f"Floor: {', '.join(under)} under the floor of {FLOOR}.")
if step := floor_step(scoring.means, plan, ids):
say(step)
appended_to = append(given.read, scoring_entry(named.title, scoring), home)
if isinstance(appended_to, Failure):
return appended_to
say(appended_to)
reranked = rerank(home, warn)
removed = removed_setup(checkout, home)
return reranked or (removed and Failure(f"recorded the run, but {removed.reason}"))
@@ -152,7 +152,7 @@ def history_file(home: pathlib.Path) -> tuple[pathlib.Path, str] | Failure:
def append(read: str, entry: str, home: pathlib.Path) -> str | Failure:
"""Append entry unless the history already holds one on what the seats read; what the tool prints once it has."""
"""Appends entry and returns the line the tool prints; a Failure where the history already holds an entry on what the seats read."""
read_history = history_file(home)
if isinstance(read_history, Failure):
return read_history
+2 -2
View File
@@ -150,8 +150,8 @@ since Claude Code starts the subagent whatever the hook exits with.
Exit 1, saying why, on unknown arguments, an unknown item ID, a seats file it cannot read or that
breaks the shape above, a todo.md that fails rank_todo.py after record-scoring records a run, or
when git cannot start, finds no checkout or no default branch, cannot fetch origin for ruling-base,
needs-scoring-run, scoring-run-owed or record-scoring, or cannot read or write the history, todo.md or the review
folder.
needs-scoring-run, scoring-run-owed or record-scoring, or cannot read or write the history, todo.md, the review
folder or a file prepare-scoring reads.
"""
import pathlib
import re
+14 -6
View File
@@ -94,6 +94,14 @@ def file_globs(paths: list[str], forbidden_files: list[str]) -> str:
return listed(globs + sorted(f"`{path}`" for path in read if "/" not in path), "and") + (f", {TEST_FILES}" if tested & set(folders) else "")
def read(path: pathlib.Path) -> str:
"""path's text. Raises OSError where it cannot be read, and where it is not UTF-8, naming path as that error alone would not."""
try:
return path.read_text()
except UnicodeDecodeError as failure:
raise OSError(f"{path}: {failure}") from failure
def preloaded_files(main: pathlib.Path, home: pathlib.Path) -> str:
"""The files Claude Code loads into a seat started in main before its first tool call: each CLAUDE.md, the files it imports, and each rule file without `paths:`, leaving out those `claudeMdExcludes` names."""
excludes = claude_md_excludes(main, home)
@@ -105,8 +113,8 @@ def preloaded_files(main: pathlib.Path, home: pathlib.Path) -> str:
for shown, claude_md, rules in (("~/.claude/", home / ".claude" / CLAUDE_MD, home / ".claude" / "rules"), ("", main / CLAUDE_MD, main / ".claude" / "rules")):
if claude_md.is_file() and kept(claude_md):
found.append(f"`{shown}{CLAUDE_MD}`")
found += [f"`{shown}{name}`, which it imports" for name in re.findall(r"^@(\S+)", claude_md.read_text(), re.M)]
found += [f"`{shown}{rule.relative_to(claude_md.parent)}`" for rule in sorted(rules.glob("*.md")) if kept(rule) and not re.search(r"^paths:", rule.read_text(), re.M)]
found += [f"`{shown}{name}`, which it imports" for name in re.findall(r"^@(\S+)", read(claude_md), re.M)]
found += [f"`{shown}{rule.relative_to(claude_md.parent)}`" for rule in sorted(rules.glob("*.md")) if kept(rule) and not re.search(r"^paths:", read(rule), re.M)]
return listed(found, "and") if found else "none"
@@ -129,7 +137,7 @@ def prompt_parts() -> dict[str, str] | Failure:
"""seat-prompts.md's opening, shared brief and each report as their fenced text, and each seat's background, keyed by heading or label."""
path = PANEL / "seat-prompts.md"
try:
text = path.read_text()
text = read(path)
except OSError as failure:
return Failure(f"cannot read {path}: {failure}")
parts = {}
@@ -166,8 +174,8 @@ def prepare_scoring(worktree: str, preloaded: str | None, home: pathlib.Path) ->
if not source.is_file() and (own := pathlib.Path(worktree) / "skills" / "comprehension-panel" / "seat-prompts.md").is_file():
source = own
try:
rules, skill = source.read_text() if source.is_file() else "", (PANEL / "SKILL.md").read_text()
except (OSError, UnicodeDecodeError) as failure:
rules, skill = read(source) if source.is_file() else "", read(PANEL / "SKILL.md")
except OSError as failure:
return Failure(f"could not read what the seats' prompts quote: {failure}")
values = project_values(rules, source.name)
if isinstance(values, Failure):
@@ -188,7 +196,7 @@ def prepare_scoring(worktree: str, preloaded: str | None, home: pathlib.Path) ->
main = listing.splitlines()[0].removeprefix("worktree ")
try:
loaded = preloaded if preloaded is not None else preloaded_files(pathlib.Path(main), home)
except (OSError, UnicodeDecodeError) as failure:
except OSError as failure:
return Failure(f"could not read a file Claude Code loads into a seat: {failure}")
made = made_review_folder(worktree, home)
if isinstance(made, Failure):