From df128508a383d00b32b78342ff480010793fcd7d Mon Sep 17 00:00:00 2001 From: "Kevin Carter (via Claude)" Date: Sat, 4 Jul 2026 11:56:40 +0000 Subject: [PATCH] exam: persist command_word + preamble from analyse contract v2 (WS-2) _map_service_contract_to_rows now carries the two v2 fields onto exam_questions ghost rows (command_word on leaf parts, preamble jsonb). Requires supabase migration 78; applied to dev .94. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01GruxHXxfdp4kZCgAMVFgvV --- routers/exam/templates.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/routers/exam/templates.py b/routers/exam/templates.py index 72746e6..66d0fb8 100644 --- a/routers/exam/templates.py +++ b/routers/exam/templates.py @@ -745,6 +745,9 @@ def _map_service_contract_to_rows(template_id: str, contract: Dict[str, Any], "bounds": _frac_box_to_canvas(q.get("bounds"), q.get("page") or 1, pages), "page": q.get("page"), "source": "ai", "confirmed": False, "confidence": _safe_confidence(q.get("confidence")), "derivation": "extract-service", + # analyse contract v2 (migration 78): command verb + stem prose per part + "command_word": (q.get("command_word") or None) if not q.get("is_container") else None, + "preamble": q.get("preamble") or None, }) for q in questions: # FK safety: de-parent a dangling parent_id if q["parent_id"] and q["parent_id"] not in q_ids: