Answer principles round 1: 2 🔴, 9 🟡 (0 misread); explicit record versions in place of the Confluence store's hidden state, the routing ruling filed as item 393 for 0.12.0, rule-hook catching heavy runs through uv, poetry, sudo and doas, one unreleased heading, one owner of the no-item message, typed Jira issues, a turn that gives its failure as a value, outcome tests for the Atlassian client, an Emptied reason type, an injected clock and git in touch-predictions, and paired record names

This commit is contained in:
2026-11-16 16:12:36 +01:00
parent a60bfdbc1c
commit ba21a1efcd
41 changed files with 406 additions and 280 deletions
+9 -8
View File
@@ -44,8 +44,9 @@ cannot be read; or when git cannot name the merge base or the diff.
"""
import sys
import time
import typing
from git_cli.git_repo import default_ref, git
from git_cli.git_repo import default_ref, git, Git
from failure import Failure
from plan_store.stores import store as plan_store
from touch_predictions.prediction import predicted, together, Touches
@@ -73,8 +74,8 @@ def main(argv: list[str]) -> int:
return 0
def recorded(config: ProjectConfig, ids: list[int]) -> str | Failure:
"""Appends the entry of the chunk that takes the items ids, and says so; or says that the project keeps no record."""
def recorded(config: ProjectConfig, ids: list[int], now: typing.Callable[[], float] = time.time, run: Git = 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:
return f"The project's config sets no `{TOUCH_PREDICTIONS}`, so nothing is recorded."
@@ -82,17 +83,17 @@ def recorded(config: ProjectConfig, ids: list[int]) -> str | Failure:
if isinstance(prediction, Failure):
return prediction
cwd = str(config.top)
default = default_ref(cwd)
base = default if isinstance(default, Failure) else git("merge-base", default, "HEAD", cwd=cwd)
head = base if isinstance(base, Failure) else git("rev-parse", "--short", "HEAD", cwd=cwd)
default = default_ref(cwd, run=run)
base = default if isinstance(default, Failure) else run("merge-base", default, "HEAD", cwd=cwd)
head = base if isinstance(base, Failure) else run("rev-parse", "--short", "HEAD", cwd=cwd)
if isinstance(base, Failure) or isinstance(head, Failure):
return head if isinstance(head, Failure) else base
# Every chunk writes the plan and the records, so they are left out of what a chunk touched.
skipped = {path for name in ("plan", *RECORDS, TOUCH_PREDICTIONS) if (path := config.tracked(name))}
touches = touched(base.strip(), "HEAD", cwd, skipped)
touches = touched(base.strip(), "HEAD", cwd, skipped, run)
if isinstance(touches, Failure):
return touches
failed = record.append(store, ids, record.entry(ids, utc(time.time()), head.strip(), prediction, touches))
failed = record.append(store, ids, record.entry(ids, utc(now()), head.strip(), prediction, touches))
return failed or f"Recorded what chunk {', '.join(map(str, ids))} was predicted to touch, and what it touched, in {store.label}."
+4 -3
View File
@@ -20,8 +20,9 @@ def listed(label: str, touches: Touches | None) -> str:
def append(store: RecordStore, items: list[int], text: str) -> Failure | None:
"""Appends text, the entry of the chunk that took items, in place of each entry the record holds for the same items: a fix after the first entry changes what the chunk touched."""
held = store.read()
held = store.held()
if isinstance(held, Failure):
return held
kept = re.sub(rf"^## Chunk {', '.join(map(str, items))}, {STAMPED},.*?(?=^## |\Z)", "", held, flags=re.M | re.S)
return store.write(f"{kept.rstrip() or TITLE}\n\n{text}")
kept = re.sub(rf"^## Chunk {', '.join(map(str, items))}, {STAMPED},.*?(?=^## |\Z)", "", held.text, flags=re.M | re.S)
written = store.write(f"{kept.rstrip() or TITLE}\n\n{text}", held.version)
return written if isinstance(written, Failure) else None
@@ -9,12 +9,14 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from touch_predictions.beside import Beside, chunks_beside
from touch_predictions import diff_parts, file_parts, record
from touch_predictions import diff_parts, file_parts, main, record
from failure import Failure
from test_env import isolated_env
from project_config.main import located
from record_store.fakes import MemoryStore
from touch_predictions.prediction import overlaps, Part, predicted, rendered, together
from plan_store.todo_md import plan_of
from project_config.settings import ProjectConfig
from project_config.test_project_config import write_config
DETAIL = """A planning call.
@@ -451,6 +453,13 @@ class RecordCommandTest(unittest.TestCase):
assert entry is not None
self.assertEqual(entry.group(1), "Predicted:\n\n- `app.py`: `run`\n\nTouched:\n\n- `app.py`: `run`, `stop`\n")
def test_stamps_the_entry_at_the_clock_it_is_handed(self) -> None:
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.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:
path = self.set_record()
self.record("record", "3")