[PR #4647] [MERGED] fix(noodle): stop image captioning from blocking its own background refresh #6454

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4647
Author: @Gunterlie
Created: 8/5/2026
Status: ✅ Merged
Merged: 8/5/2026
Merged by: @Gunterlie

Base: staging ← Head: fix/4642-noodle-background-captioning


📝 Commits (4)

  • 1ee22eb fix(noodle): stop image captioning from blocking its own background refresh
  • 9b04da7 Merge branch 'staging' into fix/4642-noodle-background-captioning
  • 2e47b6a fix(generation): restore the unaccounted admission mode and scope the captioning exemption
  • 318ee9c Merge remote-tracking branch 'origin/fix/4642-noodle-background-captioning' into fix/4642-noodle-background-captioning

📊 Changes

4 files changed (+108 additions, -2 deletions)

View changed files

📝 packages/server/src/routes/noodle.routes.ts (+1 -0)
📝 packages/server/src/services/generation/connection-admission.ts (+9 -2)
📝 packages/server/src/services/generation/image-captioning-runtime.ts (+13 -0)
📝 scripts/regressions/provider-compat.regression.ts (+85 -0)

📄 Description

Linked issue

Closes #4642

Why this change

Scheduled Noodle refreshes have been failing since 2.4.1 with Connection <id> is not available for background generation, while manual refreshes keep working. The reporter's schedule sat at 0/6 slots indefinitely, and recreating connections only produced a new id with the same failure.

The message is misleading: it means "busy", not "missing", so the reported hunt for an absent data/connections folder was a red herring.

A refresh captions the images already on the timeline before generating new posts (noodle-public-prompt.service.ts:491, inside the prompt built at noodle-public-generation.service.ts:246, before the generation call at :302). The captioning provider was built with no admission mode, so withConnectionFallbackProvider defaulted it to {kind:"foreground"}. With the default "Use Noodle generation connection" captioning setting, that books a foreground slot on the exact connection the refresh is about to generate with. Releasing a foreground slot stamps lastForegroundFinishedAt, and background admission refuses for BACKGROUND_CONNECTION_IDLE_MS (30s) afterwards — so the refresh is refused by its own captioning pass, every scheduled run. Manual refreshes are foreground end to end and never reach that gate; the scheduler's 409 retry reproduces the same self-collision a minute later, forever.

Confirmed with the reporter: disabling image captioning makes scheduled refreshes fire again.

What changed

  • resolveImageCaptioningRuntime takes the caller's admission mode; under background the captioning provider books nothing ({kind:"none"}). Captioning is a step inside the caller's attempt, not a separate attempt, and the caller's own admission already gates it. Foreground behavior is unchanged, so chat captioning (generate.routes.ts:1098) is unaffected.
  • The Noodle refresh route threads admissionModeForRequest(req.headers) into the captioning runtime.
  • Regression case in provider-compat.regression.ts: captioning under background admission must leave the connection's background slot free; under foreground it must still take it.

Swept the rest of the scheduled path for other foreground-booking calls on the same connection — ambient profile generation is route-only, NoodleR services are not on this path, lorebook context is previewOnly. Captioning was the only one.

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

Nothing in this PR has been executed. pnpm check and pnpm regression:providers have not been run, and the new regression case has never been run even once — it is unverified in both directions. Needed before merge:

  • Run pnpm check.
  • Run pnpm regression:providers on this branch, and on staging to confirm the new case actually fails without the fix.
  • Manually verify a scheduled refresh in the app: image captioning enabled with the captioning connection set to "Use Noodle generation connection", at least one image-bearing post already on the timeline, then wait for an automatic slot and confirm it generates instead of reporting the connection unavailable.
  • Manually verify the foreground path is unchanged: send a chat message with an image attached and confirm captioning still runs normally.

Note the current regression covers the captioning seam (does captioning book a foreground slot), not the reported symptom (does a scheduled refresh complete). A refresh-level case using the noodle-refresh-transaction / noodle-scheduler harness would be the stronger test and is not included here.

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)

Summary by CodeRabbit

  • Bug Fixes

    • Improved image captioning connection handling during content refreshes.
    • Background captioning now uses the appropriate background connection capacity, while foreground captioning remains unaffected.
    • Prevented duplicate connection admission for captioning work already covered by an active generation request, improving reliability during refreshes.
  • Tests

    • Added regression coverage to verify connection admission behavior for background and foreground image captioning, including proper cleanup after processing.

