Count each finished chunk's later fixes in score-outcomes and the routing figures
This commit is contained in:
@@ -8,14 +8,19 @@ import re
|
||||
import typing
|
||||
|
||||
from transcript_archive.read import archived_outcomes, chunk_outcomes, finished_chunks
|
||||
from project_key import checkout_of
|
||||
from routing_figures.measure import Chunk, ChunkFigures, measured, MEASURED_AT, Subagent
|
||||
from git_repo import default_ref
|
||||
from failure import Failure
|
||||
from score_outcomes.later_fixes import Landed, later_fixes
|
||||
from claude_code.entries import parse_entry
|
||||
from file_writes import replace_file
|
||||
from utc_stamp import STAMPED
|
||||
from transcript_archive.outcomes import VERDICT_AT
|
||||
|
||||
FIGURES = "routing-figures.md"
|
||||
# Seconds each git call reading a project's history may take.
|
||||
GIT_TIMEOUT = 60
|
||||
LOCK = "routing-figures.lock"
|
||||
RAISED = "routing-calls-raised.md"
|
||||
RAISED_HEADING = "# Routing calls raised\n"
|
||||
@@ -72,9 +77,10 @@ def last_measured(root: pathlib.Path) -> int | Failure:
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Measured:
|
||||
"""skipped names each chunk folder that could not be read whole, such as one another loop is writing."""
|
||||
"""skipped names each chunk folder that could not be read whole, such as one another loop is writing; unread names each project whose default branch could not be read, with why."""
|
||||
chunks: list[ChunkFigures]
|
||||
skipped: tuple[str, ...]
|
||||
unread: tuple[str, ...] = ()
|
||||
|
||||
|
||||
def measure_archive(root: pathlib.Path, home: str, since: str) -> Measured | Failure:
|
||||
@@ -85,12 +91,19 @@ def measure_archive(root: pathlib.Path, home: str, since: str) -> Measured | Fai
|
||||
projects = sorted({root / key for key, _ in listed})
|
||||
found = []
|
||||
skipped = []
|
||||
unread = []
|
||||
for project in projects:
|
||||
key = str(project.relative_to(root))
|
||||
chunks = finished_chunks(project)
|
||||
if isinstance(chunks, Failure):
|
||||
skipped.append(str(project.relative_to(root)))
|
||||
skipped.append(key)
|
||||
continue
|
||||
for chunk in (chunk for chunk in chunks if chunk.finished > since):
|
||||
chunks = [chunk for chunk in chunks if chunk.finished > since]
|
||||
history = branch_history(checkout_of(key, pathlib.Path(home))) if chunks else None
|
||||
if isinstance(history, Failure):
|
||||
unread.append(f"{key}: {history.reason}")
|
||||
history = None
|
||||
for chunk in chunks:
|
||||
folder = project / chunk.folder
|
||||
try:
|
||||
kept = [path.read_text(encoding="utf-8") for path in chunk_outcomes(folder)]
|
||||
@@ -99,8 +112,14 @@ def measure_archive(root: pathlib.Path, home: str, since: str) -> Measured | Fai
|
||||
except (OSError, UnicodeDecodeError):
|
||||
skipped.append(str(folder.relative_to(root)))
|
||||
continue
|
||||
found.append(measured(Chunk(str(project.relative_to(root)), kept, worker, subagents), home))
|
||||
return Measured(found, tuple(skipped))
|
||||
found.append(measured(Chunk(key, kept, worker, subagents), home, history))
|
||||
return Measured(found, tuple(skipped), tuple(unread))
|
||||
|
||||
|
||||
def branch_history(checkout: str) -> list[Landed] | Failure:
|
||||
"""The chunks on the checkout's default branch as last fetched, read guarded, since the checkout's config may name a program."""
|
||||
ref = default_ref(checkout, GIT_TIMEOUT, guarded=True)
|
||||
return ref if isinstance(ref, Failure) else later_fixes(ref, cwd=checkout, guarded=True, timeout=GIT_TIMEOUT)
|
||||
|
||||
|
||||
def entries(path: pathlib.Path) -> list[dict]:
|
||||
|
||||
Reference in New Issue
Block a user