[PR #1760] [MERGED] fix(gacha-forge): forge chapters without waiting for fights or memory (1.24.9) #1955

Closed
opened 2026-11-07 16:38:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/1760
Author: @SpicyMarinara
Created: 10/27/2026
Status: ✅ Merged
Merged: 10/27/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/gacha-forge-chapter-forge-speed


📝 Commits (6)

  • 63c0f61 fix(gacha-forge): forge chapters without waiting for fights or memory (1.24.9)
  • 5278a8b Merge remote-tracking branch 'origin/staging' into fix/gacha-forge-chapter-forge-speed
  • 9c33b72 fix(gacha-forge): address 1.24.9 review findings
  • 870f037 test(gacha-forge): fail clearly if story memory never settles before the seasonal rollback snapshot
  • 5865472 fix(gacha-forge): pin no client fight prewarm in Keep playing e2e; README 1.24.9 section
  • 86646e5 Merge remote-tracking branch 'origin/staging' into fix/gacha-forge-chapter-forge-speed

📊 Changes

26 files changed (+1362 additions, -260 deletions)

View changed files

➕ artifacts/gacha-forge-1.24.9.zip (+0 -0)
📝 catalog/catalog.json (+8 -8)
📝 catalog/notes.json (+6 -6)
📝 catalog/v2/catalog.json (+8 -8)
📝 catalog/v2/notes.json (+6 -6)
📝 catalog/v3/catalog.json (+8 -8)
📝 catalog/v3/notes.json (+6 -6)
📝 packages/gacha-forge/CHANGELOG.md (+6 -0)
📝 packages/gacha-forge/README.md (+6 -0)
📝 packages/gacha-forge/bundle-patches.json (+48 -0)
📝 packages/gacha-forge/client.js (+22 -23)
📝 packages/gacha-forge/manifest.json (+5 -5)
📝 packages/gacha-forge/server.mjs (+128 -32)
📝 packages/gacha-forge/src/preforge-art-server.mjs (+15 -0)
📝 packages/gacha-forge/src/story-cancel-client.mjs (+17 -18)
📝 packages/gacha-forge/src/story-memory-integration.mjs (+17 -8)
📝 packages/gacha-forge/src/story-memory.mjs (+94 -22)
📝 tests/gacha-forge-chapter-regeneration-package.regression.mjs (+2 -0)
📝 tests/gacha-forge-preforge-art.regression.mjs (+163 -0)
📝 tests/gacha-forge-proactive-messages-sdk.regression.mjs (+50 -7)

...and 6 more files

📄 Description

Pull request

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch to main.

Linked issue

Fixes #1758

Why this change

Forging the next chapter took 15–20 minutes. A traced, skeptic-verified investigation found that the forging screen waited for much more than the chapter plan:

  • Every fight first. All of the chapter's fights were designed one after another before the map was shown. That is 3–6 extra model calls, each as heavy as the plan.
  • Memory in the foreground. Every generation first ran story-memory maintenance. It waited for the summary job started when the previous chapter ended, and summarized anything missing.
  • Summaries that always failed. Memory summaries reserved at most 2,000 output tokens, but every generation requires 8,192. A chapter too long for one summary request therefore always failed. The failing work was then repeated before the plan and before each fight.

The maintainer's direction:

  1. The plan is just the plan, and fights are designed with the story beats, one after another.
  2. Summaries get at least 10k output tokens, because thinking models need the room.
  3. Recall stays the same: constant summary, recalled chapter summaries, the last chapter in full, and the current chapter. Summarizing happens automatically in the background.

What changed

Package gacha-forge 1.24.9. client.js and server.mjs are rebuilt from new bundle-patches.json entries. The artifact, manifest and catalog are regenerated. The branch merges staging after #1754.

Fights

  • The chapter opens as soon as its plan is written, so the client prewarm (_prewarmCombats) is removed. The opening-story dialogs no longer promise chapter one's fights.
  • Each fight is designed right after the scene before it is written, in every pre-forge mode:
    • Pre-forge on: the server's write-ahead chain designs each fight just before the scene that follows it, in node order (forgePreforgeFights).
    • Pre-forge off (the default): /beat designs the fights that follow a played scene in the background (forgeFightsAfter), without delaying its reply.
    • Both: a freshly designed fight starts its enemy art, as the old /combat-guide route did. A fight neither path reached is still designed when its battle opens.
  • Before every fight design and before the next scene, the chain re-checks Cancel, Off and a pending choice, and refreshes its heartbeat. A stop between fights therefore pays for nothing more, and a long gap is never read as a stopped chain.
  • Seasonal events are unchanged; their pre-forge is off.

Memory (src/story-memory.mjs, src/story-memory-integration.mjs)

  • recall() never calls maintain() or summarize. The saved overview stays usable while everything it covers is still canon (a subset check, no longer a prefix check).
  • Canon the overview does not cover goes in beside it, in story order, as required text: its saved summary, or the text as written for side canon not summarized yet.
  • The latest chapter is sent in full, as before. Only an earlier chapter with no summary at all needs the legacy history.
  • Generation schedules a background catch-up only when no job is running, so it never re-arms one. A failed summary, or an unknown summary context, waits for Retry or configuration.
  • Historical targets never build an overview in the foreground. Future or changed canon is never used.
  • The background job sizes the overview for the smallest known of the structured, narration and chat contexts. A reader with an unknown context makes Continuity ask for configuration instead of showing Ready.
  • Summaries reserve max(8192, min(max(10240, tokenBudget), maxOutput)) output tokens, replacing min(2000, …).

Docs

  • CHANGELOG and in-game What's new (1.24.8 pinned).
  • README pre-forge and memory paragraphs, worded to what the code does. One example: "no longer waits for memory to catch up". A summary request already running on the same connection still finishes first, and a separate summary connection avoids that.

Package and security impact

  • Affected package IDs: gacha-forge
  • Engine compatibility impact: none.
  • New or changed permissions/entrypoints: none. /combat-guide stays, and the client simply no longer calls it before the map.
  • Restart, storage, update, or uninstall impact: no storage format change.
    • Saved memory is reused.
    • An overview built for a larger budget is resized by the next background run. Opening a world schedules that run once per process.

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

Agent-side checks

  • All 68 tests/gacha-forge-*.regression.mjs files pass locally, before and after merging staging.
  • git diff --check is clean.
  • validate-catalog's changelog and notes check passes locally. The sparse worktree lacks other packages' zips, so the full run is left to CI.

New or changed regressions

  • gacha-forge-preforge-art (29 cases):
    • The shipped chain writes scene 1, fight 1, scene 2, fight 2 in that order.
    • Cancel and Off between two fight designs stop the chain with no further model call.
    • The heartbeat holds across a gap of 45 minutes.
    • With pre-forge off, /beat designs the following fight in the background, with enemy art, without waiting.
    • Every new case was checked against deliberately broken copies of the server.
  • gacha-forge-story-memory, -integration and -package now pin:
    • recall answering from saved memory without summarizing or waiting for an in-flight job;
    • the lag rules;
    • raw side canon;
    • smallest-reader sizing and the 10,240-token reserve;
    • background scheduling: once per lag, never after "error" or for replays;
    • a chapter plan making no summary calls once memory is prepared.
  • gacha-forge-story-cancel: Keep playing and plan landing prewarm nothing.
  • chapter-regeneration-package: given an ample window, because unsummarized canon is now sent in full instead of being summarized in front of the scene.
  • proactive-messages-sdk: background summaries are held on a gate. The message is sent while they are pending, and they then complete with records for chapter, chat and event.
  • seasonal-events-package: lets background memory settle before its rollback snapshot.

Review record

  • Local CodeRabbit, two runs:
    • First run: a context-unknown phase still counted as lagging, so every scene would requeue a job that can't run. Fixed, with a regression.
    • Second run, after the review fixes: the seasonal rollback test could time out silently while waiting for memory. It now fails clearly instead (870f0373e).
  • Adversarial review: three areas, 14 skeptic-confirmed findings, all fixed in 9c33b7229:
    • Fights: Cancel or Off mid-gap; no early fights or enemy art with pre-forge off; the heartbeat.
    • Memory: the overview thrown away when canon was inserted earlier; side canon with a summary dropped; failing summaries re-armed; the reserve below 8192; unknown readers shown as Ready; recent-canon order.
    • Docs and tests: dialog text, overstated wording, and the vacuous proactive test.
  • Memory test suites: core 32/32, integration 44/44, package 11/11. Every new or modified test fails on the previous semantics.

To verify by hand

  • Finish a chapter and open the next one right away. The chapter map appears after the plan alone; no "Designing a fight" wait on the forging screen.
  • With pre-forge on, watch the chapter screen. Scenes and fights are prepared in order, and entering a fight that was prepared opens without a wait.
  • With pre-forge off, read a scene that is followed by a fight. When you reach the fight it opens without a design wait, and with its enemy portraits.
  • Play long chapters with a thinking model as the summary connection. Settings → Story → Continuity shows memory ready instead of an error.
  • Right after finishing a Character Story, the next scene still knows what happened in it.

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

UI evidence (if applicable)

No layout changes. The forging screen simply ends after the plan.

🤖 Generated with Claude Code


🔄 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-Agents/pull/1760 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/27/2026 **Status:** ✅ Merged **Merged:** 10/27/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/gacha-forge-chapter-forge-speed` --- ### 📝 Commits (6) - [`63c0f61`](https://github.com/Pasta-Devs/Marinara-Agents/commit/63c0f61495b28d4b51576c479bcfccf8646a0dba) fix(gacha-forge): forge chapters without waiting for fights or memory (1.24.9) - [`5278a8b`](https://github.com/Pasta-Devs/Marinara-Agents/commit/5278a8b99ff248f5dff3cb80d129f3319f4f0aaa) Merge remote-tracking branch 'origin/staging' into fix/gacha-forge-chapter-forge-speed - [`9c33b72`](https://github.com/Pasta-Devs/Marinara-Agents/commit/9c33b7229052ab596d97c34e298d5fe283b76641) fix(gacha-forge): address 1.24.9 review findings - [`870f037`](https://github.com/Pasta-Devs/Marinara-Agents/commit/870f0373e5bb5c176b94a2d1c70680f25c906830) test(gacha-forge): fail clearly if story memory never settles before the seasonal rollback snapshot - [`5865472`](https://github.com/Pasta-Devs/Marinara-Agents/commit/58654728e0f242042692e478a1c1ceafec1ad1ba) fix(gacha-forge): pin no client fight prewarm in Keep playing e2e; README 1.24.9 section - [`86646e5`](https://github.com/Pasta-Devs/Marinara-Agents/commit/86646e56b162be79a88c713bd66eb9071e65ac99) Merge remote-tracking branch 'origin/staging' into fix/gacha-forge-chapter-forge-speed ### 📊 Changes **26 files changed** (+1362 additions, -260 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/gacha-forge-1.24.9.zip` (+0 -0) 📝 `catalog/catalog.json` (+8 -8) 📝 `catalog/notes.json` (+6 -6) 📝 `catalog/v2/catalog.json` (+8 -8) 📝 `catalog/v2/notes.json` (+6 -6) 📝 `catalog/v3/catalog.json` (+8 -8) 📝 `catalog/v3/notes.json` (+6 -6) 📝 `packages/gacha-forge/CHANGELOG.md` (+6 -0) 📝 `packages/gacha-forge/README.md` (+6 -0) 📝 `packages/gacha-forge/bundle-patches.json` (+48 -0) 📝 `packages/gacha-forge/client.js` (+22 -23) 📝 `packages/gacha-forge/manifest.json` (+5 -5) 📝 `packages/gacha-forge/server.mjs` (+128 -32) 📝 `packages/gacha-forge/src/preforge-art-server.mjs` (+15 -0) 📝 `packages/gacha-forge/src/story-cancel-client.mjs` (+17 -18) 📝 `packages/gacha-forge/src/story-memory-integration.mjs` (+17 -8) 📝 `packages/gacha-forge/src/story-memory.mjs` (+94 -22) 📝 `tests/gacha-forge-chapter-regeneration-package.regression.mjs` (+2 -0) 📝 `tests/gacha-forge-preforge-art.regression.mjs` (+163 -0) 📝 `tests/gacha-forge-proactive-messages-sdk.regression.mjs` (+50 -7) _...and 6 more files_ </details> ### 📄 Description # Pull request > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch to `main`. ## Linked issue Fixes #1758 ## Why this change Forging the next chapter took 15–20 minutes. A traced, skeptic-verified investigation found that the forging screen waited for much more than the chapter plan: - **Every fight first.** All of the chapter's fights were designed one after another before the map was shown. That is 3–6 extra model calls, each as heavy as the plan. - **Memory in the foreground.** Every generation first ran story-memory maintenance. It waited for the summary job started when the previous chapter ended, and summarized anything missing. - **Summaries that always failed.** Memory summaries reserved at most 2,000 output tokens, but every generation requires 8,192. A chapter too long for one summary request therefore always failed. The failing work was then repeated before the plan and before each fight. The maintainer's direction: 1. The plan is just the plan, and fights are designed with the story beats, one after another. 2. Summaries get at least 10k output tokens, because thinking models need the room. 3. Recall stays the same: constant summary, recalled chapter summaries, the last chapter in full, and the current chapter. Summarizing happens automatically in the background. ## What changed Package `gacha-forge` 1.24.9. `client.js` and `server.mjs` are rebuilt from new `bundle-patches.json` entries. The artifact, manifest and catalog are regenerated. The branch merges staging after #1754. **Fights** - The chapter opens as soon as its plan is written, so the client prewarm (`_prewarmCombats`) is removed. The opening-story dialogs no longer promise chapter one's fights. - Each fight is designed right after the scene before it is written, in every pre-forge mode: - **Pre-forge on:** the server's write-ahead chain designs each fight just before the scene that follows it, in node order (`forgePreforgeFights`). - **Pre-forge off (the default):** `/beat` designs the fights that follow a played scene in the background (`forgeFightsAfter`), without delaying its reply. - **Both:** a freshly designed fight starts its enemy art, as the old `/combat-guide` route did. A fight neither path reached is still designed when its battle opens. - Before every fight design and before the next scene, the chain re-checks Cancel, Off and a pending choice, and refreshes its heartbeat. A stop between fights therefore pays for nothing more, and a long gap is never read as a stopped chain. - Seasonal events are unchanged; their pre-forge is off. **Memory** (`src/story-memory.mjs`, `src/story-memory-integration.mjs`) - `recall()` never calls `maintain()` or `summarize`. The saved overview stays usable while everything it covers is still canon (a subset check, no longer a prefix check). - Canon the overview does not cover goes in beside it, in story order, as required text: its saved summary, or the text as written for side canon not summarized yet. - The latest chapter is sent in full, as before. Only an earlier chapter with no summary at all needs the legacy history. - Generation schedules a background catch-up only when no job is running, so it never re-arms one. A failed summary, or an unknown summary context, waits for Retry or configuration. - Historical targets never build an overview in the foreground. Future or changed canon is never used. - The background job sizes the overview for the smallest known of the structured, narration and chat contexts. A reader with an unknown context makes Continuity ask for configuration instead of showing Ready. - Summaries reserve `max(8192, min(max(10240, tokenBudget), maxOutput))` output tokens, replacing `min(2000, …)`. **Docs** - CHANGELOG and in-game What's new (1.24.8 pinned). - README pre-forge and memory paragraphs, worded to what the code does. One example: "no longer waits for memory to catch up". A summary request already running on the same connection still finishes first, and a separate summary connection avoids that. ## Package and security impact - Affected package IDs: `gacha-forge` - Engine compatibility impact: none. - New or changed permissions/entrypoints: none. `/combat-guide` stays, and the client simply no longer calls it before the map. - Restart, storage, update, or uninstall impact: no storage format change. - Saved memory is reused. - An overview built for a larger budget is resized by the next background run. Opening a world schedules that run once per process. ## Validation - [ ] `node scripts/validate-catalog.mjs` passes locally - [ ] `git diff --check` passes locally - [ ] Rebuilt every affected manifest, payload, artifact, and catalog entry - [ ] Installed or updated the affected package through Marinara Engine - [ ] Checked supported modes, restart behavior, and uninstall cleanup - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes **Agent-side checks** - All 68 `tests/gacha-forge-*.regression.mjs` files pass locally, before and after merging staging. - `git diff --check` is clean. - `validate-catalog`'s changelog and notes check passes locally. The sparse worktree lacks other packages' zips, so the full run is left to CI. **New or changed regressions** - `gacha-forge-preforge-art` (29 cases): - The shipped chain writes scene 1, fight 1, scene 2, fight 2 in that order. - Cancel and Off between two fight designs stop the chain with no further model call. - The heartbeat holds across a gap of 45 minutes. - With pre-forge off, `/beat` designs the following fight in the background, with enemy art, without waiting. - Every new case was checked against deliberately broken copies of the server. - `gacha-forge-story-memory`, `-integration` and `-package` now pin: - recall answering from saved memory without summarizing or waiting for an in-flight job; - the lag rules; - raw side canon; - smallest-reader sizing and the 10,240-token reserve; - background scheduling: once per lag, never after "error" or for replays; - a chapter plan making no summary calls once memory is prepared. - `gacha-forge-story-cancel`: Keep playing and plan landing prewarm nothing. - `chapter-regeneration-package`: given an ample window, because unsummarized canon is now sent in full instead of being summarized in front of the scene. - `proactive-messages-sdk`: background summaries are held on a gate. The message is sent while they are pending, and they then complete with records for chapter, chat and event. - `seasonal-events-package`: lets background memory settle before its rollback snapshot. **Review record** - **Local CodeRabbit, two runs:** - First run: a `context-unknown` phase still counted as lagging, so every scene would requeue a job that can't run. Fixed, with a regression. - Second run, after the review fixes: the seasonal rollback test could time out silently while waiting for memory. It now fails clearly instead (870f0373e). - **Adversarial review:** three areas, 14 skeptic-confirmed findings, all fixed in 9c33b7229: - **Fights:** Cancel or Off mid-gap; no early fights or enemy art with pre-forge off; the heartbeat. - **Memory:** the overview thrown away when canon was inserted earlier; side canon with a summary dropped; failing summaries re-armed; the reserve below 8192; unknown readers shown as Ready; recent-canon order. - **Docs and tests:** dialog text, overstated wording, and the vacuous proactive test. - **Memory test suites:** core 32/32, integration 44/44, package 11/11. Every new or modified test fails on the previous semantics. **To verify by hand** - Finish a chapter and open the next one right away. The chapter map appears after the plan alone; no "Designing a fight" wait on the forging screen. - With pre-forge on, watch the chapter screen. Scenes and fights are prepared in order, and entering a fight that was prepared opens without a wait. - With pre-forge off, read a scene that is followed by a fight. When you reach the fight it opens without a design wait, and with its enemy portraits. - Play long chapters with a thinking model as the summary connection. Settings → Story → Continuity shows memory ready instead of an error. - Right after finishing a Character Story, the next scene still knows what happened in it. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation ## UI evidence (if applicable) No layout changes. The forging screen simply ends after the plan. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:38:17 +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-Agents#1955
No description provided.