Answer prose round 1: 0 🔴, 1 🟡 (0 misread); complete route_from's docstring, trim the rung comment and the test name
This commit is contained in:
@@ -1156,7 +1156,7 @@ class Routing(unittest.TestCase):
|
|||||||
def test_leaves_the_count_of_unfinished_verdicts_out_of_the_worker_line_so_a_rerun_restarts_it(self):
|
def test_leaves_the_count_of_unfinished_verdicts_out_of_the_worker_line_so_a_rerun_restarts_it(self):
|
||||||
self.assertEqual(route_from(Route(self.HIGH, 3, 4, 5, unfinished=1).worker_line()), Route(self.HIGH, 3, 4, 5))
|
self.assertEqual(route_from(Route(self.HIGH, 3, 4, 5, unfinished=1).worker_line()), Route(self.HIGH, 3, 4, 5))
|
||||||
|
|
||||||
def test_reads_no_route_from_a_worker_line_that_is_no_json_or_has_unknown_or_mistyped_fields_or_levels_off_their_scales(self):
|
def test_reads_no_route_from_a_worker_line_that_route_worker_line_could_not_have_written(self):
|
||||||
for line in ('{"effort": "high"}', '{"model": "claude-opus-5-5", "effort": "high", "unfinished": 1}', '{"model": "claude-opus-5-5", "item": "3"}', '{"model": "claude-opus-5-5", "effort": 3}', '{"model": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escalated_at": -3}', '{"model": "claude-opus-5-5", "item": true, "likelihood": 4, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 5, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escape_and_impact_taken_in": 9}', '["claude-opus-5-5"]', '{"model": ', "worker-model", "claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5"):
|
for line in ('{"effort": "high"}', '{"model": "claude-opus-5-5", "effort": "high", "unfinished": 1}', '{"model": "claude-opus-5-5", "item": "3"}', '{"model": "claude-opus-5-5", "effort": 3}', '{"model": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escalated_at": -3}', '{"model": "claude-opus-5-5", "item": true, "likelihood": 4, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "item": 3, "likelihood": 5, "escape_and_impact": 5}', '{"model": "claude-opus-5-5", "effort": "high", "escape_and_impact_taken_in": 9}', '["claude-opus-5-5"]', '{"model": ', "worker-model", "claude-opus-5-5 at high effort, routed by item 3's L of 4 and E + I of 5"):
|
||||||
with self.subTest(line=line):
|
with self.subTest(line=line):
|
||||||
self.assertIsNone(route_from(line))
|
self.assertIsNone(route_from(line))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Rung:
|
|||||||
return Rung(model, effort)
|
return Rung(model, effort)
|
||||||
return Rung(family.model, effort) if effort else family
|
return Rung(family.model, effort) if effort else family
|
||||||
|
|
||||||
# The one spelling of a rung. loop-claude hands it to rule-hook in environment variables, so parse must keep reading it.
|
# loop-claude hands a rung to rule-hook in environment variables in this spelling, so parse must keep reading it.
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return f"{self.model} at {self.effort} effort" if self.effort else self.model
|
return f"{self.model} at {self.effort} effort" if self.effort else self.model
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
"""A chunk's route: its worker's rung and the plan item that picked it. The archive keeps the route as JSON on the Worker: line that ends each outcome."""
|
"""A chunk's route: its worker's rung and the plan item that picked it. The archive keeps the route as JSON on the Worker: line that ends each verdict, interrupt, quoted answer, stop and step-up."""
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import json
|
import json
|
||||||
import typing
|
import typing
|
||||||
@@ -79,7 +79,7 @@ WORKER_LINE_FIELDS = tuple(field.name for field in dataclasses.fields(Route) if
|
|||||||
|
|
||||||
|
|
||||||
def route_from(worker: str) -> Route | None:
|
def route_from(worker: str) -> Route | None:
|
||||||
"""The route an archived worker line names. None where the line isn't JSON, names no model, holds fields Route.worker_line never writes, or holds levels off their scales."""
|
"""The route an archived worker line names; None for a line Route.worker_line could not have written, such as text that isn't JSON."""
|
||||||
fields = json_fields(worker)
|
fields = json_fields(worker)
|
||||||
if fields is None or not Route.fits(fields):
|
if fields is None or not Route.fits(fields):
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user