Rulings readout and the prior-art 500 fix #195
@@ -1698,8 +1698,11 @@ def _prior_art_line(item: dict, marker: str, owner: str | None, foreign_lang: st
|
||||
"""
|
||||
# The NAME, not the composed title (#4364) — a snippet's title carries its
|
||||
# whole trigger and ran to kilobytes on this line, again on every repeat.
|
||||
# `snippet` is a snippet record's field dict — but on a search hit it is
|
||||
# the matched excerpt, a string, under the same key.
|
||||
fields = item.get("snippet")
|
||||
title = (
|
||||
item.get("name") or (item.get("snippet") or {}).get("name")
|
||||
item.get("name") or (fields.get("name") if isinstance(fields, dict) else None)
|
||||
or (item.get("title") or "(untitled)")
|
||||
).replace("\n", " ").strip()
|
||||
mark = f"{marker} · {foreign_lang}" if foreign_lang else marker
|
||||
|
||||
@@ -956,6 +956,17 @@ def test_prior_art_line_keeps_language_and_attribution_together():
|
||||
assert "· python" in both and "shared by alex" in both
|
||||
|
||||
|
||||
def test_prior_art_line_takes_a_search_hit_whose_snippet_is_its_excerpt():
|
||||
"""A search hit carries its matched passage as a STRING under `snippet` —
|
||||
the key a snippet record uses for its field dict. Reading it as the dict
|
||||
500'd the write-path route on any nameless hit."""
|
||||
from scribe.services.plugin_context import _prior_art_line
|
||||
hit = {"id": 7, "title": "Paging contract", "snippet": "…the cursor is opaque…"}
|
||||
assert _prior_art_line(hit, "similar 0.61", None) == '> - #7 [similar 0.61] "Paging contract"'
|
||||
record = {"id": 8, "title": "long composed title", "snippet": {"name": "paginate"}}
|
||||
assert _prior_art_line(record, "similar 0.70", None) == '> - #8 [similar 0.70] "paginate"'
|
||||
|
||||
|
||||
# --- the route between them --------------------------------------------------
|
||||
|
||||
def test_route_reads_every_arg_the_hook_sends():
|
||||
|
||||
Reference in New Issue
Block a user