[PR #1843] [MERGED] Fix connection storage invariants #5313

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1843
Author: @cha1latte
Created: 6/1/2026
Status: ✅ Merged
Merged: 6/1/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1807-connection-storage-invariants


📝 Commits (1)

  • 5d8d9f1 Fix connection storage invariants

📊 Changes

3 files changed (+142 additions, -17 deletions)

View changed files

📝 src-tauri/src/commands/storage/commands/entities.rs (+134 -4)
📝 src-tauri/src/commands/storage/connection_secrets.rs (+2 -8)
📝 src-tauri/src/commands/storage/profile.rs (+6 -5)

📄 Description

Linked issue

Closes #1807

Why this change

  • Restores connection-specific storage invariants that generic refactor storage still missed: duplicated default connections could remain defaults, folder reorder accepted invalid lists, and profile export could expose raw connection API keys.

What changed

  • Masks connection secrets in profile export instead of materializing plaintext API keys.
  • Routes connection duplication through a connection-aware path that resets isDefault, default, and defaultForAgents while preserving encrypted secrets.
  • Validates connection folder reorder requests so every existing folder id appears exactly once before applying any order patches.
  • Adds Rust regression coverage for duplicate defaults, folder reorder validation, and masked profile export/import behavior.

Refactor impact

Primary owner:

Rust storage

Impact areas reviewed:

  • Connection create/update/read secret masking and runtime materialization
  • Connection duplicate command behavior
  • Connection folder delete/move/reorder behavior
  • Profile export/import connection handling

Boundary notes:

  • The fix stays in src-tauri storage/profile command code. Existing frontend hooks continue to call the storage and connection command wrappers.
  • Profile exports now preserve the fact that a key existed without exporting the key itself. Re-importing an exported profile requires re-entering provider API keys.

Pressure points touched:

  • Profile export/import connection collections
  • Generic storage duplicate command for connections
  • connection_folder_reorder

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • Codex reproduced the original failures with Rust command tests before the fix:
    • cargo test --manifest-path src-tauri\Cargo.toml duplicating_connection_resets_default_flags_and_keeps_secret_masked -- --nocapture failed because the duplicate retained isDefault: true.
    • cargo test --manifest-path src-tauri\Cargo.toml reordering_connection_folders_requires_each_folder_once -- --nocapture failed because duplicate folder ids were accepted and mutated order.
    • cargo test --manifest-path src-tauri\Cargo.toml profile_export_import_preserves_connection_folders -- --nocapture failed because profile export returned sk-export-secret as plaintext.
  • After the fix, cargo test --manifest-path src-tauri\Cargo.toml connection_ -- --nocapture passed: 28 passed.
  • After rebasing onto current upstream/refactor, pnpm check passed.
  • node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Manual note: because exported profiles no longer carry connection API key plaintext, importing an exported profile requires re-entering provider API keys. Before replacing profile data through import/export workflows, back up the active profile data/storage/connections.json and data/secrets/connection-master.key to a separate folder outside the active Marinara profile data directory.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • N/A; this is a storage/security parity bugfix and does not add a discoverable feature.

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 made. Release note may want to mention that profile export no longer includes provider API keys in plaintext.

UI evidence

N/A; this is a backend storage/profile command fix with Rust command proof and full pnpm check.


🔄 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/1843 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1807-connection-storage-invariants` --- ### 📝 Commits (1) - [`5d8d9f1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5d8d9f1676c9a3c55578f008efe6f96920eb3b47) Fix connection storage invariants ### 📊 Changes **3 files changed** (+142 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+134 -4) 📝 `src-tauri/src/commands/storage/connection_secrets.rs` (+2 -8) 📝 `src-tauri/src/commands/storage/profile.rs` (+6 -5) </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 #1807 ## Why this change <!-- What user problem, bug, refactor goal, or maintenance need does this solve? --> - Restores connection-specific storage invariants that generic refactor storage still missed: duplicated default connections could remain defaults, folder reorder accepted invalid lists, and profile export could expose raw connection API keys. ## What changed <!-- List the key changes in this PR. --> - Masks connection secrets in profile export instead of materializing plaintext API keys. - Routes connection duplication through a connection-aware path that resets `isDefault`, `default`, and `defaultForAgents` while preserving encrypted secrets. - Validates connection folder reorder requests so every existing folder id appears exactly once before applying any order patches. - Adds Rust regression coverage for duplicate defaults, folder reorder validation, and masked profile export/import behavior. ## 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 Impact areas reviewed: - Connection create/update/read secret masking and runtime materialization - Connection duplicate command behavior - Connection folder delete/move/reorder behavior - Profile export/import connection handling Boundary notes: <!-- Note engine/shared-api/feature/Rust/remote-runtime boundaries. Say "none" only if you checked. --> - The fix stays in `src-tauri` storage/profile command code. Existing frontend hooks continue to call the storage and connection command wrappers. - Profile exports now preserve the fact that a key existed without exporting the key itself. Re-importing an exported profile requires re-entering provider API keys. Pressure points touched: <!-- Mention ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules if touched. --> - Profile export/import connection collections - Generic storage duplicate command for `connections` - `connection_folder_reorder` ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes <!-- Describe exact commands and manual steps, including typecheck/build/docs/architecture/Rust/browser/remote-runtime checks when they apply. If an AI agent filled this out, verify it yourself before ticking boxes. --> - Codex reproduced the original failures with Rust command tests before the fix: - `cargo test --manifest-path src-tauri\Cargo.toml duplicating_connection_resets_default_flags_and_keeps_secret_masked -- --nocapture` failed because the duplicate retained `isDefault: true`. - `cargo test --manifest-path src-tauri\Cargo.toml reordering_connection_folders_requires_each_folder_once -- --nocapture` failed because duplicate folder ids were accepted and mutated order. - `cargo test --manifest-path src-tauri\Cargo.toml profile_export_import_preserves_connection_folders -- --nocapture` failed because profile export returned `sk-export-secret` as plaintext. - After the fix, `cargo test --manifest-path src-tauri\Cargo.toml connection_ -- --nocapture` passed: 28 passed. - After rebasing onto current `upstream/refactor`, `pnpm check` passed. - `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Manual note: because exported profiles no longer carry connection API key plaintext, importing an exported profile requires re-entering provider API keys. Before replacing profile data through import/export workflows, back up the active profile `data/storage/connections.json` and `data/secrets/connection-master.key` to a separate folder outside the active Marinara profile data directory. ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [ ] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - N/A; this is a storage/security parity bugfix and does not add a discoverable feature. ## 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 made. Release note may want to mention that profile export no longer includes provider API keys in plaintext. ## UI evidence <!-- Add before/after screenshots or recordings for visible UI changes. --> N/A; this is a backend storage/profile command fix with Rust command proof and full `pnpm check`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15:09 +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#5313
No description provided.