From 7600810639f762d018b2a063e7d50ca3282124e7 Mon Sep 17 00:00:00 2001 From: Chaim Date: Thu, 30 Apr 2026 17:51:31 +0000 Subject: [PATCH] researcher: persist precedents to DB + save report to disk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two structural gaps in legal-researcher's "שלב 5: דיווח" surfaced while auditing the case 8174-24 run: 1. **No DB linkage.** The skill told the researcher to post a comment summarizing precedents but never to call mcp__legal-ai__precedent_attach. The MCP tool itself wasn't even in the tools frontmatter — so even a researcher that wanted to write to case_precedents physically couldn't. Result: 0 rows in case_precedents after a successful research run, even with 8 precedents identified and verified in the comment text. The writer then has to grep free-text instead of querying a structured table. 2. **No persisted file.** Research output existed only as a Paperclip comment. The writer/QA can't `Read` it from disk; they have to go through Paperclip API to fetch comment bodies. Compare to the analyst, which is required to write `analysis-and-research.md`. Fix: • Added precedent_attach, precedent_list, precedent_search_library to the tools frontmatter. • Rewrote step 5 with explicit ordering: save to disk → attach verified precedents to DB → update status → email → post comment. • Documented the precedent_attach call signature inline (case_number, citation, quote, section_id) so the agent doesn't have to reverse- engineer it. Includes guidance on which precedents to attach (verified with quote) vs which to leave for external verification. Effect: future research runs will populate case_precedents and data/cases/{N}/documents/research/precedent-research.md, both of which the writer needs. Co-Authored-By: Claude Opus 4.7 (1M context) --- .claude/agents/legal-researcher.md | 33 +++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/.claude/agents/legal-researcher.md b/.claude/agents/legal-researcher.md index 207e9fe..e35e765 100644 --- a/.claude/agents/legal-researcher.md +++ b/.claude/agents/legal-researcher.md @@ -16,6 +16,9 @@ tools: - mcp__legal-ai__search_decisions - mcp__legal-ai__find_similar_cases - mcp__legal-ai__extract_references + - mcp__legal-ai__precedent_attach + - mcp__legal-ai__precedent_list + - mcp__legal-ai__precedent_search_library - mcp__legal-ai__workflow_status --- @@ -97,23 +100,43 @@ tools: ### שלב 5: דיווח — חובה! -1. **עדכן סטטוס**: `case_update(case_number, status='research_complete')` +1. **שמור את הדוח לדיסק** (חובה — ה-writer וה-QA קוראים מהקובץ הזה ישירות): + ``` + {case_dir}/documents/research/precedent-research.md + ``` + המבנה המומלץ: רקע דיוני → מפת שומות (אם רלוונטי) → סוגיות + תקדימים מאומתים לכל אחת → המלצה לכיוון. כל תקדים עם citation מלא + ציטוט מדויק + הקשר. -2. **שלח מייל**: +2. **רשום ב-DB את התקדימים שאומתו** — חובה, אחרת ה-writer יקבל רשימה ריקה כשהוא קורא `precedent_list`. + + לכל פסק דין שעבר את שלב 2 (ניתוח פסיקה) **ויש לו ציטוט מדויק מהמקור** — קרא `precedent_attach`: + ``` + mcp__legal-ai__precedent_attach( + case_number = "8174-24", + citation = "בר\"מ 3644/13 הוועדה המקומית גבעתיים נ' גלר (פורסם בנבו, 24.05.2017)", + quote = "ציטוט מדויק מפסק הדין — הקטע הספציפי שרלוונטי לסוגיה", + section_id = "issue_2" # או "threshold_1" לטענת סף; ריק אם כללי + ) + ``` + תקדימים שלא הצלחת לאמת (ציטוט לא נמצא, רק "טוענים שמופיע בפסק") **אל תכתוב ל-DB** — סמן ב-comment כ"דורש אימות חיצוני" בלבד. + +3. **עדכן סטטוס**: `case_update(case_number, status='research_complete')` + +4. **שלח מייל**: ```bash python3 /home/chaim/legal-ai/scripts/notify.py \ "מחקר תקדימים הושלם — ערר {case_number}" \ - "סיכום: X פסקי דין נותחו, Y תכניות מופו. נדרשת ביקורתך לפני המשך." + "סיכום: X פסקי דין נותחו ונרשמו ל-DB, Y תכניות מופו. נדרשת ביקורתך לפני המשך." ``` -3. פרסם comment ב-Paperclip עם: -- סיכום כל פסק דין (2-3 שורות לכל אחד) +5. **פרסם comment ב-Paperclip** עם: +- סיכום כל פסק דין (2-3 שורות לכל אחד) — **ציין במפורש כמה תקדימים נרשמו ב-DB דרך `precedent_attach`** - מיפוי הוראות תכנית רלוונטיות - ציר זמן ההליך - **המלצה מובנית לפי מקורות הנמקה:** - **טקסט**: אילו סעיפי תכנית/חוק מרכזיים (ציטוט הנוסח) - **תקדים**: אילו פסקי דין הכי חזקים (עם ציון היררכיה ומעמד — הלכה/אגב) - **מדיניות**: אילו שיקולים תכנוניים עולים מהחומר +- קישור למיקום הקובץ: `{case_dir}/documents/research/precedent-research.md` ### סגור את ה-issue של עצמך — חובה!