Answer stability round 1: 1 🔴, 11 🟡 (0 misread); drop keys typed ahead on leaving an answer, wrap every line to the drawn width, list the routing calls, test the paths mutants survived

This commit is contained in:
2026-10-29 01:27:23 +01:00
parent 192b36fada
commit e3cd8ae0cf
15 changed files with 413 additions and 151 deletions
+18 -9
View File
@@ -2,9 +2,9 @@
import pathlib
from routing_figures import archive
from loop_claude.waiting import Ask, ClaudeCommand, OpenOnTerminal
from routing_figures.measure import calls, due, render, totals
from loop_claude.cycle.interrupt import claude_args, hand_over
from loop_claude.waiting import ClaudeCommand
from loop_claude.cycle.interrupt import claude_args, hand_over, shown, withdrawn
from loop_claude.effects import Effects, say
from failure import Failure
from loop_claude.paths import Paths
@@ -13,14 +13,14 @@ from loop_claude.stop import Stop
from utc_stamp import utc
def check_routing(root: pathlib.Path, rung: Rung, paths: Paths, effects: Effects) -> Stop | None:
"""Stops only when claude cannot start for the calls; a figure it cannot measure or keep is said on stderr, and the loop goes on. rung is the rung of the claude that puts the calls to the human."""
def check_routing(root: pathlib.Path, checkout: str, rung: Rung, paths: Paths, effects: Effects) -> Stop | None:
"""Stops only when claude cannot start for the calls; a figure it cannot measure or keep is said on stderr, and the loop goes on. checkout is the loop's, and rung is the rung of the claude that puts the calls to the human."""
with archive.locked(root) as held:
new = new_calls(root, paths, effects) if held else []
if isinstance(new, Failure):
say(f"routing figures: {new.reason}", effects)
return None
return raise_calls(root, new, rung, paths, effects) if new else None
return raise_calls(root, checkout, new, rung, paths, effects) if new else None
def new_calls(root: pathlib.Path, paths: Paths, effects: Effects) -> list[str] | Failure:
@@ -43,15 +43,24 @@ def new_calls(root: pathlib.Path, paths: Paths, effects: Effects) -> list[str] |
return [call for call in found if call not in kept.calls]
def raise_calls(root: pathlib.Path, new: list[str], rung: Rung, paths: Paths, effects: Effects) -> Stop | None:
"""Puts the calls to the human through a claude in this setup's checkout, where the routing decision lives. Off a terminal they are only said, and stay in the figures, raised at the next measurement on a terminal."""
def raise_calls(root: pathlib.Path, checkout: str, new: list[str], rung: Rung, paths: Paths, effects: Effects) -> Stop | None:
"""Puts the calls to the human through a claude in this setup's checkout, where the routing decision lives; loop-inbox lists them under the loop's checkout while that claude is open. Off a terminal they are only said, and stay in the figures, raised at the next measurement on a terminal."""
listed = "".join(f"- {call}\n" for call in new)
say(f"\nloop-claude's routing figures call for a routing change:\n{listed}The figures: {root / archive.FIGURES}", effects)
question = f"loop-claude's routing figures call for a routing change:\n{listed}The figures: {root / archive.FIGURES}"
say(f"\n{question}", effects)
if not effects.on_terminal():
say("Not on a terminal: the calls are raised again at the next measurement.", effects)
return None
prompt = f"Put these calls for a routing change from loop-claude's figures to the human, and change nothing until they answer:\n{listed}The figures are in {root / archive.FIGURES}. The ladder, its steps and the delegation rule are docs/decisions.md → `routing:`, and a change to them is the human's. Record what they decide as ~/.claude/CLAUDE.md says; the next chunk of this repo files the plan item for these calls."
if unstarted := hand_over(ClaudeCommand(claude_args(rung, [prompt]), str(paths.claude_dir), {}), paths, effects):
# No worker session answers the calls, so the ask is filed under its own id.
ask_id = effects.new_id()
ask = Ask(ask_id, ask_id, checkout, question, effects.now(), effects.pid(), OpenOnTerminal())
shown(paths, ask, effects)
try:
unstarted = hand_over(ClaudeCommand(claude_args(rung, [prompt]), str(paths.claude_dir), {}), paths, effects)
finally:
withdrawn(paths, ask, effects)
if unstarted:
return Stop(1, f"could not start claude for the routing calls: {unstarted.reason}")
# Raised once the human has seen them, answered or not: an unanswered call reaches the plan through AGENTS.md, so it is not asked twice.
if unmarked := archive.mark_raised(root, new, utc(effects.now())):