@jesdi/skills 0.0.87 → 0.0.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/package.json +1 -1
  2. package/skills/babysit-pr/SKILL.md +1 -1
  3. package/skills/babysit-pr/babysit.py +21 -10
  4. package/skills/babysit-pr/fixtures/gh +2 -1
  5. package/skills/babysit-pr/judge-prompt.md +7 -3
  6. package/skills/babysit-pr/test_babysit_judge.py +16 -10
  7. package/skills/babysit-pr/test_babysit_judge_isolation.py +1 -1
  8. package/skills/babysit-pr/test_handoff_takeover.py +1 -1
  9. package/skills/babysit-pr/test_merge_and_handoff.py +17 -16
  10. package/skills/babysit-pr/test_merge_base_pin.py +1 -1
  11. package/skills/babysit-pr/test_merge_gate.py +49 -14
  12. package/skills/babysit-pr/test_merge_session_safety.py +3 -3
  13. package/skills/babysit-pr/test_merged_pr_labels.py +1 -1
  14. package/skills/babysit-pr/test_terminal_label_regressions.py +1 -1
  15. package/skills/babysit-pr/test_trusted_merge_risk.py +1 -1
  16. package/skills/implement-spec/ARCHITECTURE.md +20 -8
  17. package/skills/implement-spec/README.md +7 -4
  18. package/skills/implement-spec/driver_decisions.py +3 -2
  19. package/skills/implement-spec/driver_dispute.py +82 -57
  20. package/skills/implement-spec/driver_fixloop.py +18 -21
  21. package/skills/implement-spec/driver_legacy.py +31 -2
  22. package/skills/implement-spec/driver_report.py +13 -3
  23. package/skills/implement-spec/driver_state.py +8 -7
  24. package/skills/implement-spec/prompts/correction.md +1 -0
  25. package/skills/implement-spec/prompts/reviewer.md +3 -3
  26. package/skills/implement-spec/prompts/ruled.md +1 -1
  27. package/skills/implement-spec/tests/test_arbitration.py +101 -10
  28. package/skills/implement-spec/tests/test_decisions.py +7 -5
  29. package/skills/implement-spec/tests/test_final.py +1 -1
  30. package/skills/implement-spec/tests/test_fixloop.py +3 -3
  31. package/skills/implement-spec/tests/test_legacy.py +27 -0
  32. package/skills/implement-spec/tests/test_state.py +1 -1
  33. package/skills/implement-spec/tests/test_walk.py +1 -1
  34. package/skills/pr-risk/SKILL.md +18 -3
  35. package/skills/pr-risk/merge_policy.py +29 -9
  36. package/skills/pr-risk/merge_risk.py +57 -14
  37. package/skills/pr-risk/test_hooks.py +2 -2
  38. package/skills/pr-risk/test_merge_risk.py +2 -2
  39. package/skills/pr-risk/test_merge_risk_gate.py +128 -43
  40. package/skills/pr-risk/test_merge_risk_regressions.py +5 -5
  41. package/skills/pr-risk/test_merge_risk_structure.py +5 -4
  42. package/skills/test-weigh-in/dashboard.html +70 -17
  43. package/skills/test-weigh-in/tests/browser_driver.py +46 -5
  44. package/skills/test-weigh-in/tests/layout_page.py +7 -3
  45. package/skills/test-weigh-in/tests/overlap_page.py +3 -0
  46. package/skills/test-weigh-in/tests/rules_fixture.py +1 -1
  47. package/skills/test-weigh-in/tests/test_coverage_run.py +5 -1
  48. package/skills/test-weigh-in/tests/test_dashboard_layout.py +50 -9
  49. package/skills/test-weigh-in/tests/test_score.py +53 -2
  50. package/skills/test-weigh-in/weigh.py +2 -2
  51. package/skills/test-weigh-in/weigh_coverage.py +22 -2
  52. package/skills/test-weigh-in/weigh_dashboard.py +51 -10
  53. package/skills/test-weigh-in/weigh_score.py +6 -3
  54. package/skills/test-weigh-in/weigh_smells.py +3 -2
  55. package/skills-manifest.json +9 -9
@@ -2,6 +2,8 @@
2
2
  weigh_dashboard.write_dashboard and prints its path. The real-suite shape of the spec: 2,172 tests (all drawn on the
3
3
  Map), 3,196 cases, 6,757 overlap pairs with 200-character ids.
4
4
  Fast feedback is fully measured, Resistance to refactoring has 0 of its 4 metrics measured (reasons recorded).
