mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #4913] [MERGED] feat(capability): scoped roleplay context, world-state reads, and structured actions for packages #6540
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#6540
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/4913
Author: @Gunterlie
Created: 8/11/2026
Status: ✅ Merged
Merged: 8/13/2026
Merged by: @Gunterlie
Base:
staging← Head:at-the-service-of-your-majesty📝 Commits (10+)
f13a74ffeat(capability): expose scoped world state to package promptse52fcd5feat(capability): route structured conversation actionse1b4134feat(capability): advertise package conversation actionsfe236a8feat(capability): validate action payloads, idempotent dispatch, roleplay events175a140feat(capability): read + audience-filter roleplay events into the prompt3cc365ffix(capability): stop truncating action payloads that contain ]ee6718bfix(capability): scope roleplay-event storage per chat instead of a global scan8337e08fix(capability): make conversation actions retry-safe204120fMerge branch 'staging' into at-the-service-of-your-majestye1149c7docs(capability): clarify action handler retries📊 Changes
13 files changed (+518 additions, -30 deletions)
View changed files
📝
packages/server/src/db/schema/capability-documents.ts(+18 -11)📝
packages/server/src/routes/generate.routes.ts(+75 -12)📝
packages/server/src/services/capability-packages/capability-command-registry.service.ts(+81 -4)📝
packages/server/src/services/capability-packages/capability-module-runtime.service.ts(+9 -3)📝
packages/server/src/services/capability-packages/capability-persistence.service.ts(+75 -0)📝
packages/server/src/services/capability-packages/capability-prompt-context.service.ts(+4 -0)➕
packages/server/src/services/capability-packages/capability-roleplay-events.service.ts(+81 -0)📝
packages/server/src/services/conversation/character-commands.ts(+1 -0)📝
packages/server/src/services/generation/conversation-command-runtime.ts(+4 -0)📝
packages/server/src/services/storage/chats.storage.ts(+32 -0)📝
packages/shared/src/schemas/capability-package.schema.ts(+1 -0)📝
packages/shared/src/types/capability-runtime.ts(+36 -0)➕
scripts/regressions/capability-conversation-actions.regression.ts(+101 -0)📄 Description
What
Four deterministic capability APIs that let a feature package participate in roleplay generation — no new background LLM work; all plumbing runs off data the Engine already has.
targetCharacterIds+personaIdfor the turn.getGameState(chatId)on the package persistence host returns the latest committed snapshot (date, time, location, weather, temperature, present characters, source message + swipe). Optional, so packages feature-detect and degrade on older Engines.appendRoleplayEventpersists a durable event with an audience (public/user-only/{characterIds}) and an idempotency key. A new Engine-owned reader (collectRoleplayEventContext) injects the recent, in-audience events back into the prompt — a private event is only shown to a turn that can write every character in its audience, so a group generation can't leak it.Idempotency: dispatch is keyed on
chat:message:swipe:commandand backed by a persistent claim on the source message's swipe, so regeneration or restart can't double-fire an action or duplicate an event.Why
Feature packages (Virtual Phone is the driving case) could read the story but had no scoped, safe way to feed state back into generation or to act during a turn. These are the smallest primitives that close that loop without a second model call.
Fixed during review
]were truncated. The command parser/stripper matched up to the first], so any JSON payload with a bracket in it (an array, a bracketed note) produced invalid JSON and left a stray}]in the visible transcript when stripped. Fixed both regexes to match a full{…}run; regression added.appendRoleplayEvent's idempotency check and the new prompt-time read both scoped the synthetic document owner to a flat__engine__, capped at a 200-row global window — on a busy multi-chat instance, this chat's own recent events could fall outside that window. Both sides now scope by__engine__:<chatId>, so reads and the idempotency check are chat-local instead of a global scan.Validation
tscclean on the current staging base.capability-conversation-actionsregression: payload preservation (including bracket-safe payloads), oversized/validator rejection, dispatch idempotency, audience-filter truth table, per-chat event-owner scoping.send_message/note_to_self/post_noodleactions, scoped prompt context, World State clock, private + public events).Not yet run in a live Engine — validated by types + regressions only.
Known shortcut (flagged, not blocking)
dispatchedActionsis an in-memorySetthat never clears — the persistent message-extra claim on the message swipe is the real guard; the Set can be dropped or bounded on a follow-up.Happy to split into smaller PRs (world-state read / prompt-context / actions / events) if that's easier to land.
Summary by CodeRabbit
New Features
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.