Skip to content

feat(storage): add schema downgrade guard#920

Closed
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/schema-downgrade-detection
Closed

feat(storage): add schema downgrade guard#920
luoye520ww wants to merge 1 commit into
KunAgent:developfrom
luoye520ww:codex/schema-downgrade-detection

Conversation

@luoye520ww

Copy link
Copy Markdown
Collaborator

Problem

Older application versions must not silently write data created by a newer schema, while users still need a safe read-only view and export path.

Scope

This PR adds only a pure schema compatibility decision contract and tests. It does not change persisted formats, migrations, startup wiring, or UI.

Changes

  • Allow read/write only when stored and supported versions match.
  • Force newer data into read-only mode with export available.
  • Require migration before writing older data.
  • Fail closed for invalid versions, null input, and unknown fields.

Validation

pm.cmd exec vitest run src/main/services/schema-downgrade-guard.test.ts (3 passed)

pm.cmd run typecheck (passed)

pm.cmd --prefix kun run typecheck (passed)

pm.cmd run lint (passed)

pm.cmd run build (passed)

  • git diff --check (passed)

Review

Completed functional, lifecycle, data integrity, security, cross-platform, compatibility, test quality, and scope review. The guard never mutates persisted data.

Follow-ups

Startup read-only mode, export wiring, and migration execution belong in separate PRs.

@luoye520ww

Copy link
Copy Markdown
Collaborator Author

This work is consolidated into #942, which combines the Thread Store Doctor, bounded backups, and schema write guard with one tested scope. Closing the duplicate to keep review focused.

@luoye520ww luoye520ww closed this Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant