-
-
Notifications
You must be signed in to change notification settings - Fork 1
Extensible Storage #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Claude finished @muukii's task —— View job PR Review: Extensible StorageI've completed a comprehensive review of this PR introducing extensible storage functionality. Here are my findings: Review Tasks
🚨 Critical Issues1. Build Failure - Blocking IssueThe project currently fails to build due to incomplete code in protocol StorageDescriptor {
func makeStorage<Value>(initialValue: Value) -> Storage // ❌ Should be 'any Storage'
}
extension StorageDescriptor {
struct InMemory: StorageDescriptor { // ❌ Cannot nest types in protocol extensions
func makeStorage<Value>(initialValue: Value) -> InMemoryStorage<Value> {
// ❌ Empty implementation
}
}
struct InMemoryStorage<Value> { // ❌ Cannot nest in protocol extension
// ❌ Empty struct
}
}
final class MyStorage<Value, S: StorageDescriptor> { // ❌ No initializers
var value: Value // ❌ Uninitialized stored property
}Required Actions:
🏗️ Architecture AnalysisPositive Changes
Potential Improvements
🔍 Code Quality Issues1. UserDefaultsStorage Thread Safety (Storage.swift:85-160)public final class UserDefaultsStorage<Value: UserDefaultsStorable>: Storage, Sendable {
nonisolated(unsafe) private var subscription: NSObjectProtocol? // ⚠️ Potential race condition
nonisolated(unsafe) private var cachedValue: Value? // ⚠️ Potential race condition
nonisolated(unsafe) private var previousValue: Value? // ⚠️ Potential race condition
Issues:
Recommendation: Use actor isolation or explicit locking for mutable properties. 2. Memory Leak Risk (Storage.swift:151-153)subscription = NotificationCenter.default.addObserver(
forName: UserDefaults.didChangeNotification,
object: userDefaults,
queue: nil,
using: { [weak self] _ in // ✅ Good weak capture
// ... but potential issues with context capture
context.notifyStorageUpdated() // ⚠️ Context captured in closure
}
)The 3. Macro Implementation Complexity (UnifiedStoredMacro.swift)The macro implementation is comprehensive but has some concerns:
🧪 Test Coverage AnalysisStrengths
Missing Coverage
⚡ Performance ConsiderationsPositive
Concerns
Recommendation: Consider key-specific notifications or more selective cache invalidation. 🔒 Security ConsiderationsLow Risk Items Identified
Recommendation: Add basic validation for suite names and keys. 📚 Documentation AssessmentThe new documentation in
🏁 Final RecommendationsMust Fix Before Merge
Should Fix
Consider for Future
SummaryThis PR introduces a well-designed storage abstraction with good API ergonomics. However, the build failures and thread safety issues need to be addressed before merging. The architecture is solid and the new syntax is a significant improvement over the previous macro-based approach. |
No description provided.