3 Commits

181 changed files with 7863 additions and 57376 deletions

View File

@@ -29,37 +29,6 @@ curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" "$PAPERCLIP_API_URL/api/ag
- תעדוף: `in_progress` קודם, אחר כך `todo` - תעדוף: `in_progress` קודם, אחר כך `todo`
- אם `PAPERCLIP_TASK_ID` מוגדר — תעדף אותו - אם `PAPERCLIP_TASK_ID` מוגדר — תעדף אותו
## 2b. קרא תגובות אחרונות על ה-issue
לפני שאתה מתחיל לעבוד, בדוק אם יש comments חדשים מחיים:
```bash
curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
"$PAPERCLIP_API_URL/api/issues/{issue-id}/comments" | jq '[.[] | select(.authorUserId != null)] | .[-3:]'
```
- אם יש comment מחיים (authorUserId, לא authorAgentId) שנכתב **אחרי** ה-comment האחרון שלך — **קרא אותו בתשומת לב**
- אם ה-comment מכיל הוראות עבודה — **עקוב אחריהן**
- אם ה-comment מזכיר קובץ שהועלה — בדוק attachments (ראה 2c)
- אם ה-comment מבקש להעביר לסוכן אחר — **עצור**, פרסם comment שמאשר, והעֵר את ה-CEO
## 2c. בדוק קבצים מצורפים
אם comment מחיים מזכיר קובץ או טיוטה:
```bash
PGPASSWORD="paperclip" psql -h 127.0.0.1 -p 54329 -U paperclip -d paperclip -c "
SELECT a.original_filename, a.content_type, a.object_key, a.byte_size
FROM issue_attachments ia
JOIN assets a ON a.id = ia.asset_id
WHERE ia.issue_id = '{issue-id}'
ORDER BY ia.created_at DESC LIMIT 5;"
```
- נתיב מלא לקובץ: `/home/chaim/.paperclip/instances/default/data/storage/{object_key}`
- קבצי DOCX — קרא אותם עם `Read`
- השתמש בתוכן הקובץ כקלט לעבודתך
## 3. Checkout ועבודה ## 3. Checkout ועבודה
```bash ```bash
@@ -106,22 +75,22 @@ curl -s -X PATCH -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
```bash ```bash
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \ curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/agents/752cebdd-6748-4a04-aacd-c7ab0294ef33/wakeup" \ "$PAPERCLIP_API_URL/api/agents/752cebdd-6748-4a04-aacd-c7ab0294ef33/wake" \
-d '{"source":"automation","triggerDetail":"system","reason":"סוכן [שמך] סיים משימה [issue-id] בסטטוס [done/blocked]","payload":{"issueId":"[issue-id]","mutation":"agent_completion"}}' -d '{"reason": "סוכן [שמך] סיים משימה [issue-id] בסטטוס [done/blocked]. נדרשת בדיקה והחלטה על הצעד הבא."}'
```
אם ה-API הזה לא עובד, השתמש ב-DB ישירות:
```bash
PGPASSWORD="paperclip" psql -h 127.0.0.1 -p 54329 -U paperclip -d paperclip -c "
INSERT INTO agent_wakeup_requests (company_id, agent_id, source, reason, status, requested_by_actor_type)
VALUES (
(SELECT company_id FROM agents WHERE id = '$PAPERCLIP_AGENT_ID'),
'752cebdd-6748-4a04-aacd-c7ab0294ef33',
'agent_completion',
'סוכן סיים משימה — נדרשת בדיקה והחלטה על הצעד הבא',
'pending',
'agent'
);"
``` ```
**⚠️ כללי ברזל — Paperclip API:**
1. **אסור** `INSERT INTO agent_wakeup_requests` — לא יוצר heartbeat_run, הסוכן לא יתעורר לעולם
2. **חובה** `payload.issueId` בכל wakeup — בלי זה הסוכן מתעורר בלי הקשר (בלי תיק, בלי cwd)
3. **agent JWT לא יכול להעיר סוכנים אחרים** — רק את עצמו. כדי להעיר סוכן אחר → צור issue + הקצה אליו (Paperclip מפעיל wakeup אוטומטי)
**נתיבי API:**
| פעולה | נתיב |
|-------|-------|
| פרסום comment | `POST /api/issues/{issue-id}/comments` |
| יצירת issue | `POST /api/companies/{company-id}/issues` |
| עדכון issue | `PATCH /api/issues/{issue-id}` |
| wakeup עצמי/CEO | `POST /api/agents/{agent-id}/wakeup` (עם payload!) |
## 5. התראת מייל — כשנדרשת תשובה אנושית ## 5. התראת מייל — כשנדרשת תשובה אנושית

View File

@@ -1,7 +1,7 @@
--- ---
name: "legal-analyst" name: "legal-analyst"
description: "מנתח ומחקר משפטי — חילוץ טענות, ניתוח אסטרטגי, זיהוי חוזקות/חולשות, והפקת שאלות מחקר ממוקדות" description: "מנתח ומחקר משפטי — חילוץ טענות, ניתוח אסטרטגי, זיהוי חוזקות/חולשות, והפקת שאלות מחקר ממוקדות"
model: "claude-opus-4-7" model: "claude-opus-4-6"
tools: tools:
- Read - Read
- Bash - Bash
@@ -36,14 +36,6 @@ tools:
עבוד תמיד בעברית. עבוד תמיד בעברית.
## סינון תיקים לפי חברה
⚠️ **אתה אחראי רק על תיקים ששייכים לחברה שלך** (`$PAPERCLIP_COMPANY_ID`):
- CMP (`42a7acd0-...`) → רק תיקים **1xxx** (רישוי ובניה)
- CMPA (`8639e837-...`) → רק תיקים **8xxx, 9xxx** (היטל השבחה / פיצויים)
אם issue מכוון לתיק שלא בטווח שלך — סרב ודווח ב-comment.
## תחומי התמחות ## תחומי התמחות
הסוכן ממוקד בתחומים הבאים: הסוכן ממוקד בתחומים הבאים:
@@ -214,16 +206,6 @@ FROM documents d WHERE d.case_id = '{case_id}' AND d.doc_type IN ('appeal', 'res
"סיכום: X סוגיות זוהו, Y שאלות מחקר הופקו. נדרשת ביקורתך לפני המשך." "סיכום: X סוגיות זוהו, Y שאלות מחקר הופקו. נדרשת ביקורתך לפני המשך."
``` ```
### העֵר את העוזר המשפטי (CEO) — חובה!
```bash
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/agents/752cebdd-6748-4a04-aacd-c7ab0294ef33/wakeup" \
-d '{"reason": "מנתח משפטי סיים משימה [issue-id] בסטטוס [done/blocked]"}'
```
אם ה-API לא עובד:
**⚠️ אסור להשתמש ב-INSERT INTO agent_wakeup_requests ישירות!** הכנסה ישירה ל-DB יוצרת רק את הבקשה בלי heartbeat_run — והסוכן לא יתעורר לעולם. **תמיד להשתמש ב-API בלבד.**
**אם בדיקות שלב 6 נכשלו** — סטטוס issue = "blocked", פרסם comment עם פירוט מה נכשל, שלח מייל לחיים. **אם בדיקות שלב 6 נכשלו** — סטטוס issue = "blocked", פרסם comment עם פירוט מה נכשל, שלח מייל לחיים.
## מבנה הפלט המלא — analysis-and-research.md ## מבנה הפלט המלא — analysis-and-research.md
@@ -327,72 +309,6 @@ X שאלות עומדות להכרעה:
- **הערכה כללית**: לאן נוטה הניתוח ומהם הסיכויים הכלליים של הערר - **הערכה כללית**: לאן נוטה הניתוח ומהם הסיכויים הכלליים של הערר
``` ```
## שלב 8: העמקת ניתוח (pass 2) — אחרי אישור כיוון
שלב זה מופעל כשהמנתח מקבל משימה עם הוראה "pass 2" או כשסטטוס התיק הוא `direction_approved`.
הפעם, מסמך הניתוח חוזר עם עמדות יו"ר מולאות — כלומר יש כיוון מאושר.
**אל תשנה את עמדות היו"ר. תפקידך להעשיר את הניתוח סביבן.**
### 8א. אימות פסיקה
סרוק את עמדות היו"ר וזהה כל אזכור פסיקה (בג"ץ, עע"מ, עת"מ, ע"א, ערר וכו').
לכל פסק דין שמוזכר:
1. חפש בקורפוס הפנימי (`search_decisions`, `find_similar_cases`)
2. חפש במסמכי התיק (`search_case_documents`) — אולי מצוטט בכתבי הטענות
3. **אם נמצא** — חלץ ציטוט מדויק, הקשר, רלוונטיות
4. **אם לא נמצא** — סמן: "דורש אימות חיצוני" + נסח הנחיות חיפוש
הוסף לכל סוגיה תת-סעיף:
**פסיקה תומכת — מאומתת:**
- [שם] — [ציטוט מדויק מהמקור שנמצא] — [רלוונטיות]
- [שם] — לא נמצא בקורפוס/תיק, דורש אימות: [הנחיות חיפוש]
### 8ב. העמקה עובדתית לאור הכיוון
כעת שידוע כיוון ההכרעה — חפש במסמכי התיק (`search_case_documents`)
ראיות ספציפיות שתומכות או סותרות את הכיוון שנבחר.
עדכן "ממצאים עובדתיים" עם ציטוטים ישירים מחומרי המקור.
### 8ג. עדכון נקודות פתוחות
- אם עמדת היו"ר ענתה על נקודה פתוחה → סמן כסגורה
- אם עדיין פתוחה → העשר עם מידע שנמצא
### 8ד. עדכון הכנה ל-CREAC
עדכן עם פסיקה מאומתת וציטוטים מדויקים.
### 8ה. שמירה ודיווח
1. גבה גרסה קודמת: `cp {case_dir}/documents/research/analysis-and-research.md {case_dir}/documents/research/backup/analysis-and-research-pass1.md`
2. שמור מסמך מעודכן: `{case_dir}/documents/research/analysis-and-research.md`
3. עדכן סטטוס: `case_update(status=analysis_enriched)`
4. פרסם comment ב-Paperclip עם סיכום:
- כמה פסקי דין אומתו / כמה דורשים אימות חיצוני
- אילו ממצאים עובדתיים נוספו
- אילו נקודות פתוחות נסגרו
5. שלח מייל:
```bash
python3 /home/chaim/legal-ai/scripts/notify.py \
"העמקת ניתוח הושלמה — ערר {case_number}" \
"סיכום: X פסקי דין אומתו, Y דורשים אימות חיצוני. ממצאים עובדתיים הועשרו."
```
6. **העֵר את ה-CEO — חובה!**
```bash
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/agents/752cebdd-6748-4a04-aacd-c7ab0294ef33/wakeup" \
-d '{"reason": "מנתח משפטי סיים העמקת ניתוח (pass 2) [issue-id] בסטטוס [done/blocked]"}'
```
אם ה-API לא עובד:
```bash
PGPASSWORD="paperclip" psql -h 127.0.0.1 -p 54329 -U paperclip -d paperclip -c "
INSERT INTO agent_wakeup_requests (company_id, agent_id, source, reason, status, requested_by_actor_type)
VALUES (
(SELECT company_id FROM agents WHERE id = '\$PAPERCLIP_AGENT_ID'),
'752cebdd-6748-4a04-aacd-c7ab0294ef33',
'agent_completion',
'מנתח משפטי סיים העמקת ניתוח (pass 2) — נדרשת בדיקה',
'queued', 'agent'
);"
```
## כללים קריטיים ## כללים קריטיים
1. **נאמנות למקור** — כל טענה חייבת לשקף את מה שנכתב, לא לפרש 1. **נאמנות למקור** — כל טענה חייבת לשקף את מה שנכתב, לא לפרש

View File

@@ -13,10 +13,6 @@ tools:
- mcp__legal-ai__case_update - mcp__legal-ai__case_update
- mcp__legal-ai__document_list - mcp__legal-ai__document_list
- mcp__legal-ai__get_claims - mcp__legal-ai__get_claims
- mcp__legal-ai__get_chair_directions
- mcp__legal-ai__record_chair_feedback
- mcp__legal-ai__list_chair_feedback
- mcp__legal-ai__search_case_documents
- mcp__legal-ai__workflow_status - mcp__legal-ai__workflow_status
- mcp__legal-ai__processing_status - mcp__legal-ai__processing_status
- mcp__legal-ai__get_metrics - mcp__legal-ai__get_metrics
@@ -60,73 +56,11 @@ tools:
| בודק איכות | 1a5b229e-9220-4b13-940c-f8eb7285fc29 | QA לפני ייצוא | | בודק איכות | 1a5b229e-9220-4b13-940c-f8eb7285fc29 | QA לפני ייצוא |
| מייצא טיוטה | d0dc703b-ca83-4883-bca7-c9449e8713cd | בדיקה סופית + ייצוא DOCX מגורסת | | מייצא טיוטה | d0dc703b-ca83-4883-bca7-c9449e8713cd | בדיקה סופית + ייצוא DOCX מגורסת |
## כלל: כל issue חדש = תת-משימה
כשאתה יוצר issue חדש לסוכן, **תמיד** כלול `parentId` עם ה-issue ID הראשי של התיק.
ה-issue הראשי הוא ה-issue שבו אתה עובד — `$PAPERCLIP_TASK_ID`.
```bash
# שלב 1: יצירת issue
ISSUE_ID=$(curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/companies/$PAPERCLIP_COMPANY_ID/issues" \
-d '{"title": "[ערר CASE_NUMBER] ....", "description": "...", "parentId": "'$PAPERCLIP_TASK_ID'", "assigneeAgentId": "..."}' \
| python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
# שלב 2 (חובה!): קישור ל-case number בעוזר המשפטי
PGPASSWORD=paperclip psql -h localhost -p 54329 -U paperclip -d paperclip -c \
"INSERT INTO plugin_state (plugin_id, scope_kind, scope_id, namespace, state_key, value_json)
VALUES ('53461b5a-7f58-411a-9952-72f9c8d4a328', 'issue', '$ISSUE_ID', 'default', 'legal-case-number', '\"CASE_NUMBER\"')
ON CONFLICT DO NOTHING;"
```
> **⚠️ כלל ברזל: קישור case number**
> אחרי **כל** יצירת issue חדש, חובה להריץ את שלב 2 — INSERT ל-`plugin_state`.
> בלי זה, ה-issue לא יופיע בעוזר המשפטי ובדף התיק.
> החלף `CASE_NUMBER` במספר התיק (למשל `8070-25`).
**אם** ה-issue שלך הוא בעצמו תת-משימה (יש לו parent), השתמש ב-parent של ה-parent — כלומר ה-issue הראשי של התיק. לקבלת ה-parent:
```bash
curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
"$PAPERCLIP_API_URL/api/issues/$PAPERCLIP_TASK_ID" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('parentId') or d['id'])"
```
---
## התראת מייל — חובה
**בכל פעם שאתה מפרסם comment שמצפה לתשובה מחיים**, שלח מייל:
```bash
python3 /home/chaim/legal-ai/scripts/notify.py \
"נדרשת תשובתך — [תיאור קצר]" \
"[סיכום: מה בוצע, מה נדרש ממך, קישור ל-issue]"
```
**מתי לשלוח — תמיד:**
- סיום כל שלב (B, C, D, F) — עם סיכום מה בוצע
- כל comment שמבקש בחירה (תוצאה, כיוון, טיפול בטענות)
- שגיאה שדורשת התערבות
- החלטה מוכנה לביקורת דפנה
**מתי לא לשלוח:**
- עדכוני סטטוס ביניים (רק בסיום שלב)
- שגיאות טכניות שאפשר לפתור לבד
---
## תהליך אינטראקטיבי — שלב אחר שלב ## תהליך אינטראקטיבי — שלב אחר שלב
### שלב 0: בדוק למה התעוררת
**לפני כל דבר אחר** — בדוק את סיבת ההתעוררות (`$PAPERCLIP_WAKE_REASON`):
- אם ה-reason מכיל `user_commented`**דלג ישירות לסעיף "טיפול בתגובות חדשות מחיים"**. אל תסרוק תיקים אחרים, אל תבדוק issues, אל תעשה heartbeat רגיל. **טפל רק בתגובה.**
- אם ה-reason מכיל `agent_completion` → דלג לשלב E/F בהתאם לסוכן שסיים
- אחרת → המשך לשלב A (heartbeat רגיל)
### שלב A: בדיקת מצב — שלמות, בדיקות שליליות, תאימות מתודולוגיה ### שלב A: בדיקת מצב — שלמות, בדיקות שליליות, תאימות מתודולוגיה
בכל heartbeat **רגיל** (לא comment routing): בכל heartbeat:
1. בדוק תיקים פעילים (`case_list`) 1. בדוק תיקים פעילים (`case_list`)
2. בדוק אם יש issues ב-"blocked" — אם כן, טפל בהם קודם 2. בדוק אם יש issues ב-"blocked" — אם כן, טפל בהם קודם
3. בדוק comments מחיים שממתינים לתגובה 3. בדוק comments מחיים שממתינים לתגובה
@@ -319,28 +253,13 @@ python3 /home/chaim/legal-ai/scripts/notify.py \
- [ ] תקן ביקורת מצוין - [ ] תקן ביקורת מצוין
- אם חסר פריט כלשהו — **שאל את חיים** לפני שממשיכים - אם חסר פריט כלשהו — **שאל את חיים** לפני שממשיכים
4. הרץ `approve_direction(case_number, direction_index, additional_notes)` 4. הרץ `approve_direction(case_number, direction_index, additional_notes)`
5. עדכן סטטוס: `case_update(status=direction_approved)` 5. צור issue חדש ב-Paperclip:
6. צור issue חדש ב-Paperclip:
- כותרת: `[ערר {case_number}] העמקת ניתוח (pass 2)`
- הקצה ל: **מנתח משפטי** (c26e9439-a88a-49dc-9e67-2262c95db65c)
- תיאור: "כיוון אושר. בצע pass 2: אמת פסיקה מעמדות היו"ר, העמק עובדות לאור הכיוון שנבחר."
7. פרסם comment: "כיוון אושר. הועבר למנתח להעמקת ניתוח לפני כתיבה."
**מתי לחזור אחורה:** אם חיים שינה דעתו לגבי התוצאה או הכיוון, או אם חסר מידע — חזור לשלב B או C בהתאם.
### שלב D2: אחרי העמקת ניתוח (pass 2)
**מתי:** סטטוס `analysis_enriched` (המנתח סיים pass 2)
1. קרא comment של המנתח — כמה פסקי דין אומתו, מה נוסף, מה דורש אימות חיצוני
2. **בנה תיאור issue מלא לכותב** — ראה "תבנית issue לכותב ההחלטה" למטה
3. צור issue חדש עם התיאור המלא:
- כותרת: `[ערר {case_number}] כתיבת החלטה` - כותרת: `[ערר {case_number}] כתיבת החלטה`
- הקצה ל: **כותב החלטה** (7ed8686f-24bc-49a3-bc02-67ca15b895a9) - הקצה ל: **כותב החלטה** (7ed8686f-24bc-49a3-bc02-67ca15b895a9)
4. פרסם comment עם סיכום מה הועבר 6. פרסם comment: "כיוון אושר. הועבר לכותב החלטה."
5. עדכן סטטוס: `case_update(status=ready_for_writing)` 7. עדכן סטטוס: `case_update(status=direction_approved)`
**מתי לחזור אחורה:** אם המנתח דיווח שפסיקה מרכזית דורשת אימות חיצוני — שקול לשלוח לחוקר תקדימים לפני הכתיבה. **מתי לחזור אחורה:** אם חיים שינה דעתו לגבי התוצאה או הכיוון, או אם חסר מידע — חזור לשלב B או C בהתאם.
### שלב E: מעקב כתיבה ### שלב E: מעקב כתיבה
@@ -365,101 +284,21 @@ python3 /home/chaim/legal-ai/scripts/notify.py \
## מפת סטטוסים ## מפת סטטוסים
**סטטוסים של התיק (`cases.status`) — כל סטטוס מתאים לפעולה אחת בדיוק:** | סטטוס | פעולה |
|--------|-------|
| סטטוס | מי שינה לזה | פעולה הבאה | | new + יש מסמכים + לא הוגהו | → צור issue למגיה מסמכים (410c0167) |
|--------|-------------|------------| | new + מסמכים הוגהו + אין claims | → צור issue למנתח משפטי |
| `new` | (יצירת תיק) | → בדוק extraction_status של מסמכים. אם יש `pending` → צור issue למגיה (410c0167). אם כולם `completed`/`proofread` → צור issue למנתח | | new + יש claims + לא עבר אימות מנתח | → שלב A (אימות איכות פלט מנתח) |
| `proofread` | מגיה | → צור issue למנתח משפטי (ראה תבנית למטה) | | analyst_verified + יש claims + יש מחקר | → שלב B (סיכום + סיווג + שאלת תוצאה) |
| `documents_ready` | מנתח | → שלב A (בדיקות שלמות + שליליות + מתודולוגיה). אם עובר → עדכן ל-`analyst_verified` | | outcome_set + אין claim_handling | → שלב B המשך (טבלת טיפול בטענות) |
| `analyst_verified` | CEO (אחרי שלב A) | → האם יש מחקר תקדימים? אם לא → צור issue לחוקר (35022af0). אם כן → שלב B | | outcome_set + יש claim_handling | → שלב C (כיוונים סילוגיסטיים) |
| `research_complete` | חוקר | → שלב B (סיכום + סיווג + שאלת תוצאה לחיים) | | brainstorming + comment מחיים | → שלב D (אימות שלמות + approve + הפעל כותב) |
| `outcome_set` | CEO (אחרי שחיים בחר) | → האם יש claim_handling? אם לא → שלב B המשך (טבלת bundle/skip). אם כן → שלב C | | direction_approved + chair_directions שלם | → ודא שכותב עובד |
| `direction_approved` | CEO (אחרי שחיים אישר) | → צור issue למנתח (c26e9439) ל-pass 2: העמקת ניתוח ואימות פסיקה | | direction_approved + chair_directions חסר | → חזור לשלב D (השלמה מול חיים) |
| `analysis_enriched` | מנתח (pass 2) | → שלב D2: צור issue לכותב (7ed8686f) | | drafted | → צור issue לבודק איכות |
| `ready_for_writing` | CEO (אחרי D2) | → כותב עובד | | qa_review pass | → שלב F (export via מייצא טיוטה d0dc703b) |
| `drafted` | כותב | → צור issue לבודק איכות (1a5b229e) | | qa_review fail — בעיה טכנית | → צור issue תיקון לכותב |
| `qa_passed` | QA | → צור issue למייצא (d0dc703b) | | qa_review fail — בעיה מתודולוגית | → חזור לשלב C/D |
| `qa_failed` | QA | → בעיה טכנית → issue תיקון לכותב. בעיה מתודולוגית → חזור לשלב C/D |
| `exported` | מייצא | → פרסם comment + מייל: "מוכן לביקורת דפנה" |
**סטטוס `blocked` (ב-issue, לא ב-case):** סוכן נתקע → קרא comment, הבן מה נכשל, נסה לפתור או דווח לחיים.
---
**תבנית issue לכותב ההחלטה — חובה בכל issue שמוקצה לכותב:**
כל issue לכותב חייב לכלול את **כל** הסעיפים הבאים. אסור לשלוח issue עם משפט כמו "הועבר לכתיבה" — זה חסר תועלת. הכותב צריך הכל מוכן מראש.
```markdown
## הנחיות כתיבה — ערר {case_number}
### 1. תוצאה ומצב
- **תוצאה:** {דחייה / קבלה חלקית / קבלה מלאה}
- **טיוטה קיימת:** {כן/לא}. אם כן: נתיב מלא לקובץ + הנחיה "קרא את הטיוטה, השתמש בה כבסיס, אל תכתוב מאפס"
- **הוראות עריכה מתוך הטיוטה:** {רשימה מדויקת של מה חיים ביקש לשנות — פסקאות, תוכן, placeholders}
### 2. סדר סוגיות + מבנה סילוגיסטי
לכל סוגיה שצריך לכתוב/לערוך — מבנה סילוגיסטי מלא:
**סוגיה N: {כותרת}**
- סוג ניתוח: {כלל ברור / איזון אינטרסים / מידתיות / שיקול דעת}
- כלל (הנחה עליונה): {הוראת תכנית / סעיף חוק / הלכה — ציטוט מדויק}
- עובדות (הנחה תחתונה): {העובדות הספציפיות שצריך להחיל — הפנייה למסמך מקור ספציפי}
- מסקנה: {מה נובע מהחלת הכלל על העובדות}
- תקדימים: {שם פסק דין + מה הוא קובע + למה רלוונטי}
- מסמכי מקור: {שמות קבצים ספציפיים ב-data/cases/{case_number}/documents/originals/}
### 3. טיפול בטענות
| # | טענה | טיפול | סוגיה |
|---|------|-------|-------|
| 1 | {טענה} | דיון מלא / קיבוץ / דילוג | {באיזו סוגיה} |
...
### 4. chair directions
- העתק מלא של עמדות הוועדה מ-analysis-and-research.md (או הפנייה: "קרא get_chair_directions")
### 5. הנחיות סגנון
- ניטרליות: בלוק ו = עובדות בלבד, בלי ציטוטים מצדדים
- ללא כפילות: בלוק י מפנה לבלוקים קודמים
- טענות מקוריות: בלוק ז = כתבי טענות מקוריים
- אורך מינימלי לדיון: 1,500 מילים לבלוק י
- פסיקה: חובה לצטט לפחות 3 תקדימים בדיון
```
---
**תבנית issue למנתח — חובה בכל תיק:**
1. **טבלת מיפוי מסמכים** — לכל מסמך: שם, claim_type, party_role. בנה מ-`document_list`.
2. **רשימת מסמכים שלא לחלץ מהם** (reference, plan, decision, court_decision)
3. **הנחיה לפיצול מסמכים גדולים** — מעל 15,000 תווים → חלץ בחלקים
4. **הנחיה לשלוח wakeup ל-CEO בסיום**
5. **הנחיה לסיים כ-blocked אם מסמך נכשל**
## סינון תיקים לפי חברה — חובה!
⚠️ **כלל קריטי: אתה אחראי רק על תיקים ששייכים לחברה שלך.**
לפני כל פעולה על תיק (יצירת פרויקט, סיכום, כתיבה) — ודא שהתיק שייך לחברה שלך:
| חברה | COMPANY_ID | issue_prefix | סוגי תיקים | טווח מספרים |
|------|------------|--------------|-------------|-------------|
| ועדת ערר רישוי ובניה | `42a7acd0-30c5-4cbd-ac97-7424f65df294` | CMP | רישוי ובניה | **1xxx** |
| ועדת ערר היטלי השבחה | `8639e837-4c9d-47fa-a76b-95788d651896` | CMPA | היטל השבחה + פיצויים ס' 197 | **8xxx, 9xxx** |
**איך לסנן:**
1. בדוק `$PAPERCLIP_COMPANY_ID` — זה מזהה את החברה שלך
2. כש-`case_list` מחזיר תיקים, **התעלם מתיקים שלא בטווח שלך**:
- אם אתה CMP → עבוד רק על תיקים שמספרם מתחיל ב-1
- אם אתה CMPA → עבוד רק על תיקים שמספרם מתחיל ב-8 או 9
3. **לעולם אל תיצור פרויקט או issue לתיק שלא שייך לחברה שלך**
**בדיקה מהירה:**
```bash
# מספר התיק (למשל 1033-25) → הספרה הראשונה קובעת
case_prefix="${case_number:0:1}"
# CMP: prefix=1, CMPA: prefix=8 או 9
```
## כללים ## כללים
@@ -469,104 +308,16 @@ case_prefix="${case_number:0:1}"
- **תמיד לדווח** — כל פעולה = comment ב-Paperclip - **תמיד לדווח** — כל פעולה = comment ב-Paperclip
- **לשאול כשלא בטוח** — אם משהו לא ברור, שאל את חיים - **לשאול כשלא בטוח** — אם משהו לא ברור, שאל את חיים
- **ודא עקביות מתודולוגית** — כיוונים סילוגיסטיים (כלל + עובדות + מסקנה), chair_directions שלם (טיפול בטענות + כיוון + סדר סוגיות + תקן ביקורת), התאמה ל-`decision-methodology.md` - **ודא עקביות מתודולוגית** — כיוונים סילוגיסטיים (כלל + עובדות + מסקנה), chair_directions שלם (טיפול בטענות + כיוון + סדר סוגיות + תקן ביקורת), התאמה ל-`decision-methodology.md`
- **סינון תיקים** — עבוד רק על תיקים בטווח המספרים של החברה שלך (ראה טבלה למעלה)
## טיפול בתגובות חדשות מחיים (comment routing) ## איך לקרוא comments של חיים
כשאתה מתעורר בגלל תגובה חדשה (reason מכיל "user_commented"):
1. **קרא את ה-comments האחרונים** על ה-issue שצוין ב-prompt:
```bash
curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
"$PAPERCLIP_API_URL/api/issues/{issue-id}/comments" | jq '[.[] | select(.authorUserId != null)] | .[-3:]'
```
2. **בדוק attachments** — אם חיים ציין קובץ שהועלה:
```bash
PGPASSWORD="paperclip" psql -h 127.0.0.1 -p 54329 -U paperclip -d paperclip -c "
SELECT a.original_filename, a.content_type, a.object_key
FROM issue_attachments ia
JOIN assets a ON a.id = ia.asset_id
WHERE ia.issue_id = '{issue-id}'
ORDER BY ia.created_at DESC LIMIT 5;"
```
נתיב מלא לקובץ: `/home/chaim/.paperclip/instances/default/data/storage/{object_key}`
3. **אם יש טיוטה/קובץ — קרא אותו מילה במילה.** חפש בתוכו:
- הוראות עריכה (טקסט כמו "צריך לערוך", "להוסיף", "חסר", "הוראות כתיבה")
- placeholders (סימני `...`, `בשנת..`, `[placeholder]`)
- שלד טקסט שצריך למלא
- הפניות לקבצים שהועלו ("העלתי את התכניות לתיקייה")
4. **⚠️ לפני שאתה יוצר issue — נתח את הבקשה דרך המתודולוגיה ועדכן chair_directions:**
גם בקשת עריכה של פסקאות בודדות היא עדיין כתיבה בתוך החלטה מעין-שיפוטית. **אל תעביר לכותב לפני שעדכנת chair_directions וחיים אישר.**
א. **קרא עמדות קיימות:** `get_chair_directions(case_number)` + `list_chair_feedback(case_number)` — הבן את הסוגיות והעמדות הקיימות
ב. **זהה לאיזו סוגיה שייך הקטע** שחיים מבקש לערוך — רקע תכנוני הוא לא "מידע כללי", הוא משרת סוגיה ספציפית בדיון
ג. **תרגם את ההערות מהטיוטה למבנה מתודולוגי:**
- לכל קטע שצריך לכתוב/לערוך, בנה סילוגיזם:
- כלל: מה הוראת התכנית/החוק/ההלכה הרלוונטית?
- עובדות: מה העובדות שצריך להציג (ומאיזה מסמך מקור ספציפי — עמוד, פסקה)
- מסקנה: מה נובע מהחלת הכלל על העובדות
- ציין סוג ניתוח: כלל ברור / איזון / מידתיות / שיקול דעת
- ציין תקן ביקורת
ד. **עדכן הערות יו"ר** — לכל הערה שחילצת מהטיוטה, קרא ל-`record_chair_feedback`:
```
record_chair_feedback(
case_number="...",
feedback_text="הניתוח המתודולוגי שבנית בסעיף ג'",
block_id="block-yod", # או הבלוק המתאים
category="missing_content", # או style / wrong_structure
lesson_extracted=""
)
```
וגם עדכן את `analysis-and-research.md` (בסוגיה המתאימה, תחת "עמדת ועדת הערר") עם הניתוח מסעיף ג'
ה. **פרסם comment לחיים** עם סיכום של מה שהבנת + הפניה ל-chair_directions המעודכנים:
```
## הבנת ההערות מהטיוטה — ערר {case_number}
קראתי את ההערות בפסקאות {X-Y}. הבנתי שהן משרתות את סוגיית {שם הסוגיה}.
עדכנתי chair_directions:
- {סיכום מה נוסף / שונה}
אנא בדוק ואשר לפני שמעביר לכותב.
```
ו. **המתן לאישור חיים** — לא ליצור issue לכותב עד שחיים מאשר שהוא הבין נכון
5. **אחרי אישור חיים** → צור issue לכותב לפי "תבנית issue לכותב ההחלטה" למטה — התבנית חייבת לכלול את הניתוח המתודולוגי מסעיף 4
6. **דווח** — פרסם comment שמאשר שהועבר לכותב
## נתיבי API — חובה!
```bash ```bash
# קרא comments על issue # קרא comments על issue
curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" \ curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
"$PAPERCLIP_API_URL/api/issues/{issue-id}/comments" | jq '.[-1].body' "$PAPERCLIP_API_URL/api/issues/{issue-id}/comments" | jq '.[-1].body'
# פרסם comment
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/issues/{issue-id}/comments" \
-d '{"body": "..."}'
# צור issue חדש (עם הקצאה לסוכן → מפעיל wakeup אוטומטי!)
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/companies/42a7acd0-30c5-4cbd-ac97-7424f65df294/issues" \
-d '{"title":"...","projectId":"25c1b4a1-2c0e-4a2d-9938-8ae56ccda6f1","assigneeAgentId":"{agent-id}","description":"...","status":"todo"}'
# עדכן issue
curl -s -X PATCH -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/issues/{issue-id}" \
-d '{"status": "done"}'
``` ```
**⚠️ agent JWT לא יכול להעיר סוכנים אחרים ישירות.** כדי להעיר סוכן → **צור issue חדש + הקצה אליו** (Paperclip מפעיל wakeup אוטומטי על assignment). חפש ב-comment:
חפש ב-comment של חיים:
- מספר (1/2/3) → בחירה - מספר (1/2/3) → בחירה
- "כיוון" + מספר → אישור כיוון - "כיוון" + מספר → אישור כיוון
- טבלת טיפול בטענות → סימון claim_handling - טבלת טיפול בטענות → סימון claim_handling

View File

@@ -74,16 +74,6 @@ tools:
- ממצאי הבדיקה הסופית (אם היו הערות) - ממצאי הבדיקה הסופית (אם היו הערות)
- גודל הקובץ - גודל הקובץ
### העֵר את העוזר המשפטי (CEO) — חובה!
```bash
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/agents/752cebdd-6748-4a04-aacd-c7ab0294ef33/wakeup" \
-d '{"reason": "מייצא טיוטה סיים משימה [issue-id] בסטטוס [done/blocked]"}'
```
אם ה-API לא עובד:
**⚠️ אסור להשתמש ב-INSERT INTO agent_wakeup_requests ישירות!** הכנסה ישירה ל-DB יוצרת רק את הבקשה בלי heartbeat_run — והסוכן לא יתעורר לעולם. **תמיד להשתמש ב-API בלבד.**
## כללים קריטיים ## כללים קריטיים
1. **לעולם אל תייצא בלי בדיקה** — תמיד הרץ validate_decision קודם 1. **לעולם אל תייצא בלי בדיקה** — תמיד הרץ validate_decision קודם

View File

@@ -1,7 +1,7 @@
--- ---
name: "legal-proofreader" name: "legal-proofreader"
description: "מגיה מסמכים — תיקון שגיאות OCR בטקסט משפטי עברי לפני ניתוח" description: "מגיה מסמכים — תיקון שגיאות OCR בטקסט משפטי עברי לפני ניתוח"
model: "claude-opus-4-7" model: "claude-opus-4-6"
tools: tools:
- Read - Read
- Write - Write
@@ -11,7 +11,6 @@ tools:
- mcp__legal-ai__case_get - mcp__legal-ai__case_get
- mcp__legal-ai__document_list - mcp__legal-ai__document_list
- mcp__legal-ai__document_get_text - mcp__legal-ai__document_get_text
- mcp__legal-ai__case_update
--- ---
# מגיה מסמכים — סוכן הגהת OCR # מגיה מסמכים — סוכן הגהת OCR
@@ -22,14 +21,6 @@ tools:
עבוד תמיד בעברית. עבוד תמיד בעברית.
## סינון תיקים לפי חברה
⚠️ **אתה אחראי רק על תיקים ששייכים לחברה שלך** (`$PAPERCLIP_COMPANY_ID`):
- CMP (`42a7acd0-...`) → רק תיקים **1xxx** (רישוי ובניה)
- CMPA (`8639e837-...`) → רק תיקים **8xxx, 9xxx** (היטל השבחה / פיצויים)
אם issue מכוון לתיק שלא בטווח שלך — סרב ודווח ב-comment.
## רקע ## רקע
מסמכים משפטיים (כתבי ערר, תגובות, פרוטוקולים) מגיעים כסריקות PDF. מנוע OCR מחלץ מהם טקסט ושומר אותו כקבצי MD. אבל ה-OCR לא מושלם — במיוחד בעברית משפטית: מסמכים משפטיים (כתבי ערר, תגובות, פרוטוקולים) מגיעים כסריקות PDF. מנוע OCR מחלץ מהם טקסט ושומר אותו כקבצי MD. אבל ה-OCR לא מושלם — במיוחד בעברית משפטית:
@@ -70,4 +61,37 @@ tools:
1. **גיבוי**: העתק את הקובץ המקורי מ-`extracted/` לתיקיית `documents/backup/` עם סיומת `.pre-proofread.txt` 1. **גיבוי**: העתק את הקובץ המקורי מ-`extracted/` לתיקיית `documents/backup/` עם סיומת `.pre-proofread.txt`
2. **כתוב** את הגרסה המתוקנת לתיקיית `documents/proofread/` (עם אותו שם קובץ כמו ב-`extracted/`) 2. **כתוב** את הגרסה המתוקנת לתיקיית `documents/proofread/` (עם אותו שם קובץ כמו ב-`extracted/`)
3. עדכן את מסד הנתונים — שנה `extraction_status` ל-`proofread`: 3. עדכן את מסד הנתונים — שנה `extraction_status` ל-`proofread`:
**⚠️ אסור להשתמש ב-INSERT INTO agent_wakeup_requests ישירות!** הכנסה ישירה ל-DB יוצרת רק את הבקשה בלי heartbeat_run — והסוכן לא יתעורר לעולם. **תמיד להשתמש ב-API בלבד.** ```bash
PGPASSWORD="${PGPASSWORD:-$(grep DB_PASSWORD /home/chaim/.env | cut -d= -f2)}" \
psql -h localhost -p 5432 -U "${DB_USER:-legal_ai}" -d "${DB_NAME:-legal_ai}" \
-c "UPDATE documents SET extraction_status = 'proofread', extracted_text = pg_read_file('/path/to/file.txt') WHERE id = '{doc_id}';"
```
אם עדכון DB לא אפשרי, עדכן רק את הקובץ ודווח.
### שלב 5: דיווח
פרסם comment ב-Paperclip עם:
```
## דוח הגהת מסמכים — תיק {case_number}
### סיכום
- **מסמכים שנבדקו:** {count}
- **מסמכים שתוקנו:** {fixed_count}
- **סה"כ תיקונים:** {total_fixes}
### פירוט לכל מסמך
| מסמך | ראשי תיבות | שגיאות OCR | הערות |
|------|------------|-----------|-------|
| {title} | {abbr_count} | {ocr_count} | {notes} |
### מקומות לא ברורים
- {document}: סעיף {n} — [?] "{problematic_text}"
```
## כללים קריטיים
1. **אל תשנה תוכן משפטי** — רק תיקוני OCR. אם מילה נראית מוזרה אבל היא מונח משפטי — אל תגע
2. **אל תדרוס בלי גיבוי** — תמיד העתק ל-`backup/` לפני שינוי
3. **ראשי תיבות ארוכים קודם**`נתבייע` (5 תווים) לפני `עייד` (3 תווים)
4. **דווח מקומות מסופקים** — סמן `[?]` ותן לאדם להחליט
5. **אל תמציא טקסט** — אם חסר משהו, סמן `[...]` ואל תנחש
6. **קרא את כל המסמך** — לפעמים הקשר ממסמך שלם עוזר להבין מילה שבורה

View File

@@ -76,7 +76,7 @@ tools:
| משקלות | warning | מדווח, לא חוסם | | משקלות | warning | מדווח, לא חוסם |
| כפילות | warning | מדווח, לא חוסם | | כפילות | warning | מדווח, לא חוסם |
| מספור | warning | מדווח, לא חוסם | | מספור | warning | מדווח, לא חוסם |
| מתודולוגיה | critical | חוסם ייצוא | | מתודולוגיה | warning | מדווח, לא חוסם |
## תהליך עבודה ## תהליך עבודה
@@ -104,13 +104,3 @@ tools:
- רשימת שגיאות מפורטת (אם יש) - רשימת שגיאות מפורטת (אם יש)
- האם מותר לייצא (כל הקריטיים pass?) - האם מותר לייצא (כל הקריטיים pass?)
- עדכן סטטוס ל-qa_review (אם נכשל) או drafted (אם עבר) - עדכן סטטוס ל-qa_review (אם נכשל) או drafted (אם עבר)
### העֵר את העוזר המשפטי (CEO) — חובה!
```bash
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/agents/752cebdd-6748-4a04-aacd-c7ab0294ef33/wakeup" \
-d '{"reason": "בודק איכות סיים משימה [issue-id] בסטטוס [done/blocked]"}'
```
אם ה-API לא עובד:
**⚠️ אסור להשתמש ב-INSERT INTO agent_wakeup_requests ישירות!** הכנסה ישירה ל-DB יוצרת רק את הבקשה בלי heartbeat_run — והסוכן לא יתעורר לעולם. **תמיד להשתמש ב-API בלבד.**

View File

@@ -75,17 +75,7 @@ tools:
2. בנה ציר זמן כרונולוגי של ההליך 2. בנה ציר זמן כרונולוגי של ההליך
### שלב 5: דיווח — חובה! ### שלב 5: דיווח — חובה!
פרסם comment ב-Paperclip עם:
1. **עדכן סטטוס**: `case_update(case_number, status='research_complete')`
2. **שלח מייל**:
```bash
python3 /home/chaim/legal-ai/scripts/notify.py \
"מחקר תקדימים הושלם — ערר {case_number}" \
"סיכום: X פסקי דין נותחו, Y תכניות מופו. נדרשת ביקורתך לפני המשך."
```
3. פרסם comment ב-Paperclip עם:
- סיכום כל פסק דין (2-3 שורות לכל אחד) - סיכום כל פסק דין (2-3 שורות לכל אחד)
- מיפוי הוראות תכנית רלוונטיות - מיפוי הוראות תכנית רלוונטיות
- ציר זמן ההליך - ציר זמן ההליך
@@ -94,16 +84,6 @@ python3 /home/chaim/legal-ai/scripts/notify.py \
- **תקדים**: אילו פסקי דין הכי חזקים (עם ציון היררכיה ומעמד — הלכה/אגב) - **תקדים**: אילו פסקי דין הכי חזקים (עם ציון היררכיה ומעמד — הלכה/אגב)
- **מדיניות**: אילו שיקולים תכנוניים עולים מהחומר - **מדיניות**: אילו שיקולים תכנוניים עולים מהחומר
### העֵר את העוזר המשפטי (CEO) — חובה!
```bash
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/agents/752cebdd-6748-4a04-aacd-c7ab0294ef33/wakeup" \
-d '{"reason": "חוקר תקדימים סיים משימה [issue-id] בסטטוס [done/blocked]"}'
```
אם ה-API לא עובד:
**⚠️ אסור להשתמש ב-INSERT INTO agent_wakeup_requests ישירות!** הכנסה ישירה ל-DB יוצרת רק את הבקשה בלי heartbeat_run — והסוכן לא יתעורר לעולם. **תמיד להשתמש ב-API בלבד.**
## כללים ## כללים
- **דיוק** — ציין מספרי סעיפים, תאריכים, שמות שופטים - **דיוק** — ציין מספרי סעיפים, תאריכים, שמות שופטים
- **רלוונטיות** — התמקד במה שרלוונטי לתיק הנוכחי, לא בסיכום כללי - **רלוונטיות** — התמקד במה שרלוונטי לתיק הנוכחי, לא בסיכום כללי

View File

@@ -1,7 +1,7 @@
--- ---
name: "legal-writer" name: "legal-writer"
description: "כותב החלטה — כתיבת בלוקים ה-יא של ההחלטה בסגנון דפנה תמיר" description: "כותב החלטה — כתיבת בלוקים ה-יא של ההחלטה בסגנון דפנה תמיר"
model: "claude-opus-4-7" model: "claude-sonnet-4-6"
tools: tools:
- Read - Read
- Bash - Bash
@@ -32,14 +32,6 @@ tools:
עבוד תמיד בעברית. עבוד תמיד בעברית.
## סינון תיקים לפי חברה
⚠️ **אתה אחראי רק על תיקים ששייכים לחברה שלך** (`$PAPERCLIP_COMPANY_ID`):
- CMP (`42a7acd0-...`) → רק תיקים **1xxx** (רישוי ובניה)
- CMPA (`8639e837-...`) → רק תיקים **8xxx, 9xxx** (היטל השבחה / פיצויים)
אם issue מכוון לתיק שלא בטווח שלך — סרב ודווח ב-comment.
## לפני שאתה מתחיל — קרא! ## לפני שאתה מתחיל — קרא!
1. **מתודולוגיה אנליטית: `docs/decision-methodology.md`** — איך לחשוב על החלטה 1. **מתודולוגיה אנליטית: `docs/decision-methodology.md`** — איך לחשוב על החלטה
@@ -78,26 +70,12 @@ tools:
## תהליך עבודה ## תהליך עבודה
### שלב 0: בדיקת הוראות וטיוטות
לפני שתתחיל לכתוב, בדוק אם יש הנחיות ספציפיות:
1. **קרא comments אחרונים על ה-issue** — חפש הוראות מה-CEO או מחיים:
```bash
curl -s -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
"$PAPERCLIP_API_URL/api/issues/{issue-id}/comments" | jq '[.[] | select(.authorUserId != null)] | .[-3:]'
```
2. **בדוק attachments** (ראה HEARTBEAT שלב 2c) — אם יש קובץ DOCX מצורף, קרא אותו
3. **אם יש טיוטת DOCX** — קרא אותה, השתמש בה כבסיס. **אל תכתוב מאפס אם יש טיוטה.**
4. **אם ה-CEO או חיים כתבו הנחיות ב-comment** (למשל "ערוך בהתאם ל...") — **עקוב אחריהן**
### שלב 1: הכנה ### שלב 1: הכנה
1. **קרא את המתודולוגיה**: `Read docs/decision-methodology.md` — חובה לפני כל כתיבה 1. קרא פרטי התיק (`case_get`)
2. קרא פרטי התיק (`case_get`) 2. קרא טענות מחולצות (`get_claims`)
3. קרא טענות מחולצות (`get_claims`) 3. **קרא את עמדות יו"ר הוועדה (`get_chair_directions`) — חובה!**
4. **קרא את עמדות יו"ר הוועדה (`get_chair_directions`) — חובה!** 4. קבל תבנית החלטה (`get_decision_template`)
5. קבל תבנית החלטה (`get_decision_template`) 5. קרא מדריך סגנון (`get_style_guide`)
6. קרא מדריך סגנון (`get_style_guide`)
### שלב 1ב: בדיקת עמדות יו"ר — חובה לפני כתיבה! ### שלב 1ב: בדיקת עמדות יו"ר — חובה לפני כתיבה!
@@ -164,16 +142,6 @@ case_update(case_number, status="drafted")
- ספירת מילים לכל בלוק - ספירת מילים לכל בלוק
- יחסי משקל (% מהמסמך) - יחסי משקל (% מהמסמך)
### העֵר את העוזר המשפטי (CEO) — חובה!
```bash
curl -s -X POST -H "Authorization: Bearer $PAPERCLIP_API_KEY" \
-H "Content-Type: application/json" \
"$PAPERCLIP_API_URL/api/agents/752cebdd-6748-4a04-aacd-c7ab0294ef33/wakeup" \
-d '{"reason": "כותב החלטה סיים משימה [issue-id] בסטטוס [done/blocked]"}'
```
אם ה-API לא עובד:
**⚠️ אסור להשתמש ב-INSERT INTO agent_wakeup_requests ישירות!** הכנסה ישירה ל-DB יוצרת רק את הבקשה בלי heartbeat_run — והסוכן לא יתעורר לעולם. **תמיד להשתמש ב-API בלבד.**
**אם לא תעדכן סטטוס ל-drafted — בודק האיכות לא יוכל לרוץ!** **אם לא תעדכן סטטוס ל-drafted — בודק האיכות לא יוכל לרוץ!**
## בלוק י — דיון (הבלוק החשוב ביותר) ## בלוק י — דיון (הבלוק החשוב ביותר)

View File

@@ -4,12 +4,3 @@ mcp-server/.venv/
**/__pycache__/ **/__pycache__/
*.pyc *.pyc
.git/ .git/
.taskmaster/
web/static/
web/__pycache__/
scripts/
skills/
docs/
legacy/
node_modules/
.next/

View File

@@ -1,58 +0,0 @@
name: Build & Deploy
on:
push:
branches: [main]
tags: ["v*"]
env:
REGISTRY: gitea.nautilus.marcusgroup.org
IMAGE: ezer-mishpati/legal-ai
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Login to Gitea Registry
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
docker login ${{ env.REGISTRY }} \
-u "${{ secrets.REGISTRY_USER }}" --password-stdin
- name: Build and tag image
run: |
BASE="${{ env.REGISTRY }}/${{ env.IMAGE }}"
TAGS="-t ${BASE}:latest -t ${BASE}:build-${{ github.run_number }}"
# If this is a version tag (v*), add the semver tag
REF="${{ github.ref }}"
if [[ "$REF" == refs/tags/v* ]]; then
VERSION="${REF#refs/tags/}"
TAGS="$TAGS -t ${BASE}:${VERSION}"
echo "📦 Release: ${VERSION}"
fi
echo "🏗️ Building with tags: build-${{ github.run_number }}, latest"
docker build $TAGS .
- name: Push image
run: |
BASE="${{ env.REGISTRY }}/${{ env.IMAGE }}"
docker push "${BASE}:latest"
docker push "${BASE}:build-${{ github.run_number }}"
REF="${{ github.ref }}"
if [[ "$REF" == refs/tags/v* ]]; then
VERSION="${REF#refs/tags/}"
docker push "${BASE}:${VERSION}"
echo "✅ Pushed ${VERSION}"
fi
- name: Trigger Coolify redeploy
run: |
curl -sf \
"http://coolify:8080/api/v1/deploy?uuid=gyjo0mtw2c42ej3xxvbz8zio&force=true" \
-H "Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}"

2
.gitignore vendored
View File

@@ -2,8 +2,6 @@ data/uploads/
data/cases/ data/cases/
data/training/ data/training/
data/exports/ data/exports/
data/backups/
data/.auto-sync.log
mcp-server/.venv/ mcp-server/.venv/
__pycache__/ __pycache__/
*.pyc *.pyc

View File

@@ -1,30 +0,0 @@
# UI Updates — Legal AI Next.js
## Context
The legal-ai system uses a Next.js 15 UI at web-ui/. The workflow pipeline was significantly updated with new statuses, methodology, and agent improvements. The UI needs to reflect these changes.
## Task 1: Remove old Flask UI from Coolify
The old Flask app runs at legal-ai.nautilus.marcusgroup.org via Docker/Coolify. It should be archived and removed to save resources. The Next.js UI (legal-ai-next.nautilus.marcusgroup.org) becomes the sole UI. After removal, DNS should point legal-ai.nautilus.marcusgroup.org to the Next.js app.
Files: Coolify dashboard, DNS config.
## Task 2: Update WorkflowTimeline component with new statuses
The WorkflowTimeline component in web-ui/src/app/cases/[caseNumber]/page.tsx (line 127) only knows old statuses. It needs to support the full pipeline:
- new → proofread → documents_ready → analyst_verified → research_complete → outcome_set → direction_approved → drafted → qa_passed → exported
- Plus: qa_failed, blocked
Each status needs: Hebrew label, color, icon, description tooltip.
Files: web-ui/src/app/cases/[caseNumber]/page.tsx, possibly a new WorkflowTimeline component file.
## Task 3: Status overview page or component
Create a page or modal that shows all possible statuses with explanations — what each status means, which agent sets it, what happens next. Could be a /statuses page or a help tooltip in the WorkflowTimeline.
## Task 4: Manual status editing in case page
Add a dropdown or modal in the case page that allows manually changing the case status. This is needed for cases where the automated pipeline gets stuck or needs to be reset. Should call case_update API endpoint.
Files: web-ui/src/app/cases/[caseNumber]/page.tsx, web-ui/src/lib/api/.
## Task 5: Merge action buttons into overview card
Currently there's a separate "פעולות" (actions) card with 2 buttons: "פתח בעורך החלטה" and "עריכת פרטי תיק". These should move into the main overview/summary card at the top of the case page. The separate actions card should be removed — it wastes space for just 2 buttons.
Files: web-ui/src/app/cases/[caseNumber]/page.tsx.

View File

@@ -1,3 +0,0 @@
{
"migrationNoticeShown": true
}

View File

@@ -703,276 +703,16 @@
"status": "deferred", "status": "deferred",
"subtasks": [], "subtasks": [],
"updatedAt": "2026-04-03T10:19:26.779Z" "updatedAt": "2026-04-03T10:19:26.779Z"
},
{
"id": "83",
"title": "Phase 1 — Project setup (legal-ai UI rewrite)",
"description": "הקמת scaffold של Next.js עם TypeScript + Tailwind v4 + App Router ב-web-ui/. התקנת כל התלויות: @tanstack/react-query, @tanstack/react-table, react-hook-form, @hookform/resolvers, zod, lucide-react, react-dropzone, openapi-typescript. העברת design-system.css tokens (navy/gold/parchment, Heebo) ל-Tailwind theme דרך @theme ו-CSS variables. הגדרת RTL עברית עם Heebo via next/font/google. בניית AppShell עם navy header + gold rule + nav.",
"status": "done",
"dependencies": [],
"priority": "high",
"details": "**השלמות (2026-04-11):**\n\n✅ **Scaffold:** Next.js 16.2.3 (חדש יותר מ-v15 שתוכנן), React 19.2.4, Tailwind v4, Turbopack.\n\n✅ **תלויות מותקנות** (`web-ui/package.json:11-21`):\n- @tanstack/react-query ^5.97.0\n- @tanstack/react-table ^8.21.3\n- react-hook-form ^7.72.1 + @hookform/resolvers ^5.2.2\n- zod ^4.3.6\n- lucide-react ^1.8.0\n- react-dropzone ^15.0.0\n- openapi-typescript ^7.13.0 (devDep)\n\n✅ **Design tokens** (`web-ui/src/app/globals.css:10-107`): Tailwind v4 @theme עם כל הצבעים (navy, cream, parchment, gold, ink, status colors), radii, shadows, fonts, dark mode preserved.\n\n✅ **RTL Hebrew** (`web-ui/src/app/layout.tsx:5-10, 23`): Heebo עם hebrew+latin subsets, `lang=\"he\" dir=\"rtl\"` on html.\n\n✅ **AppShell** (`web-ui/src/components/app-shell.tsx:29-70`): Navy header עם gold border-b-3, RTL nav, parchment body.\n\n✅ **Home page placeholder** (`web-ui/src/app/page.tsx`).\n\n✅ **Build:** `npm run build` עובר ב-3.8s, 0 errors, static.\n\n**נותר:** אישור ויזואלי של המשתמש עם `npm run dev`.\n\n**תוכנית מלאה:** `~/.claude/plans/joyful-marinating-sutton.md`",
"testStrategy": "1. `cd web-ui && npm run dev` — פתיחה ב-http://localhost:3000\n2. וידוא ויזואלי: Header navy עם gold rule, RTL rendering, פונט Heebo טעון\n3. השוואה ל-legal-ai.nautilus.marcusgroup.org — אותו מראה header\n4. בדיקת dark mode (toggle class על html)\n5. אישור סופי מהמשתמש",
"subtasks": [
{
"id": 1,
"title": "יצירת Next.js 16 scaffold עם TypeScript + Tailwind v4 + App Router",
"description": "הרצת create-next-app ב-web-ui/ עם App Router, TypeScript, Tailwind v4, ESLint",
"dependencies": [],
"details": "Next.js 16.2.3 (חדש יותר מ-v15), React 19.2.4, Tailwind v4, Turbopack. קבצים: web-ui/package.json, tsconfig.json, next.config.ts",
"status": "done",
"testStrategy": "npm run build succeeds",
"parentId": "undefined"
},
{
"id": 2,
"title": "התקנת כל התלויות הנדרשות",
"description": "npm install של @tanstack/react-query, @tanstack/react-table, react-hook-form, @hookform/resolvers, zod, lucide-react, react-dropzone, openapi-typescript",
"dependencies": [
1
],
"details": "ראה web-ui/package.json:11-21 לגרסאות המותקנות. כולל openapi-typescript כ-devDep לשלב 2.",
"status": "done",
"testStrategy": "npm ls shows all packages",
"parentId": "undefined"
},
{
"id": 3,
"title": "העברת design tokens ל-Tailwind v4 @theme",
"description": "פורט מלא של design-system.css ל-globals.css עם Tailwind v4 @theme syntax",
"dependencies": [
1
],
"details": "web-ui/src/app/globals.css:10-107 כולל כל הצבעים (navy, cream, parchment, gold, ink), status colors, radii, shadows, fonts, dark mode. CSS variables עובדים עם Tailwind classes.",
"status": "done",
"testStrategy": "Tailwind classes like bg-navy, text-gold work correctly",
"parentId": "undefined"
},
{
"id": 4,
"title": "הגדרת RTL Hebrew עם Heebo font",
"description": "next/font/google Heebo עם hebrew+latin, lang=he dir=rtl על html",
"dependencies": [
1
],
"details": "web-ui/src/app/layout.tsx:5-10 — Heebo עם weights 300-900, display swap. שורה 23: html lang=he dir=rtl.",
"status": "done",
"testStrategy": "Page renders RTL, Heebo font loaded",
"parentId": "undefined"
},
{
"id": 5,
"title": "בניית AppShell component עם navy header + gold rule",
"description": "רכיב shell עם header navy, gold border, RTL nav, parchment body",
"dependencies": [
3,
4
],
"details": "web-ui/src/components/app-shell.tsx:29-70 — Header עם bg-navy, border-b-3 border-gold, nav links (בית, העלאת מסמכים, אימון סגנון, מיומנויות, אבחון), main content area עם max-w-1400px.",
"status": "done",
"testStrategy": "Visual match to current header",
"parentId": "undefined"
},
{
"id": 6,
"title": "יצירת דף בית placeholder",
"description": "דף page.tsx עם AppShell ו-placeholder content",
"dependencies": [
5
],
"details": "web-ui/src/app/page.tsx:1-27 — דף בית עם כותרת 'עוזר משפטי', תיאור המערכת, gold gradient divider, כרטיס סטטוס.",
"status": "done",
"testStrategy": "npm run build succeeds (done: 3.8s, 0 errors)",
"parentId": "undefined"
},
{
"id": 7,
"title": "אישור ויזואלי מהמשתמש — npm run dev",
"description": "הרצת dev server ואישור סופי שה-UI תואם לציפיות — header, RTL, fonts, colors",
"dependencies": [
6
],
"details": "המשתמש צריך להריץ 'cd web-ui && npm run dev' ולאשר שהכל נראה כמו legal-ai.nautilus.marcusgroup.org. בדיקת dark mode אופציונלית.",
"status": "pending",
"testStrategy": "User confirms visual parity with current site, RTL works, Heebo font loads",
"parentId": "undefined"
}
],
"updatedAt": "2026-04-11T13:50:47.941Z"
},
{
"id": "84",
"title": "Phase 2 — API client + generated TypeScript types",
"description": "Add npm run api:types script that runs openapi-typescript against FastAPI's /openapi.json -> src/lib/api/types.ts. Build lib/api/client.ts (typed fetch wrapper + TanStack Query client with default retry/staleTime). Create one lib/api/<domain>.ts per endpoint category (cases, upload, compose, training, system), each exporting typed useQuery/useMutation hooks. Build lib/sse.ts as EventSource -> Query cache adapter. Plan: ~/.claude/plans/joyful-marinating-sutton.md.",
"details": "See full plan at ~/.claude/plans/joyful-marinating-sutton.md for architecture, critical files, risks, and open questions. This task is phase 2 of 7 in the legal-ai UI rewrite from vanilla HTML to Next.js 15 + shadcn/ui.",
"testStrategy": "useCases() hook returns typed array from live FastAPI. TypeScript errors if backend endpoint changes without frontend update.",
"status": "done",
"dependencies": [
"83"
],
"priority": "high",
"subtasks": [],
"updatedAt": "2026-04-11T15:51:34.020Z"
},
{
"id": "85",
"title": "Phase 3 — Core read views (home, case detail, compose)",
"description": "Port the 3 highest-value screens. Use the frontend-design Claude Code skill to generate layout + composition, passing design tokens (navy/gold/parchment, Heebo), editorial voice, and typed API hooks. Use shadcn Card/Badge/Tabs/Sheet/ScrollArea as primitives. Port the custom donut chart into <DonutChart> component. TanStack Query staleTime:5000 for case detail replaces manual 5s polling. Plan: ~/.claude/plans/joyful-marinating-sutton.md.",
"details": "See full plan at ~/.claude/plans/joyful-marinating-sutton.md for architecture, critical files, risks, and open questions. This task is phase 3 of 7 in the legal-ai UI rewrite from vanilla HTML to Next.js 15 + shadcn/ui.",
"testStrategy": "Users can browse case list, open a case detail, and view the compose screen with live data from FastAPI. All 3 screens visually match the existing legal-ai identity.",
"status": "done",
"dependencies": [
"84"
],
"priority": "high",
"subtasks": [],
"updatedAt": "2026-04-11T16:09:18.006Z"
},
{
"id": "86",
"title": "Phase 4 — Forms and wizards (new case, upload, inline edits)",
"description": "Port new case wizard, bulk upload, inline forms on case detail. Use react-hook-form + zod with schemas in lib/schemas/<entity>.ts. Build shared <WizardShell> from shadcn Card + Progress + Tabs. Build <DropZone> (react-dropzone + shadcn). Integrate SSE for upload progress via lib/sse.ts. Plan: ~/.claude/plans/joyful-marinating-sutton.md.",
"details": "See full plan at ~/.claude/plans/joyful-marinating-sutton.md for architecture, critical files, risks, and open questions. This task is phase 4 of 7 in the legal-ai UI rewrite from vanilla HTML to Next.js 15 + shadcn/ui.",
"testStrategy": "Users can create a new case via the multi-step wizard (case appears in Gitea + Paperclip), upload documents with live SSE progress, and edit case fields inline.",
"status": "done",
"dependencies": [
"85"
],
"priority": "medium",
"subtasks": [],
"updatedAt": "2026-04-11T16:25:55.569Z"
},
{
"id": "87",
"title": "Phase 5 — Secondary screens (compare, training, style report, skills, diagnostics)",
"description": "Port the remaining 5 views. Use TanStack Table for training corpus and diagnostics lists. Port any charts/visualizations from current index.html. Plan: ~/.claude/plans/joyful-marinating-sutton.md.",
"details": "See full plan at ~/.claude/plans/joyful-marinating-sutton.md for architecture, critical files, risks, and open questions. This task is phase 5 of 7 in the legal-ai UI rewrite from vanilla HTML to Next.js 15 + shadcn/ui.",
"testStrategy": "Feature parity with old legal-ai/web/static/index.html across all 10 views.",
"status": "done",
"dependencies": [
"86"
],
"priority": "medium",
"subtasks": [],
"updatedAt": "2026-04-11T17:33:42.976Z"
},
{
"id": "88",
"title": "Phase 6 — Polish & testing",
"description": "Accessibility pass (keyboard nav, aria-label on RTL icons, focus trap in modals). Error boundaries + toast notifications for failed mutations. Loading states for every query. Cross-browser smoke test (Chrome, Firefox, Safari) + mobile device test. Document E2E smoke test script in web-ui/README.md. Plan: ~/.claude/plans/joyful-marinating-sutton.md.",
"details": "See full plan at ~/.claude/plans/joyful-marinating-sutton.md for architecture, critical files, risks, and open questions. This task is phase 6 of 7 in the legal-ai UI rewrite from vanilla HTML to Next.js 15 + shadcn/ui.",
"testStrategy": "Lighthouse a11y score > 90, all loading states visible, errors show toasts, README has documented smoke test steps.",
"status": "done",
"dependencies": [
"87"
],
"priority": "medium",
"subtasks": [],
"updatedAt": "2026-04-11T17:44:08.337Z"
},
{
"id": "89",
"title": "Phase 7 — Deployment & cutover",
"description": "Add multi-stage Dockerfile for web-ui/ (Node 20 build -> nginx serve of out/). Add web-ui as new app in Coolify project pointing to staging subdomain legal-ai-next.nautilus.marcusgroup.org. Run full smoke test against staging. Cutover: DNS flip legal-ai.nautilus.marcusgroup.org to new app, keep old on rollback subdomain for 1 week. Follow-up PR removes legal-ai/web/static/index.html + design-system.css once stable. Plan: ~/.claude/plans/joyful-marinating-sutton.md.",
"details": "See full plan at ~/.claude/plans/joyful-marinating-sutton.md for architecture, critical files, risks, and open questions. This task is phase 7 of 7 in the legal-ai UI rewrite from vanilla HTML to Next.js 15 + shadcn/ui.",
"testStrategy": "legal-ai.nautilus.marcusgroup.org serves the new Next.js UI in production. Old UI accessible on rollback subdomain for 7 days. SSE streams working through Coolify proxy.",
"status": "pending",
"dependencies": [
"88"
],
"priority": "medium",
"subtasks": []
},
{
"id": "90",
"title": "Phase 4.5 — Practice area integration",
"description": "Add practice_area + appeal_subtype to the wizard, types, schema, case header, and cases table. Gap identified after backend commit 26d09d6 (multi-tenant axis) — new Next.js UI has zero integration while vanilla UI is fully wired. Plan: ~/.claude/plans/woolly-cooking-graham.md",
"details": "",
"testStrategy": "",
"status": "done",
"dependencies": [
"86"
],
"priority": "high",
"subtasks": [],
"updatedAt": "2026-04-11T17:15:57.831Z"
},
{
"id": "91",
"title": "Precedent attachment in compose screen",
"description": "Add case_precedents table + FastAPI endpoints + MCP tools + Next.js compose UI for attaching legal precedents (quote + citation + optional archived PDF) to threshold_claims/issues and to the case as a whole. Plan: ~/.claude/plans/woolly-cooking-graham.md",
"details": "",
"testStrategy": "",
"status": "done",
"dependencies": [],
"priority": "high",
"subtasks": [],
"updatedAt": "2026-04-11T19:20:56.040Z"
},
{
"id": 92,
"title": "הסרת אפליקציית Flask הישנה מ-Coolify",
"description": "ארכיון והסרה של אפליקציית Flask הישנה מ-Coolify, וכיוון DNS כך ש-legal-ai.nautilus.marcusgroup.org יצביע על אפליקציית Next.js",
"details": "## פסאודו-קוד:\n```\n1. גיבוי הגדרות Flask מ-Coolify לפני מחיקה\n2. ב-Coolify dashboard:\n - מצא את הקונטיינר legal-ai-flask (או שם דומה)\n - עצור את הקונטיינר\n - צור snapshot או ארכיון של ההגדרות\n - מחק את הקונטיינר והסרוויס\n3. ב-DNS (Cloudflare/Coolify proxy):\n - שנה את legal-ai.nautilus.marcusgroup.org\n - הפנה ל-IP/service של legal-ai-next (Next.js app)\n4. ב-Next.js app (Coolify):\n - הוסף domain alias: legal-ai.nautilus.marcusgroup.org\n - עדכן SSL certificate\n```\n\n## קבצים מושפעים:\n- Coolify dashboard settings\n- DNS records (Cloudflare או ספק אחר)\n- Coolify proxy/Traefik configuration\n\n## הערות:\n- **אין שינויים בקוד** - רק הגדרות תשתית\n- ודא שה-Next.js app עובד עם שני הדומיינים במקביל לפני הסרת Flask\n- שמור לוגים מ-Flask לפני מחיקה למקרה של rollback",
"testStrategy": "## בדיקות:\n1. **לפני הסרה**: ודא ש-legal-ai-next.nautilus.marcusgroup.org עובד תקין\n2. **אחרי שינוי DNS**: \n - `curl -I https://legal-ai.nautilus.marcusgroup.org` - צריך להחזיר 200\n - בדוק SSL certificate תקין\n3. **בדיקת UI**: \n - פתח את legal-ai.nautilus.marcusgroup.org בדפדפן\n - ודא שזה אותו UI כמו legal-ai-next\n4. **בדיקת API**: \n - `curl https://legal-ai.nautilus.marcusgroup.org/api/cases`\n - ודא שמחזיר נתונים",
"priority": "high",
"dependencies": [],
"status": "pending",
"subtasks": []
},
{
"id": 93,
"title": "עדכון סטטוסים ב-WorkflowTimeline וב-status-badge",
"description": "עדכון רשימת הסטטוסים בממשק לפי ה-pipeline החדש: new → proofread → documents_ready → analyst_verified → research_complete → outcome_set → direction_approved → drafted → qa_passed → exported, כולל qa_failed ו-blocked",
"details": "## קבצים לעדכון:\n1. `web-ui/src/lib/api/cases.ts` - עדכון type CaseStatus\n2. `web-ui/src/components/cases/status-badge.tsx` - תוויות ועיצוב\n3. `web-ui/src/components/cases/workflow-timeline.tsx` - שלבי pipeline\n\n## פסאודו-קוד:\n\n### 1. cases.ts - עדכון הטיפוס:\n```typescript\nexport type CaseStatus =\n | \"new\"\n | \"proofread\"\n | \"documents_ready\"\n | \"analyst_verified\"\n | \"research_complete\"\n | \"outcome_set\"\n | \"direction_approved\"\n | \"drafted\"\n | \"qa_passed\"\n | \"exported\"\n | \"qa_failed\"\n | \"blocked\";\n```\n\n### 2. status-badge.tsx - תוויות עבריות וצבעים:\n```typescript\nconst STATUS_LABELS: Record<CaseStatus, string> = {\n new: \"חדש\",\n proofread: \"הוגה\",\n documents_ready: \"מסמכים מוכנים\",\n analyst_verified: \"אומת ע״י אנליסט\",\n research_complete: \"מחקר הושלם\",\n outcome_set: \"תוצאה נקבעה\",\n direction_approved: \"כיוון אושר\",\n drafted: \"טיוטה\",\n qa_passed: \"עבר QA\",\n exported: \"יוצא\",\n qa_failed: \"נכשל QA\",\n blocked: \"חסום\",\n};\n\nconst STATUS_TONE: Record<CaseStatus, string> = {\n new: \"bg-rule-soft text-ink-muted border-rule\",\n proofread: \"bg-info-bg text-info border-info/30\",\n documents_ready: \"bg-info-bg text-info border-info/40\",\n analyst_verified: \"bg-info-bg text-info border-info/50\",\n research_complete: \"bg-gold-wash text-gold-deep border-gold/40\",\n outcome_set: \"bg-gold-wash text-gold-deep border-gold/50\",\n direction_approved: \"bg-gold-wash text-gold-deep border-gold/60\",\n drafted: \"bg-warn-bg text-warn border-warn/40\",\n qa_passed: \"bg-success-bg text-success border-success/40\",\n exported: \"bg-success-bg text-success border-success/60\",\n qa_failed: \"bg-danger-bg text-danger border-danger/40\",\n blocked: \"bg-danger-bg text-danger border-danger/50\",\n};\n```\n\n### 3. workflow-timeline.tsx - קבוצות שלבים חדשות:\n```typescript\nconst PHASES: Phase[] = [\n { key: \"intake\", label: \"קליטה ועיבוד\", statuses: [\"new\", \"proofread\", \"documents_ready\"] },\n { key: \"analysis\", label: \"ניתוח\", statuses: [\"analyst_verified\", \"research_complete\"] },\n { key: \"direction\", label: \"קביעת כיוון\", statuses: [\"outcome_set\", \"direction_approved\"] },\n { key: \"writing\", label: \"כתיבה וביקורת\", statuses: [\"drafted\", \"qa_passed\"] },\n { key: \"done\", label: \"סגירה\", statuses: [\"exported\"] },\n];\n\n// טיפול בסטטוסי שגיאה (qa_failed, blocked) - הצגה מיוחדת\nif (status === \"qa_failed\" || status === \"blocked\") {\n // הצג באדום עם אייקון אזהרה\n}\n```",
"testStrategy": "## בדיקות:\n1. **Unit Tests** (אם קיימים):\n - ודא שכל הסטטוסים מופו נכון\n - בדוק שאין סטטוס חסר ב-STATUS_LABELS ו-STATUS_TONE\n\n2. **Visual Testing**:\n - צור/ערוך תיק ידנית ב-DB לכל סטטוס\n - ודא שהתווית מוצגת בעברית נכונה\n - ודא שהצבע מתאים (כחול לעיבוד, זהב לניתוח, ירוק להצלחה, אדום לשגיאה)\n\n3. **WorkflowTimeline**:\n - ודא שהשלב הנוכחי מודגש בצהוב\n - ודא ששלבים שהושלמו מסומנים בירוק\n - ודא שסטטוסי שגיאה (qa_failed, blocked) מוצגים עם אינדיקציה ויזואלית מיוחדת",
"priority": "high",
"dependencies": [],
"status": "pending",
"subtasks": []
},
{
"id": 94,
"title": "דף/קומפוננטה להצגת כל הסטטוסים עם הסברים",
"description": "יצירת דף /statuses או מודל עזרה שמסביר את כל הסטטוסים האפשריים - מה כל סטטוס אומר, איזה agent קובע אותו, ומה קורה אחר כך",
"details": "## אפשרויות מימוש:\n\n### אפשרות A: Popover tooltip בתוך WorkflowTimeline (מומלץ)\n```typescript\n// web-ui/src/components/cases/workflow-timeline.tsx\n// הוסף אייקון (?) ליד הכותרת שפותח popover\n\nconst STATUS_INFO: Record<CaseStatus, StatusInfo> = {\n new: {\n description: \"תיק נוצר, ממתין להעלאת מסמכים\",\n agent: \"משתמש\",\n nextStep: \"העלאת מסמכים → proofread\"\n },\n proofread: {\n description: \"מסמכים הועלו, עוברים הגהה אוטומטית\",\n agent: \"Proofread Agent\",\n nextStep: \"הגהה הושלמה → documents_ready\"\n },\n documents_ready: {\n description: \"מסמכים מוכנים לניתוח\",\n agent: \"Document Processor\",\n nextStep: \"בדיקת אנליסט → analyst_verified\"\n },\n analyst_verified: {\n description: \"אנליסט אימת את חילוץ הטענות\",\n agent: \"Analyst Agent\",\n nextStep: \"מחקר → research_complete\"\n },\n research_complete: {\n description: \"מחקר משפטי הושלם, פסיקה זוהתה\",\n agent: \"Research Agent\",\n nextStep: \"קביעת תוצאה → outcome_set\"\n },\n outcome_set: {\n description: \"דפנה קבעה את התוצאה (דחייה/קבלה)\",\n agent: \"משתמש (דפנה)\",\n nextStep: \"אישור כיוון → direction_approved\"\n },\n direction_approved: {\n description: \"כיוון ההחלטה אושר, מוכן לכתיבה\",\n agent: \"משתמש\",\n nextStep: \"כתיבה → drafted\"\n },\n drafted: {\n description: \"טיוטת החלטה נכתבה\",\n agent: \"Writing Agent\",\n nextStep: \"בדיקת QA → qa_passed\"\n },\n qa_passed: {\n description: \"טיוטה עברה בדיקת איכות\",\n agent: \"QA Agent\",\n nextStep: \"ייצוא → exported\"\n },\n exported: {\n description: \"ההחלטה יוצאה כ-DOCX\",\n agent: \"Export Service\",\n nextStep: \"הושלם\"\n },\n qa_failed: {\n description: \"טיוטה נכשלה בבדיקת QA\",\n agent: \"QA Agent\",\n nextStep: \"חזרה לכתיבה → drafted\"\n },\n blocked: {\n description: \"תיק חסום - דורש התערבות ידנית\",\n agent: \"מערכת\",\n nextStep: \"טיפול ידני\"\n },\n};\n```\n\n### אפשרות B: דף /statuses נפרד\n```typescript\n// web-ui/src/app/statuses/page.tsx\n// דף עצמאי עם טבלה של כל הסטטוסים\n```\n\n## המלצה: אפשרות A - פשוטה יותר ומשתלבת ב-UX הקיים",
"testStrategy": "## בדיקות:\n1. **UI Testing**:\n - לחיצה על אייקון העזרה פותחת popover/tooltip\n - כל סטטוס מציג: תיאור, agent, שלב הבא\n - סגירת ה-popover עובדת (לחיצה מחוץ/Escape)\n\n2. **Accessibility**:\n - ה-popover נגיש למקלדת (Tab, Enter, Escape)\n - aria-label מתאים\n - RTL מוצג נכון\n\n3. **Content Review**:\n - כל ההסברים בעברית תקנית\n - הזרימה בין סטטוסים מובנת",
"priority": "medium",
"dependencies": [
93
],
"status": "pending",
"subtasks": []
},
{
"id": 95,
"title": "עריכה ידנית של סטטוס בדף התיק",
"description": "הוספת dropdown או מודל בדף התיק לשינוי סטטוס ידני, לטיפול במקרים שבהם ה-pipeline נתקע או צריך reset",
"details": "## מיקום: בתוך הכרטיס של WorkflowTimeline (בצד ימין של דף התיק)\n\n## פסאודו-קוד:\n\n### 1. קומפוננטת StatusEditor:\n```typescript\n// web-ui/src/components/cases/status-editor.tsx\n\nimport { Select } from \"@/components/ui/select\";\nimport { Button } from \"@/components/ui/button\";\nimport { useUpdateCase } from \"@/lib/api/cases\";\nimport { toast } from \"sonner\";\n\nexport function StatusEditor({ caseNumber, currentStatus }: Props) {\n const [selectedStatus, setSelectedStatus] = useState(currentStatus);\n const updateCase = useUpdateCase(caseNumber);\n\n const handleSave = async () => {\n if (selectedStatus === currentStatus) return;\n \n try {\n await updateCase.mutateAsync({ status: selectedStatus });\n toast.success(\"סטטוס עודכן בהצלחה\");\n } catch (error) {\n toast.error(\"שגיאה בעדכון הסטטוס\");\n }\n };\n\n return (\n <div className=\"flex items-center gap-2 mt-4\">\n <Select value={selectedStatus} onValueChange={setSelectedStatus}>\n {ALL_STATUSES.map(status => (\n <SelectItem key={status} value={status}>\n {STATUS_LABELS[status]}\n </SelectItem>\n ))}\n </Select>\n <Button \n onClick={handleSave} \n disabled={selectedStatus === currentStatus || updateCase.isPending}\n size=\"sm\"\n >\n עדכן\n </Button>\n </div>\n );\n}\n```\n\n### 2. שילוב בדף התיק:\n```typescript\n// web-ui/src/app/cases/[caseNumber]/page.tsx\n// בתוך הכרטיס של WorkflowTimeline\n\n<Card className=\"bg-surface border-rule shadow-sm h-fit\">\n <CardContent className=\"px-6 py-5\">\n <h2 className=\"text-navy text-base mb-4\">שלב בתהליך</h2>\n <WorkflowTimeline status={data?.status} />\n {data && <StatusEditor caseNumber={caseNumber} currentStatus={data.status} />}\n </CardContent>\n</Card>\n```\n\n### 3. עדכון ה-API (אם נדרש):\nה-`useUpdateCase` כבר תומך ב-status field לפי `caseUpdateSchema`.",
"testStrategy": "## בדיקות:\n1. **Functionality**:\n - בחירת סטטוס חדש מה-dropdown\n - לחיצה על \"עדכן\" שולחת PUT request ל-API\n - הסטטוס מתעדכן ב-UI אחרי הצלחה\n - toast הודעה מוצגת\n\n2. **Edge Cases**:\n - לחיצה על \"עדכן\" כשהסטטוס לא השתנה - כפתור disabled\n - טיפול בשגיאת API - הודעת שגיאה\n - כפתור disabled בזמן loading\n\n3. **Integration**:\n - ה-WorkflowTimeline מתעדכן מיד אחרי שינוי סטטוס\n - ה-StatusBadge בכותרת מתעדכן\n - הנתונים מסונכרנים עם ה-DB",
"priority": "medium",
"dependencies": [
93
],
"status": "pending",
"subtasks": []
},
{
"id": 96,
"title": "מיזוג כפתורי פעולות לכרטיס הסקירה הראשי",
"description": "העברת הכפתורים 'פתח בעורך ההחלטה' ו'עריכת פרטי תיק' מהלשונית 'פעולות' לכרטיס הכותרת העליון, והסרת הלשונית המיותרת",
"details": "## קבצים לעדכון:\n- `web-ui/src/app/cases/[caseNumber]/page.tsx`\n- `web-ui/src/components/cases/case-header.tsx`\n\n## פסאודו-קוד:\n\n### 1. עדכון CaseHeader להוספת כפתורי פעולה:\n```typescript\n// web-ui/src/components/cases/case-header.tsx\n\nimport Link from \"next/link\";\nimport { Button } from \"@/components/ui/button\";\nimport { CaseEditDialog } from \"@/components/cases/case-edit-dialog\";\n\nexport function CaseHeader({ data }: { data?: CaseDetail }) {\n return (\n <Card className=\"bg-surface border-rule shadow-sm\">\n <CardContent className=\"px-6 py-5\">\n {/* ... breadcrumb קיים ... */}\n \n <div className=\"flex items-start justify-between gap-6 flex-wrap\">\n <div className=\"space-y-2\">\n {/* ... כותרת וסטטוס קיימים ... */}\n </div>\n\n {/* כפתורי פעולה - חדש */}\n <div className=\"flex items-center gap-3 flex-wrap\">\n <Button asChild className=\"bg-navy hover:bg-navy-soft text-parchment\">\n <Link href={`/cases/${data?.case_number}/compose`}>\n פתח בעורך ההחלטה\n </Link>\n </Button>\n {data && <CaseEditDialog data={data} />}\n </div>\n </div>\n\n {/* ... תאריכים קיימים ... */}\n </CardContent>\n </Card>\n );\n}\n```\n\n### 2. הסרת לשונית \"פעולות\" מדף התיק:\n```typescript\n// web-ui/src/app/cases/[caseNumber]/page.tsx\n\n// הסר את TabsTrigger value=\"actions\"\n<TabsList className=\"bg-rule-soft/60\">\n <TabsTrigger value=\"overview\">סקירה</TabsTrigger>\n <TabsTrigger value=\"documents\">מסמכים (...)</TabsTrigger>\n {/* הוסר: <TabsTrigger value=\"actions\">פעולות</TabsTrigger> */}\n</TabsList>\n\n// הסר את TabsContent value=\"actions\"\n// הקוד הבא נמחק:\n// <TabsContent value=\"actions\" className=\"mt-5\">\n// <div className=\"flex items-center gap-3 flex-wrap\">\n// <Button asChild>...</Button>\n// {data && <CaseEditDialog data={data} />}\n// </div>\n// </TabsContent>\n```\n\n### 3. עדכון CaseHeader props:\n```typescript\n// צריך להעביר caseNumber ל-CaseHeader אם עדיין לא קיים\n<CaseHeader data={data} caseNumber={caseNumber} />\n```",
"testStrategy": "## בדיקות:\n1. **Visual**:\n - כפתורי הפעולה מופיעים בכרטיס העליון\n - הכפתורים מיושרים ימינה (RTL)\n - responsive - נגלשים נכון במסכים קטנים\n\n2. **Functionality**:\n - \"פתח בעורך ההחלטה\" מנווט ל-/cases/{caseNumber}/compose\n - \"עריכת פרטי תיק\" פותח את ה-CaseEditDialog\n - ה-dialog עובד כרגיל\n\n3. **Removal**:\n - לשונית \"פעולות\" לא מופיעה יותר ב-Tabs\n - אין שגיאות קונסול\n - ניווט ל-#actions לא עובד (ולא אמור)\n\n4. **Regression**:\n - לשוניות \"סקירה\" ו\"מסמכים\" עובדות כרגיל\n - שאר הדף לא נפגע",
"priority": "low",
"dependencies": [],
"status": "pending",
"subtasks": []
} }
], ],
"metadata": { "metadata": {
"created": "2026-04-13T14:20:54.888Z", "version": "1.0.0",
"updated": "2026-04-13T14:20:54.888Z", "lastModified": "2026-04-04T07:50:59.999Z",
"description": "Tasks for master context" "taskCount": 51,
"completedCount": 49,
"tags": [
"master"
]
} }
} }
} }

View File

@@ -30,7 +30,7 @@
- לקחים מהשוואת טיוטות לגרסאות סופיות - לקחים מהשוואת טיוטות לגרסאות סופיות
- סקריפט ייצוא DOCX - סקריפט ייצוא DOCX
הידע שהופק מה-vault הוטמע במערכת הנוכחית — מסמכי ייחוס (`docs/`), קורפוס אימון (`data/training/`), ומבנה 12 בלוקים. ה-vault המקורי נמחק; הפרויקט הנוכחי עובד עם PostgreSQL + pgvector. כל החומר הועבר לתיקיית `legacy/` כקריאה בלבד. **הפרויקט הנוכחי** מעביר את הידע הזה למערכת מובנית עם PostgreSQL + pgvector + n8n.
--- ---
@@ -42,9 +42,6 @@
| [`docs/block-schema.md`](docs/block-schema.md) | הגדרת 12 בלוקים — content model, constraints, processing params | **לפני כל כתיבת החלטה** | | [`docs/block-schema.md`](docs/block-schema.md) | הגדרת 12 בלוקים — content model, constraints, processing params | **לפני כל כתיבת החלטה** |
| [`docs/migration-plan.md`](docs/migration-plan.md) | תוכנית מעבר vault → DB — טבלאות, עדיפויות, כמויות | לפני ייבוא נתונים | | [`docs/migration-plan.md`](docs/migration-plan.md) | תוכנית מעבר vault → DB — טבלאות, עדיפויות, כמויות | לפני ייבוא נתונים |
| [`docs/legal-decision-lessons.md`](docs/legal-decision-lessons.md) | לקחים מ-3 החלטות — מה עבד, מה השתנה, ביטויי מעבר חדשים | **לפני כל כתיבת החלטה** | | [`docs/legal-decision-lessons.md`](docs/legal-decision-lessons.md) | לקחים מ-3 החלטות — מה עבד, מה השתנה, ביטויי מעבר חדשים | **לפני כל כתיבת החלטה** |
| [`docs/decision-methodology.md`](docs/decision-methodology.md) | **מתודולוגיה אנליטית — איך לחשוב על החלטה מעין-שיפוטית** | **לפני כל כתיבת החלטה** |
| `docs/garner-methodology-extraction.md` | חומר מקור: מיצוי מספרי Garner על כתיבה משפטית | רק לבדיקת מקור |
| `docs/fjc-principles-extraction.md` | חומר מקור: מיצוי מ-Judicial Writing Manual (FJC) | רק לבדיקת מקור |
| [`docs/corpus-analysis.md`](docs/corpus-analysis.md) | ניתוח שיטתי של 24 החלטות — מפת תוכן, דפוסי דיון תכנוני, פערים | **לפני כל כתיבת החלטה** | | [`docs/corpus-analysis.md`](docs/corpus-analysis.md) | ניתוח שיטתי של 24 החלטות — מפת תוכן, דפוסי דיון תכנוני, פערים | **לפני כל כתיבת החלטה** |
| [`docs/memory.md`](docs/memory.md) | הקשר כללי — skills, פרויקטים שהושלמו, מבנה vault | להתמצאות כללית | | [`docs/memory.md`](docs/memory.md) | הקשר כללי — skills, פרויקטים שהושלמו, מבנה vault | להתמצאות כללית |
| [`skills/decision/SKILL.md`](skills/decision/SKILL.md) | מדריך סגנון מלא של דפנה — טון, מבנה, ביטויים, מתודולוגיה | **לפני כל כתיבת החלטה** | | [`skills/decision/SKILL.md`](skills/decision/SKILL.md) | מדריך סגנון מלא של דפנה — טון, מבנה, ביטויים, מתודולוגיה | **לפני כל כתיבת החלטה** |
@@ -60,27 +57,9 @@
| Redis | תור משימות | `legal-ai-redis` | | Redis | תור משימות | `legal-ai-redis` |
| n8n | אוטומציית workflows | להגדרה | | n8n | אוטומציית workflows | להגדרה |
| Gitea | מאגר קוד | `gitea.nautilus.marcusgroup.org/ezer-mishpati` | | Gitea | מאגר קוד | `gitea.nautilus.marcusgroup.org/ezer-mishpati` |
| ezer-mishpati-web | ממשק העלאת מסמכים (Docker/Coolify) | `legal-ai.nautilus.marcusgroup.org` | | ezer-mishpati-web | ממשק העלאת מסמכים | `legal-ai.nautilus.marcusgroup.org` |
| Paperclip | סוכן AI — מריץ Claude Code agents (pm2, מקומי) | `localhost:3100` |
| Infisical | ניהול סודות | `secret.dev.marcus-law.co.il` | | Infisical | ניהול סודות | `secret.dev.marcus-law.co.il` |
### ⚠️ ארכיטקטורת Deploy — חובה לקרוא
**עוזר משפטי (Legal-AI)** — רץ כ-**Docker container דרך Coolify**:
- UUID: `gyjo0mtw2c42ej3xxvbz8zio`
- שינוי קוד ב-`web/` או `web-ui/` **לא נכנס לתוקף** עד ש:
1. עושים `git commit` + `git push origin main`
2. מריצים deploy דרך Coolify (`mcp__coolify__deploy`)
3. ממתינים ~2-4 דקות לבנייה
- **אסור** לנסות להריץ uvicorn מקומית — אין סביבת Python על המכונה
- ה-container מריץ Next.js (`:3000`, חשוף) + FastAPI (`:8000`, פנימי)
- בדיקה: `curl https://legal-ai.nautilus.marcusgroup.org/api/...`
**Paperclip** — רץ **מקומית דרך pm2**:
- פורט: `localhost:3100`, DB: `localhost:54329`
- שינויי קוד נכנסים לתוקף אחרי `pm2 restart paperclip`
- **אין צורך ב-Docker או Coolify**
--- ---
## מבנה תיקיות ## מבנה תיקיות
@@ -101,28 +80,15 @@
│ └── docx/ עיצוב DOCX │ └── docx/ עיצוב DOCX
├── data/ ├── data/
│ ├── training/ ← 4 החלטות לאימון (DOCX) │ ├── training/ ← 4 החלטות לאימון (DOCX)
│ ├── exports/ ← טיוטות DOCX מיוצאות │ ├── exports/ ← ייצוא legacy (תיקים ישנים)
│ └── cases/{case-number}/ ← תיקי עררים (מבנה שטוח, סטטוס ב-DB) │ └── cases/{case-number}/ ← תיקי עררים (מבנה שטוח, סטטוס ב-DB)
├── web/ ← FastAPI backend (Python): 75 API endpoints ├── web/ ← UI + API + integration clients
│ ├── app.py ← API ראשי
│ ├── paperclip_client.py ← אינטגרציית Paperclip
│ └── gitea_client.py ← אינטגרציית Gitea
├── web-ui/ ← Next.js frontend (TypeScript/React): ממשק המשתמש
│ └── next.config.ts ← proxy: /api/* → FastAPI :8000
├── mcp-server/ ← MCP server + services + tools ├── mcp-server/ ← MCP server + services + tools
└── scripts/ ← סקריפטים וכלי עזר (ראה scripts/SCRIPTS.md) └── scripts/ ← סקריפטים וכלי עזר
└── .archive/ ← סקריפטים שהושלמו (לא להריץ)
``` ```
--- ---
## כלל: עדכון `scripts/SCRIPTS.md`
בכל פעם שנוצר, נמחק, או משתנה סקריפט בתיקיית `scripts/`**חובה לעדכן את `scripts/SCRIPTS.md`** בהתאם.
הקובץ מתעד את התפקיד, הסטטוס, וההחלפה (אם יש) של כל סקריפט.
---
## ניהול משימות — TaskMaster AI ## ניהול משימות — TaskMaster AI
הפרויקט משתמש ב-**TaskMaster AI** (MCP server) לניהול משימות מובנה: הפרויקט משתמש ב-**TaskMaster AI** (MCP server) לניהול משימות מובנה:
@@ -135,26 +101,6 @@
--- ---
## Paperclip — כללי אינטגרציה קריטיים
### Wakeup API — תמיד דרך API, לעולם לא דרך DB
- **הנתיב הנכון**: `POST /api/agents/{agent-id}/wakeup` (לא `/wake`!)
- **⚠️ אסור**: `INSERT INTO agent_wakeup_requests` ישירות — זה יוצר רק רשומה בלי `heartbeat_run`, והסוכן **לא יתעורר לעולם**
- **⚠️ חובה לשלוח `payload` עם `issueId`** — בלי זה הסוכן מתעורר בלי הקשר (בלי תיק, בלי issue, בלי cwd נכון)
- דוגמה נכונה:
```json
{"source": "automation", "triggerDetail": "system", "reason": "...",
"payload": {"issueId": "...", "mutation": "comment", "commentId": "..."}}
```
- **Board API Key**: שמור ב-DB (`board_api_keys`), auth: `Authorization: Bearer pbk_...`
### ניתוב comments דרך CEO
- כשמשתמש כותב תגובה על issue ב-Paperclip, הפלאגין (`plugin-legal-ai`) מעיר את ה-CEO דרך `ctx.agents.invoke()`
- ה-CEO קורא את ה-comment, מחליט על ניתוב, ויוצר issue לסוכן המתאים
- כל הסוכנים חייבים לקרוא comments אחרונים לפני שהם מתחילים לעבוד (HEARTBEAT שלבים 2b-2c)
---
## עקרונות כתיבה קריטיים ## עקרונות כתיבה קריטיים
1. **"מבחן השופט"** — כל החלטה חייבת להיות קריאה לשופט שלא מכיר את התיק 1. **"מבחן השופט"** — כל החלטה חייבת להיות קריאה לשופט שלא מכיר את התיק
@@ -162,16 +108,6 @@
3. **"ללא כפילות"** — בלוק י (דיון) מפנה לבלוקים קודמים, לא חוזר עליהם 3. **"ללא כפילות"** — בלוק י (דיון) מפנה לבלוקים קודמים, לא חוזר עליהם
4. **"טענות מקוריות בלבד"** — בלוק ז = מכתבי טענות מקוריים בלבד. השלמות → בלוק ח 4. **"טענות מקוריות בלבד"** — בלוק ז = מכתבי טענות מקוריים בלבד. השלמות → בלוק ח
5. **ארכיטקטורת 12 בלוקים** — ראה `docs/block-schema.md` 5. **ארכיטקטורת 12 בלוקים** — ראה `docs/block-schema.md`
6. **צ'קליסט תוכן** — בלוק י מקבל צ'קליסט תוכן אוטומטי לפי סוג הערר (ראה `lessons.py: CONTENT_CHECKLISTS`)
## הערות יו"ר (Chair Feedback)
מנגנון לתיעוד הערות דפנה על טיוטות:
- **DB**: טבלת `chair_feedback` (case_id, block_id, feedback_text, category, lesson_extracted)
- **API**: `GET/POST /api/feedback`, `PATCH /api/feedback/{id}/resolve`
- **MCP tools**: `record_chair_feedback`, `list_chair_feedback`
- **UI**: דף ניהול ב-`/feedback` (ב-Next.js)
- **קטגוריות**: missing_content, wrong_tone, wrong_structure, factual_error, style, other
## יו"ר: עו"ד דפנה תמיר ## יו"ר: עו"ד דפנה תמיר
- מדריך סגנון מלא: `skills/decision/SKILL.md` - מדריך סגנון מלא: `skills/decision/SKILL.md`

View File

@@ -1,69 +1,27 @@
# ══════════════════════════════════════════════════════════════ FROM python:3.12-slim
# Dockerfile — Next.js frontend + FastAPI backend (single container)
#
# The container runs both:
# - FastAPI (uvicorn) on :8000 — the API backend
# - Next.js (node) on :3000 — the frontend (proxies /api/* to :8000)
#
# start.sh launches both processes.
# ══════════════════════════════════════════════════════════════
# ── Stage 1: Node deps ────────────────────────────────────────
FROM node:20-alpine AS deps
WORKDIR /app
COPY web-ui/package.json web-ui/package-lock.json ./
RUN npm ci --no-audit --no-fund
# ── Stage 2: Build Next.js ────────────────────────────────────
FROM node:20-alpine AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY web-ui/ ./
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build
# ── Stage 3: Install Python deps (use slim for pre-built wheels) ──
FROM python:3.12-slim AS pydeps
WORKDIR /opt/api
COPY mcp-server/ ./mcp-server/
RUN pip install --no-cache-dir ./mcp-server
# ── Stage 4: Runner ───────────────────────────────────────────
FROM python:3.12-slim AS runner
WORKDIR /app WORKDIR /app
# Install Node.js 20.x # System deps for PyMuPDF and document processing
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates git \ gcc libmupdf-dev libfreetype6-dev libharfbuzz-dev libjpeg62-turbo-dev \
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ libopenjp2-7-dev curl git && rm -rf /var/lib/apt/lists/* && \
&& apt-get install -y --no-install-recommends nodejs \ git config --global init.defaultBranch main
&& rm -rf /var/lib/apt/lists/*
ENV NODE_ENV=production # Copy Ezer Mishpati MCP server source
ENV NEXT_TELEMETRY_DISABLED=1 COPY mcp-server/pyproject.toml /app/mcp-server/pyproject.toml
ENV PORT=3000 COPY mcp-server/src/ /app/mcp-server/src/
ENV HOSTNAME=0.0.0.0
# Copy Python packages from pydeps stage # Install MCP server + web deps
COPY --from=pydeps /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages RUN pip install --no-cache-dir /app/mcp-server && \
COPY --from=pydeps /usr/local/bin/uvicorn /usr/local/bin/uvicorn pip install --no-cache-dir fastapi uvicorn python-multipart
# Copy Next.js standalone build # Copy web app
COPY --from=builder /app/public ./public COPY web/ /app/web/
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
# Copy FastAPI backend code
COPY web/ ./web/
COPY mcp-server/src/ ./mcp-server/src/
# Make mcp-server source available to web/app.py (it does sys.path.insert for legal_mcp)
ENV PYTHONPATH=/app/mcp-server/src ENV PYTHONPATH=/app/mcp-server/src
ENV DOTENV_PATH=/dev/null
# Copy startup script EXPOSE 8080
COPY start.sh ./start.sh
RUN chmod +x ./start.sh
EXPOSE 3000 CMD ["uvicorn", "web.app:app", "--host", "0.0.0.0", "--port", "8080"]
CMD ["./start.sh"]

View File

@@ -371,7 +371,6 @@ Conclusion → Rule → Explanation → Application → Conclusion.
- MUST: מסקנה בפתיחת הדיון (לא בסוף) - MUST: מסקנה בפתיחת הדיון (לא בסוף)
- MUST: מענה לכל טענה שהוצגה בבלוק ז - MUST: מענה לכל טענה שהוצגה בבלוק ז
- MUST: ציטוט פסיקה בבלוקים ארוכים (200-600 מילים) - MUST: ציטוט פסיקה בבלוקים ארוכים (200-600 מילים)
- MUST: **צ'קליסט תוכן** — הפרומפט מזריק `{content_checklist}` אוטומטית לפי סוג הערר (מתוך `lessons.py: CONTENT_CHECKLISTS`). ראה `docs/corpus-analysis.md` לדפוסי תוכן לפי סוג.
- ⚠️ **MUST NOT ("ללא כפילות"):** חזרה על עובדות/טענות מבלוקים קודמים. השתמש בהפניות: "כאמור בסעיף X לעיל", "כפי שפורט", "כפי שציינו" - ⚠️ **MUST NOT ("ללא כפילות"):** חזרה על עובדות/טענות מבלוקים קודמים. השתמש בהפניות: "כאמור בסעיף X לעיל", "כפי שפורט", "כפי שציינו"
- MUST NOT: כותרות משנה (חריג: נושאים נפרדים לחלוטין) - MUST NOT: כותרות משנה (חריג: נושאים נפרדים לחלוטין)
- Dependencies: **ALL** previous blocks (ה-ט) - Dependencies: **ALL** previous blocks (ה-ט)

View File

@@ -1,409 +0,0 @@
# מתודולוגיית כתיבת החלטות — מדריך אנליטי לוועדת ערר לתכנון ובניה
מסמך זה מלמד כיצד לחשוב, לנתח ולבנות החלטה מנומקת. הוא אינו עוסק בסגנון הכתיבה של דפנה (ראה SKILL.md) ולא בנושאים שיש לכסות (ראה צ'קליסטים תוכניים). הוא עוסק בשיטה — כיצד להפוך חומרי מקור להנמקה משכנעת שתעמוד בביקורת שיפוטית.
---
## א. שלב מקדים — הבנת התיק לפני שנכתבת מילה
### א.1 קרא הכל, סכם, ואז חשוב
לפני שנכתב משפט אחד — קרא את כל חומרי המקור: כתב הערר, תגובת הוועדה המקומית, תגובת מבקשי ההיתר (אם יש), פרוטוקול הדיון, חוות דעת מומחים, ומסמכי תכנון רלוונטיים (תכנית, נספחים, החלטות ועדה מקומית).
**מה לעשות:**
- סמן את הטענות המרכזיות של כל צד. אל תסמוך על סיכום הצד — קרא את הנוסח המלא.
- זהה מהן העובדות שאינן שנויות במחלוקת ומהן העובדות השנויות במחלוקת.
- זהה את המסמכים הנורמטיביים הרלוונטיים (תכניות, חוקים, תקנות) וקרא אותם במלואם — לא רק את הסעיף הנטען. מילה בסעיף אחד מתפרשת לאור סעיפים אחרים באותו מסמך.
### א.2 סווג את הערר
סוג הערר קובע את מסגרת הניתוח:
- **ערר רישוי (1xxx)**: שאלת שיקול דעת תכנוני; הוועדה מפעילה שיקול דעת עצמאי.
- **ערר היטל השבחה (8xxx)**: שאלת שמאות ומשפט; ביקורת על שומה.
- **ערר פיצויים — סעיף 197 (9xxx)**: דומה להיטל השבחה.
הסיווג משפיע על תקן הביקורת, על עומק הדיון התכנוני, ועל טון ההחלטה.
### א.3 נסח את השאלות לדיון — במילותיך
הוועדה אינה כבולה לניסוח של עורכי הדין. אם העוררים העלו שמונה טענות אבל באמת יש שתי שאלות מרכזיות — נסח שתי שאלות. ניסוח הסוגיות הוא אבן הפינה של ההחלטה: הוא קובע אילו עובדות מהותיות ואילו כללים חלים.
**מה לעשות:**
- נסח כל שאלה כסילוגיזם מכווץ: הנחה משפטית, עובדות תמציתיות, שאלה חדה. לדוגמה: "תכנית X קובעת קו בניין של 3 מטרים. הבקשה כוללת בניה במרחק 1.5 מטרים מגבול המגרש. האם הבקשה תואמת את הוראות התכנית?"
- ניסוח הסוגיות נכתב בגרסה סופית רק אחרי שהדיון מגובש — כדי לוודא שהשאלות תואמות את התשובות.
**מבוסס על:** FJC Judicial Writing Manual §§A5-A7; Garner, Making Your Case §36; Posner — ניסוח סוגיות כאבן פינה.
---
## ב. ניתוח סף — מתי לבדוק, מתי לדלג
### ב.1 שאלות סף תמיד קודמות
אם עולה שאלת סמכות, מועד הגשה, או עמידה בתנאי מוקדם — היא נדונה ראשונה. הלוגיקה פשוטה: אם אין סמכות לדון, כל שאר הדיון מיותר.
**מה לעשות:**
- אם שאלת הסף נדחית (כלומר, הוועדה מוסמכת / הערר הוגש בזמן) — ציין זאת בפסקה אחת ועבור לגוף הערר.
- אם שאלת הסף מתקבלת — ההחלטה מסתיימת בה. אין צורך לדון בגוף.
- אל תדון בשאלת סף שלא הועלתה על ידי אף צד ושאין לה בסיס בחומר.
### ב.2 ציון תקן הביקורת
בפתיחת חלק הדיון, ציין את תקן הביקורת של הוועדה: "הוועדה מפעילה שיקול דעת תכנוני עצמאי" (ברישוי) או "הוועדה בוחנת את תקינות השומה המכרעת" (בהיטל השבחה). בלי ציון תקן — הקורא לא יודע באיזה סטנדרט נבחנה ההחלטה, והנימוק נשאר עמום.
**מבוסס על:** FJC §B6; Posner — legalism works when the rule is clear.
---
## ג. סדר הסוגיות — מה קודם ולמה
### ג.1 עקרון הסדר
1. **שאלות סף** — תמיד ראשונות.
2. **הסוגיה המכריעה** — מיד אחריהן. הסוגיה שמכריעה את הערר באה לפני סוגיות משניות.
3. **סוגיות נוספות** — לפי חוזק ההנמקה. פתח בנימוק החזק ביותר. רושם ראשוני אי אפשר לבטל, ותשומת הלב של הקורא בשיאה בהתחלה.
4. **סוגיות שנויות אך לא נחוצות** — בסוף, או בכלל לא.
### ג.2 מתי לא לדון בטענה
ההחלטה צריכה לדון רק בסוגיות שיש לפתור כדי להכריע. אם העורר העלה שמונה טענות אבל שתיים מכריעות — הדיון מתמקד בשתיים. את השאר ניתן לטפל כך:
- טענה שהועלתה ברצינות אך אינה נחוצה: "טענה זו נבחנה על ידי הוועדה. נוכח מסקנתנו לעיל, אין צורך להכריע בה."
- טענות חלשות או חוזרות: ניתן לקבץ. "באשר לטענות הנוספות שהעלו העוררים — לא מצאנו בהן ממש."
- אל תתעלם לחלוטין מטענה מרכזית. הצד המפסיד חייב לראות שהוועדה שקלה את יסודות עמדתו.
### ג.3 פסקת מפה
בפתיחת הדיון, ספק מפת דרכים: "שלוש שאלות עומדות להכרעה: (1) האם הבקשה תואמת את הוראות התכנית לעניין קו הבניין; (2) האם ההקלה המבוקשת עומדת בתנאי סעיף 147; (3) מהו הסעד המתאים." הקורא יודע מראש מה לצפות, וההנמקה נתפסת כמאורגנת.
**מבוסס על:** FJC §§B2-B5; Garner, MYC §§7, 12; LWPE §27; Posner — narrow holdings, focus on what matters.
---
## ד. בניית הניתוח — הלב של ההחלטה
### ד.1 מבנה סילוגיסטי לכל סוגיה
כל סוגיה נבנית כסילוגיזם:
1. **הנחה עליונה (הכלל)** — סעיף בתכנית, הוראת חוק, הלכה פסוקה, או עיקרון תכנוני.
2. **הנחה תחתונה (העובדות)** — העובדות הספציפיות של הערר שנבחנות לאור הכלל.
3. **מסקנה** — התוצאה שנובעת בהכרח מהחלת הכלל על העובדות.
זהו השלד. כל הנמקה שאינה ניתנת לפירוק למבנה זה — חסרה חוליה. אם לא ניתן לזהות את הכלל — ההנמקה אינה מספקת. אם לא ניתן לזהות כיצד העובדות מקיימות את הכלל — ההנמקה קריפטית.
### ד.2 התחל מלשון הטקסט
כשהמקרה נשלט על ידי הוראת תכנית או סעיף חוק — פתח תמיד בציטוט ההוראה. לא בפסיקה, לא בעקרון כללי. המילים של הטקסט הן נקודת המוצא.
**מה לעשות:**
- הבא את לשון ההוראה הרלוונטית (ציטוט ישיר, קצר ככל האפשר).
- פרש מילים במשמעותן הרגילה.
- בדוק עקביות עם הוראות אחרות באותה תכנית.
- תן תוקף לכל מילה — מילה "מיותרת" בטקסט נורמטיבי אינה מיותרת.
- אם יש עמימות — השתמש בכלי פרשנות: הכלל הכללי מצטמצם לאור הפרט; מילה מתפרשת לאור הקשרה; הכללת דבר אחד מרמזת על הדרת אחרים.
### ד.3 שלושה מקורות להנחה העליונה
בעררי תכנון, הכלל נשאב משלושה מקורות:
- **טקסט**: הוראות התכנית, חוק התכנון והבניה, תקנות.
- **תקדים**: פסיקת בתי משפט, החלטות ועדת ערר ארצית, החלטות ועדות ערר מחוזיות.
- **מדיניות**: שיקולים תכנוניים — צפיפות, אופי סביבה, אינטרס ציבורי, השפעות כלכליות.
בחר את המקור החזק ביותר. אם יש הוראת תכנית ברורה — אין צורך בפסיקה כדי לתמוך בה. פסיקה נדרשת כשהטקסט עמום או כשצריך לקבוע כיצד ליישם עיקרון כללי.
### ד.4 ההנחה התחתונה היא המפתח
ברוב העררים, הכלל המשפטי אינו שנוי במחלוקת. השאלה היא כיצד העובדות משתלבות בכלל. זהו לב ההחלטה. ההנמקה חייבת להראות בפירוט — לא בהכרזה — כיצד העובדות הספציפיות מקיימות או אינן מקיימות את תנאי הכלל.
**מה לעשות:**
- השתמש בנתונים: מספרים, מידות, אחוזים, תאריכים (כשרלוונטיים). "הבקשה חורגת ב-1.5 מטרים מקו הבניין" — לא "הבקשה חורגת באופן משמעותי."
- הפרד בין ממצא עובדתי למסקנה משפטית. "הבניה במרחק 1.5 מטרים מגבול המגרש" — ממצא עובדתי. "חריגה זו עולה כדי סטייה ניכרת" — מסקנה משפטית. אל תערבב.
- כל מעבר מכלל לעובדה למסקנה צריך להיות מפורש. לא לכתוב "העובדות מלמדות כי הערר אינו מוצדק" בלי לפרט למה.
### ד.5 מבנה CREAC בפועל
לכל סוגיה, השתמש במבנה הבא:
1. **מסקנה** (Conclusion) — פתח בתשובה לשאלה. "הבקשה אינה תואמת את הוראות התכנית לעניין קו הבניין."
2. **כלל** (Rule) — הבא את הכלל. ציטוט הוראת התכנית או ההלכה.
3. **הרחבה** (Explanation) — אם הכלל דורש הבהרה, הבא תקדים רלוונטי אחד שמסביר כיצד הכלל יושם במקרה דומה.
4. **יישום** (Application) — החל את הכלל על עובדות המקרה. כאן נמצא לב ההנמקה.
5. **מסקנה חוזרת** (Conclusion) — סגור בתמצית. "לפיכך, הבקשה אינה עולה בקנה אחד עם הוראות התכנית."
הפתיחה במסקנה חיונית: הקורא יודע לאן הדיון מוביל, וכל עובדה שנקראת אחר כך מובנת בהקשרה. עובדות ללא מסגרת — נתפסות כאקראיות וחסרות משמעות.
**מבוסס על:** Garner, MYC §§22-27; FJC §§B1, B8; Posner — facts drive decisions; data over words; distinguish findings from conclusions.
---
## ה. איזון ומידתיות — מתי ואיך
### ה.1 מתי נדרש איזון
איזון נדרש כשהדין לא נותן תשובה חד-משמעית. כשהכלל ברור והעובדות מתאימות לו — אין צורך באיזון. אל תאזן כשאפשר להכריע לפי כלל. איזון הוא כלי לשעה שהכללים אוזלים, לא תחליף לניתוח נורמטיבי.
### ה.2 מבנה האיזון
כשאיזון נדרש, בנה אותו כך:
1. **זהה את האינטרסים** — מהם האינטרסים המתחרים. לא "אינטרס הציבור" מול "אינטרס העורר" באופן מעורפל, אלא אינטרסים קונקרטיים: "זכות הקניין של העורר לבנות על מגרשו" מול "שמירה על אופי מגורים צמודי קרקע בשכונה."
2. **בחן השלכות לכל כיוון** — מה קורה אם מקבלים? מה קורה אם דוחים? לא "מהו האינטרס החשוב יותר" אלא "מהן ההשלכות של כל תוצאה על כל אינטרס."
3. **שקול השלכות מערכתיות** — לא רק תוצאה לתיק זה, אלא גם האות שנשלח למערכת התכנון. קבלת הערר תיצור תקדים? תפתח פתח לבקשות דומות?
4. **הגע למסקנה** — ציין מפורשות מה מכריע את הכף ולמה.
### ה.3 מידתיות כמבחן
כשהוועדה מטילה מגבלה או תנאי — בדוק: (1) האם המגבלה משרתת תכלית ראויה; (2) האם יש אמצעי פוגע פחות; (3) האם הפגיעה מידתית ביחס לתועלת. שלושת השלבים צריכים להיות מפורשים בטקסט.
**מבוסס על:** Posner — balance as methodology; systemic vs. case-specific consequences; pragmatist approach within legal norms.
---
## ו. טיפול בטענות — כללים מעשיים
### ו.1 אל תהפוך את הדיון לוויכוח
ההחלטה מנתחת שאלה — לא מתווכחת עם עורכי דין. המבנה הנכון הוא: שאלה → כלל → עובדות → מסקנה. לא: "העורר טוען X — אין לקבל טענה זו — שכן Y."
הדיון לא מתנהל כ"תשובה לכתב הערר" אלא כניתוח עצמאי שבוחן את השאלות שהתעוררו. הוועדה מגיעה למסקנותיה מכוח הנימוק — לא מכוח דחיית טענות.
### ו.2 Steel-manning — הצג את הטענה הטובה ביותר של הצד המפסיד
לפני שדוחים טענה — הצג אותה בגרסה החזקה ביותר שלה. לא קריקטורה של הטענה, אלא הטענה כפי שעורך דין מוכשר היה מנסח אותה. אז הסבר למה היא נדחית.
**למה זה חשוב:** טענת קש קלה להפריך, אבל הקורא (ובמיוחד בית המשפט בביקורת שיפוטית) יזהה שלא התמודדת עם הטענה האמיתית. הצגה הוגנת של הטענה ודחייתה — משכנעת. הצגה מעוותת — מחשידה.
**מה לעשות:**
- כשנדרשת התמודדות עם טענת העורר, כתוב: "אמנם צודק העורר כי [נקודה שפועלת לטובתו], אולם [הנימוק לדחייה]."
- אם יש נקודה שאי אפשר להגן עליה — הכר בה בגלוי. "נכון כי המבנה הסמוך חורג מקו הבניין. אולם עובדה זו אינה מקנה זכות לחריגה נוספת, שכן..."
- טענה חלשה שאין בה ממש — מספיק משפט אחד. אל תפזר זמן על טענות שאינן ראויות לדיון.
### ו.3 מיקום ההתמודדות עם טענות נגדיות
באמצע הדיון — לא בהתחלה ולא בסוף. המבנה המומלץ לכל סוגיה:
1. הנחה משפטית (הכלל)
2. יישום על העובדות
3. מסקנה ראשונית
4. **טענה נגדית + תשובה**
5. **טענה נגדית נוספת + תשובה** (אם יש)
6. נקודה תומכת נוספת
7. משפט סיכום
פתיחה בטענות הצד השני מציבה את ההחלטה בעמדת הגנה. סיום בהן משאיר את המוקד על הצד המפסיד. האמצע הוא המקום הנכון.
### ו.4 קיבוץ טענות
כשיש טענות רבות שמכוונות לאותה נקודה — קבץ אותן. "העוררים העלו מספר טענות הנוגעות לאופן חישוב השטחים. לאחר בחינתן, לא מצאנו בהן ממש, ונפרט." זה עדיף על טיפול נקודתי בכל טענה, שמייצר תחושה של רשימת מכולת ולא של ניתוח.
**מבוסס על:** FJC §§B3-B4, E1-E2; Garner, MYC §§4, 8, 10-12; LWPE §30; Posner — honest engagement with counterarguments, avoid empty formulas.
---
## ז. ציטוטים ואזכורי פסיקה — פחות זה יותר
### ז.1 טכניקת הסנדוויץ'
כל ציטוט חייב להיות עטוף: משפט הקדמה → ציטוט → ניתוח.
**הקדמה גרועה:** "בית המשפט קבע כדלקמן:" (ריקה מתוכן).
**הקדמה טובה:** "בית המשפט קבע כי אין לקבל בקשות שהוגשו באיחור ללא טעם מיוחד:" (מודיעה על התוכן).
אל תניח שהקורא יקרא ציטוט ארוך. סכם את עיקרו לפניו, ולאחריו הוסף ניתוח שמסביר כיצד הציטוט רלוונטי למקרה הנדון.
### ז.2 כמה לצטט
- **הוראת תכנית/חוק**: ציטוט ישיר — המילים המדויקות חשובות כי ההנמקה נבנית עליהן.
- **הלכה פסוקה**: פרפרזה עדיפה. צטט ישירות רק כשהניסוח המקורי עושה נקודה שלא ניתן לבטא בפרפרזה. 1-2 משפטים לכל היותר.
- **כלל מוסדר**: מקור אחד מספיק. לא מחרוזות של "ראו: X; Y; Z; A; B." מחרוזת אזכורים אינה מוסיפה כוח — היא מעידה על חוסר ביטחון.
- **כלל חדש או שנוי במחלוקת**: כאן כן יש מקום לסקירת ההתפתחות בפסיקה, אבל ממוקדת ותכליתית.
### ז.3 היררכיית תקדימים
בעררי תכנון, סדר המשקל הוא:
1. פסיקת בית המשפט העליון
2. פסיקת בית משפט לעניינים מנהליים
3. החלטות ועדת ערר ארצית
4. החלטות ועדות ערר מחוזיות אחרות
5. ספרות משפטית/תכנונית
העדף תקדים עדכני. כשמאזכרים תקדים — ציין בדיוק מה נפסק ואם מדובר בהלכה מחייבת או אמרת אגב. אם התקדים שונה מהמקרה הנדון — אמור זאת במפורש.
### ז.4 הפניות ביבליוגרפיות
שלב את שם בית המשפט ושם התיק בגוף הטקסט ("כפי שקבע בית המשפט העליון בפרשת אליאב") והעבר את ההפניה המספרית להערת שוליים. הפניות בגוף הטקסט שוברות את מהלך המחשבה.
**מבוסס על:** FJC §§D1-D5; Garner, MYC §§26-27, 48, 50; LWPE §§28-29.
---
## ח. כתיבת חלק העובדות — ניטרלי, ממוקד, מדויק
### ח.1 רק עובדות הנחוצות להסברת ההחלטה
כל עובדה שמופיעה — הקורא יניח שהיא רלוונטית. אם היא לא רלוונטית — היא מסיחה דעת. אם היא רלוונטית ולא מופיעה — ההנמקה חסרה בסיס.
**מה לעשות:**
- כלול רק עובדות שמשמשות בדיון. מבחן: לכל עובדה בחלק הרקע, שאל — "האם אני מפנה לעובדה זו בחלק הדיון?" אם לא — שקול להסיר.
- תאריכים מדויקים רק כשהם מהותיים (מועד הגשה, תוקף תכנית, שאלת שיהוי). אחרת — "כחודש לאחר מכן", "בתחילת 2023."
- פרטים "מעניינים" שאינם רלוונטיים — השמט. היסטוריה של השכונה, נוף, תיאורים ציוריים — רק אם רלוונטיים להחלטה.
### ח.2 ניטרליות מוחלטת
חלק העובדות אינו טוען. אין בו מילות שיפוט ("למרבה הפליאה", "באופן מפתיע"). אין בו ציטוטים מצדדים (ציטוטים שייכים לחלק הטענות). הוא מציג עובדות — לא מפרש אותן.
אבל ניטרליות אינה הסתרה. אם יש עובדה שתומכת בצד המפסיד — היא חייבת להופיע. רקע ניטרלי כולל את כל העובדות המהותיות, לא רק את אלה שתומכות בתוצאה.
### ח.3 מבנה: סדר כרונולוגי, עובדות כלליות ואז ספציפיות
עקוב אחר ציר הזמן: הנכס, הבקשה, ההחלטה, הערר. אל תפתח בהחלטת הוועדה המקומית ואז תחזור לתיאור הנכס.
בתיקים רב-סוגייתיים — הגבל את חלק הרקע לעובדות כלליות ושלב עובדות ספציפיות בדיון בכל סוגיה. זה מונע כפילות ושומר על רלוונטיות.
### ח.4 דיוק מוחלט
אל תסמוך על עובדות כפי שמוצגות בכתבי הטענות. בדוק מול חומרי המקור (פרוטוקולים, תכניות, תצהירים). שגיאה עובדתית היא הדבר המזיק ביותר שיכול לקרות להחלטה — היא מערערת את סמכותה ופוגעת באמינותה.
**מבוסס על:** FJC §§C1-C6; Garner, LWPE §§3, 17, 23; MYC §36; Posner — data over words, facts drive decisions.
---
## ט. כתיבת חלק ההכרעה — ברור ואופרטיבי
### ט.1 התוצאה חייבת להיות חד-משמעית
"הערר נדחה." "הערר מתקבל." "הערר מתקבל בחלקו." לא "לאור כל האמור לעיל, הערר נדחה" — אלא סיכום קצר (2-3 משפטים) שמסביר את עיקר ההנמקה, ואז התוצאה.
### ט.2 הוראות אופרטיביות מפורטות
כשהערר מוחזר לוועדה המקומית — אל תדבר בחידות. "הערר מוחזר לוועדה המקומית לצורך דיון מחדש" — אינו מספיק. פרט: מה צריכה הוועדה המקומית לבחון? לפי איזו תכנית? האם לתת שימוע? מהם השיקולים שיש לשקול?
כשנקבעים תנאים — פרט כל תנאי באופן שהגוף המבצע יוכל ליישם בלי לפרש את ההחלטה.
### ט.3 שמירה על סמכות הערכאה הנמוכה
גם כשנמצא פגם בשיקול הדעת — ההחלטה מחזירה את העניין לוועדה המקומית כדי שתפעיל שיקול דעת מחדש. אל תכפה תוצאה ספציפית אלא אם הדין מחייב תוצאה אחת בלבד.
### ט.4 התייחסות לוועדה המקומית — ללא ביקורת מיותרת
כשהערר מתקבל — הוועדה המקומית טעתה. אבל ההנמקה מתמקדת ב"מה צריך להיות" — לא ב"כמה טעתה הוועדה המקומית." אין "באופן מפתיע", "למרבה הפליאה", "שגתה שגיאה חמורה". נמק את הפגם — אל תבקר את השופט.
**מבוסס על:** FJC §§E4, F1-F3; Garner, MYC §21; Posner — narrow holdings, constrained pragmatism.
---
## י. טכניקות כתיבה — ברמת הפסקה והמשפט
### י.1 משפט נושא בפתיחת כל פסקה
כל פסקה נפתחת במשפט שמודיע על הנקודה המרכזית שלה. לא באזכור פסק דין, לא בהפניה, לא בתיאור רקע. הנקודה — ואז התמיכה.
**לא:** "בעע"מ 1234/05 נקבע כי..." → הקורא לא יודע למה הוא קורא על פסק הדין הזה.
**כן:** "ועדת ערר אינה מוסמכת להתערב בשיקול דעת מקצועי של מהנדס העיר. כך נפסק ב..." → הקורא יודע את הנקודה, ופסק הדין תומך בה.
### י.2 גשרים בין פסקאות
כל פסקה חייבה להיות מחוברת לקודמתה. שלושה כלים:
- **מילות קישור מפורשות**: לפיכך, אולם, בנוסף, מנגד, אכן, עם זאת.
- **מילות הצבעה**: "בעניין זה", "נוכח קביעה זו", "מעבר לכך".
- **הדי הפסקה הקודמת**: חזרה על מונח מפתח מהפסקה הקודמת בפתיחת הפסקה הנוכחית.
### י.3 פסקה אחת — נקודה אחת
אם פסקה עוסקת גם בכלל המשפטי, גם ביישומו, וגם בטענה נגדית — חלק אותה. הפסקה היא יחידת החשיבה הבסיסית, ויחידה שמכילה שני רעיונות שונים — מבלבלת.
### י.4 כותרות אינפורמטיביות (כשמתאים)
כשיש כותרות משנה בדיון (בתיקים מורכבים עם סוגיות נפרדות) — כתוב כותרת שמודיעה על המסקנה, לא רק על הנושא.
- **לא:** "סוגיית קו הבניין"
- **כן:** "הבנייה בקו אפס אינה עולה בקנה אחד עם הוראות התכנית"
### י.5 בניין פעיל
"הוועדה המקומית דחתה את הבקשה" — לא "הבקשה נדחתה על ידי הוועדה המקומית." בניין פעיל קצר יותר, ברור יותר, ומזהה את הפועל. חריג: כשהפעולה חשובה יותר מהפועל ("ההיתר בוטל" — כשלא חשוב מי ביטל).
### י.6 דיוק ומשמעת לשונית
- **עקביות מינוחית**: אם כתבת "היתר בנייה" — אל תעבור ל"רישיון בנייה." עקביות חשובה מגיוון.
- **לא להגזים**: "הפסיקה חד-משמעית" — רק אם היא באמת חד-משמעית. "אין כל ספק" — רק אם באמת אין. הגזמה מערערת אמינות.
- **לא לנפח**: "במידה ו-" → "אם". "לאור העובדה ש-" → "מכיוון ש-". "על מנת ש-" → "כדי ש-". כל מילה שאינה עוזרת — מפריעה.
- **לא לכפול**: "לבטל ולהפקיע" → "לבטל". אם מילה אחת מספיקה — מילה שנייה מחייבת את הקורא לחפש הבדל שאינו קיים.
- **סיום חזק**: אל תסיים משפט בתאריך או בהפניה אלא אם הם חשובים. המילה האחרונה במשפט היא זו שנשארת.
### י.7 כנות לגבי קושי
כשהמקרה קשה — אמור זאת. "הדבר אינו נקי מספקות, אולם..." עדיף על פני הצגת מקרה קשה כקל. כנות לגבי הקושי מחזקת את אמינות ההחלטה — הקורא מבין שהוועדה התלבטה ובכל זאת הגיעה למסקנה מנומקת.
אבל — ההחלטה משקפת רק את התוצאה הסופית. לא לתעד כל צעד ומעד בדרך, לא להציג שני מסלולי חשיבה חלופיים. אם ההחלטה קשה — ניתן לומר זאת, ואז להציג את ההנמקה הסופית בביטחון.
### י.8 הימנעות מנוסחאות ריקות
כל משפט חייב לעשות עבודה. "לאחר ששקלנו את כלל השיקולים הרלוונטיים" — ריק. מה שקלתם? "בעניין זה יש לומר" — ריק. אמור מה יש לומר בלי ההקדמה. "הננו סבורים" — ריק. כתוב את מה שאתה סבור, בלי להכריז שאתה סבור.
מבחן: אם מוחקים את המשפט וההחלטה לא מאבדת מידע — המשפט מיותר.
**מבוסס על:** FJC §§G1-G6; Garner, LWPE §§5-17, 24-26; MYC §§6, 35, 39, 43; Posner — avoid empty formulas, candor about uncertainty.
---
## יא. אנלוגיה ותקדים — מתי ואיך
### יא.1 אנלוגיה דורשת הסבר מדיניות
"מקרה זה דומה לפרשת X" — ריק, אלא אם מסביר למה הדמיון רלוונטי. מה המדיניות שעמדה בבסיס ההחלטה ב-X? האם אותה מדיניות חלה כאן?
**מה לעשות:**
- כשמפנים לתקדים, ציין: (1) מה נפסק שם; (2) מה הנסיבות הדומות; (3) למה הרציונל חל גם כאן.
- כשמבחינים מתקדים: (1) מה שונה; (2) למה ההבדל משמעותי.
### יא.2 החזקות חלופיות — "אף בהנחה"
הימנע מ"אף בהנחה שצודקים העוררים בטענתם..." ו"גם אם היינו מקבלים..." — הם מחלישים את ההחזקה העיקרית. אם יש שני נימוקים — דון בנימוק המשני קודם ואז הצג את הנימוק העיקרי. כך שני הנימוקים עומדים בזכות עצמם, בלי שאחד מערער את השני.
**מבוסס על:** FJC §B7; Garner, MYC §§26, 48; Posner — analogy requires policy analysis, narrow holdings.
---
## יב. עריכה — רשימת ביקורת
לפני סיום ההחלטה, בצע את הבדיקות הבאות:
### ביקורת מבנית
- [ ] המבוא מכסה את כל הסוגיות שנדונו בהחלטה
- [ ] כל עובדה בחלק הרקע מופיעה בדיון (אין עובדות "יתומות")
- [ ] כל קביעה בדיון מבוססת על עובדה מחלק הרקע (אין עובדות חדשות בדיון)
- [ ] סדר הסוגיות לוגי: סף → מכריע → משני
- [ ] המסקנה נובעת מהדיון — לא מכריזה תוצאה שלא נומקה
### ביקורת אנליטית
- [ ] לכל סוגיה — ניתן לזהות כלל + עובדות + מסקנה (מבנה סילוגיסטי)
- [ ] הממצאים העובדתיים מופרדים מהמסקנות המשפטיות
- [ ] הטענה המרכזית של הצד המפסיד קיבלה מענה מנומק
- [ ] אין "נוסחאות ריקות" — כל משפט עושה עבודה
- [ ] אין הגזמה — "חד-משמעי", "ברי", "ללא ספק" רק כשמוצדקים
### ביקורת עקביות
- [ ] התוצאה בבלוק יא/יב תואמת את הסיכום בבלוק א/ב
- [ ] מינוח עקבי לאורך כל ההחלטה (אותם מונחים לאותם מושגים)
- [ ] הציטוטים מדויקים ובהקשרם
- [ ] אזכורי פסיקה נכונים (לא מייחסים לפסק דין יותר ממה שאמר)
**מבוסס על:** FJC §§G8-G10; Garner, MYC §6; Posner — precision, intellectual honesty.
---
## סיכום — עשרת העקרונות המנחים
1. **סילוגיזם תמיד**: כלל → עובדות → מסקנה. אין קיצורי דרך.
2. **התחל מהטקסט**: הוראת תכנית או חוק — לפני פסיקה, לפני עקרונות כלליים.
3. **עובדות מכריעות**: רוב המקרים מוכרעים על ידי העובדות, לא על ידי הדין.
4. **נתונים, לא תיאורים**: מספרים ומידות — לא "משמעותי", "ניכר", "מהותי."
5. **Steel-man**: הצג את הטענה הטובה ביותר של הצד המפסיד — ואז הסבר למה היא נדחית.
6. **כנות**: מקרה קשה — אמור שהוא קשה. אל תעמיד פנים שקל.
7. **כל מילה עובדת**: נוסחה ריקה, מילה מנופחת, כפילות — מחק.
8. **מסקנה קודם**: הקורא יודע לאן הדיון מוביל — העובדות מובנות בהקשרן.
9. **מקור אחד מספיק**: לנקודה מוסדרת — אזכור אחד. מחרוזות אזכורים = חולשה.
10. **הוראות ברורות**: הצד שמקבל את ההחלטה חייב לדעת בדיוק מה נדרש ממנו.
---
*מסמך זה מבוסס על שלושה מקורות מרכזיים: (1) Federal Judicial Center, Judicial Writing Manual (1991, 2020); (2) Garner, Legal Writing in Plain English (2001) ו-Scalia & Garner, Making Your Case (2008); (3) Posner, How Judges Think (2008). העקרונות סונתזו והותאמו להקשר של ועדת ערר לתכנון ובניה בישראל.*

View File

@@ -1,610 +0,0 @@
# עקרונות כתיבת החלטות מעין-שיפוטיות — מיצוי מתוך Judicial Writing Manual (FJC)
מקורות:
- **מהדורה ראשונה (1991)** — Judicial Writing Manual, Federal Judicial Center
- **מהדורה שנייה (2020)** — Judicial Writing Manual: A Pocket Guide for Judges, Second Edition
---
## A. מבנה כולל של ההחלטה — מה קודם, מה אחרון, רצף
### A1. חמישה מרכיבים חובה בהחלטה מלאה
**העיקרון:** החלטה מלאה חייבת לכלול חמישה אלמנטים בסדר הבא: (1) מבוא — טבע התיק ומצבו הפרוצדורלי; (2) ניסוח הסוגיות; (3) תיאור העובדות המהותיות; (4) דיון בעקרונות המשפטיים וביישומם; (5) התוצאה האופרטיבית וההוראות.
> "A full-dress opinion should contain five elements: (1) an introductory statement of the nature and procedural posture of the case; (2) a statement of the issues to be decided; (3) a description of the material facts; (4) a discussion of the governing legal principles and the resolution of the issues; and (5) the disposition and necessary instructions."
> — 1991, עמ' 13; 2020, עמ' 13
**יישום לוועדת ערר:** מתאים ישירות לארכיטקטורת 12 הבלוקים — בלוקים א-ג (מבוא/פרוצדורה), ד-ה (סוגיות), ו (עובדות), ז-י (דיון), יא-יב (תוצאה).
---
### A2. כותרות וכותרות-משנה — חובה
**העיקרון:** יש להשתמש בכותרות, כותרות-משנה, ומספור כדי לחשוף את ארגון ההחלטה לקורא. זה חיוני במיוחד כשההחלטה ארוכה והנושא מורכב.
> "The use of headings and subheadings, Roman numerals, or other means of disclosing the organization to the reader is always helpful, particularly where the opinion is long and the subject matter complex. These not only provide road signs for the reader, they also help to organize the writer's thoughts and test the logic of the opinion."
> — 1991, עמ' 13; 2020, עמ' 13
**יישום לוועדת ערר:** כל בלוק מקבל כותרת ברורה. בתוך בלוק הדיון (י) — כותרות-משנה לכל סוגיה. מאפשר לצדדים ולבית המשפט לנווט בהחלטה.
---
### A3. מבוא — מכוון את הקורא
**העיקרון:** מטרת המבוא היא לכוון (orient) את הקורא. הוא צריך לציין בקצרה: מהו התיק, מה הנושא המשפטי, ומה התוצאה. בנוסף, יש לזהות את הצדדים (רצוי בשם ולא בתואר פרוצדורלי), לתאר את המצב הפרוצדורלי, ולציין את הסוגיות.
> "The purpose of the introduction is to orient the reader to the case. It should state briefly what the case is about, the legal subject matter, and the result."
> — 1991, עמ' 13; 2020, עמ' 13
> "The parties should be identified, if not in the introduction then early in the opinion, preferably by name, and that identification should be used consistently throughout. The use of legal descriptions, such as 'appellant' and 'appellee,' tends to confuse, especially in multi-party cases."
> — 1991, עמ' 13; 2020, עמ' 13-14
**יישום לוועדת ערר:** בבלוק א — זיהוי הצדדים בשם (לא "העורר" ו"המשיבה" בלבד). ציון סוג הערר, נושאו, ותוצאתו כבר בפתיחה. שימוש עקבי באותו זיהוי לאורך כל ההחלטה.
---
### A4. סיכום ההחזקה בתחילת ההחלטה
**העיקרון:** סיכום התוצאה כבר בפתיחה חוסך זמן לקוראים, ומאלץ את הכותב לנסח את ההחזקה בדיוק ובתמציתיות. הגרסה הסופית של המבוא כדאי שתיכתב אחרי השלמת ההחלטה כולה.
> "Summarizing the holding at the outset can save time for readers, particularly researchers who will be able to determine immediately whether to read the rest of the opinion. Providing a terse summary of the holding at the start of the opinion also helps the writer to state it precisely and succinctly. The final version of the introduction may be best written after the opinion is completed."
> — 1991, עמ' 13; 2020, עמ' 14
**יישום לוועדת ערר:** בבלוק א לכתוב: "הערר נדחה/מתקבל" + משפט אחד על הנימוק המרכזי. המבוא נכתב אחרון (אחרי שהדיון מגובש).
---
### A5. ניסוח הסוגיות — אבן הפינה
**העיקרון:** ניסוח הסוגיות הוא אבן הפינה של ההחלטה. הוא קובע אילו עובדות הן מהותיות ואילו עקרונות משפטיים חלים. השופט לא כבול לניסוח של עורכי הדין — עליו לנסח את הסוגיות כפי שהוא רואה אותן.
> "The statement of issues is the cornerstone of the opinion; how the issues are formulated determines which facts are material and what legal principles govern. Judges should not be prisoners of the attorneys' analysis; they should frame the issues as they see them."
> — 1991, עמ' 14; 2020, עמ' 14
**יישום לוועדת ערר:** בלוקים ד-ה — הוועדה מנסחת את השאלות לדיון במילותיה, לא בניסוח העוררים. אם העוררים הגדירו שלוש שאלות אבל באמת יש שאלה מרכזית אחת — הוועדה מנסחת שאלה אחת.
---
### A6. סוגיות לפני/אחרי עובדות — גמישות
**העיקרון:** ניסוח הסוגיות יכול לבוא לפני או אחרי תיאור העובדות. הצבת הסוגיות קודם הופכת את תיאור העובדות למשמעותי יותר ומסייעת להתמקד בעובדות המהותיות. אך לפעמים לא ניתן לנסח את הסוגיה ללא שהקורא מכיר את העובדות.
> "Stating the issues first will make the fact statement more meaningful to the reader and help focus on material facts."
> — 1991, עמ' 14; 2020, עמ' 14
**יישום לוועדת ערר:** בארכיטקטורת 12 הבלוקים — בלוק ה (סוגיות) בא לפני בלוק ו (רקע עובדתי). זה מתאים לעיקרון.
---
### A7. ניסוח סוגיות ≠ פירוט טענות הצדדים
**העיקרון:** יש להפריד בין ניסוח הסוגיות לבין פירוט טענות הצדדים. פירוטים ארוכים של טענות אינם תחליף לניתוח ולנימוק, ויש להימנע מהם.
> "The statement of issues should not be confused with recitals of the parties' contentions. Lengthy statements of the parties' contentions, occasionally found in opinions, are not a substitute for analysis and reasoning and should be avoided."
> — 1991, עמ' 14-15; 2020, עמ' 14
**יישום לוועדת ערר:** בלוקים ז-ח (טענות הצדדים) הם נפרדים מבלוק ה (סוגיות). בלוק ה קצר וממוקד; בלוקים ז-ח מפרטים את הטענות; בלוק י מנתח — ולא חוזר על הטענות.
---
### A8. ההחלטה משקפת רק את התוצאה הסופית
**העיקרון:** הכתיבה צריכה לשקף רק את ההחלטה הסופית ואת הנימוקים שלה. כשההחלטה קשה — יש לומר זאת, אבל לא לתעד כל צעד ומעד בדרך.
> "The writing should reflect only the final decision and the reasons for it. Where the decision is a close one, the opinion should say so, but it should not record every step and misstep the writer took along the way."
> — 1991, עמ' 10; 2020, עמ' 9
**יישום לוועדת ערר:** הדיון בבלוק י לא מתעד את התלבטויות הוועדה. אם ההחלטה קשה — ניתן לכתוב "הדבר אינו נקי מספקות, אולם..." ולהמשיך בנימוק ברור לתוצאה.
---
## B. כתיבת חלק הדיון/ניתוח — לב ההחלטה
### B1. הדיון חייב להיות מבוסס על היגיון ולוגיקה, לא על טיעון
**העיקרון:** חלק הדיון הוא לב ההחלטה. הוא חייב להדגים שמסקנת בית המשפט מבוססת על שכל ישר ולוגיקה. הוא צריך לשכנע את הקורא בכוח הנימוק — לא באמצעות סנגוריה או טיעון.
> "The discussion of legal principles is the heart of the opinion. It must demonstrate that the court's conclusion is based on reason and logic. It should persuade the reader of the correctness of the result by the power of its reasoning, not by advocacy or argument."
> — 1991, עמ' 16; 2020, עמ' 16
**יישום לוועדת ערר:** בלוק י — הדיון לא "טוען" בעד התוצאה אלא בונה שרשרת נימוקים: כלל → עובדות → מסקנה. הטון ניטרלי-אנליטי, לא אדברסרי.
---
### B2. סוגיות מכריעות קודם
**העיקרון:** ככלל, סוגיות מכריעות (dispositive) צריכות להידון ראשונות. הסדר ייקבע על-ידי הלוגיקה של הנימוק. סוגיות שאינן מכריעות — אם בכלל נדונות — באות בסוף.
> "Generally, dispositive issues should be discussed first. The order in which those issues are taken up will be governed by the opinion's reasoning. If non-dispositive issues are addressed at all — for educational reasons or to guide further proceedings — discuss them near the end of the opinion."
> — 1991, עמ' 16-17; 2020, עמ' 16-17
**יישום לוועדת ערר:** אם יש טענת סף (אי-עמידה בתנאי, איחור) — נדונה קודם. אם נדחית, ממשיכים לגוף הערר. בתוך הדיון — הסוגיה שמכריעה את הערר קודמת.
---
### B3. לא לדון בכל מה שהצדדים העלו
**העיקרון:** ככלל, ההחלטה צריכה לדון רק בסוגיות שיש לפתור כדי להכריע בתיק. מה שהוועדה אינה צריכה להכריע — לא צריך לדון בו. אם הערכאה מגלה שסוגיה שהצדדים לא העלו היא מכריעה — עליה להודיע לצדדים ולאפשר להם לטעון.
> "An opinion should not range beyond the issues presented; it should address only the issues that need to be resolved to decide the case."
> — 1991, עמ' 17; 2020, עמ' 17
**יישום לוועדת ערר:** אם העורר העלה 8 טענות אבל 2 מכריעות — הדיון מתמקד ב-2. את השאר ניתן לציין בקצרה ("אין צורך להכריע בשאר הטענות" או "טענה זו נבחנה ונמצא כי אין בה ממש").
---
### B4. סוגיות שאינן נחוצות — מספיק להראות שנשקלו
**העיקרון:** סוגיות שאינן נחוצות להכרעה אך הצד המפסיד הציגן ברצינות — יש לדון בהן רק במידה הנדרשת כדי להראות שנשקלו. הקו בין מה שנחוץ למה שלא — לא תמיד ברור.
> "Issues not necessary to the decision but seriously urged by the losing party should be discussed only to the extent necessary to show that they have been considered."
> — 1991, עמ' 17; 2020, עמ' 17
**יישום לוועדת ערר:** טענה שהועלתה בכובד ראש אך אינה מכריעה — משפט עד פסקה. "טענה זו נבחנה על ידי הוועדה. נוכח מסקנתנו לעיל, אין צורך להכריע בה." או דיון קצר שמראה שהטענה נשקלה.
---
### B5. שיקולי יעילות — מתי לדון במה שלא חייבים
**העיקרון:** לפעמים שיקולי יעילות מצדיקים דיון בסוגיות שאינן נחוצות להכרעה — למשל, לתת הנחיות לערכאה הנמוכה בהחזרה. אך יש להיזהר מלהכריע בסוגיות שלא בפני הערכאה ומלתת חוות דעת מייעצות.
> "Considerations of economy and efficiency may argue in favor of addressing issues not necessary to the decision if the court can thereby provide useful guidance for the lower court on remand. In doing so, however, judges must be careful not to prejudge issues that are not before them and to avoid advisory opinions."
> — 1991, עמ' 17; 2020, עמ' 17
**יישום לוועדת ערר:** כשהערר מוחזר לוועדה המקומית — כדאי לתת הנחיות ברורות ("על הוועדה המקומית לבחון..." / "יש לשקול..."). אך לא להכריע בשאלות שלא נטענו.
---
### B6. הקדמת תקן הביקורת
**העיקרון:** ההחלטה צריכה לציין את תקן הביקורת (standard of review) בתחילת חלק הדיון. בלי זה — משמעות ההחלטה עלולה להיות עמומה. ציון התקן גם ממשמע את הניתוח.
> "The opinion should specify the controlling standard of review at the outset of the discussion of legal principles. Unless the reader is told whether review is under the de novo, the clearly erroneous, or the abuse of discretion standard, the meaning of the decision may be obscure."
> — 1991, עמ' 16; 2020, עמ' 16
**יישום לוועדת ערר:** בבלוק ט או תחילת בלוק י — ציון סמכות הוועדה ותקן הביקורת: "הוועדה רשאית להפעיל שיקול דעת עצמאי / הוועדה בוחנת את שיקול הדעת של הוועדה המקומית / ביקורת שיפוטית על שומה מכרעת" וכו'.
---
### B7. החזקות חלופיות — "גם אם" / "אף בהנחה"
**העיקרון:** ציון עילות נפרדות ועצמאיות להחלטה מחזק את ההחלטה אך מחליש את ערכה כתקדים. יש להימנע מ"גם אם" ו"בהנחת ארגומנדו" כי הם מערערים את סמכות ההחזקה. אלטרנטיבה: לטפל בעילה החלופית קודם ולציין את העילה העיקרית אחרונה.
> "Stating separate and independent grounds for a decision adds strength to the decision but diminishes its value as a precedent. Statements such as 'even if the facts were otherwise' or 'assuming arguendo that we had not concluded thus and so' undermine the authority of the holding."
> — 1991, עמ' 17; 2020, עמ' 17
> "Witkin suggests either limiting the 'even if' approach to situations where it is necessary to achieve a majority decision, or avoiding it completely by phrasing the opinion in such a manner that the alternative assumption is disposed of first and the substantial ground of the opinion stated last."
> — 1991, עמ' 17; 2020, עמ' 17
**יישום לוועדת ערר:** במקום לכתוב "גם אם היינו מקבלים את טענת העורר..." — עדיף לסדר את הדיון כך שהעילה המשנית נדונה קודם ונדחית, ואז העילה העיקרית מובאת כבסיס מוצק. אם בכל זאת משתמשים ב"אף בהנחה" — רק כשזה מחזק את ההחלטה משמעותית.
---
### B8. הניתוח לא יהיה קריפטי
**העיקרון:** אמנם תמציתיות רצויה, אבל השופט חייב לפרט את הנימוקים במידה מספקת כדי שהקורא יוכל לעקוב. החלטה שמדלגת על צעדים בנימוק — לא משיגה את מטרותיה.
> "While brevity is desirable, judges must elaborate their reasoning sufficiently so that the reader can follow. An opinion that omits steps in the reasoning essential to understanding will fail to serve its purposes."
> — 1991, עמ' 22; 2020, עמ' 22
**יישום לוועדת ערר:** בלוק י — כל מעבר מכלל לעובדה למסקנה צריך להיות מפורש. לא לכתוב "העובדות מלמדות כי הערר אינו מוצדק" בלי לפרט למה.
---
## C. טיפול בעובדות
### C1. רק עובדות הנחוצות להסברת ההחלטה
**העיקרון:** יש לכלול רק את העובדות הנחוצות להסברת ההחלטה. עם זאת, מה שנחוץ אינו תמיד מובן מאליו ותלוי בקהל היעד.
> "Only the facts that are necessary to explain the decision should be included, but what is necessary to explain the decision is not always obvious and may also vary depending on the audience."
> — 1991, עמ' 15; 2020, עמ' 15
**יישום לוועדת ערר:** בלוק ו — עובדות רלוונטיות בלבד. לא לפרט את כל תולדות המקרקעין אם רק עניין אחד רלוונטי. אבל "מבחן השופט" — לשופט שלא מכיר את התיק צריך לתת מספיק רקע.
---
### C2. פרטי עובדות מיותרים מסיחים דעת
**העיקרון:** פרטים עובדתיים מיותרים מסיחים דעת. תאריכים, למשל, נוטים לבלבל ואין לכלול אותם אלא אם הם מהותיים להחלטה.
> "Excessive factual detail can be distracting. Dates, for example, tend to confuse and should not be included unless material to the decision or helpful to its understanding."
> — 1991, עמ' 15; 2020, עמ' 15
**יישום לוועדת ערר:** בבלוק ו — לא לכתוב "ביום 15.3.2024 הגיש העורר בקשה, וביום 22.4.2024 הוועדה המקומית דנה, וביום 3.5.2024 ניתנה החלטה..." אלא אם הזמנים מהותיים (למשל, שאלת איחור).
---
### C3. עובדות הצד המפסיד — אסור להתעלם
**העיקרון:** תמציתיות ופשטות רצויים, אך הם משניים לצורך בהצגה מלאה והוגנת. אין להתעלם מעובדות משמעותיות שתומכות בצד המפסיד.
> "While brevity and simplicity are always desirable, they are secondary to the need for a full and fair statement. Facts significant to the losing side should not be ignored."
> — 1991, עמ' 15; 2020, עמ' 15
**יישום לוועדת ערר:** בבלוק ו — אם יש עובדה שתומכת בטענת העורר שנדחה, היא חייבת להופיע. רקע ניטרלי = כולל את הכול, לא רק את מה שתומך בתוצאה.
---
### C4. עובדות "צבעוניות" — סיכון
**העיקרון:** יש שופטים שאוהבים לכלול עובדות שאינן מהותיות אך מוסיפות צבע. הסכנה: הקורא עלול לחשוב שההחלטה מבוססת על עובדות אלה. גם הצדדים עלולים לראות בכך זלזול בתיק.
> "There is an obvious danger, however, that the reader may think the decision is based on these facts even though they are not material to the reasoning. Moreover, this style of writing — though appealing to the author — may be seen by the parties as trivializing the case."
> — 1991, עמ' 15; 2020, עמ' 15
**יישום לוועדת ערר:** בבלוק ו — לא לכלול פרטים "מעניינים" שאינם רלוונטיים. לא לתאר את נוף השכונה או היסטוריה שאינה נחוצה. כל עובדה שמופיעה — הקורא יניח שהיא רלוונטית להחלטה.
---
### C5. דיוק עובדתי — אין תחליף לבדיקת הרשומה
**העיקרון:** הצגת העובדות חייבת להיות מדויקת. אין להניח שעובדות כפי שמוצגות בכתבי הטענות נכונות. אין תחליף לבדיקה מול הרשומה.
> "Above all, the statement of facts must be accurate. The writer should not assume that the facts recited in the parties' briefs are stated correctly. There is no substitute for checking fact references against the record."
> — 1991, עמ' 15; 2020, עמ' 16
> "Misstating significant facts or authorities is a mark of carelessness and undermines the opinion's authority and integrity."
> — 1991, עמ' 1; 2020, עמ' 1
**יישום לוועדת ערר:** המערכת חייבת לוודא שעובדות בבלוק ו נלקחות מחומרי המקור (פרוטוקולים, תכניות, תצהירים) — לא מכתבי הטענות. שגיאה עובדתית = פגיעה בסמכות ההחלטה.
---
### C6. בתיקים רב-סוגייתיים — עובדות כלליות בהתחלה, ספציפיות בדיון
**העיקרון:** כשיש סדרת סוגיות ולא כל העובדות רלוונטיות לכולן, ניתן להגביל את תיאור העובדות ההתחלתי לרקע היסטורי נחוץ ולשלב עובדות ספציפיות בניתוח של כל סוגיה.
> "In such a case, the initial statement of facts may be limited to necessary historical background, leaving the specific decisional facts to be incorporated in the analysis of the issues on which they bear."
> — 1991, עמ' 15; 2020, עמ' 15
**יישום לוועדת ערר:** בלוק ו — רקע כללי (מיקום, תכנית רלוונטית, ההליך). בבלוק י — עובדות ספציפיות לכל סוגיה, עם הפניה לבלוק ו אם צריך. נמנעים מכפילות.
---
## D. ציטוטים ואזכורי פסיקה
### D1. אזכור מקרה אחד מספיק — לא מחרוזות
**העיקרון:** רוב הנקודות המשפטיות נתמכות היטב באזכור הפסק האחרון בעניין, או פסק-הדין הפורץ דרך. מחרוזות אזכורים ודיסרטציות על תולדות הכלל אינן מוסיפות כשהעניין מוסדר. יש להתנגד לפיתוי להרשים בלמדנות.
> "Most points of law are adequately supported by citation of the latest decision on point in the court's circuit or the watershed case, if there is one. String citations and dissertations on the history of the rule add nothing when the matter is settled."
> — 1991, עמ' 17; 2020, עמ' 18
> "Judges should resist the temptation of trying to impress people with their (or their law clerks') erudition."
> — 1991, עמ' 17; 2020, עמ' 18
**יישום לוועדת ערר:** לא לכתוב "ראו: עע"מ X; עע"מ Y; עע"מ Z; עת"מ A; עת"מ B" כשמספיק פסק אחד מנחה. מחרוזת אזכורים → מיותרת ומעמיסה. אזכור אחד + ציטוט רלוונטי = מספיק.
---
### D2. פריצת דרך — כן לסקור את המקורות
**העיקרון:** כאשר ההחלטה פורצת דרך חדשה, יש למרשל את המקורות הקיימים ולנתח את התפתחות הדין כדי לתמוך בכלל החדש.
> "If an opinion breaks new ground, however, the court should marshal existing authority and analyze the evolution of the law sufficiently to support the new rule."
> — 1991, עמ' 17; 2020, עמ' 18
**יישום לוועדת ערר:** כשהוועדה קובעת עמדה חדשה (למשל, פרשנות חדשה של סעיף בחוק) — יש לסקור את ההתפתחות בפסיקה ולהראות איך העמדה החדשה נגזרת מהדין הקיים.
---
### D3. מקורות משניים — במשורה ולמטרה
**העיקרון:** מקורות משניים (מאמרים, ספרים, מקורות לא-משפטיים) אינם סמכות ראשית ויש לאזכר אותם במשורה ורק לתכלית ברורה: הפניה לניתוח תומך, סמכות מוכרת בתחום, או שפיכת אור על שיקולי מדיניות.
> "Because law review articles, treatises, texts, and non-legal sources are not primary authority, they should be cited sparingly and only to serve a purpose."
> — 1991, עמ' 18; 2020, עמ' 18
**יישום לוועדת ערר:** ספרות תכנון, חוות דעת מומחים, מסמכי מדיניות — ניתן לאזכר אך רק כשתורמים ממשית לנימוק, לא כעיטור.
---
### D4. ציטוטים — קצרים, הוגנים, רק כשהם חשובים
**העיקרון:** אם משהו חשוב נאמר היטב לפני כן — ציטוט רלוונטי יכול להיות משכנע יותר מפרפרזה. אך ההשפעה של ציטוט יחס הפוך לאורכו. יש לצטט בקצרה, ורק כשהניסוח עושה נקודה חשובה. הציטוט חייב להיות הוגן — בהקשר ומשקף נאמנה את המקור.
> "If something important to the opinion has been said well before, quoting relevant language from a case on point can be more persuasive and informative than merely citing or paraphrasing it. The impact of a quote, however, is inversely proportional to its length. Quote briefly, and only when the language makes an important point."
> — 1991, עמ' 18; 2020, עמ' 18
> "While quotes should be short, they must also be fair. They must be in context and accurately reflect the tenor of their source."
> — 1991, עמ' 18; 2020, עמ' 18
**יישום לוועדת ערר:** לא להביא פסקאות שלמות מפסקי דין. ציטוט = 1-2 משפטים לכל היותר, ורק כשהניסוח המקורי חשוב (כלל מנחה, אמירה מכוננת). תמיד לוודא שהציטוט בהקשרו.
---
### D5. הערות שוליים — רק למידע שמפריע לזרימה
**העיקרון:** מטרת הערת שוליים היא להעביר מידע שיפריע לזרימת ההחלטה אם יכלל בטקסט. השאלה הראשונה: האם התוכן מוצדק בכלל. אם הוא לא חשוב מספיק לטקסט — צריכה להיות סיבה טובה לכלול אותו בהערה. הערות שוליים לא צריכות להיות מאגר של מידע שהכותב לא יודע מה לעשות איתו.
> "The first question to ask about a prospective footnote is whether its content is appropriate for inclusion in the opinion. If it is not important enough to go into the text, the writer must have some justification for including it in the opinion at all."
> — 1991, עמ' 24; 2020, עמ' 24
> "Footnotes should not be inserted for the writer's gratification or as a repository for information that the writer does not know what to do with."
> — 1991, עמ' 24
**יישום לוועדת ערר:** הערות שוליים רק לטקסט חקיקה, פרטי רקע נחוצים אך לא-מרכזיים, או דחיית טענה צדדית בקצרה. לא מאגר לחומר "מעניין".
---
## E. טיפול בצד המפסיד
### E1. דיון מספיק כדי להראות שהטענות נשקלו
**העיקרון:** השופט חייב להתמודד עם סמכות נוגדת לכאורה ועם טענות נגדיות. עליו להתעמת עם הסוגיות ישירות ובכנות. ההחלטה לא צריכה להתייחס לכל תיק וטענה, אך הדיון חייב להספיק כדי להדגים לצד המפסיד שהיסודות של עמדתו נשקלו במלואם.
> "The judge must deal with arguably contrary authority and opposing argument, and must confront the issues squarely and deal with them forthrightly. Although the opinion need not address every case and contention, the discussion must be sufficient to demonstrate to the losing party that the essentials of its position have been fully considered."
> — 1991, עמ' 16; 2020, עמ' 16
**יישום לוועדת ערר:** זהו עיקרון מפתח. כשהערר נדחה — הדיון חייב להראות שהוועדה הבינה את הטענה המרכזית וענתה עליה. לא צריך לענות על כל נקודה, אבל הטענה העיקרית של הצד המפסיד חייבת לקבל מענה מנומק.
---
### E2. לא להפוך לוויכוח עם עורכי הדין
**העיקרון:** בהתייחסות לטענות הצד המפסיד, ההחלטה לא צריכה להפוך לוויכוח בין השופט לעורכי הדין. אם הוצגו טענות מהותיות — יש להסביר למה נדחו. אבל אין צורך להפריך את טענות הצד המפסיד נקודה בנקודה או לאמץ טון עוין.
> "An opinion should not become an argument between the judge and the lawyers, or other judges on the court, or the court below. If the losing side has raised substantial contentions, the opinion should explain why they were rejected. But it need not refute the losing party's arguments point by point or adopt a contentious or adversarial tone."
> — 1991, עמ' 18; 2020, עמ' 18-19
**יישום לוועדת ערר:** הדיון לא מתנהל כ"תשובה לכתב הערר". הוועדה מנתחת את השאלה — לא מתווכחת עם הטוען. במקום "טענת העורר כי X — שגויה מיסודה" → "לאחר בחינת הסוגיה נמצא כי Y, ועל כן אין לקבל את הטענה".
---
### E3. הרשעה בלי להיות טרקט
**העיקרון:** החלטה יכולה — וצריכה — לשדר שכנוע בלי להפוך לחוברת. יש להניח בצד רגשות ותחושות אישיות, ולהימנע משימוש בשמות תואר ותארי פועל אלא אם הם מעבירים מידע מהותי.
> "An opinion can — and properly should — carry conviction without becoming a tract. Put aside emotion and personal feelings, and avoid using adjectives and adverbs unless they convey information material to the decision."
> — 1991, עמ' 18-19; 2020, עמ' 19
**יישום לוועדת ערר:** לא "בבירור" / "ללא ספק" / "ברי כי" אלא אם מדובר בעניין שבאמת ברור. הטון של דפנה — מקצועי, מרוסן, בטוח אך לא פומפוזי.
---
### E4. התייחסות לערכאה הנמוכה — ללא ביקורת מיותרת
**העיקרון:** ניתן ונדרש לתקן שגיאות של הערכאה הנמוכה, אך ללא ביקורת מיותרת, ללא תקיפת שיקול דעתה או גישתה, וללא ייחוס מניעים לא ראויים.
> "Appellate opinions can and should correct trial court errors and provide guidance on remand without embroidering on the circumstances or criticizing the court below. An appellate opinion need not attack a trial court's wisdom, judgment, or even its attitude in order to reverse its decision."
> — 1991, עמ' 19; 2020, עמ' 19
**יישום לוועדת ערר:** כשהערר מתקבל = הוועדה המקומית טעתה. אבל הנימוק צריך להתמקד ב"מה צריך להיות" — לא ב"כמה טעתה הוועדה המקומית". ללא ביטויים כמו "באופן מפתיע" / "למרבה הפליאה".
---
## F. ניסוח התוצאה / המסקנה
### F1. התוצאה היא החלק הכי חשוב
**העיקרון:** התוצאה האופרטיבית — וההוראות לערכאה הנמוכה או לגורם המנהלי — היא החלק הכי חשוב בפסקת הסיום.
> "Disposition of a case — and the mandate to the lower court or agency, when that is a part of the disposition — is the most important part of the conclusion."
> — 1991, עמ' 19; 2020, עמ' 19
**יישום לוועדת ערר:** בלוקים יא-יב — חייבים להיות ברורים ואופרטיביים. "הערר נדחה" / "הערר מתקבל" / "הערר מתקבל בחלקו". בהחזרה — הוראות מפורטות.
---
### F2. לא לדבר בחידות
**העיקרון:** אין לדבר בחידות. להחזיר תיק "להליכים נוספים בהתאם להחלטה זו" עלול להותיר את הערכאה הנמוכה בים. ההחלטה חייבת לפרט בבירור מה צפוי מהם — מבלי לפלוש לשיקול הדעת שנותר בידיהם.
> "Appellate courts should not speak in riddles. Simply to remand a case 'for further proceedings consistent with the opinion' may leave the court below at sea. Opinions must spell out clearly what the lower courts or agencies are expected to do without, however, trespassing on what remains entrusted to their discretion."
> — 1991, עמ' 19; 2020, עמ' 19
**יישום לוועדת ערר:** במקום "הערר מוחזר לדיון מחדש" → "הערר מוחזר לוועדה המקומית לצורך בחינה מחדש של [X] בהתאם לתכנית [Y], תוך מתן הזדמנות שימוע לעורר ובהתחשב ב[Z]." הוראות ספציפיות ואופרטיביות.
---
### F3. גם כשנמצא שימוש לרעה בשיקול דעת — הסמכות נשארת
**העיקרון:** גם כשנמצא שימוש לרעה בשיקול דעת, החלטת ערכאת הערעור היא בשאלת הדין. הערכאה הנמוכה או הגוף המנהלי בהחזרה שומרים על סמכותם להפעיל שיקול דעת כראוי.
> "Even where an abuse of discretion is found, the appellate court's decision is on the law, and the lower court or agency on remand retains the authority to exercise its discretion properly."
> — 1991, עמ' 19; 2020, עמ' 19
**יישום לוועדת ערר:** כשהוועדה המקומית לא שקלה שיקול רלוונטי — הערר מוחזר כדי שתשקול אותו. אין לכפות תוצאה ספציפית (אלא אם הדין מחייב).
---
## G. שפה, סגנון, עריכה עצמית
### G1. שלוש בעיות עיקריות — יתירות, חוסר דיוק, ארגון גרוע
**העיקרון:** הבעיות העיקריות בכתיבה שיפוטית: (א) יתירות — לא רק שימוש בשתי מילים כשמספיקה אחת, אלא ניסיון להעביר יותר מדי מידע, לכסות יותר מדי סוגיות, ופשוט לכתוב יותר מדי; (ב) חוסר דיוק ובהירות; (ג) ארגון גרוע.
> "Wordiness means not just verbosity — using two words when one will do — but trying to convey too much information, covering too many issues, and simply writing too much."
> — 1991, עמ' 21; 2020, עמ' 21
> "Often wordiness reflects the writer's failure (or inability) to separate the material from the immaterial and do the grubby work of editing."
> — 1991, עמ' 21; 2020, עמ' 21
**יישום לוועדת ערר:** עריכה קפדנית של כל בלוק. אם משפט לא מקדם את הנימוק — למחוק. אם סוגיה לא נחוצה — לקצר או להסיר.
---
### G2. דיוק — המטרה המרכזית
**העיקרון:** דיוק הוא המטרה המרכזית של כתיבה טובה. כדי לכתוב בבהירות ודיוק — הכותב חייב לדעת בדיוק מה הוא רוצה לומר, ולומר את זה ותו לא. שופטים כותבים לנצח — ברגע שהחלטה מוגשת, עורכי דין יקראו אותה עם עין למה שישרת את מטרתם.
> "To write with clarity and precision, the writer must know precisely what he or she wants to say and must say that and nothing else."
> — 1991, עמ' 21; 2020, עמ' 21
> "Precision in judicial writing is important not simply as a matter of style but also because judges write for posterity. Once an opinion is filed, lawyers and others will read it with an eye to how they can use it to serve their particular purpose."
> — 1991, עמ' 21; 2020, עמ' 21
**יישום לוועדת ערר:** כל משפט — "האם אמרתי בדיוק מה שרציתי? האם ניתן לקרוא את זה אחרת ממה שהתכוונתי?" מיוחד חשוב בהחלטות שקובעות תקדים.
---
### G3. השמטת מילים מיותרות — עיקרון סטרנק
**העיקרון:** כתיבה עזה היא תמציתית. כל מילה צריכה לעבוד.
> "Vigorous writing is concise. A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts. This requires not that the writer make all his sentences short, or that he avoid all detail and treat his subjects only in outline, but that every word tell."
> — Strunk & White, מצוטט ב-1991, עמ' 22-23; 2020, עמ' 22-23
**יישום לוועדת ערר:** בעריכה — לסמן כל מילה ולשאול: "האם היא נחוצה?" לא "קצר" — אלא "כל מילה עובדת". זהו הכלל המרכזי לסגנון דפנה.
---
### G4. תמציתיות ועמידה בנקודה
**העיקרון:** תמציתיות מקדמת בהירות. כתיבה שמגיעה לנקודה בקצרה — מובנת יותר. יש להשתמש במשפטים פשוטים ודקלרטיביים ובפסקאות קצרות, אך לגוון את אורך המשפט ומבנהו לצורכי הדגשה וניגוד. יש להעדיף לשון פעילה ולהימנע מבניות כמו "נטען כי", "הוטען כי".
> "Use simple, declarative sentences and short paragraphs most of the time, but vary sentence length and structure where necessary for emphasis, contrast, and reader interest. Prefer the active voice and avoid constructions such as 'it is said,' 'it is argued,' and 'it is well founded.'"
> — 1991, עמ' 23; 2020, עמ' 23
> "Weed out adjectives and eliminate adverbs such as 'clearly,' 'plainly,' and 'merely.'"
> — 1991, עמ' 23; 2020, עמ' 23
**יישום לוועדת ערר:** לא "נטען על-ידי העורר כי הוועדה המקומית טעתה" → "העורר טוען כי הוועדה המקומית טעתה". לא "ברי כי" / "מובן מאליו כי" — אם זה ברור, לא צריך לומר שזה ברור.
---
### G5. שפה פשוטה — אנגלית/עברית רגילה
**העיקרון:** אפילו רעיונות מורכבים ניתנים לביטוי בשפה פשוטה. יש להימנע מ"לשון משפטית", קלישאות, ביטויים שחוקים, ביטויים לטיניים, וז'רגון. כשמשתמשים במונחי מקצוע — לבדוק אם הם מובנים לקהל או דורשים הגדרה.
> "Even complex ideas can be expressed in simple language understandable by the general reader. To write in simple language requires that the writer understand the idea fully, enabling him or her to break it down into its essential components."
> — 1991, עמ' 23; 2020, עמ' 23
> "Avoid 'legalese,' clichés, hackneyed phrases ('as hereinabove set forth,' for example), Latin expressions ('vel non,' for example), and jargon."
> — 1991, עמ' 23; 2020, עמ' 23
**יישום לוועדת ערר:** לא "כדרישת הדין ולפיו" / "לאמור לעיל" / "כאמור" (מיותר). עברית פשוטה ובהירה. מונח תכנוני — להגדיר אם לא ברור ("תכנית בניין עיר" לא "תב"ע" ללא הגדרה ראשונית).
---
### G6. פומפוזיות — להימנע
**העיקרון:** כתיבה שיפוטית עלולה להיות פומפוזית. השופט חייב להיזהר: ביטויים ארכאיים או מליציים, שימוש ב"אנו" הקיסרי על-ידי שופט יחיד, סטיות ללמדנות שאינה רלוונטית.
> "The judge must be vigilant for evidence of pomposity, such as arcane or florid expressions, use of the imperial 'we' by a single district judge, or excursions into irrelevant erudition."
> — 1991, עמ' 22; 2020, עמ' 22
**יישום לוועדת ערר:** הוועדה = "הוועדה", לא "אנו סבורים" (אם יו"ר יחיד כותב). לא "למותר לציין כי" / "מן המפורסמות הוא כי". טון סמכותי אך פשוט.
---
### G7. הומור — סיכון שלא כדאי לקחת
**העיקרון:** הומור עובד טוב יותר בנאום מאשר בהחלטה. בעלי הדין — שלא סביר שיראו משהו מצחיק בהתדיינות — עלולים לראות בו סימן ליהירות וחוסר רגישות.
> "Although humor is sometimes rationalized as an antidote to pomposity, it works better in after-dinner speeches than in judicial opinions. In the latter it may strike the litigants — who are not likely to see anything funny in the litigation — as a sign of judicial arrogance and lack of sensitivity."
> — 1991, עמ' 22; 2020, עמ' 22
**יישום לוועדת ערר:** לא הומור, לא אירוניה, לא ציניות בהחלטות. גם אם הטענה נראית מגוחכת — להתייחס בכבוד.
---
### G8. עריכה — לא רק שפה, גם תוכן ומבנה
**העיקרון:** בעריכה, השופט צריך לבדוק: (א) עקביות פנימית; (ב) האם המבוא מכסה את כל הסוגיות; (ג) האם העובדות מכסות את כל מה שנחוץ להחלטה ולא יותר; (ד) האם הדיון מתייחס בסדר לוגי לכל הסוגיות; (ה) האם המסקנה נובעת מהדיון.
> "Judges must check for internal consistency. Go back to the introduction to see whether the opinion has addressed all of the issues and answered the questions as they were initially formulated. Reread the statement of facts to see whether it covers all the facts significant to the decision and no more. Review the legal discussion to see whether the opinion has addressed in logical order the issues that need to be addressed. Consider whether the conclusion follows from the discussion."
> — 1991, עמ' 25; 2020, עמ' 25-26
**יישום לוועדת ערר:** צ'קליסט עריכה אוטומטי: (1) עקביות בלוק א ↔ בלוק יב; (2) כל עובדה בבלוק ו מופיעה בדיון?; (3) סדר הסוגיות לוגי?; (4) המסקנה נובעת מהניתוח?
---
### G9. הנחת הטיוטה בצד ושיבה אליה
**העיקרון:** שיפור העריכה — על-ידי הנחת הטיוטה בצד ושיבה אליה מאוחר יותר. גם עיכוב של ימים ספורים מאפשר מבט אובייקטיבי יותר, תובנות חדשות, ורעיונות חדשים.
> "Although time constraints and mounting caseloads may make it difficult, delaying editing the opinion for even a few days may help the judge review things more objectively, gain new insights, and think of new ideas."
> — 1991, עמ' 25; 2020, עמ' 26
**יישום לוועדת ערר:** בתהליך העבודה עם המערכת — שלב "צינון" לפני עריכה סופית. הטיוטה נשמרת, יו"ר הוועדה חוזרת אליה לאחר זמן.
---
### G10. עריכה משפט-משפט
**העיקרון:** עריכה מדוקדקת ומהורהרת חיונית לכתיבה מדויקת. זה אומר לעבור על ההחלטה משפט אחרי משפט ולשאול: מה התכוונתי לומר כאן, והאם אמרתי את זה ולא יותר?
> "Painstaking and thoughtful editing is essential for precise writing. This means going over the opinion, sentence by sentence, and asking: What do I mean to say here, and have I said it and no more?"
> — 1991, עמ' 21-22; 2020, עמ' 21
**יישום לוועדת ערר:** כל בלוק — עריכה ברמת המשפט. כל משפט עומד בפני עצמו ומוסיף מידע חדש או נקודה חדשה.
---
## H. חידושים ייחודיים למהדורה השנייה (2020)
### H1. התייחסות לעידן הדיגיטלי
**העיקרון:** המהדורה השנייה מציינת שהחלטות שיפוטיות נקראות יותר ויותר בפורמט דיגיטלי, ולכן הבהירות חשובה אף יותר.
> "With so much of today's writing embedded in the truncated protocols of social media and other 'real time' forms of expression, the clarity and persuasive quality the authors of the first edition sought to teach are particularly important for judges' writing."
> — 2020, Foreword, עמ' ix
**יישום לוועדת ערר:** ההחלטות מתפרסמות באתר הוועדה ובמאגרי מידע — מותאמות לקריאה דיגיטלית. כותרות, מבנה, פסקאות קצרות.
---
### H2. ציטוט מ-Bryan Garner על שפה משפטית
**העיקרון:** המהדורה השנייה מוסיפה ציטוט מ-Garner על הימנעות מביטויים משפטיים מסורתיים:
> "[N]ever assume that traditional legal expressions are legally necessary. As often as not they are scars left by the law's verbal elephantiasis, which only lately has started into remission. Use words and phrases that you know to be both precise and as widely understood as possible."
> — Bryan Garner, מצוטט ב-2020, עמ' 23-24
**יישום לוועדת ערר:** ביטויים כמו "בכבוד רב", "מן הראוי", "למיטב הבנתנו" — לא "נחוצים משפטית". להחליף בשפה פשוטה ומדויקת.
---
### H3. מודעות לפרסום בלתי נשלט
**העיקרון:** המהדורה השנייה מוסיפה אזהרה שמפרסמים משפטיים (כמו Westlaw) מפרסמים לפעמים החלטות שסומנו כ"לא לפרסום" — על סמך שיקול דעתם שלהם.
> "Some legal publishers, including Westlaw, put certain district court orders and opinions on line whether or not the judge designates them for publication and even sometimes when a judge states that the order or opinion is 'not for publication.'"
> — 2020, עמ' 7
**יישום לוועדת ערר:** כל החלטה של ועדת הערר עלולה להתפרסם ולשמש תקדים — גם אם לא תוכננה לכך. יש לכתוב כל החלטה כאילו תפורסם.
---
### H4. הדגשת ניתוח קריפטי כבעיה נפרדת
**העיקרון:** המהדורה השנייה מבנה את "ניתוח קריפטי" כבעיה נפרדת (לא רק תת-סעיף) — מה שמדגיש את חשיבות פירוט הנימוקים.
**יישום לוועדת ערר:** בלוק י — כל צעד בנימוק חייב להיות מפורש. אסור "לדלג" מכלל למסקנה בלי ליישם על העובדות.
---
### H5. מבנה מעודכן — "Editing the Opinion" כפרק נפרד
**העיקרון:** במהדורה הראשונה, שפה/סגנון/עריכה היו פרק אחד. במהדורה השנייה, "Editing" הוא פרק נפרד (V), מה שמדגיש את חשיבות העריכה כתהליך עצמאי ולא כחלק מהכתיבה.
**יישום לוועדת ערר:** בתהליך העבודה — שלב עריכה מוגדר, נפרד מהכתיבה. המערכת מפעילה צ'קליסט עריכה אוטומטי אחרי יצירת הטיוטה.
---
### H6. הפניה ל-Aldisert על חשיבה לוגית לפני כתיבה
**העיקרון:** המהדורה השנייה מוסיפה ציטוט של שופט Aldisert:
> "If a judge wants to write clearly and cogently, with words parading before the reader in logical order, the judge must first think clearly and cogently, with thoughts laid out in neat rows."
> — Aldisert, Opinion Writing (2d ed. 2009), מצוטט ב-2020, עמ' 9
**יישום לוועדת ערר:** לפני שהמערכת כותבת — שלב "תכנון" חובה: מה התוצאה? מה הנימוקים? באיזה סדר? רק אחר-כך — כתיבה.
---
## סיכום כללי — עקרונות-על
1. **ההחלטה קיימת כדי להסביר ולשכנע** — לא רק להכריע, אלא להראות שההכרעה מבוססת, הוגנת, ומנומקת.
2. **כל מילה צריכה לעבוד** — תמציתיות היא לא קיצור אלא הסרת המיותר.
3. **הצד המפסיד צריך לראות שהוא נשמע** — הדיון חייב להדגים שהטענות המרכזיות נשקלו.
4. **דיוק הוא הדבר החשוב ביותר** — כל משפט נקרא לנצח וייקרא בדרכים שלא ציפית.
5. **מבנה ברור = חשיבה ברורה** — כותרות, סדר לוגי, וחמישה אלמנטים.
6. **לא סנגוריה** — ההחלטה משכנעת בכוח הנימוק, לא בטון.
7. **עובדות מדויקות והוגנות** — כולל עובדות שתומכות בצד המפסיד.
8. **ציטוטים קצרים, אזכורים מועטים** — אחד טוב > עשרה מיותרים.
9. **הוראות אופרטיביות ברורות** — לא חידות, לא עמימות.
10. **כתוב אחרון — ערוך ראשון** — המבוא נכתב אחרי הדיון; העריכה חשובה כמו הכתיבה.

View File

@@ -1,625 +0,0 @@
# עקרונות כתיבת החלטות מעין-שיפוטיות — מיצוי מספרי גארנר
מסמך מתודולוגי המבוסס על שני ספרים:
1. **Making Your Case: The Art of Persuading Judges** (Scalia & Garner, 2008)
2. **Legal Writing in Plain English** (Garner, 2001)
> **הערה חשובה**: "Making Your Case" נכתב עבור עורכי דין טוענים, לא שופטים. העקרונות כאן מותאמים לכתיבת החלטות — לא לטיעון תיק.
---
## א. חשיבה משפטית והנמקה (Making Your Case, פרקים 2227)
### א.1 חשיבה סילוגיסטית — מבנה כל טיעון משפטי
**עיקרון**: כל הנמקה משפטית חייבת להיבנות כסילוגיזם: הנחה עליונה (כלל משפטי) → הנחה תחתונה (עובדות המקרה) → מסקנה.
> "Leaving aside emotional appeals, persuasion is possible only because all human beings are born with a capacity for logical thought... The most rigorous form of logic, and hence the most persuasive, is the syllogism." (MYC §22)
> "If the major premise (the controlling rule) and the minor premise (the facts invoking that rule) are true... the conclusion follows inevitably." (MYC §22)
**יישום להחלטות ועדת ערר**: כל סוגיה בבלוק י (דיון) חייבת להיבנות כך:
- הנחה עליונה: הכלל התכנוני/המשפטי (סעיף בתוכנית, פסיקה, עקרון תכנוני)
- הנחה תחתונה: העובדות הספציפיות של הערר
- מסקנה: התוצאה לגבי סוגיה זו
**עיקרון משנה — שלושה מקורות להנחה עליונה**:
> "Legal argument generally has three sources of major premises: a text (constitution, statute, regulation, ordinance, or contract), precedent (caselaw, etc.), and policy (i.e., consequences of the decision)." (MYC §22)
**יישום**: בעררי תכנון, המקורות הם:
- טקסט: הוראות התוכנית, חוק התכנון והבניה, תקנות
- תקדים: החלטות ועדות ערר קודמות, פסיקת בתי משפט
- מדיניות: שיקולים תכנוניים (צפיפות, אופי הסביבה, אינטרס ציבורי)
**עיקרון משנה — ההנחה התחתונה היא המפתח**:
> "There is much to be said for the proposition that 'legal reasoning revolves mainly around the establishment of the minor premise.'" (MYC §22)
**יישום**: ברוב העררים, הכלל המשפטי אינו שנוי במחלוקת — השאלה היא כיצד העובדות משתלבות בכלל. ההחלטה חייבת להראות בפירוט כיצד העובדות הספציפיות מקיימות או אינן מקיימות את תנאי הכלל.
### א.2 פרשנות טקסטואלית — ניתוח הוראות תוכנית
**עיקרון ראשי**: לפני כל מסקנה לגבי משמעות טקסט — קרא את המסמך כולו.
> "Paramount rule: Before coming to any conclusion about the meaning of a text, read the entire document, not just the particular provision at issue. The court will be seeking to give an ambiguous word or phrase meaning in the context of the document in which it appears." (MYC §23)
**כללי פרשנות שיש לאמץ**:
> "Words are presumed to bear their ordinary meanings." (MYC §23)
> "Without some contrary indication, a word or phrase is presumed to have the same meaning throughout a document." (MYC §23)
> "The provisions of a document should be interpreted in a way that renders them harmonious, not contradictory." (MYC §23)
> "If possible, every word should be given effect; no word should be read as surplusage." (MYC §23)
**יישום**: כשההחלטה מפרשת הוראת תוכנית:
1. הצג את לשון ההוראה המלאה
2. פרש מילים במשמעותן הרגילה
3. בדוק עקביות עם הוראות אחרות באותה תוכנית
4. תן תוקף לכל מילה — אל תתעלם ממילים "מיותרות"
5. אם יש עמימות — השתמש בכלים הקאנוניים (הכלל הכללי מצטמצם לאור הפרט; מילה מתפרשת על פי הקשרה)
**כלים קאנוניים לפרשנות** (MYC §23):
- **Inclusio unius**: הכללת דבר אחד מרמזת על הדרת אחרים
- **Noscitur a sociis**: מילה מתפרשת לאור המילים הסמוכות לה
- **Ejusdem generis**: קטגוריה כללית שבאה אחרי רשימה מתייחסת לפריטים מאותו סוג
### א.3 התחל תמיד מלשון הטקסט
**עיקרון**: כשהמקרה נשלט על ידי טקסט משפטי — התחל תמיד מהמילים.
> "In cases controlled by governing legal texts, always begin with the words of the text to establish the major premise." (MYC §24)
**יישום**: בלוק י חייב לפתוח כל דיון בסוגיה בציטוט ישיר של ההוראה הרלוונטית מהתוכנית/חוק, ורק אז לעבור לניתוח ויישום על העובדות.
### א.4 משקל תקדימים — היררכיה ברורה
**עיקרון**: לסמכויות משפטיות שונות יש משקל שונה, וחובה להכיר בהיררכיה.
> "From a juridical point of view, case authorities are of two sorts: those that are governing (either directly or by implication) and those that are persuasive." (MYC §26)
> "Governing authorities are more significant and should occupy more of your attention." (MYC §26)
**היררכיה בעררי תכנון** (לפי סדר יורד של משקל):
1. פסיקת בית המשפט העליון
2. פסיקת בית משפט לעניינים מנהליים (שנותן ביקורת שיפוטית ישירה)
3. החלטות ועדת ערר ארצית
4. החלטות ועדות ערר מחוזיות אחרות
5. ספרות משפטית/תכנונית
**עיקרון משנה — עדיפות לתקדים עדכני**:
> "At least where opinions of governing courts are concerned, the more recent the citation the better. The judge wants to know whether the judgment you seek will be affirmed by the current court, not whether it would have been affirmed 30 years ago." (MYC §26)
### א.5 מצא ניסוח מפורש להנחה העליונה
**עיקרון**: אם אפשר, ציין בדיוק מהי ההנחה העליונה תוך ציטוט ישיר מסמכות מחייבת.
> "It is often quite easy to find a governing case with a passage that says precisely what you want your major premise to be." (MYC §27)
> "When direct quotation is not possible, set forth the major premise in your own words, supported by citation of a case from a governing court." (MYC §27)
**יישום**: בפתיחת דיון בכל סוגיה, ההנחה העליונה צריכה להופיע בצורה ברורה — אם אפשר כציטוט ישיר מפסק דין או מהוראת חוק/תוכנית.
---
## ב. מבנה וארגון (משני הספרים)
### ב.1 הצגת המסקנה מראש (Front-loading)
**עיקרון**: התחל תמיד בהצגת הסוגיה המרכזית לפני שמפרט עובדות.
> "Always start with a statement of the main issue before fully stating the facts." (MYC §14)
> "The facts one reads seem random and meaningless until one knows what they pertain to." (MYC §14)
> "The greatest mistake a lawyer can make either in briefing or oral argument is to keep the court in the dark as to what the case is about until after a lengthy discussion of dates, testimony of witnesses, legal authorities, and the like." (MYC §14, ציטוט השופט McAmis)
**עיקרון משלים מ-Legal Writing in Plain English**:
> "Virtually all analytical or persuasive writing should have a summary on page one—a true summary that capsulizes the upshot of the message. This upshot inevitably consists of three parts: the question, the answer, and the reasons." (LWPE §22)
**יישום**: בלוק א (כותרת) ובלוק ב (סיכום מנהלי) חייבים לגלות מיד את מהות הערר ואת התוצאה. הקורא לא צריך לקרוא 10 עמודים כדי להבין במה מדובר.
### ב.2 טכניקת ה-"Deep Issue" — סילוגיזם בשאלה
**עיקרון**: נסח את הסוגיה בצורת סילוגיזם מכווץ — עד 75 מילים, במספר משפטים.
> "The most persuasive form of an issue statement—the so-called deep issue—contains within it the syllogism that produces your desired conclusion." (MYC §36)
> "The better strategy is to break up the question into separate sentences totaling no more than 75 words. The first sentences follow a chronological order, telling a story in miniature. Then, emerging inevitably from the story, the pointed question comes at the end." (MYC §36)
**דוגמה מהספר**: במקום "האם דו"ח חקירת האירוע הפר כללי OSHA?" — כתוב:
> "כללי OSHA דורשים שכל דו"ח חקירת אירוע יכלול רשימת גורמים תורמים. הדו"ח על הפיצוץ במפעל פירט את הגורמים התורמים לא בגוף הדו"ח אלא בנספח נפרד. האם הדו"ח הפר את כללי OSHA?"
**יישום**: בלוק ב (סיכום מנהלי) צריך לנסח כל סוגיה בדרך זו — הנחה משפטית, עובדות תמציתיות, שאלה חדה.
### ב.3 שלושה חלקים: פתיחה, גוף, סיכום
**עיקרון**: כל כתיבה אנליטית חייבת שלושה חלקים — ורוב הכתיבה המשפטית מזניחה את הפתיחה והסיכום.
> "Virtually all expository writing should have three parts: an introduction, a main body, and a conclusion. You'd think everyone knows this. Not so: the orthodox method of brief-writing, and the way of many research memos, is to give only one part—a middle." (LWPE §21)
> "The conclusion should briefly sum up the argument. If you're writing as an advocate, you'll need to show clearly what the decision-maker should do and why." (LWPE §21)
**יישום**: ההחלטה חייבת פתיחה (בלוקים א–ב), גוף (בלוקים ג–י), וסיכום (בלוקים יא–יב). הסיכום אינו "לאור כל האמור לעיל" אלא חזרה תמציתית ורעננה על עיקרי ההנמקה.
### ב.4 סדר הסוגיות — החזק מתחיל
**עיקרון**: אם ההיגיון מאפשר — פתח בטיעון החזק ביותר.
> "If possible, lead with your strongest argument." (MYC §7)
> "Why? Because first impressions are indelible. Because when the first taste is bad, one is not eager to drink further. Because judicial attention will be highest at the outset." (MYC §7)
**חריג חשוב**: כשההיגיון דורש סדר אחר (למשל, שאלת סמכות לפני דיון בגוף)
> "Sometimes, of course, the imperatives of logical exposition demand that you first discuss a point that is not your strongest." (MYC §7)
**יישום**: בבלוק י, סדר הסוגיות צריך להיקבע לפי:
1. שאלות סף (סמכות, מועד) — תמיד ראשונות
2. הסוגיה המרכזית — מיד אחריהן
3. סוגיות משניות — לפי חוזק ההנמקה
### ב.5 כותרות אינפורמטיביות
**עיקרון**: השתמש בכותרות שהן משפטים מלאים המודיעים לא רק על הנושא אלא גם על העמדה.
> "Headings are most effective if they're full sentences announcing not just the topic but your position on the topic: Not 'I. Statute of Limitations' but 'I. The statute of limitations was tolled while the plaintiff suffered from amnesia.'" (MYC §40)
> "State and federal judges routinely emphasize this point at judicial-writing seminars. They say that headings and subheadings help them keep their bearings, let them actually see the organization, and afford them mental rest stops." (LWPE §4)
**יישום**: כל כותרת סעיף בהחלטה צריכה להודיע על המסקנה, לא רק על הנושא:
- לא: "סוגיית הבנייה בקו אפס"
- כן: "הבנייה בקו אפס אינה עולה בקנה אחד עם תוכנית המתאר"
### ב.6 פסקת מפה (Roadmap Paragraph)
**עיקרון**: ספק שלטי דרך ברורים — אמור מראש כמה נקודות יש ומה הן.
> "If there are three issues you're going to discuss, state them explicitly on page one. If there are four advantages to your recommended course of action, say so when introducing the list. And be specific: don't say that there are 'several' advantages. If there are four, say so." (LWPE §27)
**יישום**: בפתיחת בלוק י, כתוב: "הסוגיות שיש לדון בהן הן שלוש: (1) ...; (2) ...; (3) ...". זה מכין את הקורא ומאפשר לו לעקוב.
### ב.7 חלק וכבוש — חלוקה לסעיפים
**עיקרון**: חלק את המסמך לסעיפים ותתי-סעיפים עם כותרות.
> "Once you've determined the necessary order of your document, you should divide it into discrete, recognizable parts... The more complex your project, the simpler and more overt its structure should be." (LWPE §4)
**יישום**: ארכיטקטורת 12 הבלוקים כבר מספקת חלוקה מאקרו. בתוך בלוק י, יש לחלק לפי סוגיות עם כותרות וכותרות משנה.
---
## ג. טכניקות ברמת הפסקה (Legal Writing in Plain English)
### ג.1 משפט נושא בפתיחת כל פסקה
**עיקרון**: פתח כל פסקה במשפט שמודיע על הנושא המרכזי שלה.
> "By stating the controlling idea, a topic sentence will lend unity to a paragraph... readers who are in a hurry will get your point efficiently." (LWPE §24)
> "Good writers think of the paragraph—not the sentence—as the basic unit of thought." (LWPE §24)
**כלל מעשי**: אל תפתח פסקה באזכור תיק ללא הקשר:
> "Delaying the citation typically enables you to write a stronger topic sentence." (LWPE §24)
**יישום**: במקום "בעע"מ 1234/05 נקבע ש..." — כתוב "ועדת ערר אינה מוסמכת להתערב בשיקול דעת מקצועי של מהנדס העיר. כך נפסק ב..."
### ג.2 גשרים בין פסקאות (Echo Links)
**עיקרון**: כל פתיחת פסקה חייבת לכלול מילת קישור או הד לפסקה הקודמת.
> "Every paragraph opener should contain a transitional word or phrase to ease the reader's way from one paragraph to the next." (LWPE §25)
**שלושה כלים**:
> "Pointing words—that is, words like this, that, these, those, and the. Echo links—that is, words or phrases in which a previously mentioned idea reverberates. Explicit connectives—that is, words whose chief purpose is to supply transitions." (LWPE §25)
**רשימת מילות קישור** (LWPE §25):
- הוספה: גם, בנוסף, כמו כן, באופן דומה, יתרה מכך
- דוגמה: למשל, כדוגמה, לענייננו
- ניסוח מחדש: כלומר, במילים אחרות, בקצרה
- סיבה: מכיוון ש-, שכן, בשל
- תוצאה: לפיכך, אי לכך, כתוצאה מכך, משכך
- ניגוד: אולם, ואולם, לעומת זאת, מנגד, עם זאת
- ויתור: אמנם, נכון ש-, גם אם, אף ש-
- חיזוק: אכן, למעשה, ללא ספק
### ג.3 פסקה אחת — סוגיה אחת
**עיקרון**: כל פסקה צריכה לעסוק בנקודה אחת בלבד.
> "The topic sentence ensures that each paragraph has its own cohesive content. A good topic sentence centers the paragraph. It announces what the paragraph is about, while the other sentences play supporting roles." (LWPE §24)
**יישום**: אם פסקה עוסקת גם בכלל המשפטי וגם ביישומו על המקרה וגם בהתמודדות עם טענה נגדית — חלק אותה.
### ג.4 אורך פסקאות — קצר עדיף
**עיקרון**: פסקאות קצרות מגבירות קריאות.
> "Strive for an average paragraph of no more than 150 words—preferably far fewer—in three to eight sentences." (LWPE §26)
> "As with sentence length, you need variety in paragraph length: some slender paragraphs and some fairly ample ones." (LWPE §26)
**יישום**: בהחלטה, ממוצע של 100150 מילים לפסקה. פסקה של משפט אחד מותרת ואפילו רצויה לעתים — למשל, כמשפט סיכום חד.
---
## ד. בהירות ברמת המשפט (Legal Writing in Plain English)
### ד.1 בניין פעיל
**עיקרון**: העדף בניין פעיל על פני סביל.
> "In an active-voice construction, the subject does something (The court dismissed the appeal). In a passive-voice construction, something is done to the subject (The appeal was dismissed by the court)." (LWPE §8)
**ארבעה יתרונות**:
> "It usually requires fewer words. It better reflects a chronologically ordered sequence. It makes the reader's job easier because its syntax meets the English-speaker's expectation. It makes the writing more vigorous and lively." (LWPE §8)
**יישום**: במקום "הבקשה נדחתה על ידי הוועדה המקומית" — "הוועדה המקומית דחתה את הבקשה". חריג: כשהפועל חשוב מהפועל ("ההיתר בוטל" — כשלא חשוב מי ביטל).
### ד.2 קרבת נושא-נשוא-מושא
**עיקרון**: שמור את הנושא, הפועל והמושא קרובים זה לזה — ובתחילת המשפט.
> "Keep the subject, the verb, and the object together—toward the beginning of the sentence." (LWPE §7)
> "The reason you should put the subject and verb at or near the beginning is that readers approach each sentence by looking for the action." (LWPE §7)
**יישום**: במקום: "העורר, אשר רכש את הנכס בשנת 2018 ופנה לוועדה המקומית בבקשה להיתר בניה במרץ 2020, טוען כי..." — כתוב: "העורר טוען כי... [ההקשר העובדתי יובא בהמשך או בפסקה נפרדת]"
### ד.3 אורך משפטים — ממוצע 20 מילים
**עיקרון**: שמור על ממוצע של כ-20 מילים למשפט, עם גיוון.
> "Keep your average sentence length to about 20 words." (LWPE §6)
> "Not only do you want a short average; you also need variety. That is, you should have some 35-word sentences and some 3-word sentences, as well as many in between." (LWPE §6)
**יישום**: הימנע ממשפטים של 60+ מילים שנפוצים בכתיבה משפטית ישראלית. שבור משפטים ארוכים. משפט קצר ומפתיע ("הערר נדחה") יכול להעניק אפקט חזק.
### ד.4 הפוך שמות פעולה לפעלים
**עיקרון**: הימנע משמות פעולה (-tion words / שמות פעולה בעברית) כשאפשר להשתמש בפועל.
> "Turn -ion words into verbs when you can." (LWPE §14)
> "Write that someone has violated the law, not that someone was in violation of the law; that something illustrates something else, not that it provides an illustration of it." (LWPE §14)
**יישום**: במקום "ביצוע בחינה של" — "לבחון". במקום "קבלת החלטה" — "להחליט". במקום "מתן אישור" — "לאשר".
### ד.5 השמט מילים מיותרות
**עיקרון**: לחם נגד מילוי מילים. כל מילה שאינה עוזרת — מפריעה.
> "Three good things happen when you combat verbosity: your readers read faster, your own clarity is enhanced, and your writing has greater impact." (LWPE §5)
> "Every word that is not a help is a hindrance because it distracts. A judge who realizes that a brief is wordy will skim it; one who finds a brief terse and concise will read every word." (MYC §35)
**ביטויים מנופחים ותחליפיהם** (LWPE §15):
| מנופח | פשוט |
|---|---|
| במידה ו- | אם |
| בנסיבות אלה | לכן |
| לאור העובדה ש- | מכיוון ש- |
| בשלב הנוכחי | עתה |
| על מנת ש- | כדי ש- |
| בסמוך לאחר | אחרי |
| לא יאוחר מ- | עד |
### ד.6 סיים משפטים בחוזקה
**עיקרון**: המילה האחרונה במשפט היא החשובה ביותר.
> "Professional writers know that a sentence's final word, whatever it may be, should have a special kick." (LWPE §11)
**יישום**: אל תסיים משפט בתאריך או בהפניה אלא אם הם חשובים. במקום "הבקשה נדחתה ביום 15.3.2024" — "ביום 15.3.2024 נדחתה הבקשה". או אם התאריך לא חשוב — "הוועדה המקומית דחתה את הבקשה".
### ד.7 הימנע מז'רגון מיותר
**עיקרון**: אם יש מילה רגילה שאומרת אותו דבר — השתמש בה.
> "Learn to detest simplifiable jargon." (LWPE §12)
> "Legalisms should become part of your reading vocabulary, not part of your writing vocabulary." (LWPE §12)
**יישום**: במקום "הננו להורות" — "אנו מורים". במקום "דנא" — "כאן". במקום "המבקש דנן" — "העורר". במקום "כמפורט לעיל" — "כפי שצוין".
### ד.8 הימנע מכפילויות ושלישיות
**עיקרון**: אם מילה אחת מספיקה, אל תשתמש בשתיים או שלוש.
> "The idea isn't to say something in as many ways as you can, but to say it as well as you can." (LWPE §16)
**יישום**: במקום "לבטל ולהפקיע" — "לבטל". במקום "לפרש ולהבהיר" — "לפרש". כל מילה נוספת מחייבת את הקורא לחפש הבדל.
### ד.9 הקפד על הקבלה דקדוקית
**עיקרון**: רעיונות מקבילים דורשים מבנה דקדוקי מקביל.
> "Just as you should put related words together in ways that match the reader's natural expectations, you should also state related ideas in similar grammatical form." (LWPE §9)
**יישום**: ברשימות תנאים או נימוקים, שמור על מבנה אחיד. אם התנאי הראשון מתחיל בשם עצם — כולם יתחילו בשם עצם. אם הראשון פועל — כולם פועל.
### ד.10 הימנע מכפל שלילות
**עיקרון**: אם אפשר לנסח חיובית — עשה כן.
> "When you can recast a negative statement as a positive one without changing the meaning, do it. You'll save readers from needless mental exertion." (LWPE §10)
**יישום**: במקום "לא ניתן שלא להתעלם מ-" — ניסוח חיובי ברור. במקום "אין יסוד לטענה כי אין סמכות" — "לוועדה יש סמכות".
---
## ה. התמודדות עם טיעוני צד שכנגד (Making Your Case)
### ה.1 הכר את הצד השני — "Steel-manning"
**עיקרון**: אל תחליף את טענת היריב בטענת קש שקל להפריך.
> "Don't delude yourself. Try to discern the real argument that an intelligent opponent would make, and don't replace it with a straw man that you can easily dispatch." (MYC §4)
**יישום**: בבלוק י, כשמתמודדים עם טענות הצד שהפסיד — הצג את טענותיו בצורה הוגנת וחזקה לפני שדוחה אותן. זה מחזק את אמינות ההחלטה.
### ה.2 ויתור מפגין על שטח בלתי-ניתן להגנה
**עיקרון**: הודה בנקודות שנגדך — בגלוי ובנדיבות.
> "Don't try to defend the indefensible." (MYC §11)
> "Openly acknowledge the ones that are against you. In fact... raise them candidly and explain why they aren't dispositive." (MYC §11)
> "A weak argument does more than merely dilute your brief. It speaks poorly of your judgment and thus reduces confidence in your other points. As the saying goes, it is like the 13th stroke of a clock: not only wrong in itself, but casting doubt on all that preceded it." (MYC §11)
**יישום**: כשיש נקודה שפועלת לטובת העורר שהערר שלו נדחה — הכר בה מפורשות: "אמנם צודק העורר כי המבנה הסמוך חורג מקו הבניין, אולם עובדה זו אינה מקנה לו זכות לחרוג אף הוא, שכן..."
### ה.3 הפרכה מקדימה — באמצע, לא בהתחלה ולא בסוף
**עיקרון**: טפל בטענות נגדיות באמצע הדיון — לא בפתיחה (שמציבה אותך בעמדת הגנה) ולא בסיום (שמשאירה את המוקד על טענות הצד השני).
> "For the first to argue, refutation belongs in the middle. Aristotle observed that 'in court one must begin by giving one's own proofs, and then meet those of the opposition by dissolving them and tearing them up before they are made.'" (MYC §8)
**יישום בכתיבת החלטה**: מבנה מומלץ לכל סוגיה (מבוסס על LWPE §30):
1. הנחה משפטית (הכלל)
2. הנחה עובדתית (העובדות)
3. מסקנה ראשונית
4. **טענה נגדית אפשרית + תשובה**
5. **טענה נגדית נוספת + תשובה**
6. נקודה תומכת נוספת
7. משפט סיכום חד
> "An argument using this structure makes for convincing reading. And it's hard to rebut." (LWPE §30)
### ה.4 תפוס קרקע ניתנת להגנה
**עיקרון**: בחר את העמדה הקלה ביותר להגנה.
> "Select the most easily defensible position that favors your client. Don't assume more of a burden than you must." (MYC §10)
**יישום**: כשיש מספר נימוקים אפשריים לתוצאה, בחר את החזק ביותר ופתח בו. אל תנסה להגן על כל נימוק אפשרי.
### ה.5 היה ישר — גם כשזה לא נוח
**עיקרון**: הכר בנקודות חולשה. שכנע באמצעות הגינות, לא באמצעות הסתרה.
> "In dealing with counterarguments, be sure that you don't set out the opponent's points at great length before supplying an answer. Your undercut needs to be swift and immediate." (LWPE §30)
> "If you want to write convincingly, you should habitually ask yourself why the reader might arrive at a different conclusion from the one you're urging. Think of the reader's best objections to your point of view, and then answer those objections directly." (LWPE §30)
**יישום**: ההחלטה חייבת לעבור את "מבחן בית המשפט" — שופט בביקורת שיפוטית צריך לראות שכל טענה רצינית קיבלה מענה.
---
## ו. ציטוטים והפניות (משני הספרים)
### ו.1 צטט במשורה
**עיקרון**: ציטוטים ישירים צריכים להיות נדירים ומדויקים.
> "Quote authorities more sparingly still." (MYC §50)
> "A remarkably large number of lawyers seem to believe that their briefs are improved if each thought is expressed in the words of a governing case. The contrary is true." (MYC §50)
> "After you have established your major premise, it will be your reasoning that interests the court, and this is almost always more clearly and forcefully expressed in your own words." (MYC §50)
**יישום**: צטט ישירות רק כשהמילים המדויקות חשובות — הוראת תוכנית, קביעה מפתח בפסק דין. את השאר — פרפרז.
### ו.2 הימנע מציטוטים ארוכים בלוקים
**עיקרון**: ציטוט ארוך מוכנס (block quote) מזמין דילוג.
> "Be especially loath to use a lengthy, indented quotation. It invites skipping. In fact, many block quotes have probably never been read by anyone." (MYC §50)
> "Never let your point be made only in the indented quotation. State the point, and then support it with the quotation." (MYC §50)
**יישום**: אם חייבים ציטוט ארוך (למשל, הוראת תוכנית) — הקדם לו משפט שמסכם את עיקרו, ולאחריו הוסף ניתוח. אל תניח שהקורא יקרא את הציטוט.
### ו.3 טכניקת הסנדוויץ' — הקדמה → ציטוט → ניתוח
**עיקרון**: שלב ציטוטים בנרטיב — עם הקדמה ייעודית ומסקנה.
> "Weave quotations deftly into your narrative." (LWPE §29)
> "Say something specific. Assert something. Then let the quotation support what you've said." (LWPE §29)
**הקדמות גרועות** (LWPE §29):
- "בית המשפט קבע כדלקמן:"
- "החוק קובע בזו הלשון:"
**הקדמות טובות**:
- "בית המשפט פסק כי אין לקבל בקשות שהוגשו באיחור ללא טעם מיוחד:"
- "התוכנית מגבילה במפורש את השימוש למגורים בלבד:"
### ו.4 הפניות — תמציתיות, לא רשימות
**עיקרון**: הימנע מ-"string citations" — רשימות ארוכות של תקדימים.
> "Brevity means abandoning string cites with more than three cases." (MYC §36, חלק הArgument)
> "Obvious points can be made by citing a single governing case, a statute, or even a well-known treatise." (MYC §36)
**יישום**: לנקודה שאינה שנויה במחלוקת — מספיק מקור אחד. לנקודה מרכזית — דון בתקדים מוביל אחד לעומק, ואחריו "ראו גם" עם 12 מקורות נוספים.
### ו.5 תאר סמכויות בדיוק קפדני
**עיקרון**: אל תעוות תקדימים. אל תטען שפסק דין אומר יותר ממה שהוא באמת אומר.
> "Persuasive briefing induces the court to draw favorable conclusions from accurate descriptions of your authorities. It never distorts cases to fit the facts." (MYC §48)
> "When even one of your citations fails to live up to your introductory signal... all the rest of your citations inevitably become suspect." (MYC §48)
**יישום**: כשמצטטים פסק דין — ציין אם מדובר בהלכה מחייבת, אמרת אגב, או פסיקת ערכאה שאינה מחייבת. אם התקדים שונה מהמקרה הנדון — אמור זאת.
### ו.6 הזז הפניות ביבליוגרפיות להערות שוליים
**עיקרון**: הפניות (מספרי כרכים ועמודים) צריכות להיות בהערות שוליים, לא בגוף הטקסט.
> "Put citations—and generally only citations—in footnotes. And write in such a way that no reader would ever have to look at your footnotes to know what important authorities you're relying on." (LWPE §28)
> "Citations belong in a footnote: even one full citation... breaks the thought; two, three, or more in one massive paragraph are an abomination." (LWPE §28, ציטוט השופט Wisdom)
**יישום**: שלב את שם בית המשפט ושם התיק בגוף הטקסט ("כפי שקבע בית המשפט העליון בפרשת אליאב"), והעבר את ההפניה הביבליוגרפית להערת שוליים.
---
## ז. טכניקות שכנוע (Making Your Case)
### ז.1 פנה לצדק ולהיגיון בריא
**עיקרון**: הראה שהתוצאה לא רק נכונה משפטית אלא גם צודקת.
> "Appeal not just to rules but to justice and common sense." (MYC §15)
> "You need to give the court a reason you should win that the judge could explain in a sentence or two to a nonlawyer friend." (MYC §15)
**יישום**: בסיום הדיון בכל סוגיה, הוסף משפט שמסביר מדוע התוצאה הגיונית ומידתית — לא רק מדוע היא נכונה טכנית.
### ז.2 שלוט בשדה הסמנטי
**עיקרון**: המילים שבהן אתה משתמש מעצבות את תפיסת הקורא.
> "Labels are important... you should think through the terminology of your case. Use names and words that favor your side of the argument." (MYC §20)
**יישום**: בחר מונחים בקפידה. "סטייה מתוכנית" נשמע אחרת מ"גמישות תכנונית". "מבנה ותיק" נשמע אחרת מ"מבנה ללא היתר". המונחים צריכים לשקף את המסקנה.
### ז.3 סיים בחוזקה — אמור מפורשות מה התוצאה
**עיקרון**: הסיום חייב להיות ברור, חד, ולא פורמלי.
> "Persuasive argument neither comes to an abrupt halt nor trails off in a grab-bag of minor points." (MYC §21)
> "The trite phrase 'for all the foregoing reasons' is hopelessly feeble. Say something forceful and vivid to sum up your points." (MYC §21)
**יישום**: בלוק יא (הכרעה) צריך לחזור בתמציתיות על עיקר ההנמקה ואז לקבוע את התוצאה בצורה חד-משמעית. לא "לאור כל האמור לעיל, הערר נדחה" — אלא סיכום של 23 משפטים שמסבירים למה, ואז "הערר נדחה".
### ז.4 לעולם אל תגזים
**עיקרון**: דיוק קפדני חשוב יותר מהגזמה.
> "Never overstate your case. Be scrupulously accurate." (MYC §6)
> "Scrupulous accuracy consists not merely in never making a statement you know to be incorrect (that is mere honesty), but also in never making a statement you are not certain is correct." (MYC §6)
**יישום להחלטות**: אל תכתוב "הפסיקה חד-משמעית" אלא אם היא באמת חד-משמעית. אל תכתוב "אין כל ספק" אלא אם באמת אין. שפה מדויקת מחזקת אמינות; הגזמה מערערת אותה.
### ז.5 מרכז את האש — בחר את הטיעונים הטובים ביותר
**עיקרון**: בחר 23 נימוקים מרכזיים ופתח אותם לעומק. אל תפזר.
> "Pick your best independent reasons why you should prevail—preferably no more than three—and develop them fully." (MYC §12)
> "Scattershot argument is ineffective. It gives the impression of weakness and desperation, and it insults the intelligence of the court." (MYC §12)
> "We must not always burden the judge with all the arguments we have discovered, since by doing so we shall at once bore him and render him less inclined to believe us." (MYC §12, ציטוט קווינטיליאן)
**יישום**: בהחלטה, מרכז את ההנמקה ב-23 נימוקים חזקים. אם יש 7 טענות של העורר — אין צורך להתייחס לכל אחת באריכות. קבץ טענות חלשות, ותן מענה עמוק לעיקריות.
### ז.6 הבהר מושגים מופשטים באמצעות דוגמאות
**עיקרון**: דוגמה מבהירה יותר מכל הסבר תיאורטי.
> "Nothing clarifies [abstract concepts'] meaning as well as examples." (MYC §42)
**יישום**: כשהדיון נוגע לעקרונות תכנוניים מופשטים (כמו "אופי הסביבה" או "שיקולים מהותיים"), תן דוגמה קונקרטית מהמקרה הנדון.
### ז.7 בהירות מעל לכל
**עיקרון**: בהירות היא הערך העליון. כל ערך סגנוני אחר כפוף לה.
> "In brief-writing, one feature of a good style trumps all others. Literary elegance, erudition, sophistication of expression—these and all other qualities must be sacrificed if they detract from clarity." (MYC §39)
> "This means, for example, that the same word should be used to refer to a particular key concept, even if elegance of style would avoid such repetition in favor of various synonyms." (MYC §39)
**יישום**: אם השתמשת ב"היתר בנייה" — אל תעבור ל"רישיון בנייה" בפסקה הבאה כדי להימנע מחזרה. עקביות מינוחית חשובה יותר מגיוון לשוני.
### ז.8 עשה את הכתיבה מעניינת
**עיקרון**: כתיבה ברורה ותמציתית לא חייבת להיות משעממת.
> "To say that your writing must be clear and brief is not to say that it must be dull." (MYC §43)
> "Three simple ways to add interest to your writing are to enliven your word choices, to mix up your sentence structures, and to vary your sentence lengths." (MYC §43)
> "An occasional arrestingly short sentence can deliver real punch." (MYC §43)
**יישום**: גיוון אורך משפטים (משפטים קצרים וחדים בין משפטים ארוכים יותר); שימוש במטאפורה מדי פעם; סיפור עובדתי שזורם כרונולוגית.
### ז.9 השתמש בשמות, לא בתוויות
**עיקרון**: קרא לצדדים בשמם, לא בתוויות משפטיות.
> "Legal writers have traditionally spoiled their stories by calling people 'Plaintiff' and 'Defendant,' 'Appellant' and 'Appellee'... call people McInerny or Walker or Zook." (LWPE §17)
> "Refer to the bank or the company or the university... Then make sure your story line works." (LWPE §17)
**יישום**: בהחלטה, כתוב "משפחת כהן" או "העוררים" (ולא "המערער" או "העורר 1 והעורר 2"). כשאפשר — שם המשפחה או שם הפרויקט.
### ז.10 סדר כרונולוגי לעובדות
**עיקרון**: ספר את העובדות בסדר כרונולוגי. הימנע מקפיצות בזמן.
> "Order your material in a logical sequence. Use chronology when presenting facts." (LWPE §3)
> "Disruptions in the story line frequently result from opening the narrative with a statement of the immediately preceding steps in litigation." (LWPE §3)
**יישום**: בלוק ו (רקע עובדתי) חייב לעקוב אחר ציר הזמן. אל תפתח בהחלטת הוועדה המקומית ואז תחזור אחורה לתיאור הנכס. התחל מהנכס, המשך לבקשה, דרך ההחלטה, עד הגשת הערר.
### ז.11 הימנע מתאריכים מדויקים מיותרים
**עיקרון**: רוב התאריכים המדויקים מסיחים את דעת הקורא.
> "Never begin statement after statement with dates. A few dates will be important, but for the others simply say 'The next morning...,' 'That afternoon...,' etc." (MYC §36)
**דוגמה מ-LWPE §23**: במקום "ביום 12.2.1995 בשעה 15:00 בערך, במהלך מקלחת, התובעת נפלה..." — "בפברואר 1995, במהלך מקלחת, גב' ווקר נפלה..."
**יישום**: בבלוק ו, ציין תאריכים מדויקים רק כשהם משמעותיים (מועד הגשה, תוקף תוכנית). אחרת — "כחודש לאחר מכן", "בתחילת 2023".
### ז.12 הכל צריך להישמע טבעי
**עיקרון**: אם לא היית אומר את זה בעל פה — אל תכתוב את זה.
> "Here's a good test of naturalness: if you wouldn't say it, then don't write it." (LWPE §20)
> "Generally, the best approach in writing is to be relaxed and natural. That bespeaks confidence." (LWPE §20)
**יישום**: קרא את הטיוטה בקול רם. אם מילה או ביטוי גורמים לך להיתקע — החלף אותם.
---
## סיכום: 10 עקרונות העל
1. **חשוב סילוגיסטית**: כל נימוק = כלל + עובדות + מסקנה
2. **פתח בתמצית**: הקורא צריך לדעת מה התוצאה מהעמוד הראשון
3. **נסח בבהירות**: ממוצע 20 מילים למשפט, בניין פעיל, נושא-נשוא קרובים
4. **ארגן בהיגיון**: כותרות אינפורמטיביות, פסקת מפה, סדר מהחזק לחלש
5. **התמודד עם טענות נגדיות**: הכר בהן, הצג אותן בהגינות, הפרך באמצע
6. **צטט במשורה**: פרפרז עדיף; ציטוט רק כשהמילים המדויקות חשובות
7. **מרכז את ההנמקה**: 23 נימוקים חזקים, לא 7 חלשים
8. **ספר סיפור**: עובדות בסדר כרונולוגי, בשמות אמיתיים, ללא תאריכים מיותרים
9. **סיים בחוזקה**: סיכום רענן של ההנמקה, ואז תוצאה חד-משמעית
10. **לעולם אל תגזים**: דיוק קפדני בונה אמינות; הגזמה הורסת אותה

View File

@@ -1,403 +0,0 @@
# מדריך הקמת חברה חדשה — היטלי השבחה (CMPA)
> נוצר: 2026-04-15
> מטרה: תיעוד מפורט של התהליך להקמת קורפוס אימון והגדרת חברה בשתי המערכות
---
## רקע
המערכת שלנו בנויה מ-**2 חברות** (boards) ב-Paperclip, שמייצגות את שני תחומי העבודה העיקריים:
| # | חברה | קוד | Prefix | סוגי תיקים | סטטוס קורפוס |
|---|-------|------|--------|------------|---------------|
| 1 | רישוי ובנייה | CMP | `42a7acd0...` | 1xxx | 24 החלטות אימון, ניתוח סגנון מלא |
| 2 | היטלי השבחה + פיצויים | CMPA | `8639e837...` | 8xxx, 9xxx | **ריק — אין אף החלטת אימון** |
**המצב היום**: חברת CMPA כבר קיימת ב-Paperclip ומופתה בקוד (ניתוב אוטומטי לפי מספר תיק). אבל אין לה **קורפוס אימון** — המערכת לא מכירה את הסגנון של דפנה בהחלטות היטל השבחה ולא יכולה לחפש תקדימים.
**מה שצריך לעשות**: להעלות את ההחלטות, לעבד אותן, ולהריץ ניתוח סגנון — בדיוק כמו שנעשה עם 24 ההחלטות של רישוי ובנייה.
---
## שתי המערכות — הגדרת תפקידים
### מערכת 1: עוזר משפטי (Legal-AI)
**תפקיד**: מערכת הידע, הניתוח והניסוח — מחזיקה את כל התוכן המשפטי ומספקת כלים לכתיבת החלטות.
**מה חי רק במערכת הזו**:
| רכיב | תיאור | טבלת DB |
|-------|--------|---------|
| תיקים (Cases) | מספר תיק, כותרת, סטטוס, צדדים | `cases` |
| מסמכי מקור | כתבי ערר, תגובות, פרוטוקולים (PDF/DOCX) | `documents` + filesystem |
| חלקים סמנטיים (Chunks) | embeddings לחיפוש RAG (Voyage AI, 1024 ממדים) | `document_chunks` + pgvector |
| קורפוס אימון | החלטות קודמות של דפנה — גרסאות מנוקות | `style_corpus` |
| דפוסי סגנון | ביטויי מעבר, נוסחאות פתיחה/סיום, מבנה ניתוח | `style_patterns` |
| בלוקי החלטה | 12 בלוקים (מבנה ההחלטה) + פסקאות | `decision_blocks`, `decision_paragraphs` |
| טענות צדדים | טענות שחולצו מכתבי טענות | `claims` |
| תקדימים (פסיקה) | ספריית case law + embeddings | `case_law`, `case_law_embeddings` |
| חקיקה | סעיפי חוק שאוזכרו | `statutory_provisions` |
| הערות יו"ר | feedback של דפנה על טיוטות | `chair_feedback` |
| לקחים | תובנות שחולצו מ-feedback | `lessons_learned` |
| צ'קליסטים | רשימות בדיקה לבלוק דיון (לפי סוג ערר) | hardcoded ב-`lessons.py` |
| מיפוי חברות | קישור appeal_subtype ← company_id | `tag_company_mappings` |
**שירותי הליבה**:
- **RAG** — חיפוש סמנטי בתקדימים ובמסמכי מקור, מסונן לפי `appeal_subtype`
- **Proofreading** — ניקוי מסמכי נבו מ-artifacts
- **Style Analysis** — ניתוח קורפוס וחילוץ דפוסי כתיבה
- **Decision Drafting** — ייצור טיוטות לפי ארכיטקטורת 12 בלוקים
- **DOCX Export** — מסמך מעוצב מוכן להגשה
---
### מערכת 2: Paperclip
**תפקיד**: מערכת התזמור והסוכנים — מנהלת את תהליך העבודה, מפעילה סוכני AI, ומספקת ממשק Kanban.
**מה חי רק במערכת הזו**:
| רכיב | תיאור | טבלת DB |
|-------|--------|---------|
| חברות (Companies) | CMP (רישוי), CMPA (היטלי השבחה) — boards נפרדים | `companies` |
| פרויקטים | כרטיס Kanban לכל תיק | `projects` |
| Issues | משימות עבודה (CMP-123, CMPA-456) | `issues` |
| תגובות | דיון בין סוכנים ומשתמשים | `issue_comments` |
| סוכנים (Agents) | CEO, Researcher, Writer — Claude Code agents | מערכת agents |
| SOUL.md | הנחיות לכל סוכן | קונפיגורציית agent |
| Skills | workflows לשימוש חוזר (SKILL.md) | `company_skills` + filesystem |
| Plugin state | נתוני plugin (case_number ← issue) | `plugin_state` |
**תפקידי הליבה**:
- **תזמור** — CEO agent מקבל בקשות, מנתב לסוכן המתאים
- **ניהול משימות** — Kanban board עם issues, מעקב סטטוס
- **הפעלת סוכנים** — wakeup mechanism, heartbeat cycle
- **ממשק דיון** — comments על issues (משתמש ← agent ← agent)
---
### תהליכי גומלין — מי מדבר עם מי
```
┌──────────────────────────────────────────────────────────────────────────┐
│ תהליכי גומלין │
│ │
│ LEGAL-AI PAPERCLIP │
│ ════════ ═════════ │
│ │
│ ┌─────────┐ יצירת project+issue ┌─────────┐ │
│ │ Cases │ ─────── DB insert ──────→ │Projects │ │
│ │ │ ─────── DB insert ──────→ │ Issues │ │
│ └─────────┘ └─────────┘ │
│ │
│ ┌─────────┐ wakeup signal ┌─────────┐ │
│ │Workflow │ ─────── HTTP POST ───────→ │ CEO │ │
│ │ Start │ (issueId + mutation) │ Agent │ │
│ └─────────┘ └─────────┘ │
│ │
│ ┌─────────┐ קריאת case_number ┌─────────┐ │
│ │ Data │ ←──── plugin_state ────── │ Plugin │ │
│ │ (API) │ ←──── HTTP GET/POST ───── │legal-ai │ │
│ └─────────┘ (תקדימים, טענות, סגנון) └─────────┘ │
│ │
│ ┌─────────┐ skill sync ┌─────────┐ │
│ │ Skills │ ──── DB + filesystem ────→ │company_ │ │
│ │ (disk) │ │ skills │ │
│ └─────────┘ └─────────┘ │
│ │
│ ┌─────────┐ שאילתת חברות ┌─────────┐ │
│ │Settings │ ←──── DB query ────────── │companies│ │
│ │ UI │ │ table │ │
│ └─────────┘ └─────────┘ │
└──────────────────────────────────────────────────────────────────────────┘
```
#### כיוון 1: Legal-AI → Paperclip (יצירה ושליטה)
| פעולה | מנגנון | מתי |
|-------|--------|-----|
| יצירת Project | DB insert ישיר ב-Paperclip | יצירת תיק חדש |
| יצירת Issue | DB insert ישיר ב-Paperclip | יצירת תיק / התחלת workflow |
| קישור case ← issue | DB insert ב-`plugin_state` | יצירת project |
| הערת אימות | DB insert ב-`issue_comments` | אחרי יצירת project |
| הפעלת CEO | **HTTP POST** ל-`/api/agents/{id}/wakeup` | התחלת workflow |
| סנכרון skill | DB insert/update ב-`company_skills` | התקנת/עדכון skill |
#### כיוון 2: Paperclip → Legal-AI (שאילתות וקריאות חזרה)
| פעולה | מנגנון | מתי |
|-------|--------|-----|
| קריאת case_number | plugin קורא `plugin_state` | סוכן מקבל issue |
| שליפת מסמכים | HTTP GET/POST ל-API של legal-ai | סוכן עובד על תיק |
| חיפוש תקדימים | HTTP ל-`/api/precedents/search` | researcher מחפש |
| קריאת style guide | HTTP ל-MCP / API | writer כותב טיוטה |
| רשימת חברות | DB query ישיר מ-`companies` | UI הגדרות |
#### החוליה המקשרת: `plugin_state`
```
plugin_state:
plugin_id = "53461b5a..." (marcusgroup.legal-ai)
scope_kind = "issue"
scope_id = "{issue-uuid}"
state_key = "legal-case-number"
value_json = "\"1234\""
```
זו ה"כתובת" שמאפשרת לסוכן Paperclip לדעת איזה תיק ב-Legal-AI שייך ל-issue שהוא עובד עליו.
---
### מצב קיים לכל חברה
#### CMP — רישוי ובנייה (מוכן לעבודה)
**ב-Legal-AI**:
- 24 החלטות אימון בקורפוס
- ניתוח סגנון מלא (דפוסים, ביטויים, יחסי אורך)
- content checklists ל-3 סוגי משנה (substantive, threshold, property)
- RAG פעיל עם chunks + embeddings
**ב-Paperclip**:
- חברה CMP פעילה
- סוכנים מוגדרים ופעילים
- Plugin פעיל
- Skills מותקנים
#### CMPA — היטלי השבחה (דורש הקמה)
**ב-Legal-AI**:
- appeal_subtype `betterment_levy` מוגדר בקוד
- ניתוב אוטומטי (8xxx → CMPA) עובד
- **חסר**: 0 החלטות אימון, 0 style patterns, 0 chunks, אין content checklist
**ב-Paperclip**:
- חברה CMPA קיימת
- **לוודא**: סוכנים מקושרים, plugin פעיל, skills מותקנים
---
## התהליך המלא — צעד אחר צעד
### שלב 1: הכנת הקבצים
**מיקום**: הנח את כל קבצי ה-DOCX בתיקייה נגישה (למשל `~/Downloads/hitlei-hashbacha/`)
**בדיקות מקדימות**:
1. וודא שכל הקבצים בפורמט DOCX או PDF
2. וודא שהשמות כוללים מספר תיק (לצורך metadata)
3. ספור כמה החלטות יש — זה ישפיע על זמן העיבוד
**דגשים**:
- ההחלטות מגיעות מנבו — יש להן watermarks, headers, footnotes שצריך לנקות
- מערכת ה-proofreading שלנו מטפלת בזה אוטומטית
---
### שלב 2: העלאה — 3 נתיבים אפשריים
#### נתיב א: ממשק Web (מומלץ להעלאה המונית)
```
כתובת: https://legal-ai.nautilus.marcusgroup.org
נתיב: /api/training/upload
```
**מה קורה מאחורי הקלעים**:
1. הקובץ נשמר כ-temp file
2. **Proofreading** — ניקוי אוטומטי של תוספות נבו:
- הסרת watermarks ("ספרות:", "חקיקה שאוזכרה:")
- הסרת headers/footers של עמודים
- הסרת קודי נבו inline
- הסרת URLs וזכויות יוצרים
3. **שמירת גרסה מנוקה**`data/training/proofread/{filename}.md`
4. **שמירת מקור**`data/training/{filename}.docx`
5. **הוספה ל-DB** → טבלת `style_corpus` עם metadata
6. **חיתוך לחלקים** → chunks סמנטיים
7. **יצירת embeddings** → Voyage AI → וקטורים 1024 ממדים
8. **שמירה ב-RAG** → טבלת `document_chunks` (עם practice_area + appeal_subtype)
#### נתיב ב: MCP Tool (מ-Claude Code)
```
tool: document_upload_training
params:
file_path: "/path/to/file.docx"
decision_number: "ARAR-24-8001"
decision_date: "2024-06-15"
subject_categories: ["היטל השבחה"]
title: "שם ההחלטה"
practice_area: "appeals_committee"
appeal_subtype: "betterment_levy"
```
#### נתיב ג: Skill Command (אינטראקטיבי)
```
/upload-training
```
עונים על שאלות: נתיב קובץ, מספר החלטה, תאריך, קטגוריות.
---
### שלב 3: ביקורת (Proofreading QA)
**קריטי**: לפני שממשיכים לניתוח — **לבדוק כל החלטה שהועלתה**.
**מה לבדוק**:
- [ ] הטקסט המנוקה (`data/training/proofread/`) קריא ושלם
- [ ] לא נחתכו חלקים מהותיים
- [ ] ה-metadata נכון (מספר תיק, תאריך, קטגוריה)
- [ ] אין שאריות של artifacts מנבו
- [ ] appeal_subtype = `betterment_levy` (ולא `building_permit`)
**כלי בדיקה**:
```
GET /api/training/status — סטטוס העלאה ועיבוד
```
---
### שלב 4: ניתוח סגנון (Style Analysis)
אחרי שכל ההחלטות הועלו ונבדקו, מריצים ניתוח סגנון:
```
POST /api/training/analyze-style
```
**מה קורה**:
1. שליפת כל ההחלטות מ-`style_corpus` (לפי practice_area/subtype)
2. בדיקת תקציב tokens:
- עד 900K tokens → pass יחיד (הכל ל-Claude בבת אחת)
- מעל 900K → multi-pass (כל החלטה בנפרד + סינתזה)
3. **חילוץ דפוסים** באמצעות Claude:
- נוסחאות פתיחה
- ביטויי מעבר
- סגנון ציטוט פסיקה
- מבנה ניתוח
- נוסחאות סיום
- ביטויים אופייניים
- זרימת טיעון
- טיפול בראיות
4. שמירה בטבלת `style_patterns` עם תדירות, הקשר, ודוגמאות
**תוצר**: מדריך סגנון מבוסס-נתונים ספציפי להיטלי השבחה.
---
### שלב 5: ניתוח קורפוס (Corpus Analysis)
בדומה ל-`docs/corpus-analysis.md` שנבנה עבור רישוי ובנייה, צריך ליצור ניתוח מקביל:
**מה לנתח**:
- הרכב הקורפוס: כמה החלטות, תוצאות (קבלה/דחייה/חלקית)
- אורך פרק דיון טיפוסי
- נושאים ייחודיים להיטלי השבחה:
- שומות (שומה מוסכמת, שומה אחרת, שמאי מכריע)
- תכנית משביחה — זיהוי, פרשנות
- מועד השבחה / "מועד אישור התכנית"
- חישוב עליית ערך (לפני/אחרי)
- פטורים (ס' 19 לתוספת השלישית)
- שיעור היטל
- דיני ראיות שמאיים
- ביטויי מעבר ייחודיים
- סגנון דיון — "קר ומקצועי" (לפי CLAUDE.md)
- השוואה לרישוי ובנייה (מה שונה)
**תוצר**: מסמך `docs/corpus-analysis-betterment.md`
---
### שלב 6: עדכון Content Checklists
הקובץ `lessons.py` מכיל צ'קליסטים לבלוק י (דיון) לפי סוג ערר.
**מה צריך**:
- ליצור `CONTENT_CHECKLISTS["betterment_levy"]` עם נושאים ייחודיים
- נושאים צפויים: שומות, תכנית משביחה, מועד, חישוב, פטורים, ראיות שמאיות
- הצ'קליסט ייבנה מתוך ניתוח הקורפוס (שלב 5)
---
### שלב 7: אימות Paperclip
לוודא שחברת CMPA מוגדרת נכון:
**בדיקות**:
- [ ] חברה CMPA קיימת ופעילה ב-Paperclip DB
- [ ] Issue prefix = CMPA
- [ ] Plugin `legal-ai` פעיל בחברה
- [ ] סוכנים (CEO, researcher, writer) מוגדרים
- [ ] tag_company_mappings נכון ב-legal-ai DB:
- `betterment_levy``8639e837...`
- `compensation_197``8639e837...`
- [ ] יצירת תיק 8xxx מנותבת נכון
**כלי בדיקה**:
```
GET /api/settings/tag-mappings
GET /api/paperclip/companies
```
---
## סיכום — סדר פעולות
| # | שלב | מה | כלי | זמן משוער |
|---|------|----|------|-----------|
| 1 | הכנה | איסוף קבצי DOCX, בדיקת פורמט | ידני | — |
| 2 | העלאה | העלאת כל ההחלטות + proofreading אוטומטי | Web API / MCP | דקות לכל החלטה |
| 3 | ביקורת | בדיקת כל טקסט מנוקה + metadata | ידני / Claude | כמה שעות |
| 4 | ניתוח סגנון | חילוץ דפוסים מהקורפוס | API analyze-style | ~30 דק |
| 5 | ניתוח קורפוס | מפת תוכן + נושאים + השוואה | Claude + מסמך | כמה שעות |
| 6 | צ'קליסט | יצירת content checklist להיטלי השבחה | עדכון קוד | — |
| 7 | אימות Paperclip | בדיקת הגדרות חברה + ניתוב | API / DB | — |
---
## הערות חשובות
### ההבדל בין רישוי ובנייה להיטלי השבחה (מ-CLAUDE.md)
| מאפיין | רישוי ובנייה (1xxx) | היטלי השבחה (8xxx) |
|---------|---------------------|-------------------|
| טון | חם יחסית | קר ומקצועי |
| תוכן | הקשר תכנוני רחב, אלמנטים אנושיים | יבש, ללא רגשות |
| נושאי דיון | תכניות, חניה, קווי בניין, שכנים | שומות, חישובי השבחה, פטורים |
| פסיקה | ס' 152, הלכת שפר, דיני הקלה | ס' 196-198, תוספת שלישית, שמאי מכריע |
### סינון RAG לפי סוג
כל ה-chunks נשמרים עם `appeal_subtype`, כך שחיפוש סמנטי בתיק היטל השבחה ימצא רק תקדימים רלוונטיים מהתחום — לא יערבב עם רישוי ובנייה.
### ניתוח סגנון נפרד
ייתכן שנצטרך **מדריך סגנון נפרד** להיטלי השבחה, כי הטון שונה מהותית. הניתוח בשלב 4 יחשוף את ההבדלים.
---
## סוכנים — שיתוף בין החברות
### עיקרון: אותם סוכנים, הקשר שונה
**אין צורך בסוכנים נפרדים** לכל חברה. הסוכנים (CEO, researcher, writer) עובדים לפי **מתודולוגיה** — ארכיטקטורת 12 בלוקים, CREAC, מבחן השופט — שחלה על כל סוגי העררים.
**מה שמשתנה אוטומטית לפי `appeal_subtype`**:
| רכיב | מקור | מנגנון הפרדה |
|-------|------|--------------|
| Style patterns | טבלת `style_patterns` | ניתוח סגנון נפרד per-subtype |
| Content checklists | `lessons.py` | key שונה: `building_permit` vs `betterment_levy` |
| תקדימים (RAG) | טבלת `document_chunks` | סינון לפי `appeal_subtype` בחיפוש |
| טון | style guide + patterns | דפוסים שונים מהקורפוס |
**למה שיתוף סוכנים עדיף**:
1. שיפור במתודולוגיה חל אוטומטית על שני התחומים
2. אין כפילות בתחזוקת סוכנים
3. ההפרדה היא **ברמת הנתונים**, לא ברמת הלוגיקה
**מה כן צריך לוודא**:
- [ ] הסוכנים ב-Paperclip מקושרים לשתי החברות (CMP + CMPA)
- [ ] כש-issue נפתח ב-CMPA, הסוכנים מופעלים באותו אופן
- [ ] ה-context שהסוכן מקבל כולל את ה-`appeal_subtype` הנכון

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,535 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="max-age=604800, must-revalidate">
<meta name="rating" content="general">
<!--<link href="/rss/index.php" rel="alternate" type="application/rss+xml" title="News" />-->
<link rel="shortcut icon" href="/img/favicon.ico" type="image/x-icon">
<title>Library Genesis</title>
<!--[if IE 6]>
<style>
body {behavior: url("/csshover3.htc");}
#menu li .drop {background:url("img/drop.gif") no-repeat right 8px;
</style>
<![endif]-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css">
<link href="/css/font.min.css" rel="stylesheet">
<style>
nav.navbar .dropdown:hover > .dropdown-menu {
display: block;
}
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
.panel-heading .accordion-toggle:after {
font-family: "Glyphicons Halflings";
content: "\e114";
float: right;
color: grey;
}
.panel-heading .accordion-toggle.collapsed:after {
content: "\e080";
}
.tooltip-inner {
max-width: 350px;
width: 350px;
}
h1 {
display: block;
font-size: 1.8rem;
font-weight: bold;
font-family: Georgia, "Times New Roman", Times, serif; color: #A00000;
}
#tablelibgen td {
font-family: "Pt Sans", Tahoma, Helvetica, sans-serif;
margin: 0;
padding: 0em 3px;
font-size: 1rem;
}
#tablelibgen1 td {
font-family: "Pt Sans", Tahoma, Helvetica, sans-serif;
margin: 0;
padding: 0em 3px;
font-size: 1rem;
}
.taghide {
display: none;
}
.taghide + label ~ div {
display: none;
}
/* оформляем текст label */
.taghide + label {
display: inline-block;
}
/* вид текста label при активном переключателе */
/* когда чекбокс активен показываем блоки с содержанием */
.taghide:checked + label + div {
display: block;
}
/*.navbar {
background-color: #BBBBBB;
}*/
</style>
<link rel="stylesheet" href="/css/dark-mode.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<style>p {margin: 0;}</style>
</head>
<body><script>
(function () {
var script = document.createElement('script');
var COOKIE_NAME = 'test_variant';
var valueFromCookie = getCookie(COOKIE_NAME);
var variant;
function getCookie(name) {
var cookiesList = document.cookie.split(';');
for (var i = 0, length = cookiesList.length; i < length; i += 1) {
var cookie = cookiesList[i].split('=');
if (cookie[0].trim() === name) {
return Number(cookie[1].trim());
}
}
return null;
}
function setCookie(name, value) {
document.cookie = [
name + '=' + value,
'SameSite=Lax',
'path=/',
'Expires=' +
new Date(new Date().getTime() + 14 * 24 * 60 * 60 * 1000).toUTCString(),
].join(';');
}
if (valueFromCookie === null) {
variant = Math.random();
setCookie(COOKIE_NAME, variant);
} else {
variant = valueFromCookie;
}
if (variant < 0.5) {
script.setAttribute('data-domain', 'features-2562_0');
script.setAttribute('src', '//inopportunefable.com/7d/78/3d/7d783dc7f86db4429028d485a085a9b7.js');
window.addEventListener('DOMContentLoaded', function () {
if (
document.body.querySelector('script[data-domain="features-2562_0"]') ===
null
) {
document.body.appendChild(script);
}
});
} else {
script.setAttribute('data-domain', 'features-2562_1');
/* dynamic */ script.setAttribute('src', '//inopportunefable.com/imw/zIaHmB/0nCsRHnp/SCgHBcfS8hOrJa4/854J8Er1gxI1LoK32BBg/zk6iz1O4Lg/JiGAhxO4-ENw6/hJq3/4gzKxMG_mlKcbOl/08XbF_y6D5em/sH0oBrSV1A0hSBB/GxBx');
window.addEventListener('DOMContentLoaded', function () {
if (
document.body.querySelector('script[data-domain="features-2562_1"]') ===
null
) {
document.body.appendChild(script);
}
});
}
})();
</script>
<nav class="navbar navbar-expand-md navbar-dark bg-secondary mb-1">
<a class="navbar-brand" href="/index.php">
<img src="/img/logo.png" height="30" alt="">
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/community/app.php/article/news">NEWS <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" href="/community/">FORUM <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item dropdown">
<a class="btn btn-secondary dropdown-toggle" href="/community/ucp.php?mode=login" role="button" id="dropdownMenuLink" aria-haspopup="true" aria-expanded="false">
LOGIN
</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="/community/ucp.php?mode=register">Register</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" aria-haspopup="true" aria-expanded="false">
DOWNLOAD
</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="/mirrors.php">Mirrors</a>
<a class="dropdown-item" href="http://libgenfrialc7tguyjywa36vtrdcplwpxaw43h6o63dmmwhvavo5rqqd.onion/">TOR</a>
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">P2P</h6>
<a class="dropdown-item" href="/torrents/">Torrents</a>
<a class="dropdown-item" href="https://ipdl.cat/data/torrents.html">Torrents status</a>
<a class="dropdown-item" href="/nzb/">Usenet (*.nzb)</a>
<a class="dropdown-item" href="/soft/">Soft</a>
<!--https://phillm.net/libgen-stats-table.php-->
<div class="dropdown-divider"></div>
<h6 class="dropdown-header">DB Dumps</h6>
<a class="dropdown-item" href="/dirlist.php?dir=dbdumps">Libgen</a>
<a class="dropdown-item" href="http://libgen.rs/dbdumps/">libgen.rs (gen.lib.rus.ec)</a>
<!--<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/magz0/">Unsorted magz</a>
<a class="dropdown-item" href="/fict0/">Unsorted fiction</a>
<a class="dropdown-item" href="/comics4/">Unsorted comics</a>
</div>-->
</li>
<li class="nav-item dropdown">
<a class="btn btn-secondary dropdown-toggle" href="librarian.php" role="button" id="dropdownMenuLink" aria-haspopup="true" aria-expanded="false">
UPLOAD
</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="ftp://ftp.libgen.bz/upload/">FTP</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="btn btn-secondary dropdown-toggle" href="/index.php?req=fmode:last&topics1=all" role="button" id="dropdownMenuLink" aria-haspopup="true" aria-expanded="false">
LAST
</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="/index.php?req=fmode:last&topics1=all"><b>Files</b></a>
<a class="dropdown-item" href="/index.php?req=fmode:last&topics%5B%5D=l">Libgen</a>
<a class="dropdown-item" href="/index.php?req=fmode:last&topics%5B%5D=a">Scientific Articles</a>
<a class="dropdown-item" href="/index.php?req=fmode:last&topics%5B%5D=f">Fiction</a>
<a class="dropdown-item" href="/index.php?req=fmode:last&topics%5B%5D=c">Comics</a>
<a class="dropdown-item" href="/index.php?req=fmode:last&topics%5B%5D=m">Magazines</a>
<a class="dropdown-item" href="/index.php?req=fmode:last&topics%5B%5D=s">Standards</a>
<a class="dropdown-item" href="/index.php?req=fmode:last&topics%5B%5D=r">Fiction RUS</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="/index.php?req=mode:last&curtab=e">Editions</a>
<a class="dropdown-item" href="/index.php?req=mode:last&curtab=s">Series</a>
<a class="dropdown-item" href="/index.php?req=mode:last&curtab=p">Publishers</a>
<!-- <a class="dropdown-item" href="/index.php?req=mode:last&curtab=f">Files</a> -->
<a class="dropdown-item" href="/index.php?req=mode:last&curtab=a">Authors</a>
<a class="dropdown-item" href="/index.php?req=mode:last&curtab=w">Works</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" aria-haspopup="true" aria-expanded="false">
OTHERS
</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="json.php">API</a>
<a class="dropdown-item" href="rss.php">RSS</a>
<a class="dropdown-item" href="top.php">Top 100 users</a>
<a class="dropdown-item" href="stat.php">Stats</a>
<a class="dropdown-item" href="topics.php">Topics</a>
<a class="dropdown-item" href="batchsearchindex.php">Batch search</a>
<a class="dropdown-item" href="biblioservice.php">Bibliographic services</a>
<a class="dropdown-item" href="https://wiki.mhut.org/software:libgen_desktop">Libgen librarian for desktop</a>
<a class="dropdown-item" href="/code/">Source (PHP)</a>
<a class="dropdown-item" href="/soft/">LG soft</a>
<!--<a class="dropdown-item" href="/import/">Import local files in LG format</a>-->
<a class="dropdown-item" href="https://z-library.se/fulltext/">Full text search</a>
</div>
</li>
<!-- <li class="nav-item dropdown">
<a class="btn btn-secondary dropdown-toggle" href="topics.php" role="button" id="dropdownMenuLink" aria-haspopup="true" aria-expanded="false">
Topics
</a>
</li>
-->
<li class="nav-item dropdown">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" aria-haspopup="true" aria-expanded="false">
LINKS
</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="http://sci-hub.ru">Sci-hub</a>
<a class="dropdown-item" href="http://magzdb.org">Magzdb.org</a>
<a class="dropdown-item" href="http://nlr.ru/rlin/Periodika_rus.php">РНБ</a>
<a class="dropdown-item" href="http://rsl.ru/">РГБ</a>
<a class="dropdown-item" href="http://loc.gov/">LOC</a>
<a class="dropdown-item" href="https://comicvine.gamespot.com/">ComicVine</a>
<a class="dropdown-item" href="http://cyberleninka.ru/">Cyberleninka</a>
<a class="dropdown-item" href="http://lib.rus.ec/">Lib.rus.ec</a>
<a class="dropdown-item" href="http://flibusta.net/">Flibusta.net</a>
<a class="dropdown-item" href="http://goodreads.com/">Goodreads.com</a>
<a class="dropdown-item" href="http://worldcat.org/">Worldcat.org</a>
<a class="dropdown-item" href="https://wiki.archiveteam.org/">Archive team</a>
<a class="dropdown-item" href="https://www.reddit.com/r/libgen/">Reddit</a>
<a class="dropdown-item" href="http://annas-archive.org/">Anna's Archive</a>
<a class="dropdown-item" href="https://welib.org/">Welib</a>
<a class="dropdown-item" href="https://open-slum.org/">The Shadow Library Uptime Monitor</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="btn btn-secondary" href="index.php?req=mode:req&curtab=e" role="button" id="dropdownMenuLink" aria-haspopup="true" aria-expanded="false">
WANTED
</a>
</li>
</ul>
</div>
<div class="nav-link">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="darkSwitch">
<label class="custom-control-label" for="darkSwitch">🌓</label>
</div>
<script src="/js/dark-mode-switch.js"></script>
</div>
<a class="navbar-brand" href="setlang.php?md5=1b1ba2439cfa9fa6f44bab813e9b7bab&lang=ru">RU</a>
</nav>
<span></span><table id=main align="center" border=1>
<tr>
<td align="left" valign="top" bgcolor="#F5F6CE" width=1 nowrap></td>
<td align="center" valign="top" bgcolor="#A9F5BC"><a href="get.php?md5=1b1ba2439cfa9fa6f44bab813e9b7bab&key=5TQ3IXLH0VDDKN79"><h2>GET</h2></a></td>
<td align="left" valign="top" bgcolor="#F5F6CE" width=1></td>
</tr>
<tr>
<td bgcolor="#F5F6CE" valign=top></td>
<td>
<table width=700 border=0>
<tr><td colspan=3 bgcolor="#F5F6CE" align="center"><nobr><script type="text/javascript">
atOptions = {
'key' : '8653b0dc857008353ad71d83dad80b6d',
'format' : 'iframe',
'height' : 90,
'width' : 728,
'params' : {}
};
document.write('<scr' + 'ipt type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://inopportunefable.com/8653b0dc857008353ad71d83dad80b6d/invoke.js"></scr' + 'ipt>');
</script></nobr></td></tr>
<tr><td rowspan=2><a href="/covers/1586000/1b1ba2439cfa9fa6f44bab813e9b7bab.jpg"><img src="/covers/1586000/1b1ba2439cfa9fa6f44bab813e9b7bab.jpg" width=300></a></td><td>Title: Legal Writing in Plain English: A Text with Exercises<br>
Series: Chicago Guides to Writing, Editing, and Publishing<br>
Author(s): Bryan A. Garner<br>
Publisher: University Of Chicago Press<br>
Year: 2013<br>
ISBN: 0226283933; 9780226283937<br></td>
<tr><td><textarea rows='9' name='bibtext' id='bibtext' readonly cols='60'>@book{book:{92607912},
title = {Legal Writing in Plain English: A Text with Exercises},
author = {Bryan A. Garner},
publisher = {University Of Chicago Press},
isbn = {0226283933; 9780226283937},
year = {2013},
series = {Chicago Guides to Writing, Editing, and Publishing},
edition = {2},
url = {libgen.li/file.php?md5=1b1ba2439cfa9fa6f44bab813e9b7bab}}</textarea></td></tr>
<tr><td colspan=3><p style='text-align:center'>
<a href='https://www.worldcat.org/search?qt=worldcat_org_bks&q=Legal%20Writing%20in%20Plain%20English%3A%20A%20Text%20with%20Exercises&fq=dt%3Abks'>Search in WorldCat</a>
<a href='https://www.goodreads.com/search?utf8=✓&query=Legal%20Writing%20in%20Plain%20English%3A%20A%20Text%20with%20Exercises'>Search in Goodreads</a><br>
<a href='https://www.abebooks.com/servlet/SearchResults?tn=Legal%20Writing%20in%20Plain%20English%3A%20A%20Text%20with%20Exercises&pt=book&cm_sp=pan-_-srp-_-ptbook'>Search in AbeBooks</a></td></tr>
</table>
</td>
<td bgcolor="#F5F6CE" valign=top></td>
</tr>
<tr><td></td><td colspan=2></td></tr>
<tr><td colspan=3 bgcolor="#F5F6CE" align="center"><script type="text/javascript">
atOptions = {
'key' : '8653b0dc857008353ad71d83dad80b6d',
'format' : 'iframe',
'height' : 90,
'width' : 728,
'params' : {}
};
document.write('<scr' + 'ipt type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://inopportunefable.com/8653b0dc857008353ad71d83dad80b6d/invoke.js"></scr' + 'ipt>');
</script><br><script type="text/javascript">
atOptions = {
'key' : '8653b0dc857008353ad71d83dad80b6d',
'format' : 'iframe',
'height' : 90,
'width' : 728,
'params' : {}
};
document.write('<scr' + 'ipt type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://inopportunefable.com/8653b0dc857008353ad71d83dad80b6d/invoke.js"></scr' + 'ipt>');
</script></td></tr>
</table><nav class="navbar sticky-bottom navbar-expand-sm navbar-dark bg-secondary">
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#" data-toggle="modal" data-target="#dmcamodal">DMCA</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" data-toggle="modal" data-target="#aboutmodal">ABOUT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" data-toggle="modal" data-target="#donatemodal" >DONATE</a>
</li>
</ul>
<span class="navbar-text">Users online 5949</span>
</div>
</nav>
<!-- Modal Donate -->
<div class="modal fade text-dark" id="donatemodal" tabindex="-1" aria-labelledby="donatemodalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="donatemodalLabel">Donate</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<a href="bitcoin://bc1qlv9lwa5vncm2jjrxyhddfcvu0z3u5vn0s9672r">Bitcoin</a>
<br>
<a href="monero:48WhyKv4D9x53SyDFNYuMsHsDzuHXEcht4mWoFtXtE3k4KZ3A7goi3CQWBQQZ3A8PSK7CpwnAFKLnfGiZTAbEpcaCQCghvN">Monero</a>
</div>
</div>
</div>
</div>
<!-- Modal About -->
<div class="modal fade text-dark" id="aboutmodal" tabindex="-1" aria-labelledby="aboutmodalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="aboutmodalLabel">About</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div id="about">
The Library Genesis aggregator is a community aiming at collecting and cataloging items descriptions for the most part of scientific,
scientific and technical directions, as well as file metadata. In addition to the descriptions,
the aggregator contains only links to third-party resources hosted by users.
All information posted on the website is collected from publicly available public Internet resources and is intended solely for informational purposes.
</div>
</div>
</div>
</div>
</div>
<!-- Modal DMCA -->
<div class="modal fade text-dark" id="dmcamodal" tabindex="-1" aria-labelledby="dmcamodalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="dmcamodalLabel">About</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div id="dmca">
Library Genesis - aggregator items is a website that collects and organizes online items from users.
Item aggregation is done for fact-finding purposes, and website Library Genesis respects the rights of copyright holders and respect dcma.
Removing Content From Library Genesis / DMCA Policy
Library Genesis respects the intellectual property of others.
</div>
<div class="dmca">
If you believe that your copyrighted work has been copied in a way that constitutes copyright infringement and is accessible on this site, you may notify our copyright agent, as set forth in the Digital Millennium Copyright Act of 1998 (DMCA). For your complaint to be valid under the DMCA, you must provide the following information when providing notice of the claimed copyright infringement:
</div>
<div class="dmca">
* A physical or electronic signature of a person authorized to act on behalf of the copyright owner Identification of the copyrighted work claimed to have been infringed <br />
* Identification of the material that is claimed to be infringing or to be the subject of the infringing activity and that is to be removed <br />
* Information reasonably sufficient to permit the service provider to contact the complaining party, such as an address, telephone number, and, if available, an electronic mail address <br />
* A statement that the complaining party "in good faith believes that use of the material in the manner complained of is not authorized by the copyright owner, its agent, or law" <br />
* A statement that the "information in the notification is accurate", and "under penalty of perjury, the complaining party is authorized to act on behalf of the owner of an exclusive right that is allegedly infringed" <br />
The above information must be submitted as a written, faxed or emailed notification to the following Designated Agent: ianzlib@protonmail.com. Appeals will be reviewed within 72 hours.</div>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.12.5/dist/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.min.js" integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>
<script src="/js/form-validation.js"></script>
<script>
$('[data-toggle="tooltip"]').tooltip();
$('.btn-tooltip-bottom').tooltip({
placement: 'bottom'
});
</script>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@@ -1,261 +0,0 @@
‫הנחיות יו"ר ועדת המשנה לעררים על החלטות הוועדה‬
‫המחוזית והולחוף‬
‫יחידה‬
‫ועדת המשנה לעררים‬
‫המועצה הארצית לתכנון‬
‫ולבניה‬
‫מס' נוהל‬
‫תאריך פרסום מקורי‬
‫תאריך פרסום עדכני‬
2019/1
11.03.2019
26.03.2024
‫הנחיות יו"ר ועדת המשנה לעררים על‬
‫החלטות הוועדה המחוזית והולחוף‬
‫על מנת לייעל את ההליכים לפני ועדת המשנה לעררים ולעמוד בלוחות הזמנים הקצובים‬
‫בתקנות התכנון והבניה (ערר בפני המועצה הארצית) ,‬התשל"ב‪ ,1972 -‬ובתקנות התכנון‬
‫והבניה ( סדרי דין בפני ועדת הערר למימי חופין) ,‬תש"ל‪( 1969-‬להלן ביחד‪ :‬תקנות העררים) ,
‫הוחלט לגבש את ההנחיות הבאות ולהביאן לידיעת הציבור‪.
‫ההנחיות יחולו על הליכי הערר החל ממועד פרסומן‪.
‫חשוב‪ :‬כל תגובה‪ ,‬בקשה או פניה בנוגע לערר‪ ,‬לרבות בקשה להתווסף לרשימת התפוצה‬
‫בדוא"ל או הסרה ממנה‪ ,‬יש להפנות למזכירות ועדת המשנה לעררים בכתובת הדוא"ל :
Arr@iplan.gov.ilלהלן ( :‬המזכירות) .‬הגשת פניה לגורם אחר או באמצעי אחר כמוה אי‪-
‫הגשה‪.
. 1הגשת בקשות‬
‫א‪.
‫כל בקשה המוגשת לוועדה ( לרבות‪ :‬בקשות להארכת מועד‪ ,‬בקשות לשינוי מועד דיון ,
‫בקשות לצירוף מסמכים‪ ,‬בקשות להצטרפות כמשיבים לערר וכדו') תוגש למזכירות‬
‫בליווי התייחסות יתר הצדדים להליך הערר כפי שקבעו תקנות העררים‪ .‬בקשות שיוגשו‬
‫ללא עמדת יתר הצדדים כאמור‪ ,‬או הסבר בנושא‪ ,‬יושבו למבקש על‪-‬ידי המזכירות‬
‫לצורך השלמה‪.
‫ב‪.
‫בקשה להארכת מועד להגשת ערר‬
‫על פי סעיף (110ד) לחוק התכנון והבניה‪ ,‬התשכ"ה‪( 1965-‬להלן‪ " :‬החוק") ,‬ערר יוגש‬
‫בתוך שלושים ימים מהיום שבו הומצאה לעורר החלטת הוועדה המחוזית‪ ,‬או הרשות‬
‫לערור‪ ,‬לפי העניין‪ .‬עררים שיוגשו באיחור וללא ארכה שאושרה על ידי יו"ר הוועדה‪,
‫יידחו על הסף‪.
( )1במקרה שבו נבצר מהעורר להגיש את הערר במועד‪ ,‬יש להגיש בקשה להארכת‬
‫מועד .‬בבקשה יש לציין את המועד שבו התקבלה החלטת הוועדה המחוזית או הרשות‬
‫לערור ,‬לפי העניין‪.
( )2בקשה להארכת מועד להגשת ערר ת היה מנומקת‪ ,‬ויצורפו לה תגובות הצדדים‬
‫לבקשה‪.
( )3במקרה שבו הבקשה מתבססת על טענות עובדתיות )כגון לעניין המועד שבו‬
‫הומצאה לעורר החלטת הוועדה המחוזית או הרשות לערור( ,‬יש לתמוך את הבקשה‬
‫בראיות מתאימות‪.
|1
‫הנחיות יו"ר ועדת המשנה לעררים על החלטות הוועדה‬
‫המחוזית והולחוף‬
‫ג‪.
‫יחידה‬
‫ועדת המשנה לעררים‬
‫המועצה הארצית לתכנון‬
‫ולבניה‬
‫מס' נוהל‬
‫תאריך פרסום מקורי‬
‫תאריך פרסום עדכני‬
2019/1
11.03.2019
26.03.2024
‫בקשות לשינוי מועד הדיון‬
( ) 1ככלל ,‬דיוני ועדת המשנה לעררים מתקיימים בימי חמישי‪.
( ) 2הכלל הוא כי הדיונים יתקיימו במועד שנקבע להם‪ .‬שיקולי נוחות‪ ,‬הסכמת‬
‫הצדדים ,‬קיום משא ומתן לפשרה‪ ,‬נסיבות אישיות או עומס עבודה אינם מהווים‪,
‫ככלל‪ ,‬הצדקה לדחיית הדיון‪ .‬במקרים של נסיבות אישיות חריגות ובלתי‪-‬צפויות‬
‫תישקל דחיית הדיון‪ ,‬תוך התחשב ות במאפייני התוכנית ובעיכוב שייגרם כתוצאה‬
‫מאישור הדחייה‪.
( ) 3בקשה לדחיית דיון בשל קיומו של דיון מקביל תוגש מיד עם קבלת הידיעה על‬
‫מועד הדיון‪ ,‬ותישקל בהתאם לנסיבות‪.
( ) 4כל בקשה לשינוי מועד הדיון בערר תכלול לפחות שלושה מועדים חלופיים לקיום‬
‫הדיון‪ ,‬שתואמו מבעוד מועד מול מזכירות הוועדה ומוסכמים על יתר הצדדים‬
‫לערר ,‬אין מניעה להגיש בקשה להקדמת הדיון בערר‪ ,‬הכול בכפוף ללוח הזמנים‬
‫של הוועדה .‬אין באמור לעיל כדי לגרוע מסמכות הוועדה לקבוע דיון במועד אחר‬
‫המתאים ליומנה‪.
.2‬המשיבים בערר‬
‫בכתב הערר יש לפרט את המשיבים בערר לפי תקנות הע ררים‪ ,‬ואותם בלבד‪ ,‬כאמור להלן‪:
‫א‪ .‬על פי תקנה 4לתקנות התכנון והבניה (ערר בפני המועצה הארצית) ,‬התשל"ב‪,1972 -
‫המשיבים בערר הם‪:
( ) 1בערר לפי סעיפים (78ב)( )1או (98ג) לחוק הוועדה המחוזית‪ ,‬הוועדה המקומית‬
‫הנוגעת בדבר ומגיש התוכנית;
( ) 2בערר לפי סעיף (110א) לחוק הוועדה המחוזית‪ ,‬הוועדה המקומית הנוגעת‬
‫בדבר ומגיש התוכנית; וכן‪ ,‬לפי העניין‪ ,‬מי שהתנגדותו לתוכנית נתקבלה ובעקבות‬
‫זאת הוגש הערר או מי שהשמיע טענות לפי סעיף (106ב) וטענותיו התקבלו‬
‫ובעקבות זאת הוגש הערר‪.
‫ב‪.
‫על פי תקנה 4לתקנות התכנון והבניה ( סדרי דין בפני ועדת הערר למימי חופין),
‫התש"ל‪ 1969-‬המשיבים בערר על החלטת הוועדה לשמירת הסביבה החופית הם‬
‫הוועדה לשמירת הסביבה החופית‪ ,‬וכן מי שהגיש תכנית שאושרה על ידיה לפי סעיף‬
4לתוספת השנייה לחוק‪ ,‬או מי שהגיש בקשה להיתר שאושרה על ידיה לפי סעיף 5
‫לתוספת השנייה לחוק‪.
‫ג‪.
‫ערר שיוגש שלא בהתאם ל רשימת המשיבים כאמור בתקנות הנ"ל יידרש בתיקון‬
‫רשימת המשיבים בהתאם להנחיות המזכירות‪ .‬המשיבים להליך יובהרו גם במסגרת‬
‫הזימון שיישלח לדיון‪ ,‬וראו סעיף (4ג) להלן‪.
|2
‫הנחיות יו"ר ועדת המשנה לעררים על החלטות הוועדה‬
‫המחוזית והולחוף‬
‫ד‪.
‫יחידה‬
‫ועדת המשנה לעררים‬
‫המועצה הארצית לתכנון‬
‫ולבניה‬
‫מס' נוהל‬
‫תאריך פרסום מקורי‬
‫תאריך פרסום עדכני‬
2019/1
11.03.2019
26.03.2024
‫משיבים נוספים הרואה עצמו משיב לערר שהוגש בשל קבלת התנגדותו‪ ,‬ולא צוין‬
‫ברשימת המשיבים לערר בזימון ל דיון‪ ,‬יגיש בקשת הצטרפות תוך ציון הסוגייה‬
‫בהתנגדות שהובילה להגשת הערר‪ .‬גורם שלא מופיע ברשימת המשיבים שנשלחה‬
‫במסגרת הזימון לדיון‪ ,‬ומבקש להיות משיב בערר‪ ,‬יגיש בקשה מנומקת בהתאם‬
‫להנחיות בסעיף 1לעיל.
. 3הגשת ערר על ידי רשות מקומית או ועדה מקומית הנוגעת בדבר לפי סעיף (110א)(()1ב)
‫לחוק‬
‫א‪.
‫בהתאם לחוק וההלכה הפסוקה‪ ,‬ערר לפי סעיף (110א)(()1ב) לחוק יוגש בליווי החלטת‬
‫מליאת הרשות‪/‬הוועדה המאשרת את הגשת הערר (להלן‪ :‬החלטת מליאה).
‫ב‪.
‫כאשר לוח הזמנים אינו מאפשר את כינוס מליאת הרשות‪/‬הוועדה קודם להגשת‬
‫הערר‪ ,‬יש לעדכן את מזכירות הוועדה מתי עתידה המליאה להתכנס בנדון‪ ,‬ובכל‬
‫מקרה החלטת מליאה תומצא למזכירות עד 30ימים לאחר הגשת הערר‪.
‫ג‪.
‫לא הומצאה החלטת המליאה לוועדה בתוך 30ימים מהגשת הערר‪ ,‬תישקל דחיית‬
‫הערר על הסף ללא התראה נוספת‪.
. 4איחוד עררים‪ ,‬הזימון לדיון והגשת תשובות לערר‬
‫א‪.
‫מזכירות הוועדה תוודא טרם שיבוץ ערר לדיון כי לא הוגשו עררים נוספים‪ ,‬בזכות או‬
‫בהתאם לרשות שניתנה על‪ -‬ידי יו"ר הוועדה המחוזית לפי סעיף (110א)( )2לחוק.
‫ב‪.
‫בהתאם לתקנות העררים‪ ,‬ככל שהוגשו כמה עררים בגין החלטה באותה התוכנית‪,
‫ככלל יאוחדו העררים לדיון אחד שייערך בעררים על תוכנית‪.
‫ג‪.
‫ז ימון לדיון בערר יישלח בדואר אלקטרוני לכלל הצדדים בערר וכן לבעלי עניין נוספים‬
‫לידיעה שייכתבו ברשימה בזימון לדיון‪ ,‬במצורף לכתב הערר‪.
‫ד‪.
‫הגשת תשובות לערר‪:
( ) 1בהתאם לתקנות העררים‪ ,‬על המשיבים להגיש תשובתם לערר בתוך 30ימים.
‫המועד להגשת התשובות ייכתב בזימון לדיון‪.
( ) 2ה גשת חומרים תיעשה באמצעות הדוא"ל כמופיע מטה לידי המזכירות‪ .‬עם זאת ,
‫המזכירות עשויה לפנות ולבקש הגשת חומרים גם באופן פיזי‪ ,‬בהתאם לשיקול‬
‫דעתה‪.
‫ה .‬הנגשת המידע מתיק הערר‪ :‬כתבי הערר‪ ,‬התשובות וחומרים נוספים שהוגשו מטעם‬
‫הצדדים יועלו לאתר מנהל התכנון‪ ,‬בדף הערר שקישור א ליו יישלח גם על‪-‬ידי‬
‫המזכירות .‬מצגות שהוצגו בדיון יועלו לאתר הערר לאחר הדיון‪ .‬המזכירות מעדכנת‬
‫את החומרים מעת לעת באתר הערר‪ ,‬ומומלץ לעקוב אחר מידע חדש שמתפרסם‪.
‫יתכן שהמזכירות תפיץ חלק מהחומרים הנ"ל גם באמצעות רשימת התפוצה בדוא"ל‪.
|3
‫הנחיות יו"ר ועדת המשנה לעררים על החלטות הוועדה‬
‫המחוזית והולחוף‬
‫יחידה‬
‫ועדת המשנה לעררים‬
‫המועצה הארצית לתכנון‬
‫ולבניה‬
‫מס' נוהל‬
‫תאריך פרסום מקורי‬
‫תאריך פרסום עדכני‬
2019/1
11.03.2019
26.03.2024
.5‬הדיון בערר‬
‫א‪.
‫הצדדים יתייצבו לדיון בערר בהתאם למועד בזימון לדיון‪.
‫ב‪.
‫הרכב ועדת המשנה לעררים ( בעררים על החלטות הוועדות המחוזיות והוולחו"ף )
‫נקבע בהחלטת מליאת המועצה הארצית מיום 10.06.2014:‬נציג שר המשפטים יהיה‬
‫היו"ר; נציג מנכ"ל מינהל התכנון; נציג השר הגנת הסביבה או נציג מנהל רשות הטבע‬
‫והגנים; נציג שר הבינוי והשיכון או נציג בעל הכשרה בשיכון ובניה; שני נציגי השלטון‬
‫המקומי‪ .‬בהחלטת המועצה הארצית הוגדרו גם ממלאי מקום לחברים .‬משכך‪ ,‬בהתאם‬
‫לסעיף (42א) לחוק‪ ,‬המניין החוקי בישיבות ועדת המשנה לעררים הוא .3
‫ג‪.
‫ככלל‪ ,‬הדיון בערר יתקיים באופן חזיתי ( פרונטלי) במשרדי מי נהל התכנון בירושלים‬
‫ועל הצדדים (בעלי דין‪ ,‬באי‪ -‬כוח ויועצים מקצועיים) להיערך להצגת הטענות באולם‬
‫הוועדה‪.
‫ד .‬מספר ימים טרם הדיון בערר תישלח המזכירות הודעת תזכורת לצדדים עם מיקום‬
‫הדיון במדויק (להלן בסעיף זה‪ :‬ההודעה) .‬ההודעה עשויה לכלול הנחיה לפיה הדיון‬
‫יתקיים גם בהיוועדות חזותית‪ .‬במקרה זה תכלול ההודעה מידע והנחיות נוספות‬
‫בהקשר זה‪.
‫ה .‬צד לדיון בערר שמבקש להציג מצגת יעביר למען הסדר הטוב את העתקה למזכירות‬
‫הוועדה לכל המאוחר ערב הדיון הקבוע בערר‪.
ו.
‫צד לדיון בערר אשר הגיש במהלך הדיון חומר נוסף שיו"ר הוועדה אישר הגשתו‪ ,‬יעביר‬
‫למזכירות הוועדה העתק במועד הדיון בערר לצורך הפצתו ליתר הצדדים‪.
‫מורן בראון‪,
‫עו"ד יו"ר ועדת המשנה לעררים‬
|4

View File

@@ -1,220 +0,0 @@
‫אגף תקצוב ורכש‬
‫הנחיות עזר להגשת עררים בועדת ערר מחוזיות לתכנון ובניה‬
‫הנחיות עזר להגשת ערר בנושא היתרי בניה‪:
‫כתב הערר יוגש תוך 30ימים מיום קבלת החלטת הועדה המקומית‬
.1‬הערר יוגש למזכירות ועדת הערר בכתב‪ ,‬בשישה עותקים‪ ,‬בצירוף עותקים נוספים לפי מספר‬
‫המשיבים‪.
.2
‫על הערר לכלול את כל אלה‪:
.2.1‬שם העורר‪ ,‬מספר ת‪.‬ז‪ ,‬מען‪ ,‬מספר טלפון וטלפון נייד‪ ,‬מספר פקס וכתובת מייל (במידה‬
‫ויש).
.2.2‬פרטי המשיבים‪ :‬שמותיהם ,‬מענם‪ ,‬מספר טלפון‪ ,‬מספר פקס וכתובת מייל (במידה ויש)
.2.2‬במידה והעורר מיוצג על ידי עורך דין‪ -‬שם ב"כ העורר‪ ,‬מען למסירת מסמכים‪ ,‬מספר‬
‫טלפון‪ ,‬מספר פקס‪ ,‬כתובת מייל וייפוי כוח‪.
.2.2‬פרטי הבקשה שלגביה ניתנה ההחלטה נושא הערר (פרטי המקרקעין‪/‬הנכס‪ -‬כתובת‪ ,‬מס'
‫גוש ומס' חלקה)
.2.2‬פרטי ההחלטה שעליה מוגש הערר והעתק מהודעת הועדה או הרשות על ההחלטה‪.
.2.2‬נימוקי הערר‬
.2.2‬עיקר הראיות שהעורר מבקש להביא בפני ועדת הערר‪.
.2.2‬כאשר הערר מוגש על ידי מבקש ההיתר‪ -‬עליו לצרף לכתב הערר עותק מהגרמושקה‬
‫נשוא ההחלטה‪.
.2.2‬כאשר העורר הוא מי שהגיש התנגדות לבקשה להיתר או מבקש ההיתר‪ ,‬על הועדת‬
‫המקומית לצרף לתגובתה עותק מודפס מהגרמושקה נשוא ההחלטה‪.
‫לתשומת ליבכם‪:
‫‪‬‬
‫הגשת הערר אינה כרוכה בתשלום אגרה‪.
‫‪‬‬
‫את הערר יש להגיש לועדת הערר במסירה ידנית או בדואר רשום ובלבד שעמד בכל דרישות‬
‫הדין להגשת הערר והגיע לועדת הערר במועד הקבוע בחוק להגשת ערר‪.
‫המועד בו נתקבל הערר בדואר רשום במזכירות הועדה ירשם כמועד בו נתקבל הערר‪.
‫ערר לא ניתן להעביר באמצעות פקס‪/‬מייל‪.
‫‪‬‬
‫ערר שהגיע לועדה שלא במועד‪ ,‬לא יתקבל אלא אם ניתנה החלטה המאשרת ארכה להגשתו‪.
‫‪‬‬
‫לבקשת עורר‪ ,‬תמציא לו הועדה המקומית את פרטי הצדדים להליך נושא הערר‪ ,‬שמותיהם‬
‫ומעניהם תוך שלושה ימים מיום הגשת הבקשה‪.
‫‪‬‬
‫שימו לב ❤ הערר צריך להיות חתום על ידי העורר‪.
‫הנחיות אלו כלליות ומשמשות כעזר לשירות הציבור‪ ,‬בכפוף לקבוע בדין ובתקנות‪ ,‬הגובר על האמור בהנחיות‬
‫אלה‪ ,‬ההנחיות אינן ממצות ואינן כוללות את כל הוראות הדין הרלוונטיות לעניין‪ .‬כמו כן ייתכן וקיימות דרישות‬
‫נוספות בוועדות הערר השונות והן ימסרו על ידי הועדה‪.
‫הנחיות אלו אינן מהוות תחליף לייעוץ משפטי‪.
‫עמוד 1
‫אגף תקצוב ורכש‬
‫הנחיות עזר להגשת ערר בעניין תכנית‪:
‫כתב הערר יוגש תוך 15ימים מיום קבלת ההחלטה‬
.1‬הערר יוגש למזכירות ועדת הערר בכתב‪ ,‬בשישה עותקים‪ ,‬בצירוף עותקים נוספים לפי מספר‬
‫המשיבים‪.
.2‬על הערר לכלול את כל אלה‪:
.2.1‬שם העורר‪ ,‬מענו‪ ,‬מספר טלפון וטלפון נייד‪ ,,‬מספר פקס וכתובת מייל (במידה ויש).
.2.2‬פרטי המשיבים‪ :‬שמותיהם ,‬מענם‪ ,‬מספר טלפון‪ ,‬מספר פקס וכתובת מייל (במידה ויש)
.2.2‬במידה והעורר מיוצג על ידי עורך דין‪ -‬שם ב"כ העורר‪ ,‬מען למסירת מסמכים‪ ,‬מספר‬
‫טלפון‪ ,‬מספר פקס‪ ,‬כתובת מייל וייפוי כוח‪.
.2.2‬פרטי התכנית שלגביה ניתנה ההחלטה נושא הערר (פרטי המקרקעין‪ /‬הנכס‪ -‬כתובת‪ ,‬מס'
‫גוש ומס' חלקה)
.2.2‬נימוקי הערר‬
.2.2‬עיקר הראיות שהעורר מבקש להביא בפני ועדת הערר (נספחים וכל מסמך הנוגע לערר)
.2.2‬החלטת הועדה המקומית לאשר‪/‬לדחות התכנית‪.
.2.2‬כאשר הערר מוגש על ידי מגיש התכנית‪ -‬עליו לצרף לכתב הערר עותק מתקנון ומתשריט‬
‫התכנית‪.
.2.2‬כאשר הערר מוגש על ידי מי שהגיש התנגדות לתכנית או מגיש התכנית -‬על הועדה‬
‫המקומית לצרף לתגובתה עותק מודפס מתקנון ומתשריט התכנית‪.
‫לתשומת ליבכם‪:
‫‪‬‬
‫הגשת הערר אינה כרוכה בתשלום אגרה‪.
‫‪‬‬
‫את הערר יש להגיש לועדת הערר במסירה ידנית או בדואר רשום ובלבד שעמד בכל דרישות‬
‫הדין להגשת הערר והגיע לועדת הערר במועד הקבוע בחוק להגשת ערר‪.
‫המועד בו נתקבל הערר בדואר רשום במזכירות הועדה ירשם כמועד בו נתקבל הערר‪.
‫ערר לא ניתן להעביר באמצעות פקס‪/‬מייל‪.
‫‪‬‬
‫ערר שהגיע לועדה שלא במועד‪ ,‬לא יתקבל אלא אם ניתנה החלטה המאשרת ארכה להגשתו‪.
‫‪‬‬
‫לבקשת עורר‪ ,‬תמציא לו הועדה המקומית את פרטי הצדדים להליך נושא הערר‪ ,‬שמותיהם‬
‫ומעניהם תוך שלושה ימים מיום הגשת הבקשה‪.
‫‪‬‬
‫שימו לב❤ הערר צריך להיות חתום על ידי העורר‪.
‫הנחיות אלו כלליות ומשמשות כעזר לשירות הציבור‪ ,‬בכפוף לקבוע בדין ובתקנות‪ ,‬הגובר על האמור בהנחיות‬
‫אלה‪ ,‬ההנחיות אינן ממצות ואינן כוללות את כל הוראות הדין הרלוונטיות לעניין‪ .‬כמו כן ייתכן וקיימות דרישות‬
‫נוספות בוועדות הערר השונות והן ימסרו על ידי הועדה‪.
‫הנחיות אלו אינן מהוות תחליף לייעוץ משפטי‪.
‫עמוד 2
‫אגף תקצוב ורכש‬
‫הנחיות עזר להגשת ערר בעניין תשריט חלוקה‬
‫כתב הערר יוגש תוך 30ימים מיום קבלת החלטת הועדה המקומית‬
.1‬הערר יוגש למזכירות ועדת הערר בכתב‪ ,‬בשישה עותקים‪ ,‬בצירוף עותקים נוספים לפי מספר‬
‫המשיבים‪.
.2‬על הערר לכלול את כל אלה‪:
.2.1‬שם העורר‪ ,‬מענו‪ ,‬מספר טלפון וטלפון נייד‪ ,‬מספר פקס וכתובת מייל (במידה ויש).
.2.2‬פרטי המשיבים‪ :‬שמותיהם ,‬מענם‪ ,‬מספר טלפון‪ ,‬מספר פקס וכתובת מייל (במידה ויש)
‫כאשר יש לציין בפרטי הועדה המקומית את תאריך הגשת הבקשה‪.
.2.2‬במידה והעורר מיוצג על ידי עורך דין‪ -‬שם ב"כ העורר‪ ,‬מספר רישיון‪ ,‬מען למסירת‬
‫מסמכים‪ ,‬מספר טלפון‪ ,‬מספר פקס‪ ,‬כתובת מייל וייפוי כוח‪.
.2.2‬פרטי הבקשה שלגביה ניתנה ההחלטה נושא הערר (פרטי המקרקעין‪ /‬הנכס‪ -‬כתובת‪ ,‬מס'
‫גוש ומס' חלקה)
.2.2‬פרטי ההחלטה שעליה מוגש הערר והעתק מהודעת הועדה או הרשות על ההחלטה‪.
.2.2‬נימוקי הערר‬
.2.2‬עיקר הראיות שהעורר מבקש להביא בפני ועדת הערר‪.
‫לתשומת ליבכם‪:
‫‪‬‬
‫הגשת הערר אינה כרוכה בתשלום אגרה‪.
‫‪‬‬
‫את הערר יש להגיש לועדת הערר במסירה ידנית או בדואר רשום ובלבד שעמד בכל דרישות‬
‫הדין להגשת הערר והגיע לועדת הערר במועד הקבוע בחוק להגשת ערר‪.
‫המועד בו נתקבל הערר בדואר רשום במזכירות הועדה ירשם כמועד בו נתקבל הערר‪.
‫ערר לא ניתן להעביר באמצעות פקס‪/‬מייל‪.
‫‪‬‬
‫ערר שהגיע לועדה שלא במועד‪ ,‬לא יתקבל אלא אם ניתנה החלטה המאשרת ארכה להגשתו‪.
‫‪‬‬
‫לבקשת עורר‪ ,‬תמציא לו הועדה המקומית את פרטי הצדדים להליך נושא הערר‪ ,‬שמותיהם‬
‫ומעניהם תוך שלושה ימים מיום הגשת הבקשה‪.
‫‪‬‬
‫שימו לב ❤ הערר צריך להיות חתום על ידי העורר‪.
‫הנחיות אלו כלליות ומשמשות כעזר לשירות הציבור‪ ,‬בכפוף לקבוע בדין ובתקנות‪ ,‬הגובר על האמור בהנחיות‬
‫אלה‪ ,‬ההנחיות אינן ממצות ואינן כוללות את כל הוראות הדין הרלוונטיות לעניין‪ .‬כמו כן ייתכן וקיימות דרישות‬
‫נוספות בוועדות הערר השונות והן ימסרו על ידי הועדה‪.
‫הנחיות אלו אינן מהוות תחליף לייעוץ משפטי‪.
‫עמוד 3
‫אגף תקצוב ורכש‬
‫הנחיות עזר להגשת ערר על הנחיות מרחביות‬
‫הערר יוגש תוך 30ימים מיום פרסום ההנחיות המרחביות‬
.1‬הערר יוגש למזכירות ועדת הערר בכתב‪ ,‬בשישה עותקים‪ ,‬בצירוף עותקים נוספים לפי מספר‬
‫המשיבים‪.
.2‬על הערר לכלול את כל אלה‪:
.2.1‬שם העורר‪ ,‬מענו‪ ,‬מספר טלפון וטלפון נייד‪ ,‬מספר פקס וכתובת מייל (במידה ויש).
.2.2‬פרטי המשיבים‪ :‬שמותיהם ,‬מענם‪ ,‬מספר טלפון‪ ,‬מספר פקס וכתובת מייל (במידה ויש)
.2.2‬במידה והעורר מיוצג על ידי עורך דין‪ -‬שם ב"כ העורר‪ ,‬מען למסירת מסמכים‪ ,‬מספר‬
‫טלפון‪ ,‬מספר פקס‪ ,‬כתובת מייל וייפוי כוח‪.
.2.2‬פרטי הבקשה שלגביה ניתנה ההחלטה נושא הערר (פרטי המקרקעין‪ /‬הנכס‪ -‬כתובת‪ ,‬מס'
‫גוש ומס' חלקה)
.2‬פרטי ההחלטה שעליה מוגש הערר‪ ,‬והעתק מהודעת הועדה או הרשות על ההחלטה‪.
.2.1‬נימוקי הערר;
.2.2‬עיקר הראיות שהעורר מבקש להביא בפני ועדת הערר‪.
‫לתשומת ליבכם‪:
‫‪‬‬
‫הגשת הערר אינה כרוכה בתשלום אגרה‪.
‫‪‬‬
‫את הערר יש להגיש לועדת הערר במסירה ידנית או בדואר רשום ובלבד שעמד בכל דרישות‬
‫הדין להגשת הערר והגיע לועדת הערר במועד הקבוע בחוק להגשת ערר‪.
‫המועד בו נתקבל הערר בדואר רשום במזכירות הועדה ירשם כמועד בו נתקבל הערר‪.
‫ערר לא ניתן להעביר באמצעות פקס‪/‬מייל‪.
‫‪‬‬
‫לבקשת עורר‪ ,‬תמציא לו הועדה המקומית את פרטי הצדדים להליך נושא הערר‪ ,‬שמותיהם‬
‫ומעניהם תוך שלושה ימים מיום הגשת הבקשה‪.
‫‪‬‬
‫ערר שהגיע לועדה שלא במועד‪ ,‬לא יתקבל אלא אם ניתנה החלטה המאשרת ארכה להגשתו‪.
‫‪‬‬
‫יש לציין תאריך המצאת ההחלטה לידי העורר‪.
‫‪‬‬
‫יש לציין באם הערר המוגש קשור לערר קודם שהוגש בעבר‪.
‫‪‬‬
‫שימו לב ❤ הערר צריך להיות חתום על ידי העורר‪.
‫הנחיות אלו כלליות ומשמשות כעזר לשירות הציבור‪ ,‬בכפוף לקבוע בדין ובתקנות‪ ,‬הגובר על האמור בהנחיות‬
‫אלה‪ ,‬ההנחיות אינן ממצות ואינן כוללות את כל הוראות הדין הרלוונטיות לעניין‪ .‬כמו כן ייתכן וקיימות דרישות‬
‫נוספות בוועדות הערר השונות והן ימסרו על ידי הועדה‪.
‫הנחיות אלו אינן מהוות תחליף לייעוץ משפטי‪.
‫עמוד 4
‫אגף תקצוב ורכש‬
‫הנחיות אלו כלליות ומשמשות כעזר לשירות הציבור‪ ,‬בכפוף לקבוע בדין ובתקנות‪ ,‬הגובר על האמור בהנחיות‬
‫אלה‪ ,‬ההנחיות אינן ממצות ואינן כוללות את כל הוראות הדין הרלוונטיות לעניין‪ .‬כמו כן ייתכן וקיימות דרישות‬
‫נוספות בוועדות הערר השונות והן ימסרו על ידי הועדה‪.
‫הנחיות אלו אינן מהוות תחליף לייעוץ משפטי‪.
‫עמוד 5

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -17,9 +17,6 @@ dependencies = [
"rq>=1.16.0", "rq>=1.16.0",
"pillow>=10.0.0", "pillow>=10.0.0",
"google-cloud-vision>=3.7.0", "google-cloud-vision>=3.7.0",
"fastapi>=0.115.0",
"uvicorn[standard]>=0.30.0",
"httpx>=0.27.0",
] ]
[build-system] [build-system]

View File

@@ -165,13 +165,10 @@ async def document_upload_training(
decision_date: str = "", decision_date: str = "",
subject_categories: list[str] | None = None, subject_categories: list[str] | None = None,
title: str = "", title: str = "",
practice_area: str = "appeals_committee",
appeal_subtype: str = "",
) -> str: ) -> str:
"""העלאת החלטה קודמת של דפנה לקורפוס הסגנון. קטגוריות: בנייה, שימוש חורג, תכנית, היתר, הקלה, חלוקה, תמ"א 38, היטל השבחה, פיצויים 197. סוג ערר: building_permit / betterment_levy / compensation_197 (ריק = אוטומטי ממספר ההחלטה).""" """העלאת החלטה קודמת של דפנה לקורפוס הסגנון. קטגוריות: בנייה, שימוש חורג, תכנית, היתר, הקלה, חלוקה, תמ"א 38, היטל השבחה, פיצויים 197."""
return await documents.document_upload_training( return await documents.document_upload_training(
file_path, decision_number, decision_date, subject_categories, title, file_path, decision_number, decision_date, subject_categories, title,
practice_area, appeal_subtype,
) )
@@ -207,6 +204,16 @@ async def get_claims(
return await documents.get_claims(case_number, party_role) return await documents.get_claims(case_number, party_role)
@mcp.tool()
async def document_update_status(
case_number: str,
doc_title: str,
status: str,
) -> str:
"""עדכון סטטוס עיבוד מסמך. status: pending/extracted/proofread/error."""
return await documents.document_update_status(case_number, doc_title, status)
# References # References
@mcp.tool() @mcp.tool()
async def extract_references( async def extract_references(
@@ -223,14 +230,9 @@ async def search_decisions(
query: str, query: str,
limit: int = 10, limit: int = 10,
section_type: str = "", section_type: str = "",
practice_area: str = "",
appeal_subtype: str = "",
case_number: str = "",
) -> str: ) -> str:
"""חיפוש סמנטי בהחלטות קודמות ובמסמכים — מסונן לפי תחום משפטי.""" """חיפוש סמנטי בהחלטות קודמות ובמסמכים."""
return await search.search_decisions( return await search.search_decisions(query, limit, section_type)
query, limit, section_type, practice_area, appeal_subtype, case_number,
)
@mcp.tool() @mcp.tool()
@@ -247,14 +249,9 @@ async def search_case_documents(
async def find_similar_cases( async def find_similar_cases(
description: str, description: str,
limit: int = 5, limit: int = 5,
practice_area: str = "",
appeal_subtype: str = "",
case_number: str = "",
) -> str: ) -> str:
"""מציאת תיקים דומים על בסיס תיאור — מסונן לפי תחום משפטי.""" """מציאת תיקים דומים על בסיס תיאור."""
return await search.find_similar_cases( return await search.find_similar_cases(description, limit)
description, limit, practice_area, appeal_subtype, case_number,
)
# Drafting # Drafting
@@ -274,6 +271,22 @@ async def draft_section(
return await drafting.draft_section(case_number, section, instructions) return await drafting.draft_section(case_number, section, instructions)
@mcp.tool()
async def get_research_findings(case_number: str) -> str:
"""שליפת ממצאי מחקר — סיכומי פסיקה, מיפוי תכניות, ציר זמן, והמלצות.
קורא מ-research-findings.md שנוצר ע"י חוקר התקדימים.
"""
return await drafting.get_research_findings(case_number)
@mcp.tool()
async def get_full_analysis(case_number: str) -> str:
"""שליפת הניתוח המשפטי המלא — טענות, תשובות, חוזקות/חולשות, שאלות מחקר,
חקיקה, תקדימים ועמדות יו"ר. הכלי המרכזי לכותב לפני כתיבת בלוק י.
"""
return await drafting.get_full_analysis(case_number)
@mcp.tool() @mcp.tool()
async def get_chair_directions(case_number: str) -> str: async def get_chair_directions(case_number: str) -> str:
"""שליפת עמדות יו"ר הוועדה (דפנה) על סוגיות הערר כ-direction_doc לכותב. """שליפת עמדות יו"ר הוועדה (דפנה) על סוגיות הערר כ-direction_doc לכותב.
@@ -309,6 +322,15 @@ async def save_block_content(
return await drafting.save_block_content(case_number, block_id, content) return await drafting.save_block_content(case_number, block_id, content)
@mcp.tool()
async def get_decision_blocks(
case_number: str,
block_id: str = "",
) -> str:
"""שליפת בלוקים שנכתבו — תוכן, מילים, משקלות. ריק = כל הבלוקים."""
return await drafting.get_decision_blocks(case_number, block_id)
@mcp.tool() @mcp.tool()
async def validate_decision(case_number: str) -> str: async def validate_decision(case_number: str) -> str:
"""בדיקת QA — 6 בדיקות איכות על ההחלטה. אם בדיקה קריטית נכשלת — ייצוא חסום.""" """בדיקת QA — 6 בדיקות איכות על ההחלטה. אם בדיקה קריטית נכשלת — ייצוא חסום."""
@@ -322,9 +344,9 @@ async def export_docx(case_number: str, output_path: str = "") -> str:
@mcp.tool() @mcp.tool()
async def analyze_style(appeal_subtype: str = "") -> str: async def analyze_style() -> str:
"""ניתוח סגנון על קורפוס ההחלטות של דפנה. מחלץ ושומר דפוסי כתיבה. סוג ערר: building_permit / betterment_levy / compensation_197 (ריק = הכל).""" """ניתוח סגנון על קורפוס ההחלטות של דפנה. מחלץ ושומר דפוסי כתיבה."""
return await drafting.analyze_style(appeal_subtype) return await drafting.analyze_style()
@mcp.tool() @mcp.tool()

View File

@@ -20,15 +20,15 @@ from uuid import UUID
from legal_mcp import config from legal_mcp import config
from legal_mcp.services import db, embeddings, claude_session from legal_mcp.services import db, embeddings, claude_session
from legal_mcp.services.lessons import get_content_checklist, get_methodology_summary from legal_mcp.services.lessons import get_content_checklist
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
# ── Block configuration ─────────────────────────────────────────── # ── Block configuration ───────────────────────────────────────────
# Output token limits per Anthropic docs: # Output token limits per Anthropic docs (April 2026):
# Opus 4.7: up to 128K output tokens (new tokenizer — ~35% more tokens) # Opus 4.6: up to 128K output tokens
# Sonnet 4.6: up to 64K output tokens # Sonnet 4.6: up to 64K output tokens
# Streaming required when max_tokens > 21,333 # Streaming required when max_tokens > 21,333
BLOCK_CONFIG = { BLOCK_CONFIG = {
@@ -48,7 +48,7 @@ BLOCK_CONFIG = {
MODEL_MAP = { MODEL_MAP = {
"sonnet": "claude-sonnet-4-20250514", "sonnet": "claude-sonnet-4-20250514",
"opus": "claude-opus-4-7", "opus": "claude-opus-4-20250514",
} }
@@ -201,22 +201,30 @@ BLOCK_PROMPTS = {
## זהו הבלוק הקריטי ביותר — ליבת ההחלטה (ratio decidendi). ## זהו הבלוק הקריטי ביותר — ליבת ההחלטה (ratio decidendi).
## אורך נדרש: **2,000-4,000 מילים לפחות**. זהו הבלוק הארוך ביותר בהחלטה (35-50%). ## אורך נדרש: **2,000-4,000 מילים לפחות**. זהו הבלוק הארוך ביותר בהחלטה (35-50%).
{methodology_guidance} ## מתודולוגיה — CREAC:
1. **C** (Conclusion) — פתח במסקנה: "לאחר שעיינו... מצאנו כי הערר [נדחה/מתקבל]"
2. **R** (Rule) — הצג את הכלל המשפטי הרלוונטי עם ציטוט פסיקה
3. **E** (Explanation) — צטט פסיקה שמסבירה את הכלל (200-600 מילים לכל ציטוט)
4. **A** (Application) — יישם על העובדות הספציפיות של התיק
5. **C** (Conclusion) — מסקנת ביניים
## כללים קריטיים:
- **מסקנה בפתיחה** — לא בסוף
- **מענה פרטני לכל טענה** שהוצגה בבלוק ז — עבור על כל טענה ברשימה והתייחס אליה בנפרד. אל תדלג על שום טענה.
- **ציטוטי פסיקה** — צטט לפחות 3-5 פסקי דין רלוונטיים. כל ציטוט עם שם התיק המלא.
- **ללא כפילות** — הפנה לבלוקים קודמים: "כאמור בסעיף X לעיל"
- **ללא כותרות משנה** (חריג: נושאים נפרדים לחלוטין)
- מספור רציף
{content_checklist} {content_checklist}
## כללים נוספים:
- **ללא כפילות** — הפנה לבלוקים קודמים: "כאמור בסעיף X לעיל"
- **מספור רציף** — המשך מספור מהבלוק הקודם
- מותרות כותרות-משנה כשיש נושאים נפרדים לחלוטין
## כיוון מאושר (חובה): ## כיוון מאושר (חובה):
{direction_context} {direction_context}
## מבנה לפי תוצאה: ## מבנה לפי תוצאה:
{structure_guidance} {structure_guidance}
## טענות: ## טענות שצריך לענות עליהן (חובה — כל טענה חייבת מענה):
{claims_context} {claims_context}
## חומרי מקור: ## חומרי מקור:
@@ -307,15 +315,12 @@ async def write_block(
# Content checklist — tells block-yod WHAT topics to cover # Content checklist — tells block-yod WHAT topics to cover
content_checklist = "" content_checklist = ""
methodology_guidance = ""
if block_id == "block-yod": if block_id == "block-yod":
content_checklist = get_content_checklist( content_checklist = get_content_checklist(
appeal_type=case.get("appeal_type", ""), appeal_type=case.get("appeal_type", ""),
subject=case.get("subject", ""), subject=case.get("subject", ""),
subject_categories=case.get("subject_categories", []), subject_categories=case.get("subject_categories", []),
) )
# Methodology guidance — tells block-yod HOW to reason (universal, not case-specific)
methodology_guidance = get_methodology_summary()
# Format prompt — per Anthropic long-context best practices: # Format prompt — per Anthropic long-context best practices:
# Place source documents FIRST (top of prompt), instructions LAST. # Place source documents FIRST (top of prompt), instructions LAST.
@@ -331,7 +336,6 @@ async def write_block(
discussion_context=discussion_context, discussion_context=discussion_context,
structure_guidance=structure_guidance, structure_guidance=structure_guidance,
content_checklist=content_checklist, content_checklist=content_checklist,
methodology_guidance=methodology_guidance,
) )
# Restructure: sources first, then instructions # Restructure: sources first, then instructions
@@ -427,7 +431,7 @@ async def _build_claims_context(case_id: UUID) -> str:
lines.append(f"\n### {role_heb.get(current_role, current_role)}") lines.append(f"\n### {role_heb.get(current_role, current_role)}")
claim_num += 1 claim_num += 1
lines.append(f"טענה #{claim_num}: {c['claim_text'][:400]}") lines.append(f"טענה #{claim_num}: {c['claim_text'][:400]}")
lines.append(f"\n**סה\"כ {claim_num} טענות. ענה על כל טענה מהותית; טענות [bundle] — אגד; טענות [skip] — ציון קצר בלבד.**") lines.append(f"\n**סה\"כ {claim_num} טענות — חובה לענות על כל אחת.**")
return "\n".join(lines) return "\n".join(lines)
@@ -485,12 +489,17 @@ async def _build_precedents_context(case_id: UUID, block_id: str) -> str:
case = await db.get_case(case_id) case = await db.get_case(case_id)
case_number = case.get("case_number", "") if case else "" case_number = case.get("case_number", "") if case else ""
subject = case.get("subject", "") if case else "" subject = case.get("subject", "") if case else ""
practice_area = case.get("practice_area") if case else None
appeal_subtype = case.get("appeal_subtype") if case else None
query = f"דיון משפטי בנושא {subject}" if subject else "דיון משפטי ועדת ערר" query = f"דיון משפטי בנושא {subject}" if subject else "דיון משפטי ועדת ערר"
query_emb = await embeddings.embed_query(query) query_emb = await embeddings.embed_query(query)
# Search 1: paragraph_embeddings (from other decisions by Dafna) # Search 1: paragraph_embeddings (from other decisions by Dafna).
# Filter by practice_area + appeal_subtype so we don't pull a
# betterment-levy paragraph when writing a building-permit decision.
para_results = await db.search_similar_paragraphs( para_results = await db.search_similar_paragraphs(
query_embedding=query_emb, limit=10, block_type="block-yod", query_embedding=query_emb, limit=10, block_type="block-yod",
practice_area=practice_area, appeal_subtype=appeal_subtype,
) )
# Filter out same case # Filter out same case
para_results = [r for r in para_results if r.get("case_number", "") != case_number] para_results = [r for r in para_results if r.get("case_number", "") != case_number]
@@ -516,14 +525,31 @@ async def _build_precedents_context(case_id: UUID, block_id: str) -> str:
text = r["key_quote"] or r["summary"] or "" text = r["key_quote"] or r["summary"] or ""
if text: if text:
parts.append( parts.append(
f"סיקה: {r['case_number']} {r['case_name']} ({r.get('court', '')})] " f"<EFBFBD><EFBFBD>יקה: {r['case_number']} {r['case_name']} ({r.get('court', '')})] "
f"score={r['score']:.3f}\n{text[:400]}" f"score={r['score']:.3f}\n{text[:400]}"
) )
# Search 3: case_precedents (user-attached quotes by Daphna)
# These are hand-picked citations — highest priority.
attached = await db.list_case_precedents(case_id)
if attached:
parts.insert(0, "## תקדימים שצורפו ידנית ע\"י יו\"ר הוועדה\n")
for i, prec in enumerate(attached):
section = prec.get("section_id") or "כללי"
citation = prec.get("citation", "")
quote = prec.get("quote", "")
note = prec.get("chair_note", "")
entry = f"[תקדים מצורף #{i+1} — סוגיה: {section}] {citation}"
if quote:
entry += f"\nציטוט: {quote[:600]}"
if note:
entry += f"\nהערת יו\"ר: {note}"
parts.insert(i + 1, entry)
except Exception as e: except Exception as e:
logger.warning("Failed to fetch precedents: %s", e) logger.warning("Failed to fetch precedents: %s", e)
return "\n\n".join(parts) if parts else "(אין תקדימים)" return "\n\n".join(parts) if parts else "(אין תקד<EFBFBD><EFBFBD>מים)"
async def _build_style_context() -> str: async def _build_style_context() -> str:
@@ -658,17 +684,6 @@ async def get_block_context(case_id: UUID, block_id: str, instructions: str = ""
outcome = (decision or {}).get("outcome", "rejected") outcome = (decision or {}).get("outcome", "rejected")
structure_guidance = STRUCTURE_GUIDANCE.get(outcome, "") structure_guidance = STRUCTURE_GUIDANCE.get(outcome, "")
# Content checklist + methodology for block-yod
content_checklist = ""
methodology_guidance = ""
if block_id == "block-yod":
content_checklist = get_content_checklist(
appeal_type=case.get("appeal_type", ""),
subject=case.get("subject", ""),
subject_categories=case.get("subject_categories", []),
)
methodology_guidance = get_methodology_summary()
formatted_prompt = prompt_template.format( formatted_prompt = prompt_template.format(
case_context=case_context, case_context=case_context,
source_context=source_context, source_context=source_context,
@@ -679,8 +694,6 @@ async def get_block_context(case_id: UUID, block_id: str, instructions: str = ""
style_context=style_context, style_context=style_context,
discussion_context=discussion_context, discussion_context=discussion_context,
structure_guidance=structure_guidance, structure_guidance=structure_guidance,
content_checklist=content_checklist,
methodology_guidance=methodology_guidance,
) )
if instructions: if instructions:

View File

@@ -104,8 +104,6 @@ CREATE TABLE IF NOT EXISTS style_corpus (
summary TEXT DEFAULT '', summary TEXT DEFAULT '',
outcome TEXT DEFAULT '', outcome TEXT DEFAULT '',
key_principles JSONB DEFAULT '[]', key_principles JSONB DEFAULT '[]',
practice_area TEXT DEFAULT 'appeals_committee',
appeal_subtype TEXT DEFAULT '',
created_at TIMESTAMPTZ DEFAULT now() created_at TIMESTAMPTZ DEFAULT now()
); );
@@ -116,7 +114,6 @@ CREATE TABLE IF NOT EXISTS style_patterns (
frequency INTEGER DEFAULT 1, frequency INTEGER DEFAULT 1,
context TEXT DEFAULT '', context TEXT DEFAULT '',
examples JSONB DEFAULT '[]', examples JSONB DEFAULT '[]',
appeal_subtype TEXT DEFAULT '',
created_at TIMESTAMPTZ DEFAULT now() created_at TIMESTAMPTZ DEFAULT now()
); );
@@ -159,15 +156,6 @@ ALTER TABLE decisions ADD COLUMN IF NOT EXISTS outcome_reasoning TEXT DEFAULT ''
-- הרחבת cases עם appeal_type (אם לא קיים) -- הרחבת cases עם appeal_type (אם לא קיים)
ALTER TABLE cases ADD COLUMN IF NOT EXISTS appeal_type TEXT DEFAULT ''; ALTER TABLE cases ADD COLUMN IF NOT EXISTS appeal_type TEXT DEFAULT '';
ALTER TABLE cases ADD COLUMN IF NOT EXISTS practice_area TEXT DEFAULT 'appeals_committee';
ALTER TABLE cases ADD COLUMN IF NOT EXISTS appeal_subtype TEXT DEFAULT '';
-- הרחבת style_corpus עם practice_area / appeal_subtype
ALTER TABLE style_corpus ADD COLUMN IF NOT EXISTS practice_area TEXT DEFAULT 'appeals_committee';
ALTER TABLE style_corpus ADD COLUMN IF NOT EXISTS appeal_subtype TEXT DEFAULT '';
-- הרחבת style_patterns עם appeal_subtype לניתוח סגנון נפרד לכל סוג ערר
ALTER TABLE style_patterns ADD COLUMN IF NOT EXISTS appeal_subtype TEXT DEFAULT '';
-- טבלת qa_results -- טבלת qa_results
CREATE TABLE IF NOT EXISTS qa_results ( CREATE TABLE IF NOT EXISTS qa_results (
@@ -212,6 +200,110 @@ CREATE TABLE IF NOT EXISTS appeal_type_rules (
ALTER TABLE decision_blocks ADD COLUMN IF NOT EXISTS image_placeholders JSONB DEFAULT '[]'; ALTER TABLE decision_blocks ADD COLUMN IF NOT EXISTS image_placeholders JSONB DEFAULT '[]';
""" """
# ── Phase 4: Practice area separation (multi-tenant axis) ──────────
SCHEMA_V4_SQL = """
-- ═══════════════════════════════════════════════════════════════════
-- practice_area = top-level legal domain (multi-tenant axis):
-- appeals_committee | national_insurance | labor_law | ...
-- appeal_subtype = refines within practice_area:
-- building_permit | betterment_levy | compensation_197 | unknown
-- Both columns are denormalized to documents/chunks/decisions/style_corpus
-- so vector searches can filter without expensive JOINs.
-- ═══════════════════════════════════════════════════════════════════
ALTER TABLE cases ADD COLUMN IF NOT EXISTS practice_area TEXT;
ALTER TABLE cases ADD COLUMN IF NOT EXISTS appeal_subtype TEXT;
ALTER TABLE documents ADD COLUMN IF NOT EXISTS practice_area TEXT;
ALTER TABLE documents ADD COLUMN IF NOT EXISTS appeal_subtype TEXT;
ALTER TABLE document_chunks ADD COLUMN IF NOT EXISTS practice_area TEXT;
ALTER TABLE document_chunks ADD COLUMN IF NOT EXISTS appeal_subtype TEXT;
ALTER TABLE decisions ADD COLUMN IF NOT EXISTS practice_area TEXT;
ALTER TABLE decisions ADD COLUMN IF NOT EXISTS appeal_subtype TEXT;
ALTER TABLE style_corpus ADD COLUMN IF NOT EXISTS practice_area TEXT;
ALTER TABLE style_corpus ADD COLUMN IF NOT EXISTS appeal_subtype TEXT;
CREATE INDEX IF NOT EXISTS idx_cases_practice
ON cases(practice_area, appeal_subtype);
CREATE INDEX IF NOT EXISTS idx_chunks_practice
ON document_chunks(practice_area);
CREATE INDEX IF NOT EXISTS idx_corpus_practice
ON style_corpus(practice_area, appeal_subtype);
CREATE INDEX IF NOT EXISTS idx_decisions_practice
ON decisions(practice_area);
-- Backfill (idempotent — only fills NULLs)
UPDATE cases SET practice_area = 'appeals_committee' WHERE practice_area IS NULL;
UPDATE cases SET appeal_subtype = CASE
WHEN case_number ~ '^1[0-9]{3}' THEN 'building_permit'
WHEN case_number ~ '^8[0-9]{3}' THEN 'betterment_levy'
WHEN case_number ~ '^9[0-9]{3}' THEN 'compensation_197'
ELSE 'unknown'
END WHERE appeal_subtype IS NULL;
UPDATE documents d
SET practice_area = c.practice_area, appeal_subtype = c.appeal_subtype
FROM cases c
WHERE d.case_id = c.id AND d.practice_area IS NULL;
UPDATE document_chunks dc
SET practice_area = c.practice_area, appeal_subtype = c.appeal_subtype
FROM cases c
WHERE dc.case_id = c.id AND dc.practice_area IS NULL;
UPDATE decisions de
SET practice_area = c.practice_area, appeal_subtype = c.appeal_subtype
FROM cases c
WHERE de.case_id = c.id AND de.practice_area IS NULL;
-- All existing style_corpus entries are דפנה's appeals-committee decisions
UPDATE style_corpus SET practice_area = 'appeals_committee' WHERE practice_area IS NULL;
-- Training corpus documents/chunks have case_id = NULL. All historical
-- training material is from דפנה's appeals committee, so default them.
UPDATE documents SET practice_area = 'appeals_committee'
WHERE case_id IS NULL AND practice_area IS NULL;
UPDATE document_chunks dc
SET practice_area = d.practice_area, appeal_subtype = d.appeal_subtype
FROM documents d
WHERE dc.document_id = d.id AND dc.practice_area IS NULL;
"""
# ── Phase 5: case_precedents (user-attached legal quotes) ──────────
SCHEMA_V5_SQL = """
-- ═══════════════════════════════════════════════════════════════════
-- case_precedents: legal support the chair attaches to a case / section
-- during the compose phase. Self-contained — quote + citation are
-- stored inline, with an optional FK to an archived PDF in documents.
-- Not linked to case_law (which has UNIQUE(case_number)) to keep the
-- citation as free-text. A backfill pass into case_law is a future
-- follow-up once the UI stabilizes.
-- ═══════════════════════════════════════════════════════════════════
CREATE TABLE IF NOT EXISTS case_precedents (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
case_id UUID NOT NULL REFERENCES cases(id) ON DELETE CASCADE,
section_id TEXT, -- NULL = case-level
-- else "threshold_1" / "issue_3"
quote TEXT NOT NULL,
citation TEXT NOT NULL, -- free-text "מראה מקום"
chair_note TEXT DEFAULT '',
pdf_document_id UUID REFERENCES documents(id) ON DELETE SET NULL,
practice_area TEXT, -- denormalized from cases
created_at TIMESTAMPTZ DEFAULT now(),
updated_at TIMESTAMPTZ DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_case_precedents_case
ON case_precedents(case_id, section_id);
CREATE INDEX IF NOT EXISTS idx_case_precedents_library
ON case_precedents(citation);
CREATE INDEX IF NOT EXISTS idx_case_precedents_area
ON case_precedents(practice_area);
"""
# ── Phase 2: Decision + Knowledge + RAG layers ──────────────────── # ── Phase 2: Decision + Knowledge + RAG layers ────────────────────
SCHEMA_V2_SQL = """ SCHEMA_V2_SQL = """
@@ -386,16 +478,6 @@ CREATE TABLE IF NOT EXISTS chair_feedback (
created_at TIMESTAMPTZ DEFAULT now() created_at TIMESTAMPTZ DEFAULT now()
); );
CREATE TABLE IF NOT EXISTS tag_company_mappings (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
tag TEXT NOT NULL, -- appeal_subtype value (e.g. building_permit)
tag_label TEXT NOT NULL DEFAULT '', -- Hebrew display label
company_id TEXT NOT NULL, -- Paperclip company UUID
company_name TEXT NOT NULL DEFAULT '', -- cached company name for display
created_at TIMESTAMPTZ DEFAULT now(),
UNIQUE(tag, company_id)
);
-- ═══════════════════════════════════════════════════════════════════ -- ═══════════════════════════════════════════════════════════════════
-- Indexes -- Indexes
-- ═══════════════════════════════════════════════════════════════════ -- ═══════════════════════════════════════════════════════════════════
@@ -419,51 +501,6 @@ CREATE INDEX IF NOT EXISTS idx_case_law_embeddings_vec
""" """
# ── Phase 4: Methodology alignment ──────────────────────────────
SCHEMA_V4_SQL = """
-- ═══════════════════════════════════════════════════════════════════
-- V4: Methodology alignment (decision-methodology.md)
-- ═══════════════════════════════════════════════════════════════════
-- claims: טיפול בטענות (bundle/skip) + סוג טענה
ALTER TABLE claims ADD COLUMN IF NOT EXISTS claim_type TEXT DEFAULT 'claim';
-- claim / response / reply
ALTER TABLE claims ADD COLUMN IF NOT EXISTS claim_handling TEXT DEFAULT 'address';
-- address (דיון מלא) / bundle (קיבוץ) / skip (דילוג)
ALTER TABLE claims ADD COLUMN IF NOT EXISTS bundle_group TEXT DEFAULT '';
-- שם הקבוצה לקיבוץ (למשל "פגמים פרוצדורליים")
ALTER TABLE claims ADD COLUMN IF NOT EXISTS handling_reason TEXT DEFAULT '';
-- נימוק לדילוג/קיבוץ (למשל "נבחנה ולא מצאנו ממש")
-- cases: תקן ביקורת + קטגוריות נושא
ALTER TABLE cases ADD COLUMN IF NOT EXISTS standard_of_review TEXT DEFAULT '';
-- "שיקול דעת תכנוני עצמאי" / "בחינת שומה מכרעת" / ...
ALTER TABLE cases ADD COLUMN IF NOT EXISTS subject_categories JSONB DEFAULT '[]';
-- ["חניה", "קווי בניין", "גובה", "שימוש חורג", ...]
-- case_law: רמת תקדים + מעמד
ALTER TABLE case_law ADD COLUMN IF NOT EXISTS precedent_level TEXT DEFAULT '';
-- עליון / מנהלי / ועדת ערר ארצית / ועדת ערר מחוזית
ALTER TABLE case_law ADD COLUMN IF NOT EXISTS is_binding BOOLEAN DEFAULT TRUE;
-- הלכה מחייבת (true) / אמרת אגב (false)
ALTER TABLE case_law ADD COLUMN IF NOT EXISTS creac_role TEXT DEFAULT '';
-- rule (הנחה עליונה) / explanation (הרחבה) / analogy (אנלוגיה)
-- decisions: סדר סוגיות + תקן ביקורת
ALTER TABLE decisions ADD COLUMN IF NOT EXISTS issue_order JSONB DEFAULT '[]';
-- סדר הסוגיות שנקבע ע"י המנצח: [{"title": "...", "type": "threshold/dispositive/secondary"}]
ALTER TABLE decisions ADD COLUMN IF NOT EXISTS claim_handling JSONB DEFAULT '{}';
-- {"overrides": [{"claim_id": "...", "handling": "bundle", "group": "..."}]}
-- indexes
CREATE INDEX IF NOT EXISTS idx_claims_handling ON claims(claim_handling);
CREATE INDEX IF NOT EXISTS idx_claims_type ON claims(claim_type);
CREATE INDEX IF NOT EXISTS idx_case_law_level ON case_law(precedent_level);
"""
async def init_schema() -> None: async def init_schema() -> None:
pool = await get_pool() pool = await get_pool()
async with pool.acquire() as conn: async with pool.acquire() as conn:
@@ -472,7 +509,8 @@ async def init_schema() -> None:
await conn.execute(SCHEMA_V2_SQL) await conn.execute(SCHEMA_V2_SQL)
await conn.execute(SCHEMA_V3_SQL) await conn.execute(SCHEMA_V3_SQL)
await conn.execute(SCHEMA_V4_SQL) await conn.execute(SCHEMA_V4_SQL)
logger.info("Database schema initialized (v1 + v2 + v3 + v4)") await conn.execute(SCHEMA_V5_SQL)
logger.info("Database schema initialized (v1 + v2 + v3 + v4 + v5)")
# ── Case CRUD ─────────────────────────────────────────────────────── # ── Case CRUD ───────────────────────────────────────────────────────
@@ -490,7 +528,7 @@ async def create_case(
notes: str = "", notes: str = "",
expected_outcome: str = "", expected_outcome: str = "",
practice_area: str = "appeals_committee", practice_area: str = "appeals_committee",
appeal_subtype: str = "", appeal_subtype: str | None = None,
) -> dict: ) -> dict:
pool = await get_pool() pool = await get_pool()
case_id = uuid4() case_id = uuid4()
@@ -511,6 +549,30 @@ async def create_case(
return await get_case(case_id) return await get_case(case_id)
async def get_case_practice_area(case_id: UUID) -> tuple[str | None, str | None]:
"""Return (practice_area, appeal_subtype) for a case, or (None, None) if missing."""
pool = await get_pool()
async with pool.acquire() as conn:
row = await conn.fetchrow(
"SELECT practice_area, appeal_subtype FROM cases WHERE id = $1", case_id
)
if row is None:
return None, None
return row["practice_area"], row["appeal_subtype"]
async def get_case_practice_area_by_number(case_number: str) -> tuple[str | None, str | None]:
pool = await get_pool()
async with pool.acquire() as conn:
row = await conn.fetchrow(
"SELECT practice_area, appeal_subtype FROM cases WHERE case_number = $1",
case_number,
)
if row is None:
return None, None
return row["practice_area"], row["appeal_subtype"]
async def get_case(case_id: UUID) -> dict | None: async def get_case(case_id: UUID) -> dict | None:
pool = await get_pool() pool = await get_pool()
async with pool.acquire() as conn: async with pool.acquire() as conn:
@@ -546,6 +608,16 @@ async def list_cases(status: str | None = None, limit: int = 50) -> list[dict]:
return [_row_to_case(r) for r in rows] return [_row_to_case(r) for r in rows]
async def delete_case(case_id: UUID) -> bool:
"""Delete a case. Dependent rows in documents/document_chunks/qa_results
cascade automatically (schema-level ON DELETE CASCADE); audit_log rows
nullify their case_id reference. Returns True if a row was deleted."""
pool = await get_pool()
async with pool.acquire() as conn:
result = await conn.execute("DELETE FROM cases WHERE id = $1", case_id)
return result.endswith(" 1")
async def update_case(case_id: UUID, **fields) -> dict | None: async def update_case(case_id: UUID, **fields) -> dict | None:
if not fields: if not fields:
return await get_case(case_id) return await get_case(case_id)
@@ -576,19 +648,34 @@ def _row_to_case(row: asyncpg.Record) -> dict:
# ── Document CRUD ─────────────────────────────────────────────────── # ── Document CRUD ───────────────────────────────────────────────────
async def create_document( async def create_document(
case_id: UUID, case_id: UUID | None,
doc_type: str, doc_type: str,
title: str, title: str,
file_path: str, file_path: str,
page_count: int | None = None, page_count: int | None = None,
practice_area: str | None = None,
appeal_subtype: str | None = None,
) -> dict: ) -> dict:
pool = await get_pool() pool = await get_pool()
doc_id = uuid4() doc_id = uuid4()
async with pool.acquire() as conn: async with pool.acquire() as conn:
# If practice_area not explicitly given, inherit from the parent case
# (for case-bound documents). Training corpus passes case_id=None and
# provides the practice_area directly.
if practice_area is None and case_id is not None:
case_row = await conn.fetchrow(
"SELECT practice_area, appeal_subtype FROM cases WHERE id = $1",
case_id,
)
if case_row:
practice_area = case_row["practice_area"]
appeal_subtype = case_row["appeal_subtype"]
await conn.execute( await conn.execute(
"""INSERT INTO documents (id, case_id, doc_type, title, file_path, page_count) """INSERT INTO documents (id, case_id, doc_type, title, file_path,
VALUES ($1, $2, $3, $4, $5, $6)""", page_count, practice_area, appeal_subtype)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)""",
doc_id, case_id, doc_type, title, file_path, page_count, doc_id, case_id, doc_type, title, file_path, page_count,
practice_area, appeal_subtype,
) )
row = await conn.fetchrow("SELECT * FROM documents WHERE id = $1", doc_id) row = await conn.fetchrow("SELECT * FROM documents WHERE id = $1", doc_id)
return _row_to_doc(row) return _row_to_doc(row)
@@ -644,6 +731,113 @@ def _row_to_doc(row: asyncpg.Record) -> dict:
return d return d
# ── case_precedents CRUD ───────────────────────────────────────────
def _row_to_precedent(row: asyncpg.Record) -> dict:
d = dict(row)
for k in ("id", "case_id"):
if d.get(k) is not None:
d[k] = str(d[k])
if d.get("pdf_document_id") is not None:
d["pdf_document_id"] = str(d["pdf_document_id"])
for ts in ("created_at", "updated_at"):
if d.get(ts) is not None:
d[ts] = d[ts].isoformat()
return d
async def create_case_precedent(
case_id: UUID,
quote: str,
citation: str,
section_id: str | None = None,
chair_note: str = "",
pdf_document_id: UUID | None = None,
practice_area: str | None = None,
) -> dict:
"""Insert a new attached precedent. practice_area is inherited from
the parent case when not explicitly supplied, so the cross-case
library search can filter without a JOIN."""
pool = await get_pool()
async with pool.acquire() as conn:
if practice_area is None:
row = await conn.fetchrow(
"SELECT practice_area FROM cases WHERE id = $1", case_id
)
practice_area = row["practice_area"] if row else None
inserted = await conn.fetchrow(
"""INSERT INTO case_precedents
(case_id, section_id, quote, citation, chair_note,
pdf_document_id, practice_area)
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING *""",
case_id, section_id, quote, citation, chair_note,
pdf_document_id, practice_area,
)
return _row_to_precedent(inserted)
async def list_case_precedents(case_id: UUID) -> list[dict]:
pool = await get_pool()
async with pool.acquire() as conn:
rows = await conn.fetch(
"SELECT * FROM case_precedents WHERE case_id = $1 "
"ORDER BY section_id NULLS FIRST, created_at",
case_id,
)
return [_row_to_precedent(r) for r in rows]
async def delete_case_precedent(precedent_id: UUID) -> bool:
pool = await get_pool()
async with pool.acquire() as conn:
result = await conn.execute(
"DELETE FROM case_precedents WHERE id = $1", precedent_id
)
return result.endswith(" 1")
async def search_precedent_library(
query: str, practice_area: str = "", limit: int = 10,
) -> list[dict]:
"""Cross-case typeahead for the citation field. Returns one row per
distinct citation so the user sees each precedent once even if they
previously attached it to multiple cases/sections. No embeddings —
simple ILIKE is fine at this scale."""
pool = await get_pool()
pattern = f"%{query}%"
async with pool.acquire() as conn:
if practice_area:
rows = await conn.fetch(
"""SELECT DISTINCT ON (citation)
id, citation, quote, chair_note, practice_area, created_at
FROM case_precedents
WHERE practice_area = $1
AND (citation ILIKE $2 OR quote ILIKE $2)
ORDER BY citation, created_at DESC
LIMIT $3""",
practice_area, pattern, limit,
)
else:
rows = await conn.fetch(
"""SELECT DISTINCT ON (citation)
id, citation, quote, chair_note, practice_area, created_at
FROM case_precedents
WHERE citation ILIKE $1 OR quote ILIKE $1
ORDER BY citation, created_at DESC
LIMIT $2""",
pattern, limit,
)
out = []
for r in rows:
d = dict(r)
d["id"] = str(d["id"])
if d.get("created_at"):
d["created_at"] = d["created_at"].isoformat()
out.append(d)
return out
# ── Claims ───────────────────────────────────────────────────────── # ── Claims ─────────────────────────────────────────────────────────
async def store_claims(case_id: UUID, claims: list[dict], source_document: str = "") -> int: async def store_claims(case_id: UUID, claims: list[dict], source_document: str = "") -> int:
@@ -710,12 +904,20 @@ async def create_decision(
) )
version = (existing["version"] + 1) if existing else 1 version = (existing["version"] + 1) if existing else 1
case_row = await conn.fetchrow(
"SELECT practice_area, appeal_subtype FROM cases WHERE id = $1", case_id
)
practice_area = case_row["practice_area"] if case_row else None
appeal_subtype = case_row["appeal_subtype"] if case_row else None
await conn.execute( await conn.execute(
"""INSERT INTO decisions (id, case_id, version, outcome, outcome_summary, """INSERT INTO decisions (id, case_id, version, outcome, outcome_summary,
outcome_reasoning, direction_doc) outcome_reasoning, direction_doc,
VALUES ($1, $2, $3, $4, $5, $6, $7)""", practice_area, appeal_subtype)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)""",
decision_id, case_id, version, outcome, outcome_summary, decision_id, case_id, version, outcome, outcome_summary,
outcome_reasoning, json.dumps(direction_doc) if direction_doc else None, outcome_reasoning, json.dumps(direction_doc) if direction_doc else None,
practice_area, appeal_subtype,
) )
return await get_decision(decision_id) return await get_decision(decision_id)
@@ -773,22 +975,6 @@ async def update_decision(decision_id: UUID, **fields) -> None:
await conn.execute(sql, decision_id, *values) await conn.execute(sql, decision_id, *values)
# ── Document deletion ──────────────────────────────────────────────
async def delete_document(doc_id: UUID) -> bool:
"""Delete a document and all its chunks. Returns True if deleted."""
pool = await get_pool()
async with pool.acquire() as conn:
async with conn.transaction():
await conn.execute(
"DELETE FROM document_chunks WHERE document_id = $1", doc_id
)
result = await conn.execute(
"DELETE FROM documents WHERE id = $1", doc_id
)
return int(result.split()[-1]) > 0
# ── Chunks & Vectors ─────────────────────────────────────────────── # ── Chunks & Vectors ───────────────────────────────────────────────
async def delete_document_chunks(document_id: UUID) -> int: async def delete_document_chunks(document_id: UUID) -> int:
@@ -805,12 +991,37 @@ async def store_chunks(
document_id: UUID, document_id: UUID,
case_id: UUID | None, case_id: UUID | None,
chunks: list[dict], chunks: list[dict],
practice_area: str | None = None,
appeal_subtype: str | None = None,
) -> int: ) -> int:
"""Store document chunks with embeddings. Each chunk dict has: """Store document chunks with embeddings. Each chunk dict has:
content, section_type, embedding (list[float]), page_number, chunk_index content, section_type, embedding (list[float]), page_number, chunk_index.
practice_area defaults to the parent case's value, or — when case_id is
None (training corpus) — falls back to the parent document's value so
vector search can still filter cleanly.
""" """
pool = await get_pool() pool = await get_pool()
async with pool.acquire() as conn: async with pool.acquire() as conn:
# Resolve practice_area in priority order: explicit > case > document.
if practice_area is None:
if case_id is not None:
case_row = await conn.fetchrow(
"SELECT practice_area, appeal_subtype FROM cases WHERE id = $1",
case_id,
)
if case_row:
practice_area = case_row["practice_area"]
appeal_subtype = case_row["appeal_subtype"]
if practice_area is None:
doc_row = await conn.fetchrow(
"SELECT practice_area, appeal_subtype FROM documents WHERE id = $1",
document_id,
)
if doc_row:
practice_area = doc_row["practice_area"]
appeal_subtype = doc_row["appeal_subtype"]
# Delete existing chunks for this document # Delete existing chunks for this document
await conn.execute( await conn.execute(
"DELETE FROM document_chunks WHERE document_id = $1", document_id "DELETE FROM document_chunks WHERE document_id = $1", document_id
@@ -818,14 +1029,16 @@ async def store_chunks(
for chunk in chunks: for chunk in chunks:
await conn.execute( await conn.execute(
"""INSERT INTO document_chunks """INSERT INTO document_chunks
(document_id, case_id, chunk_index, content, section_type, embedding, page_number) (document_id, case_id, chunk_index, content, section_type,
VALUES ($1, $2, $3, $4, $5, $6, $7)""", embedding, page_number, practice_area, appeal_subtype)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)""",
document_id, case_id, document_id, case_id,
chunk["chunk_index"], chunk["chunk_index"],
chunk["content"], chunk["content"],
chunk.get("section_type", "other"), chunk.get("section_type", "other"),
chunk["embedding"], chunk["embedding"],
chunk.get("page_number"), chunk.get("page_number"),
practice_area, appeal_subtype,
) )
return len(chunks) return len(chunks)
@@ -838,7 +1051,12 @@ async def search_similar(
practice_area: str | None = None, practice_area: str | None = None,
appeal_subtype: str | None = None, appeal_subtype: str | None = None,
) -> list[dict]: ) -> list[dict]:
"""Cosine similarity search on document chunks.""" """Cosine similarity search on document chunks.
Filter by practice_area to keep precedents from the same legal domain
(e.g. don't surface betterment-levy chunks when working on building
permits). Uses the denormalized column on document_chunks — no JOIN.
"""
pool = await get_pool() pool = await get_pool()
conditions = [] conditions = []
params: list = [query_embedding, limit] params: list = [query_embedding, limit]
@@ -853,11 +1071,11 @@ async def search_similar(
params.append(section_type) params.append(section_type)
param_idx += 1 param_idx += 1
if practice_area: if practice_area:
conditions.append(f"c.practice_area = ${param_idx}") conditions.append(f"dc.practice_area = ${param_idx}")
params.append(practice_area) params.append(practice_area)
param_idx += 1 param_idx += 1
if appeal_subtype: if appeal_subtype:
conditions.append(f"c.appeal_subtype = ${param_idx}") conditions.append(f"dc.appeal_subtype = ${param_idx}")
params.append(appeal_subtype) params.append(appeal_subtype)
param_idx += 1 param_idx += 1
@@ -893,7 +1111,7 @@ async def add_to_style_corpus(
outcome: str = "", outcome: str = "",
key_principles: list[str] | None = None, key_principles: list[str] | None = None,
practice_area: str = "appeals_committee", practice_area: str = "appeals_committee",
appeal_subtype: str = "", appeal_subtype: str | None = None,
) -> UUID: ) -> UUID:
pool = await get_pool() pool = await get_pool()
corpus_id = uuid4() corpus_id = uuid4()
@@ -977,14 +1195,12 @@ async def upsert_style_pattern(
pattern_text: str, pattern_text: str,
context: str = "", context: str = "",
examples: list[str] | None = None, examples: list[str] | None = None,
appeal_subtype: str = "",
) -> None: ) -> None:
pool = await get_pool() pool = await get_pool()
async with pool.acquire() as conn: async with pool.acquire() as conn:
existing = await conn.fetchrow( existing = await conn.fetchrow(
"SELECT id, frequency FROM style_patterns " "SELECT id, frequency FROM style_patterns WHERE pattern_type = $1 AND pattern_text = $2",
"WHERE pattern_type = $1 AND pattern_text = $2 AND appeal_subtype = $3", pattern_type, pattern_text,
pattern_type, pattern_text, appeal_subtype,
) )
if existing: if existing:
await conn.execute( await conn.execute(
@@ -993,26 +1209,17 @@ async def upsert_style_pattern(
) )
else: else:
await conn.execute( await conn.execute(
"""INSERT INTO style_patterns (pattern_type, pattern_text, context, examples, appeal_subtype) """INSERT INTO style_patterns (pattern_type, pattern_text, context, examples)
VALUES ($1, $2, $3, $4, $5)""", VALUES ($1, $2, $3, $4)""",
pattern_type, pattern_text, context, pattern_type, pattern_text, context,
json.dumps(examples or []), json.dumps(examples or []),
appeal_subtype,
) )
async def clear_style_patterns(appeal_subtype: str = "") -> None: async def clear_style_patterns() -> None:
"""Delete style patterns, optionally filtered by appeal_subtype. """Delete all existing style patterns (used before re-analysis)."""
Empty appeal_subtype = delete ALL patterns.
"""
pool = await get_pool() pool = await get_pool()
async with pool.acquire() as conn: async with pool.acquire() as conn:
if appeal_subtype:
await conn.execute(
"DELETE FROM style_patterns WHERE appeal_subtype = $1", appeal_subtype
)
else:
await conn.execute("DELETE FROM style_patterns") await conn.execute("DELETE FROM style_patterns")
@@ -1022,8 +1229,15 @@ async def search_similar_paragraphs(
query_embedding: list[float], query_embedding: list[float],
limit: int = 10, limit: int = 10,
block_type: str | None = None, block_type: str | None = None,
practice_area: str | None = None,
appeal_subtype: str | None = None,
) -> list[dict]: ) -> list[dict]:
"""Search decision paragraphs by semantic similarity.""" """Search decision paragraphs by semantic similarity.
Filtering by practice_area uses the denormalized column on `decisions`
so we don't pull, e.g., betterment-levy paragraphs when writing a
building-permit decision.
"""
pool = await get_pool() pool = await get_pool()
conditions = [] conditions = []
params: list = [query_embedding, limit] params: list = [query_embedding, limit]
@@ -1033,6 +1247,14 @@ async def search_similar_paragraphs(
conditions.append(f"db.block_id = ${param_idx}") conditions.append(f"db.block_id = ${param_idx}")
params.append(block_type) params.append(block_type)
param_idx += 1 param_idx += 1
if practice_area:
conditions.append(f"d.practice_area = ${param_idx}")
params.append(practice_area)
param_idx += 1
if appeal_subtype:
conditions.append(f"d.appeal_subtype = ${param_idx}")
params.append(appeal_subtype)
param_idx += 1
where = f"WHERE {' AND '.join(conditions)}" if conditions else "" where = f"WHERE {' AND '.join(conditions)}" if conditions else ""
@@ -1117,91 +1339,6 @@ async def search_precedents(
return results[:limit] return results[:limit]
# ── Case precedents (CRUD) ────────────────────────────────────────
async def create_case_precedent(
case_id: UUID,
quote: str,
citation: str,
section_id: str | None = None,
chair_note: str = "",
pdf_document_id: UUID | None = None,
practice_area: str | None = None,
) -> dict:
"""Insert a new precedent attached to a case."""
pool = await get_pool()
row = await pool.fetchrow(
"""
INSERT INTO case_precedents
(case_id, section_id, quote, citation, chair_note, pdf_document_id, practice_area)
VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING *
""",
case_id, section_id, quote, citation, chair_note, pdf_document_id, practice_area,
)
return dict(row)
async def list_case_precedents(case_id: UUID) -> list[dict]:
"""List all precedents attached to a case, ordered by section then creation time."""
pool = await get_pool()
rows = await pool.fetch(
"""
SELECT id, case_id, section_id, quote, citation, chair_note,
pdf_document_id, practice_area, created_at, updated_at
FROM case_precedents
WHERE case_id = $1
ORDER BY section_id NULLS LAST, created_at
""",
case_id,
)
return [dict(r) for r in rows]
async def delete_case_precedent(precedent_id: UUID) -> bool:
"""Delete a precedent attachment by ID. Returns True if deleted."""
pool = await get_pool()
result = await pool.execute(
"DELETE FROM case_precedents WHERE id = $1", precedent_id
)
return result == "DELETE 1"
async def search_precedent_library(
query: str, practice_area: str = "", limit: int = 10,
) -> list[dict]:
"""Search all precedents across cases by citation or quote text."""
pool = await get_pool()
pattern = f"%{query}%"
if practice_area:
rows = await pool.fetch(
"""
SELECT id, case_id, section_id, quote, citation, chair_note,
practice_area, created_at
FROM case_precedents
WHERE (citation ILIKE $1 OR quote ILIKE $1)
AND practice_area = $2
ORDER BY created_at DESC
LIMIT $3
""",
pattern, practice_area, limit,
)
else:
rows = await pool.fetch(
"""
SELECT id, case_id, section_id, quote, citation, chair_note,
practice_area, created_at
FROM case_precedents
WHERE citation ILIKE $1 OR quote ILIKE $1
ORDER BY created_at DESC
LIMIT $2
""",
pattern, limit,
)
return [dict(r) for r in rows]
# ── Chair feedback ──────────────────────────────────────────────── # ── Chair feedback ────────────────────────────────────────────────
async def record_chair_feedback( async def record_chair_feedback(

View File

@@ -1,8 +1,7 @@
"""Text extraction from PDF, DOCX, DOC, and RTF files. """Text extraction from PDF, DOCX, and RTF files.
Primary PDF extraction: PyMuPDF direct text (for born-digital PDFs). Primary PDF extraction: PyMuPDF direct text (for born-digital PDFs).
Fallback: Google Cloud Vision OCR (for scanned documents). Fallback: Google Cloud Vision OCR (for scanned documents).
DOC files: converted to DOCX via LibreOffice before extraction.
Post-processing: Hebrew abbreviation quote fixer. Post-processing: Hebrew abbreviation quote fixer.
""" """
@@ -11,8 +10,6 @@ from __future__ import annotations
import asyncio import asyncio
import logging import logging
import re import re
import subprocess
import tempfile
from pathlib import Path from pathlib import Path
import fitz # PyMuPDF import fitz # PyMuPDF
@@ -132,8 +129,6 @@ async def extract_text(file_path: str) -> tuple[str, int]:
return await _extract_pdf(path) return await _extract_pdf(path)
elif suffix == ".docx": elif suffix == ".docx":
return _extract_docx(path), 0 return _extract_docx(path), 0
elif suffix == ".doc":
return _extract_doc(path), 0
elif suffix == ".rtf": elif suffix == ".rtf":
return _extract_rtf(path), 0 return _extract_rtf(path), 0
elif suffix in (".txt", ".md"): elif suffix in (".txt", ".md"):
@@ -192,21 +187,6 @@ def _ocr_with_google_vision(image_bytes: bytes, page_num: int) -> str:
return _fix_hebrew_quotes(text) return _fix_hebrew_quotes(text)
def _extract_doc(path: Path) -> str:
"""Extract text from legacy .doc file by converting to .docx via LibreOffice."""
with tempfile.TemporaryDirectory() as tmp_dir:
result = subprocess.run(
["libreoffice", "--headless", "--convert-to", "docx", str(path), "--outdir", tmp_dir],
capture_output=True, text=True, timeout=120,
)
if result.returncode != 0:
raise RuntimeError(f"LibreOffice conversion failed: {result.stderr}")
docx_path = Path(tmp_dir) / f"{path.stem}.docx"
if not docx_path.exists():
raise FileNotFoundError(f"Converted file not found: {docx_path}")
return _extract_docx(docx_path)
def _extract_docx(path: Path) -> str: def _extract_docx(path: Path) -> str:
"""Extract text from DOCX file.""" """Extract text from DOCX file."""
doc = DocxDocument(str(path)) doc = DocxDocument(str(path))
@@ -218,30 +198,3 @@ def _extract_rtf(path: Path) -> str:
"""Extract text from RTF file.""" """Extract text from RTF file."""
rtf_content = path.read_text(encoding="utf-8", errors="replace") rtf_content = path.read_text(encoding="utf-8", errors="replace")
return rtf_to_text(rtf_content) return rtf_to_text(rtf_content)
# ── Nevo preamble stripping ──────────────────────────────────────
_NEVO_MARKERS = ("ספרות:", "חקיקה שאוזכרה:", "מיני-רציו:", "פסקי דין שאוזכרו:",
"כתבי עת:", "הועתק מנבו")
_DECISION_START = re.compile(
r"^(בפנינו|לפנינו|הערר שבנדון|ועדת הערר לתכנון|רקע עובדתי|עסקינן)",
re.MULTILINE,
)
def strip_nevo_preamble(text: str) -> str:
"""Remove Nevo database preamble (bibliography, legislation, mini-ratio) from decision text.
Returns the original text unchanged if no preamble is detected.
"""
head = text[:400]
if not any(marker in head for marker in _NEVO_MARKERS):
return text
m = _DECISION_START.search(text)
if m and m.start() > 50:
stripped = text[m.start():]
logger.debug("Stripped %d chars of Nevo preamble", m.start())
return stripped
return text

View File

@@ -72,14 +72,9 @@ OPENING_STRATEGIES = {
), ),
}, },
"betterment_levy": { "betterment_levy": {
"style": "direct_factual", "style": "direct_with_disclaimer",
"paragraphs": (1, 3), "paragraphs": (1, 3),
"description": ( "description": "פתיחה ישירה עם מסקנה + 'על מנת לא לצאת בחסר'",
"פתיחה ישירה ועובדתית: 'בפנינו ערר על דרישת תשלום היטל השבחה מיום [תאריך] "
"בסך של [סכום] ₪' → רקע קצר (נכס, תכנית משביחה, מימוש) → "
"תמצית טענות הצדדים (עוררים + משיבה בנפרד). "
"אין הקשר תכנוני רחב. הפתיחה = עובדות בלבד."
),
}, },
} }
@@ -106,16 +101,9 @@ SUMMARY_STRATEGIES = {
), ),
}, },
"betterment_levy": { "betterment_levy": {
"heading": "various", "heading": "סיכום",
"format": "dry_operative", "format": "numbered_hebrew_dry",
"description": ( "description": "אותיות עבריות, סיום יבש ללא פסקה חמה",
"סיום יבש ואופרטיבי. כותרת משתנה: 'סוף דבר' / 'לאור כל האמור לעיל' / ללא כותרת. "
"תוכן: 'הערר נדחה/מתקבל' + הוצאות ('כל צד ישא בהוצאותיו' / חיוב בסכום). "
"אם מתקבל: הוראות אופרטיביות (החזר, שומה מתוקנת, תנאים). "
"חתימה: 'ניתנה פה אחד היום, [תאריך עברי], [תאריך לועזי].' "
"לעיתים: 'התיק ייסגר.' / 'עומדת זכות ערר כדין.' "
"אין פסקה חמה. אין חזרה על נימוקים."
),
}, },
} }
@@ -141,12 +129,7 @@ DISCUSSION_RULES: dict[str, list[str]] = {
"מבנה ישיר: נקודות עיקריות → ניתוח → מסקנה.", "מבנה ישיר: נקודות עיקריות → ניתוח → מסקנה.",
], ],
"betterment_levy": [ "betterment_levy": [
"פתיחת דיון: מסקנה מוקדמת ('לאחר שבחנו... מצאנו כי דין הערר להידחות/להתקבל').", "מבנה ישיר עם מסקנה מוקדמת + 'על מנת לא לצאת בחסר' לנקודות נוספות.",
"תקן ביקורת: ציון רף ההתערבות בשומה מכרעת (בר\"ם 3644/13 גלר) — אבחנה בין שמאי למשפטי.",
"הצגת הלכה פסוקה: ציטוט ארוך מפס\"ד מרכזי → 'ברוח הדברים לעיל נבחן את טענות הצדדים'.",
"טיפול שיטתי: כל טענה/סוגיה בנפרד → ניתוח → מסקנת ביניים.",
"ביטויים: 'אין בידינו לקבל', 'לא מצאנו מקום להתערב', 'קביעה נכונה שאין מקום להתערב בה'.",
"'על מנת לא לצאת בחסר' — לנקודות obiter dicta בסוף הדיון.",
], ],
} }
@@ -465,41 +448,26 @@ CONTENT_CHECKLISTS: dict[str, str] = {
""", """,
"betterment_levy": """## צ'קליסט תוכן — ערר היטל השבחה "betterment_levy": """## צ'קליסט תוכן — ערר היטל השבחה
מבוסס על ניתוח 26 החלטות של דפנה תמיר (קורפוס CMPA, אפריל 2026). ⚠️ שים לב: אין עדיין החלטות היטל השבחה בקורפוס האימון.
הצ'קליסט הזה מבוסס על ידע כללי — לא על ניתוח ספציפי של סגנון דפנה.
### א. תקן ביקורת (חובה בפתיחת הדיון) ### א. המסגרת הנורמטיבית
- ציין את רף ההתערבות: "ועדת הערר תיטה לאמץ את חוות דעתו של השמאי..."
- אבחנה: התערבות מצומצמת בעניינים שמאיים-מקצועיים, התערבות רחבה בעניינים משפטיים
- הפניה ל-בר"ם 3644/13 גלר או פסיקה דומה
### ב. המסגרת הנורמטיבית
- התוספת השלישית לחוק התכנון והבנייה - התוספת השלישית לחוק התכנון והבנייה
- סעיפי הפטור הרלוונטיים (ס' 19(ג), ס' 19(ב) וכו') - אירוע מס — מה יצר את ההשבחה?
- אירוע מס — מה יצר את ההשבחה? (תכנית, היתר, מכר)
- מועד המימוש ומועד הקובע
### ג. שומה ומתודולוגיה שמאית ### ב. שומה
- שיטת השומה (שומה מכרעת / שומה מוסכמת / שמאי מייעץ) - שיטת השומה (שומה מכרעת / שמאי מייעץ)
- מבחן השימוש הטוב והיעיל (highest and best use) — מצב קודם ומצב חדש - מועד הקובע
- זכויות בנייה — לפני ואחרי (אחוזי בנייה, שטחים עיקריים, תמהיל שימושים) - זכויות בנייה — לפני ואחרי
- שווי מקרקעין — מצב קודם ומצב חדש (שיטת השוואה / יחידות תועלת)
- עלויות עודפות (חניה, מטלות ציבוריות, תשתיות)
- מקדמי זמינות, שיעורי הפקעה
### ד. שאלות משפטיות (לפי רלוונטיות) ### ג. שאלות משפטיות
- פטורים — דירת מגורים (ס' 19(ג)(1)), שטח עד 140 מ"ר, תא משפחתי - פטורים (ס' 19)
- מועד מימוש — זיכרון דברים vs הסכם מכר, העברת זכויות - מועדי תשלום
- זהות החייב — בעלים, חוכר, יזם, חברה בבעלות יזם - שיערוך
- מקרקעי ישראל — הסדרים מיוחדים (ס' 21 לתוספת השלישית)
- שומות מוסכמות — תוקף, משמעות, "בלתי נצפה מראש"
- פרשנות תכניות — ייעוד, שימושים מותרים, מדיניות ועדה מקומית
### ה. ניתוח שמאי (כשיש שומה מכרעת) ### ד. ניתוח שמאי
- האם השומה מבוססת על מסד עובדתי הולם? - האם השומה תקינה?
- האם השיטה השמאית מקובלת? - פערים בין השומות
- האם ההנחות סבירות והגיוניות?
- טעות מהותית / דופי חמור?
- פגם מינהלי (ניגוד עניינים, משוא פנים)?
""", """,
} }
@@ -551,65 +519,3 @@ def get_content_checklist(
# Default: substantive licensing # Default: substantive licensing
return CONTENT_CHECKLISTS["licensing_substantive"] return CONTENT_CHECKLISTS["licensing_substantive"]
# ── Methodology guidance (condensed from decision-methodology.md) ──
_METHODOLOGY_CORE = """## מתודולוגיה אנליטית — עקרונות מנחים לכתיבת הדיון
### מבנה סילוגיסטי לכל סוגיה
כל סוגיה נבנית כסילוגיזם: (1) הנחה עליונה = הכלל (הוראת תכנית, חוק, הלכה); (2) הנחה תחתונה = העובדות הספציפיות; (3) מסקנה. אם לא ניתן לזהות את הכלל — ההנמקה אינה מספקת. אם לא ניתן לזהות כיצד העובדות מקיימות את הכלל — ההנמקה קריפטית.
### התחל מלשון הטקסט
כשהמקרה נשלט על ידי הוראת תכנית או סעיף חוק — פתח בציטוט ההוראה. פרש מילים במשמעותן הרגילה. תן תוקף לכל מילה. אם יש עמימות — השתמש בכלי פרשנות.
### הפרד ממצא עובדתי ממסקנה משפטית
"הבניה במרחק 1.5 מטרים מגבול המגרש" = ממצא עובדתי. "חריגה זו עולה כדי סטייה ניכרת" = מסקנה משפטית. אל תערבב.
### CREAC לכל סוגיה
1. מסקנה — פתח בתשובה ("הבקשה אינה תואמת...")
2. כלל — ציטוט ההוראה
3. הרחבה — תקדים רלוונטי אחד (אם נדרש)
4. יישום — החלת הכלל על העובדות (לב ההנמקה)
5. מסקנה חוזרת — סגירה תמציתית
### Steel-Man — הצג טענה בחוזקתה לפני דחייה
לפני שדוחים טענה — הצג אותה בגרסה החזקה ביותר: "אמנם צודק העורר כי [נקודה לטובתו], אולם [הנימוק לדחייה]." טענת קש קלה להפריך אך לא משכנעת.
### טכניקת סנדוויץ' לציטוטים
כל ציטוט עטוף: משפט הקדמה (מודיע על התוכן) → ציטוט → ניתוח (מסביר כיצד רלוונטי למקרה). אל תניח שהקורא יקרא ציטוט ארוך ויפיק ממנו מסקנות בעצמו.
### נתונים, לא תיאורים
"הבקשה חורגת ב-1.5 מטרים מקו הבניין" — לא "הבקשה חורגת באופן משמעותי." מספרים, מידות, אחוזים.
### כנות לגבי קושי
כשהמקרה קשה — אמור זאת: "הדבר אינו נקי מספקות, אולם..." אל תעמיד פנים שמקרה קשה הוא קל.
### כל מילה עובדת
"לאחר ששקלנו את כלל השיקולים" — ריק, מחק. מבחן: אם מוחקים את המשפט וההחלטה לא מאבדת מידע — המשפט מיותר.
### איזון ומידתיות (כשהכלל לא נותן תשובה חד-משמעית)
כשנדרש איזון:
1. זהה אינטרסים קונקרטיים (לא "אינטרס הציבור" אלא "שמירה על אופי מגורים צמודי קרקע")
2. בחן השלכות לכל כיוון: מה קורה אם מקבלים? אם דוחים?
3. שקול השלכות מערכתיות: מה הסיגנל שנשלח למערכת?
4. ציין מה מכריע את הכף ולמה
כשמטילים מגבלה/תנאי — מבחן מידתיות: (1) תכלית ראויה?; (2) אמצעי פוגע פחות?; (3) פגיעה מידתית ביחס לתועלת?
### טיפול בטענות
- ההחלטה מנתחת שאלות — לא מתווכחת עם עו"ד. מבנה: שאלה→כלל→עובדות→מסקנה
- טענות שסומנו [bundle] ב-chair_directions: קבץ ודון יחד
- טענות שסומנו [skip] ב-chair_directions: ציון קצר בלבד
- טענות ללא סימון: ענה בנפרד עם מענה מנומק
- טענה מרכזית של הצד המפסיד חייבת מענה Steel-Man
- מיקום ההתמודדות עם טענות נגדיות: באמצע הדיון בסוגיה (לא בהתחלה ולא בסוף)
"""
def get_methodology_summary() -> str:
"""Return the condensed methodology guidance — always the same, always complete.
The methodology is universal: it teaches HOW to think, not WHAT to discuss.
Case-specific content (parking, building lines, significant deviation) belongs
in the content checklists, not here.
"""
return _METHODOLOGY_CORE

View File

@@ -43,17 +43,14 @@ SUBTYPES_BY_AREA: dict[str, set[str]] = {
# ── Derivation ───────────────────────────────────────────────────── # ── Derivation ─────────────────────────────────────────────────────
_FIRST_DIGIT = re.compile(r"^\s*(\d)")
_APPEALS_COMMITTEE_DIGIT_TO_SUBTYPE = { _APPEALS_COMMITTEE_DIGIT_TO_SUBTYPE = {
"1": "building_permit", "1": "building_permit",
"8": "betterment_levy", "8": "betterment_levy",
"9": "compensation_197", "9": "compensation_197",
} }
# Match the case number (last numeric group) in formats like:
# ARAR-25-8126, ARAR-24-01-8007-33, 8126/25, 1170, ערר 1024-25
_CASE_NUM = re.compile(r"(?:ARAR[-\s]*\d{2}[-\s]*(?:\d{2}[-\s]*)?)(\d{4})", re.IGNORECASE)
_PLAIN_NUM = re.compile(r"(\d{4})")
def derive_subtype(case_number: str, practice_area: str = DEFAULT_PRACTICE_AREA) -> str: def derive_subtype(case_number: str, practice_area: str = DEFAULT_PRACTICE_AREA) -> str:
"""Infer the appeal_subtype from case_number. """Infer the appeal_subtype from case_number.
@@ -61,20 +58,15 @@ def derive_subtype(case_number: str, practice_area: str = DEFAULT_PRACTICE_AREA)
For appeals_committee, the convention is: For appeals_committee, the convention is:
1xxx → building_permit, 8xxx → betterment_levy, 9xxx → compensation_197. 1xxx → building_permit, 8xxx → betterment_levy, 9xxx → compensation_197.
Handles multiple formats: ARAR-25-8126, 8126/25, 1170, ערר 1024-25. For other practice areas there is no public numbering convention yet,
so we return 'unknown' until a real rule is defined.
""" """
if practice_area != "appeals_committee": if practice_area != "appeals_committee":
return "unknown" return "unknown"
cn = case_number or "" m = _FIRST_DIGIT.match(case_number or "")
# Try ARAR format first (extracts the 4-digit case number after year prefix)
m = _CASE_NUM.search(cn)
if not m:
# Fallback: first 4-digit number in the string
m = _PLAIN_NUM.search(cn)
if not m: if not m:
return "unknown" return "unknown"
first_digit = m.group(1)[0] return _APPEALS_COMMITTEE_DIGIT_TO_SUBTYPE.get(m.group(1), "unknown")
return _APPEALS_COMMITTEE_DIGIT_TO_SUBTYPE.get(first_digit, "unknown")
# ── Validation ───────────────────────────────────────────────────── # ── Validation ─────────────────────────────────────────────────────

View File

@@ -26,6 +26,13 @@ CHAIR_POSITION_PLACEHOLDERS = (
"[טרם מולא]", "[טרם מולא]",
) )
# Any text starting with these prefixes is also a placeholder
# (the analyst sometimes adds explanatory text after the bracket)
CHAIR_POSITION_PLACEHOLDER_PREFIXES = (
"[ימולא",
"ימולא ע",
)
CHAIR_POSITION_LABEL = "עמדת ועדת הערר" CHAIR_POSITION_LABEL = "עמדת ועדת הערר"
# Matches "## N. title" or "## title" for main sections # Matches "## N. title" or "## title" for main sections
@@ -47,6 +54,9 @@ CASE_NUMBER_RE = re.compile(r"#\s*ניתוח.*?ערר\s+([\d/\-]+)", re.MULTILIN
DATE_RE = re.compile(r"^תאריך:\s*(.+?)\s*$", re.MULTILINE) DATE_RE = re.compile(r"^תאריך:\s*(.+?)\s*$", re.MULTILINE)
RESEARCH_FINDINGS_FILENAME = "research-findings.md"
def _is_placeholder(text: str) -> bool: def _is_placeholder(text: str) -> bool:
"""Check if a field value is one of the placeholder strings (empty).""" """Check if a field value is one of the placeholder strings (empty)."""
stripped = text.strip() stripped = text.strip()
@@ -55,6 +65,9 @@ def _is_placeholder(text: str) -> bool:
for ph in CHAIR_POSITION_PLACEHOLDERS: for ph in CHAIR_POSITION_PLACEHOLDERS:
if ph in stripped: if ph in stripped:
return True return True
for prefix in CHAIR_POSITION_PLACEHOLDER_PREFIXES:
if stripped.startswith(prefix):
return True
return False return False
@@ -434,3 +447,199 @@ def extract_chair_directions(file_path: Path) -> dict[str, Any]:
"threshold_claims": threshold, "threshold_claims": threshold,
"issues": issues, "issues": issues,
} }
# ── Full analysis extraction (for legal-writer) ──────────────────
# Map Hebrew field labels → stable English keys for JSON output
_FIELD_KEY_MAP = {
"טענה": "claims",
"טענה (claim)": "claims",
"טענות": "claims",
"תשובה": "responses",
"תשובה (response)": "responses",
"תשובות": "responses",
"תגובה": "replies",
"תגובה (reply)": "replies",
"תגובות": "replies",
# Analyst sometimes appends party name to the label
# e.g. "תגובה (reply — קובר)" — catch the pattern dynamically below
"ניתוח אסטרטגי": "strategic_analysis",
"חוזקות": "strengths",
"חולשות": "weaknesses",
"הזדמנויות": "opportunities",
"שאלות משפטיות": "legal_questions",
"חיפוש תקדימים": "precedent_search",
"חקיקה רלוונטית": "relevant_legislation",
"תקדימים מהקורפוס הפנימי": "internal_precedents",
}
def _fields_to_dict(fields: list[dict]) -> dict[str, str]:
"""Convert ordered field list to a dict with stable English keys.
Unknown labels are kept as-is (Hebrew) so no data is lost.
Handles dynamic labels like "תגובה (reply — קובר)" by matching prefix.
"""
result: dict[str, str] = {}
for f in fields:
label = f["label"]
key = _FIELD_KEY_MAP.get(label)
if key is None:
# Try prefix matching for dynamic labels (e.g. "תגובה (reply — name)")
if label.startswith("תגובה"):
key = "replies"
elif label.startswith("טענה"):
key = "claims"
elif label.startswith("תשובה"):
key = "responses"
else:
key = label
result[key] = f["content"]
return result
def extract_full_analysis(file_path: Path) -> dict[str, Any]:
"""Extract the complete strategic analysis from analysis-and-research.md.
Unlike extract_chair_directions (which returns only chair positions),
this returns ALL fields per issue: claims, responses, replies,
strengths/weaknesses/opportunities, legal questions, legislation,
and internal precedents — everything the legal-writer needs to
produce block-yod (discussion).
Returns the same envelope as extract_chair_directions (status, counts)
plus full field data in each item.
"""
if not file_path.exists():
return {
"file_exists": False,
"status": "missing",
"error": "analysis-and-research.md not found",
"procedural_background": "",
"agreed_facts": "",
"disputed_facts": "",
"conclusions": "",
"threshold_claims": [],
"issues": [],
"total_items": 0,
"filled_count": 0,
"empty_count": 0,
}
parsed = parse(file_path)
def enrich_item(item: dict) -> dict:
"""Return full item with all fields as a flat dict."""
enriched = {
"id": item["id"],
"number": item["number"],
"title": item["title"],
"direction": item.get("chair_position", "") or "",
}
# Add all extracted fields with stable keys
enriched.update(_fields_to_dict(item.get("fields", [])))
return enriched
threshold = [enrich_item(t) for t in parsed.get("threshold_claims", [])]
issues = [enrich_item(i) for i in parsed.get("issues", [])]
all_items = threshold + issues
total = len(all_items)
filled = sum(1 for x in all_items if x["direction"].strip())
empty = total - filled
if total == 0:
status = "missing"
elif filled == 0:
status = "empty"
elif filled == total:
status = "complete"
else:
status = "partial"
return {
"file_exists": True,
"file_path": str(file_path),
"case_number": parsed.get("header", {}).get("case_number", ""),
"modified_at": parsed.get("header", {}).get("modified_at", ""),
"status": status,
"total_items": total,
"filled_count": filled,
"empty_count": empty,
"procedural_background": parsed.get("procedural_background", ""),
"agreed_facts": parsed.get("agreed_facts", ""),
"disputed_facts": parsed.get("disputed_facts", ""),
"conclusions": parsed.get("conclusions", ""),
"threshold_claims": threshold,
"issues": issues,
}
# ── Research findings extraction ──────────────────────────────────
def extract_research_findings(file_path: Path) -> dict[str, Any]:
"""Extract structured research findings from research-findings.md.
The file is produced by the legal-researcher agent and contains:
precedent summaries, plan mappings, timeline, and recommendations.
Returns a structured dict or a status-only dict if file is missing.
"""
if not file_path.exists():
return {
"file_exists": False,
"status": "missing",
"error": "research-findings.md not found",
}
content = file_path.read_text(encoding="utf-8")
stat = file_path.stat()
mtime_iso = datetime.fromtimestamp(stat.st_mtime).isoformat()
sections = _split_main_sections(content)
result: dict[str, Any] = {
"file_exists": True,
"file_path": str(file_path),
"modified_at": mtime_iso,
"file_size": stat.st_size,
"precedent_summaries": [],
"plan_mappings": [],
"timeline": "",
"recommendations": "",
"other_sections": [],
}
for _number, title, body in sections:
title_norm = title.strip()
if "סיכום פסיקה" in title_norm or "פסיקה" in title_norm:
subs = _split_subsections(body)
for sub_title, sub_body in subs:
fields = _extract_fields(sub_body)
result["precedent_summaries"].append({
"title": sub_title,
"fields": {f["label"]: f["content"] for f in fields},
"raw": sub_body if not fields else "",
})
elif "מיפוי תכנית" in title_norm or "תכנית" in title_norm:
subs = _split_subsections(body)
for sub_title, sub_body in subs:
fields = _extract_fields(sub_body)
result["plan_mappings"].append({
"title": sub_title,
"fields": {f["label"]: f["content"] for f in fields},
"raw": sub_body if not fields else "",
})
elif "ציר זמן" in title_norm:
result["timeline"] = body
elif "המלצות" in title_norm:
result["recommendations"] = body
else:
result["other_sections"].append({
"title": title_norm,
"body": body,
})
return result

View File

@@ -109,24 +109,13 @@ SYNTHESIS_PROMPT = """\
""" """
async def analyze_corpus(appeal_subtype: str = "") -> dict: async def analyze_corpus() -> dict:
"""Analyze the style corpus and extract/update patterns. """Analyze the style corpus and extract/update patterns.
Args:
appeal_subtype: filter by appeal subtype (e.g. 'betterment_levy', 'building_permit').
Empty string = all decisions.
Returns summary of patterns found. Returns summary of patterns found.
""" """
pool = await db.get_pool() pool = await db.get_pool()
async with pool.acquire() as conn: async with pool.acquire() as conn:
if appeal_subtype:
rows = await conn.fetch(
"SELECT full_text, decision_number FROM style_corpus "
"WHERE appeal_subtype = $1 ORDER BY decision_date DESC LIMIT 20",
appeal_subtype,
)
else:
rows = await conn.fetch( rows = await conn.fetch(
"SELECT full_text, decision_number FROM style_corpus ORDER BY decision_date DESC LIMIT 20" "SELECT full_text, decision_number FROM style_corpus ORDER BY decision_date DESC LIMIT 20"
) )
@@ -134,8 +123,8 @@ async def analyze_corpus(appeal_subtype: str = "") -> dict:
if not rows: if not rows:
return {"error": "אין החלטות בקורפוס. העלה החלטות קודמות תחילה."} return {"error": "אין החלטות בקורפוס. העלה החלטות קודמות תחילה."}
# Clear old patterns for this subtype (or all if unfiltered) # Clear old patterns before re-analysis
await db.clear_style_patterns(appeal_subtype) await db.clear_style_patterns()
# Calculate token budget # Calculate token budget
total_chars = sum(len(row["full_text"]) for row in rows) total_chars = sum(len(row["full_text"]) for row in rows)
@@ -147,12 +136,12 @@ async def analyze_corpus(appeal_subtype: str = "") -> dict:
) )
if estimated_tokens < MAX_INPUT_TOKENS: if estimated_tokens < MAX_INPUT_TOKENS:
return await _analyze_single_pass(rows, appeal_subtype) return await _analyze_single_pass(rows)
else: else:
return await _analyze_multi_pass(rows, appeal_subtype) return await _analyze_multi_pass(rows)
async def _analyze_single_pass(rows, appeal_subtype: str = "") -> dict: async def _analyze_single_pass(rows) -> dict:
"""Send all decisions in a single API call.""" """Send all decisions in a single API call."""
decisions_text = "" decisions_text = ""
for row in rows: for row in rows:
@@ -164,10 +153,10 @@ async def _analyze_single_pass(rows, appeal_subtype: str = "") -> dict:
timeout=claude_session.LONG_TIMEOUT, timeout=claude_session.LONG_TIMEOUT,
) )
return await _parse_and_store_patterns(raw, len(rows), appeal_subtype) return await _parse_and_store_patterns(raw, len(rows))
async def _analyze_multi_pass(rows, appeal_subtype: str = "") -> dict: async def _analyze_multi_pass(rows) -> dict:
"""Analyze each decision individually, then synthesize patterns.""" """Analyze each decision individually, then synthesize patterns."""
all_patterns = [] all_patterns = []
@@ -197,7 +186,7 @@ async def _analyze_multi_pass(rows, appeal_subtype: str = "") -> dict:
timeout=claude_session.LONG_TIMEOUT, timeout=claude_session.LONG_TIMEOUT,
) )
return await _parse_and_store_patterns(raw, len(rows), appeal_subtype) return await _parse_and_store_patterns(raw, len(rows))
def _extract_json(response_text: str) -> list | None: def _extract_json(response_text: str) -> list | None:
@@ -248,16 +237,14 @@ def _extract_json(response_text: str) -> list | None:
return None return None
async def _parse_and_store_patterns( async def _parse_and_store_patterns(response_text: str, num_decisions: int) -> dict:
response_text: str, num_decisions: int, appeal_subtype: str = "",
) -> dict:
"""Parse Claude's response and store patterns in the database.""" """Parse Claude's response and store patterns in the database."""
patterns = _extract_json(response_text) patterns = _extract_json(response_text)
if patterns is None: if patterns is None:
return {"error": "Could not parse analysis results", "raw": response_text} return {"error": "Could not parse analysis results", "raw": response_text}
# Store patterns tagged by appeal_subtype # Store patterns
count = 0 count = 0
for pattern in patterns: for pattern in patterns:
await db.upsert_style_pattern( await db.upsert_style_pattern(
@@ -265,13 +252,11 @@ async def _parse_and_store_patterns(
pattern_text=pattern.get("text", ""), pattern_text=pattern.get("text", ""),
context=pattern.get("context", ""), context=pattern.get("context", ""),
examples=[pattern.get("example", "")], examples=[pattern.get("example", "")],
appeal_subtype=appeal_subtype,
) )
count += 1 count += 1
return { return {
"patterns_found": count, "patterns_found": count,
"decisions_analyzed": num_decisions, "decisions_analyzed": num_decisions,
"appeal_subtype": appeal_subtype or "all",
"pattern_types": list({p.get("type") for p in patterns}), "pattern_types": list({p.get("type") for p in patterns}),
} }

View File

@@ -3,107 +3,14 @@
from __future__ import annotations from __future__ import annotations
import json import json
import logging
import os
import shutil import shutil
import subprocess import subprocess
from pathlib import Path from pathlib import Path
from uuid import UUID from uuid import UUID
import httpx
from legal_mcp import config from legal_mcp import config
from legal_mcp.services import audit, db, practice_area as pa from legal_mcp.services import audit, db, practice_area as pa
logger = logging.getLogger(__name__)
GITEA_ORG = "cases"
def _gitea_host() -> str:
return os.environ.get("GITEA_HOST", "https://gitea.nautilus.marcusgroup.org")
def _gitea_token() -> str:
return os.environ.get("GITEA_ACCESS_TOKEN") or os.environ.get("GITEA_TOKEN", "")
async def _setup_gitea_remote(case_number: str, title: str, case_dir: Path) -> bool:
"""Create Gitea repo and configure git remote. Best-effort — returns False on failure."""
token = _gitea_token()
if not token:
logger.info("No GITEA_TOKEN — skipping Gitea repo creation for %s", case_number)
return False
try:
async with httpx.AsyncClient(verify=False, timeout=30) as client:
resp = await client.post(
f"{_gitea_host()}/api/v1/orgs/{GITEA_ORG}/repos",
headers={"Authorization": f"token {token}"},
json={
"name": case_number,
"description": f"ערר {case_number}{title}"[:255],
"private": True,
"auto_init": False,
},
)
if resp.status_code == 409:
resp2 = await client.get(
f"{_gitea_host()}/api/v1/repos/{GITEA_ORG}/{case_number}",
headers={"Authorization": f"token {token}"},
)
resp2.raise_for_status()
repo = resp2.json()
else:
resp.raise_for_status()
repo = resp.json()
clone_url = repo.get("clone_url", "")
if not clone_url:
return False
auth_url = clone_url.replace("https://", f"https://chaim:{token}@")
git_env = {
"GIT_AUTHOR_NAME": "Ezer Mishpati",
"GIT_AUTHOR_EMAIL": "legal@local",
"GIT_COMMITTER_NAME": "Ezer Mishpati",
"GIT_COMMITTER_EMAIL": "legal@local",
"PATH": os.environ.get("PATH", "/usr/bin:/bin"),
}
# Add or update remote
result = subprocess.run(
["git", "remote", "get-url", "origin"],
cwd=case_dir, capture_output=True, text=True,
)
if result.returncode == 0:
subprocess.run(
["git", "remote", "set-url", "origin", auth_url],
cwd=case_dir, capture_output=True, env=git_env,
)
else:
subprocess.run(
["git", "remote", "add", "origin", auth_url],
cwd=case_dir, capture_output=True, env=git_env,
)
# Push
push = subprocess.run(
["git", "push", "-u", "origin", "HEAD"],
cwd=case_dir, capture_output=True, text=True, env=git_env,
)
if push.returncode != 0:
logger.warning("Gitea push failed for %s: %s", case_number, push.stderr)
return False
logger.info("Gitea repo created and pushed for %s", case_number)
return True
except Exception as exc:
logger.warning("Gitea setup failed for %s: %s", case_number, exc)
return False
async def case_create( async def case_create(
case_number: str, case_number: str,
@@ -185,7 +92,7 @@ async def case_create(
case_dir.mkdir(parents=True, exist_ok=True) case_dir.mkdir(parents=True, exist_ok=True)
docs_dir = case_dir / "documents" docs_dir = case_dir / "documents"
docs_dir.mkdir(exist_ok=True) docs_dir.mkdir(exist_ok=True)
(docs_dir / "originals").mkdir(exist_ok=True) (docs_dir / "original").mkdir(exist_ok=True)
(docs_dir / "extracted").mkdir(exist_ok=True) (docs_dir / "extracted").mkdir(exist_ok=True)
(docs_dir / "proofread").mkdir(exist_ok=True) (docs_dir / "proofread").mkdir(exist_ok=True)
(docs_dir / "backup").mkdir(exist_ok=True) (docs_dir / "backup").mkdir(exist_ok=True)
@@ -199,8 +106,7 @@ async def case_create(
notes_file = case_dir / "notes.md" notes_file = case_dir / "notes.md"
notes_file.write_text(f"# הערות - תיק {case_number}\n\n{notes}\n") notes_file.write_text(f"# הערות - תיק {case_number}\n\n{notes}\n")
# Initialize git repo (best-effort) # Initialize git repo
try:
subprocess.run(["git", "init"], cwd=case_dir, capture_output=True) subprocess.run(["git", "init"], cwd=case_dir, capture_output=True)
subprocess.run(["git", "add", "."], cwd=case_dir, capture_output=True) subprocess.run(["git", "add", "."], cwd=case_dir, capture_output=True)
subprocess.run( subprocess.run(
@@ -211,14 +117,6 @@ async def case_create(
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
"PATH": "/usr/bin:/bin"}, "PATH": "/usr/bin:/bin"},
) )
except Exception:
pass # git not available — non-critical
# Create Gitea repo and configure remote (best-effort)
try:
await _setup_gitea_remote(case_number, title, case_dir)
except Exception:
pass # Gitea not available — non-critical
return json.dumps(case, default=str, ensure_ascii=False, indent=2) return json.dumps(case, default=str, ensure_ascii=False, indent=2)
@@ -277,26 +175,12 @@ async def case_update(
""" """
from datetime import date as date_type from datetime import date as date_type
# Ordered workflow statuses — regression protection
STATUS_ORDER = [
"new", "uploading", "processing", "documents_ready",
"analyst_verified", "research_complete", "outcome_set",
"brainstorming", "direction_approved", "analysis_enriched", "ready_for_writing",
"drafting", "qa_review", "drafted",
"exported", "reviewed", "final",
]
case = await db.get_case_by_number(case_number) case = await db.get_case_by_number(case_number)
if not case: if not case:
return f"תיק {case_number} לא נמצא." return f"תיק {case_number} לא נמצא."
fields = {} fields = {}
if status: if status:
current = case.get("status", "")
cur_idx = STATUS_ORDER.index(current) if current in STATUS_ORDER else -1
new_idx = STATUS_ORDER.index(status) if status in STATUS_ORDER else -1
# Only update if advancing or status is unknown to the order
if new_idx >= cur_idx or new_idx == -1:
fields["status"] = status fields["status"] = status
if title: if title:
fields["title"] = title fields["title"] = title
@@ -315,8 +199,7 @@ async def case_update(
updated = await db.update_case(UUID(case["id"]), **fields) updated = await db.update_case(UUID(case["id"]), **fields)
# Git commit the update (best-effort) # Git commit the update
try:
case_dir = config.find_case_dir(case_number) case_dir = config.find_case_dir(case_number)
if case_dir.exists(): if case_dir.exists():
case_json = case_dir / "case.json" case_json = case_dir / "case.json"
@@ -330,8 +213,6 @@ async def case_update(
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
"PATH": "/usr/bin:/bin"}, "PATH": "/usr/bin:/bin"},
) )
except Exception:
pass # git not available — non-critical
return json.dumps(updated, default=str, ensure_ascii=False, indent=2) return json.dumps(updated, default=str, ensure_ascii=False, indent=2)

View File

@@ -67,8 +67,7 @@ async def document_upload(
await db.update_document(UUID(doc["id"]), doc_type=classified_type) await db.update_document(UUID(doc["id"]), doc_type=classified_type)
doc["doc_type"] = classified_type doc["doc_type"] = classified_type
# Git commit (best-effort — don't fail upload on git errors) # Git commit
try:
repo_dir = config.find_case_dir(case_number) repo_dir = config.find_case_dir(case_number)
if repo_dir.exists(): if repo_dir.exists():
subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True) subprocess.run(["git", "add", "."], cwd=repo_dir, capture_output=True)
@@ -93,8 +92,6 @@ async def document_upload(
"GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local", "GIT_COMMITTER_NAME": "Ezer Mishpati", "GIT_COMMITTER_EMAIL": "legal@local",
"PATH": "/usr/bin:/bin"}, "PATH": "/usr/bin:/bin"},
) )
except Exception:
pass # git not available in container — non-critical
return json.dumps({ return json.dumps({
"document": doc, "document": doc,
@@ -139,22 +136,14 @@ async def document_upload_training(
appeal_subtype = pa.derive_subtype(decision_number, practice_area) appeal_subtype = pa.derive_subtype(decision_number, practice_area)
pa.validate(practice_area, appeal_subtype) pa.validate(practice_area, appeal_subtype)
# Copy to training directory, organized by subtype # Copy to training directory (skip if already there)
_SUBTYPE_DIRS = { config.TRAINING_DIR.mkdir(parents=True, exist_ok=True)
"betterment_levy": "cmpa", dest = config.TRAINING_DIR / source.name
"compensation_197": "cmpa",
"building_permit": "cmp",
}
subdir = _SUBTYPE_DIRS.get(appeal_subtype, "")
training_dest = config.TRAINING_DIR / subdir if subdir else config.TRAINING_DIR
training_dest.mkdir(parents=True, exist_ok=True)
dest = training_dest / source.name
if source.resolve() != dest.resolve(): if source.resolve() != dest.resolve():
shutil.copy2(str(source), str(dest)) shutil.copy2(str(source), str(dest))
# Extract text and strip Nevo preamble # Extract text
text, page_count = await extractor.extract_text(str(dest)) text, page_count = await extractor.extract_text(str(dest))
text = extractor.strip_nevo_preamble(text)
# Parse date # Parse date
d_date = None d_date = None
@@ -182,12 +171,11 @@ async def document_upload_training(
title=f"[קורפוס] {title}", title=f"[קורפוס] {title}",
file_path=str(dest), file_path=str(dest),
page_count=page_count, page_count=page_count,
practice_area=practice_area,
appeal_subtype=appeal_subtype,
) )
doc_id = UUID(doc["id"]) doc_id = UUID(doc["id"])
await db.update_document( await db.update_document(doc_id, extracted_text=text, extraction_status="completed")
doc_id, extracted_text=text, extraction_status="completed",
metadata={"practice_area": practice_area, "appeal_subtype": appeal_subtype},
)
# Generate embeddings and store chunks # Generate embeddings and store chunks
texts = [c.content for c in chunks] texts = [c.content for c in chunks]
@@ -202,7 +190,10 @@ async def document_upload_training(
} }
for c, emb in zip(chunks, embs) for c, emb in zip(chunks, embs)
] ]
await db.store_chunks(doc_id, None, chunk_dicts) await db.store_chunks(
doc_id, None, chunk_dicts,
practice_area=practice_area, appeal_subtype=appeal_subtype,
)
return json.dumps({ return json.dumps({
"corpus_id": str(corpus_id), "corpus_id": str(corpus_id),
@@ -392,3 +383,49 @@ async def get_claims(case_number: str, party_role: str = "") -> str:
}) })
return json.dumps(formatted, default=str, ensure_ascii=False, indent=2) return json.dumps(formatted, default=str, ensure_ascii=False, indent=2)
async def document_update_status(
case_number: str,
doc_title: str,
status: str,
) -> str:
"""עדכון סטטוס עיבוד מסמך (extraction_status).
ערכים אפשריים: pending, extracted, proofread, error.
Args:
case_number: מספר תיק הערר
doc_title: שם/כותרת המסמך (או חלק ממנו)
status: הסטטוס החדש
"""
valid_statuses = ("pending", "extracted", "proofread", "error")
if status not in valid_statuses:
return f"סטטוס לא חוקי: {status}. ערכים אפשריים: {', '.join(valid_statuses)}"
case = await db.get_case_by_number(case_number)
if not case:
return f"תיק {case_number} לא נמצא."
case_id = UUID(case["id"])
docs = await db.get_documents(case_id)
# Find matching document by title (partial match)
matched = None
for d in docs:
if doc_title.lower() in d.get("title", "").lower():
matched = d
break
if not matched:
titles = [d.get("title", "?") for d in docs]
return f"מסמך '{doc_title}' לא נמצא בתיק {case_number}. מסמכים קיימים: {titles}"
doc_id = UUID(matched["id"])
await db.update_document(doc_id, extraction_status=status)
return json.dumps({
"updated": True,
"document": matched["title"],
"new_status": status,
}, ensure_ascii=False, indent=2)

View File

@@ -281,6 +281,39 @@ async def draft_section(
return json.dumps(context, ensure_ascii=False, indent=2) return json.dumps(context, ensure_ascii=False, indent=2)
async def get_research_findings(case_number: str) -> str:
"""שליפת ממצאי מחקר — סיכומי פסיקה, מיפוי תכניות, ציר זמן, והמלצות.
קורא מ-research-findings.md שנוצר ע"י סוכן חוקר התקדימים (legal-researcher).
מחזיר JSON מובנה עם הממצאים, או status=missing אם הקובץ לא קיים עדיין.
Args:
case_number: מספר תיק הערר
"""
case_dir = config.find_case_dir(case_number)
file_path = case_dir / "documents" / "research" / research_md.RESEARCH_FINDINGS_FILENAME
result = research_md.extract_research_findings(file_path)
return json.dumps(result, ensure_ascii=False, indent=2)
async def get_full_analysis(case_number: str) -> str:
"""שליפת הניתוח המשפטי המלא מ-analysis-and-research.md — כולל טענות, תשובות,
תגובות, ניתוח אסטרטגי (חוזקות/חולשות/הזדמנויות), שאלות מחקר, חקיקה רלוונטית,
תקדימים פנימיים, ועמדות יו"ר הוועדה.
זה הכלי המרכזי שכותב ההחלטה צריך לקרוא **לפני** כתיבת בלוק י (דיון).
מחזיר JSON מובנה עם כל השדות שהניתוח המשפטי הפיק, ולא רק עמדות כמו
get_chair_directions.
Args:
case_number: מספר תיק הערר
"""
case_dir = config.find_case_dir(case_number)
file_path = case_dir / "documents" / "research" / "analysis-and-research.md"
result = research_md.extract_full_analysis(file_path)
return json.dumps(result, ensure_ascii=False, indent=2)
async def get_chair_directions(case_number: str) -> str: async def get_chair_directions(case_number: str) -> str:
"""שליפת עמדות יו"ר הוועדה (דפנה) על סוגיות הערר, לצורך יצירת direction_doc """שליפת עמדות יו"ר הוועדה (דפנה) על סוגיות הערר, לצורך יצירת direction_doc
לכותב. קורא מ-analysis-and-research.md (שנוצר ע"י legal-analyst ומולא ע"י לכותב. קורא מ-analysis-and-research.md (שנוצר ע"י legal-analyst ומולא ע"י
@@ -454,16 +487,76 @@ async def save_block_content(case_number: str, block_id: str, content: str) -> s
return str(e) return str(e)
async def analyze_style(appeal_subtype: str = "") -> str: async def get_decision_blocks(case_number: str, block_id: str = "") -> str:
"""הרצת ניתוח סגנון על קורפוס ההחלטות של דפנה. מחלץ דפוסי כתיבה ושומר אותם. """שליפת בלוקים שנכתבו בהחלטה — תוכן, ספירת מילים, משקלות.
אם block_id ריק — מחזיר את כל הבלוקים. אם מצוין — רק בלוק ספציפי.
שימושי לבודק איכות (QA) שצריך לקרוא בלוקים בודדים.
Args: Args:
appeal_subtype: סינון לפי סוג ערר (building_permit / betterment_levy / compensation_197). case_number: מספר תיק הערר
ריק = כל ההחלטות. block_id: מזהה בלוק (ריק = כולם). למשל: block-yod, block-vav
""" """
case = await db.get_case_by_number(case_number)
if not case:
return f"תיק {case_number} לא נמצא."
case_id = UUID(case["id"])
decision = await db.get_decision_by_case(case_id)
if not decision:
return f"אין החלטה בתיק {case_number}."
decision_id = UUID(decision["id"])
pool = await db.get_pool()
async with pool.acquire() as conn:
if block_id:
rows = await conn.fetch(
"SELECT block_id, block_index, title, content, word_count, "
"weight_percent, status FROM decision_blocks "
"WHERE decision_id = $1 AND block_id = $2 "
"ORDER BY block_index",
decision_id, block_id,
)
else:
rows = await conn.fetch(
"SELECT block_id, block_index, title, content, word_count, "
"weight_percent, status FROM decision_blocks "
"WHERE decision_id = $1 ORDER BY block_index",
decision_id,
)
if not rows:
if block_id:
return f"בלוק {block_id} לא נמצא בהחלטה."
return "אין בלוקים בהחלטה."
blocks = []
total_words = 0
for r in rows:
total_words += r["word_count"] or 0
blocks.append({
"block_id": r["block_id"],
"index": r["block_index"],
"title": r["title"],
"content": r["content"],
"word_count": r["word_count"],
"weight_percent": float(r["weight_percent"] or 0),
"status": r["status"],
})
return json.dumps({
"case_number": case_number,
"total_blocks": len(blocks),
"total_words": total_words,
"blocks": blocks,
}, default=str, ensure_ascii=False, indent=2)
async def analyze_style() -> str:
"""הרצת ניתוח סגנון על קורפוס ההחלטות של דפנה. מחלץ דפוסי כתיבה ושומר אותם."""
from legal_mcp.services.style_analyzer import analyze_corpus from legal_mcp.services.style_analyzer import analyze_corpus
result = await analyze_corpus(appeal_subtype) result = await analyze_corpus()
return json.dumps(result, ensure_ascii=False, indent=2) return json.dumps(result, ensure_ascii=False, indent=2)

View File

@@ -52,7 +52,7 @@ async def precedent_attach(
pdf_document_id=pdf_uuid, pdf_document_id=pdf_uuid,
practice_area=case.get("practice_area"), practice_area=case.get("practice_area"),
) )
return json.dumps(row, ensure_ascii=False, indent=2, default=str) return json.dumps(row, ensure_ascii=False, indent=2)
async def precedent_list(case_number: str) -> str: async def precedent_list(case_number: str) -> str:
@@ -62,7 +62,7 @@ async def precedent_list(case_number: str) -> str:
return json.dumps({"error": f"תיק {case_number} לא נמצא."}, ensure_ascii=False) return json.dumps({"error": f"תיק {case_number} לא נמצא."}, ensure_ascii=False)
rows = await db.list_case_precedents(UUID(case["id"])) rows = await db.list_case_precedents(UUID(case["id"]))
return json.dumps(rows, ensure_ascii=False, indent=2, default=str) return json.dumps(rows, ensure_ascii=False, indent=2)
async def precedent_remove(precedent_id: str) -> str: async def precedent_remove(precedent_id: str) -> str:
@@ -92,4 +92,4 @@ async def precedent_search_library(
return json.dumps([], ensure_ascii=False) return json.dumps([], ensure_ascii=False)
rows = await db.search_precedent_library(query.strip(), practice_area, limit) rows = await db.search_precedent_library(query.strip(), practice_area, limit)
return json.dumps(rows, ensure_ascii=False, indent=2, default=str) return json.dumps(rows, ensure_ascii=False, indent=2)

65
paperclip-bug-report.md Normal file
View File

@@ -0,0 +1,65 @@
# Bug: Skill import from Gitea — wrong raw URL format causes empty SKILL.md
**File at:** https://github.com/paperclipai/paperclip/issues/new
## Title
Skill import from Gitea: wrong raw URL format causes empty SKILL.md
## Body
### Bug Summary
When importing skills from a **Gitea** instance (self-hosted), Paperclip fetches the git tree successfully via the `/api/v3/` endpoint (which Gitea supports), but then uses the **wrong raw file URL format** to download `SKILL.md` content, resulting in a 404 and an almost-empty stub being saved.
### Environment
- Paperclip server: `@paperclipai/server@2026.403.0`
- Gitea instance: self-hosted Gitea
### Steps to Reproduce
1. Host a skill repo on a Gitea instance with a `SKILL.md` (32KB+), `scripts/`, and `references/` directories
2. Import the skill via URL: `https://my-gitea.example.com/org/skill-name.git`
3. Observe that only a stub SKILL.md (~283 bytes) is saved, and subdirectories are missing
### Root Cause
In `server/dist/services/github-fetch.js`, the `resolveRawGitHubUrl()` function builds:
```
https://{hostname}/raw/{owner}/{repo}/{ref}/{file}
```
This format works for **GitHub Enterprise**, but **not for Gitea**. Gitea expects:
```
https://{hostname}/{owner}/{repo}/raw/branch/{ref}/{file}
```
### Proof
```bash
# Paperclip's URL format -> 404
$ curl -s -o /dev/null -w "%{http_code}" "https://my-gitea.example.com/raw/org/skill-repo/main/SKILL.md"
404
# Correct Gitea format -> 200
$ curl -s -o /dev/null -w "%{http_code}" "https://my-gitea.example.com/org/skill-repo/raw/branch/main/SKILL.md"
200
```
### Secondary Issue
When `SKILL.md` is at the repository root, `path.posix.dirname("SKILL.md")` returns `"."`, causing the inventory filter `entry.startsWith("./")` to miss all sibling directories (`scripts/`, `references/`). This means even if the raw URL worked, subdirectories would still be excluded from the file inventory.
### Suggested Fix
1. **Detect Gitea** vs GitHub Enterprise (e.g., check for `/api/v1/` endpoint which is Gitea-specific, vs `/api/v3/`)
2. **Use the correct raw URL format** per platform:
- GitHub/GHE: `https://{hostname}/raw/{owner}/{repo}/{ref}/{file}`
- Gitea: `https://{hostname}/{owner}/{repo}/raw/branch/{ref}/{file}`
3. **Fix root-level SKILL.md inventory**: when `skillDir === "."`, include all files instead of filtering by `entry.startsWith("./")`
### Workaround
Manually clone the repo into `~/.paperclip/instances/default/skills/{company_id}/{slug}/` and update the `company_skills` table directly with correct markdown content and file_inventory.

View File

@@ -1,51 +0,0 @@
# scripts/ — מדריך סקריפטים
> **כלל:** כל עדכון, יצירה, או מחיקה של סקריפט בתיקייה זו מחייב עדכון של קובץ זה.
---
## סקריפטים פעילים
| Script | Type | Purpose | Scheduled |
|--------|------|---------|-----------|
| `auto-sync-cases.sh` | bash | סנכרון תיקי ערר ל-Gitea — רץ כל דקה | `* * * * *` (cron) |
| `backup-db.sh` | bash | גיבוי PostgreSQL יומי ל-`data/backups/` (gzip) | לתזמן: `0 2 * * *` |
| `restore-db.sh` | bash | שחזור DB מגיבוי (companion ל-backup-db.sh) | ידני |
| `notify.py` | python | שליחת מייל התראה מסוכנים via SMTP (Gmail) | נקרא ע"י סוכנים |
| `bidi_table.py` | python | יצירת טבלאות box-drawing עם תמיכה ב-BiDi (עברית+אנגלית) | ספריית עזר |
## תיקיית `.archive/` — סקריפטים שהושלמו
סקריפטים חד-פעמיים שהפונקציונליות שלהם הוטמעה ב-MCP server או ב-API.
נשמרים ב-git לצורך היסטוריה — **אין להריץ אותם**.
| Script | Original Purpose | Superseded By |
|--------|-----------------|---------------|
| `backfill_pattern_frequency.py` | עדכון תדירות דפוסי סגנון ב-DB | `web/app.py::_extract_pattern_variants()` |
| `batch_upload_training.py` | העלאת קורפוס אימון (16 קבצים) | Web UI: `/api/training/upload` |
| `benchmark_embeddings.py` | השוואת מודלי embeddings (voyage-3 vs voyage-4) | הושלם — voyage-3-large נבחר |
| `benchmark_new_vs_old.py` | השוואת Google Vision vs markdown קיים | הושלם — בדיקה חד-פעמית לתיק 1130-25 |
| `decompose-decisions.py` | פירוק החלטות סופיות ל-12 בלוקים | MCP: `write_block()`, `write_all_blocks()` |
| `export-decision-docx.py` | ייצוא החלטה ל-DOCX | MCP: `export_docx()` |
| `extract-citations.py` | חילוץ ציטוטי פסיקה מבלוק י | MCP service: `references_extractor.py` |
| `extract-claims.py` | חילוץ טענות מבלוק ז | MCP: `extract_claims()` + `claims_extractor.py` |
| `extract_all_google_vision.py` | OCR בכמות עם Google Vision | MCP: `document_upload()` pipeline |
| `extract_originals.py` | חילוץ טקסט מ-PDF עם Claude Opus | MCP service: `extractor.py` |
| `extract_originals_ocr.py` | חילוץ OCR מלא מ-PDF | MCP service: `extractor.py` |
| `generate-embeddings.py` | יצירת embeddings לבלוקים ופסיקה | אוטומטי — נוצרים עם יצירת בלוקים |
| `link-claims-to-discussion.py` | קישור טענות לפסקאות דיון | MCP service: `qa_validator.py` |
| `proofread_training_corpus.py` | ניקוי Nevo מ-DOCX/PDF ל-Markdown | MCP service: `proofreader.py` + Web UI |
| `seed-appeals.py` | seeding תיקי ערר ראשוניים ל-DB | MCP: `case_create()` |
| `seed-knowledge.py` | seeding לקחים, ביטויי מעבר, פסיקה | MCP: `record_chair_feedback()`, `precedent_attach()` |
| `validate-decision.py` | ולידציה מול block-schema | MCP: `validate_decision()` + `qa_validator.py` |
## סקריפטים שנמחקו (git history בלבד)
| Script | Reason |
|--------|--------|
| `import-final-decisions.py` | מיגרציה הושלמה — כל ההחלטות ב-`data/training/` |
| `compare_extractions.py` | בדיקה חד-פעמית לתיק 1130-25 |
| `decompose-decisions-v2.py` | כפילות של v1 |
| `extract_google_vision.py` | hardcoded לתיק בודד |
| `extract_google_vision_single.py` | wrapper חד-פעמי |
| `test-search.py` | סקריפט דיבאג |

View File

@@ -4,22 +4,13 @@
CASES_DIR="/home/chaim/legal-ai/data/cases" CASES_DIR="/home/chaim/legal-ai/data/cases"
LOG="/home/chaim/legal-ai/data/.auto-sync.log" LOG="/home/chaim/legal-ai/data/.auto-sync.log"
GIT_ENV="GIT_AUTHOR_NAME=Ezer Mishpati GIT_AUTHOR_EMAIL=legal@local GIT_COMMITTER_NAME=Ezer Mishpati GIT_COMMITTER_EMAIL=legal@local GIT_TERMINAL_PROMPT=0"
export GIT_AUTHOR_NAME="Ezer Mishpati" for status_dir in "$CASES_DIR"/new "$CASES_DIR"/in-progress "$CASES_DIR"/completed; do
export GIT_AUTHOR_EMAIL="legal@local" [ -d "$status_dir" ] || continue
export GIT_COMMITTER_NAME="Ezer Mishpati" for case_dir in "$status_dir"/*/; do
export GIT_COMMITTER_EMAIL="legal@local"
export GIT_TERMINAL_PROMPT=0
for case_dir in "$CASES_DIR"/*/; do
[ -d "$case_dir/.git" ] || continue [ -d "$case_dir/.git" ] || continue
case_name=$(basename "$case_dir")
# Ensure safe.directory is set for this repo
git config --global --get-all safe.directory | grep -qF "$case_dir" \
|| git config --global --add safe.directory "$case_dir"
cd "$case_dir" || continue cd "$case_dir" || continue
# Check for any changes (modified, new, deleted) # Check for any changes (modified, new, deleted)
@@ -29,25 +20,18 @@ for case_dir in "$CASES_DIR"/*/; do
# Stage all changes # Stage all changes
git add -A 2>/dev/null git add -A 2>/dev/null
# Count changed files # Build commit message from changed files
changed_files=$(git diff --cached --name-only 2>/dev/null | head -5)
count=$(git diff --cached --name-only 2>/dev/null | wc -l) count=$(git diff --cached --name-only 2>/dev/null | wc -l)
[ "$count" -eq 0 ] && continue case_name=$(basename "$case_dir")
msg="סנכרון אוטומטי — ${count} קבצים שונו" msg="סנכרון אוטומטי — ${count} קבצים שונו"
# Commit # Commit
if git commit -m "$msg" --quiet 2>/dev/null; then env $GIT_ENV git commit -m "$msg" --quiet 2>/dev/null
# Push only if remote exists if [ $? -eq 0 ]; then
if git remote get-url origin >/dev/null 2>&1; then # Push (non-blocking, ignore errors)
if git push origin HEAD --quiet 2>/dev/null; then git push origin main --quiet 2>/dev/null
echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | $count files synced + pushed" >> "$LOG" echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | $count files synced" >> "$LOG"
else
echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | $count files committed, push FAILED" >> "$LOG"
fi
else
echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | $count files committed (no remote)" >> "$LOG"
fi
else
echo "$(date '+%Y-%m-%d %H:%M:%S') | $case_name | commit FAILED" >> "$LOG"
fi fi
done done
done

View File

@@ -0,0 +1,126 @@
"""Compare existing MD files with freshly extracted text from PDFs."""
import difflib
from pathlib import Path
DOCS_DIR = Path("/home/chaim/legal-ai/data/cases/1130-25/documents")
EXTRACTED_DIR = DOCS_DIR / "extracted"
# Map: existing MD -> extracted MD
PAIRS = [
("2025-08-14-כתב-ערר-קובר.md", "מרק קובר-כתב ערר.md", "Appeal - Kuber"),
("2025-09-01-כתב-תשובה-ליבמן-לערר.md", "תשובה לערר מטעם המשיבים.md", "Response - Livman"),
("2025-09-02-כתב-תשובה-ועדת-הראל-לערר.md", "תשובת הועדה המרחבית לערר.md", "Response - Committee"),
("2025-10-22-כתב-ערר-מטמון.md", "תשובת המשיב-יצחק מטמון.md", "Response - Matmon"),
]
def normalize(text: str) -> str:
"""Normalize text for comparison."""
# Remove markdown formatting, extra whitespace
lines = text.strip().split("\n")
lines = [l.strip() for l in lines if l.strip()]
return "\n".join(lines)
def word_overlap(a: str, b: str) -> float:
"""Calculate word-level overlap ratio."""
words_a = set(a.split())
words_b = set(b.split())
if not words_a or not words_b:
return 0.0
intersection = words_a & words_b
return len(intersection) / max(len(words_a), len(words_b))
def main():
print(f"{'=' * 70}")
print("COMPARISON: Existing MD vs Fresh PDF Extraction")
print(f"{'=' * 70}\n")
summary = []
for existing_name, extracted_name, label in PAIRS:
existing_path = DOCS_DIR / existing_name
extracted_path = EXTRACTED_DIR / extracted_name
if not existing_path.exists():
print(f"SKIP: {existing_name} not found")
continue
if not extracted_path.exists():
print(f"SKIP: {extracted_name} not found")
continue
existing_text = existing_path.read_text(encoding="utf-8")
extracted_text = extracted_path.read_text(encoding="utf-8")
existing_norm = normalize(existing_text)
extracted_norm = normalize(extracted_text)
# Stats
existing_chars = len(existing_text)
extracted_chars = len(extracted_text)
existing_words = len(existing_text.split())
extracted_words = len(extracted_text.split())
# Similarity
overlap = word_overlap(existing_norm, extracted_norm)
# Sequence matcher ratio (slower but more accurate)
# Use first 5000 chars for speed
sm = difflib.SequenceMatcher(None, existing_norm[:5000], extracted_norm[:5000])
seq_ratio = sm.ratio()
# Find lines in extracted but not in existing (new content)
existing_lines = set(existing_norm.split("\n"))
extracted_lines = set(extracted_norm.split("\n"))
new_lines = extracted_lines - existing_lines
missing_lines = existing_lines - extracted_lines
print(f"{'=' * 70}")
print(f" {label}")
print(f" Existing: {existing_name}")
print(f" Extracted: {extracted_name}")
print(f"{'=' * 70}")
print(f" {'Metric':<30} {'Existing MD':>15} {'Fresh PDF':>15} {'Diff':>10}")
print(f" {'-' * 70}")
print(f" {'Characters':<30} {existing_chars:>15,} {extracted_chars:>15,} {extracted_chars - existing_chars:>+10,}")
print(f" {'Words':<30} {existing_words:>15,} {extracted_words:>15,} {extracted_words - existing_words:>+10,}")
print(f" {'Lines':<30} {len(existing_lines):>15,} {len(extracted_lines):>15,} {len(extracted_lines) - len(existing_lines):>+10,}")
print(f" {'Word overlap':<30} {overlap:>15.1%}")
print(f" {'Sequence similarity':<30} {seq_ratio:>15.1%}")
print(f" {'Lines only in fresh PDF':<30} {len(new_lines):>15}")
print(f" {'Lines only in existing MD':<30} {len(missing_lines):>15}")
# Show sample differences
if new_lines:
print(f"\n Sample lines ONLY in fresh extraction (first 3):")
for line in sorted(new_lines)[:3]:
print(f" + {line[:100]}")
if missing_lines:
print(f"\n Sample lines ONLY in existing MD (first 3):")
for line in sorted(missing_lines)[:3]:
print(f" - {line[:100]}")
print()
summary.append({
"label": label,
"existing_words": existing_words,
"extracted_words": extracted_words,
"word_overlap": overlap,
"seq_similarity": seq_ratio,
})
# Summary table
print(f"\n{'=' * 70}")
print("SUMMARY")
print(f"{'=' * 70}")
print(f" {'Document':<25} {'Existing':>10} {'Fresh':>10} {'Overlap':>10} {'Similarity':>12}")
print(f" {'-' * 67}")
for s in summary:
print(f" {s['label']:<25} {s['existing_words']:>10,} {s['extracted_words']:>10,} {s['word_overlap']:>10.1%} {s['seq_similarity']:>12.1%}")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,289 @@
#!/usr/bin/env python3
"""Decompose final decisions into 12-block structure — V2 calibrated on הכט.
Key insight: DOCX extraction strips header blocks (א-ד). The real content
starts at block ה (opening "לפנינו"). We identify blocks by known section
headers and line-by-line analysis.
"""
import asyncio
import json
import re
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "mcp-server" / "src"))
from legal_mcp.services.db import get_pool, init_schema, close_pool
BLOCK_DEFS = [
("block-alef", 1, "כותרת מוסדית", "template-fill"),
("block-bet", 2, "הרכב הוועדה", "template-fill"),
("block-gimel", 3, "צדדים", "template-fill"),
("block-dalet", 4, "כותרת החלטה", "template-fill"),
("block-he", 5, "פתיחה", "paraphrase"),
("block-vav", 6, "רקע עובדתי", "reproduction"),
("block-zayin", 7, "טענות הצדדים", "paraphrase"),
("block-chet", 8, "הליכים בפני ועדת הערר", "reproduction"),
("block-tet", 9, "תכניות חלות", "guided-synthesis"),
("block-yod", 10, "דיון והכרעה", "rhetorical-construction"),
("block-yod-alef", 11, "סיכום", "paraphrase"),
("block-yod-bet", 12, "חתימות", "template-fill"),
]
def find_line(lines: list[str], pattern: str, start: int = 0) -> int:
"""Find first line matching pattern (substring or regex). Returns -1 if not found."""
pat = re.compile(pattern)
for i in range(start, len(lines)):
if pat.search(lines[i]):
return i
return -1
def slice_text(lines: list[str], start: int, end: int) -> str:
"""Join lines[start:end] into text."""
if start < 0 or end <= start:
return ""
return "\n".join(lines[start:end]).strip()
def count_words(text: str) -> int:
return len(text.split()) if text else 0
def decompose(text: str) -> dict[str, str]:
"""Parse decision into blocks. Returns {block_id: content}."""
lines = text.split("\n")
n = len(lines)
blocks = {}
# Find key section headers
# Style 1: רישוי — descriptive headers ("תמצית טענות הצדדים", "דיון והכרעה")
# Style 2: היטל השבחה — numbered headers ("א. רקע עובדתי", "ו. דיון והכרעה")
opening = find_line(lines, r"^לפנינו\s|^בפנינו\s|^בפני\s*ועדת|^בפני\s*בקשה")
claims = find_line(lines, r"תמצית\s*טענות|טענות\s*הצדדים|טענות\s*העוררי")
if claims == -1:
claims = find_line(lines, r"^טענות\s*העוררי")
if claims == -1:
# היטל השבחה style: "ב. טענות העורר"
claims = find_line(lines, r"^[א-ת][\.\)]\s*טענות")
background = find_line(lines, r"^[א-ת][\.\)]\s*רקע\s*עובדתי")
proceedings = find_line(lines, r"ההליכים\s*בפני|הליכים\s*בפני|הדיון\s*בפני\s*ועדת\s*הערר")
if proceedings == -1:
# היטל השבחה: "ד. הבהרות השמאית" or similar procedural sections
proceedings = find_line(lines, r"^[א-ת][\.\)]\s*הבהרות|^[א-ת][\.\)]\s*ההליך")
plans = find_line(lines, r"תכניות\s*חלות|המסגרת\s*הנורמטיבית|הוראות\s*התכנית")
if plans == -1:
plans = find_line(lines, r"^[א-ת][\.\)]\s*המסגרת\s*הנורמטיבית")
discussion = find_line(lines, r"^דיון\s*והכרעה|^דיון$|^הכרעה$")
if discussion == -1:
discussion = find_line(lines, r"^[א-ת][\.\)]\s*דיון\s*והכרעה")
summary = find_line(lines, r"^סיכום\s*$|^סוף\s*דבר\s*$")
if summary == -1:
summary = find_line(lines, r"^[א-ת][\.\)]\s*סיכום")
signature = find_line(lines, r"^ניתנה?\s*(היום|פה\s*אחד|ביום)")
# If no explicit discussion header, look for the opening formula
if discussion == -1:
discussion = find_line(lines, r"לאחר\s*שבחנו\s*את\s*טענות")
# ── Header blocks (א-ד): everything before opening ──
if opening >= 0:
header_text = slice_text(lines, 0, opening)
if header_text:
# Try to split header, but usually DOCX extraction loses these
blocks["block-alef"] = header_text
else:
blocks["block-alef"] = ""
else:
blocks["block-alef"] = ""
blocks["block-bet"] = "" # Usually lost in extraction
blocks["block-gimel"] = ""
blocks["block-dalet"] = "החלטה"
# ── Block ה: Opening — first 1-3 paragraphs from "לפנינו" ──
if opening >= 0:
next_section = claims if claims > opening else discussion if discussion > opening else n
opening_end = opening + 1
for i in range(opening + 1, min(opening + 5, next_section)):
line = lines[i].strip()
if not line:
break
opening_end = i + 1
blocks["block-he"] = slice_text(lines, opening, opening_end)
else:
blocks["block-he"] = ""
# ── Block ו: Background ──
# Style 1 (רישוי): after opening, before claims
# Style 2 (היטל השבחה): explicit "א. רקע עובדתי" section
if background >= 0:
# Explicit background header (היטל השבחה style)
bg_end = claims if claims > background else (proceedings if proceedings > background else (discussion if discussion > background else n))
blocks["block-vav"] = slice_text(lines, background, bg_end)
# In this case, opening (ה) might not exist — "לפנינו" may be absent
elif opening >= 0 and claims > opening:
bg_start = opening + 1
he_lines = count_words(blocks.get("block-he", ""))
if he_lines > 0:
he_end = opening
for i in range(opening, min(opening + 5, claims)):
if lines[i].strip():
he_end = i + 1
else:
break
bg_start = he_end
blocks["block-vav"] = slice_text(lines, bg_start, claims)
elif opening >= 0 and discussion > opening:
blocks["block-vav"] = slice_text(lines, opening + 1, discussion)
else:
blocks["block-vav"] = ""
# ── Block ז: Claims — from claims header to next section ──
if claims >= 0:
claims_end = min(
x for x in [proceedings, plans, discussion, summary, n]
if x > claims
)
blocks["block-zayin"] = slice_text(lines, claims, claims_end)
else:
blocks["block-zayin"] = ""
# ── Block ח: Proceedings (optional) ──
if proceedings >= 0:
proc_end = min(
x for x in [plans, discussion, summary, n]
if x > proceedings
)
blocks["block-chet"] = slice_text(lines, proceedings, proc_end)
else:
blocks["block-chet"] = ""
# ── Block ט: Plans (optional) ──
if plans >= 0 and (discussion == -1 or plans < discussion):
plans_end = min(
x for x in [discussion, summary, n]
if x > plans
)
blocks["block-tet"] = slice_text(lines, plans, plans_end)
else:
blocks["block-tet"] = ""
# ── Block י: Discussion ──
if discussion >= 0:
disc_end = summary if summary > discussion else (signature if signature > discussion else n)
blocks["block-yod"] = slice_text(lines, discussion, disc_end)
else:
blocks["block-yod"] = ""
# ── Block יא: Summary ──
if summary >= 0:
summ_end = signature if signature > summary else n
blocks["block-yod-alef"] = slice_text(lines, summary, summ_end)
else:
blocks["block-yod-alef"] = ""
# ── Block יב: Signatures ──
if signature >= 0:
blocks["block-yod-bet"] = slice_text(lines, signature, n)
else:
blocks["block-yod-bet"] = ""
return blocks
async def main():
await init_schema()
pool = await get_pool()
async with pool.acquire() as conn:
decisions = await conn.fetch(
"""SELECT d.id as decision_id, c.case_number, c.title,
doc.extracted_text
FROM decisions d
JOIN cases c ON c.id = d.case_id
JOIN documents doc ON doc.case_id = d.case_id AND doc.doc_type = 'decision'
WHERE d.status = 'final'
ORDER BY c.case_number"""
)
for dec in decisions:
decision_id = dec["decision_id"]
case_number = dec["case_number"]
text = dec["extracted_text"]
total_words = count_words(text)
print(f"\n{'='*60}")
print(f"מפרק: {case_number}{dec['title']}")
print(f"סה\"כ מילים: {total_words}")
print(f"{'='*60}")
parsed = decompose(text)
async with pool.acquire() as conn:
# Delete existing blocks
await conn.execute(
"DELETE FROM decision_blocks WHERE decision_id = $1", decision_id
)
total_parsed_words = 0
for block_id, block_index, title, gen_type in BLOCK_DEFS:
content = parsed.get(block_id, "")
wc = count_words(content)
weight = round(wc / total_words * 100, 1) if total_words > 0 and wc > 0 else 0
status = "final" if wc > 0 else "empty"
total_parsed_words += wc
await conn.execute(
"""INSERT INTO decision_blocks
(decision_id, block_id, block_index, title, content,
word_count, weight_percent, generation_type, status)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)""",
decision_id, block_id, block_index, title,
content, wc, weight, gen_type, status,
)
marker = "" if wc > 0 else ""
print(f" {marker} {block_id:18s} | {title:25s} | {wc:5d} מילים | {weight:5.1f}%")
# Update decision totals
disc_words = count_words(parsed.get("block-yod", ""))
disc_paras = len([p for p in parsed.get("block-yod", "").split("\n") if p.strip() and len(p.strip()) > 20])
await conn.execute(
"UPDATE decisions SET total_words = $1, total_paragraphs = $2, updated_at = now() WHERE id = $3",
total_words, disc_paras, decision_id,
)
coverage = round(total_parsed_words / total_words * 100, 1) if total_words > 0 else 0
print(f" --- כיסוי: {total_parsed_words}/{total_words} מילים ({coverage}%)")
# Summary
async with pool.acquire() as conn:
stats = await conn.fetch(
"""SELECT block_id, count(*) as decisions,
avg(word_count) as avg_words,
avg(weight_percent) as avg_weight
FROM decision_blocks
WHERE word_count > 0
GROUP BY block_id ORDER BY block_id"""
)
print(f"\n{'='*60}")
print("סטטיסטיקה לפי בלוק (רק בלוקים עם תוכן):")
for s in stats:
print(f" {s['block_id']:18s} | {s['decisions']} החלטות | ממוצע {s['avg_words']:.0f} מילים | {s['avg_weight']:.1f}%")
await close_pool()
if __name__ == "__main__":
asyncio.run(main())

View File

@@ -0,0 +1,66 @@
"""Extract text from PDF using Google Cloud Vision API."""
import io
import time
from pathlib import Path
import fitz # PyMuPDF for rendering pages to images
from google.cloud import vision
API_KEY = "AIzaSyDZgUsxsy_FHkkREU7R_oQLJALU3_V26j8"
PDF_PATH = Path("/home/chaim/legal-ai/data/cases/1130-25/documents/originals/מרק קובר-כתב ערר.pdf")
OUTPUT_DIR = Path("/home/chaim/legal-ai/data/cases/1130-25/documents/extracted")
def main():
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
client = vision.ImageAnnotatorClient(
client_options={"api_key": API_KEY}
)
doc = fitz.open(str(PDF_PATH))
page_count = len(doc)
print(f"Processing: {PDF_PATH.name} ({page_count} pages)\n")
pages_text = []
total_time = 0.0
for i in range(page_count):
page = doc[i]
pix = page.get_pixmap(dpi=300)
img_bytes = pix.tobytes("png")
image = vision.Image(content=img_bytes)
print(f" Page {i+1}/{page_count}...", end=" ", flush=True)
t0 = time.time()
response = client.document_text_detection(
image=image,
image_context={"language_hints": ["he"]}
)
elapsed = time.time() - t0
total_time += elapsed
if response.error.message:
print(f"ERROR: {response.error.message}")
pages_text.append("")
continue
text = response.full_text_annotation.text if response.full_text_annotation else ""
pages_text.append(text)
print(f"{len(text):,} chars, {elapsed:.1f}s")
doc.close()
full_text = "\n\n".join(pages_text)
out_file = OUTPUT_DIR / f"{PDF_PATH.stem}.md"
out_file.write_text(full_text, encoding="utf-8")
print(f"\nTotal: {len(full_text):,} chars, {len(full_text.split()):,} words, {total_time:.1f}s")
print(f"Saved: {out_file}")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,54 @@
"""Extract text from a single PDF using Google Cloud Vision API."""
import sys
import time
from pathlib import Path
import fitz
from google.cloud import vision
API_KEY = "AIzaSyDZgUsxsy_FHkkREU7R_oQLJALU3_V26j8"
OUTPUT_DIR = Path("/home/chaim/legal-ai/data/cases/1130-25/documents/extracted")
def main():
pdf_path = Path(sys.argv[1])
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
client = vision.ImageAnnotatorClient(client_options={"api_key": API_KEY})
doc = fitz.open(str(pdf_path))
page_count = len(doc)
print(f"Processing: {pdf_path.name} ({page_count} pages)\n")
pages_text = []
total_time = 0.0
for i in range(page_count):
page = doc[i]
pix = page.get_pixmap(dpi=300)
img_bytes = pix.tobytes("png")
image = vision.Image(content=img_bytes)
print(f" Page {i+1}/{page_count}...", end=" ", flush=True)
t0 = time.time()
response = client.document_text_detection(image=image, image_context={"language_hints": ["he"]})
elapsed = time.time() - t0
total_time += elapsed
if response.error.message:
print(f"ERROR: {response.error.message}")
pages_text.append("")
continue
text = response.full_text_annotation.text if response.full_text_annotation else ""
pages_text.append(text)
print(f"{len(text):,} chars, {elapsed:.1f}s")
doc.close()
full_text = "\n\n".join(pages_text)
out_file = OUTPUT_DIR / f"{pdf_path.stem}.md"
out_file.write_text(full_text, encoding="utf-8")
print(f"\nTotal: {len(full_text):,} chars, {len(full_text.split()):,} words, {total_time:.1f}s")
print(f"Saved: {out_file}")
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,202 @@
#!/usr/bin/env python3
"""Import 6 final signed decisions: extract text, store in DB."""
import asyncio
import json
import sys
from datetime import date
from pathlib import Path
from uuid import UUID
sys.path.insert(0, str(Path(__file__).parent.parent / "mcp-server" / "src"))
import fitz # PyMuPDF
from docx import Document as DocxDocument
from legal_mcp.services.db import get_pool, init_schema, close_pool
# ═══════════════════════════════════════════════════════════════════
# 6 Final Decisions
# ═══════════════════════════════════════════════════════════════════
FINAL_DECISIONS = [
{
"case_number": "1180-1181",
"file_path": "legacy/dafna-tamir/04_Archive/ערר 1180-1181 הכט/החלטה/הכט 1180-1181.pdf",
"title": "החלטה סופית — הכט 1180-1181",
"outcome": "rejected",
"decision_date": date(2026, 2, 5),
},
{
"case_number": "8255-25",
"file_path": "legacy/dafna-tamir/04_Archive/בל\"מ 8255-25 אפרים אבי נ' הוועדה המקומית לתכנון ובניה/החלטה/אליהו הרנון - להפצה.docx",
"title": "החלטה סופית — אפרים אבי 8255-25",
"outcome": "rejected",
"decision_date": None,
},
{
"case_number": "8007-24",
"file_path": "legacy/dafna-tamir/04_Archive/ערר 8007-24-עומר דרוויש-ערר על שומה מכרעת/החלטה/החלטה-סופית.docx",
"title": "החלטה סופית — עומר דרוויש 8007-24",
"outcome": "",
"decision_date": None,
},
{
"case_number": "1113/25",
"file_path": "legacy/dafna-tamir/04_Archive/ערר-1113-25-אייל-מבורך/החלטה/החלטה-1113-25-טיוטה-סופית.docx",
"title": "החלטה סופית — מבורך 1113-25",
"outcome": "",
"decision_date": None,
},
{
"case_number": "1126/25+1141/25",
"file_path": "legacy/dafna-tamir/04_Archive/ערר-1126-25-תמא-38-בית-הכרם/החלטה/בית הכרם-טיוטת החלטה-9.pdf",
"title": "החלטה סופית — בית הכרם 1126/25",
"outcome": "partial",
"decision_date": date(2026, 3, 1),
},
{
"case_number": "1128/25",
"file_path": "legacy/dafna-tamir/04_Archive/ערר-1128-25-שטרית/החלטה/1128-25 החלטה להפצה.pdf",
"title": "החלטה סופית — שטרית 1128-25",
"outcome": "",
"decision_date": None,
},
]
PROJECT_ROOT = Path(__file__).parent.parent
def extract_pdf_text(file_path: Path) -> str:
"""Extract text from PDF using PyMuPDF."""
doc = fitz.open(str(file_path))
text_parts = []
for page in doc:
text_parts.append(page.get_text())
doc.close()
return "\n".join(text_parts)
def extract_docx_text(file_path: Path) -> str:
"""Extract text from DOCX."""
doc = DocxDocument(str(file_path))
return "\n".join(p.text for p in doc.paragraphs if p.text.strip())
def extract_text(file_path: Path) -> str:
"""Extract text based on file extension."""
suffix = file_path.suffix.lower()
if suffix == ".pdf":
return extract_pdf_text(file_path)
elif suffix == ".docx":
return extract_docx_text(file_path)
else:
raise ValueError(f"Unsupported format: {suffix}")
def count_words(text: str) -> int:
return len(text.split())
async def main():
await init_schema()
pool = await get_pool()
for d in FINAL_DECISIONS:
file_path = PROJECT_ROOT / d["file_path"]
if not file_path.exists():
print(f"❌ קובץ לא נמצא: {file_path}")
continue
# Extract text
print(f"\nמחלץ טקסט: {d['title']}...")
text = extract_text(file_path)
word_count = count_words(text)
print(f" {word_count} מילים, {len(text)} תווים")
async with pool.acquire() as conn:
# Get case_id
case_id = await conn.fetchval(
"SELECT id FROM cases WHERE case_number = $1", d["case_number"]
)
if not case_id:
print(f" ⚠ תיק {d['case_number']} לא נמצא ב-DB — מדלג")
continue
# Register document
existing_doc = await conn.fetchval(
"SELECT id FROM documents WHERE file_path = $1",
str(file_path),
)
if existing_doc:
doc_id = existing_doc
print(f" מסמך כבר קיים ב-DB: {doc_id}")
# Update text
await conn.execute(
"""UPDATE documents SET extracted_text = $1, extraction_status = 'completed'
WHERE id = $2""",
text, doc_id,
)
else:
doc_id = await conn.fetchval(
"""INSERT INTO documents (case_id, doc_type, title, file_path, extracted_text, extraction_status, page_count)
VALUES ($1, 'decision', $2, $3, $4, 'completed', $5)
RETURNING id""",
case_id, d["title"], str(file_path), text,
len(fitz.open(str(file_path))) if file_path.suffix == ".pdf" else None,
)
print(f" מסמך נרשם: {doc_id}")
# Create/update decision record
existing_decision = await conn.fetchval(
"SELECT id FROM decisions WHERE case_id = $1", case_id
)
if existing_decision:
await conn.execute(
"""UPDATE decisions SET status = 'final', outcome = $1, total_words = $2,
decision_date = $3, updated_at = now() WHERE id = $4""",
d["outcome"], word_count, d["decision_date"], existing_decision,
)
decision_id = existing_decision
print(f" החלטה עודכנה: {decision_id}")
else:
decision_id = await conn.fetchval(
"""INSERT INTO decisions (case_id, version, status, outcome, outcome_summary,
total_words, decision_date, author)
VALUES ($1, 1, 'final', $2, $3, $4, $5, 'דפנה תמיר')
RETURNING id""",
case_id, d["outcome"], d["title"], word_count, d["decision_date"],
)
print(f" החלטה נוצרה: {decision_id}")
# Update case status
await conn.execute(
"UPDATE cases SET status = 'final', expected_outcome = $1, updated_at = now() WHERE id = $2",
d["outcome"], case_id,
)
print(f" ✅ הושלם: {d['case_number']}")
# Summary
async with pool.acquire() as conn:
doc_count = await conn.fetchval(
"SELECT count(*) FROM documents WHERE doc_type = 'decision' AND extraction_status = 'completed'"
)
dec_count = await conn.fetchval(
"SELECT count(*) FROM decisions WHERE status = 'final'"
)
total_words = await conn.fetchval(
"SELECT sum(total_words) FROM decisions WHERE status = 'final'"
)
await close_pool()
print(f"\n{'='*50}")
print(f"✅ סה\"כ מסמכי החלטה: {doc_count}")
print(f"✅ סה\"כ החלטות סופיות: {dec_count}")
print(f"✅ סה\"כ מילים: {total_words:,}")
if __name__ == "__main__":
asyncio.run(main())

View File

@@ -15,7 +15,7 @@ SMTP_HOST = "smtp.gmail.com"
SMTP_PORT = 587 SMTP_PORT = 587
FROM_EMAIL = "notify@marcus-law.co.il" FROM_EMAIL = "notify@marcus-law.co.il"
FROM_PASS = "vuva jwed lbuz xjds" FROM_PASS = "vuva jwed lbuz xjds"
TO_EMAIL = "chaim+paperclip@marcus-law.co.il" TO_EMAIL = "paperclip+chaim@marcus-law.co.il"
def send(subject: str, body: str) -> bool: def send(subject: str, body: str) -> bool:

40
scripts/test-search.py Normal file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python3
"""Test semantic search functions."""
import asyncio
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent / "mcp-server" / "src"))
from legal_mcp.services.db import search_similar_paragraphs, search_similar_case_law, search_precedents, init_schema
from legal_mcp.services.embeddings import embed_query
async def main():
await init_schema()
queries = [
"טענות קנייניות רוב דרוש בעלי דירות רכוש משותף",
"חניה תנועה חניות מצוקת חניה",
"היטל השבחה שמאי מכריע התערבות",
]
for query in queries:
print(f'=== שאילתה: "{query}" ===')
emb = await embed_query(query)
results = await search_precedents(emb, limit=3)
if not results:
print(" אין תוצאות")
else:
for i, r in enumerate(results):
score = r["score"]
cn = r["case_number"]
rtype = r["type"]
content = r["content"][:120].replace("\n", " ")
print(f" {i+1}. [{rtype}] {score:.3f} | {cn} | {content}")
print()
asyncio.run(main())

View File

@@ -203,9 +203,6 @@ description: This skill should be used when writing legal decisions (החלטו
## 6. השיטה האנליטית - "איך לחשוב" לפני "איך לכתוב" ## 6. השיטה האנליטית - "איך לחשוב" לפני "איך לכתוב"
> **מסמך המתודולוגיה המלא:** [`docs/decision-methodology.md`](../../docs/decision-methodology.md)
> מסמך זה עוסק בטכניקות הכתיבה של דפנה. לתאוריית ההחלטה הכללית — מבנה סילוגיסטי, איזון, steel-man, טכניקת סנדוויץ', הפרדת ממצאים ממסקנות — ראה את מסמך המתודולוגיה.
### 6.1 שומר הסף - שאלת הסף ### 6.1 שומר הסף - שאלת הסף
לפני שנוגעים בטענה לגופה, השאלה הראשונה היא: "יש לעוררים בכלל זכות ערר?" זו לא רק שאלה פרוצדורלית - זו מסגרת הניתוח כולה. **סייג חשוב:** שאלת הסף היא כלי אסטרטגי, לא חובה. בתיקים עם שאלות מהותיות חזקות (חניה, שימור, קווי בניין), דפנה עשויה לדלג על שאלת הסף ולדון ישירות בגוף העניין — במיוחד בקבלה חלקית. ראה: בית הכרם 1126/25 — דילגה על ס' 152 לחלוטין. לפני שנוגעים בטענה לגופה, השאלה הראשונה היא: "יש לעוררים בכלל זכות ערר?" זו לא רק שאלה פרוצדורלית - זו מסגרת הניתוח כולה. **סייג חשוב:** שאלת הסף היא כלי אסטרטגי, לא חובה. בתיקים עם שאלות מהותיות חזקות (חניה, שימור, קווי בניין), דפנה עשויה לדלג על שאלת הסף ולדון ישירות בגוף העניין — במיוחד בקבלה חלקית. ראה: בית הכרם 1126/25 — דילגה על ס' 152 לחלוטין.
@@ -502,39 +499,3 @@ description: This skill should be used when writing legal decisions (החלטו
| תיבות תמונה | מסגרת עם shading אפור בהיר (fill: "F0F0F0"), טקסט "📷 תמונה: [תיאור]" | ShadingType.CLEAR | | תיבות תמונה | מסגרת עם shading אפור בהיר (fill: "F0F0F0"), טקסט "📷 תמונה: [תיאור]" | ShadingType.CLEAR |
| חתימות | טבלה ללא גבולות (`visuallyRightToLeft: true`), 2 טורים | כמו בתבנית ב-create-legal-doc.js | | חתימות | טבלה ללא גבולות (`visuallyRightToLeft: true`), 2 טורים | כמו בתבנית ב-create-legal-doc.js |
| כותרת מוסדית | טבלה ללא גבולות, 2 טורים: ימין=מוסד, שמאל=מספרי תיק | `visuallyRightToLeft: true` | | כותרת מוסדית | טבלה ללא גבולות, 2 טורים: ימין=מוסד, שמאל=מספרי תיק | `visuallyRightToLeft: true` |
## 12. צ'קליסט תוכן לפי סוג ערר
> נוסף אפריל 2026 בעקבות ניתוח שיטתי של 24 החלטות. ראה: `docs/corpus-analysis.md`
הפרומפט של בלוק י מקבל **צ'קליסט תוכן** אוטומטי לפי סוג הערר (`lessons.py: CONTENT_CHECKLISTS`). זה מבטיח שהדיון יכסה את הנושאים הנדרשים — לא רק סגנון ומתודולוגיה, אלא תוכן ענייני.
### 12.1 חמישה תת-סוגי רישוי (לא שלושה)
ניתוח הקורפוס חשף שלתיקי רישוי יש 5 תת-סוגים שונים מבחינת מבנה הדיון:
| תת-סוג | מה בדיון | דוגמאות |
|---------|---------|---------|
| **רישוי מהותי** | דיון תכנוני מקיף + משפטי | רוב ההחלטות |
| **סף/סמכות** | משפטי בלבד, ללא תכנון | גבאי, ירושלים שקופה |
| **קנייני** | תימוכין קנייניים, מינימום תכנון | טלי-אביב, הראל 1043 |
| **תמ"א 38** | איזון אינטרסים + תכנון + שכנות | בית הכרם |
| **שימוש חורג** | פרשנות תכניות מרובות | תורן |
### 12.2 דיון תכנוני — מתי ואיך
**מתי חובה:** כשהערר מגיע לדיון מהותי (לא סף/סמכות, לא קנייני טהור).
**מבנה טיפוסי (מהקורפוס):**
1. הקשר תכנוני רחב — תכניות חלות, ייעוד, סביבה (2-8 סעיפים)
2. ציטוט ישיר מהוראות תכנית — בלוקים של 200-600 מילים עם "הדגשת הח"מ"
3. יישום על המקרה — הוראה → עובדה → מסקנה
4. מסקנה תכנונית — תואם/סוטה, מוצדק/לא
**נושאים שמופיעים בתדירות גבוהה:**
- חניה (8/24 החלטות) — הנושא התכנוני הנפוץ ביותר, עומק של 5-15 סעיפים
- קווי בניין (7/24) — כולל ניתוח סטייה ניכרת
- ניתוח הוראות תכנית (18/24) — כמעט תמיד
- פגיעה בשכנים (5/24) — צל, פרטיות, רעש
### 12.3 הערות יו
הערות דפנה על טיוטות מתועדות במערכת `chair_feedback` (DB + API + UI ב-`/feedback`). כל הערה מסווגת לקטגוריה ומפיקה לקח שמשפר את ההחלטות הבאות.

View File

@@ -1 +0,0 @@
../../../docs/block-schema.md

View File

@@ -0,0 +1,574 @@
# Block Schema — ארכיטקטורת מסמך החלטת ועדת ערר
מסמך זה מגדיר את המבנה הפורמלי של החלטת ועדת ערר לתכנון ובניה. הוא משמש כמקור סמכותי להגדרת בלוקים, משקלות, פרמטרי עיבוד, וכללי ולידציה.
**הפניה:** SKILL.md סעיפים 11-12 מכילים סיכום מהיר והנחיות תהליך. מסמך זה מכיל את ההגדרות המלאות.
---
## 1. יסודות תיאורטיים
ארכיטקטורת המסמך מבוססת על שילוב של ארבעה frameworks מוכרים:
### CREAC — מתודולוגיית כתיבה משפטית
Conclusion → Rule → Explanation → Application → Conclusion.
מקור: Columbia Law School, Legal Writing methodology.
**מיפוי:** חל על בלוק י (דיון) ובלוק יא (סיכום). בלוק י פותח במסקנה (C), מציג כלל משפטי (R), מסביר באמצעות פסיקה (E), מיישם על העובדות (A), וחוזר למסקנה (C). בלוק יא = C אחרון בלבד.
### Federal Judicial Center — Judicial Writing Manual
מגדיר תפקוד פונקציונלי לכל חלק בהחלטה שיפוטית:
- **Orientation** (אוריינטציה) — מי, מה, איפה → בלוקים א-ה
- **Framing** (מסגור) — הקשר עובדתי ותכנוני → בלוק ו
- **Argumentation** (טיעון) — עמדות הצדדים → בלוק ז
- **Procedural record** (תיעוד הליכי) — מה עשינו → בלוק ח
- **Deliberation** (דיון) — ניתוח משפטי → בלוקים ט-י
- **Disposition** (החלטה) — תוצאה אופרטיבית → בלוק יא
### DITA — Darwin Information Typing Architecture
סטנדרט OASIS להגדרת סוגי תוכן מובנים. מספק:
- **Content model** — אילו אלמנטים מותרים בכל בלוק
- **Constraints** — מה אסור (חשוב יותר ממה שמותר)
- **Specialization** — ירושה מסוג בסיסי עם התאמות
- **Relationships** — תלויות בין בלוקים
### Akoma Ntoso / LegalDocumentML
סטנדרט OASIS בינלאומי למסמכים משפטיים מובנים (UN/DESA). מספק:
- **Semantic mapping** — כל בלוק ממופה לרכיב מוכר בסטנדרט
- **Document class** — "judgment" (פסק דין / החלטה)
---
## 2. הגדרות בלוקים
### Block א: כותרת מוסדית / Institutional Header
**ID:** `block-alef`
**Akoma Ntoso:** `meta > identification`
**CREAC role:** none
**Functional purpose (JWM):** Orientation — מזהה את המוסד, התיק והגורם המחליט.
**Content model:**
- Types: template-field
- Elements: טבלה 2 טורים (מוסד | מספרי תיק)
- Sources: מערכת ניהול תיקים
**Constraints:**
- MUST: שם מוסד, מספר תיק, מספר תכנית/בקשה
- MUST NOT: תוכן מהותי כלשהו
- Dependencies: none
**Weight:** 1% (קבוע, לא משתנה בין סוגי עררים)
**Processing:**
- Generation type: template-fill
- Temperature: 0 | Thinking: off | Effort: min | Model: script
### Block ב: הרכב הוועדה / Panel Composition
**ID:** `block-bet`
**Akoma Ntoso:** `meta > references > TLCPerson`
**CREAC role:** none
**Functional purpose (JWM):** Orientation — מזהה את ההרכב המחליט. חשוב לביקורת שיפוטית (הרכב כשיר).
**Content model:**
- Types: template-field
- Elements: "בפני:" + יו"ר + חברים
- Sources: מערכת ניהול
**Constraints:**
- MUST: יו"ר + לפחות חבר אחד
- MUST NOT: תוכן מהותי
- Dependencies: none
**Weight:** 1% (קבוע)
**Processing:**
- Generation type: template-fill
- Temperature: 0 | Thinking: off | Effort: min | Model: script
### Block ג: צדדים / Parties
**ID:** `block-gimel`
**Akoma Ntoso:** `meta > references > TLCPerson` (appellants, respondents)
**CREAC role:** none
**Functional purpose (JWM):** Orientation — מזהה את הצדדים וב"כ. מגדיר את מסגרת הדיון.
**Content model:**
- Types: template-field
- Elements: עוררים + "נגד" + משיבים + ב"כ
- Sources: כתב ערר, כתב תשובה
**Constraints:**
- MUST: שם כל צד, "נגד" כמפריד
- MUST NOT: תוכן מהותי, תיאור הערר
- Dependencies: none
**Weight:** 1% (קבוע)
**Processing:**
- Generation type: template-fill
- Temperature: 0 | Thinking: off | Effort: min | Model: script
### Block ד: כותרת "החלטה" / Decision Title
**ID:** `block-dalet`
**Akoma Ntoso:** `body > judgment > header`
**CREAC role:** none
**Functional purpose (JWM):** Orientation — סימון פורמלי של תחילת ההחלטה.
**Content model:**
- Types: template-field
- Elements: מילה אחת: "החלטה"
- Sources: none
**Constraints:**
- MUST: David 16pt, bold, מרכז
- Dependencies: none
**Weight:** 0% (שורה אחת)
**Processing:**
- Generation type: template-fill
- Temperature: 0 | Thinking: off | Effort: min | Model: script
### Block ה: פתיחה / Opening
**ID:** `block-he`
**Akoma Ntoso:** `body > judgment > introduction`
**CREAC role:** C (מסקנה ראשונית — הצגת מה לפנינו)
**Functional purpose (JWM):** Orientation — מכוון את הקורא למהות הערר במשפט אחד. מגדיר "להלן" מרכזיים.
**Content model:**
- Types: narrative (1-2 סעיפים)
- Elements: numbered-para עם הגדרות "להלן"
- Sources: כתב ערר, החלטת ועדה מקומית
**Constraints:**
- MUST: "לפנינו...", הגדרת הוועדה המקומית, הגדרת התכנית/הבקשה, הגדרת המגרש
- MUST NOT: ניתוח, ערכי שיפוט, ציטוטים מצדדים
- Dependencies: block-gimel (שמות צדדים להגדרות)
**Weight:** 1% (קבוע — 1-2 סעיפים)
**Processing:**
- Generation type: paraphrase
- Temperature: 0.2 | Thinking: low | Effort: low | Model: sonnet
### Block ו: רקע עובדתי / Factual Background ("פתח דבר")
**ID:** `block-vav`
**Akoma Ntoso:** `body > judgment > background`
**CREAC role:** none (עובדות בלבד, לא ניתוח)
**Functional purpose (JWM):** Framing — מספק את התשתית העובדתית שעליה נבנה הדיון. השופט חייב להבין את המציאות בשטח לפני שקורא טענות.
**Content model:**
- Types: narrative, citation-block, image-placeholder
- Elements: numbered-para, blockquote (ציטוט מפרוטוקול), image-box
- Sources: כתבי טענות, תשריטים, פרוטוקולים, החלטות קודמות, GIS
**סדר תוכן פנימי:**
1. מקרקעין — מיקום, שטח, מאפיינים
2. סביבת מקרקעין — בנייה סמוכה, אופי
3. 📷 תמונה: מיקום GIS
4. היסטוריה תכנונית — תכניות, החלטות (עובדות יבשות בלבד)
5. מהות הבקשה/תכנית
6. 📷 תמונה: תשריט
7. ציטוט מפרוטוקול ועדה מקומית
8. החלטת הוועדה + תנאים
9. 📷 תמונה: צילום אוויר (אופציונלי)
10. הגשת הערר
**Constraints:**
- MUST: מקרקעין, מהות הבקשה, החלטת הוועדה, הגשת הערר
- MUST: לפחות 2 תמונות (מיקום + תשריט)
- MUST: ציטוט מפרוטוקול הוועדה המקומית
- ⚠️ **MUST NOT ("רקע ניטרלי"):** ציטוטים ישירים מצדדים, מילות ערך/שיפוט ("חריג", "חטא", "בעייתי"). החלטות קודמות = עובדה יבשה ("ביום X נדחתה תכנית Y"), ללא נימוקים וציטוטים מהן.
- Dependencies: block-he (הגדרות "להלן")
**Weight:**
| סוג ערר | משקל | הערות |
|---------|------|-------|
| רישוי — דחייה | 15-25% | רקע מפורט עם הקשר תכנוני |
| רישוי — קבלה | 30-40% | כולל ציטוט מפרוטוקול |
| רישוי — קבלה חלקית | 25-35% | כולל ציטוט מפרוטוקול |
| היטל השבחה | 6-18% | רקע מצומצם |
**Weight methodology:**
- Communicative weight (40%): גבוה — מספק את "התמונה" לשופט שלא מכיר את התיק
- Reader attention (20%): בינוני-גבוה — primacy effect, הקורא קשוב בהתחלה
- Judicial review (25%): גבוה — שופט בודק שהעובדות מלאות ומדויקות
- Empirical (15%): מבוסס על מדידת החלטות דפנה (3.2 ב-SKILL.md)
**Processing:**
- Generation type: reproduction (העתקה נאמנה ממקורות)
- Cognitive complexity: lookup (ארגון, לא ניתוח)
- Accuracy: high-precision
- Temperature: 0 | Thinking: off | Effort: low | Model: sonnet
### Block ז: טענות הצדדים / Parties' Claims
**ID:** `block-zayin`
**Akoma Ntoso:** `body > judgment > arguments`
**CREAC role:** none (הצגת טענות, לא ניתוח)
**Functional purpose (JWM):** Argumentation — מציג את עמדות הצדדים בנאמנות, כך שהקורא יבין את המחלוקת לפני שקורא את ההכרעה.
**Content model:**
- Types: narrative
- Elements: section-heading ("תמצית טענות הצדדים"), sub-headings (לכל צד), numbered-para
- Sources: כתב ערר, כתב תשובה — **כתבי טענות מקוריים בלבד** (לא השלמות טיעון)
**סדר קבוע:**
1. כותרת: "תמצית טענות הצדדים"
2. "טענות העוררים" (אם כמה עוררים — תתי-כותרות לכל אחד)
3. "עמדת הוועדה המקומית"
4. "עמדת מבקשי ההיתר" / "עמדת מגישי התכנית"
**Constraints:**
- MUST: כל טענה בסעיף נפרד, גוף שלישי ("העורר טוען כי...")
- MUST: כל צד בפרק נפרד, סדר קבוע
- MUST NOT: ניתוח, מסקנות, הערכת הוועדה ("טענה זו חלשה...")
- MUST NOT: תוכן מהשלמות טיעון (→ block-chet)
- Dependencies: block-vav (מספור רציף)
**Weight:**
| סוג ערר | משקל | הערות |
|---------|------|-------|
| רישוי — דחייה | 30-40% | טענות מפורטות |
| רישוי — קבלה | 20-30% | כולל השלמות |
| רישוי — קבלה חלקית | 25-30% | |
| היטל השבחה | 13-25% | |
**Weight methodology:**
- Communicative weight (40%): בינוני — הצגה, לא הכרעה
- Reader attention (20%): נמוך-בינוני — scanning attention, הקורא מחפש טענות ספציפיות
- Judicial review (25%): גבוה — שופט בודק ש"נשמעו כל הצדדים"
- Empirical (15%): מבוסס על מדידת החלטות דפנה
**Processing:**
- Generation type: paraphrase (סיכום נאמן בשפה של דפנה)
- Cognitive complexity: medium-synthesis (קיבוץ וסידור טענות)
- Accuracy: high-precision (לא לפספס טענה, לא לעוות)
- Temperature: 0.1 | Thinking: low | Effort: medium | Model: sonnet
### Block ח: הליכים בפני ועדת הערר / Proceedings
**ID:** `block-chet`
**Akoma Ntoso:** `body > judgment > proceedings` (custom extension)
**CREAC role:** none (תיעוד, לא ניתוח)
**Functional purpose (JWM):** Procedural record — מתעד שהוועדה פעלה כדין ונתנה מלוא יום בבית דין. קריטי ל"מבחן השופט" — שופט בעתמ"ם בודק שהצדדים קיבלו הזדמנות הוגנת.
**Content model:**
- Types: narrative, image-placeholder
- Elements: section-heading ("ההליכים בפני ועדת הערר"), numbered-para, image-box
- Sources: פרוטוקול דיון, תמונות סיור, החלטות ביניים, השלמות טיעון
**סדר כרונולוגי:**
1. דיון — תאריך, נוכחים
2. סיור — תאריך, תיאור
3. 📷 תמונה: צילומים מהסיור
4. השלמות טיעון — עם תוכן מפורט (כל השלמה = סעיף נפרד)
5. החלטות ביניים
6. תגובות לתגובות — כרונולוגי
7. 📷 תמונה: הדמיות/חתכים (אם צורפו)
8. עררים מקבילים (אם יש)
**Constraints:**
- MUST: תאריכים מדויקים, כרונולוגיה ברורה
- MUST: תוכן השלמות טיעון מפורט — כל השלמה בסעיף נפרד עם תמצית תוכן
- MUST NOT: ניתוח או הערכה של ההשלמות ("טענה חזקה/חלשה")
- Dependencies: block-zayin (מספור רציף)
- References: block-zayin (הפניה לטענות מקוריות כשיש חפיפה)
**Weight:**
| סוג ערר | משקל | הערות |
|---------|------|-------|
| ערר פשוט (ללא השלמות) | 3-5% | דיון + סיור בלבד |
| ערר מורכב (השלמות רבות) | 8-15% | כמו אריאלי: 31 סעיפים |
| היטל השבחה | 2-4% | בדרך כלל מינימלי |
**Weight methodology:**
- Communicative weight (40%): נמוך-בינוני — תיעוד, לא הכרעה
- Reader attention (20%): נמוך — scanning, אלא אם יש ממצאים חדשים מסיור/השלמות
- Judicial review (25%): **גבוה מאוד** — שופט בודק שנתנו procedural fairness
- Empirical (15%): מגוון רחב — תלוי בכמות ההשלמות
**Processing:**
- Generation type: reproduction + paraphrase (תאריכים מדויקים + תמצית תוכן)
- Cognitive complexity: low (סידור כרונולוגי)
- Accuracy: high-precision (תאריכים, שמות מסמכים)
- Temperature: 0 | Thinking: off | Effort: low | Model: sonnet
### Block ט: תכניות חלות / Applicable Plans (אופציונלי)
**ID:** `block-tet`
**Akoma Ntoso:** `body > judgment > motivation > background` (extended)
**CREAC role:** R (Rule — הצגת הכללים המשפטיים/תכנוניים)
**Functional purpose (JWM):** Deliberation (preliminary) — מציג את המסגרת הנורמטיבית שלאורה ייבחנו הטענות. בלוק גשר בין עובדות לניתוח.
**Content model:**
- Types: narrative, citation-block
- Elements: section-heading, numbered-para, blockquote (ציטוט מהוראות תכנית)
- Sources: הוראות תכנית (PDF), נספחי בינוי, החלטות מרכזות
**Constraints:**
- MUST: ציטוט ישיר מהוראות תכנית עם הדגשת (bold) מילים מכריעות
- MUST NOT: ניתוח מעמיק (→ block-yod), הכרעה בין פרשנויות
- Dependencies: block-chet (מספור), block-vav (הגדרות תכניות)
- Condition: **אופציונלי** — רק כשיש מורכבות תכנונית (תכניות סותרות, תמ"א 38 + שימור, פרשנות)
**Weight:**
| מתי קיים | משקל |
|----------|------|
| תמ"א 38 + שימור | 8-12% |
| פרשנות תכנית | 5-10% |
| לא קיים | 0% |
**Weight methodology:**
- Communicative weight (40%): בינוני — הנחת תשתית נורמטיבית
- Reader attention (20%): נמוך — טכני, אלא אם פרשנות שנויה במחלוקת
- Judicial review (25%): בינוני — שופט בודק שהוועדה הבינה את הדין
- Empirical (15%): אריאלי — 14 סעיפים; בית הכרם — משולב בדיון
**Processing:**
- Generation type: guided-synthesis (ציטוט + ניתוח ראשוני)
- Cognitive complexity: medium (פרשנות טקסט משפטי)
- Accuracy: precision + interpretation
- Temperature: 0.2 | Thinking: medium | Effort: medium | Model: opus
### Block י: דיון והכרעה / Discussion and Decision
**ID:** `block-yod`
**Akoma Ntoso:** `body > judgment > motivation`
**CREAC role:** **full-CREAC** — C (מסקנה בפתיחה) → R (כלל משפטי) → E (ציטוט פסיקה) → A (יישום על העובדות) → C (מסקנת ביניים)
**Functional purpose (JWM):** Deliberation — ליבת ההחלטה. כאן הוועדה מנתחת, מאזנת, ומכריעה. זהו ה-ratio decidendi.
**Content model:**
- Types: narrative, citation-block, image-placeholder
- Elements: numbered-para (אסה רציפה ללא כותרות משנה), blockquote (ציטוטי פסיקה ותכנית), image-box
- Sources: **כל** הבלוקים הקודמים + פסיקה + skill
**מבנה פנימי (לפי סוג ערר — ראה SKILL.md סעיף 7.3):**
- דחייה: שכבות הגנה (concentric circles)
- קבלה: נימוק-נימוק
- קבלה חלקית: מיפוי מתחים + ניתוח נושאי
- היטל השבחה: פתיחה ישירה עם מסקנה
**Constraints:**
- MUST: מסקנה בפתיחת הדיון (לא בסוף)
- MUST: מענה לכל טענה שהוצגה בבלוק ז
- MUST: ציטוט פסיקה בבלוקים ארוכים (200-600 מילים)
- ⚠️ **MUST NOT ("ללא כפילות"):** חזרה על עובדות/טענות מבלוקים קודמים. השתמש בהפניות: "כאמור בסעיף X לעיל", "כפי שפורט", "כפי שציינו"
- MUST NOT: כותרות משנה (חריג: נושאים נפרדים לחלוטין)
- Dependencies: **ALL** previous blocks (ה-ט)
**Weight:**
| סוג ערר | משקל | הערות |
|---------|------|-------|
| רישוי — דחייה | 37-50% | פתיחה רחבה + שכבות |
| רישוי — קבלה | 35-45% | נימוק-נימוק |
| רישוי — קבלה חלקית | 40-47% | מיפוי מתחים + ניתוח נושאי |
| היטל השבחה | 32-48% | ציטוטי פסיקה מרובים |
**Weight methodology:**
- Communicative weight (40%): **מקסימלי** — זהו ה-ratio decidendi, תכלית ההחלטה
- Reader attention (20%): **גבוה** — deep reading, הקורא מחפש את הנימוקים
- Judicial review (25%): **מקסימלי** — שופט בוחן סבירות, מידתיות, התייחסות לטענות
- Empirical (15%): 35-50% באופן עקבי בכל החלטות דפנה
**Processing:**
- Generation type: **rhetorical-construction** (בניית טיעון, איזון, רטוריקה)
- Cognitive complexity: **high-reasoning** (CREAC מלא, שכבות, חידוד)
- Accuracy: **precision + creativity** (ניתוח מדויק + ביטוי אלגנטי)
- Temperature: **0.4** | Thinking: **max (budget 16K+)** | Effort: **max** | Model: **opus בלבד**
### Block יא: סיכום / סוף דבר / Summary
**ID:** `block-yod-alef`
**Akoma Ntoso:** `body > judgment > decision`
**CREAC role:** C (Conclusion אחרון — תמצית אופרטיבית)
**Functional purpose (JWM):** Disposition — ההוראה האופרטיבית שמבצעים. זה מה שהצדדים צריכים לדעת "מה עכשיו."
**Content model:**
- Types: narrative
- Elements: section-heading ("סיכום"/"סוף דבר"), numbered-para, sub-items (א. ב. ג.)
- Sources: block-yod (מסקנות)
**מבנה לפי תוצאה (ראה SKILL.md סעיף 8):**
- דחייה: "הערר נדחה" + תתי-סעיפים + פסקה חמה (רישוי בלבד)
- קבלה: "הערר מתקבל בכפוף ל..." + פרוזה
- קבלה חלקית: "הערר מתקבל באופן חלקי" + 2-3 הוראות אופרטיביות
- היטל השבחה: יבש
**Constraints:**
- MUST: תוצאה ברורה (נדחה/מתקבל/מתקבל חלקית)
- MUST NOT (בקבלה חלקית): חזרה על נימוקים — ההנמקה כבר בדיון
- Dependencies: block-yod (מסקנות)
**Weight:**
| סוג ערר | משקל |
|---------|------|
| דחייה | 2-9% |
| קבלה | 3-5% |
| קבלה חלקית | 2-3% |
| היטל השבחה | 3-4% |
**Processing:**
- Generation type: paraphrase (עיבוד מסקנות בלוק י)
- Cognitive complexity: low
- Accuracy: high-precision (הוראות חייבות להיות חד-משמעיות)
- Temperature: 0.1 | Thinking: low | Effort: low | Model: sonnet
### Block יב: חתימות / Signatures
**ID:** `block-yod-bet`
**Akoma Ntoso:** `conclusions > signature`
**CREAC role:** none
**Functional purpose (JWM):** Authentication — אישור פורמלי של ההחלטה.
**Content model:**
- Types: template-field
- Elements: "ניתנה פה אחד" + תאריך עברי/לועזי + טבלת חתימות
- Sources: none
**Constraints:**
- MUST: "ניתנה פה אחד", תאריך, יו"ר + מזכיר/ה
- Dependencies: none
**Weight:** 1% (קבוע)
**Processing:**
- Generation type: template-fill
- Temperature: 0 | Thinking: off | Effort: min | Model: script
---
## 3. כללי גזירת פרמטרים
פרמטרי העיבוד נגזרים ממאפייני התוכן, לא נקבעים שרירותית:
### Temperature — נגזר מסוג הייצור
| Generation type | Temperature | נימוק |
|----------------|-------------|-------|
| template-fill | 0 | אין צורך בשפה — מילוי שדות |
| reproduction | 0 | נאמנות מוחלטת למקור. אפס יצירתיות |
| paraphrase | 0.1 | מרווח מינימלי לניסוח בשפה של דפנה |
| guided-synthesis | 0.2 | גמישות בארגון וחיבור מקורות, לא בתוכן |
| analytical-reasoning | 0.3-0.4 | צריך ליצור קשרים בין עקרונות משפטיים |
| rhetorical-construction | 0.4-0.5 | טווח ביטוי רחב לכתיבה משכנעת ואלגנטית |
### Thinking budget — נגזר ממורכבות קוגניטיבית
| Cognitive task | Budget | נימוק |
|---------------|--------|-------|
| template-fill / lookup | off | אין צורך בחשיבה |
| sequential-extraction | low | חילוץ מידע חד-שלבי |
| multi-source-integration | medium | צריך להצליב מקורות |
| legal-analysis-with-CREAC | max (16K+) | חשיבה רב-שלבית: מסקנה → כלל → הסבר → יישום |
### Model — נגזר מדרישת דיוק
| Accuracy profile | Model | נימוק |
|-----------------|-------|-------|
| factual-precision | sonnet | מהיר, מדויק לחילוץ עובדות |
| precision + interpretation | opus | נדרש לפרשנות תכנית / ציטוט מובנה |
| precision + creativity | opus | נדרש לניתוח משפטי מורכב ורטוריקה |
---
## 4. מתודולוגיית משקלות
משקל כל בלוק נקבע על ידי שקלול 4 גורמים:
### 4.1 Communicative Weight (40%)
מה חלקו של הבלוק בתכלית ההחלטה? ההחלטה באה לעשות דבר אחד: להכריע במחלוקת ולנמק. בלוק י (דיון) הוא ליבת התכלית. בלוקים א-ד (כותרות) הם עטיפה.
### 4.2 Reader Attention Distribution (20%)
מבוסס על מחקרי F-pattern ו-primacy/recency:
- **פתיחה** (בלוקים ה-ו): קשב גבוה (primacy effect)
- **אמצע** (בלוקים ז-ח): scanning — הקורא מחפש טענות ספציפיות
- **דיון** (בלוק י): deep reading — הקורא מחפש נימוקים
- **סיום** (בלוק יא): קשב גבוה (recency effect)
### 4.3 Judicial Review Requirement (25%)
מה שופט בבית משפט לעניינים מנהליים יבדוק ("מבחן השופט"):
- **תשתית עובדתית** (בלוק ו): מלאה ומדויקת?
- **שמיעת צדדים** (בלוקים ז-ח): נתנו מלוא יום בבית דין?
- **סבירות ומידתיות** (בלוק י): ההכרעה מנומקת ומאוזנת?
- **התייחסות לטענות** (בלוק י): כל טענה קיבלה מענה?
### 4.4 Empirical Basis (15%)
מבוסס על מדידה מהחלטות שפורסמו:
- הכט 1180-1181 (דחייה, 02.2026)
- בית הכרם 1126/25 (קבלה חלקית, 03.2026)
- אריאלי 1078+1083 (קבלה, 03.2026)
המשקלות ב-SKILL.md סעיף 3.2 (יחסי הזהב) משמשים כבסיס אמפירי שאומת על ידי שלושת הגורמים האנליטיים.
---
## 5. כללי ולידציה
### 5.1 סדר בלוקים
- בלוקים חייבים להופיע בסדר א עד יב
- בלוקים א-ה ויב נדרשים בכל החלטה
- בלוק ט אופציונלי (רק כשיש מורכבות תכנונית)
### 5.2 Content Constraints
- **רקע ניטרלי (בלוק ו):** אם סעיף מכיל ציטוט ישיר מצד או מילת שיפוט → לא שייך כאן
- **טענות מקוריות בלבד (בלוק ז):** רק מכתבי ערר/תשובה. השלמות → בלוק ח
- **ללא כפילות (בלוק י):** הפניה לבלוקים קודמים, לא חזרה. חריג: "נשוב על כך כי..." (חזרה מכוונת עם שכבה חדשה)
- **הליכים ללא הערכה (בלוק ח):** תיעוד מה הוגש, לא הערכה של חוזק הטענות
### 5.3 Weight Compliance
- משקל כל בלוק (ספירת מילים / סה"כ) צריך להיות בטווח המוגדר **±10%**
- אם בלוק י < 30% → flag: דיון לא מפותח מספיק
- אם בלוק ו > 35% → flag: רקע מנופח, בדוק שאין תוכן טענתי
### 5.4 Structural Integrity
- מספור סעיפים רציף מ-1 עד הסוף, ללא איפוס בין בלוקים
- כל הגדרת "להלן" חייבת להופיע לפני השימוש הראשון בה
- כל טענה בבלוק ז חייבת לקבל מענה בבלוק י (ישיר או "למעלה מן הצורך")
- כותרות פרקים: David 14pt, bold, קו תחתון, מרכז
- כותרות משנה: David 12pt, bold, מרכז, ללא קו תחתון
---
## 6. גרף תלויות בין בלוקים
```
א (כותרת) → עצמאי
ב (הרכב) → עצמאי
ג (צדדים) → עצמאי
ד (כותרת) → עצמאי
ה (פתיחה) → תלוי ב: ג (שמות צדדים להגדרות "להלן")
ו (רקע) → תלוי ב: ה (הגדרות). מספור ממשיך מ-ה.
ז (טענות) → תלוי ב: ו (מספור). מפנה ל: ה, ו (הגדרות)
ח (הליכים) → תלוי ב: ז (מספור). מפנה ל: ז (טענות מקוריות)
ט (תכניות) → תלוי ב: ח (מספור). אופציונלי. מפנה ל: ו (הגדרות תכניות)
י (דיון) → תלוי ב: **כל** הבלוקים ה-ט. מפנה ל: כולם.
יא (סיכום) → תלוי ב: י (מסקנות). מפנה ל: י בלבד.
יב (חתימות) → עצמאי
```

View File

@@ -1,20 +0,0 @@
#!/bin/sh
# Start FastAPI backend + Next.js frontend in the same container.
# Both processes log to stdout/stderr so Docker captures everything.
set -e
echo "[start.sh] Starting FastAPI backend on :8000 ..."
uvicorn web.app:app --host 127.0.0.1 --port 8000 --workers 1 2>&1 &
UVICORN_PID=$!
# Give uvicorn a moment to start (or crash)
sleep 2
if ! kill -0 $UVICORN_PID 2>/dev/null; then
echo "[start.sh] ERROR: uvicorn failed to start!"
# Don't exit — let Node.js run so the UI is accessible for debugging
fi
echo "[start.sh] Starting Next.js frontend on :3000 ..."
node server.js

41
web-ui/.gitignore vendored
View File

@@ -1,41 +0,0 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# env files (can opt-in for committing if needed)
.env*
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

View File

@@ -1,5 +0,0 @@
<!-- BEGIN:nextjs-agent-rules -->
# This is NOT the Next.js you know
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
<!-- END:nextjs-agent-rules -->

View File

@@ -1 +0,0 @@
@AGENTS.md

View File

@@ -1,175 +0,0 @@
# עוזר משפטי — Web UI (Next.js rewrite)
The Next.js 16 rewrite of `legal-ai.nautilus.marcusgroup.org`, currently hosted side-by-side with the legacy vanilla `index.html` at:
- **Staging:** https://legal-ai-next.nautilus.marcusgroup.org (auto-deployed from `ui-rewrite` branch via Coolify)
- **Production FastAPI:** https://legal-ai.nautilus.marcusgroup.org (same backend, old UI still default)
The rewrite talks to the existing FastAPI via proxy rewrites in `next.config.ts` — no CORS setup, no duplicated backend.
## Stack
- Next.js 16.2.3 (App Router, Turbopack, `output: "standalone"`)
- React 19.2 · TypeScript · Tailwind v4 · shadcn/ui (radix-nova preset)
- TanStack Query v5 + TanStack Table v8
- react-hook-form + zod for mutations
- react-dropzone for uploads; EventSource for SSE progress
- Heebo via `next/font/google`; design tokens in `src/app/globals.css`
## Local development
```bash
npm install
npm run dev # http://localhost:3000
npm run build # full type check + production build
npm run lint
npm run api:types # regenerate src/lib/api/types.ts from FastAPI's OpenAPI
```
### API connection
By default the dev server proxies to production FastAPI (`https://legal-ai.nautilus.marcusgroup.org`). To point at a different backend, set:
```bash
export NEXT_PUBLIC_API_ORIGIN=http://localhost:8000
npm run dev
```
## Project layout
```
src/
├── app/ # Route segments (App Router)
│ ├── layout.tsx # Root: Providers + RTL html + fonts
│ ├── page.tsx # Home: KPIs + status donut + cases table
│ ├── error.tsx # Route-segment error boundary
│ ├── global-error.tsx # Root crash fallback
│ ├── not-found.tsx # 404
│ ├── cases/
│ │ ├── new/ # 3-step create wizard
│ │ └── [caseNumber]/
│ │ ├── page.tsx # Case detail (tabs + workflow timeline)
│ │ └── compose/ # Research analysis + chair-position editor
│ ├── training/ # Style portrait + corpus + compare (3 tabs)
│ ├── skills/ # Paperclip skills inventory
│ └── diagnostics/ # DB health + failed/stuck docs
├── components/
│ ├── app-shell.tsx # Header + nav with aria-current
│ ├── cases/ # Home + detail screens
│ ├── compose/ # Research analysis editor
│ ├── documents/ # UploadSheet
│ ├── training/ # Style report / corpus / compare panels
│ ├── wizard/ # Case create wizard + parties-field
│ └── ui/ # shadcn primitives
├── lib/
│ ├── api/ # Typed hooks per domain (cases, documents, research,
│ │ # system, skills, training)
│ ├── schemas/ # zod schemas (case create / update)
│ ├── practice-area.ts # Multi-tenant axis enum + deriveSubtype()
│ ├── sse.ts # EventSource wrapper
│ ├── providers.tsx # QueryClient + Toaster
│ └── utils.ts # cn()
```
## Smoke test (run after every deploy)
Use any browser at the staging URL. Every step should be doable **without console errors** and each mutation should produce a visible toast.
### 1. Home · `/`
- [ ] Header nav shows 5 items; the current page is underlined in gold
- [ ] 4 KPI cards render real numbers (סה״כ · בהכנה · בכתיבה · מוכנים)
- [ ] Cases table lists existing cases; search filters by case number or title
- [ ] "פיזור סטטוסים" donut renders with a legend
- [ ] "+ תיק חדש" button in the top-left navigates to `/cases/new`
### 2. Create case · `/cases/new`
- [ ] 3-step wizard: פרטי יסוד → צדדים → השלמות
- [ ] Type `1500-25` → appeal_subtype auto-fills to "רישוי ובנייה"
- [ ] Type `8500-25` → subtype auto-fills to "היטל השבחה"
- [ ] Manually pick a different subtype → auto-fill stops
- [ ] Submitting with invalid case number shows a zod field error (no crash)
- [ ] Successful create → toast "תיק חדש נוצר" → router pushes to `/cases/{number}`
### 3. Case detail · `/cases/[caseNumber]`
- [ ] Header shows status badge + gold "ועדת ערר · X" practice-area badge
- [ ] Tabs switch cleanly: סקירה / מסמכים / פעולות
- [ ] Workflow timeline on the right shows the current phase highlighted in gold
- [ ] פעולות tab → "עריכת פרטי תיק" dialog opens; submitting updates the header without full reload (optimistic cache patch)
- [ ] "העלאת מסמכים" sheet opens from the tab row; drag-drop fires a POST and a live progress bar appears via SSE
### 4. Compose · `/cases/[caseNumber]/compose`
- [ ] If analysis-and-research.md exists: threshold claims + issues render as collapsible cards
- [ ] Chair-position textarea auto-saves on blur with "✓ נשמר {time}" indicator
- [ ] If 404 (no analysis yet): empty state card renders, no error toast
### 5. Training · `/training`
- [ ] **Report tab:** headline card, 4 KPIs, subject donut, anatomy bars, top-12 signature phrases
- [ ] **Corpus tab:** table of corpus decisions with a trash icon per row (aria-label present)
- [ ] Deleting a decision refreshes both the corpus table and the report KPIs
- [ ] **Compare tab:** two Selects, pick 2 different decisions, side-by-side panels + shared/only-A/only-B pattern lists
### 6. Skills · `/skills`
- [ ] Card grid of Paperclip skills with sync-status badges (מסונכרן / DB בלבד / לא סונכרן)
- [ ] Chars + file counts render; "לא ידוע" doesn't appear for installed skills
### 7. Diagnostics · `/diagnostics`
- [ ] DB status card shows "מחובר" in green
- [ ] Table counts populate for cases / documents / chunks / corpus / patterns
- [ ] Failed + stuck document lists render (empty states OK)
- [ ] Page self-refreshes every 10s — check the network tab for recurring calls
### 8. Error boundary
- [ ] Visit `/cases/NOT-REAL-999-99` → case detail shows an error card with the FastAPI message and "חזרה לרשימת התיקים" button (no white screen)
- [ ] Visit `/anything-broken-xyz` → custom 404 page with "חזרה לבית" button
### 9. Keyboard + RTL
- [ ] Tab through the home page — focus rings are gold, visible
- [ ] Wizard progresses via Enter on the "הבא" button
- [ ] Screen reader announces nav items with "עמוד נוכחי" on the active one
## Deploy
```
git push # → Coolify auto-build on branch ui-rewrite (~90 s)
```
> **Known issue:** the Gitea → Coolify webhook is not firing at the time of writing. Trigger a manual deploy via the Coolify MCP (`mcp__coolify__deploy` with app UUID `l146g36mtlp0k03vrwkyrgkk`) or the Coolify UI until the webhook is fixed.
## Phase tracking
See `~/.claude/plans/joyful-marinating-sutton.md` for the 7-phase rewrite plan and `~/legal-ai-ui-rewrite/.taskmaster/tasks/tasks.json` for the task board.
| Phase | Scope | Status |
|---|---|---|
| 1 | Scaffold + Coolify staging | ✅ |
| 2 | API client + typed hooks + probe | ✅ |
| 3 | Read views (home, case detail, compose) | ✅ |
| 4 | Mutations (wizard, edit, upload+SSE) | ✅ |
| 4.5 | Practice-area integration | ✅ |
| 5 | Secondary screens (training, skills, diagnostics) | ✅ |
| 6 | Polish, a11y, error boundaries, smoke test | ✅ |
| 7 | DNS cutover to production | pending |
## Backend contract
The new UI consumes the existing FastAPI at `legal-ai/web/app.py`. Key endpoints currently relied on:
| Endpoint | Hook | Used by |
|---|---|---|
| `GET /api/cases?detail=true` | `useCases` | home table, KPIs |
| `GET /api/cases/{n}/details` | `useCase` | case detail |
| `POST /api/cases/create` | `useCreateCase` | wizard |
| `PUT /api/cases/{n}` | `useUpdateCase` | inline edit |
| `DELETE /api/cases?case_number=...` | (MCP only so far) | admin cleanup |
| `POST /api/cases/{n}/documents/upload-tagged` | `useUploadDocument` | upload sheet |
| `GET /api/progress/{task_id}` (SSE) | `useProgress` | upload progress |
| `GET /api/cases/{n}/research/analysis` | `useResearchAnalysis` | compose |
| `PATCH .../chair-position` | `useSaveChairPosition` | chair editor |
| `GET /api/training/style-report` | `useStyleReport` | training/report tab |
| `GET /api/training/corpus` | `useCorpus` | training/corpus tab |
| `GET /api/training/compare` | `useCompare` | training/compare tab |
| `DELETE /api/training/corpus/{id}` | `useDeleteCorpusEntry` | corpus tab |
| `GET /api/system/diagnostics` | `useDiagnostics` | diagnostics page |
| `GET /api/admin/skills` | `useSkills` | skills page |
Any new endpoint should get a typed hook in `src/lib/api/` — do not reach into `fetch` from component code.

View File

@@ -1,25 +0,0 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "radix-nova",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/app/globals.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"iconLibrary": "lucide",
"rtl": true,
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"menuColor": "default",
"menuAccent": "subtle",
"registries": {}
}

View File

@@ -1,18 +0,0 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";
const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);
export default eslintConfig;

View File

@@ -1,30 +0,0 @@
import type { NextConfig } from "next";
/**
* Proxies /api/* and /openapi.json to the FastAPI backend.
* In Docker both processes run in the same container, so the default
* target is http://127.0.0.1:8000. Override with NEXT_PUBLIC_API_ORIGIN
* if the backend lives elsewhere (e.g. during local dev).
*/
const API_ORIGIN =
process.env.NEXT_PUBLIC_API_ORIGIN ?? "http://127.0.0.1:8000";
const nextConfig: NextConfig = {
output: "standalone",
async rewrites() {
return [
{
source: "/api/:path*",
destination: `${API_ORIGIN}/api/:path*`,
},
{
source: "/openapi.json",
destination: `${API_ORIGIN}/openapi.json`,
},
];
},
};
export default nextConfig;

13235
web-ui/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,45 +0,0 @@
{
"name": "web-ui",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint",
"api:types": "openapi-typescript https://legal-ai.nautilus.marcusgroup.org/openapi.json -o src/lib/api/types.ts"
},
"dependencies": {
"@hookform/resolvers": "^5.2.2",
"@tanstack/react-query": "^5.97.0",
"@tanstack/react-table": "^8.21.3",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^1.8.0",
"next": "16.2.3",
"next-themes": "^0.4.6",
"radix-ui": "^1.4.3",
"react": "19.2.4",
"react-dom": "19.2.4",
"react-dropzone": "^15.0.0",
"react-hook-form": "^7.72.1",
"react-markdown": "^10.1.0",
"remark-gfm": "^4.0.1",
"shadcn": "^4.2.0",
"sonner": "^2.0.7",
"tailwind-merge": "^3.5.0",
"tw-animate-css": "^1.4.0",
"zod": "^4.3.6"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "16.2.3",
"openapi-typescript": "^7.13.0",
"tailwindcss": "^4",
"typescript": "^5"
}
}

View File

@@ -1,7 +0,0 @@
const config = {
plugins: {
"@tailwindcss/postcss": {},
},
};
export default config;

View File

@@ -1 +0,0 @@
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>

Before

Width:  |  Height:  |  Size: 391 B

View File

@@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>

Before

Width:  |  Height:  |  Size: 128 B

View File

@@ -1 +0,0 @@
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>

Before

Width:  |  Height:  |  Size: 385 B

View File

@@ -1,312 +0,0 @@
"use client";
import { use, useRef, useState } from "react";
import Link from "next/link";
import { AppShell } from "@/components/app-shell";
import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { SubsectionCard } from "@/components/compose/subsection-card";
import { PrecedentsSection } from "@/components/compose/precedents-section";
import { Markdown } from "@/components/ui/markdown";
import { useCase } from "@/lib/api/cases";
import { useResearchAnalysis } from "@/lib/api/research";
import { useCasePrecedents } from "@/lib/api/precedents";
function ProseSection({ title, content }: { title: string; content?: string }) {
if (!content?.trim()) return null;
return (
<section className="space-y-2">
<h3 className="text-[0.78rem] uppercase tracking-[0.08em] text-gold-deep font-semibold">
{title}
</h3>
<Markdown content={content.trim()} />
</section>
);
}
function AnalysisActions({
caseNumber,
hasAnalysis,
onUploaded,
}: {
caseNumber: string;
hasAnalysis: boolean;
onUploaded: () => void;
}) {
const fileRef = useRef<HTMLInputElement>(null);
const [uploading, setUploading] = useState(false);
const [uploadMsg, setUploadMsg] = useState<{ ok: boolean; text: string } | null>(null);
async function handleUpload(file: File) {
setUploading(true);
setUploadMsg(null);
try {
const form = new FormData();
form.append("file", file);
const res = await fetch(`/api/cases/${caseNumber}/research/analysis/upload`, {
method: "PUT",
body: form,
});
const data = await res.json();
if (!res.ok) {
setUploadMsg({ ok: false, text: data.detail || "שגיאה בהעלאה" });
return;
}
setUploadMsg({
ok: true,
text: `הקובץ הועלה בהצלחה — ${data.sections.threshold_claims} טענות סף, ${data.sections.issues} סוגיות`,
});
onUploaded();
} catch {
setUploadMsg({ ok: false, text: "שגיאת רשת" });
} finally {
setUploading(false);
if (fileRef.current) fileRef.current.value = "";
}
}
return (
<div className="flex items-center gap-2 flex-wrap">
{uploadMsg && (
<span className={`text-xs ${uploadMsg.ok ? "text-green-700" : "text-red-600"}`}>
{uploadMsg.text}
</span>
)}
<input
ref={fileRef}
type="file"
accept=".md"
className="hidden"
onChange={(e) => {
const f = e.target.files?.[0];
if (f) handleUpload(f);
}}
/>
<Button
variant="outline"
disabled={uploading}
onClick={() => fileRef.current?.click()}
>
{uploading ? "מעלה..." : "העלה ניתוח מעודכן"}
</Button>
{hasAnalysis && (
<Button
variant="outline"
onClick={() => {
const a = document.createElement("a");
a.href = `/api/cases/${caseNumber}/research/analysis/download`;
a.download = `analysis-${caseNumber}.md`;
a.click();
}}
>
הורד ניתוח
</Button>
)}
<Button asChild variant="outline">
<Link href={`/cases/${caseNumber}`}>חזרה לתיק</Link>
</Button>
</div>
);
}
export default function ComposePage({
params,
}: {
params: Promise<{ caseNumber: string }>;
}) {
const { caseNumber } = use(params);
const caseQuery = useCase(caseNumber);
const analysis = useResearchAnalysis(caseNumber);
const precedentsQuery = useCasePrecedents(caseNumber);
/* Partition the flat list into scopes so each child renders its own slice
* without re-fetching. Done once at the page level. */
const allPrecedents = precedentsQuery.data ?? [];
const caseLevelPrecedents = allPrecedents.filter((p) => p.section_id === null);
const precedentsBySection = new Map<string, typeof allPrecedents>();
for (const p of allPrecedents) {
if (p.section_id) {
const existing = precedentsBySection.get(p.section_id) ?? [];
existing.push(p);
precedentsBySection.set(p.section_id, existing);
}
}
const practiceArea = caseQuery.data?.practice_area ?? null;
const isNotFound =
analysis.error instanceof Error &&
/404|לא נמצא|טרם בוצע/.test(analysis.error.message);
return (
<AppShell>
<section className="space-y-6">
{/* Header strip */}
<div className="flex items-center justify-between gap-4 flex-wrap">
<div>
<nav className="text-[0.78rem] text-ink-muted flex items-center gap-2 mb-1">
<Link href="/" className="hover:text-gold-deep">בית</Link>
<span aria-hidden>·</span>
<Link
href={`/cases/${caseNumber}`}
className="hover:text-gold-deep"
>
ערר {caseNumber}
</Link>
<span aria-hidden>·</span>
<span className="text-navy">עורך החלטה</span>
</nav>
<h1 className="text-navy mb-0">ניתוח משפטי וכתיבת עמדה</h1>
{caseQuery.data?.title && (
<p className="text-ink-muted text-sm mt-1 max-w-2xl">
{caseQuery.data.title}
</p>
)}
</div>
<AnalysisActions caseNumber={caseNumber} hasAnalysis={!!analysis.data} onUploaded={() => analysis.refetch()} />
</div>
<div className="h-[2px] bg-gradient-to-l from-transparent via-gold to-transparent" />
{analysis.isPending ? (
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-6 py-5 space-y-3">
<Skeleton className="h-6 w-48" />
<Skeleton className="h-4 w-96" />
<Skeleton className="h-4 w-80" />
<Skeleton className="h-32 w-full" />
</CardContent>
</Card>
) : isNotFound ? (
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-6 py-12 text-center space-y-3">
<div className="text-gold text-3xl" aria-hidden></div>
<h2 className="text-navy text-lg mb-0">
טרם בוצע ניתוח משפטי לתיק זה
</h2>
<p className="text-ink-muted text-sm max-w-md mx-auto">
לאחר שקובץ <code>analysis-and-research.md</code> ייווצר, תוכלי
לערוך כאן את עמדת הוועדה לכל טענת סף וסוגיה.
</p>
</CardContent>
</Card>
) : analysis.error ? (
<Card className="bg-danger-bg border-danger/40">
<CardContent className="px-6 py-5 text-center">
<p className="text-danger">{analysis.error.message}</p>
</CardContent>
</Card>
) : analysis.data ? (
<div className="space-y-6">
{/* Case-level general precedents */}
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-6 py-5">
<h2 className="text-navy text-xl mb-1">פסיקה כללית לדיון</h2>
<p className="text-[0.78rem] text-ink-muted mb-4">
ציטוטים התומכים בעמדה באופן רוחבי ישולבו בפתיחת בלוק י (דיון).
</p>
<PrecedentsSection
caseNumber={caseNumber}
sectionId={null}
precedents={caseLevelPrecedents}
practiceArea={practiceArea}
emptyHelperText="עדיין לא צורפה פסיקה כללית לתיק"
/>
</CardContent>
</Card>
{/* Threshold claims */}
{analysis.data.threshold_claims &&
analysis.data.threshold_claims.length > 0 && (
<div className="space-y-3">
<div className="flex items-center gap-2">
<h2 className="text-navy text-xl mb-0">טענות סף</h2>
<span className="text-[0.72rem] rounded-full bg-gold-wash text-gold-deep px-2 py-0.5 border border-gold/40 tabular-nums">
{analysis.data.threshold_claims.length}
</span>
</div>
<div className="space-y-3">
{analysis.data.threshold_claims.map((tc) => (
<SubsectionCard
key={tc.id}
caseNumber={caseNumber}
item={tc}
precedents={precedentsBySection.get(tc.id) ?? []}
practiceArea={practiceArea}
/>
))}
</div>
</div>
)}
{/* Issues */}
{analysis.data.issues && analysis.data.issues.length > 0 && (
<div className="space-y-3">
<div className="flex items-center gap-2">
<h2 className="text-navy text-xl mb-0">סוגיות להכרעה</h2>
<span className="text-[0.72rem] rounded-full bg-gold-wash text-gold-deep px-2 py-0.5 border border-gold/40 tabular-nums">
{analysis.data.issues.length}
</span>
</div>
<div className="space-y-3">
{analysis.data.issues.map((iss) => (
<SubsectionCard
key={iss.id}
caseNumber={caseNumber}
item={iss}
precedents={precedentsBySection.get(iss.id) ?? []}
practiceArea={practiceArea}
/>
))}
</div>
</div>
)}
{(!analysis.data.threshold_claims?.length &&
!analysis.data.issues?.length) && (
<Card className="bg-surface border-rule">
<CardContent className="px-6 py-10 text-center text-ink-muted">
לא נמצאו טענות סף או סוגיות בניתוח זה.
</CardContent>
</Card>
)}
{/* Background prose — moved below the issues so it reads as
supporting context after the chair has seen the main
decision points, not as a wall of text beside them. */}
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-6 py-5 space-y-5">
<h2 className="text-navy text-xl mb-0">רקע לניתוח</h2>
<ProseSection
title="צד מיוצג"
content={analysis.data.represented_party}
/>
<ProseSection
title="רקע דיוני"
content={analysis.data.procedural_background}
/>
<ProseSection
title="עובדות מוסכמות"
content={analysis.data.agreed_facts}
/>
<ProseSection
title="עובדות במחלוקת"
content={analysis.data.disputed_facts}
/>
</CardContent>
</Card>
{analysis.data.conclusions?.trim() && (
<Card className="bg-gold-wash border-gold/40 shadow-sm">
<CardContent className="px-6 py-5 space-y-3">
<h2 className="text-gold-deep text-xl mb-0">מסקנות</h2>
<Markdown content={analysis.data.conclusions.trim()} />
</CardContent>
</Card>
)}
</div>
) : null}
</section>
</AppShell>
);
}

View File

@@ -1,184 +0,0 @@
"use client";
import { use } from "react";
import Link from "next/link";
import { AppShell } from "@/components/app-shell";
import { Card, CardContent } from "@/components/ui/card";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Button } from "@/components/ui/button";
import { Skeleton } from "@/components/ui/skeleton";
import { CaseHeader } from "@/components/cases/case-header";
import { CaseEditDialog } from "@/components/cases/case-edit-dialog";
import { WorkflowTimeline } from "@/components/cases/workflow-timeline";
import { StatusGuide } from "@/components/cases/status-guide";
import { StatusChanger } from "@/components/cases/status-changer";
import { DocumentsPanel } from "@/components/cases/documents-panel";
import { DraftsPanel } from "@/components/cases/drafts-panel";
import { AgentActivityFeed } from "@/components/cases/agent-activity-feed";
import { AgentStatusWidget } from "@/components/cases/agent-status-widget";
import { UploadSheet } from "@/components/documents/upload-sheet";
import { expectedOutcomes } from "@/lib/schemas/case";
import { useCase, useStartWorkflow } from "@/lib/api/cases";
import { toast } from "sonner";
import { Play, Loader2 } from "lucide-react";
const EXPECTED_OUTCOME_LABELS: Record<string, string> = Object.fromEntries(
expectedOutcomes.map((o) => [o.value, o.label]),
);
/*
* Next 16 breaking change: route params are now a Promise.
* The `use()` hook unwraps them inside a client component.
*/
export default function CaseDetailPage({
params,
}: {
params: Promise<{ caseNumber: string }>;
}) {
const { caseNumber } = use(params);
const { data, isPending, error } = useCase(caseNumber);
const startWorkflow = useStartWorkflow(caseNumber);
const canStartWorkflow = data?.status === "new" || data?.status === "documents_ready";
const expectedOutcomeLabel = data?.expected_outcome
? EXPECTED_OUTCOME_LABELS[data.expected_outcome] ?? data.expected_outcome
: null;
return (
<AppShell>
<section className="space-y-6">
{error ? (
<Card className="bg-danger-bg border-danger/40">
<CardContent className="px-6 py-6 text-center space-y-3">
<p className="text-danger font-semibold">שגיאה בטעינת התיק</p>
<p className="text-sm text-ink-muted">{error.message}</p>
<Button asChild variant="outline">
<Link href="/">חזרה לרשימת התיקים</Link>
</Button>
</CardContent>
</Card>
) : (
<>
{isPending ? (
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-6 py-5 space-y-3">
<Skeleton className="h-4 w-40" />
<Skeleton className="h-8 w-64" />
<Skeleton className="h-6 w-96" />
</CardContent>
</Card>
) : (
<CaseHeader data={data} />
)}
<div className="grid gap-6 lg:grid-cols-[1fr_280px]">
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-6 py-5">
<Tabs defaultValue="overview" dir="rtl">
<div className="flex items-center justify-between gap-3 mb-1">
<TabsList className="bg-rule-soft/60">
<TabsTrigger value="overview">סקירה</TabsTrigger>
<TabsTrigger value="documents">
מסמכים
{data?.documents && (
<span className="ms-1.5 text-[0.7rem] text-ink-muted tabular-nums">
({data.documents.length})
</span>
)}
</TabsTrigger>
<TabsTrigger value="drafts">
טיוטות והערות
</TabsTrigger>
<TabsTrigger value="agents">
סוכנים
</TabsTrigger>
</TabsList>
<UploadSheet caseNumber={caseNumber} />
</div>
<TabsContent value="overview" className="mt-5 space-y-4">
<div>
<h3 className="text-navy text-base mb-2">תוצאה צפויה</h3>
<p className="text-ink-soft text-sm leading-relaxed">
{expectedOutcomeLabel ?? "לא נקבעה תוצאה צפויה."}
</p>
</div>
<div>
<h3 className="text-navy text-base mb-2">סיכום מהיר</h3>
<dl className="grid grid-cols-2 gap-y-2 gap-x-6 text-sm">
<dt className="text-ink-muted">מסמכים בתיק</dt>
<dd className="text-ink tabular-nums">
{data?.documents?.length ?? 0}
</dd>
<dt className="text-ink-muted">בעיבוד</dt>
<dd className="text-ink tabular-nums">
{data?.processing_count ?? 0}
</dd>
</dl>
</div>
<div className="flex items-center gap-3 flex-wrap pt-2 border-t border-rule">
{canStartWorkflow && (
<Button
className="bg-gold-deep hover:bg-gold-deep/90 text-parchment"
disabled={startWorkflow.isPending}
onClick={() =>
startWorkflow.mutate(undefined, {
onSuccess: (res) =>
toast.success(
`תהליך הופעל — ${res.issue_identifier}`,
),
onError: (err) =>
toast.error(`שגיאה: ${err.message}`),
})
}
>
{startWorkflow.isPending ? (
<Loader2 className="w-4 h-4 animate-spin me-1.5" />
) : (
<Play className="w-4 h-4 me-1.5" />
)}
התחל תהליך
</Button>
)}
<Button asChild className="bg-navy hover:bg-navy-soft text-parchment">
<Link href={`/cases/${caseNumber}/compose`}>
פתח בעורך ההחלטה
</Link>
</Button>
{data && <CaseEditDialog data={data} />}
</div>
</TabsContent>
<TabsContent value="documents" className="mt-5">
<DocumentsPanel data={data} />
</TabsContent>
<TabsContent value="drafts" className="mt-5">
<DraftsPanel
caseNumber={caseNumber}
status={data?.status}
/>
</TabsContent>
<TabsContent value="agents" className="mt-5">
<AgentActivityFeed caseNumber={caseNumber} />
</TabsContent>
</Tabs>
</CardContent>
</Card>
<Card className="bg-surface border-rule shadow-sm h-fit">
<CardContent className="px-6 py-5 space-y-5">
<AgentStatusWidget caseNumber={caseNumber} />
<h2 className="text-navy text-base mb-4">שלב בתהליך</h2>
<WorkflowTimeline status={data?.status} />
<StatusChanger caseNumber={caseNumber} currentStatus={data?.status} />
<StatusGuide />
</CardContent>
</Card>
</div>
</>
)}
</section>
</AppShell>
);
}

View File

@@ -1,26 +0,0 @@
import Link from "next/link";
import { AppShell } from "@/components/app-shell";
import { CaseWizard } from "@/components/wizard/case-wizard";
export default function NewCasePage() {
return (
<AppShell>
<section className="space-y-6">
<header>
<nav className="text-[0.78rem] text-ink-muted flex items-center gap-2 mb-1">
<Link href="/" className="hover:text-gold-deep">בית</Link>
<span aria-hidden>·</span>
<span className="text-navy">תיק חדש</span>
</nav>
<h1 className="text-navy mb-0">יצירת תיק ערר</h1>
<p className="text-ink-muted text-sm mt-1 max-w-2xl">
שלושה שלבים קצרים פרטי יסוד, צדדים, והשלמות. התיק ייווצר ב-DB
וב-Gitea מיד בשמירה.
</p>
</header>
<CaseWizard />
</section>
</AppShell>
);
}

View File

@@ -1,219 +0,0 @@
"use client";
import Link from "next/link";
import { AlertTriangle, CheckCircle2, Clock, Database } from "lucide-react";
import { AppShell } from "@/components/app-shell";
import { Card, CardContent } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Skeleton } from "@/components/ui/skeleton";
import { useDiagnostics, type DiagDoc } from "@/lib/api/system";
const TABLE_LABELS: Record<string, string> = {
cases: "תיקים",
documents: "מסמכים",
document_chunks: "chunks",
style_corpus: "קורפוס סגנון",
style_patterns: "דפוסי סגנון",
};
function formatRelativeTime(iso: string | null) {
if (!iso) return "—";
const then = new Date(iso);
const diffMs = Date.now() - then.getTime();
const min = Math.floor(diffMs / 60000);
if (min < 1) return "עכשיו";
if (min < 60) return `לפני ${min} דקות`;
const hr = Math.floor(min / 60);
if (hr < 24) return `לפני ${hr} שעות`;
const days = Math.floor(hr / 24);
if (days < 30) return `לפני ${days} ימים`;
return then.toLocaleDateString("he-IL");
}
function DocRow({ doc, tone }: { doc: DiagDoc; tone: "danger" | "warn" }) {
const cls =
tone === "danger" ? "bg-danger-bg/60 border-danger/30" : "bg-warn-bg/60 border-warn/30";
return (
<li
className={`rounded border px-3 py-2 flex items-center gap-3 text-sm ${cls}`}
>
<div className="flex-1 min-w-0">
<div className="text-ink font-medium truncate" title={doc.title}>
{doc.title || "(ללא כותרת)"}
</div>
<div className="text-[0.72rem] text-ink-muted flex gap-3 mt-0.5">
{doc.case_number && (
<Link href={`/cases/${doc.case_number}`} className="hover:text-gold-deep">
ערר {doc.case_number}
</Link>
)}
<span>{formatRelativeTime(doc.created_at)}</span>
</div>
</div>
<Badge variant="outline" className="text-[0.7rem]">{doc.status}</Badge>
</li>
);
}
export default function DiagnosticsPage() {
const { data, isPending, error } = useDiagnostics();
return (
<AppShell>
<section className="space-y-6">
<header>
<nav className="text-[0.78rem] text-ink-muted mb-1">
<Link href="/" className="hover:text-gold-deep">בית</Link>
<span aria-hidden> · </span>
<span className="text-navy">אבחון מערכת</span>
</nav>
<h1 className="text-navy mb-0">אבחון מערכת</h1>
<p className="text-ink-muted text-sm mt-1 max-w-2xl">
מצב ה-DB, מסמכים שנכשלו או תקועים, ומשימות רקע פעילות. מתעדכן כל 10
שניות.
</p>
</header>
<div className="h-[2px] bg-gradient-to-l from-transparent via-gold to-transparent" />
{error ? (
<Card className="bg-danger-bg border-danger/40">
<CardContent className="px-6 py-6 text-center text-danger">
{error.message}
</CardContent>
</Card>
) : (
<>
{/* DB status + table counts */}
<div className="grid gap-4 md:grid-cols-[240px_1fr]">
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-5 py-4 flex flex-col items-start gap-2">
<div className="flex items-center gap-2 text-ink-muted text-[0.72rem] uppercase tracking-wider">
<Database className="w-3.5 h-3.5" />
מצב DB
</div>
{isPending ? (
<Skeleton className="h-6 w-24" />
) : data?.db_ok ? (
<div className="flex items-center gap-2 text-success font-semibold">
<CheckCircle2 className="w-5 h-5" />
<span>מחובר</span>
</div>
) : (
<div className="flex items-center gap-2 text-danger font-semibold">
<AlertTriangle className="w-5 h-5" />
<span>מנותק</span>
</div>
)}
</CardContent>
</Card>
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-5 py-4">
<div className="text-ink-muted text-[0.72rem] uppercase tracking-wider mb-3">
ספירת טבלאות
</div>
<dl className="grid grid-cols-2 md:grid-cols-5 gap-y-2 gap-x-4">
{Object.keys(TABLE_LABELS).map((key) => (
<div key={key} className="space-y-0.5">
<dt className="text-[0.72rem] text-ink-muted">
{TABLE_LABELS[key]}
</dt>
<dd className="font-display font-bold text-navy text-xl tabular-nums">
{isPending ? "—" : (data?.tables[key] ?? "—")}
</dd>
</div>
))}
</dl>
</CardContent>
</Card>
</div>
{/* Active tasks */}
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-6 py-5">
<h2 className="text-navy text-lg mb-3 flex items-center gap-2">
<Clock className="w-4 h-4" />
משימות רקע פעילות
<Badge variant="outline" className="text-[0.7rem] tabular-nums">
{data?.active_tasks.length ?? 0}
</Badge>
</h2>
{isPending ? (
<Skeleton className="h-16 w-full" />
) : data?.active_tasks.length === 0 ? (
<p className="text-ink-muted text-sm">אין משימות פעילות</p>
) : (
<ul className="space-y-2">
{data?.active_tasks.map((t) => (
<li
key={t.task_id}
className="flex items-center gap-3 text-sm rounded bg-rule-soft/60 border border-rule px-3 py-2"
>
<span className="flex-1 text-ink truncate">
{t.filename || t.task_id}
</span>
<Badge variant="outline" className="text-[0.7rem]">
{t.step || t.status}
</Badge>
</li>
))}
</ul>
)}
</CardContent>
</Card>
{/* Failed + stuck docs */}
<div className="grid gap-4 md:grid-cols-2">
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-6 py-5">
<h2 className="text-danger text-lg mb-3 flex items-center gap-2">
<AlertTriangle className="w-4 h-4" />
מסמכים שנכשלו
<Badge variant="outline" className="text-[0.7rem] tabular-nums">
{data?.failed_documents.length ?? 0}
</Badge>
</h2>
{isPending ? (
<Skeleton className="h-20 w-full" />
) : data?.failed_documents.length === 0 ? (
<p className="text-ink-muted text-sm">אין כשלונות</p>
) : (
<ul className="space-y-2">
{data?.failed_documents.map((d) => (
<DocRow key={d.id} doc={d} tone="danger" />
))}
</ul>
)}
</CardContent>
</Card>
<Card className="bg-surface border-rule shadow-sm">
<CardContent className="px-6 py-5">
<h2 className="text-warn text-lg mb-3 flex items-center gap-2">
<Clock className="w-4 h-4" />
תקועים (&gt; 10 דק׳)
<Badge variant="outline" className="text-[0.7rem] tabular-nums">
{data?.stuck_documents.length ?? 0}
</Badge>
</h2>
{isPending ? (
<Skeleton className="h-20 w-full" />
) : data?.stuck_documents.length === 0 ? (
<p className="text-ink-muted text-sm">אין מסמכים תקועים</p>
) : (
<ul className="space-y-2">
{data?.stuck_documents.map((d) => (
<DocRow key={d.id} doc={d} tone="warn" />
))}
</ul>
)}
</CardContent>
</Card>
</div>
</>
)}
</section>
</AppShell>
);
}

View File

@@ -1,57 +0,0 @@
"use client";
import { useEffect } from "react";
import Link from "next/link";
import { AlertTriangle } from "lucide-react";
import { Button } from "@/components/ui/button";
/*
* Route-segment error boundary. Next 16 App Router convention: this file
* catches render-time errors thrown below the root layout. `reset` clears
* the error and re-renders the segment; we keep the user's nav in place
* (no AppShell here — the shell re-renders from the layout above us).
*/
export default function ErrorPage({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
useEffect(() => {
console.error("Route error:", error);
}, [error]);
return (
<main className="flex-1 w-full max-w-[1400px] mx-auto px-10 py-10">
<div className="max-w-xl mx-auto text-center space-y-5 py-16">
<AlertTriangle className="w-12 h-12 text-danger mx-auto" aria-hidden="true" />
<div className="space-y-2">
<h1 className="text-navy">משהו השתבש</h1>
<p className="text-ink-muted leading-relaxed">
נכשלה טעינת המסך. זה עשוי להיות כשל זמני ברשת או באחד מה-endpoints
של FastAPI.
</p>
{error.digest && (
<p className="text-[0.72rem] text-ink-light tabular-nums">
error id: {error.digest}
</p>
)}
{error.message && (
<code className="text-[0.78rem] text-ink-soft bg-rule-soft/60 rounded px-3 py-1 inline-block mt-2">
{error.message}
</code>
)}
</div>
<div className="flex items-center justify-center gap-3">
<Button onClick={reset} className="bg-navy hover:bg-navy-soft text-parchment">
נסה שוב
</Button>
<Button variant="outline" asChild>
<Link href="/">חזרה לבית</Link>
</Button>
</div>
</div>
</main>
);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Some files were not shown because too many files have changed in this diff Show More