mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5114] [MERGED] fix(game): cap game auto-checkpoints per trigger type to bound checkpoint blob accumulation #6635
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#6635
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/5114
Author: @kolacheee
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @kolacheee
Base:
staging← Head:fix/5110-checkpoint-retention📝 Commits (10+)
c080283fix(game): cap auto-checkpoints per trigger type to bound blob accumulationebb851cMerge remote-tracking branch 'origin/staging' into fix/5110-checkpoint-retention4ce2c54fix(game): keep the checkpoint cap at exactly MAX when protecting the fresh rowfb85ffaMerge remote-tracking branch 'origin/staging' into fix/5110-checkpoint-retention9714a61Merge remote-tracking branch 'origin/staging' into fix/5110-checkpoint-retention8243d2bMerge remote-tracking branch 'origin/staging' into fix/5110-checkpoint-retention534fa6eMerge remote-tracking branch 'origin/staging' into fix/5110-checkpoint-retention8ee4794Merge remote-tracking branch 'origin/staging' into fix/5110-checkpoint-retentionf0d3502Merge remote-tracking branch 'origin/staging' into fix/5110-checkpoint-retention91a0a78Merge remote-tracking branch 'origin/staging' into fix/5110-checkpoint-retention📊 Changes
4 files changed (+401 additions, -27 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
package.json(+2 -1)📝
packages/server/src/services/game/checkpoint.service.ts(+127 -26)➕
scripts/regressions/checkpoint-retention.regression.ts(+271 -0)📄 Description
Linked issue
Closes #5110
Why this change
Game checkpoints store full immutable copies of everything they capture — the tracker snapshot (
snapshotData), the World Map snapshot (spatialSnapshotData), and (once #5102 lands) the turn-game/Experience engine-state blobs. Nothing bounded how many a chat accumulated: auto-checkpoints fire at session start, session end, and on every combat start and end, and only manual deletion removed one.Because
game_checkpointsis chat-sharded and the file store holds tables in memory, a long campaign multiplied every captured blob into permanent heap and re-serialized the chat's whole checkpoint shard on every new checkpoint — an O(n²) write pattern. With a game-surface Experience whose world save approaches its 256 KB cap, tens of sessions of auto-checkpoints add up to tens of megabytes duplicated per chat, worst on Android where the whole app fights a ~1 GB heap (#4730).listForChatalso materialized every stored blob just to strip the fields before returning the list.What changed
create()now prunes auto-checkpoints to the newestMAX_AUTO_CHECKPOINTS_PER_TRIGGER(5) per trigger type after each insert. The cap is row-level, so it is field-agnostic — it boundssnapshotData,spatialSnapshotData, and #5102's futureengineStateDatatogether with no per-field wiring, and coversengineStateDataautomatically once that column merges.create()just returned: aprotectIdguard covers the pathological same-millisecondcreatedAtcollision, so a returned checkpoint id always resolves.listForChatnow projects the list columns instead of copying the captured blobs out of the store only to strip them again; the store sorts full rows before projecting, so the newest-first order is unchanged (pinned by the regression).Retention is per trigger type rather than a single total, so a burst of one kind of event — a dungeon's worth of
combat_start/combat_end— cannot evict the lastsession_startrewind point.Scope notes: I left the cap a named constant rather than an env var to keep this focused; a
MARINARA_*override is an easy follow-up if users want deeper auto-history. Per-chat retention is the first (highest-value) of the three directions the issue lists; content-addressing captured blobs by hash is the natural next step if per-type retention proves too coarse.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Automated (run locally against this branch, all green):
pnpm checkpnpm regression:checkpoint-retention(new lane; also wired intoregression:issues)pnpm regression:game-checkpoint-engine-state(sibling checkpoint lane, unaffected)pnpm version:checkStill needs a manual browser pass (a human should verify — do not treat the boxes above as done):
combat_startand 5combat_endauto-checkpoints remain in the checkpoint list, and that any manual checkpoints you made are all still present.game_checkpointsshard underdata/storage/tables/and confirm it stops growing without bound across many sessions.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG.mdgets aFixedentry. No user-facing docs underdocs/changed, so nodocs-i18nmirroring is required. No version bump.Summary by CodeRabbit
Summary by CodeRabbit
Bug Fixes
Tests
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.