Registry Mirror
Skip to content

Conversation

@LuQQiu

@LuQQiu LuQQiu commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Why this change?

Compaction rewrites data into new files, so rows move to new locations. Most indexes can keep working by following a map from the old locations to the new ones. Lance calls this deferred index remapping, and stores the map in the Fragment Reuse Index (FRI).

Some older index files cannot follow that map. Their metadata can still say “this index covers these rows,” even though the reader can no longer use it for those rows.

This PR makes that metadata match what the index can actually do.

Why not just remap inline and remove the FRI?

Correct row addresses do not imply correct fragment coverage. An index segment's coverage bitmap names whole fragments, not arbitrary subsets of their rows.

Consider a stable-partition rewrite from two fragments to two fragments. Segment S indexes all of A, but none of B:

Before rewrite:
  A = [a1, a2]       S covers A
  B = [b1, b2]       S does not cover B

After rewrite:
  C = [a1, b1]
  D = [a2, b2]

An inline remap can correctly change S's stored addresses:

  a1: A:0 -> C:0
  a2: A:1 -> D:0

But what should S's coverage bitmap become?

  • {C, D} is wrong: S has never indexed b1 or b2. Claiming both fragments are fully covered can cause queries to skip those unindexed rows.
  • Keeping {A} does not finish the job either: A is retired. Its coverage must still be interpreted through the FRI history to determine which current rows S covers.

So rewriting the addresses alone does not produce an index segment whose coverage can stand on its own. This partially covered transition cannot simply be drained and its FRI removed; the segment needs a safe rebuild/replacement or must retain its translation history. If S covered both A and B, remapping its addresses and restamping coverage to {C, D} together would be valid.

This is why inline remapping is not a general fallback for an index that cannot use deferred remapping. This PR withdraws affected unusable coverage in the compaction commit, keeps the logical index definition, and preserves any FRI history other usable segments still need.

What happens after compaction?

For each affected index:

  • It supports deferred remapping: keep using it through the existing map.
  • It is known not to support deferred remapping: remove its claim to cover the rewritten data, in the same commit that publishes the new data files.
  • Its capability cannot be verified: do not guess that it is unsupported. Refuse maintenance decisions that depend on the uncertain coverage.

For example, a table may have an older vector index and a BTree index over the same data. After compaction, the older index can lose coverage while the BTree keeps working. Queries that allow scanning read the affected rows without that index until replacement coverage is built.

The index definition is kept, so later index maintenance can restore coverage. This coverage change does not delete table rows, directly delete index files, or remove the shared maps that other indexes still need.

Safety and scope

  • Applies to deferred compaction using tagged FRI history. Immediate remapping, stable-row-ID tables, and legacy v0 FRI behavior are unchanged.
  • Checks the actual index file's capability; it does not disable an entire index type.
  • Commits the data rewrite and coverage change together, including conflict checks when index creation races with compaction. Failed or no-op compaction does not withdraw coverage; partial completion affects only committed work and its required mapping dependencies.
  • Keeps other usable coverage where possible. When several files share an older mapping, safe removal can also lose some additional index acceleration.
  • Adds no on-disk format, persisted field, or feature flag.

An unreadable index must not block maintenance of a separate, independent named index. Operations that inspect all indexes, such as table-wide cleanup, still refuse if they cannot verify the coverage they depend on.

Validation and remaining limits

Tests cover coverage bookkeeping, actual BTree and full-text query results, partial commits, concurrent index creation, interrupted full-text index finalization, and unreadable-index failure/recovery. Full-text tests also check that custom tokenizer behavior is preserved.

Current published head: 6766f42bf. The explicit-remap re-read issue is fixed, the focused 30-test suite and format/lint checks pass, and both Claude and Gatekeeper report no blocking issue. All applicable CI has completed successfully on this head. Technical validation is complete; formal review approval and merge are still pending.

Existing full-text column-discovery limitations are unchanged. This PR does not redesign how a query chooses its text column.

LuQQiu and others added 3 commits November 7, 2026 19:12
Assert, rather than infer, what the existing representation and the engine's
single deferred-remap capability predicate already decide, ahead of selecting
a compaction coverage-withdrawal policy.

`withdrawal_feasibility` covers `withdraw_rewritten_coverage`: the direct
S1={F1,F2} case keeps F2 and cannot trip the whole-remainder fallback (the
rewritten fragment is still live in the manifest the withdrawal is computed
against); the historical S1={P} case with P->F1+F2 withdraws P and gives up
F2 as well; removing F1 from a {P} bitmap is a no-op; and the fallback fires
only for a live remainder the history does not mention, retaining a retired
on-history remainder.

