Answer architecture round 1: 1 🔴, 21 🟡 (0 misread); skip the routing call where no development clone exists, name the judge's rules the setup's, record two accepted trade-offs, and update stale plan paths
This commit is contained in:
@@ -60,10 +60,10 @@ FINISHED_RULES = (
|
||||
"The chunk is the piece of work the worker is on, shipped as one pull request.\n\n"
|
||||
"finished=true when the chunk is complete: merged, or nothing remains that the worker could do on "
|
||||
"its own. Even then, it is finished only once {answers_recorded}.\n\n"
|
||||
"An answer counts as recorded where the premises or the records above already hold it, the human's rules "
|
||||
"An answer counts as recorded where the premises or the records above already hold it, the setup's rules "
|
||||
"(the setup's CLAUDE.md, the setup's rules/, the project's review standards, each headed by its name) included. "
|
||||
"It also counts where the transcript shows the worker writing it into {answer_destinations}, "
|
||||
"but not into one of the human's rules.\n\n"
|
||||
"but not into one of the setup's rules.\n\n"
|
||||
"finished=false when work remains that a further run can "
|
||||
"continue: an open PR, a review not yet run, CI not yet reported, an answer not yet recorded."
|
||||
)
|
||||
|
||||
@@ -196,7 +196,7 @@ class JudgePrompt(unittest.TestCase):
|
||||
def test_the_judge_prompt_names_the_entry_points_answer_destinations_in_both_rules_on_a_recorded_answer(self):
|
||||
prompt, _ = judge.judge_prompt(self.brief([assistant({"type": "text", "text": "done"})], 0, "the ledger"))
|
||||
self.assertIn("is recorded in the ledger at the one place it governs", prompt)
|
||||
self.assertIn("the worker writing it into the ledger, but not into one of the human's rules", prompt)
|
||||
self.assertIn("the worker writing it into the ledger, but not into one of the setup's rules", prompt)
|
||||
|
||||
def test_shows_the_judge_where_the_worker_last_stepped_up_and_checks_an_escalation_only_after_it(self):
|
||||
entries = [assistant({"type": "text", "text": "round 2: 🔴"}), assistant({"type": "text", "text": "round 3: 🔴"})]
|
||||
|
||||
@@ -4,7 +4,7 @@ import dataclasses
|
||||
from chunk_driver.drivers import BUILD_EPIC
|
||||
from build_epic.backend.protocol import EpicIssue
|
||||
from build_epic import findings
|
||||
from chunk_driver.project.records import HUMAN_RULE_NAMES, RECORD_FILES
|
||||
from chunk_driver.project.records import SETUP_RULE_NAMES, RECORD_FILES
|
||||
from build_epic.repo_pick import LabelRepos
|
||||
from text_files.markdown_text import listed
|
||||
import pathlib
|
||||
@@ -57,11 +57,11 @@ def fresh(task: str, premises: str, route: Route, project: ProjectRung | None, f
|
||||
|
||||
|
||||
# The worker names no plan items: the chunk's one item is its issue.
|
||||
# The epic's records come first, as its goals do; a chunk without a repo is handed only those and the human's rules, so the names that mention a repo's then name nothing it reads.
|
||||
# The epic's records come first, as its goals do; a chunk without a repo is handed only those and the setup's rules, so the names that mention a repo's then name nothing it reads.
|
||||
NAMES = prompts.RecordNames(
|
||||
quote_sources=listed(("the epic's description", "the repo's goals file's Goals and Audience", *RECORD_FILES, *HUMAN_RULE_NAMES), "or"),
|
||||
quote_sources=listed(("the epic's description", "the repo's goals file's Goals and Audience", *RECORD_FILES, *SETUP_RULE_NAMES), "or"),
|
||||
answer_destinations="the epic's description under ## Decisions, the repo's goals file's Goals or Audience, " + ", ".join(RECORD_FILES) + ", the repo's plan or a comment",
|
||||
records_named="the epic's scoring and decisions, then the repo's working rules and decisions, then the human's rules for every project",
|
||||
records_named="the epic's scoring and decisions, then the repo's working rules and decisions, then the setup's rules for every project",
|
||||
)
|
||||
WORKER = prompts.worker_prompts(DRIVER, fresh, "", NAMES)
|
||||
|
||||
|
||||
@@ -548,7 +548,7 @@ def repoless_models(epic: EpicRun) -> Models:
|
||||
|
||||
|
||||
def records_read(root: str | None, epic: EpicRun) -> str | Failure:
|
||||
"""The epic's Scoring and Decisions, from its description, then the records of the repo checked out at root, where the chunk has one, then the human's rules."""
|
||||
"""The epic's Scoring and Decisions, from its description, then the records of the repo checked out at root, where the chunk has one, then the setup's rules."""
|
||||
sections: list[tuple[str, str]] = []
|
||||
for name in ("Scoring", "Decisions"):
|
||||
body = epic.record.section(name)
|
||||
|
||||
@@ -628,7 +628,7 @@ class AChunksRun(BuildEpicTest):
|
||||
self.assertIn("add one bullet to `## Unreleased` in `CHANGELOG.md`", prompt)
|
||||
self.assertIn("the chunk finished; started ABC-12\n", out)
|
||||
judge_prompt = [what[1] for seam, what in fake.calls if seam == "claude"][0]
|
||||
self.assertIn("The records: the epic's scoring and decisions, then the repo's working rules and decisions, then the human's rules for every project:\nFrom the epic ABC-12's description, ## Decisions:\nKeep the v1 endpoints.\n\nFrom AGENTS.md:\nSquash every merge.", judge_prompt)
|
||||
self.assertIn("The records: the epic's scoring and decisions, then the repo's working rules and decisions, then the setup's rules for every project:\nFrom the epic ABC-12's description, ## Decisions:\nKeep the v1 endpoints.\n\nFrom AGENTS.md:\nSquash every merge.", judge_prompt)
|
||||
self.assertIn("writing it into the epic's description under ## Decisions, the repo's goals file's Goals or Audience, AGENTS.md, docs/decisions.md, the repo's plan or a comment", judge_prompt)
|
||||
|
||||
def test_a_chunk_without_a_repo_reads_no_forge(self) -> None:
|
||||
|
||||
@@ -55,7 +55,7 @@ def new_calls(root: pathlib.Path, paths: Paths, env: Mapping[str, str], effects:
|
||||
|
||||
|
||||
def raise_calls(root: pathlib.Path, new: list[Call], rung: Rung, loop: Loop) -> Stop | None:
|
||||
"""Puts the calls to the human through a claude in this setup's development clone, where the routing decision is changed. Off a terminal they are only said, and stay in the figures, raised at the next measurement on a terminal."""
|
||||
"""Puts the calls to the human through a claude in this setup's development clone, where the routing decision is changed. Off a terminal, or on a machine without that clone, they are only said, and stay in the figures, raised at the next measurement that has both."""
|
||||
bullets = "".join(f"- {call.sentence()}\n" for call in new)
|
||||
question = f"build-release's routing figures call for a routing change:\n{bullets}The figures: {root / archive.FIGURES}"
|
||||
say(f"\n{question}", loop.effects)
|
||||
@@ -63,6 +63,9 @@ def raise_calls(root: pathlib.Path, new: list[Call], rung: Rung, loop: Loop) ->
|
||||
if not loop.effects.on_terminal():
|
||||
say("Not on a terminal: the calls are raised again at the next measurement.", loop.effects)
|
||||
return None
|
||||
if not loop.paths.config_clone.is_dir():
|
||||
say(f"No development clone at {loop.paths.config_clone}: the calls are raised again at the next measurement.", loop.effects)
|
||||
return None
|
||||
prompt = f"Put these calls for a routing change from build-release's figures to the human, and don't change anything until they answer:\n{bullets}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 in this checkout, the development clone, as the setup's CLAUDE.md says; the next chunk of this repo files the plan item for these calls."
|
||||
unstarted = hand_over(ClaudeCommand(claude_args(rung, [prompt]), str(loop.paths.config_clone), {}), loop.effects)
|
||||
if unstarted:
|
||||
|
||||
@@ -34,6 +34,7 @@ class RoutingCheck(unittest.TestCase):
|
||||
self.addCleanup(shutil.rmtree, self.home)
|
||||
self.root = self.home / "archive"
|
||||
self.paths = paths.paths_from(self.home, {})
|
||||
self.paths.config_clone.mkdir(parents=True)
|
||||
self.session = session.session_named("A log build-release", self.paths.claude_code_transcripts)
|
||||
|
||||
def loop(self, fake):
|
||||
@@ -116,6 +117,18 @@ class RoutingCheck(unittest.TestCase):
|
||||
self.assertIsNone(state.mark_measured(self.root, 0))
|
||||
self.assertIn("Not on a terminal", self.check(FakeEffects(on_terminal=False, git=[UNREAD] * 3))[1])
|
||||
|
||||
def test_goes_on_where_the_machine_has_no_development_clone_and_raises_the_call_again_next_time(self):
|
||||
"""A release's clone holds only a release, so a machine without `~/code/dev-factory` has nowhere to change the routing decision."""
|
||||
self.chunks(5, 4)
|
||||
shutil.rmtree(self.paths.config_clone)
|
||||
fake = FakeEffects(on_terminal_claude=[0], git=[UNREAD] * 3)
|
||||
stop, said = self.check(fake)
|
||||
self.assertIsNone(stop)
|
||||
self.assertEqual(fake.made("claude_on_terminal"), [])
|
||||
self.assertIn(f"No development clone at {self.paths.config_clone}: the calls are raised again at the next measurement.", said)
|
||||
self.assertIn("Explore subagents' reports took more of the worker's context", (self.root / "routing-figures.md").read_text())
|
||||
self.assertFalse((self.root / "routing-calls-raised.md").exists())
|
||||
|
||||
def test_leaves_the_measuring_to_a_loop_holding_the_lock(self):
|
||||
self.chunks(5, 4)
|
||||
with archive.locked(self.root):
|
||||
|
||||
@@ -38,7 +38,7 @@ class ExitContract(unittest.TestCase):
|
||||
def test_every_exit_1_stop_has_its_clause_in_help(self):
|
||||
read, git, premises_ = "a transcript cannot be read or archived", "git cannot start or finds no checkout", "no config names the checkout, its config cannot be read, or the goals file holds no premises"
|
||||
models_ = "the models file cannot be read or written"
|
||||
names = (*records.RECORD_FILES, records.HUMAN_RULE_NAMES[0], f"{records.HUMAN_RULE_NAMES[1]}*.md", records.HUMAN_RULE_NAMES[2])
|
||||
names = (*records.RECORD_FILES, records.SETUP_RULE_NAMES[0], f"{records.SETUP_RULE_NAMES[1]}*.md", records.SETUP_RULE_NAMES[2])
|
||||
unreadable = f"the goals file, or {', '.join(names[:-1])} or {names[-1]} where they exist, cannot be read or is not UTF-8"
|
||||
# Every Stop whose code is not a literal 0, 2 or 130, in source order: path, function, code, start of reason, its --help clause.
|
||||
clauses = [
|
||||
|
||||
@@ -7,32 +7,32 @@ from chunk_driver.project.text_file import read_utf8
|
||||
from loop_state.paths import RELEASE_ROOT
|
||||
from record_store.stores import store
|
||||
|
||||
# The records the judge reads beside the premises, by the name that heads each, with the setting in the project's config that places it; then the human's rules below.
|
||||
# The records the judge reads beside the premises, by the name that heads each, with the setting in the project's config that places it; then the setup's rules below.
|
||||
WORKING_RULES = ("AGENTS.md", "working-rules")
|
||||
DECISIONS = ("docs/decisions.md", "decisions")
|
||||
RECORD_FILES = (WORKING_RULES[0], DECISIONS[0])
|
||||
# The human's rules, in the order the judge reads them: the setup's CLAUDE.md, each .md file in its rules/,
|
||||
# The setup's rules, in the order the judge reads them: the setup's CLAUDE.md, each .md file in its rules/,
|
||||
# then each .md file in the review standards folder the project's config sets.
|
||||
HUMAN_RULES_FILE = "CLAUDE.md"
|
||||
HUMAN_RULE_DIR = "rules"
|
||||
SETUP_RULES_FILE = "CLAUDE.md"
|
||||
SETUP_RULE_DIR = "rules"
|
||||
# How the judge's prompt names the records above, in the order it reads them.
|
||||
RECORDS_NAMED = "the project's working rules and decisions, then the human's rules for every project"
|
||||
RECORDS_NAMED = "the project's working rules and decisions, then the setup's rules for every project"
|
||||
# How prose names a file of the setup wherever its clone lies: the setup's CLAUDE.md → "Vocabulary", "setup".
|
||||
OF_THE_SETUP = "the setup's"
|
||||
HUMAN_RULE_NAMES = (f"{OF_THE_SETUP} {HUMAN_RULES_FILE}", f"{OF_THE_SETUP} {HUMAN_RULE_DIR}/", "the project's review standards")
|
||||
SETUP_RULE_NAMES = (f"{OF_THE_SETUP} {SETUP_RULES_FILE}", f"{OF_THE_SETUP} {SETUP_RULE_DIR}/", "the project's review standards")
|
||||
|
||||
|
||||
CONSEQUENCE = "the judge cannot read the records"
|
||||
|
||||
|
||||
def read_records(root: str | None, home: pathlib.Path, env: Mapping[str, str], claude_dir: pathlib.Path, first: tuple[tuple[str, str], ...] = ()) -> str | Failure:
|
||||
"""The project's `AGENTS.md` and decision log, then the human's rules, CLAUDE.md first, each headed by its name. One that does not exist, or is empty, is left out. A text that several of them hold appears once, headed by all their names.
|
||||
"""The project's `AGENTS.md` and decision log, then the setup's rules, CLAUDE.md first, each headed by its name. One that does not exist, or is empty, is left out. A text that several of them hold appears once, headed by all their names.
|
||||
|
||||
`AGENTS.md` is read where the config under home of root's project puts it, and the decision log from the store that config names. Each is headed by its name in RECORD_FILES wherever it is kept.
|
||||
|
||||
first holds records kept outside the project, such as the sections of a Jira epic's description, each as its heading and text: they come before the project's. A root of None is work without a checkout, which has no project records and no review standards."""
|
||||
texts: list[tuple[str, str | Failure]] = list(first)
|
||||
rules = [claude_dir / HUMAN_RULES_FILE, *sorted((claude_dir / HUMAN_RULE_DIR).glob("*.md"))]
|
||||
rules = [claude_dir / SETUP_RULES_FILE, *sorted((claude_dir / SETUP_RULE_DIR).glob("*.md"))]
|
||||
if root is not None:
|
||||
config = located(root, home, env)
|
||||
if isinstance(config, Failure):
|
||||
|
||||
@@ -107,7 +107,7 @@ class Records(unittest.TestCase):
|
||||
|
||||
class JudgeRules(unittest.TestCase):
|
||||
def test_the_judge_prompt_names_every_rule_the_judge_reads_from_the_human(self):
|
||||
self.assertEqual([name for name in records.HUMAN_RULE_NAMES if name not in judge.judge_rules("the ledger", "a-driver")], [])
|
||||
self.assertEqual([name for name in records.SETUP_RULE_NAMES if name not in judge.judge_rules("the ledger", "a-driver")], [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -7,13 +7,13 @@ from agent_cycle.escalation_mark import asks_higher_rung
|
||||
from model_routing.review_choice import chosen, ReviewChoice
|
||||
from model_routing.route import ESCALATION_MARKER, Route
|
||||
from agent_cycle.routing import escalation_rungs
|
||||
from chunk_driver.project.records import HUMAN_RULE_NAMES, RECORD_FILES, RECORDS_NAMED
|
||||
from chunk_driver.project.records import SETUP_RULE_NAMES, RECORD_FILES, RECORDS_NAMED
|
||||
from review_rules.review_passes import INSTRUCTION_FILES, INSTRUCTION_FOLDERS
|
||||
from text_files.markdown_text import listed, quoted
|
||||
from model_routing.ladder import ProjectRung, Rung
|
||||
|
||||
# Where the judge may quote an answer from, named as the human and the worker see them; of the goals file the judge sees only the premises.
|
||||
QUOTE_SOURCES = listed(("the goals file's Goals and Audience", *RECORD_FILES, *HUMAN_RULE_NAMES), "or")
|
||||
QUOTE_SOURCES = listed(("the goals file's Goals and Audience", *RECORD_FILES, *SETUP_RULE_NAMES), "or")
|
||||
# Where the worker may write an answer the human typed, so it counts as recorded.
|
||||
ANSWER_DESTINATIONS = "the goals file's Goals or Audience, " + ", ".join(RECORD_FILES) + ", the plan or a comment"
|
||||
ANSWERS_RECORDED = answers_recorded(ANSWER_DESTINATIONS)
|
||||
|
||||
@@ -261,7 +261,7 @@ class Main(unittest.TestCase):
|
||||
code, _, err = self.run_main(["claude-opus-5-5"], lambda rung, interrupted: self.verdict(interrupted, f"said {INTERRUPTED if interrupted else FINISHED}"))
|
||||
self.assertEqual(code, 0, err)
|
||||
for prompt, schema in zip(self.prompts, self.schemas, strict=True):
|
||||
self.assertIn("\n\nThe records: the project's working rules and decisions, then the human's rules for every project:\n", prompt)
|
||||
self.assertIn("\n\nThe records: the project's working rules and decisions, then the setup's rules for every project:\n", prompt)
|
||||
self.assertIn("what build-release told it on [loop] lines, latest last:\n", prompt)
|
||||
self.assertEqual(prompt.count("said Verdict: "), 1)
|
||||
self.assertIn("build-release", schema)
|
||||
|
||||
@@ -6,13 +6,13 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from chunk_driver.project.records import HUMAN_RULE_DIR
|
||||
from chunk_driver.project.records import SETUP_RULE_DIR
|
||||
from repo_checks import ROOT
|
||||
|
||||
# The review standards this repo ships. A project's config may name another folder as `standards`.
|
||||
STANDARDS = "skills/larv-review/standards"
|
||||
# The folders whose files a citation may name by path. The judge reads both.
|
||||
RULE_DIRS = (HUMAN_RULE_DIR, STANDARDS)
|
||||
RULE_DIRS = (SETUP_RULE_DIR, STANDARDS)
|
||||
RULE_PATH = rf"(?:{'|'.join(map(re.escape, RULE_DIRS))})/[\w-]+\.md"
|
||||
NAMES = r'("[^"]+"(?:,? (?:and )?"[^"]+")*)'
|
||||
CITATION = re.compile(rf'`?(CLAUDE\.md|{RULE_PATH})`? → {NAMES}')
|
||||
|
||||
Reference in New Issue
Block a user