@jesdi/skills 0.0.87 → 0.0.88
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.
- package/package.json +1 -1
- package/skills/implement-spec/ARCHITECTURE.md +20 -8
- package/skills/implement-spec/README.md +7 -4
- package/skills/implement-spec/driver_decisions.py +3 -2
- package/skills/implement-spec/driver_dispute.py +82 -57
- package/skills/implement-spec/driver_fixloop.py +18 -21
- package/skills/implement-spec/driver_legacy.py +31 -2
- package/skills/implement-spec/driver_report.py +13 -3
- package/skills/implement-spec/driver_state.py +8 -7
- package/skills/implement-spec/prompts/correction.md +1 -0
- package/skills/implement-spec/prompts/reviewer.md +3 -3
- package/skills/implement-spec/prompts/ruled.md +1 -1
- package/skills/implement-spec/tests/test_arbitration.py +101 -10
- package/skills/implement-spec/tests/test_decisions.py +7 -5
- package/skills/implement-spec/tests/test_fixloop.py +3 -3
- package/skills/implement-spec/tests/test_legacy.py +27 -0
- package/skills/implement-spec/tests/test_state.py +1 -1
- package/skills/test-weigh-in/dashboard.html +70 -17
- package/skills/test-weigh-in/tests/browser_driver.py +46 -5
- package/skills/test-weigh-in/tests/layout_page.py +7 -3
- package/skills/test-weigh-in/tests/overlap_page.py +3 -0
- package/skills/test-weigh-in/tests/rules_fixture.py +1 -1
- package/skills/test-weigh-in/tests/test_coverage_run.py +5 -1
- package/skills/test-weigh-in/tests/test_dashboard_layout.py +50 -9
- package/skills/test-weigh-in/tests/test_score.py +53 -2
- package/skills/test-weigh-in/weigh.py +2 -2
- package/skills/test-weigh-in/weigh_coverage.py +22 -2
- package/skills/test-weigh-in/weigh_dashboard.py +51 -10
- package/skills/test-weigh-in/weigh_score.py +6 -3
- package/skills/test-weigh-in/weigh_smells.py +3 -2
- package/skills-manifest.json +3 -3
|
@@ -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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
53
|
-
|
|
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"] <=
|
|
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
|
|
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=
|
|
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
|
|
65
|
-
return {node: test for node, test in tests.items() if test
|
|
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
|
|
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
|
|
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
|
|
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}" + (" (
|
|
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
|
|
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
|
|
341
|
-
if pillar == "economy" and test
|
|
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
|
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-06T01:48:56.950Z",
|
|
4
4
|
"skills": [
|
|
5
5
|
{
|
|
6
6
|
"name": "agents-wayfinder",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"name": "implement-spec",
|
|
61
|
-
"version": "0.1.
|
|
62
|
-
"hash": "sha256-
|
|
61
|
+
"version": "0.1.52",
|
|
62
|
+
"hash": "sha256-b31df9477b2d36aaf396d4f36c7ee15af10286eb726ed27d214b1858f98a780d",
|
|
63
63
|
"description": "Implement a specification in code."
|
|
64
64
|
},
|
|
65
65
|
{
|