upravy skillu

This commit is contained in:
lachtan
2026-09-02 15:22:39 +02:00
parent 63089cb8cb
commit 442ddc3c24
5 changed files with 177 additions and 104 deletions

View File

@@ -189,6 +189,20 @@ class TestCheckAndReject:
assert "-If the fetch fails, try again." in printed
assert "+If the fetch fails, STOP and diagnose." in printed
def test_check_previews_the_users_own_rewrite(self, workspace, tmp_path, capsys):
"""`edit:` shows the user's wording as a diff first, so --check has to take it too —
without --check the same flag applies and commits straight away."""
replacement = tmp_path / "new.txt"
replacement.write_text("If the fetch fails, ask the user.", encoding="utf-8")
exit_code = reflect_apply.main(
["--id", "f7a2", "--check", "--new-text-file", str(replacement), "--workspace", str(workspace)]
)
assert exit_code == 0
assert "+If the fetch fails, ask the user." in capsys.readouterr().out
assert (workspace / TARGET_REL).read_text(encoding="utf-8") == ORIGINAL
assert _findings(workspace)[0]["status"] == "open"
def test_check_fails_on_a_stale_patch(self, workspace):
_write_findings(workspace, _record(patch={**_record()["patch"], "old_text": "absent"}))
assert reflect_apply.main(["--id", "f7a2", "--check", "--workspace", str(workspace)]) == 2

View File

@@ -394,6 +394,17 @@ class TestRendering:
report = reflect_auto.render_report(merged, _stats(), None, WHEN)
assert "REGRESSION" in report
def test_a_regression_outranks_a_higher_severity_finding(self):
"""Severity is the model's per-run guess and drifts; `regression_of` is a fact from the audit."""
applied = _filed(status="applied", applied={"at": "2026-07-01", "sha": "abc1234", "file": "SOUL.md"})
regression = _raw_finding(severity="low")
louder = _raw_finding(pattern="speculation-presented-as-fact", severity="high", occurrences=3, sessions_affected=2)
merged = reflect_auto.merge_findings([applied], _parsed(_answer(louder, regression)), TODAY)
report = reflect_auto.render_report(merged, _stats(), None, WHEN)
assert [f.status for f in merged] == [reflect_auto.STATUS_OPEN] * 2, "both must be open for the order to matter"
assert report.index("`retry-without-diagnosis`") < report.index("`speculation-presented-as-fact`")
def test_report_renders_a_patch_as_a_diff(self):
raw = _raw_finding(patch={"file": "a.md", "old_text": "try again", "new_text": "STOP"})
merged = reflect_auto.merge_findings([], _parsed(_answer(raw)), TODAY)