Answer stability round 1: 0 🔴, 4 🟡 (0 misread); a cycle's close takes the task from the cycle, a resolved thread is skipped unread, and tests run git in their own environment
CI / tests (pull_request) Successful in 3m56s
CI / tests (pull_request) Successful in 3m56s
This commit is contained in:
@@ -6,7 +6,7 @@ import shutil
|
||||
from review_rules.comprehension_history import DIMENSIONS
|
||||
from failure import Failure
|
||||
from text_files.markdown_text import FENCE, listed, section
|
||||
from git_cli.git_repo import git
|
||||
from git_cli.git_repo import git, Git
|
||||
from project_config.main import located
|
||||
from review_rules.review_folder import made_review_folder, review_folder
|
||||
from project_config.settings import ProjectConfig
|
||||
@@ -127,14 +127,14 @@ def scoring_folder(worktree: str, home: pathlib.Path) -> pathlib.Path:
|
||||
return pathlib.Path(review_folder(str(home), worktree)) / "scoring"
|
||||
|
||||
|
||||
def prepare_scoring(worktree: str, home: pathlib.Path) -> str | Failure:
|
||||
def prepare_scoring(worktree: str, home: pathlib.Path, run: Git = git) -> str | Failure:
|
||||
"""Makes the scoring run's worktree at worktree's HEAD and writes each seat's prompt beside it, in the chunk's review folder; what it made, as the tool prints it."""
|
||||
folder = scoring_folder(worktree, home)
|
||||
# A setup record-scoring never removed, as where the seats failed, would otherwise block every later run.
|
||||
replaced = folder.exists()
|
||||
if replaced and isinstance(removed := removed_setup(worktree, home), Failure):
|
||||
if replaced and isinstance(removed := removed_setup(worktree, home, run), Failure):
|
||||
return removed
|
||||
config = located(worktree, home)
|
||||
config = located(worktree, home, run)
|
||||
if isinstance(config, Failure):
|
||||
return config
|
||||
# Where AGENTS.md is missing, this repo keeps the values in seat-prompts.md: .claude/rules/this-repo-keeps-no-agents-md.md.
|
||||
@@ -156,9 +156,9 @@ def prepare_scoring(worktree: str, home: pathlib.Path) -> str | Failure:
|
||||
score = score_bullets(skill)
|
||||
if isinstance(score, Failure):
|
||||
return score
|
||||
listing = git("worktree", "list", "--porcelain", cwd=worktree)
|
||||
branch = git("symbolic-ref", "--short", "-q", "HEAD", cwd=worktree)
|
||||
head = git("rev-parse", "--short", "HEAD", cwd=worktree)
|
||||
listing = run("worktree", "list", "--porcelain", cwd=worktree)
|
||||
branch = run("symbolic-ref", "--short", "-q", "HEAD", cwd=worktree)
|
||||
head = run("rev-parse", "--short", "HEAD", cwd=worktree)
|
||||
if isinstance(listing, Failure):
|
||||
return listing
|
||||
if isinstance(head, Failure):
|
||||
@@ -169,8 +169,8 @@ def prepare_scoring(worktree: str, home: pathlib.Path) -> str | Failure:
|
||||
return made
|
||||
checkout = folder / "checkout"
|
||||
# The seats score the chunk's head, which holds origin's default branch since larv-review §4 step 1, as larv-review → "Scoring run" says.
|
||||
added = git("worktree", "add", "--quiet", "--detach", str(checkout), "HEAD", cwd=worktree)
|
||||
tracked = added if isinstance(added, Failure) else git("ls-files", cwd=str(checkout))
|
||||
added = run("worktree", "add", "--quiet", "--detach", str(checkout), "HEAD", cwd=worktree)
|
||||
tracked = added if isinstance(added, Failure) else run("ls-files", cwd=str(checkout))
|
||||
if isinstance(tracked, Failure):
|
||||
shutil.rmtree(folder, ignore_errors=True)
|
||||
return tracked
|
||||
@@ -200,12 +200,12 @@ def prepare_scoring(worktree: str, home: pathlib.Path) -> str | Failure:
|
||||
return before + f"Scoring worktree, at {head.strip()}: {checkout}\nPrompts, each for one {SEAT_AGENT} agent:\n" + "\n".join(written)
|
||||
|
||||
|
||||
def removed_setup(worktree: str, home: pathlib.Path) -> Failure | None:
|
||||
def removed_setup(worktree: str, home: pathlib.Path, run: Git = git) -> Failure | None:
|
||||
"""Removes the scoring worktree and prompts prepare_scoring made for the chunk at worktree, where they exist."""
|
||||
folder = scoring_folder(worktree, home)
|
||||
if not folder.exists():
|
||||
return None
|
||||
if (folder / "checkout").exists() and isinstance(removed := git("worktree", "remove", "--force", str(folder / "checkout"), cwd=worktree), Failure):
|
||||
if (folder / "checkout").exists() and isinstance(removed := run("worktree", "remove", "--force", str(folder / "checkout"), cwd=worktree), Failure):
|
||||
return Failure(f"could not remove the scoring worktree {folder / 'checkout'}: {removed.reason}")
|
||||
shutil.rmtree(folder, ignore_errors=True)
|
||||
return None
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import functools
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
@@ -10,6 +11,7 @@ sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from larv_review.scoring_setup import bullets, file_globs, prepare_scoring, project_values, removed_setup, score_bullets
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import git
|
||||
from test_env import isolated_env
|
||||
from project_config.doubles import write_config
|
||||
|
||||
@@ -102,7 +104,7 @@ class PrepareScoring(unittest.TestCase):
|
||||
|
||||
def prepare(self):
|
||||
"""What prepare-scoring returns in the checkout, run in this process so mutation tests see the lines it runs."""
|
||||
return prepare_scoring(str(self.checkout), self.root)
|
||||
return prepare_scoring(str(self.checkout), self.root, functools.partial(git, env=self.env))
|
||||
|
||||
def run_tool(self, *args):
|
||||
return subprocess.run([sys.executable, str(TOOL), *args], capture_output=True, cwd=self.checkout, env=self.env, text=True)
|
||||
@@ -137,7 +139,7 @@ class PrepareScoring(unittest.TestCase):
|
||||
self.commit()
|
||||
checkout = self.root / ".local" / "state" / "larv-review" / "proj" / "scoring" / "checkout"
|
||||
checkout.mkdir(parents=True)
|
||||
removed = removed_setup(str(self.checkout), self.root)
|
||||
removed = removed_setup(str(self.checkout), self.root, functools.partial(git, env=self.env))
|
||||
self.assertIsInstance(removed, Failure)
|
||||
self.assertTrue(removed.reason.startswith(f"could not remove the scoring worktree {checkout}: "), removed.reason)
|
||||
self.assertTrue(checkout.exists())
|
||||
|
||||
Reference in New Issue
Block a user