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