Answer architecture round 4: 0 🔴, 0 🟡 (0 misread); loop-claude's suites sit beside their modules, and what tests share across packages lives in each package's doubles.py
CI / tests (pull_request) Successful in 3m43s
CI / tests (pull_request) Successful in 3m43s
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
|
||||
|
||||
from loop_claude.chunk import chunk_items
|
||||
from claude_code import entries
|
||||
from failure import Failure
|
||||
from loop_claude.chunk import fresh_prompt
|
||||
from plan_store.todo_md import plan_of
|
||||
from model_routing.route import Route
|
||||
from model_routing.ladder import Rung
|
||||
from loop_effects.doubles import said
|
||||
from agent_cycle.verdicts import TakenIn
|
||||
|
||||
|
||||
# Item 297 scores the higher L, item 298 the higher E + I.
|
||||
SCORED = "## Items\n\n| ID | Release | Exempt | Item | L | E | I | R | S | Moves | Score |\n|---|---|---|---|---|---|---|---|---|---|---|\n| 297 | 0.8.0 | | **Do it.** | 4 | 2 | 3 | 7 | 2 | 1 by 9 | 25 |\n| 298 | 0.8.0 | | **Do more.** | 3 | 3 | 4 | 8 | 2 | 1 by 9 | 20 |\n"
|
||||
|
||||
|
||||
class ChunkItems(unittest.TestCase):
|
||||
def test_names_the_items_on_the_workers_latest_chunk_items_line(self):
|
||||
earlier = said("Chunk items: 297 (L 3, E + I 5)")
|
||||
latest = said("Starting.\n**Chunk items:** 297 (L 4, E + I 5), item 298 (L 3, E + I 7), #12, 298\nOn to the tests.")
|
||||
self.assertEqual(chunk_items.named([earlier, latest]), (297, 298, 12))
|
||||
self.assertEqual(chunk_items.named([latest, earlier]), (297,))
|
||||
self.assertEqual(chunk_items.named([earlier, said("Chunk items: none")]), ())
|
||||
self.assertEqual(chunk_items.named([said("Chunk items: 297 and 298 (L 3, E + I 7)")]), (297, 298))
|
||||
|
||||
def test_reads_the_example_line_the_prompt_gives_the_worker(self):
|
||||
example = re.search(r"`(Chunk items:[^`]*)`", fresh_prompt.NAME_THE_ITEMS)[1]
|
||||
self.assertEqual(chunk_items.named([said(example)]), (297, 298))
|
||||
|
||||
def test_every_prompt_that_starts_or_resumes_a_chunk_asks_for_the_line(self):
|
||||
self.assertIn("on one line, as in `Chunk items: ", fresh_prompt.WORKER.resumed("", Route(Rung("m")), None))
|
||||
|
||||
def test_reads_only_a_line_the_worker_opens_with_the_label_in_its_own_text(self):
|
||||
prompt = entries.LoopPrompt(text="Chunk items: 297 (L 3, E + I 5)")
|
||||
written = entries.AssistantTurn(parts=(entries.ToolCall("t", "Write", {"content": "Chunk items: 9"}),))
|
||||
mentioned = said("Once I know them, I write `Chunk items: 5`.")
|
||||
self.assertEqual(chunk_items.named([prompt, written, mentioned]), ())
|
||||
|
||||
def test_takes_the_highest_l_and_e_plus_i_todo_md_scores_among_the_named_items(self):
|
||||
self.assertEqual(chunk_items.taken_in([said("Chunk items: 297 (L 1, E + I 2), 298, 400")], plan_of(SCORED)), TakenIn(4, 7))
|
||||
self.assertEqual(chunk_items.taken_in([said("Chunk items: 400")], plan_of(SCORED)), TakenIn())
|
||||
self.assertEqual(chunk_items.taken_in([], plan_of(SCORED)), TakenIn())
|
||||
|
||||
def test_names_the_items_at_no_level_where_todo_md_cannot_be_read(self):
|
||||
self.assertEqual(chunk_items.taken_in([said("Chunk items: 297")], Failure("no todo.md")), TakenIn())
|
||||
self.assertEqual(chunk_items.taken_in([said("Chunk items: 297")], plan_of("no items table")), TakenIn())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,57 @@
|
||||
import pathlib
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2]))
|
||||
|
||||
from loop_claude.chunk import fresh_prompt
|
||||
from loop_claude.doubles import OPUS_PROJECT
|
||||
from chunk_driver import prompts
|
||||
from model_routing.route import Route
|
||||
from model_routing.ladder import Rung
|
||||
|
||||
|
||||
class FreshPrompt(unittest.TestCase):
|
||||
"""loop-claude's first prompt of a chunk."""
|
||||
# What the preflight found, as the fresh prompt quotes it.
|
||||
FACTS = "- A preflight fact."
|
||||
|
||||
def test_names_the_route_in_a_fresh_prompt_only_where_an_item_routed_it(self):
|
||||
routed = fresh_prompt.WORKER.fresh("Do it.", "## Goals", Route(Rung("m", "high"), 3, 4, 5), None, self.FACTS)
|
||||
self.assertIn(f"Continue any open draft PR or worktree for the chunk before creating a new one. {prompts.READING_RULE} {fresh_prompt.NAME_THE_ITEMS}\n\nloop-claude runs you on m at high effort, routed by item 3's L of 4.", routed)
|
||||
unrouted = fresh_prompt.WORKER.fresh("Do it.", "## Goals", Route(Rung("m")), None, self.FACTS)
|
||||
self.assertIn(f"before creating a new one. {prompts.READING_RULE} {fresh_prompt.NAME_THE_ITEMS}\n\n{self.FACTS}\n\nThe chunk's", unrouted)
|
||||
self.assertNotIn("loop-claude runs you on", unrouted)
|
||||
|
||||
def test_has_the_routed_worker_count_its_items_size_again_and_puts_the_facts_before_the_scope(self):
|
||||
routed = fresh_prompt.WORKER.fresh("Do it.", "## Goals", Route(Rung("m", "high"), 3, 4, 5), None, self.FACTS)
|
||||
self.assertIn("item 3's size again", routed)
|
||||
self.assertIn("escalation trigger 1", routed)
|
||||
self.assertIn(f"\n\n{self.FACTS}\n\nThe chunk's", routed)
|
||||
self.assertNotIn("size again", fresh_prompt.WORKER.fresh("Do it.", "## Goals", Route(Rung("m")), None, self.FACTS))
|
||||
|
||||
def test_gives_each_fresh_worker_the_reading_rule_once(self):
|
||||
rule = "never read more than 80 lines of a file at once, nor take a tool output over 3,000 characters into your context"
|
||||
for route in (Route(Rung("m", "high"), 3, 4, 5), Route(Rung("m"))):
|
||||
with self.subTest(route=route):
|
||||
self.assertEqual(fresh_prompt.WORKER.fresh("Do it.", "## Goals", route, None, self.FACTS).count(rule), 1)
|
||||
|
||||
def test_quotes_what_the_preflight_printed_or_has_the_worker_find_the_facts_itself(self):
|
||||
self.assertIn("\n\n- A fact.", fresh_prompt.preflight_facts("- A fact."))
|
||||
failed = fresh_prompt.preflight_failed("git could not start")
|
||||
self.assertIn("yourself", failed)
|
||||
self.assertIn("git could not start", failed)
|
||||
|
||||
def test_has_each_fresh_worker_continue_an_open_draft_pr_or_worktree_once_whatever_the_preflight_found(self):
|
||||
for facts in (fresh_prompt.preflight_facts("- A fact."), fresh_prompt.preflight_failed("git could not start")):
|
||||
with self.subTest(facts=facts):
|
||||
self.assertEqual(fresh_prompt.WORKER.fresh("Do it.", "## Goals", Route(Rung("m")), None, facts).count("Continue any open draft PR or worktree"), 1)
|
||||
|
||||
def test_puts_the_rung_sentences_after_the_route_or_else_before_the_facts(self):
|
||||
routed, unrouted = Route(OPUS_PROJECT.rung, 3, 2, 4), Route(OPUS_PROJECT.rung)
|
||||
self.assertIn(f"routed by item 3's L of 2.{prompts.rungs_held(fresh_prompt.DRIVER, routed, OPUS_PROJECT)} After your first read", fresh_prompt.WORKER.fresh("Do it.", "## Goals", routed, OPUS_PROJECT, self.FACTS))
|
||||
self.assertIn(f"{fresh_prompt.NAME_THE_ITEMS}\n\n{prompts.rungs_held(fresh_prompt.DRIVER, unrouted, OPUS_PROJECT).lstrip()}\n\n{self.FACTS}", fresh_prompt.WORKER.fresh("Do it.", "## Goals", unrouted, OPUS_PROJECT, self.FACTS))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user