mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #4514] [MERGED] fix(generation): centralize connection admission and provider fallback #6406
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6406
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4514
Author: @Gunterlie
Created: 8/3/2026
Status: ✅ Merged
Merged: 8/3/2026
Merged by: @Gunterlie
Base:
staging← Head:fix/connection-admission📝 Commits (7)
d9d3af4fix(generation): centralize connection admission and provider fallback7f4bb3dfix(generation): wire background admission and share one attempt across fallbackb63cf27Merge branch 'staging' into fix/connection-admissiondd1443afix(noodle): let connection admission failures defer automatic image work1b6ddb3Merge remote-tracking branch 'origin/fix/connection-admission' into fix/connection-admission5d35faffix(generation): settle a fallback chain on the chain's own outcome4d8fcb6fix(generation): settle a fallback chain completed once usable output is delivered📊 Changes
26 files changed (+991 additions, -44 deletions)
View changed files
📝
packages/server/src/routes/connections.routes.ts(+3 -0)📝
packages/server/src/routes/encounter.routes.ts(+3 -0)📝
packages/server/src/routes/generate.routes.ts(+8 -0)📝
packages/server/src/routes/generate/dry-run-route.ts(+3 -1)📝
packages/server/src/routes/lorebooks.routes.ts(+1 -0)📝
packages/server/src/routes/noodle.routes.ts(+17 -1)📝
packages/server/src/services/capability-packages/capability-language-model.service.ts(+4 -1)➕
packages/server/src/services/generation/connection-admission.ts(+263 -0)📝
packages/server/src/services/image/image-generation.ts(+59 -2)📝
packages/server/src/services/llm/base-provider.ts(+20 -11)📝
packages/server/src/services/llm/connection-fallback-provider.ts(+94 -21)📝
packages/server/src/services/llm/provider-registry.ts(+5 -1)📝
packages/server/src/services/memory-recall-embedding.ts(+1 -0)📝
packages/server/src/services/noodle/noodle-autopost-scheduler.service.ts(+16 -5)📝
packages/server/src/services/noodle/noodle-generated-activity.service.ts(+9 -0)📝
packages/server/src/services/noodle/noodle-image-retry.ts(+5 -0)📝
packages/server/src/services/noodle/noodle-noodler-generation.service.ts(+11 -0)📝
packages/server/src/services/noodle/noodle-noodler-images.service.ts(+3 -0)📝
packages/server/src/services/noodle/noodle-noodler-post.operation.ts(+3 -1)📝
packages/server/src/services/noodle/noodle-public-generation.service.ts(+5 -0)...and 6 more files
📄 Description
Why
Automatic work (NoodleR autopost, the timeline refresh scheduler) shares API connections with
whatever the user is generating right now. Nothing coordinated the two, so a scheduled run could
start on a connection mid-conversation and compete for the same rate limit, parallel-job budget,
or local model. This adds one admission layer that every generation path routes through:
foreground work always proceeds, background work yields to it and waits out a short idle window.
Fallback and cleanup came along because they are the same problem: an admitted slot that is never
released is worse than no admission at all, and a fallback that resolves a logical attempt must
report that attempt's real outcome.
What changed
services/generation/connection-admission.ts): per-connection foregroundcount and background flag, a 30s post-foreground idle window, and a provider decorator that
holds a slot for the duration of a chat, completion, or embed call.
run as background. A busy connection is a deferral, not a failure — the refresh route answers
409 so the scheduler retries shortly instead of backing off as a configuration error.
on abort, disconnect, and token-write failure, so slots are always released.
finalized once after the primary-plus-fallback chain settles, so a successful fallback is not
recorded as a failed attempt. Admission rejections are rethrown rather than triggering fallback.
separate, and the origin/
/v1spellings of one OpenAI-compatible endpoint converge.Linked issue
No issue is linked. One should be opened for this before merge.
Automated validation (run locally, passing)
pnpm checkpnpm regression:providers— admission rejection, fallback skip on admission failure, attemptoutcomes across a successful and a failed fallback, stream abandonment releasing the slot,
image admission key convergence and separation.
pnpm regression:noodleManual verification still needed
Automated coverage is unit/regression level only — no test exercises a real scheduler racing a
real user generation against a live provider. Please verify by hand:
scheduler for a creator on connection A; confirm the automatic post is deferred (logged as
[noodle-autopost] Deferred ...) rather than running concurrently.of recording a configuration failure and backing off for minutes.
while nothing else is generating (manual paths must stay foreground).
after the idle window; confirm it is admitted (no stranded foreground slot).
behavior is unchanged for the user.
again with the
/v1form; confirm both still generate successfully.Known gaps
Professor Mari workspace, memory recall, lorebook vectorization, and three more) still run
unadmitted; tracked as #4520. Follow-up adoption, not regressions.
Summary by CodeRabbit
New Features
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.