Repository navigation
feat(reference-engine): add mnehmos-rpg-mcp A/B backend integration - #211
Merged
Merged
Conversation
Routes campaigns to either lantern-engine or the mnehmos-rpg-mcp reference engine (deployed as a separate Railway service in this project), per an explicit per-campaign toggle. This is a deliberate, disclosed override of ADR-H13 (reference engine must not be on the production request path) -- see the reconciliation note being added alongside this change. - reference-engine-client.ts: MCP JSON-RPC transport (Streamable HTTP) - reference-engine-store.ts: tenant-isolation routing table + LLM- authored narrative "docket" documents (state/player/npcs/journal/ secrets/campaign), with secrets excluded from every player-facing read by construction - reference-engine-tools.ts: fetches and caches the reference engine's tool schemas, converted to OpenRouter tool-call format - reference-engine-adapter.ts: golden-path campaign/character/ inventory/notes operations; hydrates the character sheet with real SRD data (saves, skills, hit die, spellcasting incl. Warlock Pact Magic) for any of the 12 D&D classes via the existing content kernel, while keeping hp/ac/inventory authoritative from the reference engine itself - reference-engine-dm.ts: the turn orchestrator -- an LLM calls the engine's tools (never the reverse), including two local-only tools (read_docket/write_docket) that never reach the remote engine - server.ts: routes campaign/character/inventory/notes/turn-submission endpoints to the selected backend; new POST .../engine-backend toggle - app.js/index.html: engine-backend toggle button + backend badge on the campaign list 47 new unit tests. Full suite otherwise unaffected (pre-existing, unrelated failures in the paused narrator-collapse refactor are not touched by this change). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ide, document mnehmos-rpg-mcp service
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…teria/Verification sections)
…h CLI GraphQL failure)
3 tasks done
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.
Summary
Adds a per-campaign A/B toggle between
lantern-engineand themnehmos-rpg-mcpreference engine (deployed as a separate Railway service in the same project). This is a deliberate, disclosed override of ADR-H13 ("reference engine is not Lantern production") — see the reconciliation note added to that ADR in this PR for the reasoning and the tenant-isolation mitigation.src/reference-engine-client.ts— MCP JSON-RPC transport (Streamable HTTP) to the reference engine.src/reference-engine-store.ts— the tenant-isolation control point (account+campaign → reference-engine world/party/character IDs; the reference engine itself has no tenant scoping at all) and storage for LLM-authored narrative "docket" documents, withsecretsexcluded from every player-facing read by construction.src/reference-engine-tools.ts— fetches/caches the reference engine's tool schemas as OpenRouter tool-call definitions.src/reference-engine-adapter.ts— golden-path campaign/character/inventory/notes operations. Hydrates the character sheet with real SRD data (saves, skills, hit die, proficiencies, spellcasting — including Warlock's actual Pact Magic slot table) for any of the 12 D&D classes via the existing Open5e content kernel (hydrateCharacter), while keeping HP/AC/inventory authoritative from the reference engine itself, never locally recomputed.src/reference-engine-dm.ts— the turn orchestrator: an LLM calls the engine's tools (never the reverse, per ADR-H37's doctrine), including two local-only tools (read_docket/write_docket) that never reach the remote engine.src/server.ts— routes campaign/character/inventory/notes/turn-submission endpoints to the selected backend; newPOST /api/campaigns/:id/engine-backendtoggle route.public/app.js/index.html— engine-backend toggle button in the campaign dossier + a backend badge on the campaign list.docs/ADR-H13-reference-engine-boundary.md— reconciliation note recording the 2026-08-11 override decision.docs/DEPLOYMENT.md— documents the newmnehmos-rpg-mcpservice and its env vars.Risk
session_manage.initializewill hand a caller "whichever w 8000 orld/party is first in the database" if IDs aren't passed explicitly. Mitigation:ReferenceEngineStoreis the only place account+campaign IDs bind to reference-engine world/party/character IDs, and the adapter never accepts a client-supplied raw reference-engine ID — real users only ever reach the reference engine through this one adapter, never directly.docs/REFERENCE-ENGINE.md). Campaigns routed to it inherit those bugs. This is disclosed, not fixed by this PR.lantern-engineremains the default backend for every campaign unless explicitly switched via the new toggle route. No existing campaign or code path changes behavior.quest_manageisn't wired yet) — cosmetic, not misleading, flagged as a fast-follow.Acceptance criteria
POST /api/campaigns/:id/engine-backend, withlantern-enginebehavior completely unchanged when not switched.PLAYER.mddocket attempting to override them.secretsdocket never appears in any player-facing API response, verified by a dedicated test.worldId/partyId/sessionId) regardless of what the model supplies, verified by a dedicated test.Verification
tsc --noEmitclean.mnehmos-rpg-mcpRailway service during development (MCP handshake, tool catalog, character creation, inventory, notes, session init) — including finding and fixing a real bug in that service's HTTP transport (stateless-transport-per-request reuse), separately committed there.🤖 Generated with Claude Code