5
+ `layout_page.py <out-dir> red` makes the suite red: every 50th test fails and the one after it is skipped, so Regression
6
+ and Refactoring are partial for missing metrics and for the red suite at once.
5
7
  """
6
8
  import sys
7
9
  from pathlib import Path
@@ -17,7 +19,7 @@ FIXTURE = "2172 tests, 3196 cases, 6757 pairs"
17
19
  NOT_MEASURED = ("brittle_test_files", "private_access", "mock_heavy", "interaction_only")
18
20
 
19
21
 
20
- def build(out):
22
+ def build(out, red=False):
21
23
  out.mkdir(parents=True, exist_ok=True)
22
24
  rules = load()
23
25
  tests = {}
@@ -25,8 +27,10 @@ def build(out):
25
27
  lo = (i % 300) * 10 + 1
26
28
  tests[overlap_page.name(i)] = {"outcome": "passed", "duration": 0.01 + (i % 9) / 100, "coverage": {"src/m.py": list(range(lo, lo + 6 + i % 3))},
27
29
  "unique_coverage": 0, "flaky": False, "smells": [], "lines": 2}
30
+ if red and i % 50 < 2:
31
+ tests[overlap_page.name(i)]["outcome"] = "failed" if i % 50 == 0 else "skipped"
28
32
  values = {**feedback_values(tests, 1.0), "no_unique_coverage": 100.0, "branch_coverage": 80.0, "hollow_tests": 1.0}
29
- metrics, pillars = score(rules, values)
33
+ metrics, pillars = score(rules, values, red=red)
30
34
  data = {"commit": "abc1234", "dirty": False, "inventory": {"tests": overlap_page.N_TESTS, "cases": 3196, "test_files": 44, "test_lines": 9000, "source_lines": 9000, "runtime_seconds": 64.2},
31
35
  "metrics": metrics, "pillars": pillars, "tests": tests, "overlaps": overlap_page.pairs(),
32
36
  "unmeasured": {m: "no git history" for m in NOT_MEASURED}}
@@ -34,4 +38,4 @@ def build(out):
34
38
 
35
39
 
36
40
  if __name__ == "__main__":
37
- print(build(Path(sys.argv[1])))
41
+ print(build(Path(sys.argv[1]), red=sys.argv[2:] == ["red"]))
@@ -10,6 +10,9 @@ Interface the acceptance tests pin (the spec leaves the markup open), inside the
10
10
  [data-testid=overlap-test] identities and a label naming "Jaccard" with the value
11
11
  [data-testid=overlap-empty] shown only when no pair matches, with an explanation
12
12
  [data-testid=overlap-next] pages forward; disabled on the last page
13
+ [data-testid=overlap-prev] pages back; disabled on the first page
14
+ [data-testid=overlap-page] "Page <n> of <pages>"; these three form the pager above the list, the same three with
15
+ a -bottom suffix (overlap-next-bottom, ...) the pager below it
13
16
  """
14
17
  import json
15
18
  import sys
