Skip to content

The agent that grows with you

fix: managed-runtime guard no longer trips on sdist/build copies in the workspace

Teknium3f5d37568eea
diff --git a/tests/test_managed_runtime_resolution.py b/tests/test_managed_runtime_resolution.py
index 8d4c48eeae3..e52a4ddcfbd 100644
--- a/tests/test_managed_runtime_resolution.py
+++ b/tests/test_managed_runtime_resolution.py
@@ -26,6 +26,7 @@ whose behavior is separately covered by a real test.
from __future__ import annotations
import ast
+import functools
from pathlib import Path
import pytest
@@ -125,10 +126,31 @@ def _source_files() -> list[Path]:
rel = path.relative_to(REPO_ROOT)
if rel.parts and rel.parts[0] in _EXEMPT_DIRS:
continue
+ # Skip packaging copies of the source tree (sdist extractions like
+ # hermes_agent-0.20.5/, build/ and *.egg-info dirs). CI jobs that
+ # build the wheel leave one in the workspace; scanning it re-finds
+ # every already-exempted call site under a versioned path prefix
+ # that can never match an _ALLOWED key, failing the guard on code
+ # that was never touched. A dir is a packaging copy iff its top
+ # level carries PKG-INFO (sdist/egg metadata) or it is a build/
+ # dist output directory.
+ if rel.parts and _is_packaging_copy(rel.parts[0]):
+ continue
files.append(path)
return files
[email protected]_cache(maxsize=None)
+def _is_packaging_copy(top_level: str) -> bool:
+ """Whether *top_level* (a dir name under REPO_ROOT) is a build artifact."""
+ if top_level in ("build", "dist") or top_level.endswith(".egg-info"):
+ return True
+ candidate = REPO_ROOT / top_level
+ if not candidate.is_dir():
+ return False
+ return (candidate / "PKG-INFO").exists()
+
+
def _findings() -> list[tuple[str, str, int]]:
"""Return (relpath, command, lineno) for every bare managed lookup."""
found: list[tuple[str, str, int]] = []