← Back to Pull requests

fix: the search index lives in IndexedDB and a refused save is reported (#363) #403

Closed
unknown closed this pull request without merging on Nov 30, 2026 04:19 UTC
View on GitHub
unknown unknown commented on Nov 30, 2026 04:07 UTC
Author

Closes #363.

The chosen layout (proposed for review)

A new storage-layer file, src/utils/indexStorage.js, owns where the index lives; useSemanticSearch.js stays the hook that owns the rules. The issue's "durable fix" — IndexedDB behind the same read/write shape — is what lands; vector compaction and unlimitedStorage are deliberately not taken (quantisation slightly changes retrieval quality, and the new permission stays rejected per #13's direction).

  • IndexedDB first: a bookmarkit database whose settings store holds the index under the same name, bookmarkit.semanticIndex, as the plain object — structured clone moves it without a JSON pass over every float, so a 5,000-bookmark index is neither stringified nor capped by the 10 MiB quota.

  • The settings store stays behind it, through the existing readSetting/writeSetting: the fallback where IndexedDB is missing or refuses to open (jsdom, some webviews), and the migration path — a read that finds nothing in IndexedDB adopts what the settings store holds, writes it into IndexedDB, and drops the old copy, the way adoptLegacyLocalStorage moved the web build's settings. An unparsable legacy value reads as no index rather than breaking the read.

  • A refused save is reported once: writeIndexStore returns the boolean #36 taught writeSetting to return, the hook latches indexSaveFailed until a write lands, and BookmarkApp renders it as a role="status" panel beside the organizer bar — one report, not a failure per search. A refused save costs the next session its index, not this one's.
  • Acceptance

  • A refused index write is reported, not swallowed. Tested exactly with a failing writeSetting: without IndexedDB the helper writes through to it, so the test breaks localStorage.setItem for that link (useSemanticSearch.test.jsx). The report clears when a later write lands.

  • A stated library size keeps its index across sessions on the default model. 5,000 bookmarks × 1,536 dimensions (text-embedding-3-small's): session one embeds 100 batches of 50 plus its query, session two reads the same IndexedDB and embeds only its query (101 calls → 102), ranking 20 hits from storage.

  • README's "embedded once" claim: now states the index lives in IndexedDB, that a library of thousands keeps it across sessions on the default model, and that a refused save is reported. DESIGN.md's index paragraph records the layout, the migration, and the latch. The issue's per-bookmark size figures remain modelled estimates — nothing measured a real library here; with IndexedDB as the primary store the quota math no longer bounds the index, and the notice covers the case where IndexedDB is unavailable _and_ the settings store refuses.
  • Tests

  • New src/utils/indexStorage.test.js: IndexedDB primary (plain object, no JSON), settings-store fallback, boolean honest when every store refuses, fallback when IndexedDB refuses to open, legacy adoption + drop, unparsable legacy, empty everywhere. Shared fake in src/test/fakeIndexedDB.js (every open() answers its own request).

  • useSemanticSearch.test.jsx: the three #363 cases above; the existing suite passes unchanged through the new read/write shape.

  • npm run ci green (version policy, notices, format, lint, 1,534 tests, Chrome + Storybook builds).
  • Verified in the real extension

    A forced-failure check ran the built extension in Brave: IndexedDB removed from the page and chrome.storage.local.set throwing for the index key only, the provider pointed at a mock whose chat endpoint fails fast (so the ask falls back to a plain search plan whose widening embeds against the mock embeddings endpoint). The notice rendered once, stayed exactly one through a second ask window, search still worked (the semanticMatches plan filtered the list), the index key never appeared in chrome.storage.local, and the console stayed clean.

    Changeset: patch.

    <!-- agent-bot-write: ghw_33e41ff96cd8e16d session=acad26a80cec bot=trueline-zcode-agent[bot] -->

    Diff: 504 lines (+378 / -126) across 6 files Reviewer: qwts Review duration: 11m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.55)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.48 · 504 lines diff across 6 files
    0.48
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 94% · Reviewer familiarity: 35%
    55%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.372
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #403"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 55.4% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.6% (MEDIUM) · Higher = larger blast radius
    47.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 55.4% · Lower = rushed or shallow review
    55.4%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.2% · Safe to merge
    21.2%