fix(learning): extract precedent metadata inline on final-decision enroll #335

Merged
chaim merged 1 commits from worktree-enroll-inline-metadata into main 2026-06-28 10:49:24 +00:00
Owner

מה ולמה

בקליטת החלטה סופית חתומה, ההחלטה נרשמת לספריית-הפסיקה — אבל _enroll_final_in_library מילא רק שדות דטרמיניסטיים (ציטוט, proceeding_type, תאריך) והעתיק subject_tags מ-subject_categories של התיק, שבדרך-כלל ריק. חילוץ-המטא של Gemini (subject_tags / summary / headnote / key_quote) לא הופעל כלל, אז הרשומה נשארה ב-metadata_extraction_status='pending' בלי תגיות-נושא עד שדריינר במקרה הרים אותה. בפועל: החלטה סופית טרייה הראתה "תגיות נושא" ריק במסך עריכת-הפסיקה (התגלה ב-8137-11-24 ערר הפדרציה).

השינוי

אחרי ה-enroll + הציטוט, קוראים inline למסלול הקיים reextract_metadata (G2 — מסלול יחיד, מחזור-סטטוס מלא). הוא רץ על Gemini Flash דרך REST (GOOGLE_GEMINI_API_KEY, כבר ב-Coolify) → בטוח-בקונטיינר, בניגוד למסלול ההלכות (claude CLI, מקומי-בלבד). apply_to_record ממלא רק שדות ריקים, אז הזרעים הדטרמיניסטיים וכל subject_categories שאצר היו"ר נשמרים. התוצאה מוחזרת ב-out["metadata"]; כשל נרשם ל-log וההעלאה מצליחה.

תיקון שתי הערות מיושנות: "Gemini מחזיר no_metadata להחלטות פנימיות" בלולאת-ה-enroll, ו-"MCP-tool-only path" ב-docstring של reextract_metadata (נכון להלכות, לא ל-Gemini REST).

Invariants

  • G1 — מילוי במקור בזמן ה-enroll, לא workaround בזמן-קריאה.
  • G2 — שימוש-חוזר ב-reextract_metadata — אין מסלול-חילוץ מקביל.
  • קריאת ה-LLM היא Gemini REST (לא claude_session), כך שמגבלת "אין claude מהקונטיינר" נשמרת.

בדיקה ידנית

חילוץ-המטא הורץ ידנית על 8137-11-24 ואכן הפיק 8 תגיות (היטל_השבחה, פטור_מוסד_ציבורי, סעיף_19ב4, …) — אותו מסלול שה-PR מפעיל אוטומטית מעכשיו.

🤖 Generated with Claude Code

## מה ולמה בקליטת החלטה סופית חתומה, ההחלטה נרשמת לספריית-הפסיקה — אבל `_enroll_final_in_library` מילא רק שדות דטרמיניסטיים (ציטוט, proceeding_type, תאריך) והעתיק `subject_tags` מ-`subject_categories` של התיק, ש**בדרך-כלל ריק**. חילוץ-המטא של Gemini (subject_tags / summary / headnote / key_quote) **לא הופעל כלל**, אז הרשומה נשארה ב-`metadata_extraction_status='pending'` בלי תגיות-נושא עד שדריינר במקרה הרים אותה. בפועל: החלטה סופית טרייה הראתה "תגיות נושא" ריק במסך עריכת-הפסיקה (התגלה ב-8137-11-24 ערר הפדרציה). ## השינוי אחרי ה-enroll + הציטוט, קוראים inline למסלול הקיים `reextract_metadata` (G2 — מסלול יחיד, מחזור-סטטוס מלא). הוא רץ על **Gemini Flash דרך REST** (`GOOGLE_GEMINI_API_KEY`, כבר ב-Coolify) → **בטוח-בקונטיינר**, בניגוד למסלול ההלכות (claude CLI, מקומי-בלבד). `apply_to_record` ממלא **רק שדות ריקים**, אז הזרעים הדטרמיניסטיים וכל `subject_categories` שאצר היו"ר נשמרים. התוצאה מוחזרת ב-`out["metadata"]`; כשל נרשם ל-log וההעלאה מצליחה. תיקון שתי הערות מיושנות: "Gemini מחזיר no_metadata להחלטות פנימיות" בלולאת-ה-enroll, ו-"MCP-tool-only path" ב-docstring של `reextract_metadata` (נכון להלכות, לא ל-Gemini REST). ## Invariants - **G1** — מילוי במקור בזמן ה-enroll, לא workaround בזמן-קריאה. - **G2** — שימוש-חוזר ב-`reextract_metadata` — אין מסלול-חילוץ מקביל. - קריאת ה-LLM היא Gemini REST (לא `claude_session`), כך שמגבלת "אין claude מהקונטיינר" נשמרת. ## בדיקה ידנית חילוץ-המטא הורץ ידנית על 8137-11-24 ואכן הפיק 8 תגיות (`היטל_השבחה`, `פטור_מוסד_ציבורי`, `סעיף_19ב4`, …) — אותו מסלול שה-PR מפעיל אוטומטית מעכשיו. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
chaim added 1 commit 2026-06-28 10:49:16 +00:00
fix(learning): extract precedent metadata inline on final-decision enroll
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 4s
Lint — undefined names / undefined-names (pull_request) Successful in 9s
8e2cfd602c
When a chair's signed final decision is uploaded it is enrolled into the
precedent library, but _enroll_final_in_library only set deterministic
fields (citation, proceeding_type, date) and copied subject_tags from the
case's subject_categories — which is usually empty. The Gemini metadata
pass (subject_tags / summary / headnote / key_quote) was never triggered,
so the row sat at metadata_extraction_status='pending' with no subject
tags until a drain happened to pick it up. In practice a freshly-enrolled
final showed an empty "תגיות נושא" in the precedent edit UI.

Fix: after enrollment + citation, call the existing reextract_metadata
path inline (G2 — one path, full status lifecycle). It runs on Gemini
Flash over REST (GOOGLE_GEMINI_API_KEY, already in Coolify), so it is
container-safe — unlike the halacha path (claude CLI, host-only).
apply_to_record fills only empty fields, so the deterministic seeds and
any chair-curated subject_categories are preserved. Result surfaced in the
upload response (out["metadata"]); failures logged, upload still succeeds.

Also corrects two now-stale comments: the "Gemini returns no_metadata for
internal decisions" note in the enroll loop, and the "MCP-tool-only path"
docstring on reextract_metadata (true for halacha, not for Gemini REST).

Invariants: G1 (fill at source on enroll, not a read-time workaround),
G2 (reuse reextract_metadata — no parallel extraction path). LLM call is
Gemini REST, not claude_session, so the container LLM-call constraint holds.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
chaim merged commit 6c487a2e85 into main 2026-06-28 10:49:24 +00:00
chaim deleted branch worktree-enroll-inline-metadata 2026-06-28 10:49:24 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ezer-mishpati/legal-ai#335