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#6483
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/4735
Author: @kolacheee
Created: 8/7/2026
Status: ✅ Merged
Merged: 8/8/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/4708-message-shards📝 Commits (10+)
fc65583feat(storage): shard messages and message_swipes per chat9f3e951Merge branch 'staging' into feat/4708-message-shardsfd308ecfix(storage): check the format version before migration side effectsca2bde0fix(storage): heal a lagging manifest version on the next startupa448afffix(storage): rewrite or delete physical shard files whose rows movedefc4421Merge branch 'staging' into feat/4708-message-shards606c2d7fix(storage): review round on the stacked guard PR (#4738)453054fMerge remote feat/4708-message-shards (maintainer branch update)acab6e2Merge branch 'staging' into feat/4708-message-shardsa5d9873fix(storage): dirty swipe shards when an inserted message adopts orphans📊 Changes
4 files changed (+1606 additions, -12 deletions)
View changed files
📝
docs/development/file-storage.md(+11 -1)📝
package.json(+1 -1)📝
packages/server/src/db/file-backed-store.ts(+863 -10)➕
scripts/regressions/message-sharding.regression.ts(+731 -0)📄 Description
Linked issue
Part of #4708 (PR 1 of the approved plan — see the maintainer-approved decisions and my confirmation in the issue thread). PR 2 (the launcher/updater downgrade guard) must ship in the same release as this PR — merging this alone is safe for
stagingusers going forward, but the release that ships it needs the guard so a later downgrade can't silently confuse users.Why this change
messages/<A>.json— nothing else.What changed
All storage changes in
file-backed-store.ts; tables stay registered inFILE_BACKED_TABLES(schema/backup/query machinery untouched) — only load/save/dirty plumbing consults the newSHARDED_TABLESmarker.messagesandmessage_swipes:storage/tables/<table>/<encoded-chat-id>.json, storage format 2 → 3. Dirty tracking runs at shard granularity through a structure parallel to the table-level dirty set (never encoded into it — the transaction context's table-name set doubles as the rollback-snapshot key set), mirrored at every dirty-state path: flush snapshot/reset and failure re-add, transaction deep-snapshot/rollback-restore, the durable-rollback re-add, cascade deletes, and load-time self-heal. The #4705 write-generation contract stays keyed on the bare table name.messageId → chatIdindex (rebuilt on load and on rollback), including during cascade deletes — a live lookup would have reintroduced the O(n²) write-path class this store has already been bitten by. Orphan swipes (no parent message) persist in a reservedorphaned-rowsshard instead of vanishing.existsSyncon the hot path. Zero-row dirty shards delete their file and.bak(deleted chats leave no litter)..bakrename to.pre-shard— those files are the mandated automatic backup, never deleted by the Engine, no extra copies (per the backup-weight decision). A.migratingsentinel plus a shard-data check make every crash state decidable; a monolith recreated by an older build beside live shards is quarantined with a timestamped suffix and never merged. Data written by a newer storage format refuses to load (StorageFormatTooNewError) — honestly scoped: it protects future format changes; the guard for this transition is PR 2's launcher work, since pre-shard builds never read the version.[a-z0-9-]is percent-encoded — uppercase included (NTFS/APFS are case-insensitive; case-variant ids must never share a file) — with hash fallbacks for overlong and Windows-reserved names. Filenames are containers only; rows carry their own keys.message-sharding.regression.ts, wired intoregression:issues) drives the real store end-to-end: fresh-install sharding; the single-shard flush granularity claim; migration with rename set and orphan handling; crashed-migration retry (including the empty-dir and between-renames crash states); downgrade-artifact quarantine; version gate; transaction rollback; chat-delete cleanup; bak-only shard recovery; cross-shard duplicate dedup; and the encoding boundary.The adversarial review pass (verifiers ran live probes against the real store) caught five defects in the first cut, all fixed and pinned: a crash between
mkdirand the sentinel write would have classified the next boot as a downgrade and quarantined the monolith in favor of empty shards (classification now requires actual shard data); a crash between the two renames would have retried from the one-flush-stale.bak(the.baknow renames first); case-variant chat ids collided into one file on Windows/macOS (uppercase now encodes); a profile-import upsert that moves a message between chats now dirties its swipes' old and new shards (previously duplicated or silently dropped them); and duplicate primary keys across shards are dropped at load with the affected shards healed on the next flush.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm checkand the fullregression:issueslane pass locally (every existing lane runs against the sharded store)..bak, v2 manifest) → boot →Sharded messages: 40 rows into 2 per-chat files (originals preserved as .pre-shard)→ shard files under readable names, both.pre-shardbackups present, no residual monolith,/api/healthok, messages served correctly per chat, manifest v3 with shard diagnostics.Still to verify manually (contributor to-do):
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)docs/development/file-storage.mdupdated (layout, sharding, migration semantics) — developer docs, not part of the translated packs. User-facing TROUBLESHOOTING/UPGRADING recovery steps land with PR 2 (the guard), where they belong.Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.