mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2729] [Issue]: Tracker re-run (retry-agents) diverges from first-generation — quest auto-remove and capability gate skipped #1373
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#1373
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?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2729
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The retry-agents (re-run / Retry button) path is a second, divergent copy of the tracker-persistence pipeline that does not match first-generation semantics. It omits the
autoRemoveFullyCompletedoption so re-running the quest tracker keeps fully-completed quests the first-gen path drops, and it omits thecustomAgentCanApplyResult/customAgentCanEmitResultcapability gates so an unauthorized custom agent can write and leak tracker state on retry that it is blocked from writing on first-gen. Both produce state that differs depending on whether an agent ran during generation or via re-run, corrupting the committed snapshot that feeds the next prompt. Root cause: duplicated logic that drifted from the main route.Bug 1 — Quest re-run does not auto-remove fully-completed quests (medium)
How it breaks the pipeline: The main route calls
applyQuestUpdatesToPlayerStats(existingPS, updates, { autoRemoveFullyCompleted: true }); the retry route passes NO options, and the option defaults to false. So a quest the model marks fully complete is removed on first-gen but retained on re-run, sticking in the Active Quests panel as stale data.Steps to replicate: Re-run the quest tracker on a turn where the model marks a quest fully complete; the completed quest reappears/sticks in Active Quests (vs first-gen which drops it).
Code trace: main
generate.routes.ts:8059-8061({ autoRemoveFullyCompleted: true }); retryretry-agents-route.ts:2289(no options); option default + gated removalquest-state.ts:240,271-281; persisted viabuildLockedPlayerStatsArrayPatch(generate-route-utils.ts:86-109) thenretry-agents-route.ts:2297-2303.Bug 2 — Retry route bypasses the edit_trackers capability gate (medium)
How it breaks the pipeline: Every tracker persistence/emit block in the main route is gated by
customAgentCanApplyResult(result,...,'edit_trackers')andcustomAgentCanEmitResult.applyRetryResultEffectshas NO such gate on ANY tracker block, so a custom agent that emits a tracker result type but lacksedit_trackers(blocked on first-gen) silently overwrites GameState (presentCharacters, personaStats/status/inventory, customTrackerFields, activeQuests, world fields) and leaks the result to the client on Retry/re-run.Steps to replicate: Configure (via the agent create/update API or import) a custom agent with
resultTypeof a tracker type but without theedit_trackerscapability; on first-gen it writes nothing, but clicking Retry on it persists and emits tracker state.Code trace: main guards
generate.routes.ts:7511-7516,7652-7657,7924-7929,7989-7994,8033-8038, emit:4613,4618; helpers:383-419,builtInAgentTypes :3409. Retry has zero capability checks (grep finds none): persistence blocksretry-agents-route.ts:2084-2123,2163-2207,2209-2237,2276-2310,2349-2374gated only onresult.success && result.type && result.data; unconditional emit loop:2986-3001. Reachable:resolveAgentResultTypereturns configuredsettings.resultType(agent-executor.ts:1864-1871); no capability filter at resolution.Suggested Fix
{ autoRemoveFullyCompleted: true }toapplyQuestUpdatesToPlayerStatsinretry-agents-route.ts:2289(or extract a shared helper so the two paths cannot drift). (Bug 1.)builtInAgentTypes(or acanApplyTracker(result)predicate) intoapplyRetryResultEffectsand gate every tracker persistence block withcustomAgentCanApplyResult(result, resolvedAgents, builtInAgentTypes, 'edit_trackers'); gate theagent_result/game_state_patchsends withcustomAgentCanEmitResult. (Bug 2.)generate.routes.tsandretry-agents-route.tsso semantics and permission gates cannot diverge.Template checklist
pnpm checkpasses (TypeScript + ESLint)edit_trackerscannot write/emit tracker state on RetryAffected files
packages/server/src/routes/generate/retry-agents-route.tspackages/server/src/routes/generate.routes.tspackages/shared/src/utils/quest-state.tsAudit provenance
Found by a multi-agent static audit of the trackers/widgets subsystem (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). Severity: MEDIUM. Line numbers are against the
stagingworking tree.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in 1915404a.\n\nVerified against current code and addressed the still-valid retry-route drift:\n- retry quest updates now pass autoRemoveFullyCompleted: true, matching first-generation behavior\n- retry tracker persistence for world-state, character, persona, quest, and custom tracker results is now gated by edit_trackers for custom agents\n- retry agent_result emission is filtered through the same result-type capability model so unauthorized tracker output is not streamed to the client\n\nSkipped unrelated retry lorebook wording/behavior churn because this issue is specifically about tracker retry semantics. Per maintainer request, pnpm validation is deferred until the sweep is complete.