[GH-ISSUE #1895] [Issue]: remote storage writes bypass embedded connection and chat preset guards #918

Closed
opened 2026-10-21 05:23:32 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Xelvanis on GitHub (Jun 2, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1895

Originally assigned to: @Promansis on GitHub.

Summary

The remote /api/invoke storage write path duplicates embedded storage command logic and misses side effects/guards for some entities. Connection writes can skip the single-default cleanup for defaultForAgents, and remote chat preset updates can bypass the embedded guard that blocks mutating default presets.

Expected behavior

Embedded Tauri storage commands and hostable /api/invoke storage commands should enforce the same write behavior:

  • creating or updating a connection with defaultForAgents: true should clear other default agent connections in the same language/image scope
  • updating a default chat preset should return the same protected-preset error as the embedded command when the patch mutates protected default fields

Actual behavior

Static inspection shows the embedded path and remote path diverge:

  • embedded storage_create calls clear_other_default_agent_connections after creating connections
  • embedded storage_update routes chat-presets through patch_chat_preset and calls clear_other_default_agent_connections after updating connections
  • remote storage_create creates connections and masks secrets, but does not clear other default agent connections
  • remote storage_update handles connections directly through connection_secrets::patch_connection and otherwise falls through to generic state.storage.patch, with no chat-presets default-preset guard

Steps to reproduce

  1. Run through the remote runtime /api/invoke path.
  2. Create or update one language-model connection with defaultForAgents: true.
  3. Create or update a second language-model connection with defaultForAgents: true.
  4. List connections and compare against embedded Tauri behavior.
  5. Separately, call remote storage_update on a default chat-presets record with a patch that mutates protected default fields.

Expected: remote behavior matches embedded behavior.
Actual from code inspection: the remote path can leave multiple default agent connections and can route default chat preset updates through the generic patch path.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: current refactor checkout during storage parity review
  • Run mode: remote runtime / /api/invoke
  • OS + version: not captured
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not captured
  • Remote Runtime URL configured? yes
  • Provider, model, or integration, if relevant: connections and chat presets

Logs, screenshots, or video

No runtime screenshot attached. Static evidence:

  • src-tauri/src/commands/storage/commands/entities.rs: embedded storage_create_inner clears other default agent connections for connections.
  • src-tauri/src/commands/storage/commands/entities.rs: embedded storage_update_inner routes chat-presets through patch_chat_preset and clears other default agent connections after connection updates.
  • src-tauri/src/http_dispatch.rs: remote storage_create and storage_update duplicate the write path and do not call those embedded helpers.

Regression notes

This is current refactor hostable-runtime drift. The matching storage_list drift is already tracked separately in #1885 and PR #1890; this issue covers write-path side effects and guards.

Additional context

Suggested fix: route remote storage writes through shared command helpers or extract the embedded side-effect/guard logic into functions used by both embedded and remote dispatch. Add focused Rust coverage for:

  • remote connection create/update clears previous defaultForAgents for the same scope
  • remote default chat preset update returns the same protected-preset error as embedded storage_update

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Jun 2, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1895 Originally assigned to: @Promansis on GitHub. ## Summary The remote `/api/invoke` storage write path duplicates embedded storage command logic and misses side effects/guards for some entities. Connection writes can skip the single-default cleanup for `defaultForAgents`, and remote chat preset updates can bypass the embedded guard that blocks mutating default presets. ## Expected behavior Embedded Tauri storage commands and hostable `/api/invoke` storage commands should enforce the same write behavior: - creating or updating a connection with `defaultForAgents: true` should clear other default agent connections in the same language/image scope - updating a default chat preset should return the same protected-preset error as the embedded command when the patch mutates protected default fields ## Actual behavior Static inspection shows the embedded path and remote path diverge: - embedded `storage_create` calls `clear_other_default_agent_connections` after creating `connections` - embedded `storage_update` routes `chat-presets` through `patch_chat_preset` and calls `clear_other_default_agent_connections` after updating `connections` - remote `storage_create` creates `connections` and masks secrets, but does not clear other default agent connections - remote `storage_update` handles `connections` directly through `connection_secrets::patch_connection` and otherwise falls through to generic `state.storage.patch`, with no `chat-presets` default-preset guard ## Steps to reproduce 1. Run through the remote runtime `/api/invoke` path. 2. Create or update one language-model connection with `defaultForAgents: true`. 3. Create or update a second language-model connection with `defaultForAgents: true`. 4. List connections and compare against embedded Tauri behavior. 5. Separately, call remote `storage_update` on a default `chat-presets` record with a patch that mutates protected default fields. Expected: remote behavior matches embedded behavior. Actual from code inspection: the remote path can leave multiple default agent connections and can route default chat preset updates through the generic patch path. ## Impact area - [ ] App shell, navigation, startup, or providers - [x] Catalog resources - [ ] Chat mode - [ ] Roleplay mode - [ ] Game mode - [ ] Shared mode UI - [ ] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [ ] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: current refactor checkout during storage parity review - Run mode: remote runtime / `/api/invoke` - OS + version: not captured - Node + pnpm versions: not relevant - Rust version, if relevant: not captured - Remote Runtime URL configured? yes - Provider, model, or integration, if relevant: connections and chat presets ## Logs, screenshots, or video No runtime screenshot attached. Static evidence: - `src-tauri/src/commands/storage/commands/entities.rs`: embedded `storage_create_inner` clears other default agent connections for `connections`. - `src-tauri/src/commands/storage/commands/entities.rs`: embedded `storage_update_inner` routes `chat-presets` through `patch_chat_preset` and clears other default agent connections after connection updates. - `src-tauri/src/http_dispatch.rs`: remote `storage_create` and `storage_update` duplicate the write path and do not call those embedded helpers. ## Regression notes This is current refactor hostable-runtime drift. The matching `storage_list` drift is already tracked separately in #1885 and PR #1890; this issue covers write-path side effects and guards. ## Additional context Suggested fix: route remote storage writes through shared command helpers or extract the embedded side-effect/guard logic into functions used by both embedded and remote dispatch. Add focused Rust coverage for: - remote connection create/update clears previous `defaultForAgents` for the same scope - remote default chat preset update returns the same protected-preset error as embedded `storage_update` ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:23:32 +07:00
Author
Owner

@Xelvanis commented on GitHub (Jun 2, 2026):

Storage/data-access parity follow-up from current origin/refactor:

This appears fixed by #1906 on the current refactor branch. src-tauri/src/http_dispatch.rs now routes remote storage_get, storage_create, and storage_update through the same storage entity helpers used by embedded Tauri commands, instead of keeping the older duplicated write path.

Current local proof:

  • cargo test --manifest-path src-tauri/Cargo.toml dispatch_storage_
  • Result: 7 passed, 0 failed.
  • Covered cases include projected remote storage list reads, connection defaultForAgents cleanup on create/update, and default chat preset mutation protection.

I did not close this from the parity scan. It looks ready for maintainer closure or fixed-in-refactor marking unless there is separate runtime evidence still failing after #1906.

<!-- gh-comment-id:4600501894 --> @Xelvanis commented on GitHub (Jun 2, 2026): Storage/data-access parity follow-up from current `origin/refactor`: This appears fixed by #1906 on the current refactor branch. `src-tauri/src/http_dispatch.rs` now routes remote `storage_get`, `storage_create`, and `storage_update` through the same storage entity helpers used by embedded Tauri commands, instead of keeping the older duplicated write path. Current local proof: - `cargo test --manifest-path src-tauri/Cargo.toml dispatch_storage_` - Result: 7 passed, 0 failed. - Covered cases include projected remote storage list reads, connection `defaultForAgents` cleanup on create/update, and default chat preset mutation protection. I did not close this from the parity scan. It looks ready for maintainer closure or fixed-in-refactor marking unless there is separate runtime evidence still failing after #1906.
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#918
No description provided.