← Back to Pull requests

[ZEPPELIN-6412] Shard embedding search index persistence by note #5535

Open
unknown opened this pull request with 321 lines diff across 4 files
View on GitHub
unknown unknown commented on Oct 05, 2026 04:52 UTC
Author

What is this PR for?

EmbeddingSearch currently keeps all entries in a single embedding_index.bin file. Although paragraph embeddings are updated incrementally in memory, every flush serializes and rewrites the entire index.

This PR shards the persisted index by note. Updating a paragraph now rewrites only the shard belonging to the affected note, while semantic search continues to operate across the complete in-memory index.

What type of PR is it?

Bug Fix

What changes were made?

Per-note persistence

  • Store embedding index entries in per-note shard files under notes/

  • Track dirty state and coordinate writes per note

  • Atomically replace individual shard files

  • Preserve notebook-wide semantic search behavior
  • Shard lifecycle and recovery

  • Delete a shard when its note is removed

  • Clean up orphan shards during startup

  • Rebuild only the affected note when a shard is missing or corrupt

  • Prevent concurrent flushes from recreating a deleted note shard
  • Legacy index migration

  • Migrate the legacy embedding_index.bin using an all-or-nothing staging directory

  • Keep the legacy index available for retry if migration fails
  • Tests and documentation

  • Add tests for sharding, migration, recovery, and concurrent updates

  • Update the embedding search documentation to describe per-note persistence
  • Todos

  • Implement per-note index persistence

  • Handle shard migration and recovery

  • Add unit tests

  • Update documentation
  • What is the Jira issue?

  • [ZEPPELIN-6412]
  • How should this be tested?

    ./mvnw test -pl zeppelin-server --am \
      -Dtest=EmbeddingSearchShardingTest \
      -Dsurefire.failIfNoSpecifiedTests=false
    

    EmbeddingSearchShardingTest contains 20 tests covering:

  • Isolation between note shards

  • Missing and corrupt shard recovery

  • Orphan shard cleanup

  • Legacy index migration and migration failure recovery

  • Concurrent note deletion and flushing

  • Prevention of partially loaded entries from truncated shards
  • All 20 tests pass.

    Screenshots (if appropriate)

    Not applicable.

    Questions:

  • Does the license files need to update? No.

  • Is there breaking changes for older versions? No API or configuration changes. Older versions cannot read the new shard format, but the embedding index is rebuildable.

  • Does this needs documentation? Yes. docs/embedding-search.md has been updated to describe per-note persistence.
  • Diff: 321 lines (+240 / -81) across 4 files Reviewer: tbonelee Review duration: 85085m
    All Vouch review confidence checks passed
    Residual risk 0.29 = Change Risk (0.49) × (1 − Review Confidence (0.41)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.49 · 321 lines diff across 4 files
    0.49
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    40%
    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.345
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #5535"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 40.9% 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: 48.9% (MEDIUM) · Higher = larger blast radius
    48.9%
    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: 40.9% · Lower = rushed or shallow review
    40.9%
    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: 28.9% · Safe to merge
    28.9%