Skip to content

Replay your coding agent sessions as a map and a timeline

fix(health): scope keeps targets that merely contain a job word

aiswaryasankartestfdb6651a1912
diff --git a/python/src/agentplay/health.py b/python/src/agentplay/health.py
index 407bf2d..3588909 100644
--- a/python/src/agentplay/health.py
+++ b/python/src/agentplay/health.py
@@ -63,8 +63,10 @@ def _scope(verb: str) -> frozenset[str]:
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:]
- job_words = {w for _, ws in _PURPOSES for w in ws}
- return frozenset(w for w in words if w not in ("run", "exec", "x") and not any(j in w for j in job_words))
+ # 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}
+ 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))
def purpose(verb: str) -> str | None:
diff --git a/python/tests/test_search_health_fixes.py b/python/tests/test_search_health_fixes.py
index 24ef404..428a88d 100644
--- a/python/tests/test_search_health_fixes.py
+++ b/python/tests/test_search_health_fixes.py
@@ -455,6 +455,8 @@ def test_a_replacement_check_must_cover_the_same_target():
rows = [_row("s1", cmd=cmd, verifyAfterLastEdit=True)]
assert [f for f in health.fixes(rows) if f["rule"] == "use_working_command"] == []
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")
def test_one_multi_file_reread_charges_one_request():