| 1 | """The bounded lines of the patent evidence block, built from the lane's artifact.""" |
| 2 | |
| 3 | import copy |
| 4 | |
| 5 | from lib import patent_digest, patents |
| 6 | |
| 7 | PDF = "https://image-ppubs.uspto.gov/dirsearch-public/print/downloadPdf/" |
| 8 | OTHERS = "- Other filers with the company's name, not verified:" |
| 9 | |
| 10 | # Trimmed from a live Nvidia run on 2026-11-13: two of its twelve entries and |
| 11 | # two of its forty index items, counts as returned. |
| 12 | NVIDIA = { |
| 13 | "company": "Nvidia", |
| 14 | "company_via_person": False, |
| 15 | "window": {"from": "2026-10-14", "to": "2026-11-13"}, |
| 16 | "groups": [ |
| 17 | {"name": "NVIDIA Corporation", "kind": "confirmed", "applications": 160, "grants": 86}, |
| 18 | {"name": "NVIDIA Corparation", "kind": "name-matched", "applications": 0, "grants": 1}, |
| 19 | ], |
| 20 | "other_names": [], |
| 21 | "counts": { |
| 22 | "applications": 160, "grants": 86, |
| 23 | "name_matched_applications": 0, "name_matched_grants": 1, |
| 24 | # The name-matched grant is a first publication (it is in the index), |
| 25 | # so 97 of the 98 the run found sit under the confirmed name. |
| 26 | "first_publications": 97, "name_matched_first_publications": 1, |
| 27 | "continuing": 73, "previously_published_grants": 75, |
| 28 | "designs": 1, "other_kinds": 0, "floor": False, |
| 29 | }, |
| 30 | "entries": [ |
| 31 | { |
| 32 | "guid": "US-20260321219-A1", "number": "20260321219", |
| 33 | "title": "DYNAMICALLY UPDATABLE PERSISTENT DISPLAYS FOR HARDWARE RESOURCES", |
| 34 | "url": f"{PDF}20260321219", "kind": "application", "kind_code": "A1", |
| 35 | "published": "2026-10-15", "filed": "2025-04-15", "earliest_priority": None, |
| 36 | "cpc": ["G09G3/344", "G09G3/3453", "G09G3/035"], |
| 37 | "filed_as": "NVIDIA Corporation", "group_kind": "confirmed", |
| 38 | "applicant_location": "Santa Clara, CA, US", |
| 39 | "abstract": ( |
| 40 | "Persistent displays such as E-ink persistent displays can convey information " |
| 41 | "related to hardware components such as servers, GPUs, and network switches." |
| 42 | ), |
| 43 | "first_claim": ( |
| 44 | "1. A display device, comprising: a persistent display; a data connection to " |
| 45 | "receive state data from a hardware device with which the persistent display " |
| 46 | "is associated." |
| 47 | ), |
| 48 | }, |
| 49 | { |
| 50 | "guid": "US-20260316792-A1", "number": "20260316792", |
| 51 | "title": "TARGET OBJECT AND FEATURE MINING", |
| 52 | "url": f"{PDF}20260316792", "kind": "application", "kind_code": "A1", |
| 53 | "published": "2026-10-15", "filed": "2025-06-30", "earliest_priority": "2025-04-10", |
| 54 | "cpc": ["B60W60/0027", "G08G1/0133"], |
| 55 | "filed_as": "NVIDIA Corporation", "group_kind": "confirmed", |
| 56 | "applicant_location": "Santa Clara, CA, US", |
| 57 | "abstract": "Autonomous and/or semi-autonomous machine performance benefits from learning.", |
| 58 | "first_claim": "1. A method comprising: receiving first data describing agent trajectories.", |
| 59 | }, |
| 60 | ], |
| 61 | "index": [ |
| 62 | { |
| 63 | "title": "COMPILER-SCHEDULED TRIANGULAR UPDATE NEURAL NETWORK", |
| 64 | "url": f"{PDF}20260359632", "kind": "application", "published": "2026-11-12", |
| 65 | "cpc": "G06N3/08", "filed_as": "NVIDIA Corporation", "group_kind": "confirmed", |
| 66 | }, |
| 67 | { |
| 68 | "title": "TRIANGULAR UPDATE NEURAL NETWORK", |
| 69 | "url": f"{PDF}20260359641", "kind": "grant", "published": "2026-11-12", |
| 70 | "cpc": "G06N3/084; G06N3/048", "filed_as": "NVIDIA Corparation", |
| 71 | "group_kind": "name-matched", |
| 72 | }, |
| 73 | ], |
| 74 | "partial": None, |
| 75 | "status": "digest", |
| 76 | } |
| 77 | |
| 78 | |
| 79 | def _entry(number, *, filed_as="Microsoft Corporation", group_kind="confirmed", **fields): |
| 80 | return { |
| 81 | "guid": f"US-{number}-A1", "number": str(number), "title": f"Filing {number}", |
| 82 | "url": f"{PDF}{number}", "kind": "application", "kind_code": "A1", |
| 83 | "published": "2026-11-05", "filed": "2025-05-01", "earliest_priority": None, |
| 84 | "cpc": ["G06F9/50"], "filed_as": filed_as, "group_kind": group_kind, |
| 85 | "applicant_location": "Redmond, WA, US", |
| 86 | "abstract": f"Abstract of {number}.", "first_claim": f"1. Claim of {number}.", |
| 87 | **fields, |
| 88 | } |
| 89 | |
| 90 | |
| 91 | def microsoft(): |
| 92 | licensing = "Microsoft Mobile Oy" |
| 93 | return { |
| 94 | "company": "Microsoft", |
| 95 | "company_via_person": False, |
| 96 | "window": {"from": "2026-10-14", "to": "2026-11-13"}, |
| 97 | "groups": [ |
| 98 | {"name": "Microsoft Corporation", "kind": "confirmed", "applications": 0, "grants": 1}, |
| 99 | {"name": licensing, "kind": "name-matched", "applications": 212, "grants": 140}, |
| 100 | ], |
| 101 | "other_names": [{"name": "Nuance Communications, Inc.", "count": 3}], |
| 102 | "counts": { |
| 103 | "applications": 0, "grants": 1, |
| 104 | "name_matched_applications": 212, "name_matched_grants": 140, |
| 105 | # One entry below is filed under the confirmed name, two are not. |
| 106 | "first_publications": 1, "name_matched_first_publications": 2, |
| 107 | "continuing": 0, "previously_published_grants": 0, |
| 108 | "designs": 0, "other_kinds": 0, "floor": False, |
| 109 | }, |
| 110 | "entries": [ |
| 111 | _entry(1001, filed_as=licensing, group_kind="name-matched"), |
| 112 | _entry(1002, kind="grant", kind_code="B1"), |
| 113 | _entry(1003, filed_as=licensing, group_kind="name-matched"), |
| 114 | ], |
| 115 | "index": [], |
| 116 | "partial": None, |
| 117 | "status": "digest", |
| 118 | } |
| 119 | |
| 120 | |
| 121 | def block(): |
| 122 | """One application under the company's own name and five under a |
| 123 | stranger's that extends it.""" |
| 124 | imaging = "Block Imaging, Inc." |
| 125 | return { |
| 126 | "company": "Block", |
| 127 | "company_via_person": False, |
| 128 | "window": {"from": "2026-10-14", "to": "2026-11-13"}, |
| 129 | "groups": [ |
| 130 | {"name": "Block, Inc.", "kind": "confirmed", "applications": 1, "grants": 0}, |
| 131 | {"name": imaging, "kind": "name-matched", "applications": 5, "grants": 0}, |
| 132 | ], |
| 133 | "other_names": [], |
| 134 | "counts": { |
| 135 | "applications": 1, "grants": 0, |
| 136 | "name_matched_applications": 5, "name_matched_grants": 0, |
| 137 | "first_publications": 1, "name_matched_first_publications": 5, |
| 138 | "continuing": 0, "previously_published_grants": 0, |
| 139 | "designs": 0, "other_kinds": 0, "floor": False, |
| 140 | }, |
| 141 | "entries": [ |
| 142 | _entry(3001, filed_as="Block, Inc."), |
| 143 | *[_entry(3002 + n, filed_as=imaging, group_kind="name-matched") for n in range(5)], |
| 144 | ], |
| 145 | "index": [], |
| 146 | "partial": None, |
| 147 | "status": "digest", |
| 148 | } |
| 149 | |
| 150 | |
| 151 | def block_imaging_only(): |
| 152 | """Block with every filing under a stranger's name that extends it.""" |
| 153 | artifact = block() |
| 154 | artifact["groups"] = artifact["groups"][1:] |
| 155 | artifact["counts"].update(applications=0, first_publications=0) |
| 156 | artifact["entries"] = [ |
| 157 | entry for entry in artifact["entries"] if entry["group_kind"] == "name-matched" |
| 158 | ] |
| 159 | return artifact |
| 160 | |
| 161 | |
| 162 | def openai_opco(): |
| 163 | """OpenAI with every filing under its operating company's name, which the |
| 164 | lane counts as the company's own.""" |
| 165 | return { |
| 166 | "company": "OpenAI", |
| 167 | "company_via_person": False, |
| 168 | "window": {"from": "2026-10-14", "to": "2026-11-13"}, |
| 169 | "groups": [ |
| 170 | {"name": "OpenAI OpCo, LLC", "kind": "confirmed", "applications": 14, "grants": 3}, |
| 171 | ], |
| 172 | "other_names": [], |
| 173 | "counts": { |
| 174 | "applications": 14, "grants": 3, |
| 175 | "name_matched_applications": 0, "name_matched_grants": 0, |
| 176 | "first_publications": 15, "name_matched_first_publications": 0, |
| 177 | "continuing": 2, "previously_published_grants": 0, |
| 178 | "designs": 0, "other_kinds": 0, "floor": False, |
| 179 | }, |
| 180 | "entries": [_entry(4001, filed_as="OpenAI OpCo, LLC")], |
| 181 | "index": [], |
| 182 | "partial": None, |
| 183 | "status": "digest", |
| 184 | } |
| 185 | |
| 186 | |
| 187 | def _link(url, title): |
| 188 | return f"[{title}]({url})" |
| 189 | |
| 190 | |
| 191 | def _untrusted(text, limit): |
| 192 | return text[:limit] |
| 193 | |
| 194 | |
| 195 | def lines(artifact): |
| 196 | return patent_digest.digest_lines(artifact, link=_link, untrusted=_untrusted) |
| 197 | |
| 198 | |
| 199 | def _line(out, label): |
| 200 | found = [line for line in out if line.startswith(label)] |
| 201 | assert len(found) == 1, (label, out) |
| 202 | return found[0] |
| 203 | |
| 204 | |
| 205 | def test_block_lines_come_in_the_documented_order(): |
| 206 | artifact = copy.deepcopy(NVIDIA) |
| 207 | artifact["other_names"] = [{"name": "Mellanox Technologies, Ltd.", "count": 4}] |
| 208 | out = lines(artifact) |
| 209 | assert out[:2] == ["## Patent Digest", ""] |
| 210 | labels = [ |
| 211 | "- Filings:", OTHERS, "- First US publications:", |
| 212 | "- [DYNAMICALLY UPDATABLE", "- [TARGET OBJECT", |
| 213 | "- More first US publications (titles only):", |
| 214 | " - [COMPILER-SCHEDULED", " - [TRIANGULAR UPDATE", |
| 215 | "- Other names in the search, not read:", |
| 216 | ] |
| 217 | positions = [out.index(_line(out, label)) for label in labels] |
| 218 | assert positions == sorted(positions) |
| 219 | assert positions[-1] == len(out) - 1 |
| 220 | assert not any(line.startswith("- Note:") for line in out) |
| 221 | |
| 222 | |
| 223 | def test_filings_line_names_company_window_confirmed_counts_and_names(): |
| 224 | filings = _line(lines(NVIDIA), "- Filings:") |
| 225 | assert "Nvidia" in filings |
| 226 | assert "2026-10-14 to 2026-11-13" in filings |
| 227 | assert "160 applications published" in filings |
| 228 | assert "86 patents granted" in filings |
| 229 | assert "NVIDIA Corporation" in filings |
| 230 | assert "Corparation" not in filings |
| 231 | |
| 232 | |
| 233 | def test_first_publications_line_counts_what_is_not_listed_and_omits_zeros(): |
| 234 | first = _line(lines(NVIDIA), "- First US publications:") |
| 235 | assert first.startswith("- First US publications: 97 (") |
| 236 | assert "73 continuing applications (continuations, divisionals)" in first |
| 237 | assert "75 grants of applications published earlier" in first |
| 238 | assert "1 design patent" in first |
| 239 | assert "other kind" not in first |
| 240 | |
| 241 | |
| 242 | def test_entry_line_carries_every_field_and_the_text(): |
| 243 | out = lines(NVIDIA) |
| 244 | first = _line(out, "- [DYNAMICALLY UPDATABLE") |
| 245 | assert first.startswith( |
| 246 | "- [DYNAMICALLY UPDATABLE PERSISTENT DISPLAYS FOR HARDWARE RESOURCES]" |
| 247 | f"({PDF}20260321219) | application 20260321219 | published 2026-10-15 | " |
| 248 | "filed 2025-04-15 | CPC G09G3/344; G09G3/3453; G09G3/035 | " |
| 249 | "filed as NVIDIA Corporation (Santa Clara, CA, US) | abstract: Persistent displays" |
| 250 | ) |
| 251 | assert "earliest priority" not in first |
| 252 | assert " | first claim: 1. A display device, comprising" in first |
| 253 | assert "not verified" not in first |
| 254 | second = _line(out, "- [TARGET OBJECT") |
| 255 | assert "| filed 2025-06-30 | earliest priority 2025-04-10 | CPC" in second |
| 256 | |
| 257 | |
| 258 | def test_earliest_priority_equal_to_the_filed_date_is_not_repeated(): |
| 259 | artifact = microsoft() |
| 260 | artifact["entries"] = [_entry(1, earliest_priority="2025-05-01")] |
| 261 | assert "earliest priority" not in _line(lines(artifact), "- [Filing 1]") |
| 262 | |
| 263 | |
| 264 | def test_index_lines_carry_kind_date_cpc_and_filed_as(): |
| 265 | out = lines(NVIDIA) |
| 266 | assert _line(out, " - [COMPILER-SCHEDULED") == ( |
| 267 | f" - [COMPILER-SCHEDULED TRIANGULAR UPDATE NEURAL NETWORK]({PDF}20260359632) | " |
| 268 | "application | published 2026-11-12 | CPC G06N3/08 | filed as NVIDIA Corporation" |
| 269 | ) |
| 270 | assert _line(out, " - [TRIANGULAR UPDATE").endswith( |
| 271 | "| grant | published 2026-11-12 | CPC G06N3/084; G06N3/048 | " |
| 272 | "filed as NVIDIA Corparation | not verified" |
| 273 | ) |
| 274 | |
| 275 | |
| 276 | def test_name_matched_entries_follow_confirmed_ones_and_are_marked(): |
| 277 | out = lines(microsoft()) |
| 278 | order = [line.split("]")[0] for line in out if line.startswith("- [Filing")] |
| 279 | assert order == ["- [Filing 1002", "- [Filing 1001", "- [Filing 1003"] |
| 280 | confirmed = _line(out, "- [Filing 1002]") |
| 281 | assert "| grant 1002 |" in confirmed |
| 282 | assert "not verified" not in confirmed |
| 283 | matched = _line(out, "- [Filing 1001]") |
| 284 | assert ( |
| 285 | "| filed as Microsoft Mobile Oy (Redmond, WA, US) | not verified | " |
| 286 | "abstract:" in matched |
| 287 | ) |
| 288 | |
| 289 | |
| 290 | def test_name_matched_line_lists_the_group_and_filings_counts_exclude_it(): |
| 291 | out = lines(microsoft()) |
| 292 | filings = _line(out, "- Filings:") |
| 293 | assert "0 applications published" in filings and "1 patent granted" in filings |
| 294 | assert "212" not in filings and "140" not in filings and "Mobile" not in filings |
| 295 | assert "Microsoft Corporation" in filings |
| 296 | assert _line(out, OTHERS) == ( |
| 297 | f"{OTHERS} Microsoft Mobile Oy (212 applications, 140 grants); " |
| 298 | "2 first US publications among them" |
| 299 | ) |
| 300 | |
| 301 | |
| 302 | def test_first_publications_under_name_matched_names_are_counted_apart(): |
| 303 | out = lines(block()) |
| 304 | filings = _line(out, "- Filings:") |
| 305 | assert "1 application published | 0 patents granted | filed as Block, Inc." in filings |
| 306 | assert _line(out, "- First US publications:").startswith("- First US publications: 1 (") |
| 307 | assert _line(out, OTHERS).endswith( |
| 308 | "Block Imaging, Inc. (5 applications, 0 grants); 5 first US publications among them" |
| 309 | ) |
| 310 | # The name-matched filings are still listed, labelled. |
| 311 | listed = [line for line in out if line.startswith("- [Filing")] |
| 312 | assert [("not verified" in line) for line in listed] == [False] + [True] * 5 |
| 313 | |
| 314 | |
| 315 | def test_one_name_matched_first_publication_is_singular(): |
| 316 | assert _line(lines(NVIDIA), OTHERS).endswith( |
| 317 | "NVIDIA Corparation (0 applications, 1 grant); 1 first US publication among them" |
| 318 | ) |
| 319 | |
| 320 | |
| 321 | def test_name_matched_line_says_nothing_of_first_publications_when_it_has_none(): |
| 322 | artifact = block() |
| 323 | artifact["counts"]["name_matched_first_publications"] = 0 |
| 324 | assert _line(lines(artifact), OTHERS).endswith( |
| 325 | "Block Imaging, Inc. (5 applications, 0 grants)" |
| 326 | ) |
| 327 | |
| 328 | |
| 329 | def test_with_no_own_filing_no_zero_count_sits_beside_the_other_filers(): |
| 330 | out = lines(block_imaging_only()) |
| 331 | assert _line(out, "- Filings:") == ( |
| 332 | "- Filings: Block | US patent filings published 2026-10-14 to 2026-11-13 | " |
| 333 | "none filed under the company's own name" |
| 334 | ) |
| 335 | assert not any(line.startswith("- First US publications:") for line in out) |
| 336 | assert _line(out, OTHERS).endswith( |
| 337 | "Block Imaging, Inc. (5 applications, 0 grants); 5 first US publications among them" |
| 338 | ) |
| 339 | listed = [line for line in out if line.startswith("- [Filing")] |
| 340 | assert len(listed) == 5 and all("| not verified |" in line for line in listed) |
| 341 | |
| 342 | |
| 343 | def test_an_operating_company_s_filings_are_the_company_s_own(): |
| 344 | out = lines(openai_opco()) |
| 345 | assert _line(out, "- Filings:").endswith( |
| 346 | "| 14 applications published | 3 patents granted | filed as OpenAI OpCo, LLC" |
| 347 | ) |
| 348 | assert _line(out, "- First US publications:").startswith("- First US publications: 15 (") |
| 349 | assert not any(line.startswith(OTHERS) for line in out) |
| 350 | assert "not verified" not in _line(out, "- [Filing 4001]") |
| 351 | |
| 352 | |
| 353 | def test_no_name_matched_line_without_such_a_group(): |
| 354 | artifact = copy.deepcopy(NVIDIA) |
| 355 | artifact["groups"] = artifact["groups"][:1] |
| 356 | assert not any(line.startswith(OTHERS) for line in lines(artifact)) |
| 357 | |
| 358 | |
| 359 | def test_other_names_line_lists_names_with_counts(): |
| 360 | assert _line(lines(microsoft()), "- Other names in the search, not read:") == ( |
| 361 | "- Other names in the search, not read: Nuance Communications, Inc. (3)" |
| 362 | ) |
| 363 | |
| 364 | |
| 365 | def test_floor_puts_a_plus_on_the_counts(): |
| 366 | artifact = microsoft() |
| 367 | artifact["counts"]["floor"] = True |
| 368 | out = lines(artifact) |
| 369 | filings = _line(out, "- Filings:") |
| 370 | assert "0+ applications published" in filings and "1+ patents granted" in filings |
| 371 | assert _line(out, OTHERS).endswith( |
| 372 | "(212+ applications, 140+ grants); 2+ first US publications among them" |
| 373 | ) |
| 374 | assert _line(out, "- First US publications:").startswith("- First US publications: 1+ (") |
| 375 | |
| 376 | |
| 377 | def test_person_topic_names_the_company_the_person_leads(): |
| 378 | artifact = copy.deepcopy(NVIDIA) |
| 379 | artifact["company_via_person"] = True |
| 380 | filings = _line(lines(artifact), "- Filings:") |
| 381 | assert "Nvidia, the company the person leads" in filings |
| 382 | assert "the company's filings, not the person's" in filings |
| 383 | |
| 384 | |
| 385 | def test_partial_renders_a_note_with_the_number(): |
| 386 | artifact = copy.deepcopy(NVIDIA) |
| 387 | artifact["partial"] = {"missing_text": 3} |
| 388 | note = _line(lines(artifact), "- Note:") |
| 389 | assert "3 of the filings listed by title only" in note |
| 390 | assert "no abstract or claim text" in note |
| 391 | assert "did not return it or time ran out" in note |
| 392 | out = lines(artifact) |
| 393 | assert out.index(_line(out, "- First US publications:")) + 1 == out.index(note) |
| 394 | |
| 395 | |
| 396 | def _full_size(entries, index=40): |
| 397 | artifact = copy.deepcopy(NVIDIA) |
| 398 | artifact["entries"] = [ |
| 399 | _entry( |
| 400 | 2000 + n, title="T" * 120, filed_as="NVIDIA Corporation", |
| 401 | cpc=["G06N3/0455"] * patents.MAX_CPC_CODES, earliest_priority="2024-01-01", |
| 402 | abstract="a" * patents.ABSTRACT_CHARS, first_claim="c" * patents.FIRST_CLAIM_CHARS, |
| 403 | ) |
| 404 | for n in range(entries) |
| 405 | ] |
| 406 | artifact["index"] = [ |
| 407 | {**NVIDIA["index"][0], "title": f"Index {n} " + "T" * 120} for n in range(index) |
| 408 | ] |
| 409 | return artifact |
| 410 | |
| 411 | |
| 412 | def _size(out): |
| 413 | return sum(len(line) + 1 for line in out) |
| 414 | |
| 415 | |
| 416 | def test_a_block_over_the_cap_stops_early_and_says_how_many_were_left_out(): |
| 417 | out = lines(_full_size(entries=30, index=10)) |
| 418 | assert _size(out) <= patent_digest.DIGEST_MAX_CHARS == 36_000 |
| 419 | shown = sum(1 for line in out if line.startswith("- [T")) |
| 420 | assert 0 < shown < 30 |
| 421 | note = _line(out, "- Note:") |
| 422 | assert f"{30 - shown} entries and 10 titles left out" in note |
| 423 | assert "36,000 characters" in note |
| 424 | assert not any(line.startswith("- More first US publications") for line in out) |
| 425 | assert not any(line.startswith(" - [") for line in out) |
| 426 | |
| 427 | |
| 428 | def test_the_lane_s_largest_artifact_stays_under_the_cap(): |
| 429 | # Every slot filled with text at its own cap, and the whole index. |
| 430 | assert (patents.ABSTRACT_CHARS, patents.FIRST_CLAIM_CHARS) == (1000, 1200) |
| 431 | out = lines(_full_size(entries=patents.DETAIL_SLOTS, index=patents.MAX_INDEX)) |
| 432 | assert _size(out) <= patent_digest.DIGEST_MAX_CHARS |
| 433 | assert sum(1 for line in out if line.startswith("- [T")) == patents.DETAIL_SLOTS |
| 434 | |
| 435 | |
| 436 | def test_titles_cut_by_the_cap_are_counted_in_the_note(): |
| 437 | artifact = _full_size(entries=patents.DETAIL_SLOTS, index=patents.MAX_INDEX) |
| 438 | for item in artifact["index"]: |
| 439 | item["title"] = "T" * 400 |
| 440 | out = lines(artifact) |
| 441 | assert _size(out) <= patent_digest.DIGEST_MAX_CHARS |
| 442 | shown = sum(1 for line in out if line.startswith(" - [")) |
| 443 | assert 0 < shown < patents.MAX_INDEX |
| 444 | assert f"{patents.MAX_INDEX - shown} titles left out" in _line(out, "- Note:") |
| 445 | |
| 446 | |
| 447 | def test_counts_only_or_malformed_artifact_has_no_block(): |
| 448 | counts_only = copy.deepcopy(NVIDIA) |
| 449 | counts_only.update(status="counts-only", entries=[], index=[]) |
| 450 | assert lines(counts_only) == [] |
| 451 | assert lines(None) == [] |
| 452 | assert lines({"status": "digest"}) == [] |
| 453 |