`capability_predicate_classifies_hnsw_as_deferrable` records the predicate's
answers for a real IVF_HNSW_SQ segment, a BTree segment and a segment whose
details are absent, so a later reclassification is visible as a test change.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…compaction commit

A deferred compaction on a tagged fragment reuse history leaves every
covering segment's retired provenance in its bitmap and records the row-level
translation in the history. A segment whose type cannot be translated in
batches was left pointing at provenance it can never translate: the reader
derives no coverage for it (`load_indices` excludes it, scan fallback) but the
manifest keeps claiming it, so nothing ever repairs the claim and a later
reader change could serve those addresses.

Such a segment's coverage of the rewritten sources is now withdrawn in the
same Rewrite commit. The classification is the engine's own single predicate
`segment_supports_batch_remapping`, not a type list: `Some(true)` keeps its
provenance and translates as before, `Some(false)` is withdrawn, `None`
(details absent or uninterpretable) is left exactly as it was, since the read
path already refuses such a segment and guessing a withdrawal from unreadable
metadata would delete coverage this build cannot prove unsound.

Representation, within the existing operation fields and with no persisted
format, field or flag added. `Operation::Rewrite` cannot carry the decision:
`rewritten_indices` means "replace this segment with these new files" and the
manifest build is synchronous, while the predicate must open index details.
The decision therefore rides `TaggedRewriteAssembly`, the in-memory per-attempt
value the commit path already assembles for a tagged rewrite and hands to the
build as `FragReuseUpdate::Rewrite`, as a list of segment uuids. It is
established in `finish_rewrite`, against the manifest the attempt builds on
and re-established on every retry, for the same reason the entry is: a
concurrent `CreateIndex` can add an undeferrable segment that the withdrawal
has to cover. `prepare_indices` then applies the existing helper
`withdraw_rewritten_coverage`'s algorithm to the prepared list, through a new
`withdraw_undeferrable_rewrite_coverage` entry point that selects by segment
instead of by rewritten column (a compaction rewrites no column) and shares
one `withdraw_coverage` implementation with the in-place-rewrite and
unverified-retired cases.

The other commit order is handled where the mirror decision already lives:
`finish_create_index` withdraws, from a segment being created over a committed
rewrite, the retired coverage it cannot translate, beside the in-place-rewrite
withdrawal already there.

Conservative loss is unchanged from the helper's existing rules and bounded:
an independent direct source keeps its coverage, while a retired ancestor
reaching a rewritten fragment is withdrawn whole, giving up its other
destinations too. The index definition always stays, so a later optimize can
restore coverage. `defer_index_remap = false`, stable-row-id tables and
untagged (v0) histories are untouched.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… end

Seven tests in `dataset::optimize::tests::undeferrable_withdrawal` over one
fixture: a table without stable row ids, made tagged by a stable-partition
commit before any index exists, carrying a legacy pre-(0,3) IVF_PQ segment
(the kind `segment_supports_batch_remapping` reports as undeferrable at this
pin) and a BTree segment over the same fragments.

- the whole contract on one commit: the legacy segment's stored bitmap no
  longer names the rewritten sources and claims none of the destinations, the
  BTree's stored provenance is untouched and its derived coverage translates
  to the destinations, both definitions remain, no other segment changed, the
  commit is the Rewrite itself; afterwards the KNN answer equals brute force
  with no ANN node in the plan (no retired row, no duplicate) and the BTree
  lookup is still served by `ScalarIndexQuery`;
- no-op: a compaction holding every covered fragment out of the plan leaves
  every index's metadata equal to what it was;
- partial: committing one task of a multi-task plan withdraws that task's
  sources only; the omitted (failed) task's sources stay covered;
- both commit orders through the conflict resolver: a `CreateIndex` of the
  legacy kind committed first with the Rewrite rebased over it, and the
  Rewrite committed first with the index build rebased over it. Both land (a
  refusal would make the assertions vacuous, so it fails the test) and neither
  keeps coverage of sources it cannot translate;
- the ordinary eager default: `defer_index_remap = false` on this table is
  still refused up front and withdraws nothing;
- `None` from the predicate: a segment whose details are stripped keeps its
  coverage byte for byte, and the reader's own refusal (no derived coverage)
  is what pins the behaviour.

