[PR #2558] [MERGED] Fix storage recovery and tracker edit context #5656

Closed
opened 2026-10-22 04:18:13 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2558
Author: @SpicyMarinara
Created: 6/14/2026
Status: ✅ Merged
Merged: 6/14/2026
Merged by: @SpicyMarinara

Base: staging ← Head: codex/fix-storage-recovery-tracker-edits


📝 Commits (1)

  • 02d107a fix storage recovery and tracker edit context

📊 Changes

4 files changed (+82 additions, -26 deletions)

View changed files

📝 packages/server/src/db/file-backed-store.ts (+46 -23)
📝 packages/server/src/routes/generate.routes.ts (+17 -1)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+18 -1)
📝 packages/shared/src/types/agent.ts (+1 -1)

📄 Description

Why

Fixes #2553.
Addresses the #2551 follow-up where manual tracker edits were saved but tracker agents could still use stale pre-edit committed tracker context on the next run.

What changed

  • Hardened file-native JSON loading so startup continues when both a primary JSON file and its .bak are corrupt or NUL-filled.
  • Marked fallback-loaded files dirty and suppressed the immediate backup refresh so a corrupt primary is not copied over the recovery source during self-heal.
  • Updated normal generation and retry-agent context building to prefer the active visible tracker snapshot for the matching assistant message, so manual edits become the base context for the next tracker generation.
  • Relaxed the shared agent context comment because recent-message tracker state can now be visible/uncommitted, not only committed.

Validation

  • pnpm install
  • pnpm --filter @marinara-engine/server lint
  • pnpm check
  • Temp FILE_STORAGE_DIR repro with NUL-filled manifest.json, manifest.json.bak, tables/chats.json, and tables/chats.json.bak; file-native DB initialized, flushed, closed, and printed file storage recovered.
  • GitHub pnpm-validate passed.
  • GitHub container-build-test passed.
  • CodeRabbit passed/skipped with no suggestions.

Manual verification needed

  • Manually edit a roleplay tracker field, send the next turn, and confirm debug/agent prompt context contains the edited tracker value before the tracker agent produces its replacement.
  • Launch with a copied damaged storage folder if available from the reporter and confirm the app starts far enough to make/export a backup.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/2558 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 6/14/2026 **Status:** ✅ Merged **Merged:** 6/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/fix-storage-recovery-tracker-edits` --- ### 📝 Commits (1) - [`02d107a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/02d107a2a76d7879f887903766ef609fb8609b5d) fix storage recovery and tracker edit context ### 📊 Changes **4 files changed** (+82 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/db/file-backed-store.ts` (+46 -23) 📝 `packages/server/src/routes/generate.routes.ts` (+17 -1) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+18 -1) 📝 `packages/shared/src/types/agent.ts` (+1 -1) </details> ### 📄 Description ## Why Fixes #2553. Addresses the #2551 follow-up where manual tracker edits were saved but tracker agents could still use stale pre-edit committed tracker context on the next run. ## What changed - Hardened file-native JSON loading so startup continues when both a primary JSON file and its `.bak` are corrupt or NUL-filled. - Marked fallback-loaded files dirty and suppressed the immediate backup refresh so a corrupt primary is not copied over the recovery source during self-heal. - Updated normal generation and retry-agent context building to prefer the active visible tracker snapshot for the matching assistant message, so manual edits become the base context for the next tracker generation. - Relaxed the shared agent context comment because recent-message tracker state can now be visible/uncommitted, not only committed. ## Validation - `pnpm install` - `pnpm --filter @marinara-engine/server lint` - `pnpm check` - Temp FILE_STORAGE_DIR repro with NUL-filled `manifest.json`, `manifest.json.bak`, `tables/chats.json`, and `tables/chats.json.bak`; file-native DB initialized, flushed, closed, and printed `file storage recovered`. - GitHub `pnpm-validate` passed. - GitHub `container-build-test` passed. - CodeRabbit passed/skipped with no suggestions. ## Manual verification needed - Manually edit a roleplay tracker field, send the next turn, and confirm debug/agent prompt context contains the edited tracker value before the tracker agent produces its replacement. - Launch with a copied damaged storage folder if available from the reporter and confirm the app starts far enough to make/export a backup. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:18:13 +07:00
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#5656
No description provided.