🔄 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/4647 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 8/5/2026 **Status:** ✅ Merged **Merged:** 8/5/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `fix/4642-noodle-background-captioning` --- ### 📝 Commits (4) - [`1ee22eb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1ee22eb7ba3a7fe0d4ecf83cf2a387e8986ec8f5) fix(noodle): stop image captioning from blocking its own background refresh - [`9b04da7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9b04da729f7b3bc62688561b108acd0402703798) Merge branch 'staging' into fix/4642-noodle-background-captioning - [`2e47b6a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2e47b6a4f8e3b16404cb2350d26d508c57768eae) fix(generation): restore the unaccounted admission mode and scope the captioning exemption - [`318ee9c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/318ee9c5faaf396f1b22214dabdfd40f1f2c76c1) Merge remote-tracking branch 'origin/fix/4642-noodle-background-captioning' into fix/4642-noodle-background-captioning ### 📊 Changes **4 files changed** (+108 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/noodle.routes.ts` (+1 -0) 📝 `packages/server/src/services/generation/connection-admission.ts` (+9 -2) 📝 `packages/server/src/services/generation/image-captioning-runtime.ts` (+13 -0) 📝 `scripts/regressions/provider-compat.regression.ts` (+85 -0) </details> ### 📄 Description ## Linked issue Closes #4642 ## Why this change Scheduled Noodle refreshes have been failing since 2.4.1 with `Connection <id> is not available for background generation`, while manual refreshes keep working. The reporter's schedule sat at 0/6 slots indefinitely, and recreating connections only produced a new id with the same failure. The message is misleading: it means "busy", not "missing", so the reported hunt for an absent `data/connections` folder was a red herring. A refresh captions the images already on the timeline before generating new posts (`noodle-public-prompt.service.ts:491`, inside the prompt built at `noodle-public-generation.service.ts:246`, before the generation call at :302). The captioning provider was built with no admission mode, so `withConnectionFallbackProvider` defaulted it to `{kind:"foreground"}`. With the default "Use Noodle generation connection" captioning setting, that books a foreground slot on the exact connection the refresh is about to generate with. Releasing a foreground slot stamps `lastForegroundFinishedAt`, and background admission refuses for `BACKGROUND_CONNECTION_IDLE_MS` (30s) afterwards — so the refresh is refused by its own captioning pass, every scheduled run. Manual refreshes are foreground end to end and never reach that gate; the scheduler's 409 retry reproduces the same self-collision a minute later, forever. Confirmed with the reporter: disabling image captioning makes scheduled refreshes fire again. ## What changed - `resolveImageCaptioningRuntime` takes the caller's admission mode; under `background` the captioning provider books nothing (`{kind:"none"}`). Captioning is a step inside the caller's attempt, not a separate attempt, and the caller's own admission already gates it. Foreground behavior is unchanged, so chat captioning (`generate.routes.ts:1098`) is unaffected. - The Noodle refresh route threads `admissionModeForRequest(req.headers)` into the captioning runtime. - Regression case in `provider-compat.regression.ts`: captioning under background admission must leave the connection's background slot free; under foreground it must still take it. Swept the rest of the scheduled path for other foreground-booking calls on the same connection — ambient profile generation is route-only, NoodleR services are not on this path, lorebook context is `previewOnly`. Captioning was the only one. ## 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 Nothing in this PR has been executed. `pnpm check` and `pnpm regression:providers` have not been run, and the new regression case has never been run even once — it is unverified in both directions. Needed before merge: - Run `pnpm check`. - Run `pnpm regression:providers` on this branch, and on `staging` to confirm the new case actually fails without the fix. - Manually verify a scheduled refresh in the app: image captioning enabled with the captioning connection set to "Use Noodle generation connection", at least one image-bearing post already on the timeline, then wait for an automatic slot and confirm it generates instead of reporting the connection unavailable. - Manually verify the foreground path is unchanged: send a chat message with an image attached and confirm captioning still runs normally. Note the current regression covers the captioning seam (does captioning book a foreground slot), not the reported symptom (does a scheduled refresh complete). A refresh-level case using the `noodle-refresh-transaction` / `noodle-scheduler` harness would be the stronger test and is not included here. ## Docs and release impact - [x] 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) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved image captioning connection handling during content refreshes. * Background captioning now uses the appropriate background connection capacity, while foreground captioning remains unaffected. * Prevented duplicate connection admission for captioning work already covered by an active generation request, improving reliability during refreshes. * **Tests** * Added regression coverage to verify connection admission behavior for background and foreground image captioning, including proper cleanup after processing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:10:35 +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#6454
No description provided.