Read the records at their configured paths in the review header, replay, chunk-pr, score-outcomes, reading-cost and metric-bench

This commit is contained in:
2026-11-13 00:58:02 +01:00
parent 220bd39d49
commit d648e4a989
33 changed files with 202 additions and 79 deletions
+11 -7
View File
@@ -94,13 +94,14 @@ import re
import sys
from score_outcomes.anchors import anchor_lines, Anchors, ANCHORS_PATH, parse_anchors
from branch_chunks.read import branch_chunks
from branch_chunks.read import branch_chunks, unsupported
from git_cli.git_repo import default_branch, full_history, git, top
from failure import Failure
from score_outcomes.results import file_lines, fixed_later, item_text, misreads, nearest, render, report, Result, results_of
from release_plan.todo_table import item_details, LEVELS, risk, TOP_SCORE
from records.markdown_text import listed
from release_plan.named_code import named_files
from project_config.main import project
from transcript_archive.location import project_archive
from score_outcomes.reversals import reversal_lines
@@ -166,16 +167,17 @@ def failed(failure: Failure) -> int:
def read_anchors() -> Anchors | Failure:
"""The checkout's anchors as its working tree holds them, so a branch that edits them shows its edit; none where it has no such file."""
root = top()
if isinstance(root, Failure):
return root
"""The project's anchors as they stand where its config puts them, so a branch that edits them shows its edit; none where it has no such file."""
config = project()
if isinstance(config, Failure):
return config
anchors = config.paths["score-anchors"]
try:
return parse_anchors((pathlib.Path(root) / ANCHORS_PATH).read_text())
return parse_anchors(anchors.read_text(encoding="utf-8"))
except FileNotFoundError:
return []
except (OSError, UnicodeDecodeError) as failure:
return Failure(f"cannot read {ANCHORS_PATH}: {failure}")
return Failure(f"cannot read {anchors}: {failure}")
def read_reversals() -> list[str] | Failure:
@@ -190,6 +192,8 @@ def read_results(default: str) -> 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()):
return Failure(f"score-outcomes doesn't support this project yet: {why}")
root = top()
if isinstance(root, Failure):
return root
+14
View File
@@ -18,6 +18,7 @@ from transcript_archive import outcomes
from transcript_archive.location import project_archive
from score_outcomes.main import report_text
from score_outcomes.reversals import reversal_lines
from project_config.test_project_config import write_config
TOOL = pathlib.Path(__file__).resolve().parents[1] / "score-outcomes"
HEADER = "| ID | Release | Exempt | Item | R | S | C | A | G | Goals | Score |\n|---|---|---|---|---|---|---|---|---|---|---|\n"
@@ -285,6 +286,7 @@ class ScoreOutcomesTool(unittest.TestCase):
self.checkout = root / "proj"
self.checkout.mkdir()
self.git("init", "-q", "-b", "main")
write_config(root, self.checkout)
self.commit("start", {"todo.md": todo(FIRST, SECOND)})
def git(self, *args):
@@ -312,6 +314,18 @@ class ScoreOutcomesTool(unittest.TestCase):
def run_tool(self, *args, cwd=None):
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=cwd or self.checkout, env=self.env, text=True)
def test_says_it_does_not_support_a_plan_outside_the_checkout_and_reads_the_anchors_where_the_config_puts_them(self):
config = pathlib.Path(self.env["HOME"], ".claude-projects", "proj", "config.toml")
config.write_text(config.read_text().replace('"checkout:docs/score-anchors.md"', '"folder:score-anchors.md"'))
(config.parent / "score-anchors.md").write_text("| Level | Items |\n|---|---|\n| L 9 | 1 |\n")
ran = self.run_tool()
self.assertEqual(ran.returncode, 1)
self.assertIn("score-outcomes: cannot read the row | L 9 | 1 | in docs/score-anchors.md", ran.stderr)
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"'))
ran = self.run_tool()
self.assertEqual((ran.returncode, ran.stdout), (1, ""))
self.assertEqual(ran.stderr, f"score-outcomes: score-outcomes doesn't support this project yet: the project's config puts {config.parent}/todo.md elsewhere than todo.md, docs/comprehension-history.md, docs/reading-cost.md in the checkout, the only paths whose commits are read so far\n")
def test_counts_the_reversals_in_loop_claudes_archive_of_the_main_checkout_run_from_a_worktree(self):
archive = pathlib.Path(self.env["HOME"], "archive")
self.env["LOOP_CLAUDE_TRANSCRIPTS"] = str(archive)