srdcheck is a deterministic rules-adjudication tool designed for "agents that run games," describing itself as "the rules lawyer for agents." It gives machine-decidable conclusions for specific rules of System Reference Document 5.2.1: applying rules comes with citations, results are reproducible, it runs offline, and it honestly refuses questions beyond its published scope. In the repository, the SRD 5.2.1 adapter serves as the reference implementation, and a 5.1 adapter is also provided.
Purpose and positioning The project targets scenarios in which multiple agents share the same evolving game state: GM, player agents, rules referees, and tool callers. After multiple models each read the SRD, they give different rulings on grappling, concentration, death saving throws, and so on, causing the shared state to silently fall out of sync. srdcheck provides a common deterministic rules track so that everyone calling it gets the same atomic conclusions and citations, every application of a rule has an auditable provenance, and table rulings retain a separate ruling lineage. It describes itself as a "track" rather than a knowledge base: it takes structured facts as input and outputs deterministic, scope-constrained results.
Main capabilities
- Gives rulings on named and bounded questions, such as whether a proposal passes a modeled action-economy check, and which kinds of modeled budget options remain.
- Exit code semantics: 0 means passing the checked scope, 1 means conflicting with the checked scope, 2 means unable to adjudicate.
- Ruling mode 4.0 retains coverage_level, checked_scope, unchecked_scope, and assumptions on every result, and separately reports asserted/consumed/derived/missing facts, a suggested rule_result, a scoped DM table_decision, and explicit state changes.
- State commits use fail-closed behavior: event.apply generates idempotent transition proposals bound to the exact evaluation state, transition.commit rejects stale or out-of-order proposals, retries return semantically identical receipts; atomic state writes are still performed by the agent-DM or host.
- Table policy persistence: provides a portable table-policy manifest with request/encounter/session/campaign IDs, automatically applies matching rulings, distinguishes them from SRD results, and carries an explicit table-authority lineage.
- Deterministic and fast: there are no LLM calls in the adjudication path, and it runs locally offline; CI requires the p95 latency of 100 adjudications to be under 100 ms.
- Observability: metadata-only lifecycle events can optionally be enabled, including request/adjudication IDs, versions, rejection categories, and elapsed time, output to stderr or a caller-provided sink; by contract, raw prompts, state, rulings, citations, and error messages are excluded, and SRDCheck itself does not persist anything.
- Agent-first: provides MCP and CLI, --pipe, --schema, and tool.json at the repository root.
- Rulesets as adapters: the core contains no game knowledge; all rules content is loaded by adapter packages, and each adapter carries its own provenance manifest (source documents, hashes, licenses, attribution). The SRD 5.2.1 adapter serves as the reference implementation in this repository; anyone can build adapters for other rulesets.
Usage
- Agents start with SKILL.md, which explains when to invoke it, examples, and MUST/MUST NOT.
- MCP: after installation, the command is srdcheck-mcp; it can also be run from a cloned repository. Each invocation returns the same adjudication object as the CLI in structured content.
- CLI: provides --pipe and --schema; query and --pipe can accept --table-evaluation for hosts that need the shared table.evaluation/1.0 envelope; the optional --table-context JSON can add the caller's own session_id, entity_refs, and correlation_id. Adjudication output goes to stdout, and metadata-only canonical NDJSON output goes to stderr.
- Python library: loads the content of a ruleset through a stable versioned interface, without coupling to internal file paths; the adapter identifier carries the version, and load_adapter("srd-5.2.1") and load_adapter("srd-5.1") can coexist. Provides cross-version version trap detection (edition_check, for example 2014's "Goblin" is "Goblin Warrior" in 2024).
Applicable scenarios Suitable for tabletop game runtime environments with shared state across multiple agents, including scenarios where an agent acts as the authorized DM; it can be embedded into others' DM products, VTTs, or agents. It is also suitable for evaluation and judging workflows that require consistent, citable rules adjudication; the repository includes bench/ rules-fidelity judging: versioned question sets with SRD citation gold standards, and a harness that can score any model or agent (gemini:, ollama:, or cmd:your-agent).
Limitations and boundaries The current SRD adapter covers combat turn basics and does not yet check: feature prerequisites (turn.plan only adjudicates action economy and does not verify whether a feature grants that action), the specific effects of individual spells (damage/HP, death saves, and saving throws are modeled, but spells such as Fireball's 8d6 and Hold Person's paralysis effect are not handled; srdcheck computes saves, does not roll dice, and does not apply spell-specific effects), and status coverage varies by query surface (15 SRD statuses are registered and classified individually, but each query claims only the effects it actually consumes; positional geometry, initiative order, and stealth/perception contests remain explicit boundaries). Content outside SRD 5.2.1 returns exit code 2 (jurisdiction). The 0.2.1 adapter explicitly rejects typos or unknown query fields and points out the offending field, and never silently uses defaults. Additional information is requested only for facts that can change the result; meaningless input (negative speed, 99th-level spells, exhaustion above 6) returns exit code 2. Whenever in doubt, srdcheck rejects, because an incorrect adjudication is the only unforgivable bug.