generated from coulomb/repo-seed
Wire instruction report execution
This commit is contained in:
@@ -21,6 +21,7 @@ from activity_core.rules.executor import (
|
||||
UntrustedFieldError,
|
||||
_render_prompt,
|
||||
execute_instruction,
|
||||
execute_instruction_with_audit,
|
||||
)
|
||||
|
||||
|
||||
@@ -201,6 +202,82 @@ def test_valid_llm_output_returns_task_spec():
|
||||
assert result[0].source_type == "instruction"
|
||||
|
||||
|
||||
def test_execute_instruction_with_audit_returns_metadata():
|
||||
task_data = [{"title": "Run triage", "priority": "high"}]
|
||||
llm = _CountingLLM([json.dumps(task_data)])
|
||||
instr = _instr(
|
||||
id="daily-triage",
|
||||
condition="",
|
||||
prompt="Check State Hub.",
|
||||
trusted_fields=[],
|
||||
model="test-model",
|
||||
review_required=True,
|
||||
)
|
||||
|
||||
result = execute_instruction_with_audit(instr, _Event(), {}, llm)
|
||||
|
||||
assert len(result.tasks) == 1
|
||||
assert result.tasks[0].source_id == "daily-triage"
|
||||
assert result.prompt_hash is not None
|
||||
assert len(result.prompt_hash) == 64
|
||||
assert result.model == "test-model"
|
||||
assert result.output_validated is True
|
||||
assert result.review_required is True
|
||||
|
||||
|
||||
def test_execute_instruction_with_audit_accepts_report_payload():
|
||||
report_data = {
|
||||
"summary": "State Hub has loose ends.",
|
||||
"recommendations": [{"action": "revisit", "candidate": "CUST-WP-0045"}],
|
||||
}
|
||||
llm = _CountingLLM([json.dumps(report_data)])
|
||||
instr = _instr(
|
||||
id="daily-triage-report",
|
||||
prompt="Report.",
|
||||
trusted_fields=[],
|
||||
output_schema="schemas/daily-triage-report.json",
|
||||
)
|
||||
|
||||
result = execute_instruction_with_audit(instr, _Event(), {}, llm)
|
||||
|
||||
assert result.tasks == []
|
||||
assert result.report == report_data
|
||||
assert result.output_validated is True
|
||||
|
||||
|
||||
def test_execute_instruction_with_audit_rejects_invalid_report_schema():
|
||||
report_data = {"summary": "Missing recommendations."}
|
||||
llm = _CountingLLM([json.dumps(report_data), json.dumps(report_data)])
|
||||
instr = _instr(
|
||||
id="daily-triage-report",
|
||||
prompt="Report.",
|
||||
trusted_fields=[],
|
||||
output_schema="schemas/daily-triage-report.json",
|
||||
)
|
||||
|
||||
result = execute_instruction_with_audit(instr, _Event(), {}, llm)
|
||||
|
||||
assert result.tasks == []
|
||||
assert result.report is None
|
||||
assert result.output_validated is False
|
||||
assert llm.call_count == 2
|
||||
|
||||
|
||||
def test_execute_instruction_with_audit_accepts_report_and_tasks_envelope():
|
||||
envelope = {
|
||||
"report": {"summary": "Review needed."},
|
||||
"tasks": [{"title": "Inspect CUST-WP-0045"}],
|
||||
}
|
||||
llm = _CountingLLM([json.dumps(envelope)])
|
||||
instr = _instr(id="daily-triage-report", prompt="Report.", trusted_fields=[])
|
||||
|
||||
result = execute_instruction_with_audit(instr, _Event(), {}, llm)
|
||||
|
||||
assert result.report == {"summary": "Review needed."}
|
||||
assert len(result.tasks) == 1
|
||||
assert result.tasks[0].title == "Inspect CUST-WP-0045"
|
||||
|
||||
|
||||
# ── Condition pre-filter ───────────────────────────────────────────────────────
|
||||
|
||||
def test_condition_false_skips_llm():
|
||||
|
||||
Reference in New Issue
Block a user