feat(digests): case-contextual digest radar — surface unlinked digests as chair leads (X12)
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:
@@ -5018,14 +5018,24 @@ async def search_digests_semantic(
|
||||
subject_tag: str = "",
|
||||
concept_tag: str = "",
|
||||
limit: int = 10,
|
||||
linked_only: bool | None = None,
|
||||
) -> list[dict]:
|
||||
"""Pure-semantic search over the digests radar (X12). Single vector per row
|
||||
(no chunks/halachot), so no RRF here — see X12 §6. Joins the linked ruling's
|
||||
citation when present so the researcher sees the pointer target directly."""
|
||||
citation when present so the researcher sees the pointer target directly.
|
||||
|
||||
``linked_only``: None = all digests (default); False = only UNLINKED digests
|
||||
(``linked_case_law_id IS NULL`` — rulings we don't hold yet, the case radar's
|
||||
target set); True = only linked digests.
|
||||
"""
|
||||
pool = await get_pool()
|
||||
conditions = ["d.embedding IS NOT NULL"]
|
||||
params: list = [query_embedding, limit]
|
||||
idx = 3
|
||||
if linked_only is True:
|
||||
conditions.append("d.linked_case_law_id IS NOT NULL")
|
||||
elif linked_only is False:
|
||||
conditions.append("d.linked_case_law_id IS NULL")
|
||||
if practice_area:
|
||||
conditions.append(f"d.practice_area = ${idx}")
|
||||
params.append(practice_area)
|
||||
|
||||
Reference in New Issue
Block a user