From de67ac37293fdf18bfdb9d57b584ef65cb0a88bb Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 20:02:44 -0700 Subject: [PATCH 01/10] fix: align staged temp guard with tracked temp policy --- scripts/check_staged_autoskillit_temp.sh | 15 +- tests/arch/test_temp_tracking_guard.py | 212 +++++++++++++++++++++-- 2 files changed, 202 insertions(+), 25 deletions(-) diff --git a/scripts/check_staged_autoskillit_temp.sh b/scripts/check_staged_autoskillit_temp.sh index f5b50e6db8..6bb3af9106 100755 --- a/scripts/check_staged_autoskillit_temp.sh +++ b/scripts/check_staged_autoskillit_temp.sh @@ -1,14 +1,15 @@ #!/usr/bin/env bash set -euo pipefail -if git diff --cached --name-only -z --diff-filter=ACMRT | +# Git's pathspec engine decides containment, the same predicate as the tracked-temp +# policy. A plain pathspec from the top level stays valid under GIT_LITERAL_PATHSPECS. +top_level="$(git rev-parse --show-toplevel)" +cd "$top_level" + +if git diff --cached --name-only -z --diff-filter=ACMRT --ignore-submodules=none -- .autoskillit/temp | while IFS= read -r -d '' path; do - case "$path" in - .autoskillit/temp/*) - printf 'Refusing to stage AutoSkillit temp artifact: %s\n' "$path" >&2 - exit 1 - ;; - esac + printf 'Refusing to stage AutoSkillit temp artifact: %s\n' "$path" >&2 + exit 1 done then exit 0 diff --git a/tests/arch/test_temp_tracking_guard.py b/tests/arch/test_temp_tracking_guard.py index 61501a1e76..2f9d4c5043 100644 --- a/tests/arch/test_temp_tracking_guard.py +++ b/tests/arch/test_temp_tracking_guard.py @@ -4,20 +4,22 @@ import subprocess from pathlib import Path +from typing import Literal import pytest from tests._git_inventory import git_ls_files -pytestmark = [pytest.mark.layer("arch"), pytest.mark.small] +pytestmark = [pytest.mark.layer("arch"), pytest.mark.medium] _REPO_ROOT = Path(__file__).resolve().parents[2] _TEMP_PATH_ALLOWLIST: dict[str, str] = {} +_TEMP_PATHSPEC = ".autoskillit/temp" _STAGED_TEMP_GUARD = _REPO_ROOT / "scripts" / "check_staged_autoskillit_temp.sh" def test_no_autoskillit_temp_artifacts_are_tracked() -> None: - tracked_paths = git_ls_files(_REPO_ROOT, ".autoskillit/temp", allow_empty=True) + tracked_paths = git_ls_files(_REPO_ROOT, _TEMP_PATHSPEC, allow_empty=True) unexpected = sorted(set(tracked_paths).difference(_TEMP_PATH_ALLOWLIST)) assert not unexpected, ( @@ -46,17 +48,7 @@ def _run_git(repo: Path, *args: str) -> None: ) -@pytest.fixture -def temporary_git_repo(tmp_path: Path) -> Path: - repo = tmp_path / "repo" - repo.mkdir() - _run_git(repo, "init", "--quiet") - - (repo / "source.txt").write_text("source\n", encoding="utf-8") - legacy_temp_artifact = repo / ".autoskillit" / "temp" / "legacy.txt" - legacy_temp_artifact.parent.mkdir(parents=True) - legacy_temp_artifact.write_text("legacy\n", encoding="utf-8") - _run_git(repo, "add", "source.txt", ".autoskillit/temp/legacy.txt") +def _commit(repo: Path, message: str) -> None: _run_git( repo, "-c", @@ -66,21 +58,118 @@ def temporary_git_repo(tmp_path: Path) -> Path: "commit", "--quiet", "-m", - "initial", + message, ) + + +@pytest.fixture +def clean_git_repo(tmp_path: Path, isolated_git_config: None) -> Path: + repo = tmp_path / "repo" + repo.mkdir() + _run_git(repo, "init", "--quiet") + (repo / "source.txt").write_text("source\n", encoding="utf-8") + _run_git(repo, "add", "source.txt") + _commit(repo, "initial") return repo -def _run_staged_temp_guard(repo: Path) -> subprocess.CompletedProcess[str]: +@pytest.fixture +def temporary_git_repo(clean_git_repo: Path) -> Path: + repo = clean_git_repo + legacy_temp_artifact = repo / ".autoskillit" / "temp" / "legacy.txt" + legacy_temp_artifact.parent.mkdir(parents=True) + legacy_temp_artifact.write_text("legacy\n", encoding="utf-8") + _run_git(repo, "add", ".autoskillit/temp/legacy.txt") + _commit(repo, "add legacy temp artifact") + return repo + + +def _stage_entry(repo: Path, relative: str, kind: Literal["file", "symlink"]) -> None: + path = repo / relative + path.parent.mkdir(parents=True, exist_ok=True) + if kind == "file": + path.write_text(f"{relative}\n", encoding="utf-8") + else: + path.symlink_to("link-target") + _run_git(repo, "update-index", "--add", "--", relative) + + +def _run_staged_temp_guard( + repo: Path, *, cwd: Path | None = None +) -> subprocess.CompletedProcess[str]: return subprocess.run( [str(_STAGED_TEMP_GUARD)], - cwd=repo, + cwd=cwd or repo, check=False, capture_output=True, text=True, ) +def _assert_rejected(result: subprocess.CompletedProcess[str], path: str) -> None: + assert result.returncode == 1 + assert result.stderr == f"Refusing to stage AutoSkillit temp artifact: {path}\n" + + +@pytest.mark.parametrize( + ("path", "kind", "expect_reject"), + [ + pytest.param(".autoskillit/temp", "file", True, id="root-file"), + pytest.param(".autoskillit/temp", "symlink", True, id="root-symlink"), + pytest.param(".autoskillit/temp/child.txt", "file", True, id="child-file"), + pytest.param(".autoskillit/temporary/x", "file", False, id="sibling-dir"), + pytest.param(".autoskillit/temp-x", "file", False, id="sibling-name"), + pytest.param("sub/.autoskillit/temp/y", "file", False, id="nested-non-top"), + ], +) +def test_staged_temp_guard_matches_tracked_temp_policy( + clean_git_repo: Path, path: str, kind: Literal["file", "symlink"], expect_reject: bool +) -> None: + _stage_entry(clean_git_repo, path, kind) + policy = git_ls_files(clean_git_repo, _TEMP_PATHSPEC, allow_empty=True) + assert policy == ((path,) if expect_reject else ()) + + result = _run_staged_temp_guard(clean_git_repo) + if expect_reject: + _assert_rejected(result, path) + else: + assert result.returncode == 0, result.stderr + assert result.stderr == "" + + +@pytest.mark.parametrize( + ("change", "expect_reject"), + [pytest.param("modify", True, id="modify"), pytest.param("delete", False, id="delete")], +) +def test_staged_temp_guard_on_committed_temp_root( + clean_git_repo: Path, change: str, expect_reject: bool +) -> None: + _stage_entry(clean_git_repo, _TEMP_PATHSPEC, "symlink") + _commit(clean_git_repo, "commit temp root") + root = clean_git_repo / _TEMP_PATHSPEC + root.unlink() + if change == "modify": + root.symlink_to("other-target") + _run_git(clean_git_repo, "add", "--all") + + result = _run_staged_temp_guard(clean_git_repo) + if expect_reject: + _assert_rejected(result, _TEMP_PATHSPEC) + else: + assert result.returncode == 0, result.stderr + assert result.stderr == "" + + +def test_staged_temp_guard_rejects_temp_child_replaced_by_root(temporary_git_repo: Path) -> None: + root = temporary_git_repo / _TEMP_PATHSPEC + (root / "legacy.txt").unlink() + root.rmdir() + root.write_text("legacy\n", encoding="utf-8") + _run_git(temporary_git_repo, "add", "--all") + + _assert_rejected(_run_staged_temp_guard(temporary_git_repo), _TEMP_PATHSPEC) + + def test_staged_temp_guard_rejects_rename_into_temp(temporary_git_repo: Path) -> None: source = temporary_git_repo / "source.txt" destination = temporary_git_repo / ".autoskillit" / "temp" / "source.txt" @@ -89,8 +178,7 @@ def test_staged_temp_guard_rejects_rename_into_temp(temporary_git_repo: Path) -> result = _run_staged_temp_guard(temporary_git_repo) - assert result.returncode == 1 - assert ".autoskillit/temp/source.txt" in result.stderr + _assert_rejected(result, ".autoskillit/temp/source.txt") def test_staged_temp_guard_permits_deletion(temporary_git_repo: Path) -> None: @@ -100,3 +188,91 @@ def test_staged_temp_guard_permits_deletion(temporary_git_repo: Path) -> None: result = _run_staged_temp_guard(temporary_git_repo) assert result.returncode == 0, result.stderr + + +def test_staged_temp_guard_permits_non_temp_change_beside_tracked_temp( + temporary_git_repo: Path, +) -> None: + (temporary_git_repo / "source.txt").write_text("changed\n", encoding="utf-8") + _run_git(temporary_git_repo, "add", "--all") + + result = _run_staged_temp_guard(temporary_git_repo) + assert result.returncode == 0, result.stderr + assert result.stderr == "" + + +def test_staged_temp_guard_sees_gitlink_hidden_by_submodule_ignore(clean_git_repo: Path) -> None: + _run_git(clean_git_repo, "config", "diff.ignoreSubmodules", "all") + _run_git( + clean_git_repo, + "update-index", + "--add", + "--cacheinfo", + f"160000,{'1' * 40},.autoskillit/temp/module", + ) + + _assert_rejected(_run_staged_temp_guard(clean_git_repo), ".autoskillit/temp/module") + + +def test_staged_temp_guard_is_independent_of_invocation_cwd(clean_git_repo: Path) -> None: + sub = clean_git_repo / "sub" + sub.mkdir() + _stage_entry(clean_git_repo, ".autoskillit/temp/child.txt", "file") + + _assert_rejected( + _run_staged_temp_guard(clean_git_repo, cwd=sub), ".autoskillit/temp/child.txt" + ) + + +def test_staged_temp_guard_honors_relative_alternate_index( + clean_git_repo: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + sub = clean_git_repo / "sub" + sub.mkdir() + _stage_entry(clean_git_repo, ".autoskillit/temp/child.txt", "file") + (clean_git_repo / "alternate-index").write_bytes( + (clean_git_repo / ".git" / "index").read_bytes() + ) + _run_git(clean_git_repo, "reset", "--quiet", "HEAD") + monkeypatch.setenv("GIT_INDEX_FILE", "alternate-index") + + _assert_rejected( + _run_staged_temp_guard(clean_git_repo, cwd=sub), ".autoskillit/temp/child.txt" + ) + + +def test_staged_temp_guard_rejects_root_symlink_in_real_commit(clean_git_repo: Path) -> None: + sub = clean_git_repo / "sub" + sub.mkdir() + _stage_entry(clean_git_repo, _TEMP_PATHSPEC, "symlink") + (clean_git_repo / ".git" / "hooks" / "pre-commit").symlink_to(_STAGED_TEMP_GUARD) + + result = subprocess.run( + [ + "git", + "--literal-pathspecs", + "-c", + "user.name=AutoSkillit Test", + "-c", + "user.email=autoskillit-test@example.invalid", + "commit", + "--quiet", + "-m", + "reject temp root", + ], + cwd=sub, + capture_output=True, + text=True, + check=False, + timeout=30, + ) + _assert_rejected(result, _TEMP_PATHSPEC) + tree = subprocess.run( + ["git", "ls-tree", "--name-only", "HEAD", "--", _TEMP_PATHSPEC], + cwd=clean_git_repo, + capture_output=True, + text=True, + check=True, + timeout=30, + ) + assert tree.stdout == "" From 9b81281b39c039c8005db2566b3526f2ff099d4a Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 22:56:30 -0700 Subject: [PATCH 02/10] docs(review): explain mirrored temp containment policy --- scripts/check_staged_autoskillit_temp.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/check_staged_autoskillit_temp.sh b/scripts/check_staged_autoskillit_temp.sh index 6bb3af9106..9558d301c4 100755 --- a/scripts/check_staged_autoskillit_temp.sh +++ b/scripts/check_staged_autoskillit_temp.sh @@ -1,8 +1,9 @@ #!/usr/bin/env bash set -euo pipefail -# Git's pathspec engine decides containment, the same predicate as the tracked-temp -# policy. A plain pathspec from the top level stays valid under GIT_LITERAL_PATHSPECS. +# This pathspec intentionally mirrors _TEMP_PATHSPEC in test_temp_tracking_guard.py; +# its equivalence test guards their alignment. Keep both literals in sync. +# A plain pathspec from the top level stays valid under GIT_LITERAL_PATHSPECS. top_level="$(git rev-parse --show-toplevel)" cd "$top_level" From 66740a281d9f78fd91112575303509227b565d85 Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 22:57:43 -0700 Subject: [PATCH 03/10] test(review): assert hook refusal without owning Git stderr --- tests/arch/test_temp_tracking_guard.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/arch/test_temp_tracking_guard.py b/tests/arch/test_temp_tracking_guard.py index 2f9d4c5043..f472db3ce5 100644 --- a/tests/arch/test_temp_tracking_guard.py +++ b/tests/arch/test_temp_tracking_guard.py @@ -246,6 +246,9 @@ def test_staged_temp_guard_rejects_root_symlink_in_real_commit(clean_git_repo: P sub.mkdir() _stage_entry(clean_git_repo, _TEMP_PATHSPEC, "symlink") (clean_git_repo / ".git" / "hooks" / "pre-commit").symlink_to(_STAGED_TEMP_GUARD) + head_before = subprocess.check_output( + ["git", "rev-parse", "HEAD"], cwd=clean_git_repo, timeout=30 + ) result = subprocess.run( [ @@ -266,13 +269,9 @@ def test_staged_temp_guard_rejects_root_symlink_in_real_commit(clean_git_repo: P check=False, timeout=30, ) - _assert_rejected(result, _TEMP_PATHSPEC) - tree = subprocess.run( - ["git", "ls-tree", "--name-only", "HEAD", "--", _TEMP_PATHSPEC], - cwd=clean_git_repo, - capture_output=True, - text=True, - check=True, - timeout=30, + assert result.returncode != 0 + assert f"Refusing to stage AutoSkillit temp artifact: {_TEMP_PATHSPEC}\n" in result.stderr + assert ( + subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=clean_git_repo, timeout=30) + == head_before ) - assert tree.stdout == "" From f2dda8c0727ad720c8b8735f5facc06e7691b901 Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 22:58:30 -0700 Subject: [PATCH 04/10] test(review): cover child artifacts under literal pathspecs --- tests/arch/test_temp_tracking_guard.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/arch/test_temp_tracking_guard.py b/tests/arch/test_temp_tracking_guard.py index f472db3ce5..e068f45fa7 100644 --- a/tests/arch/test_temp_tracking_guard.py +++ b/tests/arch/test_temp_tracking_guard.py @@ -241,11 +241,24 @@ def test_staged_temp_guard_honors_relative_alternate_index( ) -def test_staged_temp_guard_rejects_root_symlink_in_real_commit(clean_git_repo: Path) -> None: +@pytest.mark.parametrize( + ("path", "kind"), + [ + pytest.param(_TEMP_PATHSPEC, "symlink", id="root-symlink"), + pytest.param(f"{_TEMP_PATHSPEC}/child.txt", "file", id="child-file"), + ], +) +def test_staged_temp_guard_rejects_temp_in_real_commit( + clean_git_repo: Path, + monkeypatch: pytest.MonkeyPatch, + path: str, + kind: Literal["file", "symlink"], +) -> None: sub = clean_git_repo / "sub" sub.mkdir() - _stage_entry(clean_git_repo, _TEMP_PATHSPEC, "symlink") + _stage_entry(clean_git_repo, path, kind) (clean_git_repo / ".git" / "hooks" / "pre-commit").symlink_to(_STAGED_TEMP_GUARD) + monkeypatch.setenv("GIT_LITERAL_PATHSPECS", "1") head_before = subprocess.check_output( ["git", "rev-parse", "HEAD"], cwd=clean_git_repo, timeout=30 ) @@ -261,7 +274,7 @@ def test_staged_temp_guard_rejects_root_symlink_in_real_commit(clean_git_repo: P "commit", "--quiet", "-m", - "reject temp root", + "reject temp artifact", ], cwd=sub, capture_output=True, @@ -270,7 +283,7 @@ def test_staged_temp_guard_rejects_root_symlink_in_real_commit(clean_git_repo: P timeout=30, ) assert result.returncode != 0 - assert f"Refusing to stage AutoSkillit temp artifact: {_TEMP_PATHSPEC}\n" in result.stderr + assert f"Refusing to stage AutoSkillit temp artifact: {path}\n" in result.stderr assert ( subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=clean_git_repo, timeout=30) == head_before From f20e58926100aec82779575fe18ec49843db7858 Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 22:59:09 -0700 Subject: [PATCH 05/10] test(review): make relative index resolution explicit --- tests/arch/test_temp_tracking_guard.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/arch/test_temp_tracking_guard.py b/tests/arch/test_temp_tracking_guard.py index e068f45fa7..63f1165aae 100644 --- a/tests/arch/test_temp_tracking_guard.py +++ b/tests/arch/test_temp_tracking_guard.py @@ -224,7 +224,7 @@ def test_staged_temp_guard_is_independent_of_invocation_cwd(clean_git_repo: Path ) -def test_staged_temp_guard_honors_relative_alternate_index( +def test_staged_temp_guard_resolves_relative_alternate_index_from_repo_root( clean_git_repo: Path, monkeypatch: pytest.MonkeyPatch ) -> None: sub = clean_git_repo / "sub" @@ -235,6 +235,14 @@ def test_staged_temp_guard_honors_relative_alternate_index( ) _run_git(clean_git_repo, "reset", "--quiet", "HEAD") monkeypatch.setenv("GIT_INDEX_FILE", "alternate-index") + # Pre-commit hooks start at the repository root; direct invocations normalize there. + staged = subprocess.check_output( + ["git", "diff", "--cached", "--name-only"], + cwd=clean_git_repo, + text=True, + timeout=30, + ) + assert staged.splitlines() == [".autoskillit/temp/child.txt"] _assert_rejected( _run_staged_temp_guard(clean_git_repo, cwd=sub), ".autoskillit/temp/child.txt" From ca280794d1c950956246ef0d66dd63ad979315de Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 22:59:42 -0700 Subject: [PATCH 06/10] test(review): use an existing commit for the gitlink fixture --- tests/arch/test_temp_tracking_guard.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/arch/test_temp_tracking_guard.py b/tests/arch/test_temp_tracking_guard.py index 63f1165aae..f05c1e14c4 100644 --- a/tests/arch/test_temp_tracking_guard.py +++ b/tests/arch/test_temp_tracking_guard.py @@ -203,12 +203,15 @@ def test_staged_temp_guard_permits_non_temp_change_beside_tracked_temp( def test_staged_temp_guard_sees_gitlink_hidden_by_submodule_ignore(clean_git_repo: Path) -> None: _run_git(clean_git_repo, "config", "diff.ignoreSubmodules", "all") + commit_sha = subprocess.check_output( + ["git", "rev-parse", "HEAD"], cwd=clean_git_repo, text=True, timeout=30 + ).strip() _run_git( clean_git_repo, "update-index", "--add", "--cacheinfo", - f"160000,{'1' * 40},.autoskillit/temp/module", + f"160000,{commit_sha},.autoskillit/temp/module", ) _assert_rejected(_run_staged_temp_guard(clean_git_repo), ".autoskillit/temp/module") From bf6c2ad6aee8fb42e50eb362cb88855bcef77c4c Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 23:00:16 -0700 Subject: [PATCH 07/10] test(review): permit nested temp paths from a subdirectory --- tests/arch/test_temp_tracking_guard.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/arch/test_temp_tracking_guard.py b/tests/arch/test_temp_tracking_guard.py index f05c1e14c4..9052674fd5 100644 --- a/tests/arch/test_temp_tracking_guard.py +++ b/tests/arch/test_temp_tracking_guard.py @@ -217,14 +217,26 @@ def test_staged_temp_guard_sees_gitlink_hidden_by_submodule_ignore(clean_git_rep _assert_rejected(_run_staged_temp_guard(clean_git_repo), ".autoskillit/temp/module") -def test_staged_temp_guard_is_independent_of_invocation_cwd(clean_git_repo: Path) -> None: +@pytest.mark.parametrize( + ("path", "expect_reject"), + [ + pytest.param(".autoskillit/temp/child.txt", True, id="top-level"), + pytest.param("sub/.autoskillit/temp/y", False, id="nested"), + ], +) +def test_staged_temp_guard_is_independent_of_invocation_cwd( + clean_git_repo: Path, path: str, expect_reject: bool +) -> None: sub = clean_git_repo / "sub" sub.mkdir() - _stage_entry(clean_git_repo, ".autoskillit/temp/child.txt", "file") + _stage_entry(clean_git_repo, path, "file") - _assert_rejected( - _run_staged_temp_guard(clean_git_repo, cwd=sub), ".autoskillit/temp/child.txt" - ) + result = _run_staged_temp_guard(clean_git_repo, cwd=sub) + if expect_reject: + _assert_rejected(result, path) + else: + assert result.returncode == 0, result.stderr + assert result.stderr == "" def test_staged_temp_guard_resolves_relative_alternate_index_from_repo_root( From 3d361a1ea3d5a6061589d31747235b54652a5533 Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 23:00:53 -0700 Subject: [PATCH 08/10] test(review): type the closed root-change parameter --- tests/arch/test_temp_tracking_guard.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/arch/test_temp_tracking_guard.py b/tests/arch/test_temp_tracking_guard.py index 9052674fd5..f014fb8fc7 100644 --- a/tests/arch/test_temp_tracking_guard.py +++ b/tests/arch/test_temp_tracking_guard.py @@ -142,7 +142,7 @@ def test_staged_temp_guard_matches_tracked_temp_policy( [pytest.param("modify", True, id="modify"), pytest.param("delete", False, id="delete")], ) def test_staged_temp_guard_on_committed_temp_root( - clean_git_repo: Path, change: str, expect_reject: bool + clean_git_repo: Path, change: Literal["modify", "delete"], expect_reject: bool ) -> None: _stage_entry(clean_git_repo, _TEMP_PATHSPEC, "symlink") _commit(clean_git_repo, "commit temp root") From 1c773d5e32910db1a5854773547ddaa68e0df92f Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 23:01:26 -0700 Subject: [PATCH 09/10] test(review): share complete permit-path assertions --- tests/arch/test_temp_tracking_guard.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/arch/test_temp_tracking_guard.py b/tests/arch/test_temp_tracking_guard.py index f014fb8fc7..6af188a746 100644 --- a/tests/arch/test_temp_tracking_guard.py +++ b/tests/arch/test_temp_tracking_guard.py @@ -111,6 +111,11 @@ def _assert_rejected(result: subprocess.CompletedProcess[str], path: str) -> Non assert result.stderr == f"Refusing to stage AutoSkillit temp artifact: {path}\n" +def _assert_permitted(result: subprocess.CompletedProcess[str]) -> None: + assert result.returncode == 0, result.stderr + assert result.stderr == "" + + @pytest.mark.parametrize( ("path", "kind", "expect_reject"), [ @@ -133,8 +138,7 @@ def test_staged_temp_guard_matches_tracked_temp_policy( if expect_reject: _assert_rejected(result, path) else: - assert result.returncode == 0, result.stderr - assert result.stderr == "" + _assert_permitted(result) @pytest.mark.parametrize( @@ -156,8 +160,7 @@ def test_staged_temp_guard_on_committed_temp_root( if expect_reject: _assert_rejected(result, _TEMP_PATHSPEC) else: - assert result.returncode == 0, result.stderr - assert result.stderr == "" + _assert_permitted(result) def test_staged_temp_guard_rejects_temp_child_replaced_by_root(temporary_git_repo: Path) -> None: @@ -187,7 +190,7 @@ def test_staged_temp_guard_permits_deletion(temporary_git_repo: Path) -> None: result = _run_staged_temp_guard(temporary_git_repo) - assert result.returncode == 0, result.stderr + _assert_permitted(result) def test_staged_temp_guard_permits_non_temp_change_beside_tracked_temp( @@ -197,8 +200,7 @@ def test_staged_temp_guard_permits_non_temp_change_beside_tracked_temp( _run_git(temporary_git_repo, "add", "--all") result = _run_staged_temp_guard(temporary_git_repo) - assert result.returncode == 0, result.stderr - assert result.stderr == "" + _assert_permitted(result) def test_staged_temp_guard_sees_gitlink_hidden_by_submodule_ignore(clean_git_repo: Path) -> None: @@ -235,8 +237,7 @@ def test_staged_temp_guard_is_independent_of_invocation_cwd( if expect_reject: _assert_rejected(result, path) else: - assert result.returncode == 0, result.stderr - assert result.stderr == "" + _assert_permitted(result) def test_staged_temp_guard_resolves_relative_alternate_index_from_repo_root( From 93a160a87e54355ba4e4e1eadaac99c946aeac4f Mon Sep 17 00:00:00 2001 From: Trecek Date: Fri, 23 Oct 2026 23:02:00 -0700 Subject: [PATCH 10/10] test(review): remove the temporary repo fixture alias --- tests/arch/test_temp_tracking_guard.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/arch/test_temp_tracking_guard.py b/tests/arch/test_temp_tracking_guard.py index 6af188a746..8f19836e8c 100644 --- a/tests/arch/test_temp_tracking_guard.py +++ b/tests/arch/test_temp_tracking_guard.py @@ -75,13 +75,12 @@ def clean_git_repo(tmp_path: Path, isolated_git_config: None) -> Path: @pytest.fixture def temporary_git_repo(clean_git_repo: Path) -> Path: - repo = clean_git_repo - legacy_temp_artifact = repo / ".autoskillit" / "temp" / "legacy.txt" + legacy_temp_artifact = clean_git_repo / ".autoskillit" / "temp" / "legacy.txt" legacy_temp_artifact.parent.mkdir(parents=True) legacy_temp_artifact.write_text("legacy\n", encoding="utf-8") - _run_git(repo, "add", ".autoskillit/temp/legacy.txt") - _commit(repo, "add legacy temp artifact") - return repo + _run_git(clean_git_repo, "add", ".autoskillit/temp/legacy.txt") + _commit(clean_git_repo, "add legacy temp artifact") + return clean_git_repo def _stage_entry(repo: Path, relative: str, kind: Literal["file", "symlink"]) -> None: