Repository navigation
fix: report missed spell attacks, and tighten the agent runtime - #116
Merged
Merged
Conversation
…e server An exploding one-sided die (1d1!) never stopped exploding, and dice counts were unbounded, so one math_manage call could freeze or kill the process for every campaign. Dice are now capped at 1000 dice of 1000 sides at every parser, exploding dice need at least 2 sides, and exact distributions are refused when too large to compute. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
subscribe_to_events left a callback pointing at the per-request HTTP transport. The next combat event in any campaign made it reject with 'Not connected'; the unhandled rejection shut the process down, and the shutdown path exited 0, so the host never restarted it. - Crashes now exit 1; requested stops still exit 0. - A subscriber whose connection is gone is dropped, not left to reject. - Subscribers only receive events from their own campaign. - On the stateless HTTP transport, where nothing can be pushed after the response, subscribe_to_events makes no subscription and points the caller at poll_events. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
- Moves are validated (destination, path, remaining movement) before opportunity attacks resolve. A refused move used to cost the mover hit points and the attacker its reaction, then report success. It is now an error, so the call rolls back. - Negative damage is rejected; it was subtracted as healing with no cap at max HP (a 7 HP goblin reached 107). Dice damage with a penalty floors at zero, and applyDamage/heal ignore negative amounts. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
npm audit fix: clears the advisories in @modelcontextprotocol/sdk and its transitive dependencies. The remaining zod advisory needs a breaking move to zod 4 and is left for a separate change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
- An attack outside the attacker's turn now resolves as its reaction, one per round, and no longer spends its action. It used to be a warning only, so a combatant could attack any number of times off turn. - A target must be within reach: 5ft for melee, or the new optional `range` (feet) for ranged and reach attacks. Checked only when both combatants have a position. - Caller-supplied attackBonus, dc and damage are bounded (-20..30, 1..40, 1000 damage), so one call can no longer decide the outcome. - Opportunity attacks use the attacker's attack bonus and the mover's AC when known instead of deriving both from initiative. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
…g call Pool eviction closed the least recently used handle even when a call was mid-transaction on it, and DELETE /campaign did the same. Eviction now skips handles that are in use, and erasure waits for the call in flight. The pool cap can be set with RPG_MAX_OPEN_DATABASES (default 64). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
Cached worlds were keyed by a guessable id alone and never evicted, so one campaign could read another's world by id and memory grew for the life of the process. Entries are now keyed by the verified tenant too, and the cache keeps the most recently used worlds (RPG_MAX_CACHED_WORLDS, default 32); the rest are restored from their database snapshot on demand. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
…ng it A hosted campaign that failed its integrity check was quarantined and swapped for an empty database, so the game looked deleted and play continued into a second file. Campaign databases now fail to open and the files are left untouched. Local single-user databases keep the quarantine-and-recreate behaviour. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
audit_logs stored arguments and results for every tool call and was never pruned. It now keeps the newest RPG_AUDIT_LOG_MAX_ROWS rows (default 5000). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
… URLs better-sqlite3 12 requires Node 20+, so CI no longer tests 18 and package.json declares the engine. The HTTP transport builds a server per request and logged tool registration every time; it now logs once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
The tool's outer input schema dropped the new range argument before it reached the handler, so a ranged attack could not be made over MCP. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
The earlier commits on this branch were squash-merged as #113. This merge keeps the current tree exactly as it is; it only records that history so the branch can be pushed without rewriting it. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
npm audit reported a memory-exhaustion advisory fixed only in zod 4. - z.record() takes an explicit key schema. - Object defaults that relied on inner defaults use .prefault(), which parses the default as zod 3 did (zod 4's .default() returns it as is). - UUID fields use z.guid() to keep zod 3's lenient matching. - load_tool_schema's summarizer read zod 3 internals; it now reads zod 4 definitions and produces byte-identical output for all 36 tools. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
Tree unchanged. The earlier commits on this branch were squash-merged as #113 and #114. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
A missed spell attack returned a bare 'casts Fire Bolt!' with no attack roll, no dice and no miss, so the caller could not tell a miss from a hit for zero damage. It now uses the same formatter as a hit. The fire bolt scaling test depended on three unseeded attacks all hitting and was retried to hide that; it is now deterministic and the retry is gone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
- Live replay took its model straight from the caller, so it bypassed the no-pro-model rule that invoke enforces. It now refuses a pro variant before calling the provider. - timeoutMs had no upper limit. The provider call runs inside the campaign's unit of work, holding its lock and an open transaction, so a huge timeout could stall a campaign. New and updated agents are capped at 120s; rows stored earlier are clamped when used. - An abort that landed while reading the response body escaped as a bare AbortError and was recorded as a generic error; it is now a timeout. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
Tree unchanged. The earlier commits on this branch were squash-merged as #113, #114 and #115. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Mnehmos
marked this pull request as ready for review
November 10, 2026 02:49
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Mnehmos
pushed a commit
that referenced
this pull request
Nov 10, 2026
Tree unchanged. The earlier commits on this branch were squash-merged as #113 to #116. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013FWeViVwVRAxVuCWaf7UQS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two follow-ups from the engine audit: the flaky spellcasting test (which turned out to be a real bug) and an audit pass over the agent runtime.
Spell attacks that miss
spellcasting.test.ts"12.1 - fire bolt damage scales with character level" failed by chance and carriedretry: 3. Repeating it 60 times showed why: when a spell attack missed, the response was a barecasts Fire Bolt!with no attack roll, no dice and no word that it missed. The caller could not tell a miss from a hit for zero damage.A missed spell attack now goes through the same formatter as a hit, so it reports the roll, the dice and
The spell missed!. The test no longer depends on three unseeded attacks all hitting, the retry is removed, and a new deterministic test covers the miss.Agent runtime
invokeenforces it through the competency ladder and overrides; livereplaytookmodelstraight from the caller. It now refuses a pro variant before calling the provider.timeoutMshad no upper limit. The provider call runs inside the campaign's unit of work, holding its lock and an open write transaction, so every other call on that campaign waits behind it. New and updated agents are capped at 120s (MAX_AGENT_TIMEOUT_MS); rows stored before the limit are clamped when used rather than rejected.AbortErrorand was stored as a genericerror. Both providers now classify it astimeout.Contract changes for
rpg-mcp-liveagent_managecreate/updatewithtimeoutMsabove 120000 returns a validation error.agent_managereplaywith a pro model returnserror: true.[SPELL: …]tag andSTATE_JSONblock are unchanged.Found but not changed
replay.next_turnauto-invoke succeeds and the enclosing call then fails, the provider was paid buttokensUsedis restored.Testing
tests/server/spellcasting.test.ts,tests/agent/runtime/timeout-bounds.test.ts, a replay model-policy test intests/agent/audit/replay.test.ts, body-read timeout tests intests/agent/provider/openai.test.ts.tests/server/websocket.test.ts, which cannot bind::in the sandbox this ran in; they pass in CI.Note on history
The branch could not be force-pushed after the earlier PRs were squash-merged, so their history is recorded with an
oursmerge that leaves the tree unchanged. The diff againstmainis only this change.Generated by Claude Code