Answer architecture round 1: 1 🔴, 8 🟡 (0 misread); one reader per message, prices and Spent block moved, one table of larv-review commands

This commit is contained in:
2026-11-12 20:05:52 +01:00
parent 9066f477a4
commit 5c37027046
28 changed files with 503 additions and 412 deletions
+17 -1
View File
@@ -1,8 +1,10 @@
import re
import typing
from model_routing.prices import PRICES
from records.markdown_text import quoted
from records.utc_stamp import STAMPED
from claude_code.tokens import Tokens
from model_routing.route import WorkerLine
TASK = "Task: "
@@ -33,6 +35,9 @@ JUDGE_COST_AT = re.compile(rf"^{re.escape(JUDGE)}(.+)\n{re.escape(JUDGE_COST)}([
CONFIG = "Config: "
# Opens the block of what the work since the previous outcome that recorded a spend spent; an outcome that spent nothing has none.
SPENT = "Spent since "
KINDS = "input, cache write 5m, cache write 1h, cache read, output"
# Who spent, such as `worker`, `judge` or `Explore "Search the hooks"`, and the model they ran on.
Spender = tuple[str, str]
# Opens the quote of a typed answer of the human's that reversed a choice the worker took on its own recommendation.
REVERSED = "Reversed:"
REVERSED_AT = re.compile(rf"^{re.escape(REVERSED)}\n((?:> .*\n)*> .*)", re.MULTILINE)
@@ -41,7 +46,7 @@ REVERSED_AT = re.compile(rf"^{re.escape(REVERSED)}\n((?:> .*\n)*> .*)", re.MULTI
class Annotation(typing.NamedTuple):
"""What a verdict, an interrupt or a quoted answer records beside its judge lines, so a change to the setup can be judged before and after: docs/decisions.md → `loop-claude: each verdict records the claude-config release and commit that ran it…`. Each part is left out where empty; the cycle always gives config."""
config: str = ""
# The block spend.spent_block renders.
# The block spent_block renders.
spent: str = ""
# The human's whole typed answer that holds the judge's quote of the reversal, as loop-claude checked it.
reversed: str = ""
@@ -54,6 +59,17 @@ def annotation_lines(annotation: Annotation) -> str:
return f"{reversed_block}{spent_block}{config_line}"
# Nothing reads a Spent block yet: the first tool that derives dollars from one adds its parser here, beside this writer.
def spent_block(since: str, found: dict[Spender, Tokens]) -> str:
"""The archive's block for what the stretch spent, then the list prices in force for each model in it; empty where nothing was spent."""
if not found:
return ""
spenders = [f"- {name}, {model}: {', '.join(map(str, (tokens.input, tokens.write_5m, tokens.write_1h, tokens.read, tokens.output)))}" for (name, model), tokens in found.items()]
priced = [f"- {model}: {price.input:g}, {price.write_5m:g}, {price.write_1h:g}, {price.read:g}, {price.output:g}" for model in dict.fromkeys(model for _, model in found) if (price := PRICES.get(model))]
prices = ["", f"List prices in dollars per million tokens of {KINDS}:", *priced] if priced else []
return "\n".join([f"{SPENT}{since or 'the chunk began'}, in tokens of {KINDS}:", *spenders, *prices])
def reversals(outcomes: str) -> list[str]:
"""Each reversing answer the outcomes quote, unquoted, in the order they were written."""
return [unquoted(found[1]) for found in REVERSED_AT.finditer(outcomes)]