generated from coulomb/repo-seed
Set up daily WSJF closure gates
This commit is contained in:
@@ -28,13 +28,18 @@ def persist_reports(payload: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
"""
|
||||
results: list[dict[str, Any]] = []
|
||||
for report_entry in payload.get("reports", []):
|
||||
report_context = dict(report_entry)
|
||||
for sink in report_entry.get("sinks", []):
|
||||
sink_type = sink.get("type")
|
||||
try:
|
||||
if sink_type == "working-memory":
|
||||
results.append(_write_working_memory(payload, report_entry, sink))
|
||||
result = _write_working_memory(payload, report_context, sink)
|
||||
if result.get("path"):
|
||||
report_context["working_memory_path"] = result["path"]
|
||||
report_context["working_memory_status"] = result.get("status")
|
||||
results.append(result)
|
||||
elif sink_type == "state-hub-progress":
|
||||
results.append(_post_state_hub_progress(payload, report_entry, sink))
|
||||
results.append(_post_state_hub_progress(payload, report_context, sink))
|
||||
else:
|
||||
results.append({
|
||||
"type": sink_type or "unknown",
|
||||
@@ -132,6 +137,11 @@ def _post_state_hub_progress(
|
||||
"report": report,
|
||||
},
|
||||
}
|
||||
if report_entry.get("working_memory_path"):
|
||||
body["detail"]["working_memory_path"] = report_entry["working_memory_path"]
|
||||
body["detail"]["working_memory_status"] = report_entry.get(
|
||||
"working_memory_status"
|
||||
)
|
||||
for key in ("topic_id", "workstream_id", "task_id", "decision_id"):
|
||||
if sink.get(key):
|
||||
body[key] = sink[key]
|
||||
|
||||
@@ -126,6 +126,18 @@ def execute_instruction_with_audit(
|
||||
return _empty_result(instr)
|
||||
except Exception as exc:
|
||||
logger.warning("instruction %r failed — %s", instr.id, exc)
|
||||
failure_report = _execution_failure_report(instr, str(exc))
|
||||
if failure_report is not None:
|
||||
return InstructionResult(
|
||||
tasks=[],
|
||||
report=failure_report,
|
||||
prompt_hash=None,
|
||||
model=getattr(instr, "model", None),
|
||||
output_validated=False,
|
||||
review_required=True,
|
||||
condition_matched=getattr(instr, "condition", "") or None,
|
||||
validation_error=str(exc),
|
||||
)
|
||||
return _empty_result(instr)
|
||||
|
||||
|
||||
@@ -267,6 +279,19 @@ def _invalid_output_report(
|
||||
return report
|
||||
|
||||
|
||||
def _execution_failure_report(instr: Any, error: str) -> dict[str, Any] | None:
|
||||
"""Build a durable diagnostic report when a report instruction cannot run."""
|
||||
if not getattr(instr, "report_sinks", None):
|
||||
return None
|
||||
return {
|
||||
"summary": (
|
||||
f"Instruction {instr.id} could not run; operator review is required."
|
||||
),
|
||||
"status": "execution_failed",
|
||||
"validation_error": error,
|
||||
}
|
||||
|
||||
|
||||
def _validate_output(
|
||||
raw_output: Any,
|
||||
instr: Any,
|
||||
|
||||
Reference in New Issue
Block a user