[PR #6315] [MERGED] feat(game): ruleset schema, registry and Capability API 1.20 (rulesets slice 1) #7134

Closed
opened 2026-10-23 04:16:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6315
Author: @kolacheee
Created: 9/18/2026
Status: ✅ Merged
Merged: 9/18/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/rulesets-registry


📝 Commits (2)

  • 4d7816c feat(game): add ruleset schema, registry and Capability API 1.20
  • 57ce70e fix(game): require the ruleset kind wherever ruleset.json is listed

📊 Changes

13 files changed (+2856 additions, -7 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
➕ docs/development/game-rulesets-and-sheets-implementation.md (+236 -0)
📝 docs/development/optional-agent-packages.md (+48 -0)
➕ docs/development/ruleset-5e-2014.example.json (+1109 -0)
📝 packages/client/src/components/agents/AgentCatalogView.tsx (+1 -0)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+82 -0)
➕ packages/server/src/services/game/ruleset-registry.service.ts (+125 -0)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+20 -2)
➕ packages/shared/src/schemas/ruleset.schema.ts (+854 -0)
📝 packages/shared/src/types/chat.ts (+3 -0)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+5 -5)
➕ scripts/regressions/game-ruleset-registry.regression.ts (+371 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Part of #6314 (slice 1 of 7; it does not close the issue).

Why this change

  • Game Mode checks are locked to a d20 plus Marinara's own modifiers, and the sheet is six attributes. Running another tabletop system today takes several per-turn agents per system.
  • This is the groundwork for selectable rulesets: the data format, the way a package ships one, and the way a game remembers which one it was created on. It changes no behaviour yet, which makes it the cheapest place to find out the format is wrong.

What changed

  • Shared schema (packages/shared/src/schemas/ruleset.schema.ts): a strict zod schema for ruleset.json. A ruleset picks a resolution kind from a closed, Engine-owned set (first kind: dice-sum) and declares a sheet from closed primitives. There are no expression strings. Every name a ruleset uses is checked to exist, derived values may only read values declared above them (so a cycle cannot be written), and all text that can reach the GM prompt follows the gm-verbs hygiene rules. Refusals come back as path: message lines an author can act on.
  • The format is not 5e-shaped. No id is special, the dice are a parameter, saves are a list like skills, and rest amounts, row pools and the prompt summary are general primitives. docs/development/game-rulesets-and-sheets-implementation.md § Format decisions lists each choice and why.
  • The pin: chat.metadata.gameRuleset (RulesetRef), declared on ChatMetadata. No pin resolves to engine-legacy.
  • Capability API 1.20: a package lists ruleset.json in contributions.assets.paths, declares the new kind ruleset, and needs no permission and no entrypoint. Listing the asset requires 1.20, so an older Engine refuses the install cleanly. The lifecycle regression's version pin, message regexes and unsupported-minor probe moved together.
  • Registry (ruleset-registry.service.ts plus rulesetSources() in the package manager): reads every ready package's ruleset with the same discipline as gm-verbs.json (declared, hash-pinned, refused on declared size above 256 KB before the read, re-verified against the install hash). A file it cannot use is dropped with one log line. Two packages claiming one id resolve by package-id order. A pin the install cannot honour (missing, or older than the pinned version) is reported as unavailable, never reinterpreted.
  • Docs: the plan, the first-party 5e file as ruleset-5e-2014.example.json, and § Capability API 1.20 in optional-agent-packages.md.
  • Regression: scripts/regressions/game-ruleset-registry.regression.ts covers the 5e file validating, a 2d6 system with its own names validating, sixteen refusal cases, registry drops with their log lines, pin resolution, and the manifest gate.

Local CodeRabbit review: three findings fixed (hideWhen value typing, locale-free ordering, a regression message). One declined: memoizing the registry. It is re-read per call on purpose, like the GM verb table, so install, update, disable and uninstall need no invalidation and every read is re-verified against the install hash.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Commands run locally by the agent: pnpm check (exit 0), and the regressions game-ruleset-registry, capability-package-lifecycle, capability-gm-verbs, capability-tool-runtime and agent-catalog-kind-badges (all pass).

Still to verify by hand:

  • Manually verify that an existing game opens and plays a turn with a skill check exactly as before (no pin, so nothing should differ).
  • Manually verify that Download Agents still lists and installs packages, since the package kind list gained ruleset.
  • There is no UI in this slice, so there is nothing else to click through yet.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Docs touched: CHANGELOG.md, docs/development/optional-agent-packages.md, and two new files under docs/development/. The [docs-i18n] follow-up will be filed as one batch for the ruleset slices.

UI evidence (if applicable)

None. The only client change is the word "Rules" for the new package kind in the catalog.

Summary by CodeRabbit

  • New Features

    • Added groundwork for Game Mode rulesets supplied through capability packages.
    • Added validation and integrity checks for ruleset.json packages under Capability API 1.20.
    • Games can record their creation ruleset; games without one continue using legacy behavior.
    • Added an example 5e (SRD 5.1) ruleset configuration.
    • Ruleset packages now appear with a “Rules” label in the catalog.
    • Ruleset selection is not yet active; existing game behavior remains unchanged.
  • Documentation

    • Added implementation and package-authoring documentation.
  • Tests

    • Added coverage for validation, registration, compatibility, and failure handling.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6315 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/18/2026 **Status:** ✅ Merged **Merged:** 9/18/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/rulesets-registry` --- ### 📝 Commits (2) - [`4d7816c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4d7816c8bf743b1bab5f8248f6231ecf41bde66c) feat(game): add ruleset schema, registry and Capability API 1.20 - [`57ce70e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/57ce70eeb2a1e751bcb431ae8131c5023dc40236) fix(game): require the ruleset kind wherever ruleset.json is listed ### 📊 Changes **13 files changed** (+2856 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) ➕ `docs/development/game-rulesets-and-sheets-implementation.md` (+236 -0) 📝 `docs/development/optional-agent-packages.md` (+48 -0) ➕ `docs/development/ruleset-5e-2014.example.json` (+1109 -0) 📝 `packages/client/src/components/agents/AgentCatalogView.tsx` (+1 -0) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+82 -0) ➕ `packages/server/src/services/game/ruleset-registry.service.ts` (+125 -0) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+20 -2) ➕ `packages/shared/src/schemas/ruleset.schema.ts` (+854 -0) 📝 `packages/shared/src/types/chat.ts` (+3 -0) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+5 -5) ➕ `scripts/regressions/game-ruleset-registry.regression.ts` (+371 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Part of #6314 (slice 1 of 7; it does not close the issue). ## Why this change - Game Mode checks are locked to a d20 plus Marinara's own modifiers, and the sheet is six attributes. Running another tabletop system today takes several per-turn agents per system. - This is the groundwork for selectable rulesets: the data format, the way a package ships one, and the way a game remembers which one it was created on. It changes no behaviour yet, which makes it the cheapest place to find out the format is wrong. ## What changed - **Shared schema** (`packages/shared/src/schemas/ruleset.schema.ts`): a strict zod schema for `ruleset.json`. A ruleset picks a resolution kind from a closed, Engine-owned set (first kind: `dice-sum`) and declares a sheet from closed primitives. There are no expression strings. Every name a ruleset uses is checked to exist, derived values may only read values declared above them (so a cycle cannot be written), and all text that can reach the GM prompt follows the gm-verbs hygiene rules. Refusals come back as `path: message` lines an author can act on. - **The format is not 5e-shaped.** No id is special, the dice are a parameter, saves are a list like skills, and rest amounts, row pools and the prompt summary are general primitives. `docs/development/game-rulesets-and-sheets-implementation.md` § Format decisions lists each choice and why. - **The pin**: `chat.metadata.gameRuleset` (`RulesetRef`), declared on `ChatMetadata`. No pin resolves to `engine-legacy`. - **Capability API 1.20**: a package lists `ruleset.json` in `contributions.assets.paths`, declares the new kind `ruleset`, and needs no permission and no entrypoint. Listing the asset requires 1.20, so an older Engine refuses the install cleanly. The lifecycle regression's version pin, message regexes and unsupported-minor probe moved together. - **Registry** (`ruleset-registry.service.ts` plus `rulesetSources()` in the package manager): reads every ready package's ruleset with the same discipline as `gm-verbs.json` (declared, hash-pinned, refused on declared size above 256 KB before the read, re-verified against the install hash). A file it cannot use is dropped with one log line. Two packages claiming one id resolve by package-id order. A pin the install cannot honour (missing, or older than the pinned version) is reported as unavailable, never reinterpreted. - **Docs**: the plan, the first-party 5e file as `ruleset-5e-2014.example.json`, and § Capability API 1.20 in `optional-agent-packages.md`. - **Regression**: `scripts/regressions/game-ruleset-registry.regression.ts` covers the 5e file validating, a 2d6 system with its own names validating, sixteen refusal cases, registry drops with their log lines, pin resolution, and the manifest gate. Local CodeRabbit review: three findings fixed (hideWhen value typing, locale-free ordering, a regression message). One declined: memoizing the registry. It is re-read per call on purpose, like the GM verb table, so install, update, disable and uninstall need no invalidation and every read is re-verified against the install hash. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes Commands run locally by the agent: `pnpm check` (exit 0), and the regressions `game-ruleset-registry`, `capability-package-lifecycle`, `capability-gm-verbs`, `capability-tool-runtime` and `agent-catalog-kind-badges` (all pass). Still to verify by hand: - Manually verify that an existing game opens and plays a turn with a skill check exactly as before (no pin, so nothing should differ). - Manually verify that **Download Agents** still lists and installs packages, since the package kind list gained `ruleset`. - There is no UI in this slice, so there is nothing else to click through yet. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Docs touched: `CHANGELOG.md`, `docs/development/optional-agent-packages.md`, and two new files under `docs/development/`. The `[docs-i18n]` follow-up will be filed as one batch for the ruleset slices. ## UI evidence (if applicable) None. The only client change is the word "Rules" for the new package kind in the catalog. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added groundwork for Game Mode rulesets supplied through capability packages. * Added validation and integrity checks for `ruleset.json` packages under Capability API 1.20. * Games can record their creation ruleset; games without one continue using legacy behavior. * Added an example 5e (SRD 5.1) ruleset configuration. * Ruleset packages now appear with a “Rules” label in the catalog. * Ruleset selection is not yet active; existing game behavior remains unchanged. * **Documentation** * Added implementation and package-authoring documentation. * **Tests** * Added coverage for validation, registration, compatibility, and failure handling. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:16:50 +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#7134
No description provided.