@@ -6,7 +6,7 @@ Interface the tests pin (the spec leaves the TOML keys and the snapshot JSON key
6
6
  optional partial_weight, target, bad, optional log = true. Percentages are 0-100,
7
7
  durations are seconds. Pillar keys: regression, refactoring, feedback,
8
8
  maintainability, economy.
9
- snapshot: rules {version, sha256}; metrics {<id>: {value, score}}; pillars {<key>: {score, partial}}.
9
+ snapshot: rules {version, sha256}; metrics {<id>: {value, score}}; pillars {<key>: {score, partial, red_suite}}.
10
10
  Scores are unrounded floats; only the dashboard rounds and clamps.
11
11
  """
12
12
  import hashlib
@@ -7,8 +7,9 @@ Snapshot interface the tests pin (the spec leaves the JSON keys open), on top of
7
7
  tests[node].unique_coverage number of lines the test covers that no other passing test covers
8
8
  overlaps [{"tests": [node, node], "jaccard": float}] for passing pairs with jaccard >= 0.9
9
9
  metrics.branch_coverage / metrics.no_unique_coverage {value, score}; value in percent
10
- Stdout: "<n> flaky test(s)" and "<n> tests are failing" warnings.
10
+ Stdout: "<n> flaky test(s)" and "<n> tests are failing" warnings; a partial pillar's line ends "(partial: <reasons>)", its gauge status.
11
11
  """
12
+ import re
12
13
  import time
13
14
  from concurrent.futures import ThreadPoolExecutor
14
15
 
@@ -112,6 +113,9 @@ def test_a_red_suite_is_measured_without_the_failing_tests_value(tmp_path, home,
112
113
  100 * sum(not t["unique_coverage"] for t in passed) / 40)
113
114
  assert data["pillars"]["regression"]["partial"] and data["pillars"]["economy"]["partial"]
114
115
  assert "3 tests are failing" in result.stdout
116
+ # the chat summary says why each pillar is partial, the same words as its gauge
117
+ assert re.search(r"^Protection against regressions: \d+ \(partial: 2 of 4 measured; 3 tests failing\)$", result.stdout, re.M)
118
+ assert re.search(r"^Fast feedback: \d+$", result.stdout, re.M)
115
119
 
116
120
 
117
121
  def test_skipped_tests_cost_without_value(tmp_path, home, cache):
@@ -20,18 +20,28 @@ SPEC = HERE.parents[2] / "specs" / "test-weigh-in-dashboard-polish"
20
20
  TABS = ["Metrics", "Overlaps", "Map"]
21
21
 
22
22
 
23
- @pytest.fixture(scope="module")
24
- def report(tmp_path_factory):
25
- out = tmp_path_factory.mktemp("layout04")
26
- built = subprocess.run([sys.executable, str(HERE / "layout_page.py"), str(out)], capture_output=True, text=True, timeout=600)
23
+ def drive(out, page=(), driver=()):
24
+ """Build layout_page.py with `page` args into `out` and measure it with browser_driver.py and `driver` args."""
25
+ built = subprocess.run([sys.executable, str(HERE / "layout_page.py"), str(out), *page], capture_output=True, text=True, timeout=600)
27
26
  assert built.returncode == 0, built.stderr
28
27
  html = Path(built.stdout.strip())
29
- drove = subprocess.run([uv(), "run", "--with", "playwright", "python", str(HERE / "browser_driver.py"), str(html)],
28
+ drove = subprocess.run([uv(), "run", "--with", "playwright", "python", str(HERE / "browser_driver.py"), str(html), *driver],
30
29
  capture_output=True, text=True, timeout=600)
31
30
  assert drove.returncode == 0, drove.stderr[-3000:]
32
31
  return {"bytes": html.stat().st_size, **json.loads(drove.stdout)}
33
32
 
34
33
 
34
+ @pytest.fixture(scope="module")
35
+ def report(tmp_path_factory):
36
+ return drive(tmp_path_factory.mktemp("layout04"))
37
+
38
+
39
+ @pytest.fixture(scope="module")
40
+ def red_report(tmp_path_factory):
41
+ """The same suite red: failing and skipped tests, Regression and Refactoring partial for both reasons."""
42
+ return drive(tmp_path_factory.mktemp("layout04red"), page=["red"], driver=["--gauges"])
43
+
44
+
35
45
  def only_active(tabs, label):
36
46
  """Exactly one tab looks different from the rest, and it is `label`."""
37
47
  sigs = [t["sig"] for t in tabs]
@@ -49,14 +59,22 @@ def test_the_active_tab_follows_selection_and_keyboard_focus_shows(report):
49
59
 
50
60
 
51
61
  @pytest.mark.parametrize("view", ["desktop", "narrow"])
52
- def test_gauges_align_and_partial_status_stays_readable(report, view):
53
- gauges = report[view]["gauges"]
62
+ def test_selecting_a_tab_moves_no_tab(report, view):
63
+ steps = report["tab_boxes"][view]["steps"]
64
+ assert len(steps) == 5, f"Economy shows every tab: {list(steps)}"
65
+ first = next(iter(steps.values()))
66
+ for label, boxes in steps.items():
67
+ assert boxes == first, f"selecting {label} at {view} moves the tabs: {boxes} vs {first}"
68
+
69
+
70
+ def gauges_readable(r, view, max_lines=2):
71
+ gauges = r[view]["gauges"]
54
72
  assert len(gauges) == 5
55
73
  for g in gauges:
56
74
  assert g["title"] and g["status"], "every gauge has a gauge-title and a gauge-status, a fully measured one too"
57
75
  assert g["status"]["text"], "a fully measured pillar still states its measurement status"
58
76
  assert not g["title"]["clipped"] and not g["status"]["clipped"]
59
- assert g["status"]["font"] >= 11 and g["status"]["lines"] <= 2, f"partial status unreadable: {g['status']}"
77
+ assert g["status"]["font"] >= 11 and g["status"]["lines"] <= max_lines, f"partial status unreadable: {g['status']}"
60
78
  rows = {}
61
79
  for g in gauges:
62
80
  rows.setdefault(g["card"]["top"], []).append(g)
@@ -65,7 +83,30 @@ def test_gauges_align_and_partial_status_stays_readable(report, view):
65
83
  assert len({g[part]["top"] for g in row}) == 1, f"{part} not aligned across a row at {view}: {[g[part]['top'] for g in row]}"
66
84
  refactoring = next(g for g in gauges if "refactoring" in g["title"]["text"].lower())
67
85
  assert "0 of 4" in refactoring["status"]["text"]
68
- assert report[view]["overview"]["scroll_width"] <= report[view]["overview"]["viewport"], "the page overflows sideways"
86
+ assert r[view]["overview"]["scroll_width"] <= r[view]["overview"]["viewport"], "the page overflows sideways"
87
+ return refactoring
88
+
89
+
90
+ @pytest.mark.parametrize("view", ["desktop", "narrow"])
91
+ def test_gauges_align_and_partial_status_stays_readable(report, view):
92
+ gauges_readable(report, view)
93
+
94
+
95
+ @pytest.mark.parametrize("view", ["desktop", "narrow"])
96
+ def test_a_red_suite_status_naming_both_reasons_stays_readable(red_report, view):
97
+ # 3 lines at most: at 390 px "partial: 2 of 4 measured;" is a pixel or two wider than the card, so the head, the
98
+ # metric count and the tests left out take a line each; no reason may break across lines
99
+ refactoring = gauges_readable(red_report, view, max_lines=3)
100
+ assert re.fullmatch(r"partial: 0 of 4 measured; \d+ tests not green", refactoring["status"]["text"]), refactoring["status"]
101
+ # a lone "0 of 3 metrics measured" of a pillar the red suite leaves whole may flow as text
102
+ for g in (g for g in red_report[view]["gauges"] if "green" in g["status"]["text"]):
103
+ assert all(n == 1 for n in g["reasons"]), f"a reason breaks across lines at {view}: {g['status']['text']} {g['reasons']}"
104
+
105
+
106
+ @pytest.mark.parametrize("view, least", [("desktop", 32), ("narrow", 44)])
107
+ def test_the_overlap_pager_buttons_are_tall_enough_to_tap(report, view, least):
108
+ for button, height in report[view]["pager_heights"].items():
109
+ assert height >= least, f"{button} is {height} px tall at {view}, under {least}"
69
110
 
70
111
 
71
112
  @pytest.mark.parametrize("view", ["desktop", "narrow"])
@@ -6,6 +6,8 @@ import pytest
6
6
  sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
7
7
 
8
8
  from weigh_rules import load # noqa: E402
9
+ from weigh_coverage import left_out, valued, value_kind # noqa: E402
10
+ from weigh_dashboard import left_out_line, pillar_status # noqa: E402
9
11
  from weigh_score import feedback_values, score # noqa: E402
10
12
 
11
13
 
@@ -17,10 +19,59 @@ def test_tests_over_10s_is_a_percentage_of_all_tests():
17
19
  def test_without_mutation_regression_uses_the_partial_weights():
18
20
  # coverage 90 scores 90 and 10% hollow tests score 10: .60 * 90 + .40 * 10
19
21
  metrics, pillars = score(load(), {"branch_coverage": 90, "hollow_tests": 10})
20
- assert pillars["regression"] == {"score": pytest.approx(58), "partial": True}
22
+ assert pillars["regression"] == {"score": pytest.approx(58), "partial": True, "red_suite": False}
21
23
 
22
24
 
23
25
  def test_a_pillar_without_partial_weights_keeps_its_weights():
24
26
  values = {"total_runtime": 60, "p95_duration": 2, "slowest_decile_share": 40, "tests_over_10s": 2}
25
27
  _, pillars = score(load(), values)
26
- assert pillars["feedback"] == {"score": pytest.approx(.4 * 90 + .3 * 10 + .15 * 90 + .15 * 10), "partial": False}
28
+ assert pillars["feedback"] == {"score": pytest.approx(.4 * 90 + .3 * 10 + .15 * 90 + .15 * 10), "partial": False, "red_suite": False}
29
+
30
+
31
+ def test_a_red_suite_leaves_only_the_pillars_with_a_value_metric_partial_and_says_so():
32
+ values = {"total_runtime": 60, "p95_duration": 2, "slowest_decile_share": 40, "tests_over_10s": 2}
33
+ _, pillars = score(load(), values, red=True)
34
+ assert pillars["regression"]["partial"] and pillars["regression"]["red_suite"]
35
+ assert not pillars["feedback"]["partial"] and not pillars["feedback"]["red_suite"]
36
+
37
+
38
+ def t(outcome, flaky=False):
39
+ return {"outcome": outcome, "flaky": flaky}
40
+
41
+
42
+ def test_left_out_names_each_kind_of_test_that_gives_no_value():
43
+ assert left_out({"a": t("passed")}) == []
44
+ one = left_out({"a": t("skipped"), "b": t("passed")})
45
+ assert left_out_line(one) == "1 test skipped"
46
+ mixed = left_out({"a": t("failed"), "b": t("failed", flaky=True), "c": t("skipped"), "d": t("passed", flaky=True)})
47
+ assert left_out_line(mixed) == "2 tests failing, 1 skipped, 1 flaky"
48
+
49
+
50
+ @pytest.mark.parametrize("outcome", ["passed", "failed", "skipped", "error", "xfail"])
51
+ @pytest.mark.parametrize("flaky", [False, True])
52
+ def test_a_test_that_gives_no_value_is_always_named_left_out(outcome, flaky):
53
+ # a red suite (some test not valued) must have a kind to name, or a gauge would read "0 tests not green"
54
+ tests = {"ok": t("passed"), "x": t(outcome, flaky)}
55
+ kinds = left_out(tests)
56
+ assert sum(n for n, _ in kinds) == len(tests) - len(valued(tests))
57
+ assert bool(kinds) == (value_kind(tests["x"]) != "valued")
58
+
59
+
60
+ def _status(tests, measured, red):
61
+ """pillar_status of one pillar with 4 metrics, 2 of them value metrics, `measured` of them measured."""
62
+ ids = ["branch_coverage", "mutation_score", "a", "b"]
63
+ rules = {"pillars": {"p": {"metrics": {i: {"name": i.replace("_", " ").capitalize()} for i in ids}}}}
64
+ data = {"tests": tests, "metrics": {i: {} for i in ids[:measured]},
65
+ "pillars": {"p": {"partial": red or measured < 4, "red_suite": red}}}
66
+ return pillar_status(data, rules)["p"]
67
+
68
+
69
+ def test_the_status_says_why_a_pillar_is_partial():
70
+ one = {"a": t("skipped"), "b": t("passed")}
71
+ mixed = {"a": t("failed"), "b": t("failed", flaky=True), "c": t("skipped"), "d": t("passed", flaky=True)}
72
+ assert _status(one, 4, True)["reasons"] == ["1 test skipped"]
73
+ assert _status(mixed, 0, True)["reasons"] == ["0 of 4 measured", "4 tests not green"]
74
+ assert _status(mixed, 2, False) == {"head": "partial:", "reasons": ["2 of 4 metrics measured"], "note": None}
75
+ assert _status({"a": t("passed")}, 4, False) == {"head": "all 4 metrics measured", "reasons": [], "note": None}
76
+ assert _status(mixed, 4, True)["note"] == ("Partial: Branch coverage and Mutation score count only the tests that passed "
77
+ "in both the plain and the coverage run. Left out: 2 tests failing, 1 skipped, 1 flaky.")
@@ -9,7 +9,7 @@ from pathlib import Path
9
9
  sys.path.insert(0, str(Path(__file__).resolve().parent))
10
10
 
11
11
  from weigh_env import SetupError, build_overlay, check_versions, find_interpreter
12
- from weigh_coverage import branch_percent, overlaps, per_test, test_file_sources, unique_coverage, valued
12
+ from weigh_coverage import branch_percent, left_out, overlaps, per_test, test_file_sources, unique_coverage, valued
13
13
  from weigh_git import brittle_percent, brittleness, is_repo
14
14
  from weigh_dashboard import summary, write_dashboard
15
15
  from weigh_inventory import count_lines
@@ -105,7 +105,7 @@ def main(argv=None):
105
105
  test_files = brittleness(repo, test_file_sources(tests))
106
106
  measure("brittle_test_files", brittle_percent(test_files),
107
107
  "no source file maps to a test file" if is_repo(repo) else "no git history")
108
- metrics, pillars = score(rules, values, red=len(passing) < len(tests))
108
+ metrics, pillars = score(rules, values, red=bool(left_out(tests)))
109
109
  data = {
110
110
  "commit": commit,
111
111
  "dirty": dirty,
@@ -1,6 +1,7 @@
1
1
  """Read `coverage json --show-contexts` into per-test coverage, and derive unique coverage and overlaps."""
2
2
  import os
3
3
  import re
4
+ from collections import Counter
4
5
  from itertools import combinations
5
6
 
6
7
  from weigh_inventory import is_test
@@ -60,9 +61,28 @@ def branch_percent(report):
60
61
  return 100 * totals["covered_branches"] / totals["num_branches"]
61
62
 
62
63
 
64
+ # Why a test gives no value, in the order the report names them
65
+ NO_VALUE = ("failing", "skipped", "flaky")
66
+
67
+
68
+ def value_kind(test):
69
+ """"valued" when a test passed in the plain run and the same under coverage, else why it gives no value: "failing"
70
+ (flaky or not), "skipped", or "flaky" (passed, then differed under coverage). The one definition of a test's value."""
71
+ if test["outcome"] == "passed":
72
+ return "flaky" if test["flaky"] else "valued"
73
+ return "skipped" if test["outcome"] == "skipped" else "failing"
74
+
75
+
63
76
  def valued(tests):
64
- """The tests that give value: passed in the plain run and the same under coverage, so not flaky."""
65
- return {node: test for node, test in tests.items() if test["outcome"] == "passed" and not test["flaky"]}
77
+ """The tests that give value."""
78
+ return {node: test for node, test in tests.items() if value_kind(test) == "valued"}
79
+
80
+
81
+ def left_out(tests):
82
+ """Each kind of test that gives no value with its count, e.g. [(3, "failing"), (4, "skipped")]; empty exactly when
83
+ every test gives value, so a red suite always has a kind to name."""
84
+ counts = Counter(value_kind(t) for t in tests.values())
85
+ return [(counts[kind], kind) for kind in NO_VALUE if counts[kind]]
66
86
 
67
87
 
68
88
  def _items(test):
@@ -2,8 +2,8 @@
2
2
  import json
3
3
  from pathlib import Path
4
4
 
5
- from weigh_coverage import similarity_map, valued
6
- from weigh_score import display
5
+ from weigh_coverage import left_out, similarity_map, valued, value_kind
6
+ from weigh_score import VALUE_METRICS, display
7
7
  from weigh_smells import PILLAR_SMELLS, pillar_smells, worst_tests
8
8
 
9
9
  TEMPLATE = Path(__file__).resolve().parent / "dashboard.html"
@@ -15,40 +15,80 @@ def inventory_line(inv):
15
15
 
16
16
 
17
17
  def _failing(tests):
18
- return sum(t["outcome"] == "failed" for t in tests.values())
18
+ return sum(value_kind(t) == "failing" for t in tests.values())
19
19
 
20
20
 
21
21
  def _failing_names(tests):
22
- return [n for n, t in tests.items() if t["outcome"] == "failed"]
22
+ return [n for n, t in tests.items() if value_kind(t) == "failing"]
23
23
 
24
24
 
25
25
  def _flaky(tests):
26
+ # every flaky test, a failing one too: this warns about flakiness, left_out about the value a test gives
26
27
  return sum(t.get("flaky", False) for t in tests.values())
27
28
 
28
29
 
30
+ def _tests(n, what):
31
+ return f"{n} {'test' if n == 1 else 'tests'} {what}"
32
+
33
+
34
+ def left_out_line(kinds):
35
+ """Every kind with its count, e.g. "3 tests failing, 4 skipped", for the Metrics tab."""
36
+ return ", ".join([_tests(*kinds[0]), *(f"{n} {kind}" for n, kind in kinds[1:])])
37
+
38
+
39
+ def _names(words):
40
+ return words[0] if len(words) == 1 else ", ".join(words[:-1]) + " and " + words[-1]
41
+
42
+
43
+ def pillar_status(data, rules):
44
+ """{pillar key: status}, the words for how complete each pillar's score is, said the same in the chat summary and
45
+ on the dashboard:
46
+ head "partial:", or "all <n> metrics measured" for a pillar that is not partial
47
+ reasons why it is partial, [] when it is not: how many metrics were measured and the tests a red suite leaves out;
48
+ short enough for two lines of a 150 px gauge, so one kind of test is named and several summed as not green
49
+ note with a red suite, the sentence for the Metrics tab naming the pillar's value metrics and every kind left
50
+ out; None otherwise"""
51
+ kinds = left_out(data["tests"])
52
+ status = {}
53
+ for key, pillar in rules["pillars"].items():
54
+ snap, total = data["pillars"][key], len(pillar["metrics"])
55
+ measured = sum(i in data["metrics"] for i in pillar["metrics"])
56
+ reasons, note = [], None
57
+ if snap["red_suite"]:
58
+ red = left_out_line(kinds) if len(kinds) == 1 else _tests(sum(n for n, _ in kinds), "not green")
59
+ reasons = [f"{measured} of {total} measured", red] if measured < total else [red]
60
+ value = [m["name"] for i, m in pillar["metrics"].items() if i in VALUE_METRICS]
61
+ note = (f"Partial: {_names(value)} {'counts' if len(value) == 1 else 'count'} only the tests that passed in both "
62
+ "the plain and the coverage run. "
63
+ f"Left out: {left_out_line(kinds)}.")
64
+ elif snap["partial"]:
65
+ reasons = [f"{measured} of {total} metrics measured"]
66
+ status[key] = {"head": "partial:" if reasons else f"all {total} metrics measured", "reasons": reasons, "note": note}
67
+ return status
68
+
69
+
29
70
  def _slow(rules):
30
71
  """A test is slow when it takes longer than the target of the p95 test duration."""
31
72
  return rules["pillars"]["feedback"]["metrics"]["p95_duration"]["target"]
32
73
 
33
74
 
34
75
  def write_dashboard(home, data, rules):
35
- failing = _failing(data["tests"])
76
+ failing, status = _failing(data["tests"]), pillar_status(data, rules)
36
77
  page = {
37
78
  "banner": f"{failing} tests are failing" if failing > 1 else "1 test is failing" if failing else None,
38
79
  "failing": _failing_names(data["tests"]),
39
- "skipped": [n for n, t in data["tests"].items() if t["outcome"] == "skipped"],
80
+ "skipped": [n for n, t in data["tests"].items() if value_kind(t) == "skipped"],
40
81
  "insufficient": [n for n, t in data["tests"].items() if t.get("insufficient_evidence")],
41
82
  "overlaps": data.get("overlaps", []),
42
83
  "map": [{**d, "runtime": data["tests"][d["test"]]["duration"], "unique": data["tests"][d["test"]].get("unique_coverage", 0)}
43
84
  for d in similarity_map(valued(data["tests"]))],
44
85
  "inventory": inventory_line(data["inventory"]),
45
86
  "pillars": [
46
- {"key": k, "name": p["name"], **data["pillars"][k],
87
+ {"key": k, "name": p["name"], **data["pillars"][k], "status": status[k],
47
88
  "metrics": [{"name": m["name"], "unit": m["unit"], "target": m["target"], "bad": m["bad"], **data["metrics"][i]}
48
89
  for i, m in p["metrics"].items() if i in data["metrics"]],
49
90
  # an entry the snapshot does not record (older data) has no known cause
50
91
  "missing": [{"name": m["name"], "reason": data.get("unmeasured", {}).get(i)} for i, m in p["metrics"].items() if i not in data["metrics"]],
51
- "total": len(p["metrics"]),
52
92
  "worst": worst_tests(data["tests"], k, _slow(rules)),
53
93
  "smells": pillar_smells(data["tests"], PILLAR_SMELLS.get(k, ()))}
54
94
  for k, p in rules["pillars"].items()
@@ -63,10 +103,11 @@ def write_dashboard(home, data, rules):
63
103
 
64
104
  def summary(data, rules, snapshot, dashboard):
65
105
  lines = [inventory_line(data["inventory"])]
106
+ status = pillar_status(data, rules)
66
107
  for k, p in rules["pillars"].items():
67
- s = data["pillars"][k]
108
+ s, st = data["pillars"][k], status[k]
68
109
  shown = "not measured" if s["score"] is None else str(display(s["score"]))
69
- lines.append(f"{p['name']}: {shown}" + (" (partial)" if s["partial"] else ""))
110
+ lines.append(f"{p['name']}: {shown}" + (f" ({st['head']} {'; '.join(st['reasons'])})" if st["reasons"] else ""))
70
111
  failing, flaky = _failing(data["tests"]), _flaky(data["tests"])
71
112
  if failing:
72
113
  lines.append(f"Warning: {failing} tests are failing" if failing > 1 else "Warning: 1 test is failing")
@@ -33,10 +33,11 @@ VALUE_METRICS = {"mutation_score", "branch_coverage", "pseudo_tested_functions",
33
33
 
34
34
 
35
35
  def score(rules, values, red=False):
36
- """Metrics {id: {value, score}} and pillars {key: {score, partial}}; unmeasured metrics are left out and the weights re-normalized.
36
+ """Metrics {id: {value, score}} and pillars {key: {score, partial, red_suite}}; unmeasured metrics are left out and the weights re-normalized.
37
37
 
38
38
  Without the mutation tier (no mutation_score), a pillar that gives partial weights uses them, and its metrics without one do not count.
39
- With a red suite (a test that gives no value), every pillar using a value metric is partial (req 14)."""
39
+ With a red suite (a test that gives no value), every pillar using a value metric is partial (req 14) and red_suite, so
40
+ the report can say why: a pillar can be partial for a missing metric, a red suite or both."""
40
41
  metrics, pillars = {}, {}
41
42
  for key, pillar in rules["pillars"].items():
42
43
  partial_weights = "mutation_score" not in values and any("partial_weight" in m for m in pillar["metrics"].values())
@@ -49,9 +50,11 @@ def score(rules, values, red=False):
49
50
  if weight:
50
51
  scored.append((weight, s))
51
52
  weight = sum(w for w, _ in scored)
53
+ red_suite = red and bool(VALUE_METRICS & pillar["metrics"].keys())
52
54
  pillars[key] = {
53
55
  "score": sum(w * s for w, s in scored) / weight if weight else None,
54
- "partial": not values.keys() >= pillar["metrics"].keys() or (red and bool(VALUE_METRICS & pillar["metrics"].keys())),
56
+ "partial": not values.keys() >= pillar["metrics"].keys() or red_suite,
57
+ "red_suite": red_suite,
55
58
  }
56
59
  return metrics, pillars
57
60
 
@@ -3,6 +3,7 @@ import ast
3
3
  import copy
4
4
  import hashlib
5
5
 
6
+ from weigh_coverage import value_kind
6
7
  from weigh_inventory import is_test
7
8
 
8
9
  MOCK_ASSERTS = ("assert_called", "assert_any_call", "assert_has_calls", "assert_not_called", "assert_awaited", "assert_not_awaited")
@@ -337,8 +338,8 @@ def _measured(test, pillar, slow):
337
338
  return [f"{test['lines']} lines"], test["lines"]
338
339
  if pillar == "feedback" and test["duration"] > slow:
339
340
  return [f"{test['duration']:.2f} s"], test["duration"]
340
- # unique coverage is measured only for tests that passed unflaky
341
- if pillar == "economy" and test["outcome"] == "passed" and not test["flaky"] and not test.get("unique_coverage", 0):
341
+ # unique coverage is measured only for the tests that give value
342
+ if pillar == "economy" and value_kind(test) == "valued" and not test.get("unique_coverage", 0):
342
343
  return ["No unique coverage"], 0
343
344
  return [], 0
344
345
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-11-05T18:12:03.162Z",
3
+ "generatedAt": "2026-11-06T12:46:06.691Z",
4
4
  "skills": [
5
5
  {
6
6
  "name": "agents-wayfinder",
@@ -10,8 +10,8 @@
10
10
  },
11
11
  {
12
12
  "name": "babysit-pr",
13
- "version": "0.1.3",
14
- "hash": "sha256-cfc51ea1a1ed378c87e4b682bbbf9ecd01a8a5ce1bf4ed89380bb43346ad466f",
13
+ "version": "0.1.4",
14
+ "hash": "sha256-3c1b0a1434a5aaf88139d74899fa9751d639d5135b9ba35ef9f4501e00d5342a",
15
15
  "description": "Babysit an open pull request until it is merged or handed to a human. Started by the PostToolUse hook after `gh pr create`, or by hand with `/babysit-pr <pr-url>`."
16
16
  },
17
17
  {
@@ -58,14 +58,14 @@
58
58
  },
59
59
  {
60
60
  "name": "implement-spec",
61
- "version": "0.1.51",
62
- "hash": "sha256-3ae7ce51a5d74ddd7161016275ff329636448471711b21fcdd742d345f181828",
61
+ "version": "0.1.53",
62
+ "hash": "sha256-912494281639705621cd4290b046ddbc1942ed178c12174a95644dc08f621a0f",
63
63
  "description": "Implement a specification in code."
64
64
  },
65
65
  {
66
66
  "name": "pr-risk",
67
- "version": "0.1.0",
68
- "hash": "sha256-54b54a42738571c346a040326cde2d314d0239dca3ce42323d2b8434dbe9d5f9",
67
+ "version": "0.1.1",
68
+ "hash": "sha256-f67cc22d6c5c14f41a0670f0b9faef17827727c27f36f315c8d1acba5a67a738",
69
69
  "description": "Merge-risk block of a PR body. Use when a PR body needs its ```merge-risk v1 block parsed or validated, with every error named."
70
70
  },
71
71
  {
@@ -106,8 +106,8 @@
106
106
  },
107
107
  {
108
108
  "name": "test-weigh-in",
109
- "version": "0.1.3",
110
- "hash": "sha256-aecabdc7fd3d511440930bdc3274960106fe37959227ae3be7428dd634f8d4eb",
109
+ "version": "0.1.4",
110
+ "hash": "sha256-6e1d9f9c80e518edc7616cbc6770f0cfac174820559b36b1ac3479c92898fbf8",
111
111
  "description": "Measure a Python/pytest suite and score it on five pillars (Protection against regressions, Resistance to refactoring, Fast feedback, Maintainability, Economy), writing a JSON snapshot and a static HTML dashboard. Read-only. Use when the user asks to weigh, measure or score their test suite."
112
112
  },
113
113
  {