From 293532bb588437952b681e954e3c9b82d0de608e Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 22:40:50 +0100 Subject: [PATCH 1/4] Decode a reload's handed JSON with a decoder for LoopRun and its Route --- bin/loop_claude/loop/main.py | 2 +- bin/loop_claude/loop/reload.py | 82 ++++++++++++++++------------- bin/loop_claude/test_loop_claude.py | 54 ++++++++++++------- docs/reading-cost.md | 17 ++++++ todo.md | 5 -- 5 files changed, 99 insertions(+), 61 deletions(-) diff --git a/bin/loop_claude/loop/main.py b/bin/loop_claude/loop/main.py index f042cb3a..762a6ba1 100644 --- a/bin/loop_claude/loop/main.py +++ b/bin/loop_claude/loop/main.py @@ -90,7 +90,7 @@ def loop_run_from(argv: list[str], cwd: pathlib.Path, effects: Effects) -> LoopR return Stop(0 if task else 1, HELP) root = checkout_root(cwd, effects) return root if isinstance(root, Stop) else LoopRun(0, root, task, "") - loop_run = decode_handed(argv[1], LoopRun) if len(argv) == 2 else None + loop_run = decode_handed(argv[1]) if len(argv) == 2 else None if not (loop_run and loop_run.root and loop_run.task): return Stop(1, f"the edited loop-claude cannot read the state the running one handed it, likely because the edit changed that handover; rerun loop-claude . Handed: {' '.join(argv[1:])}") return loop_run diff --git a/bin/loop_claude/loop/reload.py b/bin/loop_claude/loop/reload.py index ef2a6151..b4f39ac5 100644 --- a/bin/loop_claude/loop/reload.py +++ b/bin/loop_claude/loop/reload.py @@ -3,15 +3,14 @@ import hashlib import json import pathlib import sys -import types import typing from loop_claude.effects import Effects, say from model_routing.route import Route +from model_routing.ladder import Rung from loop_claude.stop import Stop RELOAD_FLAG = "--reloaded" -T = typing.TypeVar("T") # A field removed, renamed or retyped stops a running loop at its next reload: the new script rejects the old fields. A new field with a default does not. @@ -30,47 +29,58 @@ class LoopRun: items_taken_in: tuple[int, ...] = () -def decode_handed(handed: str, kind: type[T]) -> T | None: +class Unreadable(Exception): + """The handed JSON isn't a LoopRun.""" + + +def decode_handed(handed: str) -> LoopRun | None: + """The LoopRun the JSON holds; None for text that isn't one. A field of LoopRun or Route with a default may be missing, so a field added since the running script started doesn't stop the loop.""" try: fields = json.loads(handed) - except ValueError: + return LoopRun(**decoded_fields(fields, LOOP_RUN_FIELDS, "cycle_number", "root", "task", "unfinished_evidence")) + except (ValueError, Unreadable): return None - decoded = decoded_as(fields, kind) - return None if decoded in (REJECTED, RETIRED) else typing.cast(T, decoded) -REJECTED = object() -# A dataclass handed with a field its RETIRED names: where None may stand in for it, it decodes as None. -RETIRED = object() +def decoded_fields(value: object, decoders: dict[str, typing.Callable[[typing.Any], typing.Any]], *required: str) -> dict[str, typing.Any]: + """Each field of the JSON object through its decoder; raises Unreadable unless the object holds every required field and none the decoders don't name.""" + if not isinstance(value, dict) or not set(required) <= value.keys() <= decoders.keys(): + raise Unreadable + return {name: decoders[name](field) for name, field in value.items()} -def decoded_as(value: object, kind: typing.Any) -> typing.Any: - """value as kind, REJECTED or RETIRED: a dataclass from an object holding its fields, a union's first member that fits, a tuple of one type from a list, else a value of exactly kind.""" - if isinstance(kind, types.UnionType): - found = [decoded_as(value, option) for option in typing.get_args(kind)] - fits = [each for each in found if each is not REJECTED and each is not RETIRED] - if fits: - return fits[0] - return None if RETIRED in found and type(None) in typing.get_args(kind) else REJECTED - if isinstance(kind, type) and dataclasses.is_dataclass(kind): - if isinstance(value, dict) and value.keys() & getattr(kind, "RETIRED", frozenset()): - return RETIRED - hints = typing.get_type_hints(kind) - shape = {field.name: hints[field.name] for field in dataclasses.fields(kind)} - # A field with a default may be missing, so a field added since the running script started does not stop the loop. - required = {field.name for field in dataclasses.fields(kind) if field.default is dataclasses.MISSING and field.default_factory is dataclasses.MISSING} - if not isinstance(value, dict) or not required <= value.keys() <= shape.keys(): - return REJECTED - fields = {name: decoded_as(field, shape[name]) for name, field in value.items()} - # A dataclass that checks its fields, as Route does, does so in a static method named fits. - if any(field in (REJECTED, RETIRED) for field in fields.values()) or not getattr(kind, "fits", lambda _: True)(fields): - return REJECTED - return kind(**fields) - if typing.get_origin(kind) is tuple: - element = typing.get_args(kind)[0] - found = [decoded_as(each, element) for each in value] if isinstance(value, list) else [REJECTED] - return REJECTED if REJECTED in found or RETIRED in found else tuple(found) - return value if type(value) is kind else REJECTED +def exactly(kind: type) -> typing.Callable[[typing.Any], typing.Any]: + """A decoder of a value of exactly this type: type(), not isinstance(), since JSON true is no integer.""" + def decode(value: object) -> object: + if type(value) is not kind: + raise Unreadable + return value + return decode + + +def decoded_ids(value: object) -> tuple[int, ...]: + if not isinstance(value, list): + raise Unreadable + return tuple(exactly(int)(each) for each in value) + + +def decoded_rung(value: object) -> Rung: + return Rung(**decoded_fields(value, {"model": exactly(str), "effort": exactly(str)}, "model")) + + +def decoded_route(value: object) -> Route | None: + """A reload from before Route dropped a field hands a route that field names in Route.RETIRED: it decodes as None, and the chunk routes afresh.""" + if value is None or (isinstance(value, dict) and value.keys() & Route.RETIRED): + return None + fields = decoded_fields(value, ROUTE_FIELDS, "rung") + if not Route.fits(fields): + raise Unreadable + return Route(**fields) + + +# One decoder per field, which tests hold to the dataclass's fields: a field missing here stops a loop at the reload after it joined. +LOOP_RUN_FIELDS = {"cycle_number": exactly(int), "root": exactly(str), "task": exactly(str), "unfinished_evidence": exactly(str), "route": decoded_route, "unfinished_run": exactly(int), "items_taken_in": decoded_ids} +ROUTE_FIELDS = {"rung": decoded_rung, **{name: exactly(int) for name in ("item", "likelihood", "escape_and_impact", "unfinished", "escape_and_impact_taken_in", "escalated_at")}} def fingerprint(launcher: pathlib.Path) -> str: diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 089465cd..920bf8b8 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1772,51 +1772,67 @@ class LoopRuns(unittest.TestCase): with self.subTest(handed=handed): self.assertEqual(main.loop_run_from([main.RELOAD_FLAG, *handed], CWD, FakeEffects().effects()), Stop(1, f"the edited loop-claude cannot read the state the running one handed it, likely because the edit changed that handover; rerun loop-claude . Handed: {' '.join(handed)}")) - def test_decodes_a_state_whose_annotations_are_strings(self): - @dataclasses.dataclass(frozen=True) - class Stringly: - count: "int" - name: "str" - self.assertEqual(reload.decode_handed('{"count": 1, "name": "n"}', Stringly), Stringly(1, "n")) - self.assertIsNone(reload.decode_handed('{"count": "1", "name": "n"}', Stringly)) + def test_decodes_every_field_of_the_state_and_its_route(self): + state = main.LoopRun(cycle_number=2, root="/r", task="do it", unfinished_evidence="old", route=Route(Rung("claude-opus-5-5", "high"), 3, 4, 5, 1, 7, 9), unfinished_run=2, items_taken_in=(12, 14)) + self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(state))), state) + self.assertEqual(set(reload.LOOP_RUN_FIELDS), {field.name for field in dataclasses.fields(main.LoopRun)}) + self.assertEqual(set(reload.ROUTE_FIELDS), {field.name for field in dataclasses.fields(Route)}) + + def test_rejects_a_field_of_the_state_or_its_route_of_another_type(self): + state = dataclasses.asdict(main.LoopRun(cycle_number=2, root="/r", task="do it", unfinished_evidence="", route=Route(Rung("claude-opus-5-5", "high"), 3, 4, 5, 1, 7, 9), unfinished_run=2)) + for path, wrong in ((("unfinished_run",), "2"), (("unfinished_run",), True), (("route", "unfinished"), 1.0), (("route", "escalated_at"), "9"), (("route", "item"), True), (("route", "rung"), "claude-opus-5-5"), (("route", "rung", "model"), None), (("route",), "r"), (("route", "extra"), 1)): + with self.subTest(path=path, wrong=wrong): + handed = json.loads(json.dumps(state)) + target = handed + for key in path[:-1]: + target = target[key] + target[path[-1]] = wrong + self.assertIsNone(reload.decode_handed(json.dumps(handed))) + + def test_decodes_a_rung_without_an_effort(self): + state = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", route=Route(Rung("some-model"))) + self.assertEqual(reload.decode_handed(json.dumps({**dataclasses.asdict(state), "route": {"rung": {"model": "some-model"}}})), state) + + def test_rejects_text_that_is_not_json(self): + self.assertIsNone(reload.decode_handed("not json")) def test_decodes_a_route_inside_the_state_or_none(self): state = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", route=Route(Rung("claude-opus-5-5", "high"), 3, 4, 5, 1)) - self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(state)), main.LoopRun), state) + self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(state))), state) unrouted = dataclasses.replace(state, route=None) - self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(unrouted)), main.LoopRun), unrouted) + self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(unrouted))), unrouted) handed = dataclasses.asdict(state) handed["route"]["rung"]["effort"] = 1 - self.assertIsNone(reload.decode_handed(json.dumps(handed), main.LoopRun)) + self.assertIsNone(reload.decode_handed(json.dumps(handed))) del handed["route"]["rung"] - self.assertIsNone(reload.decode_handed(json.dumps(handed), main.LoopRun)) + self.assertIsNone(reload.decode_handed(json.dumps(handed))) off_scale = dataclasses.asdict(state) off_scale["route"]["likelihood"] = 9 - self.assertIsNone(reload.decode_handed(json.dumps(off_scale), main.LoopRun)) + self.assertIsNone(reload.decode_handed(json.dumps(off_scale))) older = dataclasses.asdict(state) del older["route"]["escape_and_impact_taken_in"] - self.assertEqual(reload.decode_handed(json.dumps(older), main.LoopRun), state) + self.assertEqual(reload.decode_handed(json.dumps(older)), state) taken = dataclasses.replace(state, route=dataclasses.replace(state.route, escape_and_impact_taken_in=7)) - self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(taken)), main.LoopRun), taken) + self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(taken))), taken) for taken_in in (9, 5): with self.subTest(taken_in=taken_in): handed = dataclasses.asdict(state) handed["route"]["escape_and_impact_taken_in"] = taken_in - self.assertIsNone(reload.decode_handed(json.dumps(handed), main.LoopRun)) + self.assertIsNone(reload.decode_handed(json.dumps(handed))) def test_drops_a_route_an_older_loop_claude_handed_under_r_plus_c_so_the_chunk_routes_afresh(self): older = {"cycle_number": 3, "root": "/r", "task": "do it", "unfinished_evidence": "", "route": {"rung": {"model": "claude-opus-5-5", "effort": "high"}, "item": 3, "risk_and_complexity": 11, "unfinished": 1}} - self.assertEqual(reload.decode_handed(json.dumps(older), main.LoopRun), main.LoopRun(3, "/r", "do it", "")) + self.assertEqual(reload.decode_handed(json.dumps(older)), main.LoopRun(3, "/r", "do it", "")) def test_decodes_a_state_from_before_a_field_with_a_default_joined_it(self): - self.assertEqual(reload.decode_handed(json.dumps({"cycle_number": 3, "root": "/r", "task": "do it", "unfinished_evidence": ""}), main.LoopRun), main.LoopRun(3, "/r", "do it", "")) + self.assertEqual(reload.decode_handed(json.dumps({"cycle_number": 3, "root": "/r", "task": "do it", "unfinished_evidence": ""})), main.LoopRun(3, "/r", "do it", "")) def test_decodes_the_items_taken_in_as_a_tuple_of_ids(self): state = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", items_taken_in=(12, 14)) - self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(state)), main.LoopRun), state) + self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(state))), state) for taken_in in ([12, "14"], [True], "12", {"12": 1}): with self.subTest(taken_in=taken_in): - self.assertIsNone(reload.decode_handed(json.dumps(dataclasses.asdict(state) | {"items_taken_in": taken_in}), main.LoopRun)) + self.assertIsNone(reload.decode_handed(json.dumps(dataclasses.asdict(state) | {"items_taken_in": taken_in}))) def test_stops_when_the_reload_cannot_start_python(self): with tempfile.TemporaryDirectory() as root: diff --git a/docs/reading-cost.md b/docs/reading-cost.md index 5959cb2a..d3833059 100644 --- a/docs/reading-cost.md +++ b/docs/reading-cost.md @@ -1170,3 +1170,20 @@ Read most (opens and searches): - `bin/loop_claude/cycle/prompts.py` 2 - `AGENTS.md` 1 - `CHANGELOG.md` 1 + +## Reading cost, chunk e29f634f3ac3, finished 2026-11-08T21:38:11Z + +86720 new input tokens before the first commit. + +Read most (opens and searches): + +- `todo.md` 6 +- `bin/larv_review/history_commands.py` 5 +- `bin/larv_review/test_larv_review.py` 5 +- `bin/larv_review/plan.py` 4 +- `README.md` 3 +- `skills/larv-review/SKILL.md` 3 +- `bin/larv_review/scoring.py` 2 +- `docs/decisions.md` 2 +- `rules/todo-items.md` 2 +- `AGENTS.md` 1 diff --git a/todo.md b/todo.md index 5b4abbee..419b86e6 100644 --- a/todo.md +++ b/todo.md @@ -13,7 +13,6 @@ | ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score | |---|---|---|---|---|---|---|---|---|---|---|---| | 1 | 0.7.0 | | question | **Say in README → Install how the transcript archive is backed up, once bender-infra backs up ai-sandbox's data volume.** | 1 | 2 | 1 | 2 | 1 | | 0.0 | -| 215 | 0.7.0 | | | **Decode a reload's handed JSON with a decoder for `LoopRun` and its `Route`, in place of `decoded_as`'s generic one with its two sentinels and `Route.fits` hook.** | 2 | 1 | 3 | 4 | 3 | code health by 2 | 3.6 | | 237 | 0.7.0 | | principle | **Give `judge` and `judge_once` in `bin/loop_claude/cycle/judge.py` a record of the inputs they share, in place of nine and eight parameters, or record why they stay.** | 2 | 1 | 2 | 3 | 3 | code health by 2 | 3.6 | | 242 | 0.7.0 | | principle | **Run each case of a table-driven test in its own `subTest`, and split each test that checks several behaviours, so one failure does not hide the others and names its case.** | 2 | 1 | 1 | 2 | 3 | code health by 2 | 3.6 | | 113 | 0.7.0 | | | **Compute an item's S from the code it names, where it names any, and show it beside the finished items `score-outcomes` lists.** | 3 | 2 | 2 | 5 | 4 | 1.1 by 5, 1.4 by 5 | 3.4 | @@ -76,10 +75,6 @@ It lives under `~/.claude`, which `.gitignore` keeps from the remote, so a lost The README line covers the bench's transcripts in `workflow-bench/logs/` too (goal 3). -### 215. Decode a reload's handed JSON with a decoder for `LoopRun` and its `Route`, in place of `decoded_as`'s generic one with its two sentinels and `Route.fits` hook. - -Release 0.3.0's Mid A (PR #324 at c713910) named `bin/loop_claude/loop/reload.py:43` `decoded_as`: "a generic decoder with two sentinels and a duck-typed fits hook defined on Route". This lowers Shape: `decoded_as` is generic over any type, yet `decode_handed` calls it with one dataclass, `LoopRun`. Keep what it does today: a field added since the running script started may be missing, and a handed dataclass holding a field its `RETIRED` names decodes as None where its type allows None, and is rejected otherwise. `LoopRun.items_taken_in`, a tuple of item IDs, decodes only from a JSON array of integers. Make `decoded_as` easier to read. - ### 237. Give `judge` and `judge_once` in `bin/loop_claude/cycle/judge.py` a record of the inputs they share, in place of nine and eight parameters, or record why they stay. Found by the principles audit of PR #376. "About seven things per level" in `principles/technical-principles.md`: `judge` takes nine parameters and `judge_once` eight, past the four or five for things that act on each other, with no recorded reason. Both take root, task, premises, records, entries, escalated_at, rung and effects, which one record could carry. -- 2.52.0 From 897d93d3579d11f138f9472d290c0a0010a4c34c Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 22:41:24 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Answer=20security=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=200=20=F0=9F=9F=A1=20(0=20misread)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0 From 2956997794b32292852ca5d7ee988be15eb4019a Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 22:45:39 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Answer=20stability=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=203=20=F0=9F=9F=A1=20(0=20misread);=20catch=20onl?= =?UTF-8?q?y=20Unreadable=20around=20the=20decode,=20test=20each=20require?= =?UTF-8?q?d=20field=20and=20the=20id=20list's=20type,=20reword=20the=20de?= =?UTF-8?q?coders'=20docstrings=20as=20the=20prose=20round=20asked?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/loop_claude/loop/reload.py | 15 +++++++++------ bin/loop_claude/test_loop_claude.py | 15 +++++++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/bin/loop_claude/loop/reload.py b/bin/loop_claude/loop/reload.py index b4f39ac5..9092d3cb 100644 --- a/bin/loop_claude/loop/reload.py +++ b/bin/loop_claude/loop/reload.py @@ -34,23 +34,26 @@ class Unreadable(Exception): def decode_handed(handed: str) -> LoopRun | None: - """The LoopRun the JSON holds; None for text that isn't one. A field of LoopRun or Route with a default may be missing, so a field added since the running script started doesn't stop the loop.""" + """The LoopRun the JSON holds; None for text that isn't one. A field of LoopRun or Route with a default may be missing, so a field the sending script didn't know yet doesn't stop the loop; an effort missing from a Rung is empty.""" try: fields = json.loads(handed) + except ValueError: + return None + try: return LoopRun(**decoded_fields(fields, LOOP_RUN_FIELDS, "cycle_number", "root", "task", "unfinished_evidence")) - except (ValueError, Unreadable): + except Unreadable: return None def decoded_fields(value: object, decoders: dict[str, typing.Callable[[typing.Any], typing.Any]], *required: str) -> dict[str, typing.Any]: - """Each field of the JSON object through its decoder; raises Unreadable unless the object holds every required field and none the decoders don't name.""" + """Each field of the JSON object through its decoder. Raises Unreadable for a value that isn't an object, an object missing a required field, and an object holding a field that has no decoder.""" if not isinstance(value, dict) or not set(required) <= value.keys() <= decoders.keys(): raise Unreadable return {name: decoders[name](field) for name, field in value.items()} def exactly(kind: type) -> typing.Callable[[typing.Any], typing.Any]: - """A decoder of a value of exactly this type: type(), not isinstance(), since JSON true is no integer.""" + """A decoder of a value of exactly this type. It checks type(), since isinstance(True, int) holds and a JSON true must not pass as an integer.""" def decode(value: object) -> object: if type(value) is not kind: raise Unreadable @@ -69,7 +72,7 @@ def decoded_rung(value: object) -> Rung: def decoded_route(value: object) -> Route | None: - """A reload from before Route dropped a field hands a route that field names in Route.RETIRED: it decodes as None, and the chunk routes afresh.""" + """The Route the JSON holds; None for null, or for a route holding a key Route.RETIRED names, so the chunk routes afresh.""" if value is None or (isinstance(value, dict) and value.keys() & Route.RETIRED): return None fields = decoded_fields(value, ROUTE_FIELDS, "rung") @@ -78,7 +81,7 @@ def decoded_route(value: object) -> Route | None: return Route(**fields) -# One decoder per field, which tests hold to the dataclass's fields: a field missing here stops a loop at the reload after it joined. +# One decoder per field of LoopRun and of Route, which tests hold to those dataclasses' fields: a field missing here stops a loop at the reload after it joined. LOOP_RUN_FIELDS = {"cycle_number": exactly(int), "root": exactly(str), "task": exactly(str), "unfinished_evidence": exactly(str), "route": decoded_route, "unfinished_run": exactly(int), "items_taken_in": decoded_ids} ROUTE_FIELDS = {"rung": decoded_rung, **{name: exactly(int) for name in ("item", "likelihood", "escape_and_impact", "unfinished", "escape_and_impact_taken_in", "escalated_at")}} diff --git a/bin/loop_claude/test_loop_claude.py b/bin/loop_claude/test_loop_claude.py index 920bf8b8..1b368491 100644 --- a/bin/loop_claude/test_loop_claude.py +++ b/bin/loop_claude/test_loop_claude.py @@ -1778,7 +1778,7 @@ class LoopRuns(unittest.TestCase): self.assertEqual(set(reload.LOOP_RUN_FIELDS), {field.name for field in dataclasses.fields(main.LoopRun)}) self.assertEqual(set(reload.ROUTE_FIELDS), {field.name for field in dataclasses.fields(Route)}) - def test_rejects_a_field_of_the_state_or_its_route_of_another_type(self): + def test_rejects_a_field_of_another_type_or_an_unknown_field(self): state = dataclasses.asdict(main.LoopRun(cycle_number=2, root="/r", task="do it", unfinished_evidence="", route=Route(Rung("claude-opus-5-5", "high"), 3, 4, 5, 1, 7, 9), unfinished_run=2)) for path, wrong in ((("unfinished_run",), "2"), (("unfinished_run",), True), (("route", "unfinished"), 1.0), (("route", "escalated_at"), "9"), (("route", "item"), True), (("route", "rung"), "claude-opus-5-5"), (("route", "rung", "model"), None), (("route",), "r"), (("route", "extra"), 1)): with self.subTest(path=path, wrong=wrong): @@ -1789,6 +1789,17 @@ class LoopRuns(unittest.TestCase): target[path[-1]] = wrong self.assertIsNone(reload.decode_handed(json.dumps(handed))) + def test_rejects_a_state_or_rung_missing_a_required_field(self): + state = dataclasses.asdict(main.LoopRun(cycle_number=2, root="/r", task="do it", unfinished_evidence="", route=Route(Rung("claude-opus-5-5", "high")))) + for path in (("cycle_number",), ("root",), ("task",), ("unfinished_evidence",), ("route", "rung"), ("route", "rung", "model")): + with self.subTest(path=path): + handed = json.loads(json.dumps(state)) + target = handed + for key in path[:-1]: + target = target[key] + del target[path[-1]] + self.assertIsNone(reload.decode_handed(json.dumps(handed))) + def test_decodes_a_rung_without_an_effort(self): state = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", route=Route(Rung("some-model"))) self.assertEqual(reload.decode_handed(json.dumps({**dataclasses.asdict(state), "route": {"rung": {"model": "some-model"}}})), state) @@ -1830,7 +1841,7 @@ class LoopRuns(unittest.TestCase): def test_decodes_the_items_taken_in_as_a_tuple_of_ids(self): state = main.LoopRun(cycle_number=1, root="/r", task="do it", unfinished_evidence="", items_taken_in=(12, 14)) self.assertEqual(reload.decode_handed(json.dumps(dataclasses.asdict(state))), state) - for taken_in in ([12, "14"], [True], "12", {"12": 1}): + for taken_in in ([12, "14"], [True], "12", {"12": 1}, "", {}): with self.subTest(taken_in=taken_in): self.assertIsNone(reload.decode_handed(json.dumps(dataclasses.asdict(state) | {"items_taken_in": taken_in}))) -- 2.52.0 From f62b6b870e636513ad5bdf96264584b483e9fe43 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Sun, 8 Nov 2026 22:45:39 +0100 Subject: [PATCH 4/4] =?UTF-8?q?Answer=20prose=20round=201:=200=20?= =?UTF-8?q?=F0=9F=94=B4,=204=20=F0=9F=9F=A1=20(0=20misread);=20fixed=20in?= =?UTF-8?q?=20the=20stability=20round's=20commit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -- 2.52.0