[PR #1679] [MERGED] Harden refactor storage imports #5207

Closed
opened 2026-10-22 04:14:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1679
Author: @cha1latte
Created: 5/30/2026
Status: ✅ Merged
Merged: 5/30/2026
Merged by: @cha1latte

Base: refactor ← Head: codex/refactor-storage-safety


📝 Commits (1)

  • 0a838a8 Harden refactor storage imports

📊 Changes

9 files changed (+878 additions, -355 deletions)

View changed files

📝 src-tauri/src/commands/storage/imports/access.rs (+24 -2)
📝 src-tauri/src/commands/storage/imports/bulk_imports.rs (+52 -6)
📝 src-tauri/src/commands/storage/imports/marinara.rs (+288 -342)
➕ src-tauri/src/commands/storage/imports/marinara_assets.rs (+125 -0)
➕ src-tauri/src/commands/storage/imports/marinara_rollback.rs (+146 -0)
📝 src-tauri/src/commands/storage/imports/marinara_tests.rs (+82 -0)
📝 src-tauri/src/commands/storage/profile.rs (+134 -0)
📝 src-tauri/src/commands/storage/profile/assets.rs (+25 -4)
📝 src-tauri/src/commands/storage/profile/zip_import.rs (+2 -1)

📄 Description



Linked issue

N/A - refactor readiness blocker found during boundary/data-contract review.

Why this change

Storage/import behavior is a high-risk refactor boundary because profile imports, ST imports, managed assets, and generic Marinara imports can affect existing user data. The review found cases where missing current-profile collections or assets could be treated like empty replacement data, ST import selection trusted client-provided picker state, and nested generic imports could leave partial records behind after a failure.

What changed

  • Reject incomplete current profile imports before replacing existing rows or managed assets.
  • Preserve existing managed assets when importing legacy profiles without asset manifests.
  • Add rollback coverage for collection replacement plus asset install failures.
  • Stop treating client pickerSelected as unrestricted directory access for ST bulk import.
  • Reject empty or invalid ST chat JSONL before creating chats while preserving upstream Marinara JSONL role and character-id handling.
  • Roll back nested Marinara preset/lorebook imports when child entry/group creation fails.
  • Split Marinara import asset/rollback helpers out of the large import module.

Refactor impact

Primary owner:

Rust storage and imports.

Impact areas reviewed:

  • Profile import/export safety.
  • Managed asset restore behavior.
  • SillyTavern bulk import access and chat JSONL handling.
  • Generic Marinara preset/lorebook import rollback.

Boundary notes:

  • Keeps destructive storage behavior inside src-tauri.
  • Does not move product behavior into React or src/shared/api.
  • Uses Rust-side validation and rollback instead of UI-only guards or fake success.

Pressure points touched:

  • src-tauri/src/commands/storage/profile.rs
  • src-tauri/src/commands/storage/profile/assets.rs
  • src-tauri/src/commands/storage/imports/bulk_imports.rs
  • src-tauri/src/commands/storage/imports/marinara.rs

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Codex-run proof:

  • pnpm check passed in scratch/refactor-lane-worktrees/storage.
  • cargo test --manifest-path src-tauri\Cargo.toml bulk_imports passed: 10 tests.
  • cargo test --manifest-path src-tauri\Cargo.toml marinara::tests passed: 7 tests.
  • cargo test --manifest-path src-tauri\Cargo.toml profile passed: 38 tests.
  • cargo check --manifest-path src-tauri\Cargo.toml passed.
  • git diff --check upstream/refactor...HEAD passed.
  • Bunny pre-PR review pass: no blocking findings; remaining risk is manual review of real user backup/export data samples outside these unit-level fixtures.

Manual verification notes

  • Human reviewer should inspect whether the stricter current-profile import rejection is acceptable UX for incomplete exports.
  • No real user profile archive was imported through the desktop UI in this pass.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

No docs changes included. This is a storage/import safety lane only.

UI evidence

N/A - storage/import behavior only; no visible UI changes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/1679 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `codex/refactor-storage-safety` --- ### 📝 Commits (1) - [`0a838a8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0a838a88735ecb57d432b20ee44171cf75606e09) Harden refactor storage imports ### 📊 Changes **9 files changed** (+878 additions, -355 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/imports/access.rs` (+24 -2) 📝 `src-tauri/src/commands/storage/imports/bulk_imports.rs` (+52 -6) 📝 `src-tauri/src/commands/storage/imports/marinara.rs` (+288 -342) ➕ `src-tauri/src/commands/storage/imports/marinara_assets.rs` (+125 -0) ➕ `src-tauri/src/commands/storage/imports/marinara_rollback.rs` (+146 -0) 📝 `src-tauri/src/commands/storage/imports/marinara_tests.rs` (+82 -0) 📝 `src-tauri/src/commands/storage/profile.rs` (+134 -0) 📝 `src-tauri/src/commands/storage/profile/assets.rs` (+25 -4) 📝 `src-tauri/src/commands/storage/profile/zip_import.rs` (+2 -1) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue N/A - refactor readiness blocker found during boundary/data-contract review. ## Why this change Storage/import behavior is a high-risk refactor boundary because profile imports, ST imports, managed assets, and generic Marinara imports can affect existing user data. The review found cases where missing current-profile collections or assets could be treated like empty replacement data, ST import selection trusted client-provided picker state, and nested generic imports could leave partial records behind after a failure. ## What changed - Reject incomplete current profile imports before replacing existing rows or managed assets. - Preserve existing managed assets when importing legacy profiles without asset manifests. - Add rollback coverage for collection replacement plus asset install failures. - Stop treating client `pickerSelected` as unrestricted directory access for ST bulk import. - Reject empty or invalid ST chat JSONL before creating chats while preserving upstream Marinara JSONL role and character-id handling. - Roll back nested Marinara preset/lorebook imports when child entry/group creation fails. - Split Marinara import asset/rollback helpers out of the large import module. ## Refactor impact Primary owner: Rust storage and imports. Impact areas reviewed: - Profile import/export safety. - Managed asset restore behavior. - SillyTavern bulk import access and chat JSONL handling. - Generic Marinara preset/lorebook import rollback. Boundary notes: - Keeps destructive storage behavior inside `src-tauri`. - Does not move product behavior into React or `src/shared/api`. - Uses Rust-side validation and rollback instead of UI-only guards or fake success. Pressure points touched: - `src-tauri/src/commands/storage/profile.rs` - `src-tauri/src/commands/storage/profile/assets.rs` - `src-tauri/src/commands/storage/imports/bulk_imports.rs` - `src-tauri/src/commands/storage/imports/marinara.rs` ## Validation - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant Codex-run proof: - `pnpm check` passed in `scratch/refactor-lane-worktrees/storage`. - `cargo test --manifest-path src-tauri\Cargo.toml bulk_imports` passed: 10 tests. - `cargo test --manifest-path src-tauri\Cargo.toml marinara::tests` passed: 7 tests. - `cargo test --manifest-path src-tauri\Cargo.toml profile` passed: 38 tests. - `cargo check --manifest-path src-tauri\Cargo.toml` passed. - `git diff --check upstream/refactor...HEAD` passed. - Bunny pre-PR review pass: no blocking findings; remaining risk is manual review of real user backup/export data samples outside these unit-level fixtures. ### Manual verification notes - Human reviewer should inspect whether the stricter current-profile import rejection is acceptable UX for incomplete exports. - No real user profile archive was imported through the desktop UI in this pass. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims No docs changes included. This is a storage/import safety lane only. ## UI evidence N/A - storage/import behavior only; no visible UI changes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:14:14 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5207
No description provided.