[PR #1313] [MERGED] Fix import rollback on failed writes #5032

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/refactor-issue-1250-import-rollbacks


📝 Commits (1)

  • ae52b94 Fix import rollback on failed writes

📊 Changes

4 files changed (+713 additions, -217 deletions)

View changed files

📝 src-tauri/src/commands/storage/imports/bulk_imports.rs (+289 -46)
➕ src-tauri/src/commands/storage/imports/rollback.rs (+118 -0)
📝 src-tauri/src/commands/storage/imports/service.rs (+117 -171)
➕ src-tauri/src/commands/storage/imports/service_tests.rs (+189 -0)

📄 Description

Linked issue

Closes #1250

Why this change

  • Failed direct/ST import paths could create storage rows, managed avatar files, or target chat patches before a later import write failed, leaving partial imported state behind.

What changed

  • Added rollback helpers for imported storage rows, lorebook trees, and managed avatar files.
  • Wrapped direct ST lorebook/character imports, ST chat/branch imports, and persona avatar import writes so later failures undo earlier writes.
  • Moved ST character import tests out of the oversized service module and added failure-injection regression tests for the covered rollback paths.

Refactor impact

Primary owner:

Rust storage/imports

Impact areas reviewed:

  • Tauri/Rust import paths
  • FileStorage JSON collections
  • Managed avatar files under avatars/characters and avatars/personas

Boundary notes:

  • Stays inside Rust import/storage command code.
  • No schema, dependency, auth, prompt-pipeline, remote-runtime, release, or UI changes.

Pressure points touched:

  • src-tauri/src/commands/storage/imports/service.rs
  • src-tauri/src/commands/storage/imports/bulk_imports.rs
  • New focused rollback/test modules under src-tauri/src/commands/storage/imports/

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

Manual verification notes

  • Codex machine verification: cargo test storage_commands::imports passed 14 Rust import tests, including failure-injection rows for lorebook parent rollback, character/avatar embedded-lorebook rollback, chat rollback, group branch target restoration, existing group preservation, and persona avatar rollback.
  • Codex machine verification: pnpm check passed architecture, frontend TypeScript, Rust cargo check workspace, and docs checks.
  • Codex proof gate: node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Repo-doc mismatch: pnpm db:push is not present in this refactor worktree, so no DB push command was available to run.
  • Manual human verification available but not required for the core claim: try a real failed direct import and failed ST bulk import in the Tauri app if you want end-to-end UI confidence beyond the Rust storage harness.

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

UI evidence

N/A - non-UI Rust storage/import rollback fix. Machine proof is in the Rust import tests and proof ledger.


🔄 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/1313 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/26/2026 **Status:** ✅ Merged **Merged:** 5/26/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/refactor-issue-1250-import-rollbacks` --- ### 📝 Commits (1) - [`ae52b94`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ae52b94aa9e950f973d030535a5c62e4fd3de9b6) Fix import rollback on failed writes ### 📊 Changes **4 files changed** (+713 additions, -217 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/imports/bulk_imports.rs` (+289 -46) ➕ `src-tauri/src/commands/storage/imports/rollback.rs` (+118 -0) 📝 `src-tauri/src/commands/storage/imports/service.rs` (+117 -171) ➕ `src-tauri/src/commands/storage/imports/service_tests.rs` (+189 -0) </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 <!-- Every user-facing PR should reference a feature request or issue report when practical. --> Closes #1250 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Failed direct/ST import paths could create storage rows, managed avatar files, or target chat patches before a later import write failed, leaving partial imported state behind. ## What changed <!-- List the key changes in this PR. --> - Added rollback helpers for imported storage rows, lorebook trees, and managed avatar files. - Wrapped direct ST lorebook/character imports, ST chat/branch imports, and persona avatar import writes so later failures undo earlier writes. - Moved ST character import tests out of the oversized service module and added failure-injection regression tests for the covered rollback paths. ## Refactor impact Primary owner: <!-- Examples: app shell, catalog, chat mode, roleplay mode, game mode, runtime generation, world-state, shared API, engine generation, Rust storage, imports, remote runtime. --> Rust storage/imports Impact areas reviewed: - Tauri/Rust import paths - FileStorage JSON collections - Managed avatar files under `avatars/characters` and `avatars/personas` Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - Stays inside Rust import/storage command code. - No schema, dependency, auth, prompt-pipeline, remote-runtime, release, or UI changes. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - `src-tauri/src/commands/storage/imports/service.rs` - `src-tauri/src/commands/storage/imports/bulk_imports.rs` - New focused rollback/test modules under `src-tauri/src/commands/storage/imports/` ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] `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 ### Manual verification notes <!-- Describe exactly what you tested in a real browser/app/runtime, step by step. If an AI agent filled this out, verify it yourself before ticking boxes. --> - Codex machine verification: `cargo test storage_commands::imports` passed 14 Rust import tests, including failure-injection rows for lorebook parent rollback, character/avatar embedded-lorebook rollback, chat rollback, group branch target restoration, existing group preservation, and persona avatar rollback. - Codex machine verification: `pnpm check` passed architecture, frontend TypeScript, Rust cargo check workspace, and docs checks. - Codex proof gate: `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Repo-doc mismatch: `pnpm db:push` is not present in this refactor worktree, so no DB push command was available to run. - Manual human verification available but not required for the core claim: try a real failed direct import and failed ST bulk import in the Tauri app if you want end-to-end UI confidence beyond the Rust storage harness. ## 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 ## UI evidence <!-- Add before/after screenshots or recordings for visible UI changes. --> N/A - non-UI Rust storage/import rollback fix. Machine proof is in the Rust import tests and proof ledger. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:12:38 +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#5032
No description provided.