feat(vwb): harden supervised verdict evidence
This commit is contained in:
@@ -111,3 +111,39 @@ def test_preview_endpoint_returns_read_only_workflow():
|
||||
"wait_for_state",
|
||||
"pause_for_human",
|
||||
]
|
||||
|
||||
|
||||
def test_unsupported_method_is_reported_as_warning(tmp_path):
|
||||
root = tmp_path / "competences"
|
||||
candidate = root / "candidate"
|
||||
candidate.mkdir(parents=True)
|
||||
(candidate / "unsupported_preview.yaml").write_text(
|
||||
"\n".join(
|
||||
[
|
||||
"schema_version: 1",
|
||||
"id: unsupported_preview",
|
||||
"name: Unsupported preview",
|
||||
"learning_state: candidate",
|
||||
"intent:",
|
||||
" fr: tester une methode non supportee",
|
||||
"methods:",
|
||||
"- id: step_1_unknown",
|
||||
" kind: shell_magic",
|
||||
" primitive_ref: shell_magic",
|
||||
" parameters: {}",
|
||||
"failure_message_template:",
|
||||
" attendu: aucun replay automatique",
|
||||
]
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
preview = competence_yaml_to_vwb_preview("unsupported_preview", root=root)
|
||||
|
||||
assert [step["action_type"] for step in preview["steps"]] == [
|
||||
"pause_for_human",
|
||||
"pause_for_human",
|
||||
]
|
||||
assert preview["warnings"] == [
|
||||
"Methode non supportee en preview VWB: step_1_unknown"
|
||||
]
|
||||
|
||||
@@ -30,6 +30,14 @@ def _payload(**overrides):
|
||||
"process_name": "explorer.exe",
|
||||
},
|
||||
},
|
||||
"workflow_id": "preview_competence_key_win_r_wait_explorer_exe",
|
||||
"step_results": [
|
||||
{
|
||||
"step_id": "step_1_key_combo",
|
||||
"action_type": "keyboard_shortcut",
|
||||
"status": "success",
|
||||
}
|
||||
],
|
||||
"comments": "Supervised replay ok",
|
||||
}
|
||||
payload.update(overrides)
|
||||
@@ -52,6 +60,14 @@ def test_store_competence_verdict_appends_jsonl(tmp_path):
|
||||
assert record["write_back_enabled"] is False
|
||||
assert record["yaml_write"] is False
|
||||
assert record["duplicate"] is False
|
||||
assert record["workflow_id"] == "preview_competence_key_win_r_wait_explorer_exe"
|
||||
assert record["step_results"] == [
|
||||
{
|
||||
"step_id": "step_1_key_combo",
|
||||
"action_type": "keyboard_shortcut",
|
||||
"status": "success",
|
||||
}
|
||||
]
|
||||
assert record["context_signature"]["machine_id"] == "DESKTOP-58D5CAC_windows"
|
||||
|
||||
records = iter_competence_verdicts(log_path=log_path)
|
||||
@@ -79,6 +95,23 @@ def test_store_competence_verdict_is_idempotent(tmp_path):
|
||||
assert second["comments"] == "Supervised replay ok"
|
||||
|
||||
|
||||
def test_store_competence_verdict_rejects_same_id_for_other_competence(tmp_path):
|
||||
log_path = tmp_path / "verdicts.jsonl"
|
||||
|
||||
store_competence_verdict(
|
||||
"key_win_r_wait_explorer_exe",
|
||||
_payload(),
|
||||
log_path=log_path,
|
||||
)
|
||||
|
||||
with pytest.raises(CompetenceVerdictError, match="deja utilise"):
|
||||
store_competence_verdict(
|
||||
"key_ctrl_s_wait_notepad_exe",
|
||||
_payload(),
|
||||
log_path=log_path,
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("kind", ["valid", "invalid", "inconclusive"])
|
||||
def test_store_competence_verdict_accepts_three_kinds(tmp_path, kind):
|
||||
record = store_competence_verdict(
|
||||
@@ -115,3 +148,12 @@ def test_store_competence_verdict_rejects_yaml_write_attempt(tmp_path):
|
||||
|
||||
assert record["write_back_enabled"] is False
|
||||
assert record["yaml_write"] is False
|
||||
|
||||
|
||||
def test_store_competence_verdict_requires_step_results_list(tmp_path):
|
||||
with pytest.raises(CompetenceVerdictError, match="step_results"):
|
||||
store_competence_verdict(
|
||||
"key_win_r_wait_explorer_exe",
|
||||
_payload(step_results={"step_id": "not_a_list"}),
|
||||
log_path=tmp_path / "verdicts.jsonl",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user