Answer architecture round 1: 2 🔴, 4 🟡 (0 misread); one branch_chunks reader with a pure fix rule, routed chunks matched by item
This commit is contained in:
@@ -6,12 +6,12 @@ import statistics
|
||||
import typing
|
||||
|
||||
from claude_code.entries import assistant_parts, parts, tool_call, tool_result
|
||||
from branch_chunks.cut import BranchChunk
|
||||
from git_command import commits
|
||||
from model_routing.route import ESCALATION_MARKER, route_from
|
||||
from score_outcomes.later_fixes import Landed
|
||||
from routing_figures.prices import listed
|
||||
from model_routing.ladder import position, Rung
|
||||
from round_titles import round_counts
|
||||
from round_titles import rounds_past_first
|
||||
from shell_command import simple_commands
|
||||
from transcript_archive.outcomes import UNFINISHED_AT, workers
|
||||
|
||||
@@ -57,7 +57,7 @@ class Reports:
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class ChunkFigures:
|
||||
"""dollars maps each of DIMENSIONS to its labels' dollars; start is the rung a routed chunk started on, None where no item routed it; escalated counts the worker's escalations by trigger; unattributed is the recorded cost of a model with no priced message in the chunk; lacking counts the Agent calls, the worker's and the subagents', that have no subagent transcript in the archive; fixed_later counts the later chunks that fixed code it shipped, None where no chunk on its project's default branch matches it."""
|
||||
"""dollars maps each of DIMENSIONS to its labels' dollars; start is the rung a routed chunk started on, None where no item routed it; escalated counts the worker's escalations by trigger; unattributed is the recorded cost of a model with no priced message in the chunk; lacking counts the Agent calls, the worker's and the subagents', that have no subagent transcript in the archive; fixed_later counts the later chunks that fixed code it shipped, None where no chunk on its project's default branch shipped its item."""
|
||||
dollars: Dollars
|
||||
start: Rung | None
|
||||
rounds_past_first: int
|
||||
@@ -72,7 +72,7 @@ class ChunkFigures:
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class Figures:
|
||||
"""escalated counts every chunk's escalations by trigger, routed or not; skipped names each chunk folder the archive could not read whole; unmatched counts the chunks whose later fixes are unknown; unread names each project whose default branch could not be read, with why."""
|
||||
"""escalated counts every chunk's escalations by trigger, routed or not; skipped names each chunk folder the archive could not read whole; unmatched counts the routed chunks whose later fixes are unknown; unread names each project whose default branch could not be read, with why."""
|
||||
chunks: int
|
||||
dollars: Dollars
|
||||
routed: dict[Rung, list[ChunkFigures]]
|
||||
@@ -101,7 +101,7 @@ class Spent(typing.NamedTuple):
|
||||
message: Message
|
||||
|
||||
|
||||
def measured(chunk: Chunk, home: str, history: list[Landed] | None = None) -> ChunkFigures:
|
||||
def measured(chunk: Chunk, home: str, history: list[BranchChunk] | None = None) -> ChunkFigures:
|
||||
"""history is the chunks on the project's default branch, None where it could not be read."""
|
||||
cycles = sorted((cycle for kept in chunk.outcomes for cycle in workers(kept)), key=lambda cycle: cycle[0])
|
||||
spent = [Spent("worker", str(rung_at(cycles, message.at)), message) for message in messages(chunk.worker)]
|
||||
@@ -118,29 +118,24 @@ def measured(chunk: Chunk, home: str, history: list[Landed] | None = None) -> Ch
|
||||
spent += [Spent(kind, rung, message) for message in messages(subagent.entries)]
|
||||
dollars, unattributed = costed(spent, chunk.project, recorded_costs(chunk.worker))
|
||||
start = route_from(cycles[0][1]) if cycles else None
|
||||
titles = commit_titles(chunk.worker, home)
|
||||
return ChunkFigures(
|
||||
dollars=dollars,
|
||||
start=start.rung if start and start.item else None,
|
||||
rounds_past_first=sum(max(0, rounds - 1) for rounds in round_counts(titles).values()),
|
||||
rounds_past_first=rounds_past_first(commit_titles(chunk.worker, home)),
|
||||
unfinished=sum(len(UNFINISHED_AT.findall(kept)) for kept in chunk.outcomes),
|
||||
delegated=delegated,
|
||||
reports=reports,
|
||||
escalated=escalations(launches),
|
||||
unattributed=unattributed,
|
||||
lacking=max(0, len(launches) + sum(len(agent_calls(subagent.entries)) for subagent in chunk.subagents) - len(chunk.subagents)),
|
||||
fixed_later=later_fixes_of(titles, history or []),
|
||||
fixed_later=later_fixes_of(start.item, history or []) if start and start.item else None,
|
||||
)
|
||||
|
||||
|
||||
def later_fixes_of(titles: list[str], history: list[Landed]) -> int | None:
|
||||
"""How many chunks in history fixed code that the chunks holding one of titles shipped, each counted once and none of those chunks itself; None where no chunk holds one. Only a title no other chunk holds counts, since one such as a round's with no findings recurs."""
|
||||
# A worker's commits may land as several chunks, as a rebase cut by commit time does, and every one of them is its work.
|
||||
holders = collections.Counter(title for landed in history for title in landed.titles)
|
||||
shipped = [landed for landed in history if any(holders[title] == 1 for title in landed.titles.intersection(titles))]
|
||||
if not shipped:
|
||||
return None
|
||||
return len({later for landed in shipped for later in landed.fixed_by} - {landed.label for landed in shipped})
|
||||
def later_fixes_of(item: int, history: list[BranchChunk]) -> int | None:
|
||||
"""How many later chunks fixed code shipped by the chunk in history that shipped item; None where no chunk shipped it."""
|
||||
# lilleman chose on 2026-10-28 to match by the item a chunk's route names over commit titles, since it drops the title matching and reads projects whose commit titles the worker's transcript doesn't show; the cost is that a chunk whose PR didn't remove its item reads as unknown.
|
||||
return next((len(chunk.fixed_by) for chunk in history if any(shipped.id == item for shipped in chunk.shipped)), None)
|
||||
|
||||
|
||||
def escalations(launches: dict[str, tuple[str, dict]]) -> collections.Counter[int]:
|
||||
@@ -252,7 +247,7 @@ def totals(chunks: list[ChunkFigures], skipped: tuple[str, ...] = (), unread: tu
|
||||
routed.setdefault(chunk.start, []).append(chunk)
|
||||
for kind, found in chunk.reports.items():
|
||||
reports[kind] = reports.get(kind, Reports(0, 0, 0)) + found
|
||||
return Figures(len(chunks), dollars, routed, reports, summed(chunks, lambda chunk: chunk.escalated), skipped, sum(chunk.unattributed for chunk in chunks), sum(chunk.lacking for chunk in chunks), sum(chunk.fixed_later is None for chunk in chunks), unread)
|
||||
return Figures(len(chunks), dollars, routed, reports, summed(chunks, lambda chunk: chunk.escalated), skipped, sum(chunk.unattributed for chunk in chunks), sum(chunk.lacking for chunk in chunks), sum(chunk.start is not None and chunk.fixed_later is None for chunk in chunks), unread)
|
||||
|
||||
|
||||
def calls(figures: Figures) -> list[str]:
|
||||
@@ -279,9 +274,9 @@ def basis(figures: Figures) -> str:
|
||||
text += f" {money(figures.unattributed)} of the recorded cost is left out, since it belongs to a model with no list price or with no priced message in the archive."
|
||||
if figures.lacking:
|
||||
text += f" The archive holds no subagent transcript for {figures.lacking} of the chunks' Agent calls."
|
||||
text += " A chunk's later fixes are the chunks on its project's default branch, as last fetched, that fixed code it shipped, as `score-outcomes` counts them, so a recent chunk has had less time to gather them. What it shipped is each chunk there holding a title of the worker's commits that no other chunk there holds."
|
||||
text += " A routed chunk's later fixes are the chunks on its project's default branch, as last fetched, that fixed code it shipped, as `score-outcomes` counts them, so a recent chunk has had less time to gather them. Its chunk there is the one that removed the item its route names from todo.md."
|
||||
if figures.unmatched:
|
||||
text += f" The later fixes of {figures.unmatched} of the chunks are unknown, since no chunk on the branch held such a title, or the branch could not be read."
|
||||
text += f" The later fixes of {figures.unmatched} of the routed chunks are unknown, since no chunk on the branch removed their item from todo.md, or the branch could not be read."
|
||||
return text
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user