feat: link related precedents across court instances (SCHEMA_V11)
Add ability to mark case_law records as related (e.g. same appeal
through ועדת ערר → מנהלי → עליון):
- DB: case_law_relations join table (bidirectional, V11 migration)
- DB CRUD: add/remove/get_case_law_relations
- Service: get_precedent() now returns related_cases[]
- MCP: precedent_link_cases + precedent_unlink_cases tools
- REST: POST/DELETE /api/precedent-library/{id}/relations
- UI: RelatedCasesSection on detail page with search dialog and unlink
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
31
web/app.py
31
web/app.py
@@ -4380,6 +4380,37 @@ async def precedent_library_delete(case_law_id: str):
|
||||
return {"deleted": True, "case_law_id": case_law_id}
|
||||
|
||||
|
||||
class PrecedentRelationRequest(BaseModel):
|
||||
related_id: str
|
||||
relation_type: str = "same_case_chain"
|
||||
|
||||
|
||||
@app.post("/api/precedent-library/{case_law_id}/relations")
|
||||
async def precedent_add_relation(case_law_id: str, req: PrecedentRelationRequest):
|
||||
try:
|
||||
a = UUID(case_law_id)
|
||||
b = UUID(req.related_id)
|
||||
except ValueError:
|
||||
raise HTTPException(400, "case_law_id לא תקין")
|
||||
if not await db.get_case_law(a):
|
||||
raise HTTPException(404, "פסיקה לא נמצאה")
|
||||
if not await db.get_case_law(b):
|
||||
raise HTTPException(404, f"פסיקה קשורה {req.related_id} לא נמצאה")
|
||||
await db.add_case_law_relation(a, b, req.relation_type)
|
||||
return {"linked": True, "case_law_id": case_law_id, "related_id": req.related_id}
|
||||
|
||||
|
||||
@app.delete("/api/precedent-library/{case_law_id}/relations/{related_id}")
|
||||
async def precedent_remove_relation(case_law_id: str, related_id: str):
|
||||
try:
|
||||
a = UUID(case_law_id)
|
||||
b = UUID(related_id)
|
||||
except ValueError:
|
||||
raise HTTPException(400, "case_law_id לא תקין")
|
||||
await db.remove_case_law_relation(a, b)
|
||||
return {"unlinked": True, "case_law_id": case_law_id, "related_id": related_id}
|
||||
|
||||
|
||||
# Halacha and metadata extraction are LLM-driven and rely on the local
|
||||
# `claude` CLI via mcp-server/services/claude_session.py — they CANNOT run
|
||||
# from this container (no CLI, no claude.ai session). The endpoints below
|
||||
|
||||
Reference in New Issue
Block a user