Skip to content

Replay your coding agent sessions as a map and a timeline

fix(health): keep compound job words whole when scoping checks

aiswaryasankartestdc66efd5ac46
diff --git a/python/src/agentplay/health.py b/python/src/agentplay/health.py
index 3588909..847ff09 100644
--- a/python/src/agentplay/health.py
+++ b/python/src/agentplay/health.py
@@ -62,9 +62,14 @@ def _scope(verb: str) -> frozenset[str]:
Two checks only stand in for each other when their scopes match, so a
failing unit suite is never "replaced" by a passing e2e one.
"""
- words = [w for w in re.split(r"[^a-z0-9]+", verb.lower()) if w][1:]
- # Whole job words only (and their plurals): `unittest` or `smoke-tests` keep their target.
- job_words = {p for _, ws in _PURPOSES for w in ws for p in re.split(r"[^a-z0-9]+", w) if p}
+ low = verb.lower()
+ # A compound job word (`type-check`) is one word: joined before splitting, so its
+ # pieces (`check`) never become generic and strip a real target.
+ for w in (w for _, ws in _PURPOSES for w in ws if not w.isalnum()):
+ low = low.replace(w, re.sub(r"[^a-z0-9]+", "", w))
+ words = [w for w in re.split(r"[^a-z0-9]+", low) if w][1:]
+ # Whole job words only (and their plurals): `unittest` or `e2etests` keep their target.
+ job_words = {re.sub(r"[^a-z0-9]+", "", w) for _, ws in _PURPOSES for w in ws}
generic = job_words | {"run", "exec", "x"}
return frozenset(w for w in words if w not in generic and not (w.endswith("s") and w[:-1] in job_words))
diff --git a/python/tests/test_search_health_fixes.py b/python/tests/test_search_health_fixes.py
index 428a88d..d1f95c4 100644
--- a/python/tests/test_search_health_fixes.py
+++ b/python/tests/test_search_health_fixes.py
@@ -457,6 +457,8 @@ def test_a_replacement_check_must_cover_the_same_target():
assert health._scope("pnpm test") == health._scope("pnpm vitest") # the case the rule exists for
assert health._scope("pnpm unittest") != health._scope("pnpm vitest") # a target spelled with a job word
assert health._scope("pnpm run tests") == health._scope("pnpm test")
+ assert health._scope("pnpm test:check") != health._scope("pnpm test") # `check` is a target, not a job word
+ assert health._scope("pnpm run type-check") == health._scope("pnpm tsc")
def test_one_multi_file_reread_charges_one_request():