Answer principles round 1: 1 🔴, 7 🟡 (0 misread); every effect is handed in as an argument, no test patches a global, and the traces principle scopes tools that run on their user's machine
CI / tests (pull_request) Successful in 3m43s

This commit is contained in:
2026-11-19 12:42:03 +01:00
parent 8ca612b7a4
commit cb3135bc8c
124 changed files with 1437 additions and 793 deletions
+8 -3
View File
@@ -3,10 +3,15 @@ from failure import Failure
from plan_store.todo_md import plan_of
def plan(*items: tuple[int, str, str, str]) -> list:
"""A plan's items, each given as its ID, release, the IDs that block it and the bullets of its prediction, none for an item without one."""
def todo(*items: tuple[int, str, str, str]) -> str:
"""A todo.md's text for items, each given as its ID, release, the IDs that block it and the bullets of its prediction, none for an item without one."""
rows = "".join(f"| {id_} | {release} | {blocked} | | **Do {id_}.** | 1 | 1 | 1 | 1 | 1 | 1 by 1 | 10.0 |\n" for id_, release, blocked, _ in items)
details = "".join(f"### {id_}. Do {id_}.\n\nTouches:\n\n{bullets}\n\n" for id_, _, _, bullets in items if bullets)
found = plan_of(f"# todo\n\n## Scoring\n\n`Score = 100 * V / (2**S + 8)`\n\n`Bar = 0.1`\n\n`Next ID = 99`\n\n## Items\n\n| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |\n|---|---|---|---|---|---|---|---|---|---|---|---|\n{rows}\n## Details\n\n{details}")
return f"# todo\n\n## Scoring\n\n`Score = 100 * V / (2**S + 8)`\n\n`Bar = 0.1`\n\n`Next ID = 99`\n\n## Items\n\n| ID | Release | Blocked by | Exempt | Item | L | E | I | R | S | Moves | Score |\n|---|---|---|---|---|---|---|---|---|---|---|---|\n{rows}\n## Details\n\n{details}"
def plan(*items: tuple[int, str, str, str]) -> list:
"""The items of the plan that todo writes for items."""
found = plan_of(todo(*items))
assert not isinstance(found, Failure), found
return found.items
+2 -2
View File
@@ -66,7 +66,7 @@ def main(argv: list[str]) -> int:
print("usage: touch-predictions record <ID>...", file=sys.stderr)
return 1
config = project()
done = config if isinstance(config, Failure) else recorded(config, sorted({int(id_) for id_ in argv[1:]}))
done = config if isinstance(config, Failure) else recorded(config, sorted({int(id_) for id_ in argv[1:]}), time.time, git)
if isinstance(done, Failure):
print(f"touch-predictions: {done.reason}", file=sys.stderr)
return 1
@@ -74,7 +74,7 @@ def main(argv: list[str]) -> int:
return 0
def recorded(config: ProjectConfig, ids: list[int], now: typing.Callable[[], float] = time.time, run: Git = git) -> str | Failure:
def recorded(config: ProjectConfig, ids: list[int], now: typing.Callable[[], float], run: Git) -> str | Failure:
"""Appends the entry of the chunk that takes the items ids, stamped at now and read from the commits run shows, and says so; or says that the project keeps no record."""
store = touch_predictions_store(config)
if store is None:
@@ -343,7 +343,7 @@ class RecordCommandTest(unittest.TestCase):
path = self.set_record()
config = located(str(self.checkout), self.home)
assert isinstance(config, ProjectConfig), config
self.assertNotIsInstance(main.recorded(config, [3], now=lambda: 0.0), Failure)
self.assertNotIsInstance(main.recorded(config, [3], lambda: 0.0, main.git), Failure)
self.assertIn("## Chunk 3, 1970-01-01T00:00:00Z, at ", path.read_text(encoding="utf-8"))
def test_a_second_run_replaces_the_entry_and_leaves_the_record_out_of_what_was_touched(self) -> None: