kin: KIN-DOCS-004-backend_dev

This commit is contained in:
Gros Frumos 2026-03-19 20:30:50 +02:00
parent de52526659
commit ae2f0f1c81
8 changed files with 66 additions and 12 deletions

View file

@ -1347,14 +1347,29 @@ def _execute_department_head_step(
role = step["role"]
dept_name = role.replace("_head", "")
# Build initial context for workers: dept head's plan + artifacts
dept_plan_context = json.dumps({
"department_head_plan": {
"department": dept_name,
"artifacts": parsed.get("artifacts", {}),
"handoff_notes": parsed.get("handoff_notes", ""),
},
}, ensure_ascii=False)
# Extract context_packet (KIN-DOCS-004): fail-open if missing
context_packet = parsed.get("context_packet")
if context_packet is None and parent_pipeline_id:
try:
models.write_log(
conn, parent_pipeline_id,
f"Dept {step['role']}: context_packet missing from output — handoff quality degraded",
level="WARN",
extra={"role": step["role"]},
)
except Exception:
pass
# Build initial context for workers: context_packet first, then dept head's plan
dept_plan_context_dict: dict = {}
if context_packet is not None:
dept_plan_context_dict["context_packet"] = context_packet
dept_plan_context_dict["department_head_plan"] = {
"department": dept_name,
"artifacts": parsed.get("artifacts", {}),
"handoff_notes": parsed.get("handoff_notes", ""),
}
dept_plan_context = json.dumps(dept_plan_context_dict, ensure_ascii=False)
# KIN-084: log sub-pipeline start
if parent_pipeline_id:
@ -1429,6 +1444,7 @@ def _execute_department_head_step(
decisions_made=decisions_made,
blockers=[],
status=handoff_status,
context_packet=context_packet,
)
except Exception:
pass # Handoff save errors must never block pipeline
@ -1438,6 +1454,7 @@ def _execute_department_head_step(
"from_department": dept_name,
"handoff_notes": parsed.get("handoff_notes", ""),
"artifacts": parsed.get("artifacts", {}),
"context_packet": context_packet,
"sub_pipeline_summary": {
"steps_completed": sub_result.get("steps_completed", 0),
"success": sub_result.get("success", False),