Skip to content

Commit aaf6f1b

Browse files
authored
Label resolver config driven (#43)
* Refactor envelope encryption API to use network public keys - Introduced a complete refactor of the envelope encryption API, transitioning from `network_id: Option<&str>` to `network_public_key: Option<&[u8]>` for improved consistency with the label resolver design. - Updated the `EnvelopeCrypto` trait and `SerializationContext` structure to reflect the new public key approach, enhancing validation and performance. - Implemented changes across multiple components, including NodeKeyManager and MobileKeyManager, to support the new encryption flow. - Ensured comprehensive testing and validation of all encryption and decryption flows, addressing potential breaking changes and enhancing overall security. - Updated documentation and migration steps to guide users through the transition to the new API structure. * format * Enhance label resolver system and update related components - Implemented a complete refactor of the label resolver system, introducing `LabelResolverConfig` and `LabelValue` structures for improved configuration management. - Updated `NodeConfig` to include a mandatory `label_resolver_config` field, ensuring all nodes have a defined label mapping at startup. - Created a new example demonstrating the usage of the label resolver system, showcasing both system and user context resolutions. - Enhanced serialization context to support dynamic label resolution, improving flexibility and performance. - Added comprehensive tests for the label resolver configuration and its validation, ensuring robustness and correctness. - Updated various components to utilize the new label resolver structures, enhancing overall consistency across the codebase. * Update Node integration and enhance message structures - Completed the update of the Node struct to replace `label_resolver` with `system_label_config`, optimizing performance. - Updated the Node constructor to utilize the new `config.label_resolver_config`. - Enhanced ResponseMessage, EventMessage, and RequestMessage structures by adding the `network_public_key` field for improved message handling. - Updated QuicTransport to replace static resolvers with the new system label configuration, ensuring consistency across the transport layer. - Fixed method signatures in the API to align with new trait requirements, enhancing overall code clarity. * Complete integration of dynamic label resolver architecture and finalize transport layer updates - Marked Phase 4 (Node Integration) and Phase 5 (Transport Layer Integration) as completed, reflecting significant progress in the project. - Updated the Node struct to utilize `system_label_config` instead of `label_resolver`, enhancing performance and clarity. - Enhanced message structures by adding `network_public_key` fields to various message types for improved handling. - Transitioned to dynamic resolver creation in SerializationContext, ensuring fresh user context for each request. - Fixed all NetworkMessagePayloadItem initializations to include the `network_public_key`, ensuring consistency across the transport layer. - Initiated Phase 6 (Testing and Validation) with all unit tests passing and integration tests confirmed for node and transporter functionalities. * Refactor label resolver architecture and update message structures - Completed integration of dynamic label resolver architecture across the Node and RemoteService components, replacing static resolvers with `label_resolver_config` for improved user context handling. - Updated message structures to consistently use `profile_public_keys: Vec<Vec<u8>>`, ensuring alignment across RequestMessage, ResponseMessage, and NetworkMessagePayloadItem. - Enhanced RequestContext to support multiple user profile keys, facilitating better context propagation. - Implemented dynamic resolver creation in both Node and RemoteService, ensuring fresh user context for each request. - Updated all relevant method signatures and serialization contexts to reflect the new API structure, enhancing overall consistency and clarity. * Refactor message handling architecture to eliminate duplication - Removed `RequestMessage`, `ResponseMessage`, and `EventMessage` structures, transitioning to a single `NetworkMessage` structure for all callbacks. - Updated the transport layer to consistently use `NetworkMessage`, enhancing clarity and reducing data duplication. - Refactored related components, including Node and RemoteService, to accommodate the new message structure, ensuring compatibility across the system. - Enhanced the label resolver configuration to support the new architecture, improving overall performance and maintainability. - Updated tests and examples to reflect the changes in message handling, ensuring comprehensive coverage and validation of the new structure. * Refactor envelope encryption method to utilize profile public keys - Updated the `EnvelopeCrypto` implementation in `NodeKeyManagerWrapper` to replace the previous envelope creation method with a new approach that incorporates `profile_public_keys`. - Enhanced the encryption process to support multiple profile keys, improving flexibility in data handling. - Ensured consistency with recent changes in message structures and encryption flows across the codebase. * Remove outdated comment regarding envelope encryption approach in NodeKeyManagerWrapper * format * Remove obsolete design documents and refactor label resolver architecture - Deleted outdated documents related to envelope encryption, NodeKeyManager redesign, and Swift vector validation, streamlining the codebase. - Refactored the label resolver implementation to eliminate the trait overhead, replacing it with a concrete struct for improved performance and simplicity. - Enhanced the `LabelResolver` to utilize `DashMap` for concurrent access, ensuring efficient label resolution and cache management. - Updated related components and tests to align with the new label resolver structure, maintaining consistency across the system. * Refactor label resolver interface and update related components - Introduced a trait-based `LabelResolver` interface to enhance flexibility and decouple implementations. - Updated `ConfigurableLabelResolver` to implement the new trait, ensuring compatibility with existing functionality. - Modified method signatures across the codebase to accept the trait object, improving type safety and clarity. - Temporarily disabled cache performance tests due to the removal of the cache implementation, ensuring tests reflect current functionality. - Updated example usage to align with the new label resolver structure, demonstrating the validation process for system configurations. * Refactor label resolver implementation to streamline usage - Updated the `LabelResolver` interface to delegate functionality to `ConfigurableLabelResolver`, enhancing clarity and maintainability. - Modified method signatures across the codebase to utilize the new trait, ensuring consistent usage of the label resolver. - Adjusted example and test cases to reflect the updated label resolver structure, confirming validation processes and resolver creation. - Improved type safety by replacing direct references to `LabelResolver` with `ConfigurableLabelResolver` where applicable. * Refactor test mocks and label resolver integration - Removed obsolete mock transport implementation and related module to streamline test code. - Updated references to `LabelResolver` in the codebase, replacing them with `ConfigurableLabelResolver` for improved clarity and consistency. - Adjusted test cases to utilize the new label resolver structure, ensuring proper validation and functionality. - Cleaned up unnecessary comments and improved overall organization of the test files. * Add Clippy configuration for qualified path detection and document violations - Introduced a new `clippy.toml` file to configure Clippy for detecting absolute path usage, setting the maximum allowed segments to 1. - Created a `format_fixes.md` document outlining identified qualified path violations across the codebase, detailing the number of violations found by Clippy and a manual scan. - Updated various test files to improve clarity by removing unused parameters and enhancing error message formatting. - Adjusted method signatures to accept slices instead of vectors for better performance and consistency. - Enhanced logging and documentation to support ongoing efforts in fixing qualified path violations systematically. * Refactor cache entry expiration handling in ResolverCache - Improved the logic for handling expired cache entries by separating the removal process from the cache retrieval to avoid potential deadlocks. - Introduced a flag to indicate whether an expired entry should be removed, enhancing clarity in the cache management process. - Updated performance tests to ensure proper validation of cache behavior during TTL expiration, maintaining consistency in testing. * format * Implement comprehensive test improvements and reorganization plan - Introduced a new document outlining critical lessons learned from previous test management mistakes, emphasizing the importance of careful file handling and verification during test migrations. - Analyzed the current test structure and proposed a detailed migration plan to improve organization, maintainability, and performance across the Runar crates. - Established safe migration rules to prevent data loss and ensure successful test relocations, including moving fixtures to a centralized location and splitting mixed test files for clarity. - Updated various test files and structures to align with the new organization, enhancing clarity and reducing duplication. - Documented the expected issues and mitigation strategies related to API compatibility when moving tests between different compilation contexts. * Update request and publish method signatures to include options parameter - Modified multiple service and context methods to accept an additional `options` parameter, enhancing flexibility in request and publish operations. - Updated relevant calls throughout the codebase to accommodate the new method signatures, ensuring consistency and improved functionality. - Cleaned up formatting and organization of method definitions for better readability. * Update dependencies and enhance test structure - Added `tokio-test` as a development dependency to facilitate asynchronous testing. - Introduced `async-trait` to support async trait implementations in test utilities. - Created new test modules for improved organization, including comprehensive tests for `TopicPath` and `PathTrie`. - Updated existing tests to align with the new structure, ensuring better maintainability and clarity. - Documented recent API changes affecting migration patterns for method calls, enhancing migration guidance for developers. * format * Update request method signatures to include options parameter - Modified multiple service and test files to include an additional `options` parameter in request method calls, enhancing flexibility and consistency across the codebase. - Updated relevant tests to reflect the new method signatures, ensuring proper functionality and maintainability. - Cleaned up formatting for improved readability and organization of the code. * Refactor Clippy command handling and remove unused components - Documented critical issues with the main Clippy command not reporting `absolute_paths` violations, affecting PR verification. - Suggested solutions for CI/CD pipeline updates and wrapper script creation to ensure comprehensive Clippy checks. - Removed unused `LabelResolverConfig` references and related components from various files, streamlining the codebase. - Cleaned up test files by eliminating unnecessary parameters and improving organization for better maintainability. * Enhance code formatting guidelines and improve import organization - Updated the code formatting standards in `codeformat.mdc` to include checks for absolute paths and emphasized the use of IDE tools for code changes. - Improved import statements across multiple files for better clarity and organization, ensuring proper usage of modules and types. - Refactored `ArcValue` serialization and deserialization methods to utilize `serde_cbor` more effectively, enhancing overall code maintainability. - Streamlined the `ReplicationManager` and `QuicTransport` implementations by refining method calls and improving parameter handling for better consistency. * Refactor logging configuration and improve error handling in certificate module - Updated logging configuration to utilize `log::LevelFilter` directly, enhancing clarity and consistency in log level handling. - Refactored the `apply` method in `LoggingConfig` to streamline logger initialization and formatting. - Improved error handling in the certificate module by refining the conversion from various error types to `KeyError`, ensuring better error reporting. - Enhanced serialization and deserialization processes for `EcdsaKeyPair` and `X509Certificate` to utilize specific error types, improving maintainability and clarity. - Cleaned up import statements across multiple files for better organization and readability. * Refactor serialization and import statements for improved clarity and consistency - Replaced direct calls to `serde_json` with imported functions `from_str` and `to_string_pretty` for better readability in `NodeConfig`. - Updated `InitCommand` to utilize `to_vec` and `from_slice` from `serde_cbor`, enhancing serialization processes. - Improved import organization across multiple files, ensuring clarity and reducing redundancy. - Streamlined QR code rendering by using the imported `QrCode` type directly, simplifying the code structure. * Refactor import statements and method signatures for consistency and clarity - Consolidated import statements across multiple files to enhance organization and reduce redundancy. - Updated method signatures in various services to utilize the `OnOptions` type, improving flexibility in event handling. - Streamlined type aliases and removed unnecessary qualifiers for better readability. - Improved the handling of asynchronous tasks by using consistent patterns for spawning tasks and managing handles. * Integrate label resolver cache across core node and remote service layers - Replaced direct calls to `create_context_label_resolver` with `get_or_create_resolver` method utilizing the new `label_resolver_cache` for improved performance and concurrency. - Updated `Node` and `RemoteService` structures to include a shared `label_resolver_cache` instance, enhancing efficiency in resolver creation. - Refactored relevant methods to ensure consistent usage of the cache, resulting in significant performance improvements for request handling and serialization processes. - Cleaned up import statements and removed unused global cache functionality to streamline the codebase. * Enhance label resolver example with caching and performance statistics - Introduced a `ResolverCache` to improve performance by reusing label resolvers in the label resolver example. - Updated the example to demonstrate cache creation, usage, and statistics, showcasing cache hit functionality. - Refactored method calls to utilize the cache for both system and user context resolvers, enhancing efficiency. - Improved comments for clarity and updated the configuration validation to use `ConfigurableLabelResolver` directly. * Remove unused label resolver functionality from native APIs - Eliminated all references to label resolver functionality in the FFI and Node.js native APIs, including the removal of related struct fields, functions, and method signatures. - Updated TypeScript definitions to reflect the removal of the `setLabelMapping` method. - Cleaned up test cases to remove any dependencies on the now-removed label resolver functionality, ensuring tests focus on actual transport capabilities. - This change simplifies the API, reduces memory usage, and improves overall code clarity by removing dead code. * Update encryption tests to use network public key for envelope encryption - Modified comprehensive API and lifecycle tests to retrieve the network public key before encrypting data with an envelope, ensuring correct encryption behavior. - Updated error handling in the comprehensive API test to check for null manager type instead of 'network'. - Enhanced logging in lifecycle tests to include the size of the network public key for better debugging insights. * renamed ConfigurableLabelResolver to LabelResolver * chore * Update Transport class method signatures to accept arrays of public keys - Modified `completeRequest`, `request`, `requestToPublicKey`, `publish`, and `publishToPublicKey` methods to accept arrays of profile public keys and optional network public keys, enhancing flexibility in key management. - Updated TypeScript definitions and Rust implementation to reflect these changes, ensuring consistency across the API. - Adjusted related test cases to accommodate the new method signatures, improving overall test coverage and functionality. * Enhance transport methods to use CBOR serialization - Updated `rn_transport_request`, `rn_transport_publish`, and `rn_transport_complete_request` functions to accept CBOR serialized parameters, improving data handling and flexibility. - Introduced new parameter structs for request, publish, and complete request operations, ensuring clear and structured data representation. - Modified tests to create and validate CBOR parameters, enhancing test coverage and ensuring compatibility with the new serialization approach. - Added `serde` dependency with derive features for easier serialization and deserialization. * Remove unused methods from Transport class in TypeScript and Rust implementations - Eliminated `requestToPublicKey` and `publishToPublicKey` methods from the Transport class, simplifying the API and reducing redundancy. - Updated TypeScript definitions to reflect the removal of these methods, ensuring consistency across the codebase. - Adjusted related test cases to utilize the existing `request` and `publish` methods, maintaining functionality while improving clarity.
1 parent 1d572a8 commit aaf6f1b

File tree

113 files changed

+3764
-5205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+3764
-5205
lines changed

.cursor/rules/codeformat.mdc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,24 @@ run cargo clippy -p runar_node --all-targets --all-features -- -D warnings
1616
## 📝 **Code Quality Standards**
1717
- **Compilation**: `cargo check` must pass
1818
- **Clippy**: `cargo clippy --all-targets --all-features -- -D warnings` must pass
19+
- **Absolute Paths Check**: `cargo clippy --workspace -- -W clippy::absolute_paths` must pass
1920
- **Tests**: `cargo test --all` must pass
2021
- **Formatting**:
2122
- Use `format!("Error: {e}")` not `format!("Error: {}", e)` - run cargo fmt --all at the end of every task.
22-
- Use proper inmports, do not do let context = runar_serializer::SerializationContext {...} import the type and use let context = SerializationContext{...}
23+
- Use proper imports, do not do `let context = runar_serializer::SerializationContext {...}` import the type and use `let context = SerializationContext{...}`
2324

24-
ALWAYS RUN cargo fmt --all before u run cargo clippy --all-targets --all-features -- -D warnings .. to make sure code is properlyformated.
25+
**IMPORTANT: Use ONLY IDE tools for code changes**
26+
- **NO command line tools** (sed, grep, etc.)
27+
- **NO Python scripts**
28+
- **NO bulk find/replace operations**
29+
- **Change line by line** using IDE features
30+
- **If IDE tools fail repeatedly, stop and notify user to restart IDE**
31+
32+
ALWAYS RUN `cargo fmt --all` before running Clippy commands to ensure code is properly formatted.
33+
34+
**After implementing features, run BOTH Clippy commands:**
35+
1. `cargo clippy --workspace --all-targets --all-features -- -D warnings` (critical issues)
36+
2. `cargo clippy --workspace -- -W clippy::absolute_paths` (qualified path violations)
2537

2638
Always add timeout to test commands to make sure it does not run foerever incase of race conditionsn that makes teh code run indefinitvely.
2739

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

NODE_KEY_MANAGER_REDESIGN.md

Lines changed: 0 additions & 300 deletions
This file was deleted.

0 commit comments

Comments
 (0)