Persistent photo cache for chat attachments#510
Conversation
|
Claude finished @yewreeka's task —— View job Review of PR #510: Persistent Photo Cache DesignTasks
Overall AssessmentThis is a well-designed solution that addresses the core problem elegantly. The two-tier storage model is the right approach, and the design document is clear and comprehensive. Below are specific observations organized by review criteria. 1. Design Quality & Best PracticesStrengths:
Suggestions:
2. Potential IssuesCritical Issues:1. Missing attachment key collection before message deletion In try DBMessage.filter(DBMessage.Columns.conversationId == conversationId).deleteAll(db)The design document proposes collecting attachment keys before deletion at line 72-78, but the current Recommendation: The implementation PR must modify
2. Potential race condition during "Delete All Data" The design states: "The app's 'Delete All Data' flow already calls Recommendation: Ensure 3. Identifier scheme not fully specified Line 35 states: "The identifier is the attachment key (either the local URL string for outgoing, or the stored remote attachment JSON hash for incoming)." This is vague. The implementation needs a concrete identifier scheme:
Recommendation: Add a subsection defining the exact identifier format, or reference where this is already defined in the codebase (e.g., in Moderate Issues:4. No size limits on persistent storage Line 98 acknowledges this risk: "Persistent photos accumulate without a size cap." The mitigation relies on "cleanup on delete/explode" and the 30-day S3 lifecycle window. Concern: Power users with many conversations could accumulate hundreds of MB of photos over time. If they rarely delete conversations, this could grow unbounded. Recommendation: Consider adding observability (e.g., log total persistent storage size periodically) or a future enhancement for a soft cap with user notification when exceeded. 5. Missing migration strategy for edge case Line 91 states: "Migration of existing cached attachments (photos have not shipped to the App Store yet...)" However, internal builds already have photos in the evictable cache pool ( Recommendation: Add a one-time migration in
Alternatively, explicitly accept this as tech debt and document it in the "Out of scope" section. 3. Performance ConsiderationsStrengths:
Concern:
Recommendation: Use a more efficient query that projects only the let attachmentKeys = try String
.fetchAll(db, sql: """
SELECT attachmentKey FROM DBMessage
WHERE conversationId = ? AND attachmentKey IS NOT NULL
""", arguments: [conversationId])Or use GRDB's let attachmentKeys = try DBMessage
.select(DBMessage.Columns.attachmentKey)
.filter(DBMessage.Columns.conversationId == conversationId)
.filter(DBMessage.Columns.attachmentKey != nil)
.fetchAll(db)4. Security ConcernsStrengths:
Concerns: 1. Backup implications
Recommendation: Consider marking the var resourceValues = URLResourceValues()
resourceValues.isExcludedFromBackup = true
try photoStoreURL.setResourceValues(resourceValues)Document this decision in the design (either way). 2. No explicit file permissions The design doesn't mention file permissions for the persistent storage directory. Recommendation: Ensure the implementation sets appropriate file protection (e.g., 5. Test Coverage RequirementsThe design document doesn't include a testing strategy. For implementation, I recommend: Unit Tests:
Integration Tests:
Filesystem Tests:
6. Additional ObservationsDocumentation:
API Naming:
Future Enhancements:
SummaryThis is a solid, well-thought-out design that solves the problem with minimal API changes and good separation of concerns. The main action items for implementation are:
Overall, I'd approve this design with the understanding that the critical issues above will be addressed during implementation. Great work! 🚀 |
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merge activity
|
<!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> ### Add design for persistent photo cache for chat attachments in [persistent-photo-cache.md](https://github.com/xmtplabs/convos-ios/pull/510/files#diff-f896f93be70e32de591559d1156d767f50777e5c8597e913f4a3e4afe8d0d15c) Introduce a planning document detailing a two-tier disk storage model, `ImageCache` API changes with `ImageStorageTier`, new cache/remove methods accepting a storage tier, and cleanup behavior on conversation delete/explode in [persistent-photo-cache.md](https://github.com/xmtplabs/convos-ios/pull/510/files#diff-f896f93be70e32de591559d1156d767f50777e5c8597e913f4a3e4afe8d0d15c). #### 📍Where to Start Start with the design overview in [persistent-photo-cache.md](https://github.com/xmtplabs/convos-ios/pull/510/files#diff-f896f93be70e32de591559d1156d767f50777e5c8597e913f4a3e4afe8d0d15c). <!-- Macroscope's review summary starts here --> <sup><a href="https://app.macroscope.com">Macroscope</a> summarized a86fbd5.</sup> <!-- Macroscope's review summary ends here --> <!-- Macroscope's pull request summary ends here -->
a86fbd5 to
dbbbfe7
Compare

Add design for persistent photo cache for chat attachments in persistent-photo-cache.md
Introduce a planning document detailing a two-tier disk storage model,
ImageCacheAPI changes withImageStorageTier, new cache/remove methods accepting a storage tier, and cleanup behavior on conversation delete/explode in persistent-photo-cache.md.📍Where to Start
Start with the design overview in persistent-photo-cache.md.
Macroscope summarized dbbbfe7.