[GH-ISSUE #1919] [Issue]: projected storage_get still reads full row before projection #936

Closed
opened 2026-10-21 05:23:48 +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/1919

Originally assigned to: @Xelvanis on GitHub.

Summary

storage_get accepts fields and fieldSelections, and several current callers use projected gets, but the Rust command path reads the full matched row before applying projection. Large character rows can still pay the full row parse/read cost even when the caller only asks for a narrow field subset.

Expected behavior

Projected storage_get calls should either push projection into the storage read path or make the contract clear that projection only trims the returned payload after a full row read. For hot resource reads, the preferred behavior is a narrow get_projected storage path that keeps embedded Tauri and remote /api/invoke behavior identical.

Actual behavior

Static inspection on current origin/refactor shows storage_get_inner calling state.storage.get(&entity, &id) and then applying shared::project_record(...) afterward. The storage crate has projected list readers, but the public get path has no projection parameters and returns the full matching record before command-level projection.

Steps to reproduce

  1. Use a populated character collection with large data, avatar, prompt, or extension fields.
  2. Trigger a projected get path, such as character summary by id, greeting lookup, generation character-name lookup, or tracker color persistence.
  3. Compare the storage path against projected storage_list: storage_get still performs a full matched-row read before projection.

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: origin/refactor at 3e05c12b
  • Run mode: Tauri desktop and remote /api/invoke share the same storage helper
  • OS + version: not captured
  • Node + pnpm versions: not relevant
  • Rust version, if relevant: not captured
  • Remote Runtime URL configured? not relevant for the static path check
  • Provider, model, or integration, if relevant: not relevant

Logs, screenshots, or video

No runtime screenshot attached. Static evidence:

  • src-tauri/src/commands/storage/commands/entities.rs:247-261: storage_get_inner validates the entity, calls state.storage.get(&entity, &id), then applies shared::project_record(...).
  • src-tauri/crates/storage/src/lib.rs:54-63: list_projected accepts projection fields and nested selections.
  • src-tauri/crates/storage/src/lib.rs:111-115: get has no projection parameters.
  • src-tauri/crates/storage/src/lib.rs:550-592: the id lookup returns the full matching row.
  • Current projected get callers include src/features/catalog/characters/hooks/use-characters.ts:129, src/features/shell/bot-browser/components/BotBrowserPanel.tsx:86, src/features/runtime/generation/hooks/use-generate.ts:516, and src/features/runtime/tracker/hooks/use-tracker-card-color-manager.ts:166.

Regression notes

Adjacent closed issues are not duplicates:

  • #1887 fixed cold storage_get lookup cost for non-matching rows by adding a pretty-file id fast path.
  • #1888 fixed projected message storage_list reads.
  • #1885 tracked repeated storage_list slowdown and already has a broader storage timing-harness note.

This issue covers the remaining storage_get projection gap: once the target id is found, the matched row is still read as a full row before projection. This is static parity evidence, not a measured runtime timing repro yet.

Additional context

Suggested follow-up:

  • Add a focused cold/warm timing harness around projected character storage_get with large rows.
  • If the timing gap is real, add a storage-level get_projected path and route storage_get options through it.
  • Preserve existing message materialization and connection secret masking semantics after the narrow read path.

Related tracker: #1904 target 2, storage and data access.

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/1919 Originally assigned to: @Xelvanis on GitHub. ## Summary `storage_get` accepts `fields` and `fieldSelections`, and several current callers use projected gets, but the Rust command path reads the full matched row before applying projection. Large character rows can still pay the full row parse/read cost even when the caller only asks for a narrow field subset. ## Expected behavior Projected `storage_get` calls should either push projection into the storage read path or make the contract clear that projection only trims the returned payload after a full row read. For hot resource reads, the preferred behavior is a narrow `get_projected` storage path that keeps embedded Tauri and remote `/api/invoke` behavior identical. ## Actual behavior Static inspection on current `origin/refactor` shows `storage_get_inner` calling `state.storage.get(&entity, &id)` and then applying `shared::project_record(...)` afterward. The storage crate has projected list readers, but the public `get` path has no projection parameters and returns the full matching record before command-level projection. ## Steps to reproduce 1. Use a populated character collection with large `data`, avatar, prompt, or extension fields. 2. Trigger a projected get path, such as character summary by id, greeting lookup, generation character-name lookup, or tracker color persistence. 3. Compare the storage path against projected `storage_list`: `storage_get` still performs a full matched-row read before projection. ## Impact area - [ ] App shell, navigation, startup, or providers - [x] Catalog resources - [ ] Chat mode - [x] Roleplay mode - [x] Game mode - [ ] Shared mode UI - [x] 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: `origin/refactor` at `3e05c12b` - Run mode: Tauri desktop and remote `/api/invoke` share the same storage helper - OS + version: not captured - Node + pnpm versions: not relevant - Rust version, if relevant: not captured - Remote Runtime URL configured? not relevant for the static path check - Provider, model, or integration, if relevant: not relevant ## Logs, screenshots, or video No runtime screenshot attached. Static evidence: - `src-tauri/src/commands/storage/commands/entities.rs:247`-`261`: `storage_get_inner` validates the entity, calls `state.storage.get(&entity, &id)`, then applies `shared::project_record(...)`. - `src-tauri/crates/storage/src/lib.rs:54`-`63`: `list_projected` accepts projection fields and nested selections. - `src-tauri/crates/storage/src/lib.rs:111`-`115`: `get` has no projection parameters. - `src-tauri/crates/storage/src/lib.rs:550`-`592`: the id lookup returns the full matching row. - Current projected get callers include `src/features/catalog/characters/hooks/use-characters.ts:129`, `src/features/shell/bot-browser/components/BotBrowserPanel.tsx:86`, `src/features/runtime/generation/hooks/use-generate.ts:516`, and `src/features/runtime/tracker/hooks/use-tracker-card-color-manager.ts:166`. ## Regression notes Adjacent closed issues are not duplicates: - #1887 fixed cold `storage_get` lookup cost for non-matching rows by adding a pretty-file id fast path. - #1888 fixed projected message `storage_list` reads. - #1885 tracked repeated `storage_list` slowdown and already has a broader storage timing-harness note. This issue covers the remaining `storage_get` projection gap: once the target id is found, the matched row is still read as a full row before projection. This is static parity evidence, not a measured runtime timing repro yet. ## Additional context Suggested follow-up: - Add a focused cold/warm timing harness around projected character `storage_get` with large rows. - If the timing gap is real, add a storage-level `get_projected` path and route `storage_get` options through it. - Preserve existing message materialization and connection secret masking semantics after the narrow read path. Related tracker: #1904 target 2, storage and data access. ## Template check - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:23:48 +07:00
Author
Owner

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

Claiming this now. Plan: add a storage-level projected get path, route storage_get projection options through it for embedded and remote invoke, then verify with focused Rust storage coverage and cargo check.

<!-- gh-comment-id:4600911592 --> @Xelvanis commented on GitHub (Jun 2, 2026): Claiming this now. Plan: add a storage-level projected get path, route storage_get projection options through it for embedded and remote invoke, then verify with focused Rust storage coverage and cargo check.
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#936
No description provided.