feat(digests): case-contextual digest radar — surface unlinked digests as chair leads (X12)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 5s
Lint — undefined names / undefined-names (pull_request) Successful in 14s

A digest pointing at a ruling we don't hold yet ("unlinked") was captured globally
(missing_precedents inbox) but never surfaced IN THE CONTEXT of the case being
decided — so a relevant ruling known only via a digest could fall through the cracks
at the moment it matters. Adds the case-contextual radar:

- db.search_digests_semantic: new `linked_only` filter (False = unlinked-only target set).
- digest_library.case_digest_radar(case_number): builds the case topic from title +
  appeal_subtype + the analyst's claims, embeds once, matches against UNLINKED digests,
  and returns leads enriched with the underlying ruling's gap status + suggested action
  (new_lead / gap_open / fetched / available_link).
- MCP tool `digest_radar` + endpoint GET /api/cases/{n}/digest-radar (for the agent and
  the future case-page lead).

INV-DIG1 preserved: radar only — every lead points at the underlying RULING (fetch /
upload / link), never cites the digest. Read-only.

Validated on 8124-09-24 (היטל השבחה): 5 on-topic unlinked digests, scores 0.64–0.72.
The visible case-page panel is a separate UI change → goes through the design gate.

Invariants: G2 (reuses the one digest semantic-search + gap/citation resolvers),
INV-DIG1 (no digest citation), INV-DIG3 (gap surfacing). No schema change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-20 16:45:14 +00:00
parent 4f45fa416b
commit 70f93c3bd4
5 changed files with 126 additions and 1 deletions

View File

@@ -6444,6 +6444,17 @@ class DigestLinkRequest(BaseModel):
case_law_id: str
@app.get("/api/cases/{case_number}/digest-radar")
async def api_case_digest_radar(case_number: str, limit: int = 5, min_score: float = 0.45):
"""Case-contextual digest radar (X12) — UNLINKED digests whose topic is close to
this case (rulings we don't hold yet). Powers the case-page "📡 רדאר יומונים" lead
so a relevant ruling known only via a digest doesn't fall through the cracks while
the case is decided. INV-DIG1: points at the underlying ruling, never cites the
digest."""
return await digest_service.case_digest_radar(
case_number, limit=max(1, min(int(limit), 20)), min_score=float(min_score))
@app.post("/api/digests/upload")
async def digest_upload(
file: UploadFile = File(...),