Name the text-file helpers for what they hold, and keep what counts as a quote beside the judge

This commit is contained in:
2026-11-13 02:49:07 +01:00
parent e1ca619e96
commit 64eb8fc7d7
48 changed files with 76 additions and 66 deletions
+2 -2
View File
@@ -82,8 +82,6 @@
!bin/reading-cost
!bin/reading_cost/
!bin/reading_cost/*.py
!bin/records/
!bin/records/*.py
!bin/release_plan/
!bin/release_plan/*.py
!bin/repo_checks/
@@ -118,6 +116,8 @@
!bin/subagent_rung/
!bin/subagent_rung/*.py
!bin/test_*.py
!bin/text_files/
!bin/text_files/*.py
!bin/todo-item
!bin/todo_item/
!bin/todo_item/*.py
+1 -1
View File
@@ -172,7 +172,7 @@ Install puts only `loop-claude` and `loop-inbox` on `PATH`; call the others by t
- `mattermost_dm/` sends the human a Mattermost DM, for `mattermost-dm` and for loop-claude through `loop_effects`.
- `model_routing/` holds the routing ladder, which loop-claude, `rule_hook`, both replay tools and `subagent-rung` read, and the list prices, which `routing_figures` and `transcript_archive` read.
- `rank_todo.py`, `settings_filter.py` and `statusline.py` are tools of one file each, tested beside them.
- `records/` reads a Markdown file's `##` sections, quotes a passage and joins names into a list, stamps times in UTC, and replaces a file in one step, private where it is new.
- `text_files/` reads a Markdown file's `##` sections, quotes a passage and joins names into a list, stamps times in UTC, and replaces a file in one step, private where it is new.
- `release_plan/` reads `todo.md`'s items table and release versions, says which release is next and whether it is ready to cut (`release_standing.py`), and ranks the plan (`ranking.py`, with its score formula in `formula.py` and its blocker order in `blockers.py`). `goals_file.py` reads the goals file's sections, goals and goal weights, for the ranking and for `loop_claude`'s premises, and `citations.py` holds `todo.md` and `docs/decisions.md` to each other. `plan_file.py` reads, ranks, checks and writes a `todo.md`, for `larv_review`, `rank_todo.py`, `rule_hook` and `todo_item`.
- `repo_checks/` tests the repo itself.
- `review_rules/` holds the larv-review rules that several tools apply: its passes, its review folder, its round commit titles and the comprehension history's format.
+1 -1
View File
@@ -6,7 +6,7 @@ from failure import Failure
from review_rules.comprehension_history import HISTORY
from release_plan.todo_table import Item, items
from reading_cost.figures import RECORD
from records.utc_stamp import utc
from text_files.utc_stamp import utc
# The plan, and the records tools append to: none of their lines are the chunk's work.
NOT_WORK = ("todo.md", HISTORY, RECORD)
+1 -1
View File
@@ -4,7 +4,7 @@ from chunk_preflight.choices import cut_name, PULLS_LIST
from release_plan.release_standing import dated_cut, LastCut, unreleased_entries, UNSEEN_RELEASES
from failure import Failure
from chunk_preflight.gathered import Forge, Gathered, ItemFacts, NamedPath, NoItem, Plan, Ran
from records.markdown_text import listed, quoted
from text_files.markdown_text import listed, quoted
from release_plan.release import version
-8
View File
@@ -43,14 +43,6 @@ class Render(unittest.TestCase):
self.assertEqual(said, '[human] do it\n\nStarting.\n\n[tool Bash] {"command": "ls"}\n\n[human] yes, merge it\n\n[human] B, while you work\n\n[loop] Continue the task; the previous run stopped before it was finished.\n\n[loop] Your question: A or B?\n\n[human] use B')
class Verbatim(unittest.TestCase):
def test_a_quote_holds_only_word_for_word_less_emphasis_and_whitespace(self):
self.assertTrue(transcript.verbatim("Merge **ff-only**.", "Merge ff-only.\nNever squash."))
self.assertTrue(transcript.verbatim("Merge _ff-only_.", "Merge ff-only.\nNever squash."))
self.assertFalse(transcript.verbatim("Merge ... squash.", "Merge ff-only.\nNever squash."))
self.assertFalse(transcript.verbatim("", "Merge ff-only."))
class FirstTimestampedLine(unittest.TestCase):
def test_skips_the_lines_every_chunk_shares_and_else_takes_the_first(self):
self.assertEqual(transcript.first_timestamped_line(b'{"type": "custom-title"}\nnot JSON\n{"timestamp": "t"}\n{"timestamp": "u"}\n'), b'{"timestamp": "t"}')
-11
View File
@@ -80,14 +80,3 @@ def part_line(part: Text | ToolCall, tool_input_chars: int) -> str:
if isinstance(part, ToolCall):
return f"[tool {part.name}] {json.dumps(part.input, ensure_ascii=False)[:tool_input_chars]}"
return part.text if part.text.strip() else ""
def verbatim(quote: str, text: str) -> bool:
"""Whether text holds the judge's quote word for word, once plain strips emphasis and reflows whitespace in both."""
quoted = plain(quote)
return quoted != "" and quoted in plain(text)
def plain(text: str) -> str:
# The judge drops markdown emphasis and reflows whitespace when it quotes.
return " ".join(text.replace("*", "").replace("_", "").split())
+1 -1
View File
@@ -38,7 +38,7 @@ from transcript_archive.read import finished_chunks, read_threads
from git_cli.git_repo import git
from transcript_archive.location import project_archive
from command_patterns.tally import records, table, tally
from records.utc_stamp import seconds
from text_files.utc_stamp import seconds
USAGE = "usage: command-patterns [<version>] [--calls <file>]"
+1 -1
View File
@@ -2,7 +2,7 @@
from failure import Failure
from git_cli.git_repo import git
from release_plan.release import newest_tag, parsed, tagged
from records.markdown_text import sections
from text_files.markdown_text import sections
def deploy(checkout: str) -> str | Failure:
+1 -1
View File
@@ -13,7 +13,7 @@ from larv_review.scoring import floor_step, means, under_floor
from release_plan import plan_file
from project_config.main import project
from larv_review.scoring_setup import removed_setup
from records.file_writes import replace_file
from text_files.file_writes import replace_file
def record_ruling(votes_file: pathlib.Path) -> Failure | None:
+1 -1
View File
@@ -6,7 +6,7 @@ import shutil
from review_rules.comprehension_history import DIMENSIONS
from failure import Failure
from records.markdown_text import FENCE, listed, section
from text_files.markdown_text import FENCE, listed, section
from git_cli.git_repo import git
from project_config.main import located
from review_rules.review_folder import made_review_folder, review_folder
+1 -1
View File
@@ -4,7 +4,7 @@ import re
from claude_code.entries import AssistantTurn, Entry, Text
from failure import Failure
from release_plan.todo_table import items
from claude_code.transcript import plain
from loop_claude.quotes import plain
from loop_claude.verdicts import TakenIn
# The label opening the line; prompts.NAME_THE_ITEMS asks the worker for it.
+2 -1
View File
@@ -10,7 +10,8 @@ from claude_code.entries import Entry, structured_output
from loop_claude import escalation_mark
from failure import Failure
from loop_claude.verdicts import Finished, Interrupt, Judged, QuotedAnswer, Unfinished, Verdict
from claude_code.transcript import human_answers, plain, verbatim
from claude_code.transcript import human_answers
from loop_claude.quotes import plain, verbatim
from loop_claude.cycle.retry import retried
from model_routing.ladder import Rung
from loop_claude.stop import Stop
+1 -1
View File
@@ -6,7 +6,7 @@ from model_routing.route import ESCALATION_MARKER, Route
from loop_claude.routing import escalation_rungs
from loop_claude.project.records import HUMAN_RULE_NAMES, RECORD_FILES
from review_rules.review_passes import INSTRUCTION_FILES, INSTRUCTION_FOLDERS
from records.markdown_text import listed, quoted
from text_files.markdown_text import listed, quoted
from claude_code.transcript import Typed
# 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.
+2 -1
View File
@@ -10,9 +10,10 @@ A worker whose run ends asking loop-claude for a higher rung cites the trigger t
import dataclasses
import typing
from claude_code.transcript import assistant_lines, render, Typed, verbatim
from claude_code.transcript import assistant_lines, render, Typed
from claude_code.entries import AssistantTurn, Entry
from loop_claude.verdicts import Escalating, Verdict
from loop_claude.quotes import verbatim
# Only the judge reads the step line, so it is not a [loop] line.
STEP_TAG = "[step]"
+1 -1
View File
@@ -15,7 +15,7 @@ from model_routing.ladder import Rung
from routing_figures import state
from loop_claude.stop import Stop
from loop_claude.direct_message import tell
from records.utc_stamp import utc
from text_files.utc_stamp import utc
def check_routing(root: pathlib.Path, rung: Rung, loop: Loop) -> Stop | None:
+1 -1
View File
@@ -9,7 +9,7 @@ from loop_effects.effects import Effects, say
from failure import Failure
from loop_claude.stop import needs_human, needs_terminal, Stop
from loop_state.paths import Paths
from records.file_writes import replace_json
from text_files.file_writes import replace_json
@dataclasses.dataclass(frozen=True)
+12
View File
@@ -0,0 +1,12 @@
"""What counts as a quote, for every check of a passage the judge or the worker quotes: of the transcript, the premises, the records or a human's line."""
def verbatim(quote: str, text: str) -> bool:
"""Whether text holds the judge's quote word for word, once plain strips emphasis and reflows whitespace in both."""
quoted = plain(quote)
return quoted != "" and quoted in plain(text)
def plain(text: str) -> str:
# The judge drops markdown emphasis and reflows whitespace when it quotes.
return " ".join(text.replace("*", "").replace("_", "").split())
+1 -1
View File
@@ -45,7 +45,7 @@ from loop_claude import routing
from loop_claude.stop import Stop
from loop_state.running_loops import Taken
from claude_code.tokens import Tokens, tokens_of
from records.utc_stamp import utc
from text_files.utc_stamp import utc
from loop_claude.cycle.judge import verdict_from
from loop_state.waiting.listing import waiting
+15
View File
@@ -0,0 +1,15 @@
import pathlib
import sys
import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from loop_claude import quotes
class Verbatim(unittest.TestCase):
def test_a_quote_holds_only_word_for_word_less_emphasis_and_whitespace(self):
self.assertTrue(quotes.verbatim("Merge **ff-only**.", "Merge ff-only.\nNever squash."))
self.assertTrue(quotes.verbatim("Merge _ff-only_.", "Merge ff-only.\nNever squash."))
self.assertFalse(quotes.verbatim("Merge ... squash.", "Merge ff-only.\nNever squash."))
self.assertFalse(quotes.verbatim("", "Merge ff-only."))
+1 -1
View File
@@ -18,7 +18,7 @@ from loop_effects.effects import Effects, say
from loop_state.session_lock import ended, held, running
from failure import Failure
from release_plan.todo_table import items
from records.file_writes import replace_json
from text_files.file_writes import replace_json
# How many times, 0.1 s apart, a loop tries to take its lock: loop-inbox takes it for a moment each time it checks whether the loop has ended.
LOCK_TRIES = 10
+1 -1
View File
@@ -9,7 +9,7 @@ import pathlib
import typing
from failure import Failure
from records.file_writes import make_private
from text_files.file_writes import make_private
def lock_file(folder: pathlib.Path, session: str) -> pathlib.Path:
+1 -1
View File
@@ -7,7 +7,7 @@ import pathlib
from loop_state.waiting.ask import Ask, tagged
from failure import Failure
from records.file_writes import replace_json
from text_files.file_writes import replace_json
@dataclasses.dataclass(frozen=True)
+1 -1
View File
@@ -7,7 +7,7 @@ import pathlib
import typing
from loop_state.hand_over import ClaudeCommand
from records.utc_stamp import seconds, utc
from text_files.utc_stamp import seconds, utc
if typing.TYPE_CHECKING:
from _typeshed import DataclassInstance
+1 -1
View File
@@ -8,7 +8,7 @@ from loop_state.waiting.ask import Ask, ask_fields, read_ask
from loop_effects.effects import Effects, say
from loop_state.session_lock import ended, running
from failure import Failure
from records.file_writes import make_private, replace_json
from text_files.file_writes import make_private, replace_json
def ask_file(folder: pathlib.Path, session: str) -> pathlib.Path:
+2 -2
View File
@@ -5,8 +5,8 @@ import statistics
from failure import Failure
from transcript_archive.read import FinishedChunk
from reading_cost.measure import Reading
from records.markdown_text import sections
from records.utc_stamp import STAMPED
from text_files.markdown_text import sections
from text_files.utc_stamp import STAMPED
FIGURE = re.compile(rf"^Reading cost, chunk (\w+), finished ({STAMPED})$")
FIGURE_FILE = re.compile(r"^- `(.+)` (\d+)$")
+2 -2
View File
@@ -35,8 +35,8 @@ from transcript_archive.read import finished_chunks, read_threads
from git_cli.git_repo import git
from project_config.main import project
from transcript_archive.location import project_archive
from records.file_writes import replace_file
from records.utc_stamp import utc
from text_files.file_writes import replace_file
from text_files.utc_stamp import utc
@dataclasses.dataclass(frozen=True)
class Updated:
+1 -1
View File
@@ -7,7 +7,7 @@ import typing
from release_plan.todo_table import CODE_HEALTH
from failure import Failure
from review_rules.comprehension_history import FLOOR
from records.markdown_text import sections
from text_files.markdown_text import sections
# What each achieve goal weighs of the one above it; docs/decisions.md records the choice.
GOAL_STEP = 0.97
+1 -1
View File
@@ -5,7 +5,7 @@ import sys
from failure import Failure
from project_config.settings import ProjectConfig
from release_plan.ranking import rank, Ranked
from records.file_writes import replace_file
from text_files.file_writes import replace_file
def rank_file(todo: pathlib.Path, config: ProjectConfig) -> Ranked | Failure:
+1 -1
View File
@@ -13,7 +13,7 @@ from release_plan.formula import evaluate, parse_formula
from failure import Failure
from release_plan.goals_file import goal_weights, Mark, ranked_goals
from review_rules.comprehension_history import latest_overall
from records.markdown_text import listed
from text_files.markdown_text import listed
from release_plan.release import version
# What a point of an item's move on a maintain goal is worth. A defect that restores the goal weighs it at least this much per point. docs/decisions.md records the choice and its data.
+1 -1
View File
@@ -7,7 +7,7 @@ from release_plan.release import dated, dated_heading_pattern, newest_tag, parse
from failure import Failure
from release_plan.todo_table import Item, items, next_item, renames
from project_config.settings import Place
from records.markdown_text import sections
from text_files.markdown_text import sections
# The version a branch with no v* tag and no dated CHANGELOG.md heading counts as cut: below every release, 0.0.0 included, so that every release todo.md names comes after it.
BEFORE_FIRST_RELEASE = (-1, 0, 0)
+1 -1
View File
@@ -3,7 +3,7 @@ import re
import typing
from failure import Failure
from records.markdown_text import FENCE, sections
from text_files.markdown_text import FENCE, sections
from release_plan.release import parsed, Release, release_of, VERSION
# Each score a Shape names, and each goal's move, runs from 1 to TOP_SCORE, but for the levels L, E and I, which run from 1 to their LEVELS: ~/.claude/rules/todo-items.md defines each level.
+2 -2
View File
@@ -3,8 +3,8 @@ import decimal
import re
from failure import Failure
from records.markdown_text import sections
from records.utc_stamp import utc
from text_files.markdown_text import sections
from text_files.utc_stamp import utc
ARCHITECT = "Inherited architect"
DECIDED_BY = "decided by"
+1 -1
View File
@@ -5,7 +5,7 @@ import re
from failure import Failure
from review_rules.review_passes import REVIEWERS
from records.markdown_text import section
from text_files.markdown_text import section
# The sections of ~/.claude/CLAUDE.md a reviewer needs, in the file's order: the code-health goal the agents cite, the bar its own prose meets, and the words its reports use.
SECTIONS = ("Shared goal", "Prose", "Vocabulary")
+1 -1
View File
@@ -15,7 +15,7 @@ from routing_figures.chunk import Chunk, chunk_figures, ChunkFigures, Subagent
from git_cli.git_repo import default_ref, Git
from claude_code.entries import Entry, parse_entry
from failure import Failure
from records.file_writes import replace_file
from text_files.file_writes import replace_file
from transcript_archive.outcomes import VERDICT_AT
FIGURES = "routing-figures.md"
+2 -2
View File
@@ -8,8 +8,8 @@ import re
from routing_figures.calls import Call, SENTENCES
from failure import Failure
from records.file_writes import replace_file, replace_json
from records.utc_stamp import STAMPED
from text_files.file_writes import replace_file, replace_json
from text_files.utc_stamp import STAMPED
CYCLES_PER_CHECK = 20
RAISED = "routing-calls-raised.md"
+1 -1
View File
@@ -9,7 +9,7 @@ from rule_hook.rules import Breach
from git_cli.git_repo import default_ref
from rule_hook.git import existing, guarded_git
from failure import Failure
from records.utc_stamp import utc
from text_files.utc_stamp import utc
LOG = "rule-overrides.tsv"
+1 -1
View File
@@ -99,7 +99,7 @@ from git_cli.git_repo import default_branch, full_history, git, top
from failure import Failure
from score_outcomes.results import file_lines, fixed_later, item_text, misreads, nearest, render, report, Result, results_of
from release_plan.todo_table import item_details, LEVELS, risk, TOP_SCORE
from records.markdown_text import listed
from text_files.markdown_text import listed
from release_plan.named_code import named_files
from project_config.main import project
from transcript_archive.location import project_archive
+1 -1
View File
@@ -5,7 +5,7 @@ import typing
from branch_chunks.cut import BranchChunk, Landing, NOT_WORK
from review_rules.round_titles import Findings, round_findings, rounds_past_first
from release_plan.todo_table import Item
from records.markdown_text import listed
from text_files.markdown_text import listed
from release_plan.named_code import named_files
# Fewest single-item chunks a score needs before its medians print: the 10 figures the reading-cost trend waits for; no published standard sets either.
@@ -7,7 +7,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from failure import Failure
from records import file_writes
from text_files import file_writes
class ReplaceFile(unittest.TestCase):
@@ -4,7 +4,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from records import markdown_text
from text_files import markdown_text
class Sections(unittest.TestCase):
+2 -2
View File
@@ -2,8 +2,8 @@ import re
import typing
from model_routing.prices import PRICES
from records.markdown_text import quoted
from records.utc_stamp import STAMPED
from text_files.markdown_text import quoted
from text_files.utc_stamp import STAMPED
from claude_code.tokens import Tokens
from model_routing.route import WorkerLine
@@ -12,7 +12,7 @@ from transcript_archive.project_key import checkout_of, project_key
from failure import Failure
from transcript_archive import outcomes, read, write
from transcript_archive.location import project_archive
from records.utc_stamp import utc
from text_files.utc_stamp import utc
NOW = 1790000000
+2 -2
View File
@@ -5,10 +5,10 @@ import typing
from transcript_archive.location import chunk_folder, outcomes_of
from failure import Failure
from records.file_writes import make_private, replace_file
from text_files.file_writes import make_private, replace_file
from claude_code.session import session_files
from transcript_archive.outcomes import TASK
from records.utc_stamp import utc
from text_files.utc_stamp import utc
def archive(project_archive: pathlib.Path, path: str, task: str, outcome: str, at: float, note: typing.Callable[[str], None] = lambda text: None) -> Failure | None:
+1 -1
View File
@@ -366,7 +366,7 @@ Places the seats named, hardest first (`larv-review places`):
- Self-sufficiency: `bin/rule_hook/round_cap.py:26` `earlier_titles`: fails open on the unattended path where git cannot list the branch's titles, and the cap's wording is spelt in SKILL.md, `rules.py:61` and `round_titles.py`.
- Locality, Shape: `bin/chunk_preflight/choices.py:80` `forge_of`: forge identity and forge calls live in two tool packages, so a second forge lands in three.
- Navigation, Shape: `README.md:131` `bin/`: about 63 entries at one level, the shared libraries told apart only by README prose.
- Navigation: `bin/records/__init__.py:1` `records`: utility code named like the judge's records, and quote semantics in `claude_code/transcript.py:85` `verbatim`.
- Navigation: `bin/text_files/__init__.py:1` `records`: utility code named like the judge's records, and quote semantics in `claude_code/transcript.py:85` `verbatim`.
- Shape: `bin/rule_hook/committed_files.py:14` `committed_file_breaches`: a double-reverse dedupe whose choice of copy no comment explains.
- Shape: `bin/model_routing/route.py:28` `levels_fit`, with `route_of`: two rules in one boolean, and type checks packed into one long line.
- Shape: `bin/loop_claude/loop/reload.py:220` `decoded_route`: one dense guard, and renaming a `LoopRun` field stops a running loop.