[PR #1658] feat(gacha-forge): automatically summarize and recall story memories #1646

Open
opened 2026-10-25 04:02:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/1658
Author: @SpicyMarinara
Created: 10/24/2026
Status: 🔄 Open

Base: staging ← Head: feature/1657-gacha-automatic-memory


📝 Commits (7)

  • 00c1b70 docs(gacha-forge): track automatic continuity implementation
  • a2b5a5e feat(gacha-forge): automatically summarize canon and recall relevant memories
  • d4aaa2f Merge remote-tracking branch 'origin/staging' into feature/1657-gacha-automatic-memory
  • c7fa644 fix(gacha-forge): keep pinned token helper in package-owned source
  • 04e4649 fix(gacha-forge): separate chapter recall and retain complete recent canon
  • 2efc8ee fix(gacha-forge): retain live chat context before the first chapter ends
  • 6ebdf97 fix(gacha-forge): resolve continuity memory review findings

📊 Changes

30 files changed (+5408 additions, -84 deletions)

View changed files

📝 .github/workflows/pull-request-checks.yml (+5 -0)
➕ artifacts/gacha-forge-1.14.0.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 (+7 -0)
📝 packages/gacha-forge/README.md (+10 -0)
📝 packages/gacha-forge/bundle-patches.json (+193 -17)
📝 packages/gacha-forge/client.js (+169 -4)
📝 packages/gacha-forge/manifest.json (+5 -5)
📝 packages/gacha-forge/server.mjs (+1165 -11)
➕ packages/gacha-forge/src/shared-token-estimator.mjs (+74 -0)
➕ packages/gacha-forge/src/story-memory-client.mjs (+145 -0)
➕ packages/gacha-forge/src/story-memory-en.mjs (+17 -0)
➕ packages/gacha-forge/src/story-memory-fit.mjs (+109 -0)
➕ packages/gacha-forge/src/story-memory-integration.mjs (+434 -0)
➕ packages/gacha-forge/src/story-memory-shared.mjs (+6 -0)

...and 10 more files

📄 Description

Linked issue

Closes #1657.

Why this change

Gacha Forge required manual chapter compression and repeatedly included historical text. It now remembers completed canon automatically, maintains a bounded overview, and recalls relevant detailed history for later writing.

What changed

  • Release Gacha Forge 1.14.0 with automatic memories for completed normal chapters, Character Stories and every saved character-conversation memory.
  • Keep the always-included overview within 10% of the consuming connection/model's known context, measured with the Engine's public script-aware token estimator. Recompress incrementally, including when the model context shrinks; retain detailed records and source history.
  • Use the requested context order: overview → up to three additional chapter summaries → separate relevant character memories → the entire previous chapter → the current chapter so far. Character memories and the full previous chapter do not consume the three-chapter quota. Drop whole optional recall blocks as needed to fit the actual prompt and output reserve; preserve the overview, full previous chapter, current played history and locked decisions.
  • Archive selected first-play canon only. Replays, unplayed alternatives, future chapters and a writer's planned premise cannot overwrite or become past facts. Current character chats retain the played portion of an unfinished Character Story.
  • Persist progress through revision-checked writes and chunk checkpoints, recover after interruption, coalesce new completions during an active update, and fence deleted worlds against late writes.
  • Show status, explicit retry and context configuration guidance in Continuity. Viewing status makes no model requests; missing capacity is reported without guessing. Public model metadata supports hosts that protect loopback HTTP.
  • Rebuild the archive/manifests/catalogs, document the behavior, and register maintained regressions in PR checks. Bundle pinned public shared helpers at build time without runtime workspace imports.

Review follow-up

  • Preserve absent/nonpositive output caps; reduce only existing positive caps. Maintained controls cover undefined/null/zero/negative/NaN with and without memory metadata. The five shipped writers already request positive caps; final dS telemetry is traced.
  • Report unknown generation or compression capacity as nonretryable context-unknown, before chunk search or generation; test configuration recovery and capacity disappearing mid-job.
  • Preserve the same status/live-region and action DOM nodes across polling, retry and full settings redraws. Retain keyboard focus deliberately and reconcile interrupted requests through read-only status; the full-render path wires once. Browser negatives reproduced both replacement and duplicate wiring before repair.
  • Rebuild smaller eligible source projections without deleting archived originals. The new [chapter 1, chapter 2] -> [chapter 1] control passes while retaining both archives; existing source/epoch/CAS/operation fences remain.
  • The build portability hypothesis was not reproduced: documented npm ci installs pinned tsx@4.23.15 and locked esbuild@0.28.2; the existing repository-root resolver and clean/copied-root rebuilds pass. Installed packages need neither compiler nor workspace imports.
  • Actual shipped legacy ha reads only top-level data.bonds; the new memory document has none. Two extracted-function controls preserve existing manual-summary chronology and show no memory-document contribution.
  • Keep the small existing max-output calculation and prior ledger formatting; these are optional refactoring/style suggestions. All human checklist boxes stay unchecked as required by this repository.

Package and security impact

  • Package: gacha-forge; Engine minimum/capability API and permissions/entrypoints remain unchanged (Engine >=2.5.1, capability API 1.381).
  • Memory uses existing package-scoped summary documents and configured text connections. No Engine-private memory service, authentication secret access, new provider or storage-format migration.
  • Original worlds, manual summaries, canonical choices and detailed memories remain saved. No import/export limits.
  • Normal package update/restart applies. Delete and uninstall paths are exercised below.

Validation

All human checklist boxes remain unchecked.

  • 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

Recorded automated/local evidence:

  • Validated source head: 6ebdf971c435affd8c5c58bbb6341220af2503dc. The exact installed archive, all 247 payloads, UI checks and update/restart/uninstall proof agree with this commit. Declared package build provenance and separately tested Engine host are recorded distinctly.
  • npm run check: passed, zero errors; existing repository warnings remain.
  • All four catalog/lane/locale/release-note baselines, vendored-source regression, server host/singleton gates and diff check: passed.
  • 17 Gacha regression scripts passed, including 66 focused logic/route cases. These cover canon, context shrink/chunking, source/CAS/restart fences, all chat records, actual next-chapter provider prompt/output budgeting, and protected metadata fallback. Model responses are explicit fixtures; no provider generation claimed.
  • Bundle replay/source regeneration is deterministic, including copied build roots and every new maintained helper. Unknown bundle edits still fail closed.
  • Exact 1.13.1 -> 1.14.0 package-manager update, saved world/audio/roster/rewards/guide/memory preservation, offline restart, a genuine fresh Node process and uninstall/fresh-process 404: passed using an isolated private Engine host. Lifecycle memory is explicitly seeded; generation is proven separately by shipped-route tests.
  • Independent source reviews found issues with planned premises, partial Character Story history, final request fitting, unknown-context recovery, duplicated fallback history and first-chapter chat recovery; all were fixed and covered before the final artifact build.
  • Local CodeRabbit reviewed the feature and subsequent repair scopes. The clarified recall-policy review raised one trivial recommendation to optimize an additional canonical-source scan; it was deferred because reusing the single canon/chronology reader avoids duplicating eligibility rules. Recovery reviews completed with zero new findings. The first review-repair pass covered 11/11 files with zero findings; the UI capture/reconciliation follow-up covered 5/5 with zero findings. The final two-file duplicate-wiring/fixture follow-up reviewed 2/2 files with zero findings; byte readback confirms all 12 maintained changed files match their latest completed review snapshots. Browser tests caught and verified the actual full-redraw boundary; no source override or weaker read-count assertions were used.

Artifact: gacha-forge-1.14.0.zip, 8,061,858 bytes, SHA256 2b461e13018d41955ddaf84ab39f0aebd089e67d0fd15721b43f82e661f47141.

Manual verification still requested

  • Play a real world through a completed chapter, Character Story and character conversation with the configured provider.
  • Verify first-canon/replay behavior and subsequent relevant recall with real story content.
  • Verify the Continuity status/actions on a physical phone.

Documentation impact

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

Package README and release notes describe automatic continuity, capacity configuration and the preserved manual controls.

UI evidence

Nine strengthened memory-status cases and fifteen affected choices/Continuity/editor/scene executions passed on desktop Chromium, mobile Chromium and mobile WebKit: 24/24, zero skipped or flaky. Six screenshots were inspected for wrapping, reachable recovery actions and preserved manual controls. The shipped client preserves native status/button identity and deliberate focus through Retry and full settings redraws; exact request counts prove interrupted work is reconciled with read-only status, without repeating generation. Network traces verify cancellation and old-world response fencing.

These browser APIs are mocked; mobile WebKit is emulation. Physical-device and real-provider checks remain requested above. The exact tested and installed archive client is 597a89da04e3c97369c7418516ee2ae17d24f7a1b37a281fdefe8f5215f312da; server/lifecycle validation is separate. Screenshots, traces, original negative controls and update/restart receipts are retained locally.


🔄 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/1658 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/24/2026 **Status:** 🔄 Open **Base:** `staging` ← **Head:** `feature/1657-gacha-automatic-memory` --- ### 📝 Commits (7) - [`00c1b70`](https://github.com/Pasta-Devs/Marinara-Agents/commit/00c1b70789de1be4bc1c27e6ef83caa9d24c8610) docs(gacha-forge): track automatic continuity implementation - [`a2b5a5e`](https://github.com/Pasta-Devs/Marinara-Agents/commit/a2b5a5e20b2f97ccc61776840f55597b5cd39423) feat(gacha-forge): automatically summarize canon and recall relevant memories - [`d4aaa2f`](https://github.com/Pasta-Devs/Marinara-Agents/commit/d4aaa2fa03845d95c7e08de07cffbebf403d7fab) Merge remote-tracking branch 'origin/staging' into feature/1657-gacha-automatic-memory - [`c7fa644`](https://github.com/Pasta-Devs/Marinara-Agents/commit/c7fa64474eaf6cbe6337b0e363b809312f89eea4) fix(gacha-forge): keep pinned token helper in package-owned source - [`04e4649`](https://github.com/Pasta-Devs/Marinara-Agents/commit/04e46492e8d2f4facf084da1da0ebf29f425f0b4) fix(gacha-forge): separate chapter recall and retain complete recent canon - [`2efc8ee`](https://github.com/Pasta-Devs/Marinara-Agents/commit/2efc8ee550a61a4c666d6fdb3d2ab32c3d75e8f7) fix(gacha-forge): retain live chat context before the first chapter ends - [`6ebdf97`](https://github.com/Pasta-Devs/Marinara-Agents/commit/6ebdf971c435affd8c5c58bbb6341220af2503dc) fix(gacha-forge): resolve continuity memory review findings ### 📊 Changes **30 files changed** (+5408 additions, -84 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/pull-request-checks.yml` (+5 -0) ➕ `artifacts/gacha-forge-1.14.0.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` (+7 -0) 📝 `packages/gacha-forge/README.md` (+10 -0) 📝 `packages/gacha-forge/bundle-patches.json` (+193 -17) 📝 `packages/gacha-forge/client.js` (+169 -4) 📝 `packages/gacha-forge/manifest.json` (+5 -5) 📝 `packages/gacha-forge/server.mjs` (+1165 -11) ➕ `packages/gacha-forge/src/shared-token-estimator.mjs` (+74 -0) ➕ `packages/gacha-forge/src/story-memory-client.mjs` (+145 -0) ➕ `packages/gacha-forge/src/story-memory-en.mjs` (+17 -0) ➕ `packages/gacha-forge/src/story-memory-fit.mjs` (+109 -0) ➕ `packages/gacha-forge/src/story-memory-integration.mjs` (+434 -0) ➕ `packages/gacha-forge/src/story-memory-shared.mjs` (+6 -0) _...and 10 more files_ </details> ### 📄 Description ## Linked issue Closes #1657. ## Why this change Gacha Forge required manual chapter compression and repeatedly included historical text. It now remembers completed canon automatically, maintains a bounded overview, and recalls relevant detailed history for later writing. ## What changed - Release Gacha Forge **1.14.0** with automatic memories for completed normal chapters, Character Stories and every saved character-conversation memory. - Keep the always-included overview within **10% of the consuming connection/model's known context**, measured with the Engine's public script-aware token estimator. Recompress incrementally, including when the model context shrinks; retain detailed records and source history. - Use the requested context order: **overview → up to three additional chapter summaries → separate relevant character memories → the entire previous chapter → the current chapter so far**. Character memories and the full previous chapter do not consume the three-chapter quota. Drop whole optional recall blocks as needed to fit the actual prompt and output reserve; preserve the overview, full previous chapter, current played history and locked decisions. - Archive selected first-play canon only. Replays, unplayed alternatives, future chapters and a writer's planned premise cannot overwrite or become past facts. Current character chats retain the played portion of an unfinished Character Story. - Persist progress through revision-checked writes and chunk checkpoints, recover after interruption, coalesce new completions during an active update, and fence deleted worlds against late writes. - Show status, explicit retry and context configuration guidance in Continuity. Viewing status makes no model requests; missing capacity is reported without guessing. Public model metadata supports hosts that protect loopback HTTP. - Rebuild the archive/manifests/catalogs, document the behavior, and register maintained regressions in PR checks. Bundle pinned public shared helpers at build time without runtime workspace imports. ## Review follow-up - Preserve absent/nonpositive output caps; reduce only existing positive caps. Maintained controls cover undefined/null/zero/negative/NaN with and without memory metadata. The five shipped writers already request positive caps; final `dS` telemetry is traced. - Report unknown generation **or compression** capacity as nonretryable `context-unknown`, before chunk search or generation; test configuration recovery and capacity disappearing mid-job. - Preserve the same status/live-region and action DOM nodes across polling, retry and full settings redraws. Retain keyboard focus deliberately and reconcile interrupted requests through read-only status; the full-render path wires once. Browser negatives reproduced both replacement and duplicate wiring before repair. - Rebuild smaller eligible source projections without deleting archived originals. The new `[chapter 1, chapter 2] -> [chapter 1]` control passes while retaining both archives; existing source/epoch/CAS/operation fences remain. - The build portability hypothesis was not reproduced: documented `npm ci` installs pinned `tsx@4.23.15` and locked `esbuild@0.28.2`; the existing repository-root resolver and clean/copied-root rebuilds pass. Installed packages need neither compiler nor workspace imports. - Actual shipped legacy `ha` reads only top-level `data.bonds`; the new memory document has none. Two extracted-function controls preserve existing manual-summary chronology and show no memory-document contribution. - Keep the small existing max-output calculation and prior ledger formatting; these are optional refactoring/style suggestions. All human checklist boxes stay unchecked as required by this repository. ## Package and security impact - Package: `gacha-forge`; Engine minimum/capability API and permissions/entrypoints remain unchanged (Engine >=2.5.1, capability API 1.381). - Memory uses existing package-scoped summary documents and configured text connections. No Engine-private memory service, authentication secret access, new provider or storage-format migration. - Original worlds, manual summaries, canonical choices and detailed memories remain saved. No import/export limits. - Normal package update/restart applies. Delete and uninstall paths are exercised below. ## Validation All human checklist boxes remain unchecked. - [ ] `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` Recorded automated/local evidence: - Validated source head: `6ebdf971c435affd8c5c58bbb6341220af2503dc`. The exact installed archive, all 247 payloads, UI checks and update/restart/uninstall proof agree with this commit. Declared package build provenance and separately tested Engine host are recorded distinctly. - `npm run check`: passed, zero errors; existing repository warnings remain. - All four catalog/lane/locale/release-note baselines, vendored-source regression, server host/singleton gates and diff check: passed. - **17 Gacha regression scripts** passed, including **66 focused logic/route cases**. These cover canon, context shrink/chunking, source/CAS/restart fences, all chat records, actual next-chapter provider prompt/output budgeting, and protected metadata fallback. Model responses are explicit fixtures; no provider generation claimed. - Bundle replay/source regeneration is deterministic, including copied build roots and every new maintained helper. Unknown bundle edits still fail closed. - Exact 1.13.1 -> 1.14.0 package-manager update, saved world/audio/roster/rewards/guide/memory preservation, offline restart, a genuine fresh Node process and uninstall/fresh-process 404: passed using an isolated private Engine host. Lifecycle memory is explicitly seeded; generation is proven separately by shipped-route tests. - Independent source reviews found issues with planned premises, partial Character Story history, final request fitting, unknown-context recovery, duplicated fallback history and first-chapter chat recovery; all were fixed and covered before the final artifact build. - Local CodeRabbit reviewed the feature and subsequent repair scopes. The clarified recall-policy review raised one trivial recommendation to optimize an additional canonical-source scan; it was deferred because reusing the single canon/chronology reader avoids duplicating eligibility rules. Recovery reviews completed with zero new findings. The first review-repair pass covered 11/11 files with zero findings; the UI capture/reconciliation follow-up covered 5/5 with zero findings. The final two-file duplicate-wiring/fixture follow-up reviewed 2/2 files with zero findings; byte readback confirms all 12 maintained changed files match their latest completed review snapshots. Browser tests caught and verified the actual full-redraw boundary; no source override or weaker read-count assertions were used. Artifact: `gacha-forge-1.14.0.zip`, **8,061,858 bytes**, SHA256 `2b461e13018d41955ddaf84ab39f0aebd089e67d0fd15721b43f82e661f47141`. ### Manual verification still requested - [ ] Play a real world through a completed chapter, Character Story and character conversation with the configured provider. - [ ] Verify first-canon/replay behavior and subsequent relevant recall with real story content. - [ ] Verify the Continuity status/actions on a physical phone. ## Documentation impact - [ ] No documentation changes needed - [ ] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation Package README and release notes describe automatic continuity, capacity configuration and the preserved manual controls. ## UI evidence Nine strengthened memory-status cases and fifteen affected choices/Continuity/editor/scene executions passed on desktop Chromium, mobile Chromium and mobile WebKit: **24/24, zero skipped or flaky**. Six screenshots were inspected for wrapping, reachable recovery actions and preserved manual controls. The shipped client preserves native status/button identity and deliberate focus through Retry and full settings redraws; exact request counts prove interrupted work is reconciled with read-only status, without repeating generation. Network traces verify cancellation and old-world response fencing. These browser APIs are mocked; mobile WebKit is emulation. Physical-device and real-provider checks remain requested above. The exact tested and installed archive client is `597a89da04e3c97369c7418516ee2ae17d24f7a1b37a281fdefe8f5215f312da`; server/lifecycle validation is separate. Screenshots, traces, original negative controls and update/restart receipts are retained locally. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1646
No description provided.