mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5923] [MERGED] feat(game): skill checks are rolled by the server, not narrated by the model #6992
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#6992
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/5923
Author: @kolacheee
Created: 9/7/2026
Status: ✅ Merged
Merged: 9/8/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/gm-sparse-checks-server-rolled📝 Commits (10+)
3f0a88arefactor(game): read [skill_check:] tags through one shared parser4c1dd42refactor(game): lift skill-check rolling into a shared serviceade84c3feat(game): the engine rolls the GM's skill checks, not the modeld104b53test(game): pin server-rolled skill checks and the sparse prompt6184622fix(game): never answer a dice pool with a d2018f1c55fix(game): read a check tag the same way whichever spacing it arrives in4b48cddfix(game): read a check's rules only from what the GM declared9c6caf3Merge branch 'fix/dice-notation-consolidation' into feat/gm-sparse-checks-server-rollede1bb3b7Merge remote-tracking branch 'origin/staging' into feat/gm-sparse-checks-server-rolledeab3f75fix(game): close the four holes a review round found in server-rolled checks (#5798)📊 Changes
14 files changed (+1908 additions, -239 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
docs/game/dice-and-skill-checks.md(+4 -0)📝
packages/client/src/components/game/GameSurface.tsx(+7 -2)📝
packages/client/src/lib/game-tag-parser.ts(+7 -183)📝
packages/server/src/routes/game.routes.ts(+38 -51)📝
packages/server/src/routes/generate.routes.ts(+65 -0)📝
packages/server/src/services/game/gm-prompts.ts(+7 -2)➕
packages/server/src/services/game/skill-check-resolution.service.ts(+412 -0)📝
packages/server/src/services/game/skill-check.service.ts(+8 -1)📝
packages/shared/src/index.ts(+1 -0)📝
packages/shared/src/utils/skill-check-format.ts(+33 -0)➕
packages/shared/src/utils/skill-check-tag.ts(+425 -0)📝
scripts/regressions/capability-gm-verb-runtime.regression.ts(+54 -0)➕
scripts/regressions/gm-skill-check-resolution.regression.ts(+846 -0)📄 Description
Linked issue
Closes #5949
Tracking issue: #5949. Related Game Mode planning: #5798 (not closed by this PR).
Why this change
The Game Master invented its own dice results and the engine mostly let it.
result=, so a tag reporting a complete roll was never touched. The player saw an honest card; the transcript kept the lie; and on the next turn the model read its own invented number back out of its context as fact.What changed
One reader for check tags.
parseSkillCheckTagBody, its rolls reader, the tag type and the grammar itself move intopackages/shared/src/utils/skill-check-tag.ts. The server used to readskillanddcwith its own attribute search and throw the rest away, so an advantage mode or a die the player rolled themselves vanished the moment the server resolved a check. Both sides now reach the same verdict about whether the GM's numbers can be trusted.One service for rolling. The modifier lookup a check needs — the skill bonus from the latest game-state snapshot, and the governing attribute from either the structured stats or the player card's free-form sheet — was 27 lines inlined in the
POST /game/skill-checkhandler, so nothing else in the engine could roll a check the way the shipped endpoint rolls one.skill-check-resolution.service.tsnow owns it; the endpoint is a thin caller; a turn with several checks costs one snapshot read and every check sees the same sheet. Three deliberate behaviour changes came with it: a tag the shared reader cannot read at all is left alone instead of overwritten (the old text search could reach past its target and clobber an unrelated malformed tag); unparseable stored stats now cost the check its modifiers and log a warning instead of failing the whole request, because a resolver that runs during generation must not be able to kill a turn; and a non-numeric skill bonus coerces to 0 instead of being concatenated as a string.Resolution at save time, with real randomness. The prompt convention becomes sparse — both branches of the check line now ask the GM for
skillanddconly, plus the player's own number where the player rolled. Generation post-processing then rolls every tag in the turn that still owes a roll and rewrites it in place, immediately before thecontent_replaceframe, so the browser renders resolved text and the save carries it. The roller is the engine's own unseededMath.randompath, unchanged by the consolidation below it. It is idempotent (what it writes reads back as audited, so a second pass throws no dice), scoped to the newly generated segment on a continue, Game Mode only, never on impersonation, and a failure costs the check rather than the turn.The audit is ported server-side and now overwrites. A self-reported plain d20 check whose arithmetic does not add up is re-rolled and its invented numbers leave the saved text. That closes the live bug above at both ends: the endpoint no longer skips a tag for carrying
result=, and the decision about what to overwrite is the shared reader's rather than a text search's.Pools are never audited and never rolled — that is a rule now, not an accident.
isEngineRollableSkillCheckTagis the single place that decides whether the engine implements what a tag names:resolution=absent orsum, anddice=absent or a d20 notation the reader can restate exactly, with the die count agreeing with the declared mode (one die normally, two under advantage or disadvantage).1d20+3is refused for the same reason a pool is — it is a d20, but the engine's modifier comes from the character sheet, so rolling it would silently drop the GM's flat bonus and relabel the tag as if it had never asked. All four doors onto a rewrite ask that same question: generation post-processing, thePOST /game/skill-checkrewrite, the browser's legacy fallback, and the sparse pre-roll inference (so a pool die is never adopted as the player's own d20).The prompt carries the other half. Both check branches now show the GM the complete pool tag, and say plainly that an incomplete one is left unresolved rather than repaired. Without that, the sparse convention had removed the full form from every template in the file, so the attribute most likely to go missing was exactly the one that used to get a pool converted into a d20.
The tag grammar reads what the GM wrote, not how they spaced it. Whitespace around
=is tolerated at the one reader every door asks — which is also what the server's other check reader has always accepted, so the two stopped disagreeing about the same tag. An attribute written with no value (mode=) declares nothing and consumes nothing, so it can no longer reach across the space and swallow the declaration behind it. Advantage and disadvantage are read frommode=(compared lowercased, so a capitalised mode counts) or from a bare flag standing outside everykey=valuepair — never from a substring of the whole tag body, which used to let a skill name declare a mode.Evidence
Everything below was driven through the shipped code with live counters on the die and on the chat read, not asserted about the source:
key=inserted at every position of six declaration shapes, nine keys, four gap characters, three spacings: 2,700 shapes, none rolled.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Run in the review worktree, for information — the boxes above are yours to tick after you have seen this yourself:
pnpm checkexited 0 (full chain through the client build).pnpm version:checkin sync for 2.4.5.gm-skill-check-resolution.regression.tspassed, and passed again after every mutation sweep restored the tree.dice-notation,dice-display,conversation-game-slash,game-narration-phase,game-checkpoint-engine-state,game-journal-edit,game-metadata-race,game-portrait-recovery,prompt,context-fit.console.*in any touched server file.Still owed by hand — this change needs a playtest night, not just a click-through:
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG.mdgains one entry. No version-bearing file is touched.docs/game/dice-and-skill-checks.mdis not updated here and is now incomplete — nothing in it becomes false, but the most player-visible part of this change (the two-beat narration), the pool rule, and the fact that a check can now be declined are undocumented. That edit belongs in the batched[docs-i18n]follow-up rather than in this PR.UI evidence (if applicable)
No new UI. The animated dice card, the narration log line and the check tag all render exactly as they did; what changes is which numbers are in them. Worth a before/after screenshot of a resolved check in the transcript if you want one on the record.
The deliberate trade: the narration is now two beats
The model writes the turn before the number exists. So it narrates up to the attempt, and the consequence lands on the following turn, once the resolved check is sitting in its context. That is the honest trade for a roll the player can trust on a connection that cannot call a dice tool, and it is the whole reason this change is worth having — but whether it reads well is a prose question that only a playtest night can answer.
This branch is deliberately isolated so that a "no" is one revert rather than an unpicking. If the two-beat rhythm reads badly, revert it and revisit — the separate
feat/game-mode-dice-toolbranch gets the number before the narration on connections that support tools, and this one stays the safety net underneath for the connections that do not.Known limitations, named here rather than left for review to find
resolution="successes", or a non-d20dice=— is left verbatim, numbers and all. So a GM that writes a self-serving roll and labels it as a pool keeps it. This is pre-existing behaviour, but it matters more now for two reasons: the headline of this change is "rolled by the engine instead of written by the Game Master", and the prompt now shows the GM the exact attribute pair that exits the audit — which it has to, because that same complete pool template is what stops real pools being mangled.[skill_check: skill="Intimidation" dc="4" rolls="3|7|9"]— nodice=, noresolution=— is rolled as a plain d20 and those three numbers are discarded. Pre-existing and arguably correct: with nothing declared there is nothing to distinguish it from a sparse d20 request, and the prompt tells the GM to write every attribute for a pool. But "pools are left exactly as the GM wrote them" is about declared systems, and this is the gap in that sentence.mode=or a bare flag, which has two edges. A hyphenateddis-advantagereads as advantage (word boundaries), so it throws two dice and keeps the higher — no emitter in the app produces that spelling, and the prompt teachesmode=. And an unquoted multi-word skill name still leaks a flag word:skill=Press the advantageparses the skill asPressand picks up advantage from the leftover text. The tag is mangled either way in that case; this is inherent to having a bare-flag form at all.key=declares nothing and consumes nothing. Closing that hole by requiring an unquoted value to touch its=would reopen the one the grammar was widened to fix —dice = 6d10would stop being read, and an unseen declaration is exactly the sparse-looking tag that gets handed to a d20. Both directions have tests.Skill check result: …line only for a tag it can read completely; otherwise it drops the tag and writes nothing. So a GM that asks for a pool and writes it badly has no record next turn that it asked. This is strictly better than the old behaviour (a fabricated d20 read back as fact), and player-side it is softer — the narration log still renders the unresolved tag as a plain system line — but it is a real consequence of "leave it standing".segment-edits.ts), with its own hand-rolled scanner and no audit at all. The two now agree about spacing and about mode. They still disagree about one shape: on a complete pool written with an empty attribute beforeresolution=, the context line can read→ 3.where it should read→ 3 successes.Cosmetic, one input class wide, and it belongs to a follow-up about that reader rather than to this PR.POST /game/skill-checkendpoint still rolls a pool it then refuses to rewrite. It resolves first and asks the guard second, so a caller that posts a pool still gets a d20 result back — only the saved transcript is protected. No shipped caller does that any more; a stale browser bundle would draw a d20 card over an untouched pool tag, which is the safe direction, but it is worth knowing.resolution=""anddice=""are refused deliberately per the code's own comment but nothing pins that; one alternative spelling of the grammar's lookahead, and dropping the trim onmode=, also survive. None is a defect in behaviour — all were driven and refuse correctly — they are optional extra pins if you want them.Summary by CodeRabbit
New Features
Improvements
Maintainer staging integration
Updated against current
stagingwithout conflicts.pnpm check,gm-skill-check-resolution, and neighboring dice-display, game-narration-phase, capability GM verbs/runtime, prompt, and context-fit regressions pass locally. This is automated proof, not a live-model playtest. The prerequisite dice-grammar PR is already on staging. Translation follow-up fordocs/game/dice-and-skill-checks.md: #5951. Human validation checkboxes remain unchecked.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.