Skip to content

docs(encoding): document dictionary gather buffer safety - #10980

Merged
Xuanwo merged 1 commit into
mainfrom
xuanwo/dictionary-gather-safety-comment-nier-20261112
Nov 12, 2026
Merged

Xuanwo merged 1 commit into
mainfrom
xuanwo/dictionary-gather-safety-comment-nier-20261112

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 12, 2026

Copy link
Copy Markdown
Member

Main's ci profile lint fails with clippy::undocumented_unsafe_blocks at
DictionaryDataBlock::gather_variable_width_typed (data.rs:1200), which blocks the full Rust
lint for every PR in the workspace, #10750 included.

The existing SAFETY: note sits inside the outer unsafe block, so it justifies the unchecked
offset reads but leaves the block itself undocumented. This moves the justification above the
block and extends it to cover the rest of it: the index/offset bounds proven by
validate_offsets_for_append and the first pass, total_bytes fitting both usize and T, the
two output allocations being disjoint from the dictionary data, and every rebased offset and
payload byte being written before the set_len calls. Comment-only; no runtime change.

Context: the block came in with #10911. Validation on this branch: cargo fmt --all -- --check
and cargo clippy --profile ci --all --tests --benches -- -D warnings both pass.

The `ci` profile lint on main fails with `clippy::undocumented_unsafe_blocks`
at `DictionaryDataBlock::gather_variable_width_typed`: the existing `SAFETY:`
note sits inside the outer unsafe block and only justifies the unchecked
offset reads, leaving the block itself undocumented.

Move that justification above the block and extend it to cover the raw
pointer arithmetic, the disjoint fresh output allocations, and the `set_len`
calls. Comment-only change; no runtime behavior differs.

@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.

@github-actions github-actions Bot added A-encoding Encoding, IO, file reader/writer documentation Improvements or additions to documentation labels Nov 12, 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.

The expanded safety argument matches the surrounding bounds validation and initialization order. A focused Clippy reproduction fails with the old comment placement and passes with this change; executable code is unchanged.

@lance-gatekeeper lance-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Nov 12, 2026

@LuciferYang LuciferYang 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.

+1, LGTM
Thanks @Xuanwo

@Xuanwo
Xuanwo merged commit 33c4f10 into main Nov 12, 2026
41 checks passed
@Xuanwo
Xuanwo deleted the xuanwo/dictionary-gather-safety-comment-nier-20261112 branch November 12, 2026 07:25
Xuanwo added a commit that referenced this pull request Nov 12, 2026
Controlled services need to reject stored External Blob references
outside registered storage bases before URI resolution or size probing,
while immutable payload caches must not return stale External data.

Add an opt-in Session policy for unregistered External reads and logical
reference writes. Embedded sessions retain the existing Allow default.
Provider filtering removes selected schemes and clears cached bindings;
it does not revoke previously issued handles. Policy-aware writes report
that remote tables require registered storage bases. Explicit Ingest and
low-level file APIs retain their existing contracts.

Add an External-store wrapper hook that derives a view from the resolved
store, preserving credentials, endpoints, connection pools and provider
state. Immutable cache wrappers can bypass their cache for External
reads while retaining ordinary Managed behavior. A weak cache reuses
live External views without a reference cycle, and source/scheduler
identity prevents stores or wrapper views with matching prefixes from
being combined.

Behavioral validation covers rejection before source access, filtered
local providers, registered-base matching, repeated locator batches
sharing one executor, fresh External reads after overwrite, and zero
origin reads for warm Managed payloads. The final reviewed delta passed
483 IO and 227 Blob tests; earlier 189 Dataset IO cases and two doctests
remain applicable. The integrated tree adds only the upstream
SAFETY-comment fix from #10980; full root Clippy passed on the
integrated PR head (`cargo clippy --all --tests --benches --profile ci
-j 4 -- -D warnings`, exit 0). Hosted CI and formal approval remain
pending.

Service adoption must propagate the policy when rebuilding Sessions and
implement the External hook in its immutable cache wrapper. Production
RAM/NVMe, cloud credentials and REST/SQL integration are separate
downstream work. This PR does not establish that those service
boundaries are already enforced. It overlaps the internal read keys in
#10171; a separately reviewed integration candidate with that PR
retained Arc-instance-plus-path scheduler identity and row-independent
entries and passed 605 Blob tests (0 failures). This does not claim
downstream Sophon adoption or a merged prerequisite.
Xuanwo added a commit that referenced this pull request Nov 12, 2026
Complete the descriptor-transition contract from #9458 and #9459 with
regression assertions for exact historical descriptors, an unchanged
default storage version, and implicit-version compaction failing without
committing a new snapshot. Remove the obsolete schema-transition
discussion link while retaining the requirement to explicitly select
`data_storage_version >= 2.2` for mixed-column Blob v2 compaction.

Validation evidence for this unchanged patch contains five passing Rust
behavior cases: all four mixed-version cases and the released
legacy-fragment regression. Formatting and diff checks pass. Workspace
Clippy and the targeted lance Clippy run are blocked by the existing
`clippy::undocumented_unsafe_blocks` error at
`rust/lance-encoding/src/data.rs:1200`; the separate fix is tracked in
#10980 and is not duplicated here. Full workspace tests and Python
bindings were not run.

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

Labels

A-encoding Encoding, IO, file reader/writer documentation Improvements or additions to documentation K-approved Latest Gatekeeper recommendation permits acceptance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants