@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.
Files changed (31) hide show
  1. package/package.json +1 -1
  2. package/skills/implement-spec/ARCHITECTURE.md +20 -8
  3. package/skills/implement-spec/README.md +7 -4
  4. package/skills/implement-spec/driver_decisions.py +3 -2
  5. package/skills/implement-spec/driver_dispute.py +82 -57
  6. package/skills/implement-spec/driver_fixloop.py +18 -21
  7. package/skills/implement-spec/driver_legacy.py +31 -2
  8. package/skills/implement-spec/driver_report.py +13 -3
  9. package/skills/implement-spec/driver_state.py +8 -7
  10. package/skills/implement-spec/prompts/correction.md +1 -0
  11. package/skills/implement-spec/prompts/reviewer.md +3 -3
  12. package/skills/implement-spec/prompts/ruled.md +1 -1
  13. package/skills/implement-spec/tests/test_arbitration.py +101 -10
  14. package/skills/implement-spec/tests/test_decisions.py +7 -5
  15. package/skills/implement-spec/tests/test_fixloop.py +3 -3
  16. package/skills/implement-spec/tests/test_legacy.py +27 -0
  17. package/skills/implement-spec/tests/test_state.py +1 -1
  18. package/skills/test-weigh-in/dashboard.html +70 -17
  19. package/skills/test-weigh-in/tests/browser_driver.py +46 -5
  20. package/skills/test-weigh-in/tests/layout_page.py +7 -3
  21. package/skills/test-weigh-in/tests/overlap_page.py +3 -0
  22. package/skills/test-weigh-in/tests/rules_fixture.py +1 -1
  23. package/skills/test-weigh-in/tests/test_coverage_run.py +5 -1
  24. package/skills/test-weigh-in/tests/test_dashboard_layout.py +50 -9
  25. package/skills/test-weigh-in/tests/test_score.py +53 -2
  26. package/skills/test-weigh-in/weigh.py +2 -2
  27. package/skills/test-weigh-in/weigh_coverage.py +22 -2
  28. package/skills/test-weigh-in/weigh_dashboard.py +51 -10
  29. package/skills/test-weigh-in/weigh_score.py +6 -3
  30. package/skills/test-weigh-in/weigh_smells.py +3 -2
  31. package/skills-manifest.json +3 -3
@@ -9,7 +9,7 @@ Test-writer report, when the ticket has a test-writer: {writer_report}
9
9
 
10
10
  Check the diff against the ticket and the spec. Put only an unmet ticket criterion or a regression of a merged ticket's behavior in `findings`; set `basis` to `criterion` or `regression` accordingly; put every other observation in `observations` for final review. A red gate is a finding made by the driver. Check that each criterion has a locked test. Test each suspicion that the ticket names in its Suspicions line.
11
11
  {risk}
12
- Give each finding and observation a severity (critical, important or minor), the file and line, a title, the evidence, and a kind: `fixture` when a locked test encodes a stale path, format or setup detail; `test` when a test is weak or missing; `code` for anything else. The test-writer corrects each `fixture` finding and each critical or important `test` finding on a locked file, and the fixer gets the rest.
12
+ Give each finding and observation a severity (critical, important or minor), the file and line, a title, the evidence, and a kind: `fixture` when a locked test encodes a stale path, format or setup detail; `test` when a test is weak or missing; `code` for anything else. When a `fixture` or `test` finding is on a locked test that exists, give its id `<locked file>::<test>` in `test`; leave `test` out when the finding asks for a test that is missing. The test-writer corrects each `fixture` finding and each critical or important `test` finding on a locked file, and the fixer gets the rest.
13
13
  Do not commit and do not dispatch subagents. Leave the tree as you found it.
14
14
 
15
15
  Write one JSON report at {report}. When your sandbox is read-only, give the JSON as your whole final message and the driver saves it there. The report matches this schema:
@@ -22,9 +22,9 @@ Write one JSON report at {report}. When your sandbox is read-only, give the JSON
22
22
  "status": {"enum": ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"]},
23
23
  "files": {"type": "array", "items": {"type": "string"}},
24
24
  "concerns": {"type": "array", "items": {"type": "string"}},
25
- "findings": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}, "basis": {"enum": ["criterion", "regression"]}}}},
25
+ "findings": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}, "test": {"type": "string", "minLength": 1}, "basis": {"enum": ["criterion", "regression"]}}}},
26
26
  "observations": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}}}},
27
- "regressions": {"description": "After a fix: new regressions introduced by that fix. Set basis to criterion when a ticket criterion fails, or regression when merged-ticket behavior fails.", "type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}, "basis": {"enum": ["criterion", "regression"]}}}}
27
+ "regressions": {"description": "After a fix: new regressions introduced by that fix. Set basis to criterion when a ticket criterion fails, or regression when merged-ticket behavior fails.", "type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}, "test": {"type": "string", "minLength": 1}, "basis": {"enum": ["criterion", "regression"]}}}}
28
28
  }
29
29
  }
30
30
  ```
@@ -1,3 +1,3 @@
1
1
 
2
2
  The reviewer ruled on locked tests of this ticket that an earlier attempt disputed:
3
- {rulings}A test ruled `test-wrong` was corrected by the test-writer, and a test ruled `code-wrong` stands. Each locked test stands as the branch has it now: make it green. A second dispute on one of these test files goes to the operator as a question of the spec.
3
+ {rulings}A test ruled `test-wrong` was corrected by the test-writer, and a test ruled `code-wrong` stands. Each locked test stands as the branch has it now: make it green. A second dispute on one of these tests goes to the operator as a question of the spec.
@@ -73,9 +73,9 @@ def test_a_test_ruled_wrong_gets_one_correction_with_the_ruling_then_the_impleme
73
73
  assert ".agent/implement/01/ruled-1.json" in fixed["prompt"] and again["head"] == fixed["sha"]
74
74
  assert "R3 says single quotes" in again["prompt"]
75
75
  entry = rig.state()["tickets"]["01"]
76
- assert entry["disputes"]["tests/test_01.py"]["ruling"] == "test-wrong" and entry["test_writer_sha"] == fixed["sha"]
77
- assert entry["corrected"] == {"tests/test_01.py": {"test": TEST, "requirement": "R3",
78
- "reason": "R3 says single quotes"}}
76
+ assert entry["disputes"][TEST]["ruling"] == "test-wrong" and entry["test_writer_sha"] == fixed["sha"]
77
+ assert entry["corrected"] == {TEST: {"test": TEST, "requirement": "R3", "reason": "R3 says single quotes"}}
78
+ assert entry["settled"] == 1
79
79
  assert rig.led("the reviewer ruled test-wrong on the locked test tests/test_01.py::test_x, R3")
80
80
 
81
81
 
@@ -116,7 +116,7 @@ def test_a_dispute_on_another_locked_file_is_arbitrated_too(tmp_path):
116
116
  ruling("code-wrong", "R4 says y is a column", f"{OTHER}::test_y", "R4"),
117
117
  review("01")]})
118
118
  assert rig.code == 0 and not rig.state()["run"]["questions"], rig.ledger()
119
- assert len(arbitrations(rig)) == 2 and set(rig.state()["tickets"]["01"]["disputes"]) == {"tests/test_01.py", OTHER}
119
+ assert len(arbitrations(rig)) == 2 and set(rig.state()["tickets"]["01"]["disputes"]) == {TEST, f"{OTHER}::test_y"}
120
120
  assert (rig.folder() / "arbitration-2.json").exists()
121
121
 
122
122
 
@@ -182,7 +182,7 @@ def test_a_second_dispute_on_the_same_test_asks_spec_ambiguous_with_both_reading
182
182
 
183
183
 
184
184
  def test_after_a_correction_a_review_finding_on_the_test_asks_spec_ambiguous(tmp_path):
185
- stale = finding("STALE", kind="fixture", file="tests/test_01.py")
185
+ stale = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": TEST}
186
186
  rig = run(tmp_path, {"01/implementer": [disputes(), impl("01")], "01/test-writer": [tw("01"), correction()],
187
187
  "01/reviewer": [ruling("test-wrong", "R3 says single quotes"), review("01", [stale])]})
188
188
  assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 2, rig.ledger()
@@ -192,7 +192,7 @@ def test_after_a_correction_a_review_finding_on_the_test_asks_spec_ambiguous(tmp
192
192
 
193
193
 
194
194
  def test_a_test_ruled_wrong_that_a_review_corrected_before_asks_spec_ambiguous(tmp_path):
195
- stale = finding("STALE", kind="fixture", file="tests/test_01.py")
195
+ stale = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": TEST}
196
196
  rig = run(tmp_path, {"01/test-writer": [tw("01"), correction()],
197
197
  "01/reviewer": [review("01", [stale, STUCK]), ruling("test-wrong", "R3 says single quotes")],
198
198
  "01/fixer": [disputes(role="fixer")]})
@@ -203,18 +203,109 @@ def test_a_test_ruled_wrong_that_a_review_corrected_before_asks_spec_ambiguous(t
203
203
 
204
204
 
205
205
  def test_a_ruling_that_asks_spec_ambiguous_is_kept_so_a_dispute_after_keep_test_is_not_arbitrated_again(tmp_path):
206
- stale = finding("STALE", kind="fixture", file="tests/test_01.py")
206
+ stale = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": TEST}
207
207
  steps = plan(**{"01/test-writer": [tw("01"), correction()],
208
208
  "01/reviewer": [review("01", [stale, STUCK]), ruling("test-wrong", "R3 says single quotes"),
209
209
  review("01", [STUCK]), ruling("test-wrong", "R3 says single quotes")],
210
210
  "01/fixer": [disputes(role="fixer"), disputes(role="fixer")]})
211
211
  rig = Inside(tmp_path, ONE).run(steps)
212
- assert rig.state()["tickets"]["01"]["disputes"]["tests/test_01.py"]["ruling"] == "test-wrong", rig.ledger()
212
+ assert rig.state()["tickets"]["01"]["disputes"][TEST]["ruling"] == "test-wrong", rig.ledger()
213
213
  rig.run(steps, "--answer", f"{AMBIGUOUS}=keep-test")
214
214
  assert rig.code == 2 and len(arbitrations(rig)) == 1, rig.ledger()
215
215
  assert [q["id"] for q in asked(rig)] == ["01-spec-ambiguous-2"]
216
216
 
217
217
 
218
+ # ---------------------------------------------------------------- per test, not per file
219
+
220
+ TEST_Y = "tests/test_01.py::test_y"
221
+
222
+
223
+ def test_a_dispute_of_another_test_in_a_corrected_file_is_arbitrated_and_corrected_with_no_question(tmp_path):
224
+ """The cv-tailoring run asked 02-spec-ambiguous-1 here: test_x was corrected, then test_y of its file disputed."""
225
+ rig = run(tmp_path, {"01/implementer": [disputes(), disputes((TEST_Y, "a dict has no .body")), impl("01")],
226
+ "01/test-writer": [tw("01"), correction(), correction(CORRECTED + "def test_y():\n pass\n")],
227
+ "01/reviewer": [ruling("test-wrong", "R3 says single quotes"),
228
+ ruling("test-wrong", "a dict has no .body", TEST_Y, "R5"), review("01")]})
229
+ assert rig.code == 0 and not rig.state()["run"]["questions"], rig.ledger()
230
+ assert roles(rig) == ["test-writer", "implementer", "arbitration", "test-writer", "implementer", "arbitration",
231
+ "test-writer", "implementer", "reviewer"]
232
+ entry = rig.state()["tickets"]["01"]
233
+ assert set(entry["disputes"]) == set(entry["corrected"]) == {TEST, TEST_Y}
234
+
235
+
236
+ WEAK_Y = {**finding("WEAK", "critical", kind="test", file="tests/test_01.py"), "test": TEST_Y}
237
+
238
+
239
+ @pytest.mark.parametrize("found", [finding("MISSING", "critical", kind="test", file="tests/test_01.py"), WEAK_Y],
240
+ ids=["missing-test", "another-test"])
241
+ def test_a_review_finding_after_a_correction_of_another_test_gets_a_correction_with_no_question(tmp_path, found):
242
+ """The cv-tailoring run asked 01-spec-ambiguous-2 here: a review asked for missing tests in a corrected file."""
243
+ rig = run(tmp_path, {"01/implementer": [disputes(), impl("01")],
244
+ "01/test-writer": [tw("01"), correction(), correction(CORRECTED + "def test_z():\n pass\n")],
245
+ "01/reviewer": [ruling("test-wrong", "R3 says single quotes"), review("01", [found]),
246
+ review("01")]})
247
+ assert rig.code == 0 and not rig.state()["run"]["questions"], rig.ledger()
248
+ assert roles(rig) == ["test-writer", "implementer", "arbitration", "test-writer", "implementer", "reviewer",
249
+ "test-writer", "reviewer"]
250
+
251
+
252
+ def missing(n):
253
+ """A review finding that asks for the missing test `n` of tests/test_01.py."""
254
+ return finding(f"MISSING-{n}", "critical", kind="test", file="tests/test_01.py")
255
+
256
+
257
+ def test_the_ticket_asks_spec_ambiguous_once_its_locked_tests_were_settled_three_times(tmp_path):
258
+ """A test added is never corrected twice, so a cap bounds the review that keeps asking for one more."""
259
+ steps = {"01/test-writer": [tw("01"), *[correction(f"# added {n}\n") for n in range(1, 4)]],
260
+ "01/reviewer": [review("01", [missing(n)]) for n in range(1, 5)] + [review("01")]}
261
+ rig = run(tmp_path, steps)
262
+ assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 4, rig.ledger()
263
+ (question,) = asked(rig)
264
+ assert question["id"] == AMBIGUOUS and "3 times" in question["subject"] and "MISSING-4" in question["subject"]
265
+ assert rig.state()["tickets"]["01"]["settled"] == 3
266
+
267
+
268
+ def test_disputes_of_new_tests_reach_the_cap_too_and_the_next_one_asks_with_no_arbitration(tmp_path):
269
+ names = ["test_x", "test_y", "test_z", "test_w"]
270
+ rig = run(tmp_path, {"01/implementer": [disputes((f"tests/test_01.py::{name}", "no")) for name in names],
271
+ "01/reviewer": [ruling("code-wrong", "R3 holds", f"tests/test_01.py::{name}")
272
+ for name in names[:3]]})
273
+ assert rig.code == 2 and len(arbitrations(rig)) == 3, rig.ledger()
274
+ (question,) = asked(rig)
275
+ assert "tests/test_01.py::test_w" in question["subject"] and "3 times" in question["subject"]
276
+ assert rig.state()["tickets"]["01"]["settled"] == 3
277
+
278
+
279
+ def test_a_missing_test_asked_for_again_after_its_correction_asks_spec_ambiguous(tmp_path):
280
+ rig = run(tmp_path, {"01/test-writer": [tw("01"), correction("# added\n")],
281
+ "01/reviewer": [review("01", [missing(1)])] * 2})
282
+ assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 2, rig.ledger()
283
+ (question,) = asked(rig)
284
+ subject = question["subject"]
285
+ assert "the first reading: MISSING-1" in subject and "the second reading: MISSING-1" in subject
286
+
287
+
288
+ def test_a_fixture_finding_that_names_no_test_is_corrected_once_per_file(tmp_path):
289
+ stale = finding("STALE", kind="fixture", file="tests/test_01.py")
290
+ rig = run(tmp_path, {"01/test-writer": [tw("01"), correction("# fixed\n")],
291
+ "01/reviewer": [review("01", [stale])] * 2})
292
+ assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 2, rig.ledger()
293
+ assert [q["id"] for q in asked(rig)] == [AMBIGUOUS]
294
+
295
+
296
+ def test_keep_test_on_a_missing_test_closes_that_request_only(tmp_path):
297
+ steps = plan(**{"01/test-writer": [tw("01"), *[correction(f"# added {n}\n") for n in range(1, 4)]],
298
+ "01/reviewer": [review("01", [missing(n)]) for n in range(1, 5)] +
299
+ [review("01", [missing(4), WEAK_Y])]})
300
+ rig = Inside(tmp_path, ONE).run(steps)
301
+ assert [q["id"] for q in asked(rig)] == [AMBIGUOUS], rig.ledger()
302
+ rig.run(steps, "--answer", f"{AMBIGUOUS}=keep-test")
303
+ assert rig.code == 2 and rig.led("MISSING-4", "closed as it is by the ruling (keep-test)"), rig.ledger()
304
+ (question,) = asked(rig)
305
+ assert question["id"] == "01-spec-ambiguous-2" and "WEAK" in question["subject"]
306
+ assert "MISSING-4" not in question["subject"]
307
+
308
+
218
309
  # ---------------------------------------------------------------- the answers
219
310
 
220
311
  def test_keep_test_runs_the_implementer_again_and_keeps_the_record(tmp_path):
@@ -243,7 +334,7 @@ def test_correct_test_corrects_to_the_second_reading_then_the_implementer_runs_a
243
334
  assert wanted["evidence"] == "correct the test to the second reading: the example in R3 uses '"
244
335
  assert rig.calls("01", "implementer")[2]["head"] == fixed["sha"]
245
336
  assert [q["id"] for q in asked(rig)] == ["01-spec-ambiguous-2"]
246
- assert set(rig.state()["tickets"]["01"]["disputes"]) == {"tests/test_01.py"}
337
+ assert set(rig.state()["tickets"]["01"]["disputes"]) == {TEST}
247
338
 
248
339
 
249
340
  def test_correct_test_after_a_fixer_s_dispute_runs_the_fixer_of_that_round_again_after_the_correction(tmp_path):
@@ -271,7 +362,7 @@ def test_edit_spec_keeps_the_ticket_blocked_with_the_ruling_and_runs_no_agent(tm
271
362
 
272
363
 
273
364
  def test_keep_test_on_a_review_finding_closes_it_and_the_ticket_goes_on(tmp_path):
274
- stale = finding("STALE", kind="fixture", file="tests/test_01.py")
365
+ stale = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": TEST}
275
366
  steps = plan(**{"01/test-writer": [tw("01"), correction()], "01/fixer": [fix("01", 1)],
276
367
  "01/reviewer": [review("01", [stale]), review("01", [stale]), review("01", [stale, STUCK]),
277
368
  review("01")]})
@@ -10,6 +10,7 @@ import driver_answers
10
10
  import driver_decisions
11
11
  import driver_report
12
12
  import driver_review_page
13
+ import driver_state
13
14
  from test_cli import git, ticket
14
15
  from test_fixloop import Inside, inside # noqa: F401 (the autouse fixture puts the rig's CLIs on PATH)
15
16
  from test_tidy import Inside as Pushing, tools # noqa: F401 (an unattended run pushes: the rig with an origin and a fake gh)
@@ -141,7 +142,7 @@ def as_schema_3(rig, **question):
141
142
  """Make the run of `rig` one that a schema 3 driver left, its one question changed by `question`."""
142
143
  path = rig.repo / ".agent/implement/state.json"
143
144
  state = json.loads(path.read_text())
144
- assert state["run"]["schema"] == 4, "a new run writes schema 4"
145
+ assert state["run"]["schema"] == driver_state.SCHEMA, "a new run writes the current schema"
145
146
  state["run"]["schema"] = 3
146
147
  state["run"]["questions"][0].update(question)
147
148
  path.write_text(json.dumps(state))
@@ -167,7 +168,7 @@ def test_an_older_run_keeps_the_ruling_of_an_answered_question_of_a_removed_kind
167
168
  state["tickets"]["01"]["phase"] = "implement" # what the older driver's `retry` did
168
169
  (rig.repo / ".agent/implement/state.json").write_text(json.dumps(state))
169
170
  rig.run(run, *UNATTENDED)
170
- assert rig.code == 0 and rig.state()["run"]["schema"] == 4, rig.ledger()
171
+ assert rig.code == 0 and rig.state()["run"]["schema"] == driver_state.SCHEMA, rig.ledger()
171
172
  sentence = f"Ruling: 01 review runs again (retry): the implementer: it reported BLOCKED: {STOP}." # the older driver's
172
173
  assert f"## Rulings\n\n- {sentence}\n" in rig.prs()[0]["body"]
173
174
  assert rig.state()["run"]["questions"][0]["ruling"] == sentence
@@ -230,9 +231,10 @@ def test_only_an_implementer_or_a_fixer_blocked_on_the_contradiction_concern_dis
230
231
  f"{contra} test_01.py::test_x[a]: R3", f"{contra} b::c", contra]}
231
232
  locked = ["tests/test_01.py", "src/test_01.py", "tests/b"]
232
233
  assert driver_report.disputes("fixer", report, locked) == [
233
- ("tests/test_01.py", "tests/test_01.py::test_x", "why"), ("", "test_01.py::test_x[a]", "R3"),
234
- ("tests/b", "b::c", ""), ("", "", "")]
235
- assert driver_report.disputes("fixer", report, locked[:1])[1] == ("tests/test_01.py", "test_01.py::test_x[a]", "R3")
234
+ ("tests/test_01.py", "tests/test_01.py::test_x", "why", "tests/test_01.py::test_x"),
235
+ ("", "test_01.py::test_x[a]", "R3", "::test_x"), ("tests/b", "b::c", "", "tests/b::c"), ("", "", "", "")]
236
+ assert driver_report.disputes("fixer", report, locked[:1])[1] == (
237
+ "tests/test_01.py", "test_01.py::test_x[a]", "R3", "tests/test_01.py::test_x")
236
238
  assert driver_report.disputes("reviewer", report, locked) == []
237
239
  assert driver_report.disputes("implementer", {**report, "status": "DONE"}, locked) == []
238
240
  assert driver_report.disputes("implementer", {}, locked) == [], "a rejected report is no report"
@@ -132,7 +132,7 @@ def test_capped_regression_is_carried_through_the_final_fix_batch(tmp_path):
132
132
 
133
133
  # ---------------------------------------------------------------- the locked files
134
134
 
135
- STALE = finding("STALE", kind="fixture", file="tests/test_01.py")
135
+ STALE = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": "tests/test_01.py::test_x"}
136
136
  AMBIGUOUS_1 = "01-spec-ambiguous-1"
137
137
 
138
138
 
@@ -154,8 +154,8 @@ def test_a_locked_test_finding_that_comes_back_after_its_correction_asks_spec_am
154
154
  "01/reviewer": [review("01", [STALE])] * 2 + [review("01")]})
155
155
  rig = Inside(tmp_path).run(steps)
156
156
  assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
157
- assert rig.led("BLOCKED at the review: the spec reads two ways on a locked test: tests/test_01.py: the first "
158
- "reading: STALE: STALE; the second reading: STALE: STALE.")
157
+ assert rig.led("BLOCKED at the review: the spec reads two ways on a locked test: tests/test_01.py::test_x: the "
158
+ "first reading: STALE: STALE; the second reading: STALE: STALE.")
159
159
  assert asked(rig) == {AMBIGUOUS_1: ["keep-test", "correct-test", "edit-spec"]}
160
160
  (question,) = rig.state()["run"]["questions"]
161
161
  assert question["recommended"] == "" and question["evidence"][0] == ".agent/implement/01/spec-ambiguous-1.json"
@@ -1,6 +1,8 @@
1
1
  """The names of a run, and the take-over of a run that an older driver started (driver_names, driver_legacy)."""
2
+ import json
2
3
  import subprocess
3
4
 
5
+ import driver_dispute
4
6
  import driver_legacy
5
7
  import driver_state
6
8
  from conftest import GIT
@@ -137,3 +139,28 @@ def test_the_lock_of_an_older_driver_is_shared_by_newer_drivers_and_excludes_an_
137
139
  f"a driver of an older version runs in this repository: it holds the lock {tmp_path / 'implement-spec.lock'}. "
138
140
  "Wait until it ends, then run the driver again."))
139
141
  older.close()
142
+
143
+
144
+ def test_resume_keys_the_rulings_and_corrections_of_a_schema_4_run_by_their_test(repo, tmp_path):
145
+ """Schema 4 keyed them by the locked file; each record names its test, so the key moves to that test. A review
146
+ correction recorded only its file and is keyed by it, as a fixture finding that names no test is. The evidence
147
+ of each `spec-ambiguous` question of the ticket gets the key of its file's record, which `keep-test` closes."""
148
+ state, _, _ = older_run(repo, tmp_path)
149
+ ruled = {"test": "test_01.py::test_x[a]", "requirement": "R3", "ruling": "test-wrong", "reason": "r"}
150
+ by_file = {"test": "tests/test_02.py", "requirement": "", "reason": "STALE"}
151
+ evidence = tmp_path / ".agent/implement/01/spec-ambiguous-1.json"
152
+ evidence.parent.mkdir(parents=True, exist_ok=True)
153
+ evidence.write_text(json.dumps([{"file": "tests/test_01.py", "title": "t"}, {"file": "tests/test_02.py"}]))
154
+ question = {"ticket": "01", "kind": "spec-ambiguous", "answer": "keep-test", "evidence": [str(evidence)],
155
+ "subject": "s"}
156
+ gone = {**question, "evidence": [str(tmp_path / "gone.json")]}
157
+ edit(state, {"disputes": {"tests/test_01.py": ruled},
158
+ "corrected": {"tests/test_01.py": ruled, "tests/test_02.py": by_file}}, questions=[question, gone])
159
+ assert resume(state, tmp_path)[0] == []
160
+ entry = state.read()["tickets"]["01"]
161
+ assert entry["disputes"] == {"tests/test_01.py::test_x": ruled}
162
+ assert entry["corrected"] == {"tests/test_01.py::test_x": ruled, "tests/test_02.py": by_file}
163
+ assert entry["settled"] == 2 # one per record of schema 4: each was an arbitration or a correction
164
+ assert [one["key"] for one in json.loads(evidence.read_text())] == ["tests/test_01.py::test_x", "tests/test_02.py"]
165
+ assert driver_dispute.kept(state.read()["run"]["questions"][:1], "01") == {"tests/test_01.py::test_x",
166
+ "tests/test_02.py"}
@@ -42,7 +42,7 @@ def test_start_keeps_a_recorded_run_and_adds_only_the_new_tickets(tmp_path):
42
42
  assert again["tickets"]["01"]["phase"] == "merged" and again["tickets"]["01"]["landing"] is None
43
43
  assert again["tickets"]["02"] == {
44
44
  "phase": "pending", "round": 0, "tip": None, "test_writer_sha": None, "locked": [], "green_gates": {"fast": [], "full": []}, "slot": None,
45
- "note": "", "landing": None, "disputes": {}, "corrected": {}}
45
+ "note": "", "landing": None, "disputes": {}, "corrected": {}, "settled": 0}
46
46
 
47
47
 
48
48
  def test_verified_trusts_a_tip_only_while_it_is_on_the_ticket_branch(repo, tmp_path):
@@ -6,11 +6,16 @@ body{font:14px system-ui,sans-serif;margin:24px;color:#222;overflow-wrap:break-w
6
6
  .gauge{grid-row:span 3;display:grid;grid-template-rows:subgrid;row-gap:4px;align-content:start;margin-bottom:12px;border:2px solid #ccc;border-radius:8px;padding:12px;background:#fff;text-align:center;cursor:pointer;font:inherit}
7
7
  .gauge>*{align-self:start}
8
8
  .gauge-status{font-size:12px;line-height:1.3}
9
+ /* with a red suite, each short reason wraps inside only when it alone is wider than the card, so a line never splits
10
+ "172 tests not green"; a lone "0 of 4 metrics measured" flows as text */
11
+ .gauge-status.red>span{display:inline-block}
9
12
  /* one row of tabs on a rule; it scrolls sideways when the row is wider than the screen */
10
13
  .tabs{display:flex;gap:4px;overflow-x:auto;border-bottom:1px solid #ccc;scrollbar-width:thin}
11
- .tabs>button{flex:none;font:inherit;padding:4px 12px;border:1px solid #ccc;border-bottom:3px solid transparent;border-radius:6px 6px 0 0;background:#f3f4f6;color:#222;cursor:pointer;white-space:nowrap}
14
+ .tabs>button{flex:none;display:inline-flex;flex-direction:column;align-items:center;font:inherit;padding:4px 12px;border:1px solid #ccc;border-bottom:3px solid transparent;border-radius:6px 6px 0 0;background:#f3f4f6;color:#222;cursor:pointer;white-space:nowrap}
12
15
  .tabs>button[aria-pressed=true]{background:#2563eb;color:#fff;border-bottom-color:#1e40af;font-weight:600}
13
- @media (max-width:600px){.tabs{gap:2px}.tabs>button{padding:4px 7px}}
16
+ /* every tab is as wide as its bold label, so selecting one moves no other; hidden, so screen readers skip it */
17
+ .tabs>button::after{content:attr(data-label);content:attr(data-label)/"";font-weight:600;height:0;overflow:hidden;visibility:hidden;pointer-events:none}
18
+ @media (max-width:600px){.tabs{gap:2px}.tabs>button{padding:4px 6px}}
14
19
  button:focus-visible{outline:3px solid #f59e0b;outline-offset:2px}
15
20
  #details table{width:100%}
16
21
  #details tr+tr{border-top:1px solid #e5e7eb}
@@ -29,7 +34,15 @@ table{border-collapse:collapse}td,th{padding:4px 12px;text-align:left}
29
34
  @media (min-width:601px){#details th:nth-child(-n+3),#details td:nth-child(-n+3):not([colspan]){width:1%;white-space:nowrap}}
30
35
  td:first-child,th:first-child{padding-left:0}
31
36
  @media (max-width:600px){td,th{padding:4px 6px}td:last-child,th:last-child{padding-right:0}#details td:first-child{min-width:7em}}
32
- input[type=search]{font:inherit;padding:6px 10px;border:1px solid #ccc;border-radius:6px;width:100%;max-width:24rem;box-sizing:border-box}
37
+ input[type=search]{scroll-margin-top:16px;font:inherit;padding:6px 10px;border:1px solid #ccc;border-radius:6px;width:100%;max-width:24rem;box-sizing:border-box}
38
+ /* the pair count and a pager above the list, the same pager again below it; the pager keeps to the right */
39
+ .ov-bar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 16px;margin:12px 0}
40
+ .ov-bar>p{margin:0}
41
+ .pager{display:flex;align-items:center;gap:8px;margin-left:auto}
42
+ .pager>span{white-space:nowrap;font-variant-numeric:tabular-nums}
43
+ .pager>button{font:inherit;min-height:32px;padding:0 12px;border:1px solid #ccc;border-radius:6px;background:#f3f4f6;color:#222;cursor:pointer}
44
+ .pager>button:disabled{color:#9ca3af;cursor:default}
45
+ @media (max-width:600px){.pager>button{min-height:44px;padding:0 14px}}
33
46
  .pair{display:grid;grid-template-columns:8em minmax(0,1fr);gap:4px 12px;padding:8px 0;border-bottom:1px solid #e5e7eb}
34
47
  .pair>strong{grid-row:span 3}
35
48
  .pair hr{width:100%;border:0;border-top:1px dashed #d1d5db;margin:0}
@@ -140,13 +153,34 @@ function drawMap(parent) {
140
153
  const pickedName = el('p', '', side); pickedName.setAttribute('data-testid', 'map-picked');
141
154
  const list = el('div', '', side); list.setAttribute('data-testid', 'map-similar');
142
155
  let lit = [];
156
+ // the selected dot's own mark, unlike the blue rings of its similar dots: the dot again, then an ink ring on a white
157
+ // rim 5 px out from it (at least 18 px across on any screen), all drawn after every dot so no neighbour covers it;
158
+ // clicks pass through to the dots beneath
159
+ const mark = document.createElementNS(NS, 'g');
160
+ mark.setAttribute('data-testid', 'map-selected'); mark.setAttribute('pointer-events', 'none'); mark.setAttribute('display', 'none');
161
+ const copy = mark.appendChild(document.createElementNS(NS, 'circle'));
162
+ const rings = [['#fff', 5], ['#222', 2.5]].map(([stroke, width]) => {
163
+ const c = document.createElementNS(NS, 'circle');
164
+ c.setAttribute('fill', 'none'); c.setAttribute('stroke', stroke); c.setAttribute('stroke-width', width);
165
+ c.setAttribute('vector-effect', 'non-scaling-stroke');
166
+ return mark.appendChild(c);
167
+ });
168
+ svg.appendChild(mark);
143
169
  // selection touches only the previous and the new highlights and the neighbour list, never the placement
144
170
  const pick = (d) => {
145
171
  picked = d;
146
172
  lit.forEach((c) => { c.setAttribute('stroke', 'none'); delete c.dataset.highlighted; });
147
173
  const sims = d.similar.slice().sort((a, b) => b[1] - a[1] || (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
148
- lit = [d.test, ...sims.map(([n]) => n)].map((n) => circles.get(n)).filter(Boolean);
174
+ // only the similar dots get a blue ring; the selected one shows through its own mark below
175
+ lit = sims.map(([n]) => circles.get(n)).filter(Boolean);
149
176
  lit.forEach((c) => { c.setAttribute('stroke', '#2563eb'); c.dataset.highlighted = 'true'; });
177
+ // the drawing's pixels per unit; 1 where nothing is laid out
178
+ const dot = circles.get(d.test), scale = svg.getBoundingClientRect().width / w || 1;
179
+ const r = Number(dot.getAttribute('r')), ring = Math.max(r + 5 / scale, 9 / scale);
180
+ [copy, ...rings].forEach((c) => { c.setAttribute('cx', dot.getAttribute('cx')); c.setAttribute('cy', dot.getAttribute('cy')); });
181
+ copy.setAttribute('r', r); copy.setAttribute('fill', dot.getAttribute('fill'));
182
+ rings.forEach((c) => c.setAttribute('r', ring));
183
+ mark.removeAttribute('display');
150
184
  hint.hidden = true;
151
185
  pickedName.replaceChildren();
152
186
  el('strong', 'Selected', pickedName); el('br', '', pickedName); ident(el('span', d.test, pickedName));
@@ -176,15 +210,35 @@ function drawOverlaps(parent) {
176
210
  input.type = 'search'; input.placeholder = 'Search test identities'; input.value = ovQuery; input.setAttribute('aria-label', 'Search overlapping tests');
177
211
  input.setAttribute('data-testid', 'overlap-search');
178
212
  box.appendChild(input);
179
- const out = el('div', '', box);
213
+ const bar = el('div', '', box); bar.className = 'ov-bar';
214
+ const count = el('p', '', bar); count.setAttribute('data-testid', 'overlap-count');
215
+ const empty = el('p', 'No pair matches this search.', box); empty.setAttribute('data-testid', 'overlap-empty');
216
+ const list = el('div', '', box);
217
+ const foot = el('div', '', box); foot.className = 'ov-bar';
218
+ // the same pager above and below the list; after a page turn focus is on the top one, so paging from the bottom
219
+ // brings the reader back to the start of the new page instead of leaving them 100 rows down
220
+ const pager = (parent, label, suffix) => {
221
+ const nav = el('nav', '', parent); nav.className = 'pager'; nav.setAttribute('aria-label', label);
222
+ const step = (text, d, id) => { const b = el('button', text, nav); b.setAttribute('data-testid', id + suffix); b.onclick = () => turn(d, suffix !== ''); return b; };
223
+ // the counter before the buttons, so its width changing (page 9 to 10) never moves a button
224
+ const at = el('span', '', nav); at.setAttribute('data-testid', 'overlap-page' + suffix);
225
+ return { at, prev: step('Previous', -1, 'overlap-prev'), next: step('Next', 1, 'overlap-next') };
226
+ };
227
+ const top = pager(bar, 'Pages of pairs', ''), bottom = pager(foot, 'Pages of pairs, end of list', '-bottom');
228
+ top.at.setAttribute('aria-live', 'polite');
229
+ const turn = (d, fromBottom) => {
230
+ ovPage += d; draw();
231
+ if (fromBottom) input.scrollIntoView?.({ block: 'start' }); // jsdom has no scrollIntoView
232
+ const [ahead, back] = d < 0 ? [top.prev, top.next] : [top.next, top.prev];
233
+ (ahead.disabled ? back : ahead).focus({ preventScroll: true });
234
+ };
180
235
  const draw = () => {
181
- out.replaceChildren();
182
236
  const q = ovQuery.toLowerCase();
183
237
  const hits = q ? ranked.filter((o) => o.tests.some((t) => t.toLowerCase().includes(q))) : ranked;
184
238
  const pages = Math.max(1, Math.ceil(hits.length / PAGE));
185
239
  ovPage = Math.min(ovPage, pages - 1);
186
- el('p', hits.length.toLocaleString('en-US') + (hits.length === 1 ? ' pair' : ' pairs'), out).setAttribute('data-testid', 'overlap-count');
187
- if (!hits.length) el('p', 'No pair matches this search.', out).setAttribute('data-testid', 'overlap-empty');
240
+ count.textContent = hits.length.toLocaleString('en-US') + (hits.length === 1 ? ' pair' : ' pairs');
241
+ if (hits.length) empty.remove(); else bar.after(empty);
188
242
  // a page is built off the page and attached once: one insertion instead of hundreds
189
243
  const rows = document.createDocumentFragment();
190
244
  hits.slice(ovPage * PAGE, (ovPage + 1) * PAGE).forEach((o) => {
@@ -194,12 +248,8 @@ function drawOverlaps(parent) {
194
248
  // the two tests on their own lines, a dashed rule between them
195
249
  o.tests.forEach((t, k) => { if (k) el('hr', '', row); testLine('div', t, row).setAttribute('data-testid', 'overlap-test'); });
196
250
  });
197
- out.appendChild(rows);
198
- const nav = el('p', '', out);
199
- const step = (text, d, id) => { const b = el('button', text, nav); b.setAttribute('data-testid', id); b.disabled = ovPage + d < 0 || ovPage + d >= pages; b.onclick = () => { ovPage += d; draw(); }; };
200
- step('Previous', -1, 'overlap-prev');
201
- el('span', ' Page ' + (ovPage + 1) + ' of ' + pages + ' ', nav);
202
- step('Next', 1, 'overlap-next');
251
+ list.replaceChildren(rows);
252
+ [top, bottom].forEach((p) => { p.at.textContent = 'Page ' + (ovPage + 1) + ' of ' + pages; p.prev.disabled = ovPage === 0; p.next.disabled = ovPage === pages - 1; });
203
253
  };
204
254
  input.oninput = () => { ovQuery = input.value; ovPage = 0; draw(); };
205
255
  draw();
@@ -218,18 +268,21 @@ function render() {
218
268
  g.setAttribute('aria-pressed', i === selected);
219
269
  el('span', p.name, g).setAttribute('data-testid', 'gauge-title');
220
270
  el('span', p.score === null ? '–' : shown(p.score), g).className = 'score';
221
- const status = el('span', p.partial ? 'partial: ' + p.metrics.length + ' of ' + p.total + ' metrics measured' : 'all ' + p.total + ' metrics measured', g);
222
- status.className = 'gauge-status' + (p.partial ? ' flag' : ''); status.setAttribute('data-testid', 'gauge-status');
271
+ const { head, reasons } = p.status;
272
+ const status = el('span', head, g);
273
+ reasons.forEach((r, k) => { status.append(' '); el('span', r + (k < reasons.length - 1 ? ';' : ''), status); });
274
+ status.className = 'gauge-status' + (reasons.length ? ' flag' : '') + (p.red_suite ? ' red' : ''); status.setAttribute('data-testid', 'gauge-status');
223
275
  g.onclick = () => { selected = i; tab = 'Metrics'; picked = null; render(); };
224
276
  });
225
277
  const p = data.pillars[selected];
226
278
  el('h2', p.name, details);
227
279
  const names = ['Metrics', 'Worst tests', 'Smells', ...(p.key === 'economy' ? ['Overlaps', 'Map'] : [])];
228
280
  const tabs = el('div', '', details); tabs.className = 'tabs';
229
- names.forEach((n) => { const b = el('button', n, tabs); b.setAttribute('aria-pressed', n === tab); b.onclick = () => { tab = n; picked = null; render(); }; });
281
+ names.forEach((n) => { const b = el('button', n, tabs); b.dataset.label = n; b.setAttribute('aria-pressed', n === tab); b.onclick = () => { tab = n; picked = null; render(); }; });
230
282
  el('h3', tab, details);
231
283
  if (tab === 'Metrics') {
232
284
  if (!p.metrics.length) el('p', 'No metrics were measured for this pillar.', details);
285
+ if (p.status.note) el('p', p.status.note, details).setAttribute('data-testid', 'partial-reason');
233
286
  const t = el('table', '', details);
234
287
  const head = el('tr', '', t);
235
288
  ['Metric', 'Value', 'Score', 'Anchors'].forEach((h) => el('th', h, head));
@@ -1,6 +1,7 @@
1
- """Ticket 04 browser driver: `uv run --with playwright python browser_driver.py <dashboard.html>` opens the standalone
2
- report from disk in Chrome with the network switched off, drives the visible controls and prints one JSON document of
3
- measurements on stdout. It asserts nothing: test_dashboard_layout.py reads the measurements.
1
+ """Ticket 04 browser driver: `uv run --with playwright python browser_driver.py <dashboard.html> [--gauges]` opens the
2
+ standalone report from disk in Chrome with the network switched off, drives the visible controls and prints one JSON
3
+ document of measurements on stdout; with --gauges it measures only the overview gauges at both viewports. It asserts
4
+ nothing: test_dashboard_layout.py reads the measurements.
4
5
 
5
6
  Page interface the acceptance tests pin, on top of the earlier tickets' markup (metric/overlap/map tabs):
6
7
  [data-testid=gauge-title] inside every [data-testid=gauge]: the pillar title
@@ -25,8 +26,11 @@ GAUGES = """() => [...document.querySelectorAll('[data-testid=gauge]')].map((g)
25
26
  return {top: Math.round(r.top), left: Math.round(r.left), width: Math.round(r.width), height: Math.round(r.height),
26
27
  lines: Math.round(r.height / (parseFloat(s.lineHeight) || 1.2 * parseFloat(s.fontSize))), font: parseFloat(s.fontSize),
27
28
  clipped: e.scrollWidth > e.clientWidth + 1 || e.scrollHeight > e.clientHeight + 1, text: e.textContent.trim()}; };
29
+ const status = g.querySelector('[data-testid=gauge-status]'), lh = (e) => parseFloat(getComputedStyle(e).lineHeight);
30
+ // the lines each reason of the status spans: an inline one breaks into rects, an inline-block one grows taller
31
+ const reasons = status ? [...status.children].map((s) => Math.max(s.getClientRects().length, Math.round(s.getBoundingClientRect().height / lh(s)))) : [];
28
32
  return {card: box(g), title: box(g.querySelector('[data-testid=gauge-title]')), score: box(g.querySelector('.score')),
29
- status: box(g.querySelector('[data-testid=gauge-status]'))};
33
+ status: box(status), reasons};
30
34
  })"""
31
35
 
32
36
  SIG = """(el) => { const s = getComputedStyle(el);
@@ -58,6 +62,15 @@ def table_share(page):
58
62
  return t ? t.getBoundingClientRect().width / d.getBoundingClientRect().width : null; }""")
59
63
 
60
64
 
65
+ def overview(browser, width, height):
66
+ page = browser.new_page(viewport={"width": width, "height": height})
67
+ page.goto(URL)
68
+ page.wait_for_selector(GAUGE)
69
+ out = {"gauges": page.evaluate(GAUGES), "overview": page.evaluate(OVERFLOW)}
70
+ page.close()
71
+ return out
72
+
73
+
61
74
  def layout(browser, width, height):
62
75
  page = browser.new_page(viewport={"width": width, "height": height})
63
76
  page.goto(URL)
@@ -71,6 +84,8 @@ def layout(browser, width, height):
71
84
  click_gauge(page, "Economy")
72
85
  click_tab(page, "Overlaps")
73
86
  out["overlaps"] = page.evaluate(OVERFLOW)
87
+ out["pager_heights"] = page.evaluate("""() => Object.fromEntries(['overlap-next', 'overlap-next-bottom'].map((id) =>
88
+ [id, document.querySelector(`[data-testid=${id}]`).getBoundingClientRect().height]))""")
74
89
  out["overlap_ids"] = page.evaluate("""() => [...document.querySelectorAll('[data-testid=overlap-test]')].map((e) => {
75
90
  const r = e.getBoundingClientRect(), s = getComputedStyle(e);
76
91
  return {text: e.textContent, right: Math.round(r.right), clipped: e.scrollWidth > e.clientWidth + 1 && s.overflowX !== 'visible',
@@ -101,6 +116,27 @@ def tab_styles(browser):
101
116
  return {"steps": steps, "focus": focus}
102
117
 
103
118
 
119
+ TAB_BOXES = """() => { const row = document.querySelector('[data-testid=details] .tabs'), o = row.getBoundingClientRect();
120
+ return [...row.querySelectorAll('button')].map((b) => { const r = b.getBoundingClientRect();
121
+ return {text: b.textContent.trim(), left: r.left - o.left + row.scrollLeft, width: r.width}; }); }"""
122
+
123
+
124
+ def tab_boxes(browser, width, height):
125
+ """Each tab's unrounded box in its row (scroll-independent) after every tab of Economy is selected in turn."""
126
+ page = browser.new_page(viewport={"width": width, "height": height})
127
+ page.goto(URL)
128
+ page.wait_for_selector(GAUGE)
129
+ click_gauge(page, "Economy")
130
+ labels = [b["text"] for b in page.evaluate(TAB_BOXES)]
131
+ steps = {}
132
+ for label in labels:
133
+ click_tab(page, label)
134
+ steps[label] = page.evaluate(TAB_BOXES)
135
+ out = {"steps": steps, "overview": page.evaluate(OVERFLOW)}
136
+ page.close()
137
+ return out
138
+
139
+
104
140
  def journey(browser):
105
141
  context = browser.new_context(viewport={"width": 1440, "height": 900}, offline=True)
106
142
  requests = []
@@ -156,6 +192,11 @@ with sync_playwright() as p:
156
192
  browser = p.chromium.launch(channel="chrome")
157
193
  except Exception:
158
194
  browser = p.chromium.launch()
159
- result = {"desktop": layout(browser, 1440, 900), "narrow": layout(browser, 390, 844), "tabs": tab_styles(browser), "journey": journey(browser)}
195
+ if sys.argv[2:] == ["--gauges"]:
196
+ result = {"desktop": overview(browser, 1440, 900), "narrow": overview(browser, 390, 844)}
197
+ else:
198
+ result = {"desktop": layout(browser, 1440, 900), "narrow": layout(browser, 390, 844), "tabs": tab_styles(browser),
199
+ "tab_boxes": {"desktop": tab_boxes(browser, 1440, 900), "narrow": tab_boxes(browser, 390, 844)},
200
+ "journey": journey(browser)}
160
201
  browser.close()
161
202
  print(json.dumps(result))
@@ -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