[GH-ISSUE #5798] A way for the GM to write back to an Experience package #3202

Closed
opened 2026-10-21 06:00:31 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @kolacheee on GitHub (Sep 3, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5798

Originally assigned to: @kolacheee on GitHub.

A way for the GM to write back to an Experience package

What's missing, in one paragraph

An Experience package can read the chat: the host hands it props every turn, and it can
subscribe to a small set of engine-defined events. There is no lane in the other direction. When
the GM narrates "the storm rolls in" or "the innkeeper waves off your coin and gives you the room",
the package never hears about it, so the sky stays fair and the purse stays full. Everything the
narrator does to the world is invisible to the surface the player is standing on, and the only
thing keeping the two in step is that the package writes a few words into the prompt header and
hopes.

What this asks for is the reverse lane: a package-addressed, structured output channel — a
small closed vocabulary of named calls, with primitive arguments, validated by the server before
delivery, that reaches the package the way host events already do.

Why this shape and not a free-form one

The founding rule of Pixelforge is the model decides what happened; the algorithm decides how it
looks.
A free-form channel would hand the model geometry authority and re-open every seeding and
determinism guarantee the package is built on. A closed enum of verb names with typed arguments
does not: every call is a selection from a list the package published, and the package can refuse
one that does not fit the world it actually compiled.

The delivery mechanism already exists

The Capability API 1.12 event bus is the pattern. The host dispatches a browser event —
CAPABILITY_CLIENT_EVENT, "marinara-capability-server-event"
(packages/client/src/lib/capability-client-events.ts:1) — and a package's element filters it on
package id and chat id. Pixelforge binds that listener once
(packages/pixelforge/src/90-element.js:819, in the Pixelforge repo) and routes it into a handler
that already consumes three event types (packages/pixelforge/src/50-spatial.js:139). What it
cannot do today is carry anything the model said: the type strings are engine-defined, so there
is no surface a real writer could sit on. That is the verified reason Pixelforge 0.14 ships a fully
working weather override with a browser console as its only writer.

So the ask is not a new transport. It is the same event bus, with a payload the model can
produce
— concretely, a schema-validated custom tool call whose name is drawn from a closed enum
the package declares.

Version: this wants the next Capability API point release. The registry is
packages/shared/src/schemas/capability-package.schema.ts — supportedCapabilityApi. Two
observations, because the trees disagree: the review worktree at merge 34442e26d reads
{major: 1, minor: 13} (line 184), and feat/mari-write-readback at af2dc003a reads
{major: 1, minor: 15} (line 196). Whichever is current when this lands, the point release above
it is the ask. Pixelforge's own declaration is {major: 1, minor: 10} and does not move this.

The four vocabularies that want the channel

They are listed together because they are one channel and one validation story, not because they
have to ship together. Any subset is a useful first cut.

1. World flags — six entries

closed:<zone>, damaged:<zone>, shelter:<zone>, hold:<npc>@<zone>, gone:<npc>,
hail:<npc>.

Write-only, world-mutating. These are the ones that make the narrator's fire leave a burnt barn.
One of them already has a consumer built and waiting: _hold is read by the schedule resolver
(packages/pixelforge/src/30-sim.js:583 — "_hold reserves a GM override seam") and is the seam
that keeps a held NPC where the story put them.

These need a decision on the package side before they can ship at all — see "What this is
not" below. The channel is not what blocks them.

2. Weather — weather:<word>[:untilDay], with an optional intensity

The word comes from a five-entry enum: fair, overcast, rain, storm, snow. rain and
snow additionally take intensity: "light" | "heavy", so a GM can summon heavy rain and a bare
rain gets the intensity the day's climate would have rolled anyway.

This one is read-complete today. Pixelforge 0.14 derives the sky from the world's own climate
and calendar, and reads an override out of chat metadata at the key pixelforgeWeather — folding
it defensively, never writing it back, and re-placing the town on the next props delivery when the
key changes. A writer is the only missing half.

The landing is the metadata key, not a new store: the writer patches pixelforgeWeather (per-key
shallow merge), stamping sinceDay = the live sim day at write time. The package observes the
change, re-folds it, and calls its own schedule resolver — the town answers a mid-day override with
no contact with the prompt envelope at all.

Three duties the writer inherits, stated so they are priced rather than discovered:

  • An expired row is inert. Once untilDay is past, every reader treats the row as absent. The
    next write replaces it or nulls it; nothing garbage-collects it.
  • It does not rewind with the story. The override is chat-scoped configuration, like the world
    brief and the content pack. It is a day-range predicate: rewinding back INTO
    [sinceDay, untilDay] re-arms it, which is correct — that is the sky that day already had.
    Rewinding to before it was set restores the derived sky. A GM who wants a different old sky
    writes again.
  • A vanished row means "no override", never corruption. See the durability note below.

3. Economy verbs — four entries

rentBerth, grant, take, award — or a narrower subset.

These call straight through to mutators the package already ships and already fences, so they need
no new package-side plumbing to execute. What they need is the schema gate in front of them and
new call-site logic — and that second half is real work, for a reason worth naming up front rather
than discovering during implementation.

The proximity asymmetry, and the decision. The shipped verb functions (as distinct from the
raw mutators underneath them) assume a player-proximity precondition the GM does not have.
berthOffer resolves a keeper standing next to the player and refuses when there is none
(packages/pixelforge/src/59-economy.js:693); rentBerth re-reads that offer before it moves a
single field (:729). A GM-narrated purchase satisfies no such precondition by construction — the
innkeeper in the prose may be three zones away.

Decided, so it is in the estimate: GM verbs carry validated target arguments against explicit
allowlists
and are executed as a second, GM-shaped implementation over the same gen-fenced
mutators. The GM says which keeper, which zone, which item, and the package validates each
against the live compiled world before executing. This is more work than "expose the existing
functions", and pretending otherwise is how the spec freezes and then grows.

4. One tuning row — fishBite:<word>:<multiplier>

Pixelforge's fishing bite rate is conditioned on the sky: wet and grey days bite better. The
multipliers live in one tuning table keyed by weather word. Worth stating precisely, because it
is the kind of gap that becomes a bug: the validation enum has FIVE words and the table has FOUR
keys. Fair weather is deliberately absent — the lookup falls back to a multiplier of one — so a
write validated against the five-word enum must not be allowed to CREATE a fair key that the
fallback would then start reading. Validate the word against the five; accept a write only for
the four the table names.

Honest note, because a reader will ask: the weather override already tweaks bites
implicitly — summoning rain is summoning the multiplier. The dedicated row exists to tune the
multiplier itself, not to get faster bites. It is the smallest of the four and the easiest to cut.

Adjacent, named and not designed: a GM time-skip verb (advanceDays:<n>) is a natural
candidate for this channel. Pixelforge's own time verbs are day-grain and its seasons are months
long, so a GM who wants to show the player a winter has no way to get there. Maintainer's option;
nothing here designs it.

The validation split

Two gates, and they answer different questions:

  • The engine validates shape and enum membership before delivery. Is this a name in the
    declared vocabulary, are the arguments the declared primitive types.
  • The package re-validates at the point of use against the live compiled world. A flag naming a
    zone id that does not exist in this world is well-formed and still wrong.

Neither substitutes for the other. This is the same seal-time discipline the package already
applies to LLM-authored world briefs: validate the shape once, then re-check the meaning against
whatever is actually standing.

Size is not a constraint here

Said explicitly so the engine side does not over-design for a budget that does not exist: a six-to
-ten-entry closed enum with primitive arguments is nowhere near the 262,144-character per-row
snapshot wall. There is no need for compression, chunking, or a separate store.

One durability note the engine side should know

pixelforgeWeather inherits the #5076-class whole-blob-erase hazard (the issue itself shipped; the class is what the package's own save code names): roughly forty engine call sites
still use the unqueued whole-blob updateMetadata, any of which can silently erase a package's
metadata key between turns. Pixelforge already carries a self-heal for two of its keys for exactly
this reason (packages/pixelforge/src/60-save.js:1493, ensurePresent).

The override key gets no self-heal, deliberately — there is nothing to re-derive it from. So
the writer must treat a vanished row as "no override", never as corruption, and re-write rather
than attempt repair. If #5076 is fixed before this ships, this note retires; until then it is a
behaviour the writer has to have.

What this is explicitly NOT

It is not a request for the engine to solve the world-flag persistence question. The flags in
vocabulary 1 mutate a world that Pixelforge rebuilds from its seed on every load, so without a
persistence contract every consequence dies at the next reload. That decision — a sibling
world-state block, host-authoritative re-read, or session-only — is a package-side call, scoped on
the Pixelforge roadmap, and has to be made before those flags ship regardless of what this channel
looks like. Weather, notably, does not have this problem: the override lives in chat metadata, so
the metadata key is the persistence.

It is not a free-form state patch. If the answer is "use the tracker/state-patch surface", that
is worth saying — but the closed enum is the requirement, not the transport.

Where a reviewer would start

  • packages/shared/src/schemas/capability-package.schema.ts — supportedCapabilityApi, the
    version registry.
  • packages/client/src/lib/capability-client-events.ts — the existing package-addressed delivery
    this extends.
  • packages/shared/src/schemas/custom-tool.schema.ts — the closest existing shape for "a validated
    call the model can make".

Filed on behalf of the Pixelforge Experience package; the four vocabularies above are its own, and
the weather half is built and read-complete as of Pixelforge 0.14.0.

Originally created by @kolacheee on GitHub (Sep 3, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5798 Originally assigned to: @kolacheee on GitHub. # A way for the GM to write back to an Experience package ## What's missing, in one paragraph An Experience package can *read* the chat: the host hands it props every turn, and it can subscribe to a small set of engine-defined events. There is no lane in the other direction. When the GM narrates "the storm rolls in" or "the innkeeper waves off your coin and gives you the room", the package never hears about it, so the sky stays fair and the purse stays full. Everything the narrator does to the world is invisible to the surface the player is standing on, and the only thing keeping the two in step is that the package writes a few words into the prompt header and hopes. What this asks for is the reverse lane: **a package-addressed, structured output channel** — a small closed vocabulary of named calls, with primitive arguments, validated by the server before delivery, that reaches the package the way host events already do. ## Why this shape and not a free-form one The founding rule of Pixelforge is *the model decides what happened; the algorithm decides how it looks.* A free-form channel would hand the model geometry authority and re-open every seeding and determinism guarantee the package is built on. A closed enum of verb names with typed arguments does not: every call is a selection from a list the package published, and the package can refuse one that does not fit the world it actually compiled. ## The delivery mechanism already exists The Capability API 1.12 event bus is the pattern. The host dispatches a browser event — `CAPABILITY_CLIENT_EVENT`, `"marinara-capability-server-event"` (`packages/client/src/lib/capability-client-events.ts:1`) — and a package's element filters it on package id and chat id. Pixelforge binds that listener once (`packages/pixelforge/src/90-element.js:819`, in the Pixelforge repo) and routes it into a handler that already consumes three event types (`packages/pixelforge/src/50-spatial.js:139`). What it cannot do today is carry anything the *model* said: the type strings are engine-defined, so there is no surface a real writer could sit on. That is the verified reason Pixelforge 0.14 ships a fully working weather override with a browser console as its only writer. So the ask is not a new transport. It is **the same event bus, with a payload the model can produce** — concretely, a schema-validated custom tool call whose name is drawn from a closed enum the package declares. **Version:** this wants the next Capability API point release. The registry is `packages/shared/src/schemas/capability-package.schema.ts` — `supportedCapabilityApi`. Two observations, because the trees disagree: the review worktree at merge `34442e26d` reads `{major: 1, minor: 13}` (line 184), and `feat/mari-write-readback` at `af2dc003a` reads `{major: 1, minor: 15}` (line 196). Whichever is current when this lands, the point release above it is the ask. Pixelforge's own declaration is `{major: 1, minor: 10}` and does not move this. ## The four vocabularies that want the channel They are listed together because they are one channel and one validation story, not because they have to ship together. Any subset is a useful first cut. ### 1. World flags — six entries `closed:<zone>`, `damaged:<zone>`, `shelter:<zone>`, `hold:<npc>@<zone>`, `gone:<npc>`, `hail:<npc>`. Write-only, world-mutating. These are the ones that make the narrator's fire leave a burnt barn. One of them already has a consumer built and waiting: `_hold` is read by the schedule resolver (`packages/pixelforge/src/30-sim.js:583` — "`_hold` reserves a GM override seam") and is the seam that keeps a held NPC where the story put them. **These need a decision on the package side before they can ship at all** — see "What this is not" below. The channel is not what blocks them. ### 2. Weather — `weather:<word>[:untilDay]`, with an optional intensity The word comes from a five-entry enum: `fair`, `overcast`, `rain`, `storm`, `snow`. `rain` and `snow` additionally take `intensity: "light" | "heavy"`, so a GM can summon *heavy rain* and a bare `rain` gets the intensity the day's climate would have rolled anyway. **This one is read-complete today.** Pixelforge 0.14 derives the sky from the world's own climate and calendar, and reads an override out of chat metadata at the key `pixelforgeWeather` — folding it defensively, never writing it back, and re-placing the town on the next props delivery when the key changes. A writer is the only missing half. The landing is the metadata key, not a new store: the writer patches `pixelforgeWeather` (per-key shallow merge), stamping `sinceDay` = the live sim day at write time. The package observes the change, re-folds it, and calls its own schedule resolver — the town answers a mid-day override with no contact with the prompt envelope at all. Three duties the writer inherits, stated so they are priced rather than discovered: - **An expired row is inert.** Once `untilDay` is past, every reader treats the row as absent. The next write replaces it or nulls it; nothing garbage-collects it. - **It does not rewind with the story.** The override is chat-scoped configuration, like the world brief and the content pack. It is a *day-range* predicate: rewinding back INTO `[sinceDay, untilDay]` re-arms it, which is correct — that is the sky that day already had. Rewinding to before it was set restores the derived sky. A GM who wants a different old sky writes again. - **A vanished row means "no override", never corruption.** See the durability note below. ### 3. Economy verbs — four entries `rentBerth`, `grant`, `take`, `award` — or a narrower subset. These call straight through to mutators the package already ships and already fences, so they need **no new package-side plumbing to execute**. What they need is the schema gate in front of them and new call-site logic — and that second half is real work, for a reason worth naming up front rather than discovering during implementation. **The proximity asymmetry, and the decision.** The shipped verb *functions* (as distinct from the raw mutators underneath them) assume a player-proximity precondition the GM does not have. `berthOffer` resolves a keeper standing next to the player and refuses when there is none (`packages/pixelforge/src/59-economy.js:693`); `rentBerth` re-reads that offer before it moves a single field (`:729`). A GM-narrated purchase satisfies no such precondition by construction — the innkeeper in the prose may be three zones away. **Decided, so it is in the estimate:** GM verbs carry **validated target arguments against explicit allowlists** and are executed as a **second, GM-shaped implementation** over the same gen-fenced mutators. The GM says *which* keeper, *which* zone, *which* item, and the package validates each against the live compiled world before executing. This is more work than "expose the existing functions", and pretending otherwise is how the spec freezes and then grows. ### 4. One tuning row — `fishBite:<word>:<multiplier>` Pixelforge's fishing bite rate is conditioned on the sky: wet and grey days bite better. The multipliers live in one tuning table keyed by weather word. Worth stating precisely, because it is the kind of gap that becomes a bug: the validation enum has FIVE words and the table has FOUR keys. Fair weather is deliberately absent — the lookup falls back to a multiplier of one — so a write validated against the five-word enum must not be allowed to CREATE a `fair` key that the fallback would then start reading. Validate the word against the five; accept a write only for the four the table names. **Honest note, because a reader will ask:** the weather override *already* tweaks bites implicitly — summoning rain is summoning the multiplier. The dedicated row exists to tune the multiplier itself, not to get faster bites. It is the smallest of the four and the easiest to cut. **Adjacent, named and not designed:** a GM time-skip verb (`advanceDays:<n>`) is a natural candidate for this channel. Pixelforge's own time verbs are day-grain and its seasons are months long, so a GM who wants to show the player a winter has no way to get there. Maintainer's option; nothing here designs it. ## The validation split Two gates, and they answer different questions: - **The engine validates shape and enum membership before delivery.** Is this a name in the declared vocabulary, are the arguments the declared primitive types. - **The package re-validates at the point of use against the live compiled world.** A flag naming a zone id that does not exist in *this* world is well-formed and still wrong. Neither substitutes for the other. This is the same seal-time discipline the package already applies to LLM-authored world briefs: validate the shape once, then re-check the meaning against whatever is actually standing. ## Size is not a constraint here Said explicitly so the engine side does not over-design for a budget that does not exist: a six-to -ten-entry closed enum with primitive arguments is nowhere near the 262,144-character per-row snapshot wall. There is no need for compression, chunking, or a separate store. ## One durability note the engine side should know `pixelforgeWeather` inherits the **#5076-class whole-blob-erase hazard** (the issue itself shipped; the class is what the package's own save code names): roughly forty engine call sites still use the unqueued whole-blob `updateMetadata`, any of which can silently erase a package's metadata key between turns. Pixelforge already carries a self-heal for two of its keys for exactly this reason (`packages/pixelforge/src/60-save.js:1493`, `ensurePresent`). The override key gets **no self-heal**, deliberately — there is nothing to re-derive it from. So the writer must treat a vanished row as **"no override"**, never as corruption, and re-write rather than attempt repair. If #5076 is fixed before this ships, this note retires; until then it is a behaviour the writer has to have. ## What this is explicitly NOT **It is not a request for the engine to solve the world-flag persistence question.** The flags in vocabulary 1 mutate a world that Pixelforge rebuilds from its seed on every load, so without a persistence contract every consequence dies at the next reload. That decision — a sibling world-state block, host-authoritative re-read, or session-only — is a package-side call, scoped on the Pixelforge roadmap, and has to be made before those flags ship regardless of what this channel looks like. Weather, notably, does not have this problem: the override lives in chat metadata, so the metadata key *is* the persistence. **It is not a free-form state patch.** If the answer is "use the tracker/state-patch surface", that is worth saying — but the closed enum is the requirement, not the transport. ## Where a reviewer would start - `packages/shared/src/schemas/capability-package.schema.ts` — `supportedCapabilityApi`, the version registry. - `packages/client/src/lib/capability-client-events.ts` — the existing package-addressed delivery this extends. - `packages/shared/src/schemas/custom-tool.schema.ts` — the closest existing shape for "a validated call the model can make". Filed on behalf of the Pixelforge Experience package; the four vocabularies above are its own, and the weather half is built and read-complete as of Pixelforge 0.14.0.
bsakaguchi 2026-10-21 06:00:31 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3202
No description provided.