← Back to Pull requests

Integration robustness contracts #710

Closed
unknown closed this pull request without merging on Oct 13, 2026 16:26 UTC
View on GitHub
unknown unknown commented on Aug 12, 2026 19:40 UTC
Author

Synopsis

This is a set of changes to make the embedding layer between JVector an hosting runtimes more robust, visible, and efficient. The aspects addressed here are those which we haven't been prescriptive enough about for embedding systems.
Most essentially, these contracts and supporting types and wrappers are used by embeding systems to instruct JVector where and how to do certain things, like writing index outputs, or using thread pools.

The aspects covered in this set include execution controls, rate-limiting, output vectoring (virtualization), runtime-safety checks on non-runtime debugging features, and memory safety.

Why

Jvector today assumes it owns its execution, its output files, and its process. When it runs embedded in a host that manages its own thread pools, IO budget, mmap lifecycle, and cancellation — e.g. Cassandra's SAI vector indexing driving compaction — those assumptions leak:

  • parallel work escapes to ForkJoinPool.commonPool() / PhysicalCoreExecutor.pool(), outside the host's budget;

  • long-running operations are opaque (no progress) and unthrottled (their write bandwidth ignores the host's throughput limiter);

  • output must be a jvector-owned file, so it can't be written into a slot inside a larger host container;

  • diagnostic-only work can't be switched off in production;

  • a host that unmaps a source underneath an in-flight read faults the JVM (SIGSEGV) instead of failing diagnosably.
  • This PR adds the extension points a host needs to close those gaps. It is purely additive and opt-in — no existing behavior changes, and nothing in jvector consumes these seams yet. It's the foundation an embedding/compaction effort builds on; a follow-up PR illustrates how the compactor's calling conventions convert onto these seams.

    What's in it, in detail

    Five contracts, one per commit:

    1. Cooperative work-limiting + progress (util/work/) — ProgressLimiter = ProgressTracker (progress up) + WorkLimiter (throttle down), with WorkStage for phase scoping and LeakyBucketLimiter as a default rate-limited limiter. A host installs one to observe and rate-limit a long jvector operation, and to checkpoint cancellation at phase boundaries.
    2. Pluggable output sink (disk/) — SeekableSink + CompactionDestination (with file-backed defaults) let a host redirect compaction output through a caller-owned channel — e.g. a slot inside a larger container after a reserved header — instead of jvector always allocating its own file. Target has an explicit open → commit → close lifecycle (no commit() ⇒ aborted, partial output discarded).
    3. ParallelExecutor (graph/) — a minimal parallel-for abstraction so a host supplies its own pool (forkJoin(pool)) or runs inline (callerRuns()), instead of jvector reaching for the common pool.
    4. RuntimeMode (util/) — a process-level jvector.mode gate. Unset is production; diagnostic-only work is opt-in behind it.
    5. Reader memory-safety (disk/) — bounded record reads in OnDiskGraphIndex (an out-of-range node id fails with IllegalArgumentException instead of becoming a wild offset into the mapped file), plus documenting the close() contract on ReaderSupplier/SimpleMappedReader (the raw-release-immediate-unmap vs. coordinated-liveness-handshake families) so a host knows not to close a supplier while any vended reader is live.

    Design principles


  • Additive & opt-in. No existing public signature is removed or changed; deprecation of any older path is a separate concern.

  • Base module, --release 11. Everything lands in jvector-base (bytecode v55), so it runs on every supported JDK (11–25). No META-INF/versions/ overrides, no incubator Vector API use — no per-runtime divergence.

  • - Seams only, no consumers. Nothing in jvector calls these yet, so the PR reviews in isolation and adoption can land separately.

    Deliberately not* here

    No changes to the compactor or its algorithm, no new call sites, no host-specific code. Adoption is the follow-up PR.

    Testing

    jvector-base compiles at --release 11. New unit tests cover ProgressLimiter, SeekableSink, and RuntimeMode. The only edits to existing files are non-breaking (Javadoc on ReaderSupplier/SimpleMappedReader, an internal bounds check in OnDiskGraphIndex).

    Stats: 17 files, +1346/−3 (the 3 deletions are lines replaced by the OnDiskGraphIndex bounds check).

    Commits


  • util/work: cooperative work-limiting and progress interface

  • disk: pluggable output sink for compaction writes

  • graph: ParallelExecutor abstraction for host-provided execution

  • util: RuntimeMode gate for opt-in diagnostic work

  • disk: memory-safety guards for host-managed reads
  • Diff: 599 lines (+449 / -150) across 7 files Reviewer: MarkWolters Review duration: 89086m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 599 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.383
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #710"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 50.1% (MEDIUM) · Higher = larger blast radius
    50.1%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 19.8% · Safe to merge
    19.8%