This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v3-4-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-4-test by this push:
     new 302a919db0f [v3-4-test] Remove CLAUDE.md symlinks now that Claude Code 
reads AGENTS.md (#77634) (#77636)
302a919db0f is described below

commit 302a919db0f1a73161e16f31306dd85fb104ba58
Author: Jarek Potiuk <[email protected]>
AuthorDate: Thu Nov 26 15:29:28 2026 +0100

    [v3-4-test] Remove CLAUDE.md symlinks now that Claude Code reads AGENTS.md 
(#77634) (#77636)
    
    (cherry picked from commit ef27e7cd4896e56943b16aed2c75d8df374fc04c)
    
    The only conflict was dev/skill-evals/last-eval-hash.txt: v3-4-test has a
    different AGENTS.md, so the skill eval was re-run on the backported
    content and its recorded hash is used here.
    
    Generated-by: Claude Opus 5
---
 .../pr-management-code-review-criteria.md          |   2 +-
 .apache-magpie-overrides/project.md                |   2 +-
 .../setup-isolated-setup-install.md                |   2 +-
 .gitattributes                                     |   1 -
 .pre-commit-config.yaml                            |   4 +-
 AGENTS.md                                          |   1 +
 CLAUDE.md                                          |   1 -
 dev/skill-evals/README.md                          |  63 ++++++++--
 dev/skill-evals/eval.py                            | 139 ++++++++++-----------
 dev/skill-evals/last-eval-hash.txt                 |   2 +-
 registry/CLAUDE.md                                 |   1 -
 scripts/tests/ci/prek/test_skill_eval.py           | 114 +++++++++++++++++
 12 files changed, 242 insertions(+), 90 deletions(-)

diff --git a/.apache-magpie-overrides/pr-management-code-review-criteria.md 
b/.apache-magpie-overrides/pr-management-code-review-criteria.md
index 419c7b8dc7c..719de613bf6 100644
--- a/.apache-magpie-overrides/pr-management-code-review-criteria.md
+++ b/.apache-magpie-overrides/pr-management-code-review-criteria.md
@@ -28,7 +28,7 @@ source files themselves; this file only points at them.
 | File | What it covers |
 |---|---|
 | `.github/instructions/code-review.instructions.md` | The review checklist 
every Airflow PR is checked against |
-| `AGENTS.md` (`CLAUDE.md` is a symlink to it) | Architecture boundaries, 
security model, coding standards, testing standards, commit/PR conventions, 
newsfragment rules |
+| `AGENTS.md` | Architecture boundaries, security model, coding standards, 
testing standards, commit/PR conventions, newsfragment rules |
 | `contributing-docs/05_pull_requests.rst` | PR conventions incl. Gen-AI 
disclosure |
 
 ## Per-area source files
diff --git a/.apache-magpie-overrides/project.md 
b/.apache-magpie-overrides/project.md
index 4dc97839833..c0dcbe83176 100644
--- a/.apache-magpie-overrides/project.md
+++ b/.apache-magpie-overrides/project.md
@@ -49,7 +49,7 @@ defaults, or asks.
 | `upstream_repo` | `apache/airflow` | The public codebase — this repository |
 | `upstream_repo_url` | `https://github.com/apache/airflow` | |
 | `upstream_default_branch` | `main` | What `<default-branch>` resolves to |
-| `upstream_agents_md_url` | 
`https://github.com/apache/airflow/blob/main/AGENTS.md` | Contribution 
conventions every agent follows. `CLAUDE.md` is a symlink to it |
+| `upstream_agents_md_url` | 
`https://github.com/apache/airflow/blob/main/AGENTS.md` | Contribution 
conventions every agent follows |
 | `upstream_contributing_docs_url` | 
`https://github.com/apache/airflow/tree/main/contributing-docs` | |
 | `upstream_genai_disclosure_anchor` | 
`https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions`
 | Required in the body of any AI-assisted PR |
 | `upstream_security_policy_url` | 
`https://github.com/apache/airflow/security/policy` | |
diff --git a/.apache-magpie-overrides/setup-isolated-setup-install.md 
b/.apache-magpie-overrides/setup-isolated-setup-install.md
index b890c94c252..138cd23c0ab 100644
--- a/.apache-magpie-overrides/setup-isolated-setup-install.md
+++ b/.apache-magpie-overrides/setup-isolated-setup-install.md
@@ -59,7 +59,7 @@ Bash(docker info *)
 
 `breeze` is the mandated entrypoint for all local development in Apache
 Airflow — the contributor instructions forbid running `pytest` / `python` /
-`airflow` directly on the host (see this repo's `AGENTS.md` / `CLAUDE.md`).
+`airflow` directly on the host (see this repo's `AGENTS.md`).
 Without these allows, every breeze invocation prompts for Bash permission,
 which is pure friction for a command contributors run constantly.
 
diff --git a/.gitattributes b/.gitattributes
index 326d417741c..427db76be6f 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -21,7 +21,6 @@ AGENTS.md export-ignore
 agents.md export-ignore
 .agents export-ignore
 SKILLS.md export-ignore
-CLAUDE.md export-ignore
 .claude export-ignore
 
 .asf.yaml export-ignore
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ec4bef1e678..ad7ea7ba526 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1507,7 +1507,7 @@ repos:
         entry: ./dev/skill-evals/eval.py
         language: node
         language_version: '22.22.0'
-        additional_dependencies: ['[email protected]', 
'@anthropic-ai/[email protected]']
+        additional_dependencies: ['[email protected]', 
'@anthropic-ai/[email protected]']
         stages: ['manual']
         files: >
           (?x)
@@ -1546,7 +1546,7 @@ repos:
         entry: env PROMPTFOO_CONFIG_DIR=.build/promptfoo promptfoo view
         language: node
         language_version: '22.22.0'
-        additional_dependencies: ['[email protected]', 
'@anthropic-ai/[email protected]']
+        additional_dependencies: ['[email protected]', 
'@anthropic-ai/[email protected]']
         stages: ['manual']
         files: >
           (?x)
diff --git a/AGENTS.md b/AGENTS.md
index 7685fb036af..0822117a14d 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -20,6 +20,7 @@ Don't spell out **Directed Acyclic Graph** except for 
historical context.
 
 ## Environment Setup
 
+- Claude Code users need v2.1.281 or later (check with `claude --version`); 
older versions do not reliably read `AGENTS.md`, and the repo has no 
`CLAUDE.md`. If your session reports an older version, tell the user to upgrade.
 - Install prek: `uv tool install prek`
 - Enable commit hooks: `prek install`
 - Install breeze shim (one-time, per machine): `scripts/tools/setup_breeze` — 
installs `~/.local/bin/breeze` that runs breeze via `uv run --locked` from the 
current git worktree's `dev/breeze`, with dependencies pinned by 
`dev/breeze/uv.lock` (so each worktree, including ephemeral agent worktrees, 
gets its own breeze tied to its sources). See [ADR 
0017](dev/breeze/doc/adr/0017-use-uvx-to-run-breeze-from-local-sources.md).
diff --git a/CLAUDE.md b/CLAUDE.md
deleted file mode 120000
index 47dc3e3d863..00000000000
--- a/CLAUDE.md
+++ /dev/null
@@ -1 +0,0 @@
-AGENTS.md
\ No newline at end of file
diff --git a/dev/skill-evals/README.md b/dev/skill-evals/README.md
index e25333ff89a..e16c76dbfeb 100644
--- a/dev/skill-evals/README.md
+++ b/dev/skill-evals/README.md
@@ -38,25 +38,70 @@ Test whether changes to `AGENTS.md` break or improve agent 
decisions.
 The harness compares the `main` branch version against your working
 tree, running the same cases against both and reporting the diff.
 
-Each arm is a **git worktree** of the real repo — the agent sees
-actual source files (`pyproject.toml`, directory structure, etc.).
-The only difference between arms is which `AGENTS.md` is present.
-
-The agent reads guidance through the `CLAUDE.md → AGENTS.md` symlink,
-so the harness verifies that symlink exists (in the working tree and
-on the base branch) before running and aborts if it is broken — a
-regular-file CLAUDE.md would make every arm read identical guidance.
+Each arm is a **shared clone** (`git clone --shared`) of the real repo in a
+temp directory — the agent sees actual source files (`pyproject.toml`,
+directory structure, etc.). The only difference between arms is which
+`AGENTS.md` is present. Unlike `git worktree add`, a shared clone writes
+nothing into the repo's own `.git`, so the eval also runs inside an agent
+sandbox where `.git` is read-only.
+
+The agent reads `AGENTS.md` directly, as Claude Code does: the pinned
+Claude Agent SDK bundles a Claude Code CLI new enough (v2.1.277 or later)
+to load `AGENTS.md` without a `CLAUDE.md`. Keep that in mind when changing
+the SDK pin in `.pre-commit-config.yaml` — an older SDK would silently
+read no guidance in any arm.
 
 ## Prerequisites
 
 - **Claude authentication** (one of):
   - Claude Code session (`claude /login`) — Pro/Max subscription
   - `ANTHROPIC_API_KEY` environment variable — API credits
+  - `SKILL_EVAL_CLAUDE_TOKEN_FILE` — path to a file holding a token from
+    `claude setup-token` (Pro/Max subscription). See
+    [Running from an agent sandbox](#running-from-an-agent-sandbox).
 - **Codex authentication** (when using the Codex runtime): a Codex CLI
   session (`codex login`)
 
 That's it — prek provisions Node, promptfoo, and the agent SDKs automatically.
 
+### Running from an agent sandbox
+
+Agent sandboxes usually block the macOS keychain and the `~/.claude`
+credentials that a `/login` session stores, so every case fails with
+"Not logged in".
+
+The recommended fix is not to give the sandbox a credential at all: run the
+eval yourself, outside the sandbox, with your normal login (in Claude Code,
+type `! prek run run-skill-eval --hook-stage manual --all-files`). A token
+file readable from the sandbox stays readable to everything that runs there
+— prompt-injected commands and untrusted code under test included — for as
+long as it exists.
+
+If agents must run the eval unattended, give the eval its own credential:
+
+```bash
+claude setup-token          # run outside the agent; prints a long-lived token
+# save it to a file only you can read, at a path your sandbox allows reading
+chmod 600 /path/to/skill-eval-token
+SKILL_EVAL_CLAUDE_TOKEN_FILE=/path/to/skill-eval-token \
+  prek run run-skill-eval --hook-stage manual --all-files
+```
+
+Pick the path to suit your sandbox: sandboxes often deny reads across the
+home directory (including `~/.config`), so the file must sit somewhere the
+sandbox's read allowlist covers. Keep it outside the repository so it
+cannot be committed by accident.
+
+The harness reads the file and passes the token only to the promptfoo
+process, so it is not exported to every command in the session — prefer
+this over exporting `CLAUDE_CODE_OAUTH_TOKEN` or `ANTHROPIC_API_KEY` in the
+agent's environment.
+
+This narrows the exposure but does not hide the token from the agent: the
+sandbox must allow reading the file, so anything the agent runs can read it
+too. Use a token made only for the eval, and revoke it if it may have
+leaked.
+
 ## Agent runtimes
 
 Claude is the default runtime. The `run-skill-eval-codex` hook runs the same
@@ -160,7 +205,7 @@ Use `output.should_create` directly in assertions.
 
 ## How it works
 
-1. Creates git worktrees — one with `main`'s AGENTS.md, one with
+1. Creates shared clones — one with `main`'s AGENTS.md, one with
    your working tree version. Both are full repo checkouts.
 2. Generates a [promptfoo](https://github.com/promptfoo/promptfoo)
    config for the selected runtime. Claude uses promptfoo's
diff --git a/dev/skill-evals/eval.py b/dev/skill-evals/eval.py
index 19184629994..359bb37f794 100755
--- a/dev/skill-evals/eval.py
+++ b/dev/skill-evals/eval.py
@@ -21,7 +21,7 @@
 """Airflow skill-eval harness.
 
 Test whether AGENTS.md guidance affects agent decisions by comparing
-arms with and without the guidance. Each arm is a git worktree of the
+arms with and without the guidance. Each arm is a shared clone of the
 real repo — the agent sees actual source files.
 
 Usage:
@@ -29,7 +29,7 @@ Usage:
     prek run run-skill-eval-codex --hook-stage manual --all-files
 
 Env knobs: AGENT_RUNTIME (set by the Codex hook), MODEL, SKILL_NAME, 
EVAL_REPEAT,
-EVAL_FULL (baseline arm).
+EVAL_FULL (baseline arm), SKILL_EVAL_CLAUDE_TOKEN_FILE (Claude token for the 
eval only).
 Promptfoo flags like --filter* are argv-only — wire them as fixed entry
 args on a hook variant when needed.
 
@@ -115,7 +115,12 @@ def find_sdk_modules(runtime: str) -> Path:
         # PROMPTFOO_DISABLE_UPDATE avoids an outdated version banner on stdout 
when a newer
         # promptfoo is published upstream, which would otherwise break this 
exact match.
         version = run(
-            ["promptfoo", "--version"], env={**os.environ, 
"PROMPTFOO_DISABLE_UPDATE": "1"}
+            ["promptfoo", "--version"],
+            env={
+                **os.environ,
+                "PROMPTFOO_DISABLE_UPDATE": "1",
+                "PROMPTFOO_CONFIG_DIR": str(PROMPTFOO_STATE_DIR),
+            },
         ).stdout.strip()
         if version == PROMPTFOO_VERSION:
             pf_pkg = Path(promptfoo_bin).resolve()
@@ -135,27 +140,24 @@ def find_sdk_modules(runtime: str) -> Path:
     sys.exit(1)
 
 
-def check_claude_md_symlink(base_branch: str) -> None:
-    """Verify CLAUDE.md is a symlink to AGENTS.md, in the working tree and on 
the base branch.
+def read_claude_token_env(runtime: str) -> dict[str, str]:
+    """Return CLAUDE_CODE_OAUTH_TOKEN read from SKILL_EVAL_CLAUDE_TOKEN_FILE, 
if set.
 
-    The Claude Agent SDK reads CLAUDE.md. Swapping AGENTS.md between arms only
-    affects the agent while CLAUDE.md resolves to it — if CLAUDE.md ever 
becomes
-    a regular file, every arm would read identical guidance and the eval would
-    silently measure nothing.
+    The token goes only into the promptfoo subprocess environment, so it does
+    not have to be exported for the whole (agent) session.
     """
-    link = REPO_ROOT / "CLAUDE.md"
-    working_ok = link.is_symlink() and os.readlink(link) == "AGENTS.md"
-    tree_entry = run(["git", "-C", str(REPO_ROOT), "ls-tree", base_branch, 
"CLAUDE.md"]).stdout
-    target = run(["git", "-C", str(REPO_ROOT), "show", 
f"{base_branch}:CLAUDE.md"]).stdout
-    branch_ok = tree_entry.startswith("120000") and target == "AGENTS.md"
-    if not (working_ok and branch_ok):
-        print(
-            "Error: CLAUDE.md must be a symlink to AGENTS.md (in the working 
tree"
-            f" and on '{base_branch}'). The eval swaps AGENTS.md between arms 
and"
-            " relies on the agent reading it through that symlink.",
-            file=sys.stderr,
-        )
+    token_file = os.environ.get("SKILL_EVAL_CLAUDE_TOKEN_FILE")
+    if runtime != "claude" or not token_file:
+        return {}
+    try:
+        token = Path(token_file).expanduser().read_text().strip()
+    except OSError as e:
+        print(f"Error: cannot read SKILL_EVAL_CLAUDE_TOKEN_FILE 
({token_file}): {e}", file=sys.stderr)
+        sys.exit(1)
+    if not token:
+        print(f"Error: SKILL_EVAL_CLAUDE_TOKEN_FILE ({token_file}) is empty.", 
file=sys.stderr)
         sys.exit(1)
+    return {"CLAUDE_CODE_OAUTH_TOKEN": token}
 
 
 def resolve_base_branch() -> str:
@@ -175,58 +177,58 @@ def git_show_file(base_branch: str, path: str, dest: 
Path) -> bool:
     return True
 
 
-def create_worktree(
+def create_arm(
     work_dir: Path,
     name: str,
-    base_branch: str,
+    base_sha: str,
     agents_file: Path | None,
-    worktrees: list[Path],
     skill_name: str | None = None,
     skill_file: Path | None = None,
 ) -> Path:
-    """Create a git worktree arm with the specified AGENTS.md and optional 
SKILL.md."""
-    wt_dir = work_dir / name
-    result = run(
+    """Create an arm checkout with the specified AGENTS.md and optional 
SKILL.md.
+
+    A shared clone, unlike ``git worktree add``, writes nothing into the main
+    repo's ``.git``, so the eval also runs where that is read-only, such as an
+    agent sandbox.
+    """
+    arm_dir = work_dir / name
+    for cmd in (
+        ["git", "clone", "--quiet", "--shared", "--no-checkout", 
str(REPO_ROOT), str(arm_dir)],
+        # Global hooks (e.g. a post-checkout hook) must not run in a throwaway 
clone.
         [
             "git",
             "-C",
-            str(REPO_ROOT),
-            "worktree",
-            "add",
+            str(arm_dir),
+            "-c",
+            "core.hooksPath=/dev/null",
+            "checkout",
             "--quiet",
             "--detach",
-            str(wt_dir),
-            base_branch,
-        ]
-    )
-    if result.returncode != 0:
-        print(
-            f"Error: 'git worktree add' failed for arm 
'{name}':\n{result.stderr.strip()}",
-            file=sys.stderr,
-        )
-        sys.exit(1)
-    # Register before mutating the checkout so cleanup covers this worktree
-    # even if a later step in this function fails.
-    worktrees.append(wt_dir)
+            base_sha,
+        ],
+    ):
+        result = run(cmd)
+        if result.returncode != 0:
+            print(
+                f"Error: '{' '.join(cmd[:4])} ...' failed for arm 
'{name}':\n{result.stderr.strip()}",
+                file=sys.stderr,
+            )
+            sys.exit(1)
 
+    # A base branch that still tracks the CLAUDE.md symlink would make the SDK
+    # read CLAUDE.md files only (skipping nested AGENTS.md), unlike the other 
arms.
+    (arm_dir / "CLAUDE.md").unlink(missing_ok=True)
     if agents_file is None:
-        # Baseline arm: remove all guidance. CLAUDE.md is a symlink to
-        # AGENTS.md — drop it too so the SDK finds no dangling link.
-        (wt_dir / "AGENTS.md").unlink(missing_ok=True)
-        (wt_dir / "CLAUDE.md").unlink(missing_ok=True)
+        (arm_dir / "AGENTS.md").unlink(missing_ok=True)
     else:
-        shutil.copy2(agents_file, wt_dir / "AGENTS.md")
+        shutil.copy2(agents_file, arm_dir / "AGENTS.md")
 
     if skill_name and skill_file:
-        skill_dir = wt_dir / ".agents" / "skills" / skill_name
+        skill_dir = arm_dir / ".agents" / "skills" / skill_name
         skill_dir.mkdir(parents=True, exist_ok=True)
         shutil.copy2(skill_file, skill_dir / "SKILL.md")
 
-    return wt_dir
-
-
-def remove_worktree(wt_dir: Path) -> None:
-    run(["git", "-C", str(REPO_ROOT), "worktree", "remove", "--force", 
str(wt_dir)])
+    return arm_dir
 
 
 def build_provider(label: str, working_dir: Path, model: str | None, 
skill_name: str | None = None) -> dict:
@@ -328,15 +330,12 @@ def main() -> int:
         return 1
 
     base_branch = resolve_base_branch()
-    if runtime == "claude":
-        check_claude_md_symlink(base_branch)
 
     # Hash before building arms so edits made mid-run aren't recorded as 
tested.
     guidance_hash = compute_guidance_hash(AGENTS_SRC, CASES_DIR)
 
-    # Temp dir for config and worktrees
+    # Temp dir for config and arm checkouts
     work_dir = Path(tempfile.mkdtemp())
-    worktrees: list[Path] = []
 
     try:
         # promptfoo resolves the selected agent SDK from the config directory
@@ -363,26 +362,20 @@ def main() -> int:
             skill_changed = run(["diff", "-q", str(main_skill), 
str(skill_src)]).returncode != 0
         need_working = agents_changed or skill_changed
 
-        # Assemble arms. Prune first to self-heal stale worktree registrations
-        # left behind by a previously interrupted run.
-        print("Assembling arms (git worktrees) ...")
-        run(["git", "-C", str(REPO_ROOT), "worktree", "prune"])
+        print("Assembling arms (shared clones) ...")
+        base_sha = run(["git", "-C", str(REPO_ROOT), "rev-parse", "--verify", 
base_branch]).stdout.strip()
 
-        arm_main = create_worktree(
-            work_dir, "main", base_branch, main_agents, worktrees, skill_name, 
main_skill
-        )
+        arm_main = create_arm(work_dir, "main", base_sha, main_agents, 
skill_name, main_skill)
 
         arm_working = None
         if need_working:
-            arm_working = create_worktree(
-                work_dir, "working", base_branch, AGENTS_SRC, worktrees, 
skill_name, skill_src
-            )
+            arm_working = create_arm(work_dir, "working", base_sha, 
AGENTS_SRC, skill_name, skill_src)
         else:
             print("  AGENTS.md unchanged — skipping working arm")
 
         arm_baseline = None
         if full_mode:
-            arm_baseline = create_worktree(work_dir, "baseline", base_branch, 
None, worktrees)
+            arm_baseline = create_arm(work_dir, "baseline", base_sha, None)
 
         # Generate config (JSON — valid promptfoo config, keeps the script 
stdlib-only)
         def provider(label: str, arm: Path, selected_skill: str | None = None) 
-> dict:
@@ -431,7 +424,11 @@ def main() -> int:
         result = subprocess.run(
             ["promptfoo", "eval", "-c", str(config_path), "--output", 
str(RESULTS_FILE), *promptfoo_args],
             check=False,
-            env={**os.environ, "PROMPTFOO_CONFIG_DIR": 
str(PROMPTFOO_STATE_DIR)},
+            env={
+                **os.environ,
+                "PROMPTFOO_CONFIG_DIR": str(PROMPTFOO_STATE_DIR),
+                **read_claude_token_env(runtime),
+            },
         )
 
         # 0 = all passed, 100 = some assertions failed — both mean the eval
@@ -460,8 +457,6 @@ def main() -> int:
         return result.returncode
 
     finally:
-        for wt in worktrees:
-            remove_worktree(wt)
         shutil.rmtree(work_dir, ignore_errors=True)
 
 
diff --git a/dev/skill-evals/last-eval-hash.txt 
b/dev/skill-evals/last-eval-hash.txt
index 451e4d1e3d4..b1eeb677e73 100644
--- a/dev/skill-evals/last-eval-hash.txt
+++ b/dev/skill-evals/last-eval-hash.txt
@@ -1,3 +1,3 @@
 # Generated by dev/skill-evals/eval.py — do not edit or resolve conflicts by 
hand.
 # Run `prek run run-skill-eval --hook-stage manual --all-files` to regenerate.
-d0e8ed3ebe9973449495c65634f02bfe2fb1a41e38bb4a09aa7d0199502b3f72
+4a668efb08bd5ccd21c219a5e29ea2b4c47de3fc22f72d5ba3c25c080f9cc22f
diff --git a/registry/CLAUDE.md b/registry/CLAUDE.md
deleted file mode 120000
index 47dc3e3d863..00000000000
--- a/registry/CLAUDE.md
+++ /dev/null
@@ -1 +0,0 @@
-AGENTS.md
\ No newline at end of file
diff --git a/scripts/tests/ci/prek/test_skill_eval.py 
b/scripts/tests/ci/prek/test_skill_eval.py
index 8bac034debb..f23b8c91ab5 100644
--- a/scripts/tests/ci/prek/test_skill_eval.py
+++ b/scripts/tests/ci/prek/test_skill_eval.py
@@ -17,6 +17,7 @@
 from __future__ import annotations
 
 import importlib.util
+import subprocess
 from pathlib import Path
 from types import SimpleNamespace
 
@@ -156,3 +157,116 @@ def 
test_find_sdk_modules_requires_the_selected_runtimes_sdk(skill_eval_module,
         skill_eval_module.find_sdk_modules("codex")
 
     assert exit_info.value.code == 1
+
+
+def test_find_sdk_modules_runs_version_check_with_repo_local_config(
+    monkeypatch, skill_eval_module, promptfoo_layout
+):
+    promptfoo_layout.install(promptfoo_layout.install_root, 
skill_eval_module.SDK_PACKAGES["claude"])
+    calls = []
+
+    def fake_run(cmd, **kwargs):
+        calls.append(kwargs)
+        return 
SimpleNamespace(stdout=f"{skill_eval_module.PROMPTFOO_VERSION}\n")
+
+    monkeypatch.setattr(skill_eval_module, "run", fake_run)
+
+    skill_eval_module.find_sdk_modules("claude")
+
+    assert calls[0]["env"]["PROMPTFOO_CONFIG_DIR"] == 
str(skill_eval_module.PROMPTFOO_STATE_DIR)
+
+
[email protected](
+    ("runtime", "token_file_content", "expected"),
+    [
+        pytest.param("claude", None, {}, id="unset"),
+        pytest.param("claude", "tok-123\n", {"CLAUDE_CODE_OAUTH_TOKEN": 
"tok-123"}, id="claude"),
+        pytest.param("codex", "", {}, id="codex-ignores-file"),
+    ],
+)
+def test_read_claude_token_env(
+    monkeypatch, skill_eval_module, tmp_path, runtime, token_file_content, 
expected
+):
+    if token_file_content is None:
+        monkeypatch.delenv("SKILL_EVAL_CLAUDE_TOKEN_FILE", raising=False)
+    else:
+        token_file = tmp_path / "token"
+        token_file.write_text(token_file_content)
+        monkeypatch.setenv("SKILL_EVAL_CLAUDE_TOKEN_FILE", str(token_file))
+
+    assert skill_eval_module.read_claude_token_env(runtime) == expected
+
+
[email protected]("token_file_content", [None, "  \n"], ids=["missing", 
"empty"])
+def test_read_claude_token_env_rejects_unusable_file(
+    monkeypatch, skill_eval_module, tmp_path, token_file_content
+):
+    token_file = tmp_path / "token"
+    if token_file_content is not None:
+        token_file.write_text(token_file_content)
+    monkeypatch.setenv("SKILL_EVAL_CLAUDE_TOKEN_FILE", str(token_file))
+
+    with pytest.raises(SystemExit) as exit_info:
+        skill_eval_module.read_claude_token_env("claude")
+
+    assert exit_info.value.code == 1
+
+
[email protected]
+def source_repo(monkeypatch, skill_eval_module, tmp_path):
+    """A repo tracking AGENTS.md and a CLAUDE.md symlink, plus a global 
post-checkout hook."""
+    hooks = tmp_path / "hooks"
+    hooks.mkdir()
+    marker = tmp_path / "hook-ran"
+    hook = hooks / "post-checkout"
+    hook.write_text(f"#!/bin/sh\ntouch {marker}\n")
+    hook.chmod(0o755)
+    global_config = tmp_path / "gitconfig"
+    global_config.write_text(f"[core]\n\thooksPath = {hooks}\n")
+    monkeypatch.setenv("GIT_CONFIG_GLOBAL", str(global_config))
+    monkeypatch.setenv("GIT_CONFIG_NOSYSTEM", "1")
+
+    repo = tmp_path / "repo"
+    repo.mkdir()
+
+    def git(*args):
+        return subprocess.run(
+            ["git", "-C", str(repo), *args], check=True, capture_output=True, 
text=True
+        ).stdout.strip()
+
+    git("init", "--quiet")
+    (repo / "AGENTS.md").write_text("main guidance\n")
+    (repo / "CLAUDE.md").symlink_to("AGENTS.md")
+    git("add", "-A")
+    git("-c", "user.name=t", "-c", "[email protected]", "commit", 
"--quiet", "-m", "init")
+    monkeypatch.setattr(skill_eval_module, "REPO_ROOT", repo)
+    return SimpleNamespace(path=repo, sha=git("rev-parse", "HEAD"), 
marker=marker)
+
+
+def 
test_create_arm_checks_out_base_without_touching_source_repo(skill_eval_module, 
source_repo, tmp_path):
+    work_dir = tmp_path / "work"
+    work_dir.mkdir()
+    agents_file = tmp_path / "working-agents.md"
+    agents_file.write_text("working guidance\n")
+
+    arm = skill_eval_module.create_arm(work_dir, "working", source_repo.sha, 
agents_file)
+
+    head = subprocess.run(
+        ["git", "-C", str(arm), "rev-parse", "HEAD"], check=True, 
capture_output=True, text=True
+    ).stdout.strip()
+    assert head == source_repo.sha
+    assert (arm / "AGENTS.md").read_text() == "working guidance\n"
+    assert not (arm / "CLAUDE.md").exists()
+    assert not (arm / "CLAUDE.md").is_symlink()
+    assert not (source_repo.path / ".git" / "worktrees").exists()
+    assert not source_repo.marker.exists()
+
+
+def test_create_arm_baseline_has_no_guidance(skill_eval_module, source_repo, 
tmp_path):
+    work_dir = tmp_path / "work"
+    work_dir.mkdir()
+
+    arm = skill_eval_module.create_arm(work_dir, "baseline", source_repo.sha, 
None)
+
+    assert not (arm / "AGENTS.md").exists()
+    assert not (arm / "CLAUDE.md").is_symlink()

Reply via email to