[{"data":1,"prerenderedAt":3191},["ShallowReactive",2],{"en-blog-detail-/en/blog/20261129-hybrid-photo-search-zero-ms-lightbox-2026-12-03":3,"en-blog-linked-project-/en/blog/20261129-hybrid-photo-search-zero-ms-lightbox-2026-12-03":3175,"en-blog-ko-counterpart-/en/blog/20261129-hybrid-photo-search-zero-ms-lightbox-2026-12-03":3179,"en-blog-surround-/en/blog/20261129-hybrid-photo-search-zero-ms-lightbox-2026-12-03":3180},{"id":4,"title":5,"adsEnabled":6,"author":7,"body":8,"buildLogLabel":3153,"category":3154,"coverImage":3155,"coverImageAlt":3156,"date":3157,"description":3158,"extension":3159,"faq":3160,"meta":3161,"navigation":6,"noindex":3162,"path":3163,"project":3164,"promo":3162,"seo":3165,"seoDescription":3160,"seoTitle":3160,"status":3166,"stem":3167,"tags":3168,"__hash__":3174},"enBlog/en/blog/20261129-Hybrid-Photo-Search-Zero-Ms-Lightbox.md","Hybrid Search Across 34,050 Photos & Book Plates with a 0ms Progressive Lightbox",true,"KangSum",{"type":9,"value":10,"toc":3133},"minimark",[11,15,27,60,103,106,111,118,123,142,157,161,168,171,173,177,186,193,196,241,623,630,643,645,649,666,670,756,1037,1041,1048,1153,1168,1170,1174,1177,1204,1207,1240,1342,1344,1353,1363,1376,1395,1398,1445,2354,2367,2373,2446,3021,3048,3050,3054,3057,3123,3129],[12,13,5],"h1",{"id":14},"hybrid-search-across-34050-photos-book-plates-with-a-0ms-progressive-lightbox",[16,17,18,19,23,24],"p",{},"Once an image archive combining field-shot photography and scanned technical plates from optics and photography monographs grows to ",[20,21,22],"strong",{},"34,050 assets",", naive dense vector search and raw-file image streaming quickly break down under real production workflows. When curating photography course materials or pulling optical reference frames, the interaction bar is straightforward: ",[20,25,26],{},"surface the exact gear or optical plate at the top of page one, and expand it to high resolution on click with zero perceived wait.",[16,28,29,30,33,34,37,38,49,50,59],{},"Opening up our production telemetry and browser waterfall traces revealed two orthogonal bottlenecks compounding each other. On the retrieval side, a single dense embedding model suffered from ",[20,31,32],{},"hubness domination"," and pervasive ",[20,35,36],{},"missing EXIF metadata"," on scanned book plates, corrupting top-slot precision. On the delivery side, streaming untouched originals directly from upstream storage produced worst-case viewer latencies of ",[20,39,40,44,45,48],{},[41,42,43],"code",{},"7,504.8ms"," for a ",[41,46,47],{},"1.47MB"," original photograph"," and ",[20,51,52,44,55,58],{},[41,53,54],{},"3,953.5ms",[41,56,57],{},"2.20MB"," high-DPI book plate",".",[16,61,62,63,68,69],{},"This engineering post breaks down the five architectural pillars built for the ",[64,65,67],"a",{"href":66},"/en/projects/hybrid-photo-search-engine","Hybrid Photo & Book Plate Search Engine & 0ms Lightbox",": ",[20,70,71,72,74,75,78,79,82,83,86,87,90,91,94,95,98,99,102],{},"① separating an immutable vector corpus from a Copy-on-Write (CoW) EXIF overlay, ② Dual-Path reranking combining dense semantics with field-weighted lexical scoring and a 17-query benchmark, ③ diagnosing the ",[41,73,43],{}," viewer bottleneck, ④ an atomic ",[41,76,77],{},"1600px"," WebP persistent disk cache with ",[41,80,81],{},"404","/",[41,84,85],{},"422"," + ",[41,88,89],{},"no-store"," origin defense, and ⑤ ",[41,92,93],{},"120ms"," hover prefetching paired with ",[41,96,97],{},"N±1"," preloading and ",[41,100,101],{},"0ms"," progressive thumbnail-to-HiRes swapping.",[104,105],"hr",{},[107,108,110],"h2",{"id":109},"_1-where-a-34050-asset-archive-breaks-vector-hubness-and-missing-exif","1. Where a 34,050-Asset Archive Breaks: Vector Hubness and Missing EXIF",[16,112,113,114,117],{},"In a small photo library (under a few thousand frames), a single multilingual dense embedding often feels surprisingly capable. At ",[20,115,116],{},"34,050 heterogeneous records"," mixing camera originals and textbook plates, however, pure dense retrieval exposed two structural failure modes.",[119,120,122],"h3",{"id":121},"_11-the-hubness-phenomenon-in-high-dimensional-embeddings","1.1. The Hubness Phenomenon in High-Dimensional Embeddings",[16,124,125,126,129,130,133,134,137,138,141],{},"In high-dimensional embedding spaces, a small subset of broadly descriptive documents—frames whose captions mention generic concepts like ",[41,127,128],{},"\"studio portrait\"",", ",[41,131,132],{},"\"lighting setup\"",", or ",[41,135,136],{},"\"camera lens\"","—gravitate toward the centroid of the manifold. These documents become ",[20,139,140],{},"hub vectors",": nearest neighbors to a disproportionate fraction of unrelated queries.",[16,143,144,145,148,149,152,153,156],{},"The failure mode was painfully consistent. Even when a user issued a highly specific query such as ",[41,146,147],{},"\"50mm f/1.4 wide-open night bokeh example\""," or ",[41,150,151],{},"\"large-format Scheimpflug principle plate 4-12\"",", generic studio hub vectors routinely hijacked the Top-5 cosine-similarity slots. Neither shot at ",[41,154,155],{},"50mm"," nor depicting the Scheimpflug plane, they crowded out the exact target plate and pushed it below the fold.",[119,158,160],{"id":159},"_12-missing-exif-on-scanned-book-plates-and-the-re-indexing-dilemma","1.2. Missing EXIF on Scanned Book Plates and the Re-Indexing Dilemma",[16,162,163,164,167],{},"The second obstacle was ",[20,165,166],{},"asymmetric metadata density",". Camera-captured photographs carry shutter speed, aperture, focal length, and body strings inside EXIF headers—though legacy exports and edited derivatives frequently strip or mangle manufacturer tags. Scanned diagrams and optical plates from reference books have no camera EXIF whatsoever.",[16,169,170],{},"Mutating or upserting a 34,050-record vector index every time a curator normalized a lens string or backfilled an optical parameter for a book plate proved operationally brittle. In-place vector writes introduced index lock contention, degraded HNSW graph balance over time, and made rolling back a faulty batch tagger painful and error-prone.",[104,172],{},[107,174,176],{"id":175},"_2-separating-an-immutable-base-corpus-from-a-copy-on-write-exif-overlay","2. Separating an Immutable Base Corpus from a Copy-on-Write EXIF Overlay",[16,178,179,180,49,183,59],{},"The first structural decision was to draw a hard storage boundary between the ",[20,181,182],{},"immutable source corpus",[20,184,185],{},"mutable, continuously curated EXIF metadata",[16,187,188],{},[189,190],"img",{"alt":191,"src":192},"Architecture diagram of the 34,050-asset immutable corpus index, Copy-on-Write EXIF overlay, Dual-Path reranking, and 1600px WebP prefetch lightbox pipeline","/images/content-images/blog/20261129-Hybrid-Photo-Search-Zero-Ms-Lightbox/20261129-Hybrid-Photo-Search-Zero-Ms-Lightbox002-en.svg",[16,194,195],{},"The data layer splits cleanly into two components:",[197,198,199,222,235],"ul",{},[200,201,202,209,210,213,214,217,218,221],"li",{},[20,203,204,205,208],{},"Immutable Corpus Snapshot (",[41,206,207],{},"/srv/app/image-search/index/snapshot_v*","):"," Each of the 34,050 assets is frozen in a read-only snapshot keyed by content-addressed ",[41,211,212],{},"asset_id"," (SHA-256), media type (",[41,215,216],{},"photo"," | ",[41,219,220],{},"book_plate","), raw caption/OCR text, and dense embedding vector. Curatorial metadata edits never touch these snapshot files.",[200,223,224,230,231,234],{},[20,225,226,227,208],{},"Copy-on-Write EXIF Overlay (",[41,228,229],{},"/srv/app/image-search/data/exif_overlay.sqlite"," Backfilled camera bodies, normalized focal lengths and apertures, and curated book-plate subjects are appended strictly as revisioned deltas keyed by ",[41,232,233],{},"(asset_id, revision)"," inside a lightweight SQLite overlay table.",[200,236,237,240],{},[20,238,239],{},"Read-Time Resolution:"," Only during candidate reranking and API response serialization does the engine merge active overlay revisions on top of the immutable base record to materialize the effective metadata payload.",[242,243,248],"pre",{"className":244,"code":245,"language":246,"meta":247,"style":247},"language-python shiki shiki-themes github-light github-dark","# /srv/app/image-search/src/cow_overlay.py (Immutable corpus + CoW EXIF read-time merge)\nfrom dataclasses import dataclass\nfrom pathlib import Path\nimport sqlite3\nimport json\n\nCORPUS_SNAPSHOT_DIR = Path(\"/srv/app/image-search/index/snapshot_v1\")\nEXIF_OVERLAY_DB = Path(\"/srv/app/image-search/data/exif_overlay.sqlite\")\n\n\n@dataclass(frozen=True)\nclass EffectiveAssetRecord:\n    asset_id: str\n    source_kind: str        # \"photo\" | \"book_plate\"\n    caption: str\n    exif_merged: dict       # Base EXIF + CoW overlay delta resolution\n    overlay_revision: int\n\n\ndef patch_exif_overlay(conn: sqlite3.Connection, asset_id: str, patch: dict, editor: str) -> int:\n    \"\"\"Append a Copy-on-Write EXIF correction delta without mutating the immutable corpus.\"\"\"\n    cur = conn.execute(\n        \"SELECT COALESCE(MAX(revision), 0) FROM exif_overlay WHERE asset_id = ?\",\n        (asset_id,),\n    )\n    next_rev = int(cur.fetchone()[0]) + 1\n    conn.execute(\n        \"\"\"\n        INSERT INTO exif_overlay (asset_id, revision, patch_json, updated_by)\n        VALUES (?, ?, ?, ?)\n        \"\"\",\n        (asset_id, next_rev, json.dumps(patch, ensure_ascii=False), editor),\n    )\n    conn.commit()\n    return next_rev\n\n\ndef resolve_effective_record(base_row: dict, conn: sqlite3.Connection) -> EffectiveAssetRecord:\n    \"\"\"Merge active CoW EXIF overlay revisions onto the immutable base row at read time.\"\"\"\n    cur = conn.execute(\n        \"\"\"\n        SELECT revision, patch_json\n        FROM exif_overlay\n        WHERE asset_id = ? AND is_reverted = 0\n        ORDER BY revision ASC\n        \"\"\",\n        (base_row[\"asset_id\"],),\n    )\n    merged = dict(base_row.get(\"raw_exif\") or {})\n    latest_rev = 0\n    for rev, patch_json in cur.fetchall():\n        patch = json.loads(patch_json)\n        for key, value in patch.items():\n            if value is not None:\n                merged[key] = value\n        latest_rev = int(rev)\n\n    return EffectiveAssetRecord(\n        asset_id=base_row[\"asset_id\"],\n        source_kind=base_row[\"source_kind\"],\n        caption=base_row[\"caption\"],\n        exif_merged=merged,\n        overlay_revision=latest_rev,\n    )\n","python","",[41,249,250,258,264,270,276,282,288,294,300,305,310,316,322,328,334,340,346,352,357,362,368,374,380,386,392,398,404,410,416,422,428,434,440,445,451,457,462,467,473,479,484,489,495,501,507,513,518,524,529,535,541,547,553,559,565,571,577,582,588,594,600,606,612,618],{"__ignoreMap":247},[251,252,255],"span",{"class":253,"line":254},"line",1,[251,256,257],{},"# /srv/app/image-search/src/cow_overlay.py (Immutable corpus + CoW EXIF read-time merge)\n",[251,259,261],{"class":253,"line":260},2,[251,262,263],{},"from dataclasses import dataclass\n",[251,265,267],{"class":253,"line":266},3,[251,268,269],{},"from pathlib import Path\n",[251,271,273],{"class":253,"line":272},4,[251,274,275],{},"import sqlite3\n",[251,277,279],{"class":253,"line":278},5,[251,280,281],{},"import json\n",[251,283,285],{"class":253,"line":284},6,[251,286,287],{"emptyLinePlaceholder":6},"\n",[251,289,291],{"class":253,"line":290},7,[251,292,293],{},"CORPUS_SNAPSHOT_DIR = Path(\"/srv/app/image-search/index/snapshot_v1\")\n",[251,295,297],{"class":253,"line":296},8,[251,298,299],{},"EXIF_OVERLAY_DB = Path(\"/srv/app/image-search/data/exif_overlay.sqlite\")\n",[251,301,303],{"class":253,"line":302},9,[251,304,287],{"emptyLinePlaceholder":6},[251,306,308],{"class":253,"line":307},10,[251,309,287],{"emptyLinePlaceholder":6},[251,311,313],{"class":253,"line":312},11,[251,314,315],{},"@dataclass(frozen=True)\n",[251,317,319],{"class":253,"line":318},12,[251,320,321],{},"class EffectiveAssetRecord:\n",[251,323,325],{"class":253,"line":324},13,[251,326,327],{},"    asset_id: str\n",[251,329,331],{"class":253,"line":330},14,[251,332,333],{},"    source_kind: str        # \"photo\" | \"book_plate\"\n",[251,335,337],{"class":253,"line":336},15,[251,338,339],{},"    caption: str\n",[251,341,343],{"class":253,"line":342},16,[251,344,345],{},"    exif_merged: dict       # Base EXIF + CoW overlay delta resolution\n",[251,347,349],{"class":253,"line":348},17,[251,350,351],{},"    overlay_revision: int\n",[251,353,355],{"class":253,"line":354},18,[251,356,287],{"emptyLinePlaceholder":6},[251,358,360],{"class":253,"line":359},19,[251,361,287],{"emptyLinePlaceholder":6},[251,363,365],{"class":253,"line":364},20,[251,366,367],{},"def patch_exif_overlay(conn: sqlite3.Connection, asset_id: str, patch: dict, editor: str) -> int:\n",[251,369,371],{"class":253,"line":370},21,[251,372,373],{},"    \"\"\"Append a Copy-on-Write EXIF correction delta without mutating the immutable corpus.\"\"\"\n",[251,375,377],{"class":253,"line":376},22,[251,378,379],{},"    cur = conn.execute(\n",[251,381,383],{"class":253,"line":382},23,[251,384,385],{},"        \"SELECT COALESCE(MAX(revision), 0) FROM exif_overlay WHERE asset_id = ?\",\n",[251,387,389],{"class":253,"line":388},24,[251,390,391],{},"        (asset_id,),\n",[251,393,395],{"class":253,"line":394},25,[251,396,397],{},"    )\n",[251,399,401],{"class":253,"line":400},26,[251,402,403],{},"    next_rev = int(cur.fetchone()[0]) + 1\n",[251,405,407],{"class":253,"line":406},27,[251,408,409],{},"    conn.execute(\n",[251,411,413],{"class":253,"line":412},28,[251,414,415],{},"        \"\"\"\n",[251,417,419],{"class":253,"line":418},29,[251,420,421],{},"        INSERT INTO exif_overlay (asset_id, revision, patch_json, updated_by)\n",[251,423,425],{"class":253,"line":424},30,[251,426,427],{},"        VALUES (?, ?, ?, ?)\n",[251,429,431],{"class":253,"line":430},31,[251,432,433],{},"        \"\"\",\n",[251,435,437],{"class":253,"line":436},32,[251,438,439],{},"        (asset_id, next_rev, json.dumps(patch, ensure_ascii=False), editor),\n",[251,441,443],{"class":253,"line":442},33,[251,444,397],{},[251,446,448],{"class":253,"line":447},34,[251,449,450],{},"    conn.commit()\n",[251,452,454],{"class":253,"line":453},35,[251,455,456],{},"    return next_rev\n",[251,458,460],{"class":253,"line":459},36,[251,461,287],{"emptyLinePlaceholder":6},[251,463,465],{"class":253,"line":464},37,[251,466,287],{"emptyLinePlaceholder":6},[251,468,470],{"class":253,"line":469},38,[251,471,472],{},"def resolve_effective_record(base_row: dict, conn: sqlite3.Connection) -> EffectiveAssetRecord:\n",[251,474,476],{"class":253,"line":475},39,[251,477,478],{},"    \"\"\"Merge active CoW EXIF overlay revisions onto the immutable base row at read time.\"\"\"\n",[251,480,482],{"class":253,"line":481},40,[251,483,379],{},[251,485,487],{"class":253,"line":486},41,[251,488,415],{},[251,490,492],{"class":253,"line":491},42,[251,493,494],{},"        SELECT revision, patch_json\n",[251,496,498],{"class":253,"line":497},43,[251,499,500],{},"        FROM exif_overlay\n",[251,502,504],{"class":253,"line":503},44,[251,505,506],{},"        WHERE asset_id = ? AND is_reverted = 0\n",[251,508,510],{"class":253,"line":509},45,[251,511,512],{},"        ORDER BY revision ASC\n",[251,514,516],{"class":253,"line":515},46,[251,517,433],{},[251,519,521],{"class":253,"line":520},47,[251,522,523],{},"        (base_row[\"asset_id\"],),\n",[251,525,527],{"class":253,"line":526},48,[251,528,397],{},[251,530,532],{"class":253,"line":531},49,[251,533,534],{},"    merged = dict(base_row.get(\"raw_exif\") or {})\n",[251,536,538],{"class":253,"line":537},50,[251,539,540],{},"    latest_rev = 0\n",[251,542,544],{"class":253,"line":543},51,[251,545,546],{},"    for rev, patch_json in cur.fetchall():\n",[251,548,550],{"class":253,"line":549},52,[251,551,552],{},"        patch = json.loads(patch_json)\n",[251,554,556],{"class":253,"line":555},53,[251,557,558],{},"        for key, value in patch.items():\n",[251,560,562],{"class":253,"line":561},54,[251,563,564],{},"            if value is not None:\n",[251,566,568],{"class":253,"line":567},55,[251,569,570],{},"                merged[key] = value\n",[251,572,574],{"class":253,"line":573},56,[251,575,576],{},"        latest_rev = int(rev)\n",[251,578,580],{"class":253,"line":579},57,[251,581,287],{"emptyLinePlaceholder":6},[251,583,585],{"class":253,"line":584},58,[251,586,587],{},"    return EffectiveAssetRecord(\n",[251,589,591],{"class":253,"line":590},59,[251,592,593],{},"        asset_id=base_row[\"asset_id\"],\n",[251,595,597],{"class":253,"line":596},60,[251,598,599],{},"        source_kind=base_row[\"source_kind\"],\n",[251,601,603],{"class":253,"line":602},61,[251,604,605],{},"        caption=base_row[\"caption\"],\n",[251,607,609],{"class":253,"line":608},62,[251,610,611],{},"        exif_merged=merged,\n",[251,613,615],{"class":253,"line":614},63,[251,616,617],{},"        overlay_revision=latest_rev,\n",[251,619,621],{"class":253,"line":620},64,[251,622,397],{},[16,624,625,626,629],{},"Decoupling storage yielded two immediate operational wins. First, because the 34,050-asset vector snapshot stays read-only on disk, live queries experience zero write-lock stalls and zero index corruption risk. Second, any mistaken bulk metadata patch can be undone instantaneously by toggling ",[41,627,628],{},"is_reverted = 1"," or rolling back a revision—dramatically accelerating curation experiments.",[631,632,633],"blockquote",{},[16,634,635,638,639,642],{},[20,636,637],{},"Key Takeaway:","\nWhen a large vector corpus undergoes frequent metadata normalization or curation, resist in-place vector upserts. Splitting storage into an ",[20,640,641],{},"immutable vector snapshot + Copy-on-Write delta overlay"," preserves read stability while making every metadata mutation reversible.",[104,644],{},[107,646,648],{"id":647},"_3-dual-path-reranking-dense-semantics-field-weighted-lexical-17-query-benchmark","3. Dual-Path Reranking (Dense Semantics + Field-Weighted Lexical) & 17-Query Benchmark",[16,650,651,652,49,655,658,659,662,663,59],{},"With the storage layer isolated, we focused on retrieval precision. Our search pipeline retrieves candidates in parallel through ",[20,653,654],{},"Path A (Dense Semantic Retrieval)",[20,656,657],{},"Path B (Field-Weighted Lexical Retrieval)",", then fuses them in a ",[20,660,661],{},"Dual-Path reranker"," equipped with a selective ",[20,664,665],{},"hubness centrality penalty",[119,667,669],{"id":668},"_31-parallel-candidate-recall-field-weights-and-selective-hubness-decay","3.1. Parallel Candidate Recall, Field Weights, and Selective Hubness Decay",[671,672,673,683,735],"ol",{},[200,674,675,678,679,682],{},[20,676,677],{},"Path A (Dense Semantic Retrieval):"," Pulls Top-80 candidates by cosine similarity against the immutable vector snapshot. This path excels at abstract or mood-driven queries such as ",[41,680,681],{},"\"soft side-diffused light highlighting still-life texture\""," where exact technical tokens may not appear in captions.",[200,684,685,688,689,129,692,695,696,699,700],{},[20,686,687],{},"Path B (Field-Weighted Lexical Retrieval):"," Normalizes the query into optical specs (",[41,690,691],{},"f/1.4",[41,693,694],{},"85mm","), plate identifiers (",[41,697,698],{},"plate 4-12","), camera/lens tokens, and bigrams, then extracts a separate Top-80 pool from CoW-resolved records using tiered field weights:\n",[197,701,702,711,719,727],{},[200,703,704],{},[20,705,706,707,710],{},"Title / Plate Number / Filename Tokens (",[41,708,709],{},"w = 3.0",")",[200,712,713],{},[20,714,715,716,710],{},"Normalized EXIF Body, Focal Length & Aperture (",[41,717,718],{},"w = 2.5",[200,720,721],{},[20,722,723,724,710],{},"Curated Optical & Lighting Tags (",[41,725,726],{},"w = 2.0",[200,728,729],{},[20,730,731,732,710],{},"AI Captions & Book OCR Text (",[41,733,734],{},"w = 1.0",[200,736,737,740,741,744,745,748,749,755],{},[20,738,739],{},"Dual-Path Reranking & Hubness Attenuation:"," Over the deduplicated union of both pools, the ranker blends dense similarity (",[41,742,743],{},"0.45",") with log-damped field lexical score (",[41,746,747],{},"0.55","), then subtracts a precomputed ",[20,750,751,752,710],{},"hub centrality penalty (",[41,753,754],{},"hubness_penalty",". Crucially, that penalty is gated by missing lexical coverage: if a high-centrality hub vector lacks literal token evidence for the query, its score is decisively suppressed.",[242,757,759],{"className":244,"code":758,"language":246,"meta":247,"style":247},"# /srv/app/image-search/src/dual_path_reranker.py (Dual-Path reranking & selective hubness penalty)\nimport math\nimport re\n\nFIELD_WEIGHTS = {\n    \"plate_or_title\": 3.0,\n    \"exif_specs\": 2.5,\n    \"optical_tags\": 2.0,\n    \"caption_ocr\": 1.0,\n}\n\n\ndef tokenize_optical_query(query: str) -> list[str]:\n    \"\"\"Preserve optical notation (f/1.4, 50mm, 4-12) alongside multilingual keywords.\"\"\"\n    tokens = re.findall(r\"f/\\d+(?:\\.\\d+)?|[가-힣a-zA-Z0-9]+(?:-[0-9]+)?\", query.lower())\n    return list(dict.fromkeys(t for t in tokens if len(t) >= 2))\n\n\ndef compute_field_lexical_score(tokens: list[str], fields: dict[str, str]) -> tuple[float, int]:\n    if not tokens:\n        return 0.0, 0\n\n    matched_tokens = set()\n    weighted_sum = 0.0\n    max_possible = sum(FIELD_WEIGHTS.values()) * len(tokens)\n\n    for field_name, weight in FIELD_WEIGHTS.items():\n        haystack = (fields.get(field_name) or \"\").lower()\n        if not haystack:\n            continue\n        for tok in tokens:\n            if tok in haystack:\n                matched_tokens.add(tok)\n                weighted_sum += weight\n\n    # Apply logarithmic saturation so verbose OCR passages cannot drown out short EXIF matches\n    normalized = math.log1p(weighted_sum) / math.log1p(max(1.0, max_possible * 0.35))\n    return min(1.0, normalized), len(matched_tokens)\n\n\ndef rerank_dual_path(candidates: list[dict], query: str, top_n: int = 24) -> list[dict]:\n    tokens = tokenize_optical_query(query)\n    scored = []\n\n    for item in candidates:\n        dense_sim = max(0.0, min(1.0, float(item.get(\"dense_sim\", 0.0))))\n        lex_score, hit_count = compute_field_lexical_score(tokens, item[\"effective_fields\"])\n\n        # Penalize high-centrality hub vectors only when they lack explicit lexical coverage\n        centrality = float(item.get(\"hub_centrality\", 0.0))\n        lexical_coverage = hit_count / max(1, len(tokens))\n        hub_penalty = centrality * (1.0 - lexical_coverage) * 0.35\n\n        final_score = (0.45 * dense_sim) + (0.55 * lex_score) - hub_penalty\n        scored.append({**item, \"final_score\": round(final_score, 4), \"lexical_hits\": hit_count})\n\n    scored.sort(key=lambda x: (x[\"final_score\"], x[\"lexical_hits\"], x.get(\"dense_sim\", 0.0)), reverse=True)\n    return scored[:top_n]\n",[41,760,761,766,771,776,780,785,790,795,800,805,810,814,818,823,828,833,838,842,846,851,856,861,865,870,875,880,884,889,894,899,904,909,914,919,924,928,933,938,943,947,951,956,961,966,970,975,980,985,989,994,999,1004,1009,1013,1018,1023,1027,1032],{"__ignoreMap":247},[251,762,763],{"class":253,"line":254},[251,764,765],{},"# /srv/app/image-search/src/dual_path_reranker.py (Dual-Path reranking & selective hubness penalty)\n",[251,767,768],{"class":253,"line":260},[251,769,770],{},"import math\n",[251,772,773],{"class":253,"line":266},[251,774,775],{},"import re\n",[251,777,778],{"class":253,"line":272},[251,779,287],{"emptyLinePlaceholder":6},[251,781,782],{"class":253,"line":278},[251,783,784],{},"FIELD_WEIGHTS = {\n",[251,786,787],{"class":253,"line":284},[251,788,789],{},"    \"plate_or_title\": 3.0,\n",[251,791,792],{"class":253,"line":290},[251,793,794],{},"    \"exif_specs\": 2.5,\n",[251,796,797],{"class":253,"line":296},[251,798,799],{},"    \"optical_tags\": 2.0,\n",[251,801,802],{"class":253,"line":302},[251,803,804],{},"    \"caption_ocr\": 1.0,\n",[251,806,807],{"class":253,"line":307},[251,808,809],{},"}\n",[251,811,812],{"class":253,"line":312},[251,813,287],{"emptyLinePlaceholder":6},[251,815,816],{"class":253,"line":318},[251,817,287],{"emptyLinePlaceholder":6},[251,819,820],{"class":253,"line":324},[251,821,822],{},"def tokenize_optical_query(query: str) -> list[str]:\n",[251,824,825],{"class":253,"line":330},[251,826,827],{},"    \"\"\"Preserve optical notation (f/1.4, 50mm, 4-12) alongside multilingual keywords.\"\"\"\n",[251,829,830],{"class":253,"line":336},[251,831,832],{},"    tokens = re.findall(r\"f/\\d+(?:\\.\\d+)?|[가-힣a-zA-Z0-9]+(?:-[0-9]+)?\", query.lower())\n",[251,834,835],{"class":253,"line":342},[251,836,837],{},"    return list(dict.fromkeys(t for t in tokens if len(t) >= 2))\n",[251,839,840],{"class":253,"line":348},[251,841,287],{"emptyLinePlaceholder":6},[251,843,844],{"class":253,"line":354},[251,845,287],{"emptyLinePlaceholder":6},[251,847,848],{"class":253,"line":359},[251,849,850],{},"def compute_field_lexical_score(tokens: list[str], fields: dict[str, str]) -> tuple[float, int]:\n",[251,852,853],{"class":253,"line":364},[251,854,855],{},"    if not tokens:\n",[251,857,858],{"class":253,"line":370},[251,859,860],{},"        return 0.0, 0\n",[251,862,863],{"class":253,"line":376},[251,864,287],{"emptyLinePlaceholder":6},[251,866,867],{"class":253,"line":382},[251,868,869],{},"    matched_tokens = set()\n",[251,871,872],{"class":253,"line":388},[251,873,874],{},"    weighted_sum = 0.0\n",[251,876,877],{"class":253,"line":394},[251,878,879],{},"    max_possible = sum(FIELD_WEIGHTS.values()) * len(tokens)\n",[251,881,882],{"class":253,"line":400},[251,883,287],{"emptyLinePlaceholder":6},[251,885,886],{"class":253,"line":406},[251,887,888],{},"    for field_name, weight in FIELD_WEIGHTS.items():\n",[251,890,891],{"class":253,"line":412},[251,892,893],{},"        haystack = (fields.get(field_name) or \"\").lower()\n",[251,895,896],{"class":253,"line":418},[251,897,898],{},"        if not haystack:\n",[251,900,901],{"class":253,"line":424},[251,902,903],{},"            continue\n",[251,905,906],{"class":253,"line":430},[251,907,908],{},"        for tok in tokens:\n",[251,910,911],{"class":253,"line":436},[251,912,913],{},"            if tok in haystack:\n",[251,915,916],{"class":253,"line":442},[251,917,918],{},"                matched_tokens.add(tok)\n",[251,920,921],{"class":253,"line":447},[251,922,923],{},"                weighted_sum += weight\n",[251,925,926],{"class":253,"line":453},[251,927,287],{"emptyLinePlaceholder":6},[251,929,930],{"class":253,"line":459},[251,931,932],{},"    # Apply logarithmic saturation so verbose OCR passages cannot drown out short EXIF matches\n",[251,934,935],{"class":253,"line":464},[251,936,937],{},"    normalized = math.log1p(weighted_sum) / math.log1p(max(1.0, max_possible * 0.35))\n",[251,939,940],{"class":253,"line":469},[251,941,942],{},"    return min(1.0, normalized), len(matched_tokens)\n",[251,944,945],{"class":253,"line":475},[251,946,287],{"emptyLinePlaceholder":6},[251,948,949],{"class":253,"line":481},[251,950,287],{"emptyLinePlaceholder":6},[251,952,953],{"class":253,"line":486},[251,954,955],{},"def rerank_dual_path(candidates: list[dict], query: str, top_n: int = 24) -> list[dict]:\n",[251,957,958],{"class":253,"line":491},[251,959,960],{},"    tokens = tokenize_optical_query(query)\n",[251,962,963],{"class":253,"line":497},[251,964,965],{},"    scored = []\n",[251,967,968],{"class":253,"line":503},[251,969,287],{"emptyLinePlaceholder":6},[251,971,972],{"class":253,"line":509},[251,973,974],{},"    for item in candidates:\n",[251,976,977],{"class":253,"line":515},[251,978,979],{},"        dense_sim = max(0.0, min(1.0, float(item.get(\"dense_sim\", 0.0))))\n",[251,981,982],{"class":253,"line":520},[251,983,984],{},"        lex_score, hit_count = compute_field_lexical_score(tokens, item[\"effective_fields\"])\n",[251,986,987],{"class":253,"line":526},[251,988,287],{"emptyLinePlaceholder":6},[251,990,991],{"class":253,"line":531},[251,992,993],{},"        # Penalize high-centrality hub vectors only when they lack explicit lexical coverage\n",[251,995,996],{"class":253,"line":537},[251,997,998],{},"        centrality = float(item.get(\"hub_centrality\", 0.0))\n",[251,1000,1001],{"class":253,"line":543},[251,1002,1003],{},"        lexical_coverage = hit_count / max(1, len(tokens))\n",[251,1005,1006],{"class":253,"line":549},[251,1007,1008],{},"        hub_penalty = centrality * (1.0 - lexical_coverage) * 0.35\n",[251,1010,1011],{"class":253,"line":555},[251,1012,287],{"emptyLinePlaceholder":6},[251,1014,1015],{"class":253,"line":561},[251,1016,1017],{},"        final_score = (0.45 * dense_sim) + (0.55 * lex_score) - hub_penalty\n",[251,1019,1020],{"class":253,"line":567},[251,1021,1022],{},"        scored.append({**item, \"final_score\": round(final_score, 4), \"lexical_hits\": hit_count})\n",[251,1024,1025],{"class":253,"line":573},[251,1026,287],{"emptyLinePlaceholder":6},[251,1028,1029],{"class":253,"line":579},[251,1030,1031],{},"    scored.sort(key=lambda x: (x[\"final_score\"], x[\"lexical_hits\"], x.get(\"dense_sim\", 0.0)), reverse=True)\n",[251,1033,1034],{"class":253,"line":584},[251,1035,1036],{},"    return scored[:top_n]\n",[119,1038,1040],{"id":1039},"_32-validation-across-a-17-query-representative-benchmark","3.2. Validation Across a 17-Query Representative Benchmark",[16,1042,1043,1044,1047],{},"To verify that architectural complexity translated into measurable ranking improvements rather than intuition, we assembled a ",[20,1045,1046],{},"17-query benchmark suite"," covering the exact production failure patterns observed in logs, comparing pure dense search against Dual-Path reranking + CoW EXIF.",[1049,1050,1051,1068],"table",{},[1052,1053,1054],"thead",{},[1055,1056,1057,1062,1065],"tr",{},[1058,1059,1061],"th",{"align":1060},"left","Benchmark Axis (17-Query Suite)",[1058,1063,1064],{"align":1060},"Single Dense Embedding Limitation",[1058,1066,1067],{"align":1060},"After Dual-Path Reranking + CoW EXIF",[1069,1070,1071,1094,1112,1133],"tbody",{},[1055,1072,1073,1084,1087],{},[1074,1075,1076,1079,1080,1083],"td",{"align":1060},[20,1077,1078],{},"Gear & Optical Spec Queries"," (",[41,1081,1082],{},"50mm f/1.4",", camera/lens models)",[1074,1085,1086],{"align":1060},"Subword fragmentation let unrelated focal lengths with similar framing leak into Top-5",[1074,1088,1089,1090,1093],{"align":1060},"Exact EXIF field weight (",[41,1091,1092],{},"w=2.5",") + CoW normalized values pin matching gear to the top",[1055,1095,1096,1102,1105],{},[1074,1097,1098,1101],{"align":1060},[20,1099,1100],{},"Book Plate & Diagram Queries"," (optical schematics, Zone System plates)",[1074,1103,1104],{"align":1060},"Zero EXIF and strong studio hub vectors pushed target plates far down the result page",[1074,1106,1107,1108,1111],{"align":1060},"Plate/title weighting (",[41,1109,1110],{},"w=3.0",") + hubness attenuation restore target plates into Top-K",[1055,1113,1114,1120,1123],{},[1074,1115,1116,1119],{"align":1060},[20,1117,1118],{},"Lighting & Visual Mood Queries"," (backlit silhouette, diffused still life)",[1074,1121,1122],{"align":1060},"Captured broad visual vibe but under-weighted explicit lighting technique taxonomy",[1074,1124,1125,1126,1128,1129,1132],{"align":1060},"Dense similarity (",[41,1127,743],{},") reinforced by optical tag matches (",[41,1130,1131],{},"w=2.0",") improves relevance",[1055,1134,1135,1147,1150],{},[1074,1136,1137,1079,1140,129,1143,1146],{"align":1060},[20,1138,1139],{},"Bilingual & Technical Terminology",[41,1141,1142],{},"Scheimpflug",[41,1144,1145],{},"Rembrandt",", Korean/English mix)",[1074,1148,1149],{"align":1060},"Script/transliteration variance dropped lexical cues and triggered hub fallback",[1074,1151,1152],{"align":1060},"Optical-aware tokenizer + Dual-Path union preserve recall regardless of script mix",[631,1154,1155],{},[16,1156,1157,1159,1160,1163,1164,1167],{},[20,1158,637],{},"\nSubtracting a flat hubness penalty indiscriminately punishes canonical reference frames that legitimately match a query. Scaling centrality by ",[41,1161,1162],{},"(1.0 - lexical_coverage)"," ensures ",[20,1165,1166],{},"only unsubstantiated hub vectors get attenuated",", keeping precision and recall in balance.",[104,1169],{},[107,1171,1173],{"id":1172},"_4-diagnosing-the-viewer-bottleneck-75048ms-photos-and-39535ms-book-plates","4. Diagnosing the Viewer Bottleneck: 7,504.8ms Photos and 3,953.5ms Book Plates",[16,1175,1176],{},"Even a perfectly ranked search grid loses its utility if clicking a thumbnail leaves the user staring at an empty frame for several seconds. Profiling real browser network timings and paint frames on our initial lightbox exposed unacceptable latency spikes:",[197,1178,1179,1192],{},[200,1180,1181,1186,1187,1191],{},[20,1182,1183,1184,208],{},"Field-shot original photo (",[41,1185,47],{}," up to ",[20,1188,1189],{},[41,1190,43],{}," (~7.5 seconds)",[200,1193,1194,1186,1199,1203],{},[20,1195,1196,1197,208],{},"High-DPI scanned book plate (",[41,1198,57],{},[20,1200,1201],{},[41,1202,54],{}," (~3.95 seconds)",[16,1205,1206],{},"Breaking down the waterfall revealed three inefficiencies stacked serially:",[671,1208,1209,1224,1234],{},[200,1210,1211,1214,1215,1217,1218,1220,1221,1223],{},[20,1212,1213],{},"Streaming raw archival originals:"," A desktop lightbox viewport rarely needs more than ",[41,1216,77],{}," on the long edge, yet the viewer fetched untouched 4,000–6,000px files every time—paying ",[41,1219,47],{},"–",[41,1222,57],{}," in wire transfer plus heavy main-thread bitmap decode stalls.",[200,1225,1226,1229,1230,1233],{},[20,1227,1228],{},"Cold upstream fetches with no local derivative cache:"," Because the app server did not persist resized derivatives on local disk, even recently viewed assets suffered full round-trip latency to remote origin storage (",[41,1231,1232],{},"media-lab.example.com",").",[200,1235,1236,1239],{},[20,1237,1238],{},"Late, click-time fetching with blank placeholders:"," Image requests started only after the click event fired. Worse, the lightbox discarded the already-decoded grid thumbnail sitting in browser memory, replacing it with a blank backdrop and spinner until the multi-megabyte original arrived.",[1049,1241,1242,1262],{},[1052,1243,1244],{},[1055,1245,1246,1249,1254,1259],{},[1058,1247,1248],{"align":1060},"Lightbox Architecture Stage",[1058,1250,1251,1253],{"align":1060},[41,1252,47],{}," Original Photo Baseline",[1058,1255,1256,1258],{"align":1060},[41,1257,57],{}," Scanned Book Plate Baseline",[1058,1260,1261],{"align":1060},"Perceived User Experience",[1069,1263,1264,1288,1309],{},[1055,1265,1266,1271,1279,1285],{},[1074,1267,1268],{"align":1060},[20,1269,1270],{},"Initial Raw Origin Streaming",[1074,1272,1273,1274,1278],{"align":1060},"Up to ",[20,1275,1276],{},[41,1277,43],{}," stall",[1074,1280,1273,1281,1278],{"align":1060},[20,1282,1283],{},[41,1284,54],{},[1074,1286,1287],{"align":1060},"Multi-second blank frame and spinner; rapid arrow-key browsing unusable",[1055,1289,1290,1297,1300,1306],{},[1074,1291,1292],{"align":1060},[20,1293,1294,1296],{},[41,1295,77],{}," WebP Persistent Disk Cache",[1074,1298,1299],{"align":1060},"Compact WebP + instant local NVMe hit",[1074,1301,1302,1303,1305],{"align":1060},"High-DPI scans unified to ",[41,1304,77],{}," WebP",[1074,1307,1308],{"align":1060},"Dramatic reduction in TTFB and payload size; instant repeat views",[1055,1310,1311,1325,1333,1339],{},[1074,1312,1313],{"align":1060},[20,1314,1315,1316,1318,1319,1321,1322,1324],{},"+ ",[41,1317,93],{}," Hover · ",[41,1320,97],{}," Preload · ",[41,1323,101],{}," Swap",[1074,1326,1327],{"align":1060},[20,1328,1329,1330,1332],{},"Instant thumbnail paint (",[41,1331,101],{},") → seamless swap",[1074,1334,1335],{"align":1060},[20,1336,1329,1337,1332],{},[41,1338,101],{},[1074,1340,1341],{"align":1060},"Zero spinners, zero flash, zero layout shift on click or next/prev navigation",[104,1343],{},[107,1345,1347,1348,82,1350,1352],{"id":1346},"_5-1600px-webp-disk-cache-origin-defense-404422-and-0ms-progressive-swap","5. 1600px WebP Disk Cache, Origin Defense (",[41,1349,81],{},[41,1351,85],{},"), and 0ms Progressive Swap",[16,1354,1355,1356,1359,1360,59],{},"Eliminating the multi-second stall required coordinating a ",[20,1357,1358],{},"server-side caching media proxy"," with a ",[20,1361,1362],{},"predictive client-side prefetch and progressive swap engine",[119,1364,1366,1367,1369,1370,82,1372,86,1374,710],{"id":1365},"_51-atomic-1600px-webp-persistent-disk-cache-and-negative-cache-protection-404422-no-store","5.1. Atomic ",[41,1368,77],{}," WebP Persistent Disk Cache and Negative-Cache Protection (",[41,1371,81],{},[41,1373,85],{},[41,1375,89],{},[16,1377,1378,1379,1382,1383,1386,1387,59],{},"When the media proxy route (",[41,1380,1381],{},"/api/media/[assetId]",") receives a request, it first checks the local NVMe derivative directory (",[41,1384,1385],{},"/srv/app/image-search/cache/webp1600/{assetId}.webp","). Only on a cache miss does it fetch the raw file from origin storage, apply automatic EXIF orientation normalization, and transcode it into a ",[20,1388,1389,1391,1392,710],{},[41,1390,77],{}," max-dimension WebP (",[41,1393,1394],{},"quality: 84",[16,1396,1397],{},"Two defensive invariants keep the cache reliable under concurrent load:",[197,1399,1400,1417],{},[200,1401,1402,1405,1406,1408,1409,1412,1413,1416],{},[20,1403,1404],{},"Atomic Rename Writes:"," Because hover prefetch and ",[41,1407,97],{}," preloading can trigger concurrent requests for the same asset, freshly transcoded buffers are written to a unique ",[41,1410,1411],{},".tmp-{assetId}-{uuid}.webp"," file first and promoted via atomic POSIX ",[41,1414,1415],{},"rename",", ensuring readers never observe a half-written image.",[200,1418,1419,1430,1431,1433,1434,1436,1437,1440,1441,1444],{},[20,1420,1421,1422,1424,1425,86,1427,208],{},"Strict Origin Error Isolation (",[41,1423,81],{}," / ",[41,1426,85],{},[41,1428,1429],{},"Cache-Control: no-store"," If an asset is missing upstream (",[41,1432,81],{},") or fails image decoding due to a corrupted payload (",[41,1435,85],{},"), the proxy ",[20,1438,1439],{},"never writes a zero-byte or fallback artifact to disk"," and always responds with ",[41,1442,1443],{},"Cache-Control: no-store, no-cache, must-revalidate",". This eliminates negative cache poisoning across both local disk and intermediate CDNs/browsers.",[242,1446,1450],{"className":1447,"code":1448,"language":1449,"meta":247,"style":247},"language-ts shiki shiki-themes github-light github-dark","// /srv/app/image-search/server/api/media/[assetId].get.ts (1600px WebP disk cache & origin defense)\nimport { promises as fs } from 'node:fs'\nimport path from 'node:path'\nimport crypto from 'node:crypto'\nimport sharp from 'sharp'\n\nconst CACHE_DIR = '/srv/app/image-search/cache/webp1600'\nconst ORIGIN_ENDPOINT = 'https://media-lab.example.com/origin' // RFC 2606 example domain\n\nexport default defineEventHandler(async (event) => {\n  const assetId = getRouterParam(event, 'assetId') || ''\n  if (!/^[a-zA-Z0-9_-]{8,64}$/.test(assetId)) {\n    setResponseHeader(event, 'Cache-Control', 'no-store')\n    throw createError({ statusCode: 400, statusMessage: 'Invalid asset identifier' })\n  }\n\n  const cachePath = path.join(CACHE_DIR, `${assetId}.webp`)\n\n  // 1. Serve immediately on persistent 1600px WebP disk cache hit\n  try {\n    const cached = await fs.readFile(cachePath)\n    setResponseHeader(event, 'Content-Type', 'image/webp')\n    setResponseHeader(event, 'Cache-Control', 'public, max-age=31536000, immutable')\n    return cached\n  } catch {\n    // Cache Miss: fall through to origin fetch and transcode\n  }\n\n  // 2. Fetch origin asset and isolate 404/502/422 with strict no-store (never write to disk cache)\n  const originRes = await fetch(`${ORIGIN_ENDPOINT}/${assetId}`, {\n    headers: { 'X-Api-Key': process.env.MEDIA_ORIGIN_KEY || 'YOUR_API_KEY' },\n  }).catch(() => null)\n\n  if (!originRes || originRes.status === 404) {\n    setResponseHeader(event, 'Cache-Control', 'no-store, no-cache, must-revalidate')\n    throw createError({ statusCode: 404, statusMessage: 'Origin asset not found' })\n  }\n  if (!originRes.ok) {\n    setResponseHeader(event, 'Cache-Control', 'no-store, no-cache, must-revalidate')\n    throw createError({ statusCode: 502, statusMessage: 'Origin upstream error' })\n  }\n\n  const rawBuffer = Buffer.from(await originRes.arrayBuffer())\n  let webpBuffer: Buffer\n  try {\n    webpBuffer = await sharp(rawBuffer)\n      .rotate() // Normalize EXIF Orientation tag before resizing\n      .resize({ width: 1600, height: 1600, fit: 'inside', withoutEnlargement: true })\n      .webp({ quality: 84, effort: 4 })\n      .toBuffer()\n  } catch {\n    // Isolate corrupted or unreadable payloads with 422 + no-store\n    setResponseHeader(event, 'Cache-Control', 'no-store, no-cache, must-revalidate')\n    throw createError({ statusCode: 422, statusMessage: 'Unprocessable media payload' })\n  }\n\n  // 3. Persist via temporary file + atomic rename\n  await fs.mkdir(CACHE_DIR, { recursive: true })\n  const tmpPath = path.join(CACHE_DIR, `.tmp-${assetId}-${crypto.randomUUID()}.webp`)\n  await fs.writeFile(tmpPath, webpBuffer)\n  await fs.rename(tmpPath, cachePath)\n\n  setResponseHeader(event, 'Content-Type', 'image/webp')\n  setResponseHeader(event, 'Cache-Control', 'public, max-age=31536000, immutable')\n  return webpBuffer\n})\n","ts",[41,1451,1452,1458,1481,1493,1505,1517,1521,1536,1551,1555,1588,1615,1646,1664,1687,1692,1696,1729,1733,1738,1745,1767,1783,1798,1806,1816,1821,1825,1829,1834,1866,1889,1906,1910,1935,1950,1967,1971,1982,1996,2014,2018,2022,2050,2064,2070,2086,2100,2132,2153,2163,2171,2176,2190,2207,2211,2215,2220,2241,2283,2295,2306,2310,2325,2339,2348],{"__ignoreMap":247},[251,1453,1454],{"class":253,"line":254},[251,1455,1457],{"class":1456},"sJ8bj","// /srv/app/image-search/server/api/media/[assetId].get.ts (1600px WebP disk cache & origin defense)\n",[251,1459,1460,1464,1468,1471,1474,1477],{"class":253,"line":260},[251,1461,1463],{"class":1462},"szBVR","import",[251,1465,1467],{"class":1466},"sVt8B"," { promises ",[251,1469,1470],{"class":1462},"as",[251,1472,1473],{"class":1466}," fs } ",[251,1475,1476],{"class":1462},"from",[251,1478,1480],{"class":1479},"sZZnC"," 'node:fs'\n",[251,1482,1483,1485,1488,1490],{"class":253,"line":266},[251,1484,1463],{"class":1462},[251,1486,1487],{"class":1466}," path ",[251,1489,1476],{"class":1462},[251,1491,1492],{"class":1479}," 'node:path'\n",[251,1494,1495,1497,1500,1502],{"class":253,"line":272},[251,1496,1463],{"class":1462},[251,1498,1499],{"class":1466}," crypto ",[251,1501,1476],{"class":1462},[251,1503,1504],{"class":1479}," 'node:crypto'\n",[251,1506,1507,1509,1512,1514],{"class":253,"line":278},[251,1508,1463],{"class":1462},[251,1510,1511],{"class":1466}," sharp ",[251,1513,1476],{"class":1462},[251,1515,1516],{"class":1479}," 'sharp'\n",[251,1518,1519],{"class":253,"line":284},[251,1520,287],{"emptyLinePlaceholder":6},[251,1522,1523,1526,1530,1533],{"class":253,"line":290},[251,1524,1525],{"class":1462},"const",[251,1527,1529],{"class":1528},"sj4cs"," CACHE_DIR",[251,1531,1532],{"class":1462}," =",[251,1534,1535],{"class":1479}," '/srv/app/image-search/cache/webp1600'\n",[251,1537,1538,1540,1543,1545,1548],{"class":253,"line":296},[251,1539,1525],{"class":1462},[251,1541,1542],{"class":1528}," ORIGIN_ENDPOINT",[251,1544,1532],{"class":1462},[251,1546,1547],{"class":1479}," 'https://media-lab.example.com/origin'",[251,1549,1550],{"class":1456}," // RFC 2606 example domain\n",[251,1552,1553],{"class":253,"line":302},[251,1554,287],{"emptyLinePlaceholder":6},[251,1556,1557,1560,1563,1567,1570,1573,1575,1579,1582,1585],{"class":253,"line":307},[251,1558,1559],{"class":1462},"export",[251,1561,1562],{"class":1462}," default",[251,1564,1566],{"class":1565},"sScJk"," defineEventHandler",[251,1568,1569],{"class":1466},"(",[251,1571,1572],{"class":1462},"async",[251,1574,1079],{"class":1466},[251,1576,1578],{"class":1577},"s4XuR","event",[251,1580,1581],{"class":1466},") ",[251,1583,1584],{"class":1462},"=>",[251,1586,1587],{"class":1466}," {\n",[251,1589,1590,1593,1596,1598,1601,1604,1607,1609,1612],{"class":253,"line":312},[251,1591,1592],{"class":1462},"  const",[251,1594,1595],{"class":1528}," assetId",[251,1597,1532],{"class":1462},[251,1599,1600],{"class":1565}," getRouterParam",[251,1602,1603],{"class":1466},"(event, ",[251,1605,1606],{"class":1479},"'assetId'",[251,1608,1581],{"class":1466},[251,1610,1611],{"class":1462},"||",[251,1613,1614],{"class":1479}," ''\n",[251,1616,1617,1620,1622,1625,1627,1630,1633,1636,1638,1640,1643],{"class":253,"line":318},[251,1618,1619],{"class":1462},"  if",[251,1621,1079],{"class":1466},[251,1623,1624],{"class":1462},"!",[251,1626,82],{"class":1479},[251,1628,1629],{"class":1462},"^",[251,1631,1632],{"class":1528},"[a-zA-Z0-9_-]",[251,1634,1635],{"class":1462},"{8,64}$",[251,1637,82],{"class":1479},[251,1639,59],{"class":1466},[251,1641,1642],{"class":1565},"test",[251,1644,1645],{"class":1466},"(assetId)) {\n",[251,1647,1648,1651,1653,1656,1658,1661],{"class":253,"line":324},[251,1649,1650],{"class":1565},"    setResponseHeader",[251,1652,1603],{"class":1466},[251,1654,1655],{"class":1479},"'Cache-Control'",[251,1657,129],{"class":1466},[251,1659,1660],{"class":1479},"'no-store'",[251,1662,1663],{"class":1466},")\n",[251,1665,1666,1669,1672,1675,1678,1681,1684],{"class":253,"line":330},[251,1667,1668],{"class":1462},"    throw",[251,1670,1671],{"class":1565}," createError",[251,1673,1674],{"class":1466},"({ statusCode: ",[251,1676,1677],{"class":1528},"400",[251,1679,1680],{"class":1466},", statusMessage: ",[251,1682,1683],{"class":1479},"'Invalid asset identifier'",[251,1685,1686],{"class":1466}," })\n",[251,1688,1689],{"class":253,"line":336},[251,1690,1691],{"class":1466},"  }\n",[251,1693,1694],{"class":253,"line":342},[251,1695,287],{"emptyLinePlaceholder":6},[251,1697,1698,1700,1703,1705,1708,1711,1713,1716,1718,1721,1724,1727],{"class":253,"line":348},[251,1699,1592],{"class":1462},[251,1701,1702],{"class":1528}," cachePath",[251,1704,1532],{"class":1462},[251,1706,1707],{"class":1466}," path.",[251,1709,1710],{"class":1565},"join",[251,1712,1569],{"class":1466},[251,1714,1715],{"class":1528},"CACHE_DIR",[251,1717,129],{"class":1466},[251,1719,1720],{"class":1479},"`${",[251,1722,1723],{"class":1466},"assetId",[251,1725,1726],{"class":1479},"}.webp`",[251,1728,1663],{"class":1466},[251,1730,1731],{"class":253,"line":354},[251,1732,287],{"emptyLinePlaceholder":6},[251,1734,1735],{"class":253,"line":359},[251,1736,1737],{"class":1456},"  // 1. Serve immediately on persistent 1600px WebP disk cache hit\n",[251,1739,1740,1743],{"class":253,"line":364},[251,1741,1742],{"class":1462},"  try",[251,1744,1587],{"class":1466},[251,1746,1747,1750,1753,1755,1758,1761,1764],{"class":253,"line":370},[251,1748,1749],{"class":1462},"    const",[251,1751,1752],{"class":1528}," cached",[251,1754,1532],{"class":1462},[251,1756,1757],{"class":1462}," await",[251,1759,1760],{"class":1466}," fs.",[251,1762,1763],{"class":1565},"readFile",[251,1765,1766],{"class":1466},"(cachePath)\n",[251,1768,1769,1771,1773,1776,1778,1781],{"class":253,"line":376},[251,1770,1650],{"class":1565},[251,1772,1603],{"class":1466},[251,1774,1775],{"class":1479},"'Content-Type'",[251,1777,129],{"class":1466},[251,1779,1780],{"class":1479},"'image/webp'",[251,1782,1663],{"class":1466},[251,1784,1785,1787,1789,1791,1793,1796],{"class":253,"line":382},[251,1786,1650],{"class":1565},[251,1788,1603],{"class":1466},[251,1790,1655],{"class":1479},[251,1792,129],{"class":1466},[251,1794,1795],{"class":1479},"'public, max-age=31536000, immutable'",[251,1797,1663],{"class":1466},[251,1799,1800,1803],{"class":253,"line":388},[251,1801,1802],{"class":1462},"    return",[251,1804,1805],{"class":1466}," cached\n",[251,1807,1808,1811,1814],{"class":253,"line":394},[251,1809,1810],{"class":1466},"  } ",[251,1812,1813],{"class":1462},"catch",[251,1815,1587],{"class":1466},[251,1817,1818],{"class":253,"line":400},[251,1819,1820],{"class":1456},"    // Cache Miss: fall through to origin fetch and transcode\n",[251,1822,1823],{"class":253,"line":406},[251,1824,1691],{"class":1466},[251,1826,1827],{"class":253,"line":412},[251,1828,287],{"emptyLinePlaceholder":6},[251,1830,1831],{"class":253,"line":418},[251,1832,1833],{"class":1456},"  // 2. Fetch origin asset and isolate 404/502/422 with strict no-store (never write to disk cache)\n",[251,1835,1836,1838,1841,1843,1845,1848,1850,1852,1855,1858,1860,1863],{"class":253,"line":424},[251,1837,1592],{"class":1462},[251,1839,1840],{"class":1528}," originRes",[251,1842,1532],{"class":1462},[251,1844,1757],{"class":1462},[251,1846,1847],{"class":1565}," fetch",[251,1849,1569],{"class":1466},[251,1851,1720],{"class":1479},[251,1853,1854],{"class":1528},"ORIGIN_ENDPOINT",[251,1856,1857],{"class":1479},"}/${",[251,1859,1723],{"class":1466},[251,1861,1862],{"class":1479},"}`",[251,1864,1865],{"class":1466},", {\n",[251,1867,1868,1871,1874,1877,1880,1883,1886],{"class":253,"line":430},[251,1869,1870],{"class":1466},"    headers: { ",[251,1872,1873],{"class":1479},"'X-Api-Key'",[251,1875,1876],{"class":1466},": process.env.",[251,1878,1879],{"class":1528},"MEDIA_ORIGIN_KEY",[251,1881,1882],{"class":1462}," ||",[251,1884,1885],{"class":1479}," 'YOUR_API_KEY'",[251,1887,1888],{"class":1466}," },\n",[251,1890,1891,1894,1896,1899,1901,1904],{"class":253,"line":436},[251,1892,1893],{"class":1466},"  }).",[251,1895,1813],{"class":1565},[251,1897,1898],{"class":1466},"(() ",[251,1900,1584],{"class":1462},[251,1902,1903],{"class":1528}," null",[251,1905,1663],{"class":1466},[251,1907,1908],{"class":253,"line":442},[251,1909,287],{"emptyLinePlaceholder":6},[251,1911,1912,1914,1916,1918,1921,1923,1926,1929,1932],{"class":253,"line":447},[251,1913,1619],{"class":1462},[251,1915,1079],{"class":1466},[251,1917,1624],{"class":1462},[251,1919,1920],{"class":1466},"originRes ",[251,1922,1611],{"class":1462},[251,1924,1925],{"class":1466}," originRes.status ",[251,1927,1928],{"class":1462},"===",[251,1930,1931],{"class":1528}," 404",[251,1933,1934],{"class":1466},") {\n",[251,1936,1937,1939,1941,1943,1945,1948],{"class":253,"line":453},[251,1938,1650],{"class":1565},[251,1940,1603],{"class":1466},[251,1942,1655],{"class":1479},[251,1944,129],{"class":1466},[251,1946,1947],{"class":1479},"'no-store, no-cache, must-revalidate'",[251,1949,1663],{"class":1466},[251,1951,1952,1954,1956,1958,1960,1962,1965],{"class":253,"line":459},[251,1953,1668],{"class":1462},[251,1955,1671],{"class":1565},[251,1957,1674],{"class":1466},[251,1959,81],{"class":1528},[251,1961,1680],{"class":1466},[251,1963,1964],{"class":1479},"'Origin asset not found'",[251,1966,1686],{"class":1466},[251,1968,1969],{"class":253,"line":464},[251,1970,1691],{"class":1466},[251,1972,1973,1975,1977,1979],{"class":253,"line":469},[251,1974,1619],{"class":1462},[251,1976,1079],{"class":1466},[251,1978,1624],{"class":1462},[251,1980,1981],{"class":1466},"originRes.ok) {\n",[251,1983,1984,1986,1988,1990,1992,1994],{"class":253,"line":475},[251,1985,1650],{"class":1565},[251,1987,1603],{"class":1466},[251,1989,1655],{"class":1479},[251,1991,129],{"class":1466},[251,1993,1947],{"class":1479},[251,1995,1663],{"class":1466},[251,1997,1998,2000,2002,2004,2007,2009,2012],{"class":253,"line":481},[251,1999,1668],{"class":1462},[251,2001,1671],{"class":1565},[251,2003,1674],{"class":1466},[251,2005,2006],{"class":1528},"502",[251,2008,1680],{"class":1466},[251,2010,2011],{"class":1479},"'Origin upstream error'",[251,2013,1686],{"class":1466},[251,2015,2016],{"class":253,"line":486},[251,2017,1691],{"class":1466},[251,2019,2020],{"class":253,"line":491},[251,2021,287],{"emptyLinePlaceholder":6},[251,2023,2024,2026,2029,2031,2034,2036,2038,2041,2044,2047],{"class":253,"line":497},[251,2025,1592],{"class":1462},[251,2027,2028],{"class":1528}," rawBuffer",[251,2030,1532],{"class":1462},[251,2032,2033],{"class":1466}," Buffer.",[251,2035,1476],{"class":1565},[251,2037,1569],{"class":1466},[251,2039,2040],{"class":1462},"await",[251,2042,2043],{"class":1466}," originRes.",[251,2045,2046],{"class":1565},"arrayBuffer",[251,2048,2049],{"class":1466},"())\n",[251,2051,2052,2055,2058,2061],{"class":253,"line":503},[251,2053,2054],{"class":1462},"  let",[251,2056,2057],{"class":1466}," webpBuffer",[251,2059,2060],{"class":1462},":",[251,2062,2063],{"class":1565}," Buffer\n",[251,2065,2066,2068],{"class":253,"line":509},[251,2067,1742],{"class":1462},[251,2069,1587],{"class":1466},[251,2071,2072,2075,2078,2080,2083],{"class":253,"line":515},[251,2073,2074],{"class":1466},"    webpBuffer ",[251,2076,2077],{"class":1462},"=",[251,2079,1757],{"class":1462},[251,2081,2082],{"class":1565}," sharp",[251,2084,2085],{"class":1466},"(rawBuffer)\n",[251,2087,2088,2091,2094,2097],{"class":253,"line":520},[251,2089,2090],{"class":1466},"      .",[251,2092,2093],{"class":1565},"rotate",[251,2095,2096],{"class":1466},"() ",[251,2098,2099],{"class":1456},"// Normalize EXIF Orientation tag before resizing\n",[251,2101,2102,2104,2107,2110,2113,2116,2118,2121,2124,2127,2130],{"class":253,"line":526},[251,2103,2090],{"class":1466},[251,2105,2106],{"class":1565},"resize",[251,2108,2109],{"class":1466},"({ width: ",[251,2111,2112],{"class":1528},"1600",[251,2114,2115],{"class":1466},", height: ",[251,2117,2112],{"class":1528},[251,2119,2120],{"class":1466},", fit: ",[251,2122,2123],{"class":1479},"'inside'",[251,2125,2126],{"class":1466},", withoutEnlargement: ",[251,2128,2129],{"class":1528},"true",[251,2131,1686],{"class":1466},[251,2133,2134,2136,2139,2142,2145,2148,2151],{"class":253,"line":531},[251,2135,2090],{"class":1466},[251,2137,2138],{"class":1565},"webp",[251,2140,2141],{"class":1466},"({ quality: ",[251,2143,2144],{"class":1528},"84",[251,2146,2147],{"class":1466},", effort: ",[251,2149,2150],{"class":1528},"4",[251,2152,1686],{"class":1466},[251,2154,2155,2157,2160],{"class":253,"line":537},[251,2156,2090],{"class":1466},[251,2158,2159],{"class":1565},"toBuffer",[251,2161,2162],{"class":1466},"()\n",[251,2164,2165,2167,2169],{"class":253,"line":543},[251,2166,1810],{"class":1466},[251,2168,1813],{"class":1462},[251,2170,1587],{"class":1466},[251,2172,2173],{"class":253,"line":549},[251,2174,2175],{"class":1456},"    // Isolate corrupted or unreadable payloads with 422 + no-store\n",[251,2177,2178,2180,2182,2184,2186,2188],{"class":253,"line":555},[251,2179,1650],{"class":1565},[251,2181,1603],{"class":1466},[251,2183,1655],{"class":1479},[251,2185,129],{"class":1466},[251,2187,1947],{"class":1479},[251,2189,1663],{"class":1466},[251,2191,2192,2194,2196,2198,2200,2202,2205],{"class":253,"line":561},[251,2193,1668],{"class":1462},[251,2195,1671],{"class":1565},[251,2197,1674],{"class":1466},[251,2199,85],{"class":1528},[251,2201,1680],{"class":1466},[251,2203,2204],{"class":1479},"'Unprocessable media payload'",[251,2206,1686],{"class":1466},[251,2208,2209],{"class":253,"line":567},[251,2210,1691],{"class":1466},[251,2212,2213],{"class":253,"line":573},[251,2214,287],{"emptyLinePlaceholder":6},[251,2216,2217],{"class":253,"line":579},[251,2218,2219],{"class":1456},"  // 3. Persist via temporary file + atomic rename\n",[251,2221,2222,2225,2227,2230,2232,2234,2237,2239],{"class":253,"line":584},[251,2223,2224],{"class":1462},"  await",[251,2226,1760],{"class":1466},[251,2228,2229],{"class":1565},"mkdir",[251,2231,1569],{"class":1466},[251,2233,1715],{"class":1528},[251,2235,2236],{"class":1466},", { recursive: ",[251,2238,2129],{"class":1528},[251,2240,1686],{"class":1466},[251,2242,2243,2245,2248,2250,2252,2254,2256,2258,2260,2263,2265,2268,2271,2273,2276,2279,2281],{"class":253,"line":590},[251,2244,1592],{"class":1462},[251,2246,2247],{"class":1528}," tmpPath",[251,2249,1532],{"class":1462},[251,2251,1707],{"class":1466},[251,2253,1710],{"class":1565},[251,2255,1569],{"class":1466},[251,2257,1715],{"class":1528},[251,2259,129],{"class":1466},[251,2261,2262],{"class":1479},"`.tmp-${",[251,2264,1723],{"class":1466},[251,2266,2267],{"class":1479},"}-${",[251,2269,2270],{"class":1466},"crypto",[251,2272,59],{"class":1479},[251,2274,2275],{"class":1565},"randomUUID",[251,2277,2278],{"class":1479},"()",[251,2280,1726],{"class":1479},[251,2282,1663],{"class":1466},[251,2284,2285,2287,2289,2292],{"class":253,"line":596},[251,2286,2224],{"class":1462},[251,2288,1760],{"class":1466},[251,2290,2291],{"class":1565},"writeFile",[251,2293,2294],{"class":1466},"(tmpPath, webpBuffer)\n",[251,2296,2297,2299,2301,2303],{"class":253,"line":602},[251,2298,2224],{"class":1462},[251,2300,1760],{"class":1466},[251,2302,1415],{"class":1565},[251,2304,2305],{"class":1466},"(tmpPath, cachePath)\n",[251,2307,2308],{"class":253,"line":608},[251,2309,287],{"emptyLinePlaceholder":6},[251,2311,2312,2315,2317,2319,2321,2323],{"class":253,"line":614},[251,2313,2314],{"class":1565},"  setResponseHeader",[251,2316,1603],{"class":1466},[251,2318,1775],{"class":1479},[251,2320,129],{"class":1466},[251,2322,1780],{"class":1479},[251,2324,1663],{"class":1466},[251,2326,2327,2329,2331,2333,2335,2337],{"class":253,"line":620},[251,2328,2314],{"class":1565},[251,2330,1603],{"class":1466},[251,2332,1655],{"class":1479},[251,2334,129],{"class":1466},[251,2336,1795],{"class":1479},[251,2338,1663],{"class":1466},[251,2340,2342,2345],{"class":253,"line":2341},65,[251,2343,2344],{"class":1462},"  return",[251,2346,2347],{"class":1466}," webpBuffer\n",[251,2349,2351],{"class":253,"line":2350},66,[251,2352,2353],{"class":1466},"})\n",[119,2355,2357,2358,2360,2361,2363,2364,2366],{"id":2356},"_52-120ms-hover-debounce-n1-adjacent-preloading-and-0ms-progressive-swap","5.2. ",[41,2359,93],{}," Hover Debounce, ",[41,2362,97],{}," Adjacent Preloading, and ",[41,2365,101],{}," Progressive Swap",[16,2368,2369,2370,2372],{},"Once the server can deliver ",[41,2371,77],{}," WebP derivatives in milliseconds, the final leap to zero perceived latency happens in the browser's interaction timeline. The lightbox controller chains three client-side techniques:",[671,2374,2375,2391,2418],{},[200,2376,2377,2382,2383,2387,2388,2390],{},[20,2378,2379,2381],{},[41,2380,93],{}," Debounced Hover Prefetch:"," Rapid cursor sweeps across the search grid emit zero network requests. Only when the pointer rests on a card for ",[20,2384,2385],{},[41,2386,93],{},"—signaling genuine click intent—does the client warm the ",[41,2389,77],{}," WebP URL in the background.",[200,2392,2393,2403,2404,2407,2408,2411,2412,2414,2415,2417],{},[20,2394,2395,2396,129,2399,2402],{},"Adjacent Slot (",[41,2397,2398],{},"N-1",[41,2400,2401],{},"N+1",") Background Preloading:"," The instant slot ",[41,2405,2406],{},"N"," opens, the controller fetches and calls ",[41,2409,2410],{},"img.decode()"," on both its next (",[41,2413,2401],{},") and previous (",[41,2416,2398],{},") neighbors. Pressing left/right arrow keys or swiping displays an already-decoded GPU texture with zero network wait.",[200,2419,2420,2426,2427,2429,2430,2433,2434,2436,2437,129,2439,2442,2443,2445],{},[20,2421,2422,2423,2425],{},"Thumbnail-to-HiRes ",[41,2424,101],{}," Progressive Swap:"," On frame zero (",[41,2428,101],{},") after click, the lightbox immediately paints the ",[20,2431,2432],{},"already-decoded grid thumbnail"," inside an aspect-ratio-locked frame. Not a single blank frame or spinner ever renders. The moment ",[41,2435,77],{}," WebP finishes ",[41,2438,2410],{},[41,2440,2441],{},"highResReady"," flips ",[41,2444,2129],{}," and promotes the sharp layer cleanly in place.",[242,2447,2449],{"className":1447,"code":2448,"language":1449,"meta":247,"style":247},"// /srv/app/image-search/app/composables/useZeroMsLightbox.ts (Hover & N±1 prefetch + decode cache)\nconst decodedCache = new Map\u003Cstring, Promise\u003Cvoid>>()\nlet hoverTimer: ReturnType\u003Ctypeof setTimeout> | null = null\n\nexport function warmWebp1600(assetId: string): Promise\u003Cvoid> {\n  const url = `/api/media/${encodeURIComponent(assetId)}?w=1600`\n  const existing = decodedCache.get(url)\n  if (existing) return existing\n\n  const task = (async () => {\n    const img = new Image()\n    img.decoding = 'async'\n    img.src = url\n    if (typeof img.decode === 'function') {\n      await img.decode()\n    }\n  })().catch(() => {\n    // Evict failed 404/422 promises immediately so broken state never sticks in-session\n    decodedCache.delete(url)\n  })\n\n  decodedCache.set(url, task)\n  return task\n}\n\nexport function onCardPointerEnter(assetId: string) {\n  if (hoverTimer) clearTimeout(hoverTimer)\n  hoverTimer = setTimeout(() => {\n    void warmWebp1600(assetId)\n  }, 120) // 120ms intent debounce prevents speculative prefetch floods during fast mouse sweeps\n}\n\nexport function onCardPointerLeave() {\n  if (hoverTimer) {\n    clearTimeout(hoverTimer)\n    hoverTimer = null\n  }\n}\n\nexport function preloadAdjacentSlots(orderedIds: readonly string[], activeIndex: number) {\n  const neighbors = [activeIndex + 1, activeIndex - 1]\n  for (const idx of neighbors) {\n    const neighborId = orderedIds[idx]\n    if (neighborId) {\n      void warmWebp1600(neighborId)\n    }\n  }\n}\n",[41,2450,2451,2456,2490,2521,2525,2558,2582,2600,2613,2617,2637,2653,2663,2673,2692,2705,2710,2723,2728,2738,2743,2747,2758,2765,2769,2773,2792,2805,2821,2831,2844,2848,2852,2864,2871,2878,2887,2891,2895,2899,2933,2962,2980,2992,2999,3009,3013,3017],{"__ignoreMap":247},[251,2452,2453],{"class":253,"line":254},[251,2454,2455],{"class":1456},"// /srv/app/image-search/app/composables/useZeroMsLightbox.ts (Hover & N±1 prefetch + decode cache)\n",[251,2457,2458,2460,2463,2465,2468,2471,2474,2477,2479,2482,2484,2487],{"class":253,"line":260},[251,2459,1525],{"class":1462},[251,2461,2462],{"class":1528}," decodedCache",[251,2464,1532],{"class":1462},[251,2466,2467],{"class":1462}," new",[251,2469,2470],{"class":1565}," Map",[251,2472,2473],{"class":1466},"\u003C",[251,2475,2476],{"class":1528},"string",[251,2478,129],{"class":1466},[251,2480,2481],{"class":1565},"Promise",[251,2483,2473],{"class":1466},[251,2485,2486],{"class":1528},"void",[251,2488,2489],{"class":1466},">>()\n",[251,2491,2492,2495,2498,2500,2503,2505,2508,2511,2514,2516,2518],{"class":253,"line":266},[251,2493,2494],{"class":1462},"let",[251,2496,2497],{"class":1466}," hoverTimer",[251,2499,2060],{"class":1462},[251,2501,2502],{"class":1565}," ReturnType",[251,2504,2473],{"class":1466},[251,2506,2507],{"class":1462},"typeof",[251,2509,2510],{"class":1466}," setTimeout> ",[251,2512,2513],{"class":1462},"|",[251,2515,1903],{"class":1528},[251,2517,1532],{"class":1462},[251,2519,2520],{"class":1528}," null\n",[251,2522,2523],{"class":253,"line":272},[251,2524,287],{"emptyLinePlaceholder":6},[251,2526,2527,2529,2532,2535,2537,2539,2541,2544,2546,2548,2551,2553,2555],{"class":253,"line":278},[251,2528,1559],{"class":1462},[251,2530,2531],{"class":1462}," function",[251,2533,2534],{"class":1565}," warmWebp1600",[251,2536,1569],{"class":1466},[251,2538,1723],{"class":1577},[251,2540,2060],{"class":1462},[251,2542,2543],{"class":1528}," string",[251,2545,710],{"class":1466},[251,2547,2060],{"class":1462},[251,2549,2550],{"class":1565}," Promise",[251,2552,2473],{"class":1466},[251,2554,2486],{"class":1528},[251,2556,2557],{"class":1466},"> {\n",[251,2559,2560,2562,2565,2567,2570,2573,2575,2577,2579],{"class":253,"line":284},[251,2561,1592],{"class":1462},[251,2563,2564],{"class":1528}," url",[251,2566,1532],{"class":1462},[251,2568,2569],{"class":1479}," `/api/media/${",[251,2571,2572],{"class":1565},"encodeURIComponent",[251,2574,1569],{"class":1479},[251,2576,1723],{"class":1466},[251,2578,710],{"class":1479},[251,2580,2581],{"class":1479},"}?w=1600`\n",[251,2583,2584,2586,2589,2591,2594,2597],{"class":253,"line":290},[251,2585,1592],{"class":1462},[251,2587,2588],{"class":1528}," existing",[251,2590,1532],{"class":1462},[251,2592,2593],{"class":1466}," decodedCache.",[251,2595,2596],{"class":1565},"get",[251,2598,2599],{"class":1466},"(url)\n",[251,2601,2602,2604,2607,2610],{"class":253,"line":296},[251,2603,1619],{"class":1462},[251,2605,2606],{"class":1466}," (existing) ",[251,2608,2609],{"class":1462},"return",[251,2611,2612],{"class":1466}," existing\n",[251,2614,2615],{"class":253,"line":302},[251,2616,287],{"emptyLinePlaceholder":6},[251,2618,2619,2621,2624,2626,2628,2630,2633,2635],{"class":253,"line":307},[251,2620,1592],{"class":1462},[251,2622,2623],{"class":1528}," task",[251,2625,1532],{"class":1462},[251,2627,1079],{"class":1466},[251,2629,1572],{"class":1462},[251,2631,2632],{"class":1466}," () ",[251,2634,1584],{"class":1462},[251,2636,1587],{"class":1466},[251,2638,2639,2641,2644,2646,2648,2651],{"class":253,"line":312},[251,2640,1749],{"class":1462},[251,2642,2643],{"class":1528}," img",[251,2645,1532],{"class":1462},[251,2647,2467],{"class":1462},[251,2649,2650],{"class":1565}," Image",[251,2652,2162],{"class":1466},[251,2654,2655,2658,2660],{"class":253,"line":318},[251,2656,2657],{"class":1466},"    img.decoding ",[251,2659,2077],{"class":1462},[251,2661,2662],{"class":1479}," 'async'\n",[251,2664,2665,2668,2670],{"class":253,"line":324},[251,2666,2667],{"class":1466},"    img.src ",[251,2669,2077],{"class":1462},[251,2671,2672],{"class":1466}," url\n",[251,2674,2675,2678,2680,2682,2685,2687,2690],{"class":253,"line":330},[251,2676,2677],{"class":1462},"    if",[251,2679,1079],{"class":1466},[251,2681,2507],{"class":1462},[251,2683,2684],{"class":1466}," img.decode ",[251,2686,1928],{"class":1462},[251,2688,2689],{"class":1479}," 'function'",[251,2691,1934],{"class":1466},[251,2693,2694,2697,2700,2703],{"class":253,"line":336},[251,2695,2696],{"class":1462},"      await",[251,2698,2699],{"class":1466}," img.",[251,2701,2702],{"class":1565},"decode",[251,2704,2162],{"class":1466},[251,2706,2707],{"class":253,"line":342},[251,2708,2709],{"class":1466},"    }\n",[251,2711,2712,2715,2717,2719,2721],{"class":253,"line":348},[251,2713,2714],{"class":1466},"  })().",[251,2716,1813],{"class":1565},[251,2718,1898],{"class":1466},[251,2720,1584],{"class":1462},[251,2722,1587],{"class":1466},[251,2724,2725],{"class":253,"line":354},[251,2726,2727],{"class":1456},"    // Evict failed 404/422 promises immediately so broken state never sticks in-session\n",[251,2729,2730,2733,2736],{"class":253,"line":359},[251,2731,2732],{"class":1466},"    decodedCache.",[251,2734,2735],{"class":1565},"delete",[251,2737,2599],{"class":1466},[251,2739,2740],{"class":253,"line":364},[251,2741,2742],{"class":1466},"  })\n",[251,2744,2745],{"class":253,"line":370},[251,2746,287],{"emptyLinePlaceholder":6},[251,2748,2749,2752,2755],{"class":253,"line":376},[251,2750,2751],{"class":1466},"  decodedCache.",[251,2753,2754],{"class":1565},"set",[251,2756,2757],{"class":1466},"(url, task)\n",[251,2759,2760,2762],{"class":253,"line":382},[251,2761,2344],{"class":1462},[251,2763,2764],{"class":1466}," task\n",[251,2766,2767],{"class":253,"line":388},[251,2768,809],{"class":1466},[251,2770,2771],{"class":253,"line":394},[251,2772,287],{"emptyLinePlaceholder":6},[251,2774,2775,2777,2779,2782,2784,2786,2788,2790],{"class":253,"line":400},[251,2776,1559],{"class":1462},[251,2778,2531],{"class":1462},[251,2780,2781],{"class":1565}," onCardPointerEnter",[251,2783,1569],{"class":1466},[251,2785,1723],{"class":1577},[251,2787,2060],{"class":1462},[251,2789,2543],{"class":1528},[251,2791,1934],{"class":1466},[251,2793,2794,2796,2799,2802],{"class":253,"line":406},[251,2795,1619],{"class":1462},[251,2797,2798],{"class":1466}," (hoverTimer) ",[251,2800,2801],{"class":1565},"clearTimeout",[251,2803,2804],{"class":1466},"(hoverTimer)\n",[251,2806,2807,2810,2812,2815,2817,2819],{"class":253,"line":412},[251,2808,2809],{"class":1466},"  hoverTimer ",[251,2811,2077],{"class":1462},[251,2813,2814],{"class":1565}," setTimeout",[251,2816,1898],{"class":1466},[251,2818,1584],{"class":1462},[251,2820,1587],{"class":1466},[251,2822,2823,2826,2828],{"class":253,"line":418},[251,2824,2825],{"class":1462},"    void",[251,2827,2534],{"class":1565},[251,2829,2830],{"class":1466},"(assetId)\n",[251,2832,2833,2836,2839,2841],{"class":253,"line":424},[251,2834,2835],{"class":1466},"  }, ",[251,2837,2838],{"class":1528},"120",[251,2840,1581],{"class":1466},[251,2842,2843],{"class":1456},"// 120ms intent debounce prevents speculative prefetch floods during fast mouse sweeps\n",[251,2845,2846],{"class":253,"line":430},[251,2847,809],{"class":1466},[251,2849,2850],{"class":253,"line":436},[251,2851,287],{"emptyLinePlaceholder":6},[251,2853,2854,2856,2858,2861],{"class":253,"line":442},[251,2855,1559],{"class":1462},[251,2857,2531],{"class":1462},[251,2859,2860],{"class":1565}," onCardPointerLeave",[251,2862,2863],{"class":1466},"() {\n",[251,2865,2866,2868],{"class":253,"line":447},[251,2867,1619],{"class":1462},[251,2869,2870],{"class":1466}," (hoverTimer) {\n",[251,2872,2873,2876],{"class":253,"line":453},[251,2874,2875],{"class":1565},"    clearTimeout",[251,2877,2804],{"class":1466},[251,2879,2880,2883,2885],{"class":253,"line":459},[251,2881,2882],{"class":1466},"    hoverTimer ",[251,2884,2077],{"class":1462},[251,2886,2520],{"class":1528},[251,2888,2889],{"class":253,"line":464},[251,2890,1691],{"class":1466},[251,2892,2893],{"class":253,"line":469},[251,2894,809],{"class":1466},[251,2896,2897],{"class":253,"line":475},[251,2898,287],{"emptyLinePlaceholder":6},[251,2900,2901,2903,2905,2908,2910,2913,2915,2918,2920,2923,2926,2928,2931],{"class":253,"line":481},[251,2902,1559],{"class":1462},[251,2904,2531],{"class":1462},[251,2906,2907],{"class":1565}," preloadAdjacentSlots",[251,2909,1569],{"class":1466},[251,2911,2912],{"class":1577},"orderedIds",[251,2914,2060],{"class":1462},[251,2916,2917],{"class":1462}," readonly",[251,2919,2543],{"class":1528},[251,2921,2922],{"class":1466},"[], ",[251,2924,2925],{"class":1577},"activeIndex",[251,2927,2060],{"class":1462},[251,2929,2930],{"class":1528}," number",[251,2932,1934],{"class":1466},[251,2934,2935,2937,2940,2942,2945,2948,2951,2954,2957,2959],{"class":253,"line":486},[251,2936,1592],{"class":1462},[251,2938,2939],{"class":1528}," neighbors",[251,2941,1532],{"class":1462},[251,2943,2944],{"class":1466}," [activeIndex ",[251,2946,2947],{"class":1462},"+",[251,2949,2950],{"class":1528}," 1",[251,2952,2953],{"class":1466},", activeIndex ",[251,2955,2956],{"class":1462},"-",[251,2958,2950],{"class":1528},[251,2960,2961],{"class":1466},"]\n",[251,2963,2964,2967,2969,2971,2974,2977],{"class":253,"line":491},[251,2965,2966],{"class":1462},"  for",[251,2968,1079],{"class":1466},[251,2970,1525],{"class":1462},[251,2972,2973],{"class":1528}," idx",[251,2975,2976],{"class":1462}," of",[251,2978,2979],{"class":1466}," neighbors) {\n",[251,2981,2982,2984,2987,2989],{"class":253,"line":497},[251,2983,1749],{"class":1462},[251,2985,2986],{"class":1528}," neighborId",[251,2988,1532],{"class":1462},[251,2990,2991],{"class":1466}," orderedIds[idx]\n",[251,2993,2994,2996],{"class":253,"line":503},[251,2995,2677],{"class":1462},[251,2997,2998],{"class":1466}," (neighborId) {\n",[251,3000,3001,3004,3006],{"class":253,"line":509},[251,3002,3003],{"class":1462},"      void",[251,3005,2534],{"class":1565},[251,3007,3008],{"class":1466},"(neighborId)\n",[251,3010,3011],{"class":253,"line":515},[251,3012,2709],{"class":1466},[251,3014,3015],{"class":253,"line":520},[251,3016,1691],{"class":1466},[251,3018,3019],{"class":253,"line":526},[251,3020,809],{"class":1466},[631,3022,3023],{},[16,3024,3025,3027,3028,3031,3032,3035,3036,3039,3040,3042,3043,82,3045,3047],{},[20,3026,637],{},"\nEvicting rejected promises via ",[41,3029,3030],{},"decodedCache.delete(url)"," inside ",[41,3033,3034],{},"warmWebp1600()","'s ",[41,3037,3038],{},".catch()"," handler mirrors the server's ",[41,3041,89],{}," defense. Even if a transient ",[41,3044,81],{},[41,3046,85],{}," occurs during hover prefetch, the browser session never gets wedged on a stale failure promise.",[104,3049],{},[107,3051,3053],{"id":3052},"wrapping-up-connecting-34050-visual-records-at-0ms-interactive-speed","Wrapping Up: Connecting 34,050 Visual Records at 0ms Interactive Speed",[16,3055,3056],{},"Re-engineering this hybrid search and lightbox pipeline distilled into four durable systems principles:",[671,3058,3059,3065,3077,3102],{},[200,3060,3061,3064],{},[20,3062,3063],{},"Keep the vector corpus immutable and isolate metadata edits in Copy-on-Write:"," Separating the 34,050-asset read-only vector snapshot from a revisioned SQLite EXIF overlay lets curators normalize gear strings and backfill book-plate metadata with zero query locks and instant rollback.",[200,3066,3067,3070,3071,3073,3074,3076],{},[20,3068,3069],{},"Pair dense semantics with field-weighted lexical retrieval and gated hubness decay:"," As validated on our 17-query benchmark suite, top-slot precision stabilizes only when plate numbers (",[41,3072,1110],{},") and normalized EXIF (",[41,3075,1092],{},") reinforce dense recall while unsubstantiated hub vectors are selectively damped.",[200,3078,3079,3088,3089,3091,3092,3094,3095,82,3097,86,3099,3101],{},[20,3080,3081,3082,3084,3085,3087],{},"Fix viewer latency at the proxy boundary with ",[41,3083,77],{}," WebP caching and ",[41,3086,89],{}," error isolation:"," Eliminating ",[41,3090,43],{}," original photo stalls and ",[41,3093,54],{}," book-plate stalls starts with atomic local WebP derivatives, paired with strict ",[41,3096,81],{},[41,3098,85],{},[41,3100,89],{}," boundaries to prevent negative cache poisoning.",[200,3103,3104,3110,3111,3113,3114,3116,3117,3119,3120,3122],{},[20,3105,3106,3107,3109],{},"Engineer perceived ",[41,3108,101],{}," by overlapping human intent with async decoding:"," Combining a ",[41,3112,93],{}," hover intent window, instant ",[41,3115,101],{}," thumbnail fallback rendering, ",[41,3118,2410],{}," promotion, and ",[41,3121,97],{}," neighbor preloading removes every spinner and frame gap from visual exploration.",[16,3124,3125,3126,59],{},"You can explore the full project specifications and architectural summary on the ",[64,3127,3128],{"href":66},"Hybrid Photo & Book Plate Search Engine & 0ms Lightbox project page",[3130,3131,3132],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}",{"title":247,"searchDepth":260,"depth":260,"links":3134},[3135,3139,3140,3144,3145,3152],{"id":109,"depth":260,"text":110,"children":3136},[3137,3138],{"id":121,"depth":266,"text":122},{"id":159,"depth":266,"text":160},{"id":175,"depth":260,"text":176},{"id":647,"depth":260,"text":648,"children":3141},[3142,3143],{"id":668,"depth":266,"text":669},{"id":1039,"depth":266,"text":1040},{"id":1172,"depth":260,"text":1173},{"id":1346,"depth":260,"text":3146,"children":3147},"5. 1600px WebP Disk Cache, Origin Defense (404/422), and 0ms Progressive Swap",[3148,3150],{"id":1365,"depth":266,"text":3149},"5.1. Atomic 1600px WebP Persistent Disk Cache and Negative-Cache Protection (404/422 + no-store)",{"id":2356,"depth":266,"text":3151},"5.2. 120ms Hover Debounce, N±1 Adjacent Preloading, and 0ms Progressive Swap",{"id":3052,"depth":260,"text":3053},"34,050-Asset Dual-Path Reranking · 1600px WebP Cache · 0ms Lightbox","tech","/images/content-images/blog/20261129-Hybrid-Photo-Search-Zero-Ms-Lightbox/20261129-Hybrid-Photo-Search-Zero-Ms-Lightbox001.jpg","Swiss editorial technical journal cover on an off-white canvas illustrating a 34,050-asset immutable corpus, Copy-on-Write EXIF overlay, Dual-Path reranking, 1600px WebP disk cache, and 0ms progressive swap pipeline","2026-11-29","Eliminating vector hubness across 34,050 photos and book plates via Dual-Path reranking and CoW EXIF, and cutting a 7,504.8ms image viewer down to 0ms.","md",null,{},false,"/en/blog/20261129-hybrid-photo-search-zero-ms-lightbox","hybrid-photo-search-engine",{"title":5,"description":3158},"published","en/blog/20261129-Hybrid-Photo-Search-Zero-Ms-Lightbox",[3169,3170,3171,3172,3173],"Hybrid Search","Reranking","EXIF","WebP Cache","Lightbox","SnUl4L9oBhn_AibLjzIPi4LzCPwZUuaOexQxVKIXcYY",{"path":66,"title":3176,"subtitle":3177,"track":3178,"liveUrl":3160,"liveLabel":3160,"date":3157,"status":3166},"Large-Scale Photo & Plate Hybrid Search & 0ms Lightbox Engine","Media search and review engine uniting an immutable vector corpus, Copy-on-Write EXIF overlays, Dual-Path reranking, a 1600px persistent WebP cache, and a 0ms progressive lightbox","ai-rnd","/blog/20261129-hybrid-photo-search-zero-ms-lightbox",[3181,3186],{"title":3182,"path":3183,"stem":3184,"date":3185,"status":3166,"noindex":3162,"children":-1},"Missing Docker Build-Time Env Vars in Nuxt 4 Static Prerendering & Dual CI Smoke Gates","/en/blog/20261125-nuxt-prerender-docker-build-env-ci-smoke-gate","en/blog/20261125-Nuxt-Prerender-Docker-Build-Env-CI-Smoke-Gate","2026-11-25",{"title":3187,"path":3188,"stem":3189,"date":3190,"status":3166,"noindex":3162,"children":-1},"Gemini TTS Parent Voice Cloning & 300 DPI Print-to-Web Boardbook Pipeline","/en/blog/20261203-gemini-tts-interactive-boardbook-pipeline","en/blog/20261203-Gemini-TTS-Interactive-Boardbook-Pipeline","2026-12-03",1796290674319]