Improved File Versioning #707
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 448 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.365
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #707"
general
weight: 0.35
tlwillke
Summary
This branch eliminates scattered version-comparison branching (
if version >= X,if version < Y,version == Z) from the on-disk graph index read/write path and replaces it with a Strategy + Factory pattern: eachsupported format version (2–6) gets its own
GraphIndexFormatimplementation, andGraphIndexFormatFactorycentralizes version→format dispatch and detection.## What changed
New abstraction (
graph/diskpackage):-
GraphIndexFormat— strategy interface covering header/footer read+write, feature ordering, and full sequential/random-access write orchestration for a single format version.-
AbstractGraphIndexFormat— shared default implementation; versions override only what's actually different for them.-
GraphIndexFormatV2..GraphIndexFormatV6— one small class per version, built on a natural inheritance chain (V4extendsV3,V5extendsV4+ footer,V6extendsV5+ feature reordering + fused-PQsupport).
-
GraphIndexFormatFactory—forVersion(int),detectVersion(reader)(magic-number sniffing),getCurrentVersion().-
WriteContext— bundles the ~7 parameters that used to be threaded individually through every serializer method.Migrated call sites:
-
AbstractGraphIndexWriter(and itsOnDiskSequentialGraphIndexWriter/RandomAccessOnDiskGraphIndexWritersubclasses) now delegate all format-specific work to the resolvedGraphIndexFormatinstead ofbranching on
versioninline. Feature-support validation (Builder.build(), fused-PQ gating) now asks the format (supportsFeature) instead of hardcoding version thresholds.-
Header/CommonHeadernow delegate header size/read/write and common-header size/read/write to the per-version format, removing theversion >= 3/>= 4/>= 6chains that used to live in both classes.-
OnDiskGraphIndexload/footer dispatch goes throughGraphIndexFormat.loadOnDiskIndex, removing the inlineversion >= 5 && useFooterbranch; the two remaining fused-PQ-layout checks now ask-
CompactWriter(streaming N:1 compaction writer) validates once, at construction, that fused PQ is actually supported by the target format; the three per-callversion == 6checks in its hot paths were simplifiedto the already-existing
fusedPQEnabledflag, since this writer only ever targets the current version. No added per-record overhead.Fixed along the way:
- A regression where the writer/reader split silently dropped eager in-memory cache priming (
getInMemoryLayers/getInMemoryFeatures) for non-footer format versions — caught by aramBytesUsed()test failure,fixed by centralizing construction + priming in
OnDiskGraphIndex.construct().-
allFeatures()/nonFusedFeatures()helpers now return explicit, frozenEnumSet.of(...)listings instead of deriving fromEnumSet.allOf(...)/complementOf(...), so a futureFeatureIdaddition can'tsilently change what an already-shipped version claims to support.
## Testing
- New
TestGraphIndexFormatFactory: version→format dispatch, unsupported-version rejection, per-version characteristics (supportsMultiLayer,usesFooter,getSupportedFeatures), and magic-number versiondetection.
- New
TestOnDiskGraphIndex.testVersionRoundTrip: explicit write/read round trips for versions 3, 4, and 5 (single-layer and, for 4/5, multi-layer), in addition to the existing version-2 and current-version (6)coverage.
- Full
jvector-testssuite passes (208 tests, 0 failures).