Add pre-ruling interim draft (טיוטת ביניים) for appeals committee
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m26s

Lets the chair generate a partial decision DOCX before the discussion-and-
ruling block is decided. Same template, skill and DOCX styling as the final
decision (David, RTL, bookmarks) — only the block selection and order differ:
רקע (ו) → תכניות+היתרים (ט) → טענות (ז) → הליכים (ח). The opening (ה),
ruling (י), summary (יא), and signatures (יב) are omitted.

- New appraiser_facts table + CRUD + conflict detection in db.py (V5 schema).
  Conflict = same plan/permit identifier reported differently by 2+ appraisers.
- New appraiser_facts_extractor service: per-appraisal Claude extraction of
  plans + permits with raw quotes and page numbers.
- block-tet prompt extended with a permits sub-section sourced from the
  extracted facts, plus an explicit instruction to flag inter-appraiser
  conflicts in neutral wording without resolving them (deferred to block-yod).
- block-chet prompt extended with a post-hearing materials context sourced
  from documents.metadata.is_post_hearing.
- docx_exporter.export_decision now accepts mode='interim' which reorders
  the blocks per the chair's mental model and writes
  טיוטת-ביניים-v{N}.docx (versioned independently of regular drafts).
- 3 new MCP tools: extract_appraiser_facts, write_interim_draft,
  export_interim_draft. write_interim_draft auto-runs extraction if the
  appraiser_facts table is empty for the case.
This commit is contained in:
2026-04-18 13:28:04 +00:00
parent 2b40e02a65
commit c619c22a51
7 changed files with 731 additions and 17 deletions

View File

@@ -573,3 +573,55 @@ Conclusion → Rule → Explanation → Application → Conclusion.
יא (סיכום) → תלוי ב: י (מסקנות). מפנה ל: י בלבד.
יב (חתימות) → עצמאי
```
---
## 7. טיוטת ביניים (Pre-Ruling Draft)
ועדת הערר לעיתים מבקשת לראות טיוטה חלקית **לפני** שהוועדה מכריעה — כאשר התיק
לא מגובש או יש מחלוקת בין חברי הוועדה. הטיוטה משמשת בסיס לדיון פנימי לקראת
פרק הדיון וההכרעה.
### מבנה טיוטת הביניים
המסמך משתמש **באותו טמפלט, אותו skill ואותם prompts** של החלטה רגילה (David
12pt, RTL, bookmarks). השוני היחיד הוא בחירת הבלוקים וסידורם:
| מקום | בלוק | תפקיד |
|------|------|-------|
| 1 (אופציונלי) | א-ד | העמוד הראשון. נכלל אם יש תוכן, ולא נדרש שיהיה. |
| 2 | **ו (רקע עובדתי)** | פתח דבר — מקרקעין, סביבה, היסטוריה, החלטה, ערר |
| 3 | **ט (תכניות + היתרים)** | פירוט התכניות החלות **+ תת-פרק היתרים מהשומות**, עם סימון סתירות בין שמאים |
| 4 | **ז (טענות הצדדים)** | תמצית טענות העוררים, הוועדה ומבקשי ההיתר |
| 5 | **ח (הליכים)** | דיון בפני הוועדה, נקודות חדשות שעלו, **השלמות טיעון ומשא-ומתן לפשרה** |
הבלוקים שמדולגים: ה (פתיחה), י (דיון והכרעה), יא (סיכום), יב (חתימות).
### עובדות שמאיות וזיהוי סתירות
בטיוטת ביניים, בלוק ט מורחב לכלול תת-פרק היתרים. המקור הוא טבלת
`appraiser_facts` ב-DB, שמתמלאת ע"י `extract_appraiser_facts` — הפועל על
מסמכים מסוג `appraisal` ומחלץ לכל שמאי בנפרד את התכניות וההיתרים שציין.
זיהוי סתירות נעשה ב-DB: כל זיהוי שצוין ע"י **שני שמאים שונים או יותר** נחשב
סתירה, ומועבר אל ה-prompt של בלוק ט בנוסח structured. ה-prompt מורה לסמן את
הסתירה במפורש, בנוסח ניטרלי (לדוגמה: "יצוין כי השמאי X ציין... בעוד השמאי Y
סבר כי..."), בלי להכריע בה — ההכרעה תתבצע (אם בכלל) בבלוק י של הטיוטה
הסופית.
### מסמכי פוסט-דיון
בלוק ח מקבל בקונטקסט גם רשימת מסמכים שתויגו כ-`metadata.is_post_hearing=true`
(השלמות טיעון, הצעות פשרה). תיוג זה נעשה בעת ההעלאה (UI/API).
### Pipeline
```
1. extract_appraiser_facts(case_number) # ממלא appraiser_facts + מזהה סתירות
2. write_interim_draft(case_number) # כותב blocks ו, ט, ז, ח (ב-DB)
3. export_interim_draft(case_number) # מייצר טיוטת-ביניים-v{N}.docx
```
`write_interim_draft` מריץ אוטומטית את `extract_appraiser_facts` אם הטבלה
ריקה. הקובץ הסופי נרשם כ-`active_draft_path` בדיוק כמו טיוטה רגילה, ולכן
`apply_user_edit` ו-`revise_draft` עובדים עליו ללא שינוי.