diff --git a/core/skills/implement/SKILL.md b/core/skills/implement/SKILL.md index dd96eaac..45b983de 100644 --- a/core/skills/implement/SKILL.md +++ b/core/skills/implement/SKILL.md @@ -64,8 +64,8 @@ Before the check and draft push for primary review, rebase your own commits onto `[repo].base` (default `main`). For a stack, follow [stacked delivery](../../../docs/DELEGATION.md#stacked-delivery). Leave base merges out of a branch awaiting its delta. -After an approved primary or a delta, merge `origin/` into the existing -branch when the base or its check scripts change. +For base or check-script changes after review, follow the +[Review budget](../../CONTRACT.md#review-budget). Preserve the primary for the delta and the delta for post-review fixes. Split the PR if resolving conflicts requires rewriting its reviewed history. diff --git a/hatch_build.py b/hatch_build.py index 7e8e8be3..bbb922ff 100644 --- a/hatch_build.py +++ b/hatch_build.py @@ -13,7 +13,7 @@ def initialize(self, version, build_data): if not (root / ".git").exists(): return - tracked = subprocess.check_output(["git", "ls-files", "-z"], cwd=root) + tracked = subprocess.check_output(["git", "ls-files", "-z"], cwd=root, timeout=60) self.build_config.set_exclude_all() build_data["force_include"].update( (name, name) diff --git a/scripts/check_architecture_docs.py b/scripts/check_architecture_docs.py index 6d78847d..56c82ca8 100644 --- a/scripts/check_architecture_docs.py +++ b/scripts/check_architecture_docs.py @@ -24,7 +24,7 @@ def git(root, *args, text=True): return subprocess.run(["git", *args], cwd=root, check=True, - capture_output=True, text=text).stdout + capture_output=True, text=text, timeout=60).stdout def interface(text, names): @@ -115,7 +115,7 @@ def main(): else: base = args.base or git(root, "merge-base", "HEAD", "origin/main").strip() errors = check(root, base) - except (OSError, ValueError, SyntaxError, subprocess.CalledProcessError) as exc: + except (OSError, ValueError, SyntaxError, subprocess.SubprocessError) as exc: print(f"architecture docs: FAIL ({exc})", file=sys.stderr) return 1 if errors: diff --git a/src/loopzero/worktree.py b/src/loopzero/worktree.py index 444c8d5e..755f8e79 100644 --- a/src/loopzero/worktree.py +++ b/src/loopzero/worktree.py @@ -244,7 +244,7 @@ def task_text(wt: Path) -> str: "or recreate the file using the handoff template at " "https://github.com/feder-positronics/loop-zero/blob/main/core/HANDOFF.md" ) - return task.read_text() + return task.read_text(encoding="utf-8") def base_sha(wt: Path) -> str: diff --git a/tests/test_architecture_docs.py b/tests/test_architecture_docs.py index 25410cee..4dcda4e4 100644 --- a/tests/test_architecture_docs.py +++ b/tests/test_architecture_docs.py @@ -1,8 +1,10 @@ """Exercise the documentation check as a contributor/CI subprocess in real Git.""" import os +import runpy import subprocess import sys from pathlib import Path +from types import SimpleNamespace import pytest @@ -99,6 +101,26 @@ def test_missing_base_fails_closed(git_repo): assert run(git_repo, "not-a-revision").returncode == 1 +@pytest.mark.parametrize("entry", ["architecture", "sdist"]) +def test_direct_git_timeout(tmp_path, monkeypatch, capsys, entry): + def stalled_git(argv, *, timeout, **kwargs): + assert timeout == 60 + raise subprocess.TimeoutExpired(argv, timeout) + + monkeypatch.setattr(subprocess, "run", stalled_git) + if entry == "architecture": + monkeypatch.setattr(sys, "argv", [str(SCRIPT), "--links-only"]) + assert runpy.run_path(str(SCRIPT))["main"]() == 1 + assert "timed out" in capsys.readouterr().err + else: + monkeypatch.setitem(sys.modules, "hatchling.builders.hooks.plugin.interface", + SimpleNamespace(BuildHookInterface=object)) + hook = runpy.run_path(str(SCRIPT.parents[1] / "hatch_build.py"))["TrackedSdistFiles"] + (tmp_path / ".git").mkdir() + with pytest.raises(subprocess.TimeoutExpired): + hook.initialize(SimpleNamespace(root=tmp_path), "", {}) + + def test_tach_enforces_module_boundaries(tmp_path): import shutil diff --git a/tests/test_cli.py b/tests/test_cli.py index dd28cf13..b6a9d127 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1049,12 +1049,12 @@ def test_pr_replaces_closed_never_merged_pr(wt: Path, gh: FakeGh, capsys) -> Non assert run(capsys, "pr") == (0, URL + "\n", "") -def test_pr_title_prefers_human_heading(wt: Path, gh: FakeGh, capsys) -> None: - task = wt / ".loopzero" / "task.md" - task.write_text("## Objective\nx\n\n# Add the feature flag\n") - assert cli._pr_title(wt, "lz/t1") == "Add the feature flag" - task.write_text("## Objective\nonly sections\n") - assert cli._pr_title(wt, "lz/t1") == "lz/t1" +@pytest.mark.parametrize(("heading", "expected"), [("", "lz/t1"), ("\n# Zażółć gęślą jaźń\n", "Zażółć gęślą jaźń")]) +def test_pr_title_prefers_human_heading(wt: Path, monkeypatch, heading, expected) -> None: + task, read_text = wt / ".loopzero" / "task.md", Path.read_text + monkeypatch.setattr(Path, "read_text", lambda path, encoding="ascii", **kw: read_text(path, encoding, **kw)) + task.write_text(f"## Objective\nZażółć gęślą jaźń\n{heading}", encoding="utf-8") + assert cli._pr_title(wt, "lz/t1") == expected @pytest.mark.parametrize("name,value", [