Skip to content

Unify stock collection storage contracts - #5487

Merged
Kenny Kerr (kennykerr) merged 1 commit into
masterfrom
collections-storage
Nov 25, 2026
Merged

Kenny Kerr (kennykerr) merged 1 commit into
masterfrom
collections-storage

Conversation

@kennykerr

Copy link
Copy Markdown
Collaborator

Give all seven stock collection families the same storage choices: From requires Send + Sync stored values, unsafe from_unchecked keeps direct storage for caller-proven ownership, and from_marshaled handles interface values through agile references. The tighter From bounds are a source-breaking change.

Share immutable vector reads and iteration without changing QI surfaces, release retired map/vector entries outside their locks, and update Reactor to use the appropriate storage paths.

This does not close #5469 or promise arbitrary clone/comparison reentrancy.

Copilot AI 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.

🔵 Needs a closer look

The source-breaking storage changes affect COM marshaling, ownership, and final release, while unavailable Windows runtime validation and unverified WinUI, Reactor, and Miri checks leave key guarantees requiring maintainer review.

No open issues 🎉

What changed in this PR

This PR unifies storage contracts across all seven stock collection families in windows-collections
and updates Reactor consumers. The tighter From bounds are source-breaking; the change does not
resolve #5469 or guarantee arbitrary clone/comparison reentrancy.

Changes:

  • Require Send + Sync for safe direct storage, with unsafe direct and marshaled alternatives.
  • Share immutable vector reads and iteration while preserving interface surfaces, and release retired
    entries outside structural locks.
  • Expand storage, lifetime, concurrency, interop, and WinUI coverage, including Linux Miri checks.
File Description
crates/​tests/​libs/​reactor/​tests/​ui/​main.rs Runs the trusted read-only storage fixture.
crates/​tests/​libs/​reactor/​src/​lib.rs Registers the trusted collection fixture.
crates/​tests/​libs/​reactor/​src/​collections/​mod.rs Adds trusted mode and marshaled mutable construction.
crates/​tests/​libs/​reactor/​src/​collections/​live.rs Exercises all four collection source modes.
crates/​tests/​libs/​reactor/​readme.md Documents expanded live collection coverage.
crates/​tests/​libs/​collections/​tests/​storage.rs Tests batching, allocations, capacity reuse, and platform limits.
crates/​tests/​libs/​collections/​tests/​stock_vector.rs Makes direct interface-storage safety assumptions explicit.
crates/​tests/​libs/​collections/​tests/​stock_observable_map.rs Compares stock map behavior with native PropertySet.
crates/​tests/​libs/​collections/​tests/​stock_iterable.rs Adapts construction tests to the storage contracts.
crates/​tests/​libs/​collections/​tests/​runtime_class_name.rs Uses explicit unsafe storage for a scalar box.
crates/​tests/​libs/​collections/​tests/​interface_storage.rs Expands marshaling, interface, failure, and lifetime coverage.
crates/​tests/​interop/​fixtures/​collections/​read_only.h Shares vector contract tests and adds map resolution checks.
crates/​tests/​interop/​fixtures/​collections/​component.rs Exposes marshaled collection factories to interop tests.
crates/​tests/​interop/​fixtures/​collections/​client.cpp Runs contracts against marshaled vectors and maps.
crates/​tests/​interop/​fixtures/​collections/​api.rdl Declares the new interop factory methods.
crates/​libs/​reactor/​src/​native/​winui/​relations.rs Preserves read errors and marshals replacement data maps.
crates/​libs/​reactor/​src/​native/​winui/​objects.rs Constructs data objects with marshaled map storage.
crates/​libs/​reactor/​src/​native/​winui/​dependency.rs Uses trusted immutable storage for stock string boxes.
crates/​libs/​collections/​src/​vector.rs Adopts shared storage policies and explicit constructors.
crates/​libs/​collections/​src/​vector_view.rs Shares immutable reads and adds storage alternatives.
crates/​libs/​collections/​src/​vector_tests.rs Checks reentrant retirement and notification ordering.
crates/​libs/​collections/​src/​storage.rs Implements storage policies, batching, and unlocked retirement.
crates/​libs/​collections/​src/​read_only_vector.rs Shares immutable operations and adds unchecked direct storage.
crates/​libs/​collections/​src/​observable_vector.rs Applies shared storage while retaining change notifications.
crates/​libs/​collections/​src/​observable_map.rs Adds storage choices and releases entries before notifications.
crates/​libs/​collections/​src/​map.rs Adds storage choices and unlocked entry retirement.
crates/​libs/​collections/​src/​map_view.rs Shares map iteration and preserves storage in snapshots.
crates/​libs/​collections/​src/​map_tests.rs Tests reentrant key/value retirement and notifications.
crates/​libs/​collections/​src/​lib.rs Registers shared implementation and test modules.
crates/​libs/​collections/​src/​key_value_pair.rs Retains the selected storage policy in derived pairs.
crates/​libs/​collections/​src/​iterable.rs Adds storage choices and shared immutable iteration.
crates/​libs/​collections/​src/​immutable_vector.rs Centralizes immutable vector reads and iteration.
crates/​libs/​collections/​readme.md Explains constructors, safety obligations, and error behavior.
.github/​workflows/​miri.yml Adds Linux Miri checks for storage and retirement.
.github/​copilot-instructions.md Documents collection invariants and unresolved limitations.

Review effort: Balanced

@kennykerr
Kenny Kerr (kennykerr) merged commit 5a875c0 into master Nov 25, 2026
51 checks passed
@kennykerr
Kenny Kerr (kennykerr) deleted the collections-storage branch November 25, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#[implement] doesn't require Send + Sync, so safe code can race on a !Sync implementation

2 participants