Answer the architect: fail a judge that answers without interrupting, read every checkout file through one function
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import pathlib
|
||||
|
||||
from loop_claude.project.checkout import read_checkout_file
|
||||
from loop_claude.stop import Stop
|
||||
|
||||
|
||||
@@ -7,14 +8,10 @@ def read_records(root: str) -> str | Stop:
|
||||
"""AGENTS.md and docs/decisions.md, each headed by its path; a file the project lacks is left out."""
|
||||
records = []
|
||||
for name in ("AGENTS.md", "docs/decisions.md"):
|
||||
try:
|
||||
text = pathlib.Path(root, name).read_text(encoding="utf-8")
|
||||
except FileNotFoundError:
|
||||
if not pathlib.Path(root, name).exists():
|
||||
continue
|
||||
except OSError as failure:
|
||||
return Stop(1, f"{name} in {root}: {failure.strerror} - the judge cannot read the project's records.")
|
||||
except UnicodeDecodeError as failure:
|
||||
line = failure.object.count(b"\n", 0, failure.start) + 1
|
||||
return Stop(1, f"{name} is not UTF-8 on line {line} - the judge cannot read the project's records.")
|
||||
text = read_checkout_file(root, name, "the judge cannot read the project's records")
|
||||
if isinstance(text, Stop):
|
||||
return text
|
||||
records.append(f"From {name}:\n{text.strip()}")
|
||||
return "\n\n".join(records)
|
||||
|
||||
Reference in New Issue
Block a user