[PR #3782] [MERGED] refactor(noodle): extract public generation service #6100

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

📋 Pull Request Information

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

Base: staging ← Head: noodl-split-3-public-generation-seam


📝 Commits (9)

  • e2c89fa refactor(noodle): extract public generation service
  • 139786a fix(noodle): preserve refresh cleanup errors
  • af50d52 refactor(generation): move shared runtimes into services
  • 9a386ce refactor(noodle): split public generation services
  • 55e0b58 refactor(noodle): simplify generated post targeting
  • fe93d89 fix(noodle): address generation review findings
  • b5b188f Merge remote-tracking branch 'origin/staging' into noodl-split-3-public-generation-seam
  • 196d8af fix(noodle): preserve merged generation behavior
  • 683de9a fix(noodle): preserve calculated token budgets

📊 Changes

30 files changed (+4160 additions, -2819 deletions)

View changed files

📝 package.json (+2 -2)
📝 packages/server/src/db/schema/noodle.ts (+2 -0)
📝 packages/server/src/routes/generate.routes.ts (+2 -0)
📝 packages/server/src/routes/generate/generate-route-utils.ts (+23 -261)
📝 packages/server/src/routes/generate/illustrator-references.ts (+1 -311)
📝 packages/server/src/routes/generate/image-captioning-runtime.ts (+1 -311)
📝 packages/server/src/routes/noodle.routes.ts (+34 -1826)
➕ packages/server/src/services/generation/connection-base-url.ts (+13 -0)
📝 packages/server/src/services/generation/conversation-selfie-command-runtime.ts (+2 -2)
📝 packages/server/src/services/generation/generation-parameters.ts (+25 -1)
➕ packages/server/src/services/generation/image-captioning-runtime.ts (+380 -0)
➕ packages/server/src/services/generation/local-sidecar-generation-connection.ts (+83 -0)
📝 packages/server/src/services/generation/media-connection-fallback.ts (+1 -1)
➕ packages/server/src/services/generation/prompt-attachments.ts (+171 -0)
➕ packages/server/src/services/image/illustrator-references.ts (+305 -0)
📝 packages/server/src/services/image/image-generation.ts (+44 -1)
➕ packages/server/src/services/noodle/noodle-generated-activity.service.ts (+404 -0)
📝 packages/server/src/services/noodle/noodle-participant-selection.ts (+44 -1)
➕ packages/server/src/services/noodle/noodle-public-generation.service.ts (+467 -0)
➕ packages/server/src/services/noodle/noodle-public-images.service.ts (+409 -0)

...and 10 more files

📄 Description

NOODLER IMPLEMENTATION PLAN - SLICE 3: This PR is Slice 3, the public generation service seam. It builds on Slice 1A (#3744), Slice 1B (#3751), and Slice 2 (#3759). Later NoodleR capabilities, including private generation, stage identity, subscriptions, fan activity, automatic posting, cross-mode integration, and creator projects, remain intentionally out of scope.

Linked issue

Closes #3781

Summary

  • Extract the existing public Noodle generation pipeline from noodle.routes.ts into a small DB-backed coordinator plus focused prompt, profile, image, and generated-activity services.
  • Keep request validation, HTTP status handling, connection checks, and refresh-in-flight coordination in the route.
  • Give reviewed-image generation a domain-level service operation so the route no longer wires storage and prompt internals.
  • Move shared base-URL, image-captioning, Illustrator-reference, sidecar, and attachment runtimes to canonical service-owned modules; retain compatibility re-exports for existing route imports.
  • Move priority-account policy beside participant selection and narrow the coordinator API to its actual consumer.
  • Preserve prompt assembly, provider fallback, correction retry, image generation, generated activity persistence, digests, and refresh-run behavior.

Why

POST /api/noodle/refresh previously acted as both the HTTP endpoint and the reusable public-generation service layer. That made the generation operation difficult to reuse safely and gave later NoodleR slices the wrong extension point.

This slice resolves P2 Finding 5 for the existing public generation pipeline by establishing the invariant that routes do not own reusable generation business logic. It does not generalize the operation for capabilities that have not landed yet.

Known limitations

  • This PR does not add private NoodleR generation or any later NoodleR capability.
  • No user-visible behavior is intended to change.
  • The extraction is mechanically large because the complete public generation pipeline was previously embedded in one route file.
  • The generation service remains specific to public Noodle generation. Later slices should add their own typed operations rather than adding private-mode branching here.
  • The full pnpm regression command reached and passed every non-browser lane, but Playwright could not launch Chromium in the implementation environment because host-native browser libraries are missing (libnspr4, NSS, ATK, X11, GBM, and ALSA dependencies).

Test plan

  • Run pnpm check.
  • Run pnpm guard:installer-artifacts.
  • Run pnpm regression:prompt.
  • Run pnpm regression.
  • Manually generate a public Noodle timeline with an invited character.
  • Manually generate a public Noodle timeline with random-user fillers.
  • Verify generated posts, interactions, polls, follows, digests, and notifications match existing behavior.
  • Verify the selected persona remains reference-only during generated activity.
  • Verify image generation with image-prompt review disabled.
  • Verify image-prompt review and approval when an image connection is available.
  • Verify concurrent refresh requests retain the existing conflict response.
  • Verify invalid and unavailable generation connections retain their existing errors.
  • Verify one automatic public refresh reaches the same public generation operation.
  • Run pnpm smoke:ui on a host with Playwright Chromium dependencies installed.

Validation notes

A temporary deterministic script exercised the actual POST /api/noodle/refresh route against isolated file storage and a local OpenAI-compatible fixture before and after extraction. After normalizing generated IDs, the canonical response output was byte-identical. The temporary script was removed before commit.

pnpm check, pnpm guard:installer-artifacts, pnpm regression:prompt, and all non-browser lanes in pnpm regression passed locally. Playwright was blocked at browser startup by missing host libraries, before any UI test assertions ran.

Docs touched

None. This is an internal service extraction with no user-visible or public-contract change.

Summary by CodeRabbit

  • New Features

    • Improved public timeline generation with enhanced profile bootstrapping and priority-based participant selection.
    • Added reviewed-image generation for public refreshes, including preview handling.
    • Introduced image captioning for supported prompt attachments, with caption caching/reuse and prompt augmentation.
    • Improved readable file/image attachment handling and attachment extraction safety.
    • Added image-claim leasing to coordinate image generation and finalization.
  • Bug Fixes

    • Improved handling of unsupported vision inputs with automatic text-only fallback.
    • Strengthened refresh transaction safety (rollback prevents partial media/persistence).
  • Tests

    • Added/extended noodle and prompt-attachment regression coverage.

🔄 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/3782 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 7/18/2026 **Status:** ✅ Merged **Merged:** 7/18/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `noodl-split-3-public-generation-seam` --- ### 📝 Commits (9) - [`e2c89fa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e2c89faf04db48320d1542cb6ce0fc0beb55c2d1) refactor(noodle): extract public generation service - [`139786a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/139786acc7096b11b85b517647d65ad279ad00dd) fix(noodle): preserve refresh cleanup errors - [`af50d52`](https://github.com/Pasta-Devs/Marinara-Engine/commit/af50d52b6562d132e96c4aca54b6cf7d763aae28) refactor(generation): move shared runtimes into services - [`9a386ce`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9a386ce57256f2024a1d3579c90d59ff272989cb) refactor(noodle): split public generation services - [`55e0b58`](https://github.com/Pasta-Devs/Marinara-Engine/commit/55e0b588f9f89f40d3fd68647abd76c1897a9f62) refactor(noodle): simplify generated post targeting - [`fe93d89`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fe93d89b1af52d0baa75436f27ea8f062a8d135b) fix(noodle): address generation review findings - [`b5b188f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b5b188f0274f9f9581e490019118b3b4e3f5ad36) Merge remote-tracking branch 'origin/staging' into noodl-split-3-public-generation-seam - [`196d8af`](https://github.com/Pasta-Devs/Marinara-Engine/commit/196d8afc2d7ed92f81733f65bc464ca76c17e3bf) fix(noodle): preserve merged generation behavior - [`683de9a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/683de9af74c77946ba89b2972159b7dc6d58d7cf) fix(noodle): preserve calculated token budgets ### 📊 Changes **30 files changed** (+4160 additions, -2819 deletions) <details> <summary>View changed files</summary> 📝 `package.json` (+2 -2) 📝 `packages/server/src/db/schema/noodle.ts` (+2 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+2 -0) 📝 `packages/server/src/routes/generate/generate-route-utils.ts` (+23 -261) 📝 `packages/server/src/routes/generate/illustrator-references.ts` (+1 -311) 📝 `packages/server/src/routes/generate/image-captioning-runtime.ts` (+1 -311) 📝 `packages/server/src/routes/noodle.routes.ts` (+34 -1826) ➕ `packages/server/src/services/generation/connection-base-url.ts` (+13 -0) 📝 `packages/server/src/services/generation/conversation-selfie-command-runtime.ts` (+2 -2) 📝 `packages/server/src/services/generation/generation-parameters.ts` (+25 -1) ➕ `packages/server/src/services/generation/image-captioning-runtime.ts` (+380 -0) ➕ `packages/server/src/services/generation/local-sidecar-generation-connection.ts` (+83 -0) 📝 `packages/server/src/services/generation/media-connection-fallback.ts` (+1 -1) ➕ `packages/server/src/services/generation/prompt-attachments.ts` (+171 -0) ➕ `packages/server/src/services/image/illustrator-references.ts` (+305 -0) 📝 `packages/server/src/services/image/image-generation.ts` (+44 -1) ➕ `packages/server/src/services/noodle/noodle-generated-activity.service.ts` (+404 -0) 📝 `packages/server/src/services/noodle/noodle-participant-selection.ts` (+44 -1) ➕ `packages/server/src/services/noodle/noodle-public-generation.service.ts` (+467 -0) ➕ `packages/server/src/services/noodle/noodle-public-images.service.ts` (+409 -0) _...and 10 more files_ </details> ### 📄 Description > **NOODLER IMPLEMENTATION PLAN - SLICE 3:** This PR is Slice 3, the public generation service seam. It builds on Slice 1A (#3744), Slice 1B (#3751), and Slice 2 (#3759). Later NoodleR capabilities, including private generation, stage identity, subscriptions, fan activity, automatic posting, cross-mode integration, and creator projects, remain intentionally out of scope. ## Linked issue Closes #3781 ## Summary - Extract the existing public Noodle generation pipeline from `noodle.routes.ts` into a small DB-backed coordinator plus focused prompt, profile, image, and generated-activity services. - Keep request validation, HTTP status handling, connection checks, and refresh-in-flight coordination in the route. - Give reviewed-image generation a domain-level service operation so the route no longer wires storage and prompt internals. - Move shared base-URL, image-captioning, Illustrator-reference, sidecar, and attachment runtimes to canonical service-owned modules; retain compatibility re-exports for existing route imports. - Move priority-account policy beside participant selection and narrow the coordinator API to its actual consumer. - Preserve prompt assembly, provider fallback, correction retry, image generation, generated activity persistence, digests, and refresh-run behavior. ## Why `POST /api/noodle/refresh` previously acted as both the HTTP endpoint and the reusable public-generation service layer. That made the generation operation difficult to reuse safely and gave later NoodleR slices the wrong extension point. This slice resolves P2 Finding 5 for the existing public generation pipeline by establishing the invariant that routes do not own reusable generation business logic. It does not generalize the operation for capabilities that have not landed yet. ## Known limitations - This PR does not add private NoodleR generation or any later NoodleR capability. - No user-visible behavior is intended to change. - The extraction is mechanically large because the complete public generation pipeline was previously embedded in one route file. - The generation service remains specific to public Noodle generation. Later slices should add their own typed operations rather than adding private-mode branching here. - The full `pnpm regression` command reached and passed every non-browser lane, but Playwright could not launch Chromium in the implementation environment because host-native browser libraries are missing (`libnspr4`, NSS, ATK, X11, GBM, and ALSA dependencies). ## Test plan - [ ] Run `pnpm check`. - [ ] Run `pnpm guard:installer-artifacts`. - [ ] Run `pnpm regression:prompt`. - [ ] Run `pnpm regression`. - [ ] Manually generate a public Noodle timeline with an invited character. - [ ] Manually generate a public Noodle timeline with random-user fillers. - [ ] Verify generated posts, interactions, polls, follows, digests, and notifications match existing behavior. - [ ] Verify the selected persona remains reference-only during generated activity. - [ ] Verify image generation with image-prompt review disabled. - [ ] Verify image-prompt review and approval when an image connection is available. - [ ] Verify concurrent refresh requests retain the existing conflict response. - [ ] Verify invalid and unavailable generation connections retain their existing errors. - [ ] Verify one automatic public refresh reaches the same public generation operation. - [ ] Run `pnpm smoke:ui` on a host with Playwright Chromium dependencies installed. ## Validation notes A temporary deterministic script exercised the actual `POST /api/noodle/refresh` route against isolated file storage and a local OpenAI-compatible fixture before and after extraction. After normalizing generated IDs, the canonical response output was byte-identical. The temporary script was removed before commit. `pnpm check`, `pnpm guard:installer-artifacts`, `pnpm regression:prompt`, and all non-browser lanes in `pnpm regression` passed locally. Playwright was blocked at browser startup by missing host libraries, before any UI test assertions ran. ## Docs touched None. This is an internal service extraction with no user-visible or public-contract change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Improved public timeline generation with enhanced profile bootstrapping and priority-based participant selection. * Added reviewed-image generation for public refreshes, including preview handling. * Introduced image captioning for supported prompt attachments, with caption caching/reuse and prompt augmentation. * Improved readable file/image attachment handling and attachment extraction safety. * Added image-claim leasing to coordinate image generation and finalization. * **Bug Fixes** * Improved handling of unsupported vision inputs with automatic text-only fallback. * Strengthened refresh transaction safety (rollback prevents partial media/persistence). * **Tests** * Added/extended noodle and prompt-attachment regression coverage. <!-- 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:07:04 +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#6100
No description provided.