generated from coulomb/repo-seed
Harden WSJF triage report recovery
This commit is contained in:
@@ -98,6 +98,63 @@ async def test_evaluate_instructions_returns_report_payload(monkeypatch) -> None
|
||||
assert report["prompt_hash"] is not None
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_evaluate_instructions_returns_invalid_report_for_report_sinks(
|
||||
monkeypatch,
|
||||
tmp_path,
|
||||
) -> None:
|
||||
schema_dir = tmp_path / "schemas"
|
||||
schema_dir.mkdir()
|
||||
(schema_dir / "daily-triage-report.json").write_text(
|
||||
json.dumps({
|
||||
"type": "object",
|
||||
"required": ["summary", "recommendations"],
|
||||
"properties": {
|
||||
"summary": {"type": "string"},
|
||||
"recommendations": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["wsjf"],
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
encoding="utf-8",
|
||||
)
|
||||
monkeypatch.chdir(tmp_path)
|
||||
llm = FakeLLMClient(json.dumps({
|
||||
"summary": "Partial triage.",
|
||||
"recommendations": [{"rank": 1, "candidate": "CUST-WP-0045"}],
|
||||
}))
|
||||
monkeypatch.setattr(activities, "get_llm_client", lambda: llm)
|
||||
|
||||
result = await activities.evaluate_instructions({
|
||||
"instructions": [
|
||||
{
|
||||
"id": "daily-triage-report",
|
||||
"trusted_fields": [],
|
||||
"model": "test-model",
|
||||
"prompt": "Run report.",
|
||||
"output_schema": "schemas/daily-triage-report.json",
|
||||
"review_required": False,
|
||||
"report_sinks": [{"type": "working-memory", "path": "/tmp"}],
|
||||
}
|
||||
],
|
||||
"event": {},
|
||||
"context": {},
|
||||
})
|
||||
|
||||
assert result["task_specs"] == []
|
||||
assert len(result["reports"]) == 1
|
||||
report = result["reports"][0]
|
||||
assert report["output_validated"] is False
|
||||
assert report["review_required"] is True
|
||||
assert report["validation_error"] == "$.recommendations[0]: missing required property 'wsjf'"
|
||||
assert report["report"]["status"] == "validation_failed"
|
||||
assert report["report"]["partial_summary"] == "Partial triage."
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_evaluate_instructions_without_llm_client_returns_no_tasks(monkeypatch) -> None:
|
||||
class RaisingClient:
|
||||
|
||||
Reference in New Issue
Block a user