mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
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#6488
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4754
Author: @kolacheee
Created: 8/8/2026
Status: ✅ Merged
Merged: 8/8/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/4708-shard-remaining-tables📝 Commits (10+)
aa109b5feat(storage): shard the remaining six chat-keyed tables (#4708 PR 3)277fca3feat(storage): full chat-keyed scope + review fixes for PR 3f443a5efix(storage): persist SET_NULL cascades for sharded children + missing chat cascadesfdbacdbMerge feat/4708-downgrade-guard (verified/unverified guard fixes) into feat/4708-shard-remaining-tables6e6f049test(regressions): harden the SHARDED_TABLES pairing-pin parsere16e1acMerge feat/4708-downgrade-guard (bak-only manifest + ls-tree guard fixes) into feat/4708-shard-remaining-tables9c31fb4Merge branch 'staging' into feat/4708-shard-remaining-tables9666a0cMerge feat/4708-downgrade-guard (third review round) into feat/4708-shard-remaining-tables607d6b4Merge feat/4708-downgrade-guard (regression hygiene) into feat/4708-shard-remaining-tables8bb3060Merge branch 'staging' into feat/4708-shard-remaining-tables📊 Changes
7 files changed (+392 additions, -57 deletions)
View changed files
📝
docs/TROUBLESHOOTING.md(+2 -2)📝
docs/development/file-storage.md(+4 -2)📝
packages/server/src/db/file-backed-store.ts(+110 -44)📝
scripts/protect-launcher-data.mjs(+19 -2)📝
scripts/regressions/launcher-format-guard.regression.mjs(+37 -2)📝
scripts/regressions/message-sharding.regression.ts(+219 -4)📝
storage-format.json(+1 -1)📄 Description
Linked issue
Part 3 of #4708 — with this, every chat-keyed table on a per-turn write path is sharded (two documented exceptions below). The issue can close once the compat-cleanup follow-up is filed (see checklist there).
Why this change
messagesandmessage_swipesbecause they sat on the per-message write path. The same write-amplification applies to every other chat-keyed table: memory chunks and agent memory rewrite per turn (setMemoriesis the store's own named hot path), game state/engine/storyboards per game-mode turn, agent runs per agent call, call sessions/messages per utterance, gallery and scene-video rows per generation, influences/notes per conversation turn — each previously re-serialized the full table across all chats on every write. The maintainer mandated full scope across follow-up PRs (decision 3 on #4708, re-confirmed on Discord).What changed
memory_chunks,chat_images,agent_runs,agent_memory,conversation_call_sessions,conversation_call_messages,game_state_snapshots,game_engine_state,game_checkpoints,game_turn_storyboards,game_scene_videos,spatial_context_snapshots,ooc_influences,conversation_notesjoinSHARDED_TABLES.agent_memoryalone is the per-turnsetMemorieshot path). Doing all of them now means one format bump and one migration event for users instead of two. If you'd rather split, the added tables are one list entry each.lorebooks(nullablechatId— a chat-linked library entity, not per-chat data) andgame_turn_storyboard_keyframes(no chat column; sharding it cleanly wants a denormalizedchatId, which is a schema decision — proposed as a follow-up on #4708).shardKeyForRow(table, row)is the single source of truth for row→shard mapping:message_swipesresolves through the parent-message index (keeping the orphan-marker machinery),ooc_influences/conversation_notesshard bytargetChatId(their read-side key — they're injected per roleplay turn of the target chat) via a small per-table key-column map, and everything else by its ownchatId, with theorphaned-rowsfallback. Migration, downgrade-artifact quarantine, crash recovery, foreign-row healing, and canonical dedup from #4735 apply to all new tables unchanged — they key offSHARDED_TABLESmembership. Key-column changes on existing rows (conflict upserts during profile import) are already covered generically: insert/update dirty both the old and new rows' keys.STORAGE_VERSIONand rootstorage-format.jsonbump together (regression-pinned pairing). The #4738 guard machinery handles the new boundary with no changes: a format-4 data dir refuses format-3 and format-2 targets in the launchers, installer, and in-app updater.STORAGE_VERSIONis now exported so regressions pin against the current version rather than chasing literals on every bump..pre-shardbackups survive re-migration (review finding) — a migrate → unshard → migrate round trip previously renamed the rebuilt monolith over the pristine pre-migration backup, silently breaking the docs' "never deleted by the Engine" promise. Subsequent backups now take a timestamped.pre-shard-<ts>name. Regression-pinned.protect-launcher-data.mjsis extended (the pairing regression fails the build if the lists diverge), and its messages no longer hardcode stale format numbers. Honest note on 4 → 3 downgrades:unshardrebuilds all sharded tables to monoliths and lands the manifest on format 2; a format-3 build booted on that data simply re-runs its own messages/swipes migration — correct, just one extra migration pass.applySetNullRelationswas the one mutation path callingmarkDirtywithout shard keys; for a sharded child (game_checkpointsis a SET_NULL child ofspatial_context_snapshots) the null-out landed in memory but never reached disk, so a restart resurrected the danglingspatialSnapshotId. Regression asserts the null reaches the shard file on disk.ooc_influencesandconversation_notesdeclareonDelete: cascadeon both chat FKs in their schemas, but the store's cascade graph never carried the relations, so their rows outlived their chats. Invisible inside the old monolith; a permanently leaked per-chat shard file once sharded, plus stale injections if a chat id is ever reused via profile import. Both FK directions are now in the graph (this also makes the mari-db dangling-reference validator aware of them). If you'd rather keep behavior changes out of a storage-layout PR, say the word and I'll split it out.docs/development/file-storage.mdsharded-tables section rewritten with the full enumerated list, the two key-column exceptions, and the two deliberate monolith exceptions with reasons; the TROUBLESHOOTING downgrade section wording broadened from "messages" to per-chat data generally.chatIdfamily, a fourteen-monolith one-boot migration sweep asserting row survival per table (including thetargetChatIdgrouping, neversourceChatId), the.pre-shardround-trip preservation pin, and an unshard conversion case for a non-message table asserting content.Deferred, unchanged from the plan: the backup
.bak-exclusion follow-up (decision 4) — sixteen shard families grow the backup ZIP entry count further (the ZIP32 entry ceiling gets ~4× closer for very large installs), so the measurement-gated follow-up on #4708 stands, now with more reason.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
.pre-shardoriginals preserved) and the app behaves normally (memory recall, agent memory, gallery, game mode incl. checkpoints/storyboards, calls, OOC influences/notes).unshard+ downgrade + re-upgrade works, and the original.pre-shardbackups survive the round trip.pnpm check(green, twice — before and after the scope expansion), message-sharding lane incl. the fourteen-table migration sweep and.pre-shardround-trip pin (green), launcher-format-guard lane incl. the pairing pins and unshard conversion case (green), file-backed-shutdown + autonomous-scheduler-gate lanes (green).Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)The previous follow-up #4739 is closed (translations landed), so a new
[docs-i18n] docs/TROUBLESHOOTING.md docs/development/file-storage.mdfollow-up issue accompanies this PR.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.