@jesdi/skills 0.0.79 → 0.0.81

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jesdi/skills",
3
- "version": "0.0.79",
3
+ "version": "0.0.81",
4
4
  "description": "jesdi's agent skills (content package consumed by @jesdi/skills-cli)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -138,8 +138,10 @@ when `prune` exited 1 (the status keeps that failure, so the job still goes red)
138
138
  commit, or a change to a function or a created file another open item already changed: each
139
139
  test belongs to one item, so write another item's tests as new functions. Leave the tree clean.
140
140
  3. `strengthen-verify` rejects commits without a known trailer or outside `backend/tests/`, then
141
- proves each item on a cold run: every named id survived on the base and is killed on the
142
- head. Unproven items are reverted and closed: a later commit for a closed item is refused.
141
+ proves each item on a cold run: an item kills a named id that survived on the base and is
142
+ killed on the head. An item that kills at least one is proven for those ids only; the PR
143
+ lists the rest under "Still surviving". An item that kills none is reverted and closed: a
144
+ later commit for a closed item is refused.
143
145
  When `git revert` conflicts with a later item's lines, the item's functions are removed or
144
146
  restored instead and its created files deleted; an item that changed anything else in a file
145
147
  still stops the run with exit 1. It
@@ -156,9 +158,10 @@ when `prune` exited 1 (the status keeps that failure, so the job still goes red)
156
158
  `strengthen-verify` after any new commit); on any exit 2 HEAD stays at the proven head, so fix
157
159
  the input and rerun it. It reverts rejected items, reruns the proof cold, runs
158
160
  `make mutation-check`, `make test`, `make crap` and `make mutation-baseline`, refuses a
159
- baseline that gained an equivalent id, and commits the lower baseline. Unattended it opens the
160
- strengthen PR listing each changed test with the ids it now kills; interactive it leaves the
161
- commits on the current branch for the human.
161
+ baseline that gained an equivalent id, and commits the lower baseline. Unattended it pushes the
162
+ result as one commit on the base (a `Test-Prune-Item` trailer per kept item; the per-item
163
+ commits and reverts stay local) and opens the strengthen PR listing each changed test with the
164
+ ids it now kills; interactive it leaves the commits on the current branch for the human.
162
165
 
163
166
  ## Report
164
167
 
