mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
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#6991
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/5922
Author: @kolacheee
Created: 9/7/2026
Status: ✅ Merged
Merged: 9/7/2026
Merged by: @kolacheee
Base:
staging← Head:feat/5798-gm-verb-runtime📝 Commits (10+)
4dae701feat(capability): gated reader for a package's GM verb table (#5798)ea191f5feat(capability): engine-generic GM verb executor for both effects (#5798)5d5ea05feat(game): render, parse and execute package GM verbs on a game turn (#5798)faceb0bfeat(client): handle gm_verb in both SSE switches, and metadata_patch in the retry twin (#5798)3b488bbfeat(capability): advertise capability API 1.16 (#5798)c2dd8e5test(capability): behavioral regression for the GM verb runtime (#5798)5c3200bfix(capability): fold GM verb tag names locale-independently (#5798)a4ad584docs(capability): name the two unstated GM verb behaviors (#5798)6a78b9btest(capability): make the GM verb byte-ceiling pin discriminate (#5798)ce8a5aafix(capability): teach GM verb argument vocabularies from the table (#5798)📊 Changes
17 files changed (+1971 additions, -37 deletions)
View changed files
📝
CHANGELOG.md(+4 -1)📝
docs/development/optional-agent-packages.md(+35 -11)➕
e2e/game-verb-only-turn.e2e.ts(+172 -0)📝
packages/client/src/components/game/GameNarration.tsx(+25 -1)📝
packages/client/src/hooks/use-generate.ts(+40 -0)📝
packages/server/src/routes/generate.routes.ts(+117 -1)📝
packages/server/src/routes/generate/spatial-transition-request.ts(+8 -1)📝
packages/server/src/services/capability-packages/capability-command-registry.service.ts(+18 -6)➕
packages/server/src/services/capability-packages/capability-gm-verb-runtime.service.ts(+438 -0)📝
packages/server/src/services/capability-packages/package-manager.service.ts(+90 -0)📝
packages/server/src/services/game/gm-prompts.ts(+11 -0)📝
packages/shared/src/index.ts(+1 -0)📝
packages/shared/src/schemas/capability-package.schema.ts(+5 -1)📝
scripts/regressions/capability-conversation-actions.regression.ts(+5 -1)➕
scripts/regressions/capability-gm-verb-runtime.regression.ts(+977 -0)📝
scripts/regressions/capability-gm-verbs.regression.ts(+20 -9)📝
scripts/regressions/capability-package-lifecycle.regression.ts(+5 -5)📄 Description
Linked issue
Closes #5798
Why this change
An Experience package can read a chat and cannot write to it. The host hands the package props every turn and dispatches a small set of engine-defined events at it, but nothing carries anything the model said. So when the GM narrates the storm rolling in, the package never hears; the sky stays fair, the town keeps its fair-weather schedule, and the only thing holding the story and the world together is that the package writes a few words into the prompt header and hopes.
The request that opened this names four vocabularies that want the lane: world flags (a burnt barn stays burnt, a held NPC stays put), weather, economy verbs, and one fishing tuning row. They are one channel and one validation story, not one release — any subset is a useful first cut.
Weather is first because it is the one that is already read-complete. Pixelforge derives the sky from the world's own climate and calendar and already reads an override out of chat metadata, folds it defensively, and re-places the town on the next props delivery when the key changes. It has shipped that reader with a browser console as its only writer. Every piece of that feature exists except the half that lets the narrator use it. This PR is that half, built generically: the Engine does not know what weather is, only that a package declared an action, that the model used it, and that the values check out.
The second reason to do it now is that the package needing it cannot run server code at all. Pixelforge declares only agent and client entrypoints, so it can never register a server-side command handler — the channel has to be declaration-driven with an Engine-generic executor, or it does not reach the package that asked for it.
What changed
One table resolution per turn, threaded to both ends. The chat's Experience id resolves to an installed package, its action table is read and validated once, and that one resolution is handed to both the prompt render and the post-save scan. Two separate resolutions could disagree — a package updated mid-turn, a table that stops verifying — and then the prompt would advertise an action the parser no longer matches, leaving a raw bracket tag sitting in the player's prose. The resolution is lazy, so a chat with no Experience package pays nothing.
A gated reader,
gmVerbTableSource(packageId). The verified-file reader is module-private and there is no exported by-id package accessor, so the runtime gets exactly one narrow export that returns verified bytes or nothing and never hands back an installed-package object. Its gate chain is: package readiness (not servability — the servable path falls back to the previous version's manifest for a package awaiting restart, which would serve a vocabulary the running Engine no longer matches), then the file actually being a declared asset, then thechat-writepermission, then a 64 KB check against the declared byte count before any read, then the verified read. Failure tiers are the function's contract and the turn survives all of them: not installed, not ready or no table declared are silent; a packaging mistake warns; a hash or tamper failure logs an error naming tampering.The tag grammar is shared, not re-written. The conversation-command tag pattern is exported as a source string and the new scan uses it against a different vocabulary. An action the prompt advertises but the parser cannot match would leave a raw tag in the player's prose, and two copies of a regex is how that happens.
A new engine-generic executor resolves, renders, parses, validates and executes, with no package server code anywhere in the path.
Render, parse and strip on the game turn. Action lines render inside the GM format reminder's
COMMANDS:block through a new parameter beside the existing experience systems list — not the system message, which is rebuilt wholesale later and would overwrite anything spliced into it. The scan is its own game-mode-only path: the conversation-commands flag gates that entire surface, so flipping it here would arm every registered conversation command on every game turn, and it stays untouched. The scan runs before the content-replacement frame, because anything that must reach the client has to be in the response by then. A tag is removed from the saved text on the name match, never on validation success — a command the model got slightly wrong must not show the player machinery.Its own execution site. Not the conversation-command block: that one brackets its work in frames the game client does not consume, and never runs in Game Mode anyway. Nothing executes on an aborted turn.
The executor's write discipline
patchMetadataand nothing else. NeverupdateMetadata, never the capability persistence host. The doc comment states the rule at the function.touchUpdatedAt: false, so a weather change does not reorder the user's chat list.gmVerb:<name>on the saved swipe with a truthy object value ({verb, args, at}) — a scalar would leave the storage guard a permanent no-op. The claim is skipped, never the write, when the saved message id is empty. The claim buys provenance, not dedupe, and the code says so where it is written.metadata_patchframe is emitted if any write committed, flagged the instant the row commits rather than after the claim — a committed write the client is never told to refetch would leave the package showing a stale world. The payload itself is inert: the client's handler invalidates the chat detail and the active lorebook and ignores the data. The props re-delivery after that refetch is the delivery mechanism for a written value; there is no second event carrying it.The live-delivery half, and its honesty
An action that names no key is delivered to the package instead of written: one
gm_verbframe carrying an explicitpackageIdplus the chat, message and swipe it came from, dispatched into the shipped capability client-event bridge. The address is explicit because the executor already holds the resolved package id — the client is not asked to infer it from a convention field inside the payload the way the existing turn-game bridge does. The case lands in both SSE switches in the same change, including the agents-retry switch where GM actions do not run today, so the next wiring does not have to rediscover that the two are twins.What this half honestly is:
The
chat-writegate, and what it widensReading a package's table requires the package to declare
chat-write, and the permission check sits ahead of the read so an unpermitted package's bytes are never loaded — and behind the declaration test, so a package with no table stays silent while one that ships a table and forgot the permission is told.Stated up front rather than discovered: this changes what that permission means. Today
chat-writemeans "this package's own client code writes chat data". After this PR it also means "the Engine will execute writes on this package's behalf, from model output". Permissions are shown before install and nothing re-consents on update, so a user who granted the old meaning receives the new one without being asked again. The separate issue about capability permissions that are declared and enforced nowhere (#5899) carries this note; the first counter-example to that issue is this gate.Practically the blast radius today is zero: no released package ships an action table at all, so no install changes behavior until one does.
Capability API 1.16
The bump waited for this PR on purpose. The compatibility check compares a package's declared version against that constant alone, so bumping it advertises the seam whether or not the runtime exists. It exists now. It carries its own line in the version ladder, and the lifecycle regression pins the constant and its compatibility message in four places so the bump moves them with it.
Teaching the model the vocabulary it is allowed to use
The reminder line originally rendered a name, a description and one example, so an action's closed vocabulary reached the GM only if the package happened to spell it inside a 200-character description. A GM told to set the weather writes "sunny" for "fair"; the validator refuses a word it was never shown; and the refusal is invisible, because the tag is stripped on the name match — the narration reads clean and the world simply never changed.
The line now carries the two payload slots the sibling conversation-command renderer already uses, and the first one is derived from the same parsed table the validator reads: every argument in declaration order, optional ones marked outside the JSON string, a closed list rendered as the full alternation the built-in commands already use, an open string shown with its cap, numbers and booleans unquoted because the validator refuses
"3"for a number rather than coercing it. Deriving it here instead of from prose is what stops prompt and validator drifting: a description can no longer promise a value the validator refuses.One prompt hazard, named
The GM format reminder already renders a built-in
[reputation: npc= action=]line on every Game Mode turn, consumed by the Engine's own relative reputation service against records Pixelforge never populates. The reserved-name rule correctly makesreputationan illegal package action name — but a package's own standing action will sit one line away from a do-nothing Engine stance verb in the same block, and a model handed two overlapping stance verbs will sometimes reach for the wrong one. The name rule cannot fix that. Suppressing the Engine line on chats whose package declares a standing action is a candidate follow-up, not part of this PR.Also in this PR
metadata_patch, which is load-bearing rather than tidy: the retry route has been emitting that frame with no case to receive it, so a metadata write on a retried turn never reached the package until the chat was reopened.finally, not a ledger; what the second call refuses is the claim, after the handler has already run. That comment is where a false safety claim in the original design notes came from.Known shortcuts
Named here so review does not have to find them:
One instance per action name per message. Correct for the two proving actions; a real ceiling for any future repeatable live-delivered action, where a repeat is meaningful prose ("two coins, then two more"). A payload-hash dedupe behind a
repeatableflag is sketched, not built.Flat, single-line JSON payloads only. Argument values are string, number or boolean; there is no nesting.
A written value survives swiping away, editing or deleting the turn, and nothing reverts it. The visible symptom is that the last swipe generated wins, not the last displayed — the prose on screen and the world can disagree within a session with nothing reconciling them. A live-delivered effect does revert with a rewind; the halves genuinely differ here.
The claim buys provenance, not dedupe — and on the live-delivery half it cannot buy at-most-once even in principle. Safety comes entirely from the write being absolute.
A package's semantic refusal of a written value is advisory; the row is already committed. A refusal of a live-delivered action is binding.
Math.random()stays unseeded everywhere. There are three separate unseeded implementations in the tree; this PR neither uses nor fixes them.After an update that leaves a package awaiting restart, its actions stop resolving until the restart — a log line only, no user-facing notice. No shipped package can trip this today.
A GM turn that is nothing but an action tag now lands rather than being discarded — a review round pulled the narrow fix in: the empty-response guard's hidden-anchor gate now counts parsed GM verb calls, so a tags-only turn saves its hidden anchor, executes its validated writes, and shows the player a silent turn instead of an error; the game surface skips the hidden anchor when picking the narration to display, so the previous turn's text stays on screen. #5902 remains open for the generic anchor surface (the gate still cannot see command shapes it was never taught), and two follow-ups were filed from the review: #5926 (a command-only regenerate appends its anchor instead of replacing the message — pre-existing shape shared with Conversation) and #5927 (the game surface's sibling readers still see raw hidden rows).
A live-delivered effect is lost, silently, in the five cases listed above. The only trace it ever leaves is one warning, and only for the unwritable-reply case.
The rendered reminder has no length budget of its own. Every value it prints is a verbatim substring of a table file already refused above 64 KB, so the bound exists — but a maximal legal table would render roughly 60 KB into every Game turn's reminder. That is entirely self-inflicted by the package, and it is a named cost rather than a guarded one.
What the tests prove, and what they do not
updatedAtuntouched, a second identical apply moves nothing, the live frame is emitted exactly once carrying the package id and the message triple, and every refusal tier (no table, no permission, oversized, tampered, malformed, not ready, wrong owner) is exercised without throwing. The byte ceiling is proved to key on the declared size: the same file on disk is refused when the manifest inflates it and accepted when the manifest tells the truth.metadata_patchemit, and the once-per-turn resolution. The execution site lives inside a several-thousand-line route handler no regression can drive, and the file labels those three as searches rather than dressing them up as exercised behavior. Their reachability rests on review, not on a check.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
These twelve items need a Pixelforge build that ships a
gm-verbs.jsondeclaration installed as the chat's Experience. No released package declares an action table, so on a stock install this PR is unobservable by design — a chat with no declaring package resolves zero actions, renders no extra prompt lines, parses nothing and writes nothing. Items 10–12 additionally need the package-side consumption of the standing action, which lives in the Agents repo.Alongside those:
pnpm checkand confirm it exits clean.capability-gm-verb-runtime,capability-gm-verbs,capability-conversation-actions,capability-package-lifecycle,prompt.console.*was introduced in server code (the shared logger is used throughout the new service).During development
pnpm checkexited clean and those five regression lanes passed. That is context for the reviewer, not evidence for the boxes above — every browser item is genuinely unverified until someone runs it with a declaring package installed.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)What this PR actually does, for the reviewer to confirm against the boxes:
docs/development/optional-agent-packages.md— the delivery-and-durability contrast, the mixed-turn ordering rule, the binding-versus-advisory refusal split, the honest gate scope, the fact that a table declared in the package's file list but left out of its asset paths yields zero actions and zero diagnostics, and the fact that a declared asset is served unguarded over HTTP so a table must never hold anything sensitive.docs-i18nare not updated here; this file's changes belong in the batched[docs-i18n]follow-up.pnpm version:syncowns.UI evidence (if applicable)
Nothing in this PR draws anything. The user-visible result is a world that changes when the narrator says it changed — which is a recording of a Pixelforge chat, not a screenshot of an Engine screen. Worth attaching if the browser pass above is recorded: one clip of the sky changing mid-turn without a reload.
Summary by CodeRabbit
New Features
Bug Fixes
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.