fix(cloud): shed corrupt store entries instead of resetting whole stores - #698
Merged
Merged
Conversation
createZodJsonStorage answers a failed whole-store parse with the initial value. For the cloud push planes' record-shaped stores that turned one corrupted entry into a fleet-scale event at load: - accessSettings reset drops every explicit per-session override; the next pass resolves previously shared sessions effective-off and RETRACTS their cloud rows — one corrupted byte silently unshares the user's work. - sessionOrgTags had no validation at all (default JSON storage), and a reset makes the ownership gate retract every explicitly moved session's row. - repoScopes/syncEnabled/pushedMetadata/collabStateCursors resets re-enable disabled orgs, orphan metadata rows, or widen deltas. A shared tolerantRecordSchema now parses record entries independently and drops only invalid ones (nested for accessSettings, so a corrupt session entry costs that session, not its org). The push-cursor store's inline transform from the incremental-replay work migrates to the same helper. A non-record root still falls back to the initial value — that is unrecoverable garbage, not a partial loss. Pre-commit hook ran. Total eslint: 58, total circular: 0
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.
Problem
createZodJsonStorageanswers a failed whole-store parse with the initial value. Every record-shaped cloud store therefore converted ONE corrupted entry (disk damage, or a future entry shape rolled back onto an older build) into a whole-store reset at load, and several of those resets are destructive at fleet scale:Solution
A shared
tolerantRecordSchema(label, valueSchema)in zodStorage parses record entries independently and drops only invalid ones, warning per dropped key. Applied to all seven stores; accessSettings gets it at every nesting level, so a corrupt session-mode entry costs that one session's override, not the org. A non-record root still falls back to the initial value — that is unrecoverable garbage rather than partial loss, and the two behaviors are asserted separately.Verification
createZodJsonStorage), accessSettings nested shedding (corrupt org entry + corrupt session entry inside a healthy org), and the existing fix(cloud): incrementally replay imported histories #692 cursor tests keep passing against the migrated helper.pnpm vitest runover storage utils + Org2Cloud + TeamCollaboration: 20 files / 314 tests green.pnpm typecheck— clean.