Three unit tests in `withdrawal_feasibility` pin the new entry point itself:
selection is by segment (a deferrable sibling over the same column and
fragments is untouched), an empty selection or an empty rewrite set is a
no-op, and the retired-ancestor closure gives up the ancestor's other
destinations as the accepted loss, keeping the last segment as the definition
to rebuild.

Also drops a redundant clone in the neighbouring probe test, which
`clippy -D warnings` rejects.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions github-actions Bot added the enhancement New feature or request label Nov 8, 2026
@LuQQiu

LuQQiu commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings marked 🟡 are optional suggestions and need no follow-up push.

Additional findings (outside the current diff — GitHub can't attach inline comments there):

  • 🔴 rust/lance/src/index/frag_reuse.rs — A transient read error on an FTS index can now permanently remove that index's coverage of compacted fragments, which then get scanned until the index is rebuilt. inverted_supports_batch_remapping returns .is_ok() from opening METADATA_FILE, so any open failure counts as Some(false). This selector turns Some(false) into a withdrawal committed to the manifest. Fix: treat a failure other than a confirmed missing file as unknown (None, no withdrawal) or as an error. Do not report it as Some(false). Before this change the answer only chose a per-query scan fallback.

    Why this was flagged

    A deferred compaction on a tagged table covers fragments indexed by a modern inverted index. During finish_rewrite, undeferrable_segments_covering (frag_reuse.rs:651) calls segment_supports_batch_remapping, which calls inverted_supports_batch_remapping (frag_reuse_remapping.rs:73-78). An object store timeout or throttling error opening METADATA_FILE turns into false through .is_ok(), and the result is cached under InvertedFormatKey. The segment is listed in undeferrable_segments, and manifest_build.rs:495 withdraws its coverage of the rewritten sources in the committed Rewrite. On the base branch the same misclassification only made the reader fall back to a scan at query time, and nothing was persisted. Now the FTS index stops covering those fragments until someone runs optimize.

    Verification: inverted_supports_batch_remapping returns IndexStore::open_index_file(&store, METADATA_FILE).await.is_ok() (frag_reuse_remapping.rs:73-78), so any open error becomes Ok(false). New in this PR, frag_reuse.rs:648-654 pushes the uuid on Some(false), and finish_rewrite commits the withdrawal. On the base branch, the same misclassification only made a temporary scan fallback.

  • 🟡 rust/lance/src/index/frag_reuse.rs — Undeferrable segments that reach a rewritten fragment only through a retired ancestor keep that coverage, so the stated retired-ancestor withdrawal never runs in production. The prefilter at frag_reuse.rs:2063-2068 skips any segment whose fragment_bitmap is disjoint from the rewritten sources. A bitmap like {P}, where an earlier compaction split P into F1 and F2, is disjoint from a rewrite of F1. Fix: select a segment when its bitmap meets the rewritten set OR when one of its retired fragments has destinations_of reaching it, matching withdraw_coverage. [also at: rust/lance/src/index/frag_reuse.rs:2066 - Undeferrable segments whose coverage reaches a rewritten fragment only through a retired ancestor are never selected, so compaction leaves their untranslatable provenance in place.]

    Why this was flagged

    Take a legacy IVF_PQ segment (segment_supports_batch_remapping == Some(false)) whose bitmap holds a retired P, for example from a deferred compaction committed before this change. A later deferred compaction rewrites F1, a destination of P. finish_rewrite (finish.rs:603) calls undeferrable_rewrite_segments. That calls undeferrable_segments_covering, which skips the segment at frag_reuse.rs:646 because {P} is disjoint from {F1}. So undeferrable_segments is empty and manifest_build.rs:481 never withdraws anything. The segment keeps claiming provenance it can never translate, which is exactly what the PR says it fixes. The unit test undeferrable_withdrawal_follows_the_retired_ancestor passes the uuid in by hand, so it never exercises this selector.

    Verification: undeferrable_segments_covering (rust/lance/src/index/frag_reuse.rs:2062-2068) skips any segment where .is_none_or(|bitmap| bitmap.is_disjoint(fragments)). A bitmap {P} is disjoint from {F1}, so the segment is never listed. The outcome matches the base: the stale claim to P stays in the manifest. Query results stay correct.

@LuQQiu
LuQQiu marked this pull request as ready for review November 8, 2026 04:35

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 8, 2026
@LuQQiu LuQQiu changed the title feat(optimize): withdraw coverage an index cannot defer-remap in the compaction commit feat(optimize)!: withdraw coverage an index cannot defer-remap in the compaction commit Nov 8, 2026
@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. and removed K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 8, 2026
LuQQiu and others added 3 commits November 7, 2026 21:38
… file is missing

The inverted capability probe collapsed every failure to open the
segment's metadata file into "legacy layout": a transient object-store
error was reported as `false`, cached under that segment's uuid for the
rest of the handle's life, and turned by the rewrite commit into a
persisted withdrawal of the segment's coverage.

Only a confirmed-missing metadata file now answers `false`; any other
error propagates out of the cache-filling closure, so nothing is cached
and the commit attempt fails or retries under the existing error rules
rather than writing a narrowed fragment bitmap on the strength of an
unreadable file.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…venance

The selector skipped any segment whose fragment bitmap did not intersect
the rewritten ids directly. A segment can reach a rewritten fragment
through one more hop: when `P` was partitioned into `F1` and `F2` while
the segment covered `P`, a later rewrite of `F1` alone never names `P`,
so the segment was never classified and its coverage of `P` was left
behind for a reader that cannot translate it.

A segment is now also a candidate when it covers a retired fragment
whose rows the history moved into one of the rewritten ids. The reach of
a retired source mirrors the rule the withdrawal helper already applies,
including its conservative answer for a history that cannot be walked,
so selection and withdrawal agree on the same fragments. Only candidates
pay the capability probe, and the direct fast path is unchanged.

`undeferrable_rewrite_segments` therefore loads the tagged entry's
lineage and the manifest's live fragments, and the `CreateIndex` rebase
passes the lineage and liveness it already holds.

Accepted loss: withdrawing `P` also ends the segment's acceleration of
the sibling destination `F2`, since the rows it covered are only
reachable through the withdrawn transition.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… undeferrable segment

`P` was partitioned into `F1` and `F2` while an undeferrable segment
covered `P`, so a later rewrite of `F1` alone never names `P`. The test
pins that the selector still classifies that segment and the commit
withdraws `P`, clearing the live-only remainder with it, while the
deferrable control keeps translating to the untouched destination.

A build before this change could leave that manifest behind: its Rewrite
commits withdrew nothing. This build cannot produce the state any more,
so the fixture writes the older manifest directly through the
crate-internal manifest writer the fragment-reuse reader tests use.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@LuQQiu

LuQQiu commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Both findings are addressed on head c1f6ab643:

  • W1 (transient FTS I/O error persisted as withdrawal) → b5656d54b: inverted_supports_batch_remapping now reports the legacy layout only when the metadata file is confirmed missing (is_not_found()); any other read error propagates and nothing is cached, so no withdrawal is derived from an unreachable store. Regression a_read_failure_does_not_classify_an_inverted_index_as_legacy (fault-injected object store, asserts stored provenance unchanged, nothing cached, index still serving after reads recover; fails on the previous code with the whole coverage wiped) plus the control a_missing_inverted_metadata_file_is_the_legacy_verdict.
  • W2 (segment covering a rewritten fragment only through retired provenance) → 5f1334462: undeferrable_segments_covering now also selects a segment whose retired source reaches a rewritten fragment through TaggedLineage::destinations_of (transitive); unwalkable history stays conservative; the direct-hit path is unchanged. Regression a_retired_source_reached_by_the_rewrite_is_withdrawn_one_hop_away (c1f6ab643): a segment storing P after a committed P -> F1 + F2 partition, then a rewrite of F1 alone through the production commit path; asserts P is withdrawn, the live-only remainder is cleared as the existing rule requires, the definition stays, a deferrable control keeps its translated coverage, and a handle warmed before the rewrite sees the same state after checkout_latest. With the selector reverted to direct-only the test fails on the P assertion.

@LuQQiu

LuQQiu commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 8, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 8, 2026
@lance-gatekeeper lance-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 8, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Nov 8, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 8, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the inline finding, I checked whether a transient format-marker read error in frag_reuse_reader.rs (around line 108) could let a healthy sibling segment keep coverage it doesn't own, which would make queries drop rows. It can't. The unreadable segment is left out of supported before segment_coverage runs, so the sibling gets no destination coverage that would need the excluded segment's provenance, and those fragments are scanned instead.

Extended reasoning...

The check covered how the query-time listing in frag_reuse_reader.rs decides coverage when a segment's format-marker probe fails. Coverage is calculated only from the segments whose probe succeeded, so a sibling can't claim fragments that depend on the excluded segment.

Still open from earlier reviews (1):

  • Unresolved: 1 minor or pre-existing.

Additional findings (outside the current diff — GitHub can't attach inline comments there):

  • 🔴 rust/lance/src/dataset/optimize/remapping.rs — Explicitly remapping an index can publish a segment claiming fragments its sibling covers directly while that sibling's format marker is unreadable. Only the absent segment is refused. segment_coverage_reason returns Unverifiable only for segments missing from the listing, so a listed sibling X still gets Translate. The load_indices narrowing at remapping.rs:1008 is also derived without Y. Fix: refuse remap_index_tagged when the derived listing's unverifiable set contains the segment's name, as tagged_segment_coverage does. Run that check before committing any segment in remap_column_index.

    Why this was flagged

    Trigger: a tagged table where a same-name sibling Y covers the compaction destinations directly and its marker read fails. The handle must be cold, e.g. a fresh process, or the new snapshot each earlier remap commit creates. remap_column_index (remapping.rs:1215) calls remap_index_tagged for X before Y. frag_reuse_reader::load_indices drops Y and records its name, so the plan gives X Translate (frag_reuse.rs:374-389) and the name check at frag_reuse.rs:390 never runs. coverage &= servable (remapping.rs:1008-1016) uses a listing without Y's exclusions, so X' is committed with Y's destinations as direct coverage and dataset_version = current. Only then does Y fail with Unverifiable. With Y readable, X would be skipped as NoDerivedCoverage. Afterwards X' and Y both cover those fragments directly, and the newest-first prune drops Y. On base, a vector sibling's probe error (?) failed the remap and nothing was published. The PR says sibling decisions must be blocked, and tagged_segment_coverage does block them, but this path does not.

    Verification: In frag_reuse_reader::load_indices (frag_reuse_reader.rs:93-106), a failed segment_supports_batch_remapping is now swallowed. segment_coverage_reason returns None for X, so the new Unverifiable refusal at remapping.rs:938 never fires for X. Base used segment_supports_batch_remapping(dataset, index).await?, so the same transient read failed the remap visibly and nothing was published.

@lance-gatekeeper lance-gatekeeper Bot removed K-risk Latest Gatekeeper recommendation includes a non-blocking risk. K-approved Latest Gatekeeper recommendation permits acceptance. labels Nov 8, 2026
lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-changes Latest Gatekeeper recommendation requests changes. and removed K-changes Latest Gatekeeper recommendation requests changes. labels Nov 8, 2026
… segment

`tagged_segment_coverage` and the plan's absent-segment arm already refuse
a coverage decision for a logical index when one of its segments' format
markers cannot be read. The explicit remap did not: `remap_index_tagged`
classified each segment on its own, so when the unreadable segment was the
newer directly covering delta, the older translating segment was visited
first, classified from a listing missing the delta's direct coverage, and
published as a translated replacement over destinations the delta already
covered. After reads recovered the logical index answered every match
twice. The remap now consults the derived listing's unverifiable set for
the segment's logical index before classifying it and refuses, naming the
index and segment, before anything is published.

Covered by `an_explicit_remap_refuses_a_readable_segment_beside_an_unreadable_sibling`:
the delta's marker is unreadable on a cold handle, the remap refuses and
leaves the stored index list unchanged, and once reads recover it answers
exactly on the same and on a reopened handle. The older-fault fixture keeps
its prune/coverage controls; its remap assertion is the pre-existing
per-segment refusal.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@LuQQiu

LuQQiu commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Pushed c6063694c (append-only on 00e0b93f8) for the explicit-remap finding raised in both the Claude review (5819901514) and the Gatekeeper review (5819928649): an explicit remap_column_index on a tagged table could publish a translated replacement for an older, readable segment while a newer directly covering segment of the same logical index was unreadable, so after the read recovered the index answered with duplicates (512 rows for a 256-row match).

Fix (rust/lance/src/dataset/optimize/remapping.rs, remap_index_tagged): after the segment's own coverage probe, the remap consults the derived listing and refuses when the segment's logical index is in unverifiable, before any replacement is published. The per-segment probe only reports an unreadable marker for the segment it visits, so this is the same name-scoped refusal tagged_segment_coverage already applies, now covering the explicit remap. The error names the index and segment and says to retry once the files are readable. A segment that is itself unreadable keeps the existing diagnostic-bearing error. The check lives only in the tagged remap path; untagged and v0 tables are unchanged.

Regression (undeferrable_withdrawal.rs, an_explicit_remap_refuses_a_readable_segment_beside_an_unreadable_sibling): two FTS segments of one logical index with the same parameters, the older one translating through the tagged history and visited first, the newer delta directly covering its fragments and unreadable; cold handle. Under the fault the remap must fail with the index named and the stored segment list must be unchanged. After recovery the remap succeeds, derived coverage equals the destinations, and the indexed count equals brute force on the same handle and on a fresh open, through the indexed plan.

Evidence: with the test file against the previous remapping.rs, exactly this test fails at its no-publication assertion (the older segment had been replaced over the delta's destinations); with the fix the module passes 27/27. cargo fmt --check and cargo clippy -p lance -p lance-index --tests -D warnings are clean. The earlier older-segment fault test keeps its remap assertion, which exercises the pre-existing per-segment refusal.

🤖 Generated with Claude Code

@LuQQiu

LuQQiu commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Nov 9, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review completed

Nothing new to post: everything this review found is already covered by existing comments on this pull request or didn't merit a separate one.

lance-gatekeeper[bot]

This comment was marked as outdated.

@lance-gatekeeper lance-gatekeeper Bot added K-changes Latest Gatekeeper recommendation requests changes. and removed K-changes Latest Gatekeeper recommendation requests changes. labels Nov 9, 2026
The tagged remap verified a derived listing for unverifiable segments, then
re-derived another listing to narrow the segment's coverage. A marker read
outage between the two steps dropped the directly covering sibling from the
second listing, so nothing ceded its destinations and the published
replacement overlapped it, answering every indexed match twice.

The narrowing now intersects against the listing the guard already verified.
A regression faults the delta marker in an attempt window, with both caches
disabled, and asserts exact counts and disjoint segment coverage.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@LuQQiu

LuQQiu commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 6766f42bf (append-only on c6063694c) for the Gatekeeper check-to-use finding (review 5820563271): remap_column_index narrows coverage from the verified listing.indices instead of a second, unchecked listing. One regression added (an_explicit_remap_narrows_coverage_from_the_listing_it_verified), red on c6063694c, green on the new head together with the rest of the undeferrable_withdrawal suite, fmt and clippy.

🤖 Generated with Claude Code

@LuQQiu

LuQQiu commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@claude review

@lance-gatekeeper lance-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Nov 9, 2026

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Gate recommendation: approve with a non-blocking risk.

The reported repair closes the explicit-remap gap: coverage narrowing now uses the verified sibling listing, preserving disjoint ownership and exact indexed results through read recovery and retry. The staging and independent-index maintenance repairs remain intact. Selective atomic withdrawal remains appropriate, retaining logical definitions and shared FRI mappings.

Concurrent healthy cold opens on tagged snapshots can still duplicate derivation; warm opens remain cached. This remains a non-blocking performance risk.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 9, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment on lines +4053 to +4054
let met = attempts.swap(usize::MAX / 2, Ordering::SeqCst);
let exhausted = met >= start + PHASED_FAULT_READS;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 nit (optional): The faulted remap regression test can pass without the injected outage ever firing, so it cannot show it exercised the race it guards. exhausted and met are only put into the context string and are never asserted. If marker reads change, the window at PHASED_FAULT_START goes unreached and the test passes silently. Fix: when start == PHASED_FAULT_START, assert that the remap reached the window (met > start), or that it refused, so the faulted case cannot silently turn into the healthy control.

Why this was flagged

an_explicit_remap_narrows_coverage_from_the_listing_it_verified calls assert_partial_coverage_remap_is_exact(PHASED_FAULT_START, true). The wrapper fails only marker reads numbered 2..6 (PHASED_FAULT_START = 2, PHASED_FAULT_READS = 4, undeferrable_withdrawal.rs:3830-3834). After the first remap, line 4053 swaps the counter and line 4054 computes exhausted. Both values are used only in the context message and never asserted. Suppose the remap makes two or fewer reads of the delta's metadata.lance, for example because the fix removed the second derivation or because probes are reordered or cached. Then no injected error fires, and the test reduces to the healthy control a_partially_covered_remap_is_exact_with_healthy_uncached_reads. It still passes, so a later change to read order could hide a reintroduced overlap. This is a test-strength issue only, with no production impact.

Verification: nit. Trigger: a later change alters how many times the remap reads the delta's FTS metadata marker, so the first remap makes 2 or fewer such reads. After the first remap, met and exhausted (undeferrable_withdrawal.rs:4053-4054) are used only inside the context string, and no assertion checks them. If no fault fires, the faulted test passes on the same healthy path as the PHASED_FAULT_NEVER controls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants