60 replace typeid storage with recordid recordkey architecture - #62
Merged
lxsaah merged 10 commits intoDec 6, 2025
Merged
Conversation
…scriptive identifiers
… indexing - Added RecordId and RecordKey types for O(1) record access and identification. - Implemented key-based producer/consumer API with produce_by_key and subscribe_by_key methods. - Enhanced introspection capabilities with records_of_type and resolve_key methods. - Introduced new error variants for better error handling. - Updated RecordMetadata to include record_id and record_key fields. - Refactored internal storage for improved performance and stability. - Updated SecurityPolicy to use RecordKey for writable records. - Added multi-instance tests to validate new architecture. - Updated documentation and migration guide to reflect breaking changes.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements a comprehensive architectural refactoring (Issue #60) that replaces TypeId-based record storage with a new RecordId/RecordKey system. This enables multiple records of the same Rust type to coexist with different keys (e.g., "sensors.indoor" and "sensors.outdoor" can both store Temperature data).
The changes include:
- New
RecordId(u32 index) andRecordKey(hybrid static/dynamic string) types for record identification - Internal storage refactor from
BTreeMap<TypeId>toVec+ multipleHashMapindexes for O(1) access - Key-based producer/consumer API methods (
produce_by_key,subscribe_by_key, etc.) with newProducerByKeyandConsumerByKeytypes - Breaking change:
configure<T>()now requires a key parameter - Type-based methods return
AmbiguousTypeerror when multiple records of the same type exist - Security policy migration from TypeId-based to key-based writable records
- Comprehensive test coverage and updated examples
Reviewed changes
Copilot reviewed 32 out of 33 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
aimdb-core/src/record_id.rs |
New module with RecordId and RecordKey types, including Borrow<str> for O(1) HashMap lookups |
aimdb-core/src/builder.rs |
Refactored storage from BTreeMap to Vec + HashMap indexes; updated configure() to require key parameter |
aimdb-core/src/typed_api.rs |
Added ProducerByKey and ConsumerByKey types for key-bound access |
aimdb-core/src/error.rs |
New error variants: RecordKeyNotFound, InvalidRecordId, TypeMismatch, AmbiguousType, DuplicateRecordKey |
aimdb-core/src/remote/config.rs |
Security policy migrated from TypeId to key-based writable records |
aimdb-core/src/remote/handler.rs |
Remote access handlers updated for key-based lookups instead of TypeId |
aimdb-core/src/remote/metadata.rs |
Added record_id and record_key fields to RecordMetadata |
aimdb-tokio-adapter/tests/multi_instance_tests.rs |
Comprehensive test suite for multi-instance scenarios |
examples/* |
All examples updated to use new key-based configure() API |
docs/design/015-M6-record-id-architecture.md |
Design documentation with implementation decisions |
CHANGELOG.md |
Migration guide and breaking changes documentation |
push spawn functions only for new records improve error handling
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 33 out of 34 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
tools/aimdb-mcp/CHANGELOG.md:1
- The date '2025-11-20' in line 16 is in the future relative to the current date (December 6, 2025 is after November 20, 2025). However, this appears to be an existing entry that should remain unchanged.
lxsaah
deleted the
60-replace-typeid-storage-with-recordid-recordkey-architecture
branch
December 6, 2025 19:10
This was referenced Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added
TypeIdStorage withRecordId+RecordKeyArchitecture #60): Complete rewrite of internal storage for stable record identificationRecordId: u32 index wrapper for O(1) Vec-based hot-path accessRecordKey: Hybrid&'static str/Arc<str>withBorrow<str>for zero-alloc static keys and flexible dynamic keysHashMap<RecordKey, RecordId>HashMap<TypeId, Vec<RecordId>>produce_by_key::<T>(key, value): Produce to specific record by keysubscribe_by_key::<T>(key): Subscribe to specific record by keyproducer_by_key::<T>(key): Get key-bound producerconsumer_by_key::<T>(key): Get key-bound consumerProducerByKey<T, R>andConsumerByKey<T, R>for key-bound access with.key()accessorrecords_of_type::<T>(): Returns&[RecordId]for all records of type Tresolve_key(key): O(1) lookup returningOption<RecordId>RecordKeyNotFound: Key doesn't exist in registryInvalidRecordId: RecordId out of boundsTypeMismatch: Type assertion failed during downcastAmbiguousType: Multiple records of same type (use key-based API)DuplicateRecordKey: Key already registeredrecord_id: u32andrecord_key: StringfieldsChanged
configure<T>()Signature: Now requires key parameter:configure::<T>("key", |reg| ...)BTreeMap<TypeId, Box<dyn AnyRecord>>to:Vec<Box<dyn AnyRecord>>for O(1) hot-path access by RecordIdHashMap<RecordKey, RecordId>for O(1) name lookupsHashMap<TypeId, Vec<RecordId>>for type introspectionproduce(),subscribe(),producer(),consumer()now returnAmbiguousTypeerror when multiple records of the same type existReadWritevariant now usesHashSet<String>for writable record keyshashbrownfor no_std-compatible HashMap withdefault-hasherfeature´