Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s
CI / tests (pull_request) Successful in 6m34s
This commit is contained in:
@@ -320,7 +320,7 @@ class BranchHistory(unittest.TestCase):
|
||||
folder = configured(self, checkout)
|
||||
config = folder / "config.toml"
|
||||
config.write_text(config.read_text().replace('"checkout:todo.md"', '"folder:todo.md"'))
|
||||
found = archive.branch_history(str(checkout), folder.parents[1], BARE, functools.partial(git_repo.git, env=isolated_env()))
|
||||
found = archive.branch_history(str(checkout), folder.parents[2], {}, BARE, functools.partial(git_repo.git, env=isolated_env()))
|
||||
assert isinstance(found, Failure), found
|
||||
self.assertEqual(found.reason, f"its chunks' items and later fixes are not counted: the project's config puts {folder}/todo.md elsewhere than todo.md, docs/comprehension-history.md, docs/reading-cost.md in the checkout, the only paths whose commits are read so far")
|
||||
|
||||
@@ -349,16 +349,16 @@ class Archive(unittest.TestCase):
|
||||
def test_measures_each_finished_chunk_keyed_by_its_project(self):
|
||||
self.chunk("home/x", "c1", stamped("2026-10-14T10:00:00Z", outcomes.finished(LOW_ROUTE, "m", "j")), [message("m1", "2026-10-14T09:00:00Z", call("Agent", "a1", subagent_type="Explore"))], ({"agentType": "Explore", "toolUseId": "a1"}, [message("s1", "2026-10-14T09:00:01Z")]))
|
||||
self.chunk("log", "c2", stamped("2026-10-14T10:00:00Z", outcomes.unfinished(LOW_ROUTE, "e", "j", "")), [message("m1", "2026-10-14T09:00:00Z")])
|
||||
found = archive.measure_archive(self.root, "/h", "", no_checkout)
|
||||
found = archive.measure_archive(self.root, "/h", {}, "", no_checkout)
|
||||
self.assertEqual([chunk.dollars["project"] for chunk in found.chunks], [{"home/x": 4.0}])
|
||||
self.assertEqual(found.chunks[0].dollars["subagent type"], {"worker": 2.0, "Explore": 2.0})
|
||||
self.assertEqual(archive.measure_archive(self.root, "/h", "2026-10-14T10:00:00Z", no_checkout), archive.ArchiveChunks([], ()))
|
||||
self.assertEqual(archive.measure_archive(self.root, "/h", {}, "2026-10-14T10:00:00Z", no_checkout), archive.ArchiveChunks([], ()))
|
||||
|
||||
def test_measures_a_chunk_whose_transcripts_are_compressed(self):
|
||||
self.chunk("home/x", "c1", stamped("2026-10-14T10:00:00Z", outcomes.finished(LOW_ROUTE, "m", "j")), [message("m1", "2026-10-14T09:00:00Z", call("Agent", "a1", subagent_type="Explore"))], ({"agentType": "Explore", "toolUseId": "a1"}, [message("s1", "2026-10-14T09:00:01Z")]))
|
||||
for copy in self.root.rglob("*.jsonl"):
|
||||
self.assertIsNone(compress(copy))
|
||||
found = archive.measure_archive(self.root, "/h", "", no_checkout)
|
||||
found = archive.measure_archive(self.root, "/h", {}, "", no_checkout)
|
||||
self.assertEqual(found.chunks[0].dollars["subagent type"], {"worker": 2.0, "Explore": 2.0})
|
||||
|
||||
def test_counts_each_chunks_later_fixes_from_its_projects_checkout(self):
|
||||
@@ -366,7 +366,7 @@ class Archive(unittest.TestCase):
|
||||
env = {**isolated_env(), "GIT_CONFIG_GLOBAL": os.devnull, "HOME": str(home)}
|
||||
self.ship_then_fix(home / "code" / "log", env)
|
||||
self.chunk("log", "c1", stamped("2026-10-14T10:00:00Z", outcomes.finished(LOW_ROUTE, "m", "j")), [message("m1", "2026-10-14T09:00:00Z")])
|
||||
found = archive.measure_archive(self.root, str(home), "", functools.partial(git_repo.git, env=env))
|
||||
found = archive.measure_archive(self.root, str(home), {}, "", functools.partial(git_repo.git, env=env))
|
||||
self.assertEqual([(chunk.dollars["project"].keys(), chunk.fixed_later) for chunk in found.chunks], [({"log": 0}.keys(), 1)])
|
||||
|
||||
def test_reads_a_projects_round_titles_and_its_branchs_history_through_its_configs_templates(self):
|
||||
@@ -377,9 +377,9 @@ class Archive(unittest.TestCase):
|
||||
config = write_config(home, home / "code" / "log") / "config.toml"
|
||||
worker = [message(f"m{n}", "2026-10-14T09:00:00Z", call("Bash", command=f"git commit -m '{round_title.format(n)}'")) for n in (1, 2)]
|
||||
self.chunk("log", "c1", stamped("2026-10-14T10:00:00Z", outcomes.finished(LOW_ROUTE, "m", "j")), worker)
|
||||
bare = archive.measure_archive(self.root, str(home), "", functools.partial(git_repo.git, env=env))
|
||||
bare = archive.measure_archive(self.root, str(home), {}, "", functools.partial(git_repo.git, env=env))
|
||||
config.write_text(config.read_text() + 'commit-title = "PAY-{id} - {summary}"\n')
|
||||
templated = archive.measure_archive(self.root, str(home), "", functools.partial(git_repo.git, env=env))
|
||||
templated = archive.measure_archive(self.root, str(home), {}, "", functools.partial(git_repo.git, env=env))
|
||||
self.assertEqual([(chunk.rounds_past_first, chunk.fixed_later) for chunk in bare.chunks], [(0, 0)])
|
||||
self.assertEqual([(chunk.rounds_past_first, chunk.fixed_later) for chunk in templated.chunks], [(1, 1)])
|
||||
|
||||
@@ -390,7 +390,7 @@ class Archive(unittest.TestCase):
|
||||
config = write_config(home, home / "code" / "log") / "config.toml"
|
||||
config.write_text(config.read_text() + 'commit-title = "PAY-{id}"\n')
|
||||
self.chunk("log", "c1", stamped("2026-10-14T10:00:00Z", outcomes.finished(LOW_ROUTE, "m", "j")), [message("m1", "2026-10-14T09:00:00Z")])
|
||||
found = archive.measure_archive(self.root, str(home), "", functools.partial(git_repo.git, env=env))
|
||||
found = archive.measure_archive(self.root, str(home), {}, "", functools.partial(git_repo.git, env=env))
|
||||
self.assertEqual(found.chunks, [])
|
||||
self.assertEqual(len(found.unread), 1)
|
||||
self.assertRegex(found.unread[0], r"^log: none of its chunks is measured: .*`commit-title` is 'PAY-\{id\}'")
|
||||
@@ -405,7 +405,7 @@ class Archive(unittest.TestCase):
|
||||
def recording(*args, **options):
|
||||
made.append((args[0], options))
|
||||
return git_repo.git(*args, **options, env=env)
|
||||
archive.measure_archive(self.root, str(home), "", recording)
|
||||
archive.measure_archive(self.root, str(home), {}, "", recording)
|
||||
self.assertTrue(all(options.get("guarded") is True for _, options in made))
|
||||
read = [options.get("timeout") for command, options in made if command in ("log", "ls-tree", "show", "diff", "blame")]
|
||||
self.assertEqual(set(read), {archive.GIT_TIMEOUT})
|
||||
@@ -417,12 +417,12 @@ class Archive(unittest.TestCase):
|
||||
(home / "code" / "log").mkdir(parents=True)
|
||||
subprocess.run(["git", "init", "-q"], cwd=home / "code" / "log", check=True, env=env, capture_output=True)
|
||||
self.chunk("log", "c1", stamped("2026-10-14T10:00:00Z", outcomes.finished(LOW_ROUTE, "m", "j")), [message("m1", "2026-10-14T09:00:00Z")])
|
||||
found = archive.measure_archive(self.root, str(home), "", functools.partial(git_repo.git, env=env))
|
||||
found = archive.measure_archive(self.root, str(home), {}, "", functools.partial(git_repo.git, env=env))
|
||||
self.assertEqual(found.unread, ("log: no origin remote, and no main or master branch to take as the default branch",))
|
||||
|
||||
def test_names_each_project_whose_history_it_cannot_read(self):
|
||||
self.chunk("gone", "c1", stamped("2026-10-14T10:00:00Z", outcomes.finished(LOW_ROUTE, "m", "j")), [message("m1", "2026-10-14T09:00:00Z")])
|
||||
found = archive.measure_archive(self.root, "/h", "", no_checkout)
|
||||
found = archive.measure_archive(self.root, "/h", {}, "", no_checkout)
|
||||
self.assertEqual(([chunk.fixed_later for chunk in found.chunks], found.unread), ([None], ("gone: no checkout",)))
|
||||
|
||||
def ship_then_fix(self, checkout, env, fix_title="Fix six", ships_fix=True):
|
||||
@@ -457,7 +457,7 @@ class Archive(unittest.TestCase):
|
||||
self.assertIsNone(write.archive(kept / "log", str(transcript), "t", outcomes.unfinished(LOW_ROUTE, "e", "j", ""), 1790000000, replace=replace_file))
|
||||
transcript.write_text(json.dumps(first) + "\n" + json.dumps(message("m2", "2099-01-01T00:00:00Z")) + "\n")
|
||||
self.assertIsNone(write.archive(kept / "log", str(transcript), "t", outcomes.finished(Route(HIGH).worker_line(), "m", "j"), 4070908800, replace=replace_file))
|
||||
(found,) = archive.measure_archive(kept, "/h", "", no_checkout).chunks
|
||||
(found,) = archive.measure_archive(kept, "/h", {}, "", no_checkout).chunks
|
||||
self.assertEqual((found.start, found.unfinished), (LOW, 1))
|
||||
self.assertEqual(found.dollars["rung"], {str(LOW): 2.0, str(HIGH): 2.0})
|
||||
|
||||
@@ -467,7 +467,7 @@ class Archive(unittest.TestCase):
|
||||
self.chunk("other", "c2", stamped("2026-10-14T10:00:00Z", outcomes.finished(LOW_ROUTE, "m", "j")), [message("m1", "2026-10-14T09:00:00Z")])
|
||||
self.chunk("broken", "c3", "", [])
|
||||
(self.root / "broken" / "c3" / "copy.outcomes.md").write_bytes(b"\xff")
|
||||
found = archive.measure_archive(self.root, "/h", "", no_checkout)
|
||||
found = archive.measure_archive(self.root, "/h", {}, "", no_checkout)
|
||||
self.assertEqual((len(found.chunks), found.skipped), (1, ("broken", "log/c1")))
|
||||
self.assertIn("## Chunks skipped, unreadable\n\n- log/c1\n", render(LADDER, totals([], ("log/c1",)), [], "2026-10-15T00:00:00Z", 20, ""))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user