Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s

This commit is contained in:
2026-11-19 12:42:03 +01:00
parent 8ca612b7a4
commit cb3135bc8c
124 changed files with 1437 additions and 793 deletions
+12 -12
View File
@@ -100,8 +100,8 @@ from failure import Failure
from score_outcomes.results import file_lines, fixed_later, item_text, misreads, nearest, render, report, Result, results_of
from plan.todo_table import item_details, LEVELS, risk, TOP_SCORE
from text_files.markdown_text import listed
from project_config.main import located, title_templates
from plan.named_paths import named_files
from project_config.main import project, title_templates
from transcript_archive.location import project_archive
from score_outcomes.reversals import reversal_lines
from record_store.stores import store
@@ -119,7 +119,7 @@ UNMERGED = [
]
def main(argv: list[str]) -> int:
def main(argv: list[str], home: pathlib.Path) -> int:
if argv[:1] in (["-h"], ["--help"]):
print(__doc__.strip())
return 0
@@ -133,11 +133,11 @@ def main(argv: list[str]) -> int:
default, note = found
if note:
print(f"score-outcomes: {note}", file=sys.stderr)
results = read_results(default)
results = read_results(default, home)
if isinstance(results, Failure):
return failed(results)
anchored = read_anchors()
reversal = read_reversals()
anchored = read_anchors(home)
reversal = read_reversals(home)
print(report_text(results, anchored, dict(zip(GIVEN, map(int, argv))) if argv else None, reversal))
unread = [found for found in (anchored, reversal) if isinstance(found, Failure)]
for failure in unread:
@@ -167,34 +167,34 @@ def failed(failure: Failure) -> int:
return 1
def read_anchors() -> Anchors | Failure:
def read_anchors(home: pathlib.Path) -> Anchors | Failure:
"""The project's anchors as they stand in the store its config names, so a branch that edits them shows its edit; none where it keeps none."""
config = project()
config = located(None, home)
if isinstance(config, Failure):
return config
text = store(config, "score-anchors").read()
return text if isinstance(text, Failure) else parse_anchors(text)
def read_reversals() -> list[str] | Failure:
def read_reversals(home: pathlib.Path) -> list[str] | Failure:
"""The reversals in loop-claude's archive of this project, which the main checkout's path keys, whichever worktree this runs in."""
common = git("rev-parse", "--path-format=absolute", "--git-common-dir")
if isinstance(common, Failure):
return common
return reversal_lines(project_archive(str(pathlib.Path(common.strip()).parent), pathlib.Path.home(), os.environ))
return reversal_lines(project_archive(str(pathlib.Path(common.strip()).parent), home, os.environ))
def read_results(default: str) -> list[Result] | Failure:
def read_results(default: str, home: pathlib.Path) -> list[Result] | Failure:
"""What each chunk on the default branch's first-parent line measured."""
if partial := full_history():
return partial
if why := unsupported(None, pathlib.Path.home()):
if why := unsupported(None, home):
return Failure(f"this project is not supported yet: {why}")
root = top()
if isinstance(root, Failure):
return root
run = functools.partial(git, cwd=root)
templates = title_templates(None, pathlib.Path.home())
templates = title_templates(None, home)
if isinstance(templates, Failure):
return templates
chunks = branch_chunks(default, run, templates)
+2 -2
View File
@@ -570,12 +570,12 @@ class Reversals(unittest.TestCase):
class ReadAnchors(unittest.TestCase):
def test_fails_on_anchors_it_cannot_read_rather_than_scoring_without_them(self):
checkout = pathlib.Path(self.enterContext(tempfile.TemporaryDirectory()))
configured(self, checkout)
home = configured(self, checkout).parents[1]
self.enterContext(contextlib.chdir(checkout))
anchors = checkout.resolve() / "docs" / "score-anchors.md"
anchors.parent.mkdir()
anchors.write_bytes(b"\xff")
self.assertEqual(read_anchors(), Failure(f"cannot read {anchors}: not UTF-8 on line 1"))
self.assertEqual(read_anchors(home), Failure(f"cannot read {anchors}: not UTF-8 on line 1"))
if __name__ == "__main__":