mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5136] [MERGED] feat(game): host-run structured generation for game-surface Experiences #6647
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#6647
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/5136
Author: @kolacheee
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @kolacheee
Base:
staging← Head:feat/5135-experience-generation📝 Commits (5)
ec24b16feat(game): host-run structured generation for game-surface Experiences (#5135)4e5b83cdocs: changelog entry for #5135608e856fix(game): harden experience-generation per adversarial review (#5135)22b6bfeMerge upstream/staging: adopt the filesystem-discovered regression runner44d5d54fix(game): apply CodeRabbit review to experience-generation (#5135)📊 Changes
5 files changed (+563 additions, -2 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/middleware/error-handler.ts(+3 -1)📝
packages/server/src/middleware/rate-limit.ts(+19 -1)📝
packages/server/src/routes/game.routes.ts(+270 -0)➕
scripts/regressions/experience-generation.regression.ts(+270 -0)📄 Description
Closes #5135
Why
A game-surface Experience can store timeline-anchored state (#5102), but it has no way to run the ONE structured LLM call its content pipeline needs at game creation — e.g. turning the player's wizard preferences into a compact world brief that a deterministic generator compiles into a tile world ("the LLM decides what exists, the algorithm decides where every tile goes"). Packages are client-only here; the capability language-model host is reachable only from privileged server entrypoints, and abusing a visible chat turn pollutes the story and breaks on formatting whims.
What changed
POST /api/game/:chatId/experience-generation— one host-run, bounded, non-streaming structured-output call on the chat's GM connection, modeled on/game/scene-wrap(not/game/setup, whose 340 lines are wizard-context assembly and whose blind-retry/hand-repair-dialog failure mode fits a creation wizard, not a package call):gameExperienceId. Only the chat's own Experience can spend tokens, only on its own chat.instructions(≤16k chars) +userContent(≤8k) + optional JSONschema(≤8k serialized), forwarded as provider-native structured output where supported (OpenAI-compatibleresponse_format: json_schema, GoogleresponseSchema). Anthropic and the local sidecar ignore it by design, so the tolerant parser remains the real contract.responseFormatis set aftergameGenOptionsbecause itssuppressModelParametersbranch copies a fixed field list and silently drops it from overrides.agent-suite-rewriteprecedent — a buggy package loop hits this wall, not the 600/min default), the per-chat asset-generation lock, a 64KB routebodyLimit, and output tokens floored at 2048 / clamped by known-model caps (the caller may only tighten, never raise).parseGameJsonishhappily repairs a cut-off reply by closing its unbalanced containers, which would have returned a silently amputated brief asok: true— and there is deliberately no host-side semantic validator behind this route to catch it (that's package-owned). Afinish_reason: lengthreply now 422s with the existing actionable "increase max output tokens" message./setup's blind re-run), then a 422 carrying the raw text so the package can degrade to its own defaults. Never a hand-repair dialog; this is not a wizard.New tracked lane
regression:experience-generation(inregression:issues), 5 cases against a mock OpenAI-compatible provider: all gates verified to never reach the provider, happy path asserts the schema passthrough and token floor in the captured upstream request body, the repair round-trip converges in exactly two upstream calls with the corrective turns present, truncation 422s without a futile retry, and double-garbage degrades with the raw text.Driving case: Pixelforge 0.4.0's preference-driven world generation, whose theme layer already shipped on its package branch. A two-lens adversarial review (abuse/cost + correctness/contract) is running on this diff; findings land as a follow-up commit, per the pattern of #5106.
Validation
pnpm checkpnpm regression:experience-generation(new)pnpm regression:docsSummary by CodeRabbit
New Features
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.