@@ -1,5 +1,5 @@
1
- """strengthen-start, strengthen-verify and strengthen-finish: prove each strengthen item kills the
2
- mutant ids it names (surviving on the base, killed on the head), keep what the reviewer accepts,
1
+ """strengthen-start, strengthen-verify and strengthen-finish: prove which of the mutant ids each
2
+ strengthen item names it kills (surviving on the base, killed on the head), keep what the reviewer accepts,
3
3
  lower the baseline, and (unattended) open the strengthen PR from the base commit."""
4
4
  from __future__ import annotations
5
5
 
@@ -229,13 +229,15 @@ def _close(repo, st: dict, item_id: str, commits: list, status: str, why: str) -
229
229
 
230
230
 
231
231
  def item_proof(base_codes: dict, codes: dict, item: dict, has_commits: bool) -> dict:
232
- """Per mutant id the base and head exit codes; proven when the item names at least one id, every id
233
- survived on the base and is killed on the head, and the item has a commit."""
232
+ """Per mutant id the base and head exit codes, and the ids the item kills: survived on the base,
233
+ killed on the head. Proven when it kills at least one and has a commit; the ids it does not kill
234
+ are no longer its claim, so one survivor no longer throws away the kills it did make."""
234
235
  module = item.get("module")
235
236
  mutants = {m: {"base": base_codes.get(module, {}).get(m), "head": codes.get(module, {}).get(m)}
236
237
  for m in item["mutant_ids"]}
237
- proven = has_commits and bool(mutants) and all(e["base"] in SURVIVING and e["head"] in KILLED for e in mutants.values())
238
- return {"status": "proven" if proven else "unproven", "module": module, "mutants": mutants}
238
+ kills = [m for m, e in mutants.items() if e["base"] in SURVIVING and e["head"] in KILLED]
239
+ return {"status": "proven" if has_commits and kills else "unproven", "module": module,
240
+ "mutants": mutants, "kills": kills}
239
241
 
240
242
 
241
243
  def _judge(ctx, base: dict, st: dict, proof: dict, commits: list) -> list:
@@ -261,7 +263,7 @@ def _prove(ctx, base: dict, st: dict) -> dict:
261
263
  failing = _judge(ctx, base, st, proof, commits)
262
264
  for item_id in failing:
263
265
  _close(ctx.repo, st, item_id, commits, "reverted",
264
- "Its mutant ids are not all killed on the head while surviving on the base.")
266
+ "None of its mutant ids is killed on the head while surviving on the base.")
265
267
  proof[item_id]["status"] = "reverted"
266
268
  ctx.state.save("strengthen.json", st)
267
269
  ctx.state.save("strengthen-proof.json", {"start": st["start"], "head": ctx.repo.head(), "items": proof})
@@ -273,7 +275,8 @@ def _proof_lines(proof: dict) -> list:
273
275
  lines = []
274
276
  for item_id, entry in proof.items():
275
277
  lines.append(f"- {item_id}: {entry['status']}")
276
- lines += [f" {m}: base exit code {e['base']}, head exit code {e['head']}" for m, e in entry["mutants"].items()]
278
+ lines += [f" {m}: base exit code {e['base']}, head exit code {e['head']}"
279
+ f"{'' if m in entry.get('kills', ()) else ' (not killed)'}" for m, e in entry["mutants"].items()]
277
280
  return lines
278
281
 
279
282
 
@@ -317,23 +320,32 @@ def _guard_equivalents(repo, base: dict, new: dict) -> None:
317
320
  + "; ".join(f"{m}: {', '.join(ids)}" for m, ids in gained.items()))
318
321
 
319
322
 
320
- def _test_lines(items: dict, accepted: list, tests: dict) -> list:
323
+ def _test_lines(items: dict, accepted: list, tests: dict, proof: dict) -> list:
321
324
  lines = []
322
325
  for item_id in accepted:
323
- ids = items[item_id]["mutant_ids"]
326
+ ids = proof[item_id]["kills"]
324
327
  kills = f"now kills {', '.join(f'`{m}`' for m in ids)}" if ids else f"adds `{items[item_id]['assertion']}`"
325
328
  lines += [f"- `{t}` ({item_id}) {kills}" for t in tests[item_id]] or [f"- {item_id}: {kills}"]
326
329
  return lines
327
330
 
328
331
 
332
+ def _still_surviving(accepted: list, proof: dict) -> list:
333
+ """The ids a kept item named but does not kill: still open for a later run."""
334
+ left = [f"- `{m}` ({i}) still survives: its tests do not kill it" for i in accepted
335
+ for m in proof[i]["mutants"] if m not in proof[i]["kills"]]
336
+ return ["", "## Still surviving", ""] + left if left else []
337
+
338
+
329
339
  def _body(base: dict, st: dict, proof: dict, accepted: list, tests: dict, new: dict, ratchet: str, out: dict) -> str:
330
340
  lines = [f"Strengthened tests from `{base['branch']}` at {base['commit'][:12]}, independent of the prune PR. "
331
341
  "Every mutant id listed survived the cold mutation run on the base and is killed by the cold run on "
332
342
  "this branch.", "", "## Changed tests", ""]
333
- lines += _test_lines({i["id"]: i for i in st["items"]}, accepted, tests)
343
+ lines += _test_lines({i["id"]: i for i in st["items"]}, accepted, tests, proof)
334
344
  lines += ["", "## Proof per mutant id", ""]
335
345
  lines += [f"- `{m}` ({proof[i]['module']}): survived the base run (exit code {e['base']}), killed on this "
336
- f"branch (exit code {e['head']})" for i in accepted for m, e in proof[i]["mutants"].items()]
346
+ f"branch (exit code {e['head']})" for i in accepted for m, e in proof[i]["mutants"].items()
347
+ if m in proof[i]["kills"]]
348
+ lines += _still_surviving(accepted, proof)
337
349
  lines += ["", "## Baseline survivors", ""]
338
350
  lines += [f"- {m}: {base['baseline'].get(m, {}).get('survivors', 'new')} → {e['survivors']}" for m, e in new.items()]
339
351
  lines += ["", "## Mutation ratchet", "", "```", ratchet.strip(), "```"]
@@ -398,6 +410,13 @@ def _lower_baseline(repo, base: dict) -> tuple[str, dict]:
398
410
  return "\n".join(ratchet_lines({"output": ratchet})), new
399
411
 
400
412
 
413
+ def _squash(repo, start: str, title: str, accepted: list) -> str:
414
+ """One commit on start with the proven head's tree: the PR shows the kept tests and the baseline,
415
+ not the per-item commits and reverts the proof needed."""
416
+ message = "\n\n".join([title, "\n".join(f"{TRAILER}: {i}" for i in accepted)])
417
+ return repo.git("commit-tree", "HEAD^{tree}", "-p", start, "-m", message).strip()
418
+
419
+
401
420
  def _finish(ctx, base: dict, st: dict, reviews: dict, unattended: bool) -> int:
402
421
  repo = ctx.repo
403
422
  proof, accepted = _keep_accepted(ctx, base, st, reviews)
@@ -412,9 +431,9 @@ def _finish(ctx, base: dict, st: dict, reviews: dict, unattended: bool) -> int:
412
431
  ctx.state.emit(f"Strengthen commits kept on {repo.branch()}:\n\n{body}")
413
432
  return 0
414
433
  branch = _branch(ctx)
415
- repo.git("branch", branch)
416
- repo.push(branch)
417
434
  title = f"test: strengthen {len(accepted)} weak spot{'' if len(accepted) == 1 else 's'}"
435
+ repo.git("branch", branch, _squash(repo, st["start"], title, accepted))
436
+ repo.push(branch)
418
437
  path, body = ctx.state.save_body("strengthen-pr.md", body)
419
438
  url = repo.open_pr(base["branch"], branch, title, path)
420
439
  ctx.state.emit(f"Opened {url}\n\n{body}")
@@ -225,7 +225,7 @@ def test_finish_refuses_a_head_moved_since_the_proof_and_stays_for_the_rerun(tar
225
225
 
226
226
 
227
227
  def test_new_commits_for_a_reverted_item_are_refused(target):
228
- drift_ids = ["x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"]
228
+ drift_ids = ["x_apply_drift__mutmut_4"] # DRIFT_TEST kills only _2: nothing proven, reverted
229
229
  target.prepare([cand(case(1))], accept=[COMPUTE, DRIFT],
230
230
  groups={COMPUTE: strengthen_group(IDS_7_9), DRIFT: strengthen_group(drift_ids)})
231
231
  target.ok("strengthen-start")
@@ -61,14 +61,19 @@ def test_commit_problems_need_one_known_trailer_and_test_paths_only():
61
61
  assert commit_problems("a" * 40, [], [], {"m.f"})
62
62
 
63
63
 
64
- def test_item_proof_needs_survived_on_base_and_killed_on_head_per_id():
64
+ def test_item_proof_keeps_each_id_that_survived_on_base_and_is_killed_on_head():
65
65
  item = {"module": "s.py", "mutant_ids": ["m1", "m2"]}
66
66
  base = {"s.py": {"m1": 0, "m2": 33}}
67
67
 
68
- assert item_proof(base, {"s.py": {"m1": 1, "m2": 3}}, item, True)["status"] == "proven"
69
- assert item_proof(base, {"s.py": {"m1": 1, "m2": 0}}, item, True)["status"] == "unproven"
70
- assert item_proof(base, {"s.py": {"m1": 1, "m2": 3}}, item, False)["status"] == "unproven"
71
- assert item_proof({"s.py": {"m1": 1, "m2": 0}}, {"s.py": {"m1": 1, "m2": 1}}, item, True)["status"] == "unproven"
68
+ def proof(base_codes, head_codes, has_commits=True):
69
+ p = item_proof(base_codes, {"s.py": head_codes}, item, has_commits)
70
+ return p["status"], p["kills"]
71
+
72
+ assert proof(base, {"m1": 1, "m2": 3}) == ("proven", ["m1", "m2"])
73
+ assert proof(base, {"m1": 1, "m2": 0}) == ("proven", ["m1"]) # m2 stays a survivor, m1 is kept
74
+ assert proof(base, {"m1": 0, "m2": 5}) == ("unproven", []) # kills nothing it named
75
+ assert proof(base, {"m1": 1, "m2": 3}, has_commits=False) == ("unproven", ["m1", "m2"])
76
+ assert proof({"s.py": {"m1": 1, "m2": 0}}, {"m1": 1, "m2": 1}) == ("proven", ["m2"]) # m1 was never a survivor
72
77
 
73
78
 
74
79
  def test_changed_tests_lists_new_and_edited_tests():
@@ -4,7 +4,7 @@ import re
4
4
 
5
5
  import pytest
6
6
 
7
- from prune_harness import PRUNE_BRANCH, REFERENCE, STRENGTHEN_BRANCH, R, arg, cand, case
7
+ from prune_harness import PRUNE_BRANCH, REFERENCE, STRENGTHEN_BRANCH, R, arg, cand, case, lines_with
8
8
 
9
9
  COMPUTE = "rebalancer.compute_trades"
10
10
  DRIFT = "rebalancer.apply_drift"
@@ -144,8 +144,8 @@ def test_a_commit_naming_two_items_is_rejected_with_a_recovery_the_agent_can_run
144
144
  target.ok("strengthen-verify")
145
145
 
146
146
 
147
- def test_strengthen_item_whose_ids_are_not_all_killed_is_reverted_and_left_out_of_the_pr(target):
148
- drift_ids = ["x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"]
147
+ def test_strengthen_item_that_kills_none_of_its_ids_is_reverted_and_left_out_of_the_pr(target):
148
+ drift_ids = ["x_apply_drift__mutmut_4"] # DRIFT_TEST kills only _2
149
149
  target.prepare([cand(case(1))], accept=[COMPUTE, DRIFT],
150
150
  groups={COMPUTE: strengthen_group(IDS_7_9), DRIFT: strengthen_group(drift_ids)})
151
151
 
@@ -285,10 +285,10 @@ def test_strengthen_commit_refuses_an_unknown_item(target):
285
285
 
286
286
 
287
287
  def test_strengthen_commit_refuses_an_item_strengthen_verify_closed(target):
288
- two_items(target, drift_ids=("x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"))
288
+ two_items(target, drift_ids=("x_apply_drift__mutmut_4",))
289
289
  write_test(target, DRIFT_TEST)
290
290
  target.ok("strengthen-commit", "--item", DRIFT)
291
- target.ok("strengthen-verify") # DRIFT_TEST leaves _4 alive: the item is reverted and closed
291
+ target.ok("strengthen-verify") # DRIFT_TEST kills none of its ids (_4): reverted, closed
292
292
  assert target.read_state("strengthen.json")["status"][DRIFT] == "reverted"
293
293
  write_test(target, DRIFT_TEST.replace("_new", "_again"))
294
294
  refused(target, DRIFT, "reverted")
@@ -342,7 +342,7 @@ def test_strengthen_commit_refuses_a_head_off_the_strengthen_start(target):
342
342
 
343
343
  def test_an_unproven_item_committed_before_a_proven_one_is_removed_without_a_conflict(target):
344
344
  # Both items append to the end of one file: `git revert` of the earlier one conflicts.
345
- two_items(target, drift_ids=("x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"))
345
+ two_items(target, drift_ids=("x_apply_drift__mutmut_4",))
346
346
  for item, source in [(DRIFT, DRIFT_TEST), (COMPUTE, COMPUTE_TEST)]:
347
347
  write_test(target, source)
348
348
  target.ok("strengthen-commit", "--item", item)
@@ -360,7 +360,7 @@ def test_an_unproven_item_committed_before_a_proven_one_is_removed_without_a_con
360
360
 
361
361
 
362
362
  def test_a_new_file_left_without_tests_by_a_closed_item_is_deleted(target):
363
- two_items(target, drift_ids=("x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"))
363
+ two_items(target, drift_ids=("x_apply_drift__mutmut_4",))
364
364
  new_file = "backend/tests/test_drift_new.py"
365
365
  (target.root / new_file).write_text("from services.rebalancer import apply_drift\n" + DRIFT_TEST)
366
366
  write_test(target, DRIFT_TEST.replace("_new", "_also")) # the append COMPUTE's append conflicts with
@@ -379,13 +379,13 @@ def test_a_new_file_left_without_tests_by_a_closed_item_is_deleted(target):
379
379
 
380
380
 
381
381
  def test_a_test_a_closed_item_changed_is_free_for_another_item(target):
382
- two_items(target, drift_ids=("x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"))
382
+ two_items(target, drift_ids=("x_apply_drift__mutmut_4",))
383
383
  path = target.root / TESTS_FILE
384
384
  path.write_text(path.read_text().rstrip("\n") + "\n assert apply_drift(-0.5) == 0\n")
385
385
  target.ok("strengthen-commit", "--item", DRIFT)
386
386
  write_test(target, COMPUTE_TEST)
387
387
  target.ok("strengthen-commit", "--item", COMPUTE)
388
- target.ok("strengthen-verify") # DRIFT leaves _4 alive: reverted, test_drift_scales is back to the base
388
+ target.ok("strengthen-verify") # DRIFT kills none of its ids: reverted, test_drift_scales is back to the base
389
389
  scales = " assert apply_drift(base) <= base\n"
390
390
  path.write_text(path.read_text().replace(scales, scales + " assert apply_drift(base) >= 0\n"))
391
391
 
@@ -404,7 +404,7 @@ def test_strengthen_commit_refuses_a_test_another_item_already_changed(target):
404
404
 
405
405
 
406
406
  def test_a_test_the_closed_item_changed_is_restored_under_a_later_items_test(target):
407
- two_items(target, drift_ids=("x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"))
407
+ two_items(target, drift_ids=("x_apply_drift__mutmut_4",))
408
408
  path = target.root / TESTS_FILE
409
409
  path.write_text(path.read_text().rstrip("\n") + "\n assert apply_drift(-0.5) == 0\n")
410
410
  target.ok("strengthen-commit", "--item", DRIFT)
@@ -418,7 +418,7 @@ def test_a_test_the_closed_item_changed_is_restored_under_a_later_items_test(tar
418
418
 
419
419
 
420
420
  def test_a_closed_item_that_changed_more_than_functions_still_stops_the_run_on_a_conflict(target):
421
- two_items(target, drift_ids=("x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"))
421
+ two_items(target, drift_ids=("x_apply_drift__mutmut_4",))
422
422
  write_test(target, "LIMIT = -0.5\n" + DRIFT_TEST)
423
423
  target.ok("strengthen-commit", "--item", DRIFT)
424
424
  write_test(target, COMPUTE_TEST)
@@ -429,3 +429,44 @@ def test_a_closed_item_that_changed_more_than_functions_still_stops_the_run_on_a
429
429
  assert verify.returncode == 1, verify.stdout + verify.stderr
430
430
  assert f"changes {TESTS_FILE} beyond adding or editing functions" in verify.stdout + verify.stderr
431
431
  assert target.git("status", "--porcelain").strip() == ""
432
+
433
+
434
+ def test_the_strengthen_pr_is_one_commit_on_the_base_with_a_trailer_per_kept_item(target):
435
+ drift_ids = ["x_apply_drift__mutmut_4"] # DRIFT_TEST kills only _2: nothing proven, reverted
436
+ target.prepare([cand(case(1))], accept=[COMPUTE, DRIFT],
437
+ groups={COMPUTE: strengthen_group(IDS_7_9), DRIFT: strengthen_group(drift_ids)})
438
+
439
+ finish = strengthen(target, [(DRIFT, DRIFT_TEST), (COMPUTE, COMPUTE_TEST)], [COMPUTE])
440
+
441
+ assert finish.returncode == 0, finish.stdout + finish.stderr
442
+ head = target.remote_sha(STRENGTHEN_BRANCH)
443
+ assert target.git("rev-list", f"{target.base}..{head}").split() == [head]
444
+ assert target.git("rev-parse", f"{head}^").strip() == target.base
445
+ assert target.git("log", "-1", "--format=%s", head).strip() == "test: strengthen 1 weak spot"
446
+ trailers = target.git("log", "-1", "--format=%(trailers:key=Test-Prune-Item,valueonly)", head).split()
447
+ assert trailers == [COMPUTE]
448
+ source = target.show(head, TESTS_FILE)
449
+ assert "def test_compute_trades_rounding(targets):" in source and "test_apply_drift_new" not in source
450
+ assert baseline_at(target, head)["services/rebalancer.py"]["survivors"] == 18
451
+
452
+
453
+ def test_an_item_that_kills_some_of_its_ids_is_kept_for_those_and_reports_the_rest(target):
454
+ # DRIFT_TEST kills _2 but not _4: keep the test and its proven kill, drop only the claim on _4.
455
+ drift_ids = ["x_apply_drift__mutmut_2", "x_apply_drift__mutmut_4"]
456
+ target.prepare([cand(case(1))], accept=[COMPUTE, DRIFT],
457
+ groups={COMPUTE: strengthen_group(IDS_7_9), DRIFT: strengthen_group(drift_ids)})
458
+
459
+ finish = strengthen(target, [(COMPUTE, COMPUTE_TEST), (DRIFT, DRIFT_TEST)], [COMPUTE, DRIFT])
460
+
461
+ assert finish.returncode == 0, finish.stdout + finish.stderr
462
+ assert target.read_state("strengthen.json")["status"][DRIFT] == "proven"
463
+ head = target.remote_sha(STRENGTHEN_BRANCH)
464
+ assert "def test_apply_drift_new():" in target.show(head, TESTS_FILE)
465
+ assert baseline_at(target, head)["services/rebalancer.py"]["survivors"] == 17
466
+ body = strengthen_pr(target)
467
+ kills = lines_with(body, "test_apply_drift_new")
468
+ assert "x_apply_drift__mutmut_2" in kills and "x_apply_drift__mutmut_4" not in kills
469
+ proof = body[body.index("## Proof per mutant id"):body.index("## Still surviving")]
470
+ assert "x_apply_drift__mutmut_2" in proof and "x_apply_drift__mutmut_4" not in proof
471
+ still = lines_with(body, "x_apply_drift__mutmut_4")
472
+ assert "still survives" in still and DRIFT in still
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-11-02T00:19:48.022Z",
3
+ "generatedAt": "2026-11-02T14:19:47.551Z",
4
4
  "skills": [
5
5
  {
6
6
  "name": "agents-wayfinder",
@@ -100,8 +100,8 @@
100
100
  },
101
101
  {
102
102
  "name": "test-prune",
103
- "version": "0.1.4",
104
- "hash": "sha256-127f1b28add5b6039a306f3a16d7111bc3d1e196ed076da28565f04d269d4cd4",
103
+ "version": "0.1.6",
104
+ "hash": "sha256-cc46e2d40c52615a88a53f87c62f60ddc6944cacad55427a83f9191cd0900410",
105
105
  "description": "Mutation-guided test pruning: a fixer proposes deleting redundant tests and strengthening weak ones, an independent reviewer accepts or rejects each proposal, and prune.py applies the accepted batch behind a cold mutation run and the ratchet. Use when the user says \"prune tests\", \"test-prune\", \"mutation test pruning\" or \"strengthen weak tests\", or when a scheduled job runs it with `--unattended`."
106
106
  },
107
107
  {