[GH-ISSUE #2006] [Feature]: Drive storage defaults and delete cleanup from the contract registry #983

Closed
opened 2026-10-21 05:24:47 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Xelvanis on GitHub.

What problem does this solve?

The refactor storage contract registry now records supported collections, profile coverage, startup JSON repair, typed JSON fields, create default fields, and delete cleanup metadata. That fixed the target 1 parity gap from #1893, but create defaults and delete cleanup are still only partly registry-driven.

Current shape:

  • src-tauri/src/commands/storage/contracts.rs records create_default_fields and delete_cleanup.
  • src-tauri/src/commands/storage/shared.rs still applies create defaults through a large with_entity_defaults collection match.
  • src-tauri/src/commands/storage/commands/entities.rs still runs delete cleanup through hardcoded entity branches.

This is not a current user-facing break. It is follow-up debt from the contracts/schema parity pass: the registry can drift from the behavior it describes.

Proposed behavior

Make create defaults and delete cleanup use the storage contract registry as the executable source of truth where practical.

Suggested first slice:

  • Add helpers that apply simple default fields from StorageCollectionContract::create_default_fields.
  • Keep complex defaults, such as generated character data, in focused helper functions, but register them through the contract path.
  • Add a delete cleanup dispatcher that consumes StorageCollectionContract::delete_cleanup.
  • Keep each cleanup action focused and explicit: lorebook children, lorebook references, prompt children, default chat preset activation, connection folder clearing, managed media, character gallery, and message tracker snapshots.
  • Add focused Rust proof that registry metadata and create/delete behavior cannot drift for representative collections.

Expected owner or impact area

  • App shell, navigation, startup, or providers
  • Catalog resources: chats, characters, personas, lorebooks, presets, connections, agents, gallery, or knowledge
  • 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

Refactor branch considerations

Keep this Rust-side and storage-owned. Do not move product/UI behavior into the low-level file store. The goal is to make the command-layer storage contract registry harder to drift, not to make storage generic or implicit.

The registry already drives allowlisting, profile collection coverage, startup JSON repair collection selection, and typed JSON normalization. This issue is specifically about the remaining create-default and delete-cleanup behavior.

Alternatives considered

Leaving the current helper branches is acceptable short term. The current target 1 parity rescan found this bounded and non-blocking.

The downside is future drift: someone can add or update create_default_fields or delete_cleanup metadata without updating the executable helper branch, or vice versa.

Additional context

Related:

  • #1893 restored the centralized storage schema/default/relation registry.
  • #1904 target 1 contracts/schema parity rescan now classifies the target as on-par with focused Rust proof.
  • Current evidence came from refactor commit 54a9ffd3.

Current paths:

  • src-tauri/src/commands/storage/contracts.rs
  • src-tauri/src/commands/storage/shared.rs
  • src-tauri/src/commands/storage/commands/entities.rs
  • src-tauri/src/commands/storage/profile.rs
  • src-tauri/src/state.rs

Focused proof already run for target 1:

cargo test --manifest-path src-tauri\Cargo.toml generic_storage_commands_reject_unsupported_entities
cargo test --manifest-path src-tauri\Cargo.toml registry_answers_core_contract_questions
cargo test --manifest-path src-tauri\Cargo.toml script_execution_type_returns_actionable_error

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Jun 3, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2006 Originally assigned to: @Xelvanis on GitHub. ## What problem does this solve? The refactor storage contract registry now records supported collections, profile coverage, startup JSON repair, typed JSON fields, create default fields, and delete cleanup metadata. That fixed the target 1 parity gap from #1893, but create defaults and delete cleanup are still only partly registry-driven. Current shape: - `src-tauri/src/commands/storage/contracts.rs` records `create_default_fields` and `delete_cleanup`. - `src-tauri/src/commands/storage/shared.rs` still applies create defaults through a large `with_entity_defaults` collection match. - `src-tauri/src/commands/storage/commands/entities.rs` still runs delete cleanup through hardcoded entity branches. This is not a current user-facing break. It is follow-up debt from the contracts/schema parity pass: the registry can drift from the behavior it describes. ## Proposed behavior Make create defaults and delete cleanup use the storage contract registry as the executable source of truth where practical. Suggested first slice: - Add helpers that apply simple default fields from `StorageCollectionContract::create_default_fields`. - Keep complex defaults, such as generated character `data`, in focused helper functions, but register them through the contract path. - Add a delete cleanup dispatcher that consumes `StorageCollectionContract::delete_cleanup`. - Keep each cleanup action focused and explicit: lorebook children, lorebook references, prompt children, default chat preset activation, connection folder clearing, managed media, character gallery, and message tracker snapshots. - Add focused Rust proof that registry metadata and create/delete behavior cannot drift for representative collections. ## Expected owner or impact area - [ ] App shell, navigation, startup, or providers - [x] Catalog resources: chats, characters, personas, lorebooks, presets, connections, agents, gallery, or knowledge - [ ] 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 ## Refactor branch considerations Keep this Rust-side and storage-owned. Do not move product/UI behavior into the low-level file store. The goal is to make the command-layer storage contract registry harder to drift, not to make storage generic or implicit. The registry already drives allowlisting, profile collection coverage, startup JSON repair collection selection, and typed JSON normalization. This issue is specifically about the remaining create-default and delete-cleanup behavior. ## Alternatives considered Leaving the current helper branches is acceptable short term. The current target 1 parity rescan found this bounded and non-blocking. The downside is future drift: someone can add or update `create_default_fields` or `delete_cleanup` metadata without updating the executable helper branch, or vice versa. ## Additional context Related: - #1893 restored the centralized storage schema/default/relation registry. - #1904 target 1 contracts/schema parity rescan now classifies the target as on-par with focused Rust proof. - Current evidence came from `refactor` commit `54a9ffd3`. Current paths: - `src-tauri/src/commands/storage/contracts.rs` - `src-tauri/src/commands/storage/shared.rs` - `src-tauri/src/commands/storage/commands/entities.rs` - `src-tauri/src/commands/storage/profile.rs` - `src-tauri/src/state.rs` Focused proof already run for target 1: ```powershell cargo test --manifest-path src-tauri\Cargo.toml generic_storage_commands_reject_unsupported_entities cargo test --manifest-path src-tauri\Cargo.toml registry_answers_core_contract_questions cargo test --manifest-path src-tauri\Cargo.toml script_execution_type_returns_actionable_error ``` ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
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#983
No description provided.