[PR #4111] [MERGED] Skip Noodle accounts whose character card no longer exists #6238

Closed
opened 2026-10-23 04:08:29 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4111
Author: @Gunterlie
Created: 7/25/2026
Status: ✅ Merged
Merged: 7/26/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/noodle-stale-character-accounts


📝 Commits (1)

  • 9d3adc2 Skip Noodle accounts whose character card no longer exists

📊 Changes

4 files changed (+201 additions, -3 deletions)

View changed files

📝 package.json (+1 -1)
📝 packages/server/src/services/noodle/noodle-public-generation.service.ts (+16 -2)
📝 packages/server/src/services/noodle/noodle-public-support.ts (+31 -0)
➕ scripts/regressions/noodle-context.regression.ts (+153 -0)

📄 Description

Linked issue

Closes #4110

Why this change

A Noodle account stores its own name and handle, independently of the character card it points at. When an account's entityId stops resolving to a character row, the account keeps working — and generation quietly degrades to nothing but names:

  • # Active Noodle Accounts still lists the account, because that data lives on noodle_accounts.
  • # Character Profiles falls back to "No character profiles.", because characters.getById(entityId) returns null (noodle-public-prompt.service.ts:330).
  • # World / Lore is omitted entirely, because the lorebook scan is scoped to a character ID that cannot match anything (noodle-public-prompt.service.ts:438).

No error is raised at any point. The model receives a list of names with no substance, invents its own authors to fill the gap, and those invented handles then fail validateNoodleGeneratedRefresh — so the refresh fails with a confusing "no usable response" error two steps downstream of the actual problem.

Accounts go stale on two paths, neither of which is exotic:

  1. Deleting a character. characters.remove (characters.storage.ts:544) deletes the character row and cleans up character groups, but never touches noodle_accounts. noodleAccounts.entityId is a plain text column with no foreign key (db/schema/noodle.ts:11), so there is no cascade either, and nothing anywhere prunes accounts.
  2. Re-creating a character under a new ID. characters.create mints newId() (characters.storage.ts:412), and the legacy profile import calls it for every restored character (backup.routes.ts:2536) while never touching noodle_accounts. A profile import therefore re-IDs every character and orphans every character account at once, without the user deleting anything.

A stale account also crowds out healthy ones: participant selection picks N candidates without checking whether the entity still resolves, so a few stale accounts can consume every participant slot.

What changed

  • noodle-public-support.ts — new filterResolvableNoodleParticipants(accounts, characters), returning { resolvable, staleAccounts }. Non-character accounts are always kept (they have no character card to resolve).
  • noodle-public-generation.service.ts — participant selection now runs on the resolvable set. Stale accounts are logged with handle and entityId so this is diagnosable instead of silent.
  • Accounts are not deleted. Existing posts reference them, so removing rows would take timeline history with it; they are only skipped when choosing who takes part in a refresh. This also means installs that already have stale accounts recover immediately, with no migration.
  • When every invited character is stale, the refresh error now names the real problem ("Every invited Noodle character points at a character card that no longer exists…") instead of the misleading "Invite a character…".
  • scripts/regressions/noodle-context.regression.ts (new, wired into pnpm regression:noodle) — asserts a healthy account carries its character card and activates character-scoped lorebook entries; then drops the character row and asserts the exact reported degradation (name present, no <character> block, no # World / Lore, zero activated entries); then asserts the stale account is filtered out and non-character accounts are kept.

Not addressed here, deliberately: nothing stops stale accounts from being created. Pruning on character delete is a separate change with data-loss implications for posts, and it would not help installs that already have them. Worth a follow-up.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually verify in the app: invite two characters to Noodle, delete one of them, then run a timeline refresh. Confirm the surviving character still contributes its card and lore, and that the deleted one no longer appears as an author.
  • Manually verify the server log shows [noodle] Skipping N Noodle account(s) whose character no longer exists: @handle (id) for that refresh.
  • Manually verify the all-stale case: delete every invited character, refresh, and confirm the error names the stale-card problem rather than saying "Invite a character".
  • Manually verify a normal refresh with no stale accounts is unchanged — character cards and # World / Lore still present in the logged prompt with Debug mode on.
  • Manually verify existing Noodle posts authored by a deleted character still render in the timeline (accounts are skipped, not deleted).

Automated, run locally:

  • pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/noodle-context.regression.ts — passes with this change, fails without it (verified by reverting the helper).
  • pnpm check — passes (one pre-existing unrelated client lint warning, 0 errors).

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)


🔄 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/4111 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 7/25/2026 **Status:** ✅ Merged **Merged:** 7/26/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/noodle-stale-character-accounts` --- ### 📝 Commits (1) - [`9d3adc2`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9d3adc21e98e0cb85d75ba146c9c20f5dc55e817) Skip Noodle accounts whose character card no longer exists ### 📊 Changes **4 files changed** (+201 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `package.json` (+1 -1) 📝 `packages/server/src/services/noodle/noodle-public-generation.service.ts` (+16 -2) 📝 `packages/server/src/services/noodle/noodle-public-support.ts` (+31 -0) ➕ `scripts/regressions/noodle-context.regression.ts` (+153 -0) </details> ### 📄 Description ## Linked issue Closes #4110 <!-- #4110 covers the wider "Noodle generation lost its character and lore context" report. This PR fixes one confirmed cause of it; PR #4109 fixes a separate one. --> ## Why this change A Noodle account stores its own name and handle, independently of the character card it points at. When an account's `entityId` stops resolving to a character row, the account keeps working — and generation quietly degrades to nothing but names: - `# Active Noodle Accounts` still lists the account, because that data lives on `noodle_accounts`. - `# Character Profiles` falls back to "No character profiles.", because `characters.getById(entityId)` returns `null` (`noodle-public-prompt.service.ts:330`). - `# World / Lore` is omitted entirely, because the lorebook scan is scoped to a character ID that cannot match anything (`noodle-public-prompt.service.ts:438`). No error is raised at any point. The model receives a list of names with no substance, invents its own authors to fill the gap, and those invented handles then fail `validateNoodleGeneratedRefresh` — so the refresh fails with a confusing "no usable response" error two steps downstream of the actual problem. Accounts go stale on two paths, neither of which is exotic: 1. **Deleting a character.** `characters.remove` (`characters.storage.ts:544`) deletes the character row and cleans up character groups, but never touches `noodle_accounts`. `noodleAccounts.entityId` is a plain text column with no foreign key (`db/schema/noodle.ts:11`), so there is no cascade either, and nothing anywhere prunes accounts. 2. **Re-creating a character under a new ID.** `characters.create` mints `newId()` (`characters.storage.ts:412`), and the legacy profile import calls it for every restored character (`backup.routes.ts:2536`) while never touching `noodle_accounts`. A profile import therefore re-IDs every character and orphans every character account at once, without the user deleting anything. A stale account also crowds out healthy ones: participant selection picks N candidates without checking whether the entity still resolves, so a few stale accounts can consume every participant slot. ## What changed - **`noodle-public-support.ts`** — new `filterResolvableNoodleParticipants(accounts, characters)`, returning `{ resolvable, staleAccounts }`. Non-character accounts are always kept (they have no character card to resolve). - **`noodle-public-generation.service.ts`** — participant selection now runs on the resolvable set. Stale accounts are logged with handle and `entityId` so this is diagnosable instead of silent. - Accounts are **not** deleted. Existing posts reference them, so removing rows would take timeline history with it; they are only skipped when choosing who takes part in a refresh. This also means installs that already have stale accounts recover immediately, with no migration. - When *every* invited character is stale, the refresh error now names the real problem ("Every invited Noodle character points at a character card that no longer exists…") instead of the misleading "Invite a character…". - **`scripts/regressions/noodle-context.regression.ts`** (new, wired into `pnpm regression:noodle`) — asserts a healthy account carries its character card and activates character-scoped lorebook entries; then drops the character row and asserts the exact reported degradation (name present, no `<character>` block, no `# World / Lore`, zero activated entries); then asserts the stale account is filtered out and non-character accounts are kept. Not addressed here, deliberately: nothing stops stale accounts from being *created*. Pruning on character delete is a separate change with data-loss implications for posts, and it would not help installs that already have them. Worth a follow-up. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - [ ] Manually verify in the app: invite two characters to Noodle, delete one of them, then run a timeline refresh. Confirm the surviving character still contributes its card and lore, and that the deleted one no longer appears as an author. - [ ] Manually verify the server log shows `[noodle] Skipping N Noodle account(s) whose character no longer exists: @handle (id)` for that refresh. - [ ] Manually verify the all-stale case: delete every invited character, refresh, and confirm the error names the stale-card problem rather than saying "Invite a character". - [ ] Manually verify a normal refresh with no stale accounts is unchanged — character cards and `# World / Lore` still present in the logged prompt with Debug mode on. - [ ] Manually verify existing Noodle posts authored by a deleted character still render in the timeline (accounts are skipped, not deleted). Automated, run locally: - `pnpm --filter @marinara-engine/server exec tsx ../../scripts/regressions/noodle-context.regression.ts` — passes with this change, fails without it (verified by reverting the helper). - `pnpm check` — passes (one pre-existing unrelated client lint warning, 0 errors). ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) <!-- No UI changes; server-side participant selection only. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:08:29 +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#6238
No description provided.