mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5302] [Feature]: Shard every remaining file-storage table instead of rewriting global JSON monoliths #2932
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#2932
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SpicyMarinara on GitHub (Aug 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5302
Originally assigned to: @SpicyMarinara on GitHub.
What problem does this solve?
Marinara's file-native store still persists most logical tables as one global JSON array per table under
storage/tables/<table>.json. Only the chat-keyed high-write tables listed inSHARDED_TABLESwere split by #4708.That leaves characters and their version history, personas and their version history, lorebooks and entries, presets and sections, connections, agent configs, images, Noodle/Slurp data, folders, themes, settings, extensions, and many other collections as monoliths. A mutation to one row marks the whole table dirty, serializes every row, and atomically replaces the entire table snapshot.
The frequency is lower than messages, but the same structural problems remain:
This becomes more expensive to migrate later as user libraries and embedding data grow.
Proposed solution
Extend the proven storage-format migration from #4708 so every persistent table has an explicit shard strategy, and no multi-row collection remains a global JSON-array monolith.
Use the stable ownership/access key for each table rather than assuming every shard is chat-keyed. Examples:
characters/<characterId>.jsoncharacter_card_versions/<characterId>.jsonpersonas/<personaId>.jsonpersona_card_versions/<personaId>.jsonlorebooks/<lorebookId>.jsonlorebook_entries/<lorebookId>.jsonprompt_presets/<presetId>.jsonwith groups, sections, and choice blocks grouped by their owning presetapi_connections/<connectionId>.jsonagent_configs/<agentId>.jsonThe implementation should generalize the current chat-specific shard metadata into declarative per-table shard ownership while preserving the existing query/storage API. Parent-owned child tables may use a maintained parent index, as
message_swipesalready does.Carry forward all safety properties established by #4708:
.bakmonolith snapshots, with a crash-recoverable migration sentinel..pre-shardrecovery artifacts.This can land in reviewable phases, but it should remain one coordinated storage-format feature with a complete table-to-shard ownership map and a final regression proving that every registered table is sharded or has an explicit one-record-per-key strategy.
Acceptance criteria
FILE_BACKED_TABLEShas a declared shard-key/ownership strategy.storage/tables/<table>.jsonafter migration.Alternatives considered
Additional context
Related completed work: #4708 introduced storage formats 3/4, safe shard filenames, shard-granular dirty tracking, migration sentinels, downgrade conflict handling, backups, and orphan preservation for chat-keyed tables. This issue extends that architecture across the rest of
FILE_BACKED_TABLESrather than creating a second persistence design.Canonical architecture reference:
docs/development/file-storage.md. Current shard registry and migration machinery:packages/server/src/db/file-backed-store.ts.Duplicate check: no open issue currently covers sharding the remaining entity/configuration tables.
Template check