[PR #6345] [MERGED] feat(game): ruleset catalogs and the sheet's Add from catalog picker (rulesets slice 8a) #7145

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

📋 Pull Request Information

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

Base: staging ← Head: feat/rulesets-catalogs


📝 Commits (10+)

  • 34073bb feat(game): ruleset catalogs, the shared format, Capability API 1.21 and the catalog route
  • 0daff86 fix(game): refuse an imported ruleset whose catalog points at a separate file
  • 4e40fea feat(game): pick sheet rows from a ruleset's catalogs
  • a168ba5 fix(game): answer a repeated catalog request with 304 and tidy the picker note and the plan status
  • c38bcd9 refactor(game): use the shared If-None-Match helper for the catalog route
  • e1999c0 fix(docs): tell the editor schema a catalog has exactly one of entries or asset
  • 4a0b4df fix(game): add a catalog entry whole or not at all, and tag the catalog answer with its header too
  • bfae63e refactor(game): share the tolerant archive path helper and write the summary pattern as plain ranges
  • 325ae69 docs(game): drop a stale comment on the catalog addition plan
  • 3fa3a5a fix(game): refuse at install a ruleset that names a catalog file the package does not declare

📊 Changes

22 files changed (+3214 additions, -89 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/development/game-rulesets-and-sheets-implementation.md (+19 -16)
📝 docs/development/optional-agent-packages.md (+39 -0)
📝 docs/examples/rulesets/ember-roads.json (+157 -3)
📝 docs/extending/ruleset.schema.json (+377 -0)
📝 docs/extending/writing-rulesets.md (+105 -0)
➕ packages/client/src/components/rulesets/RulesetCatalogPicker.tsx (+313 -0)
📝 packages/client/src/components/rulesets/RulesetSheetEditor.tsx (+72 -26)
📝 packages/client/src/hooks/use-capability-packages.ts (+25 -1)
➕ packages/client/src/lib/ruleset-catalog.ts (+362 -0)
📝 packages/client/src/localization/locales/en.json (+53 -0)
📝 packages/server/src/routes/capability-packages.routes.ts (+108 -3)
📝 packages/server/src/services/capability-packages/package-manager.service.ts (+136 -29)
📝 packages/server/src/services/storage/game-rulesets.storage.ts (+8 -0)
📝 packages/shared/src/schemas/capability-package.schema.ts (+27 -2)
📝 packages/shared/src/schemas/ruleset.schema.ts (+365 -3)
📝 scripts/generate-ruleset-schema.mjs (+12 -0)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+5 -5)
➕ scripts/regressions/game-ruleset-catalogs.regression.ts (+664 -0)
📝 scripts/regressions/game-ruleset-community.regression.ts (+14 -0)

...and 2 more files

📄 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 8a; it does not close the issue). Builds on #6343 (slice 7a, merged).

Why this change

  • The first hands-on use of the 5e sheet showed that typing spells, attacks and class features row by row is miserable. A community author will want to ship their system's content the same way an official package does.
  • This slice is the format and the picker. The first-party SRD content is a later package release in Marinara-Agents, and battles do not read any of this yet.

What changed

  • Catalogs. A ruleset may ship up to 12 catalogs: named collections of ready-made entries that fill the sheet's lists. A catalog names the lists it feeds and the filters its picker offers. Nothing is 5e-shaped: every list, column, filter and word comes from the ruleset file.
  • One entry can fill several lists. Each entry carries rows, one per list it writes. In the docs example, one knack adds a row to knacks and a limited-use row to tricks. Every row's values are checked against the target list's columns when the ruleset loads, by a new shared helper rulesetListRowIssues, so a catalog can never write what the sheet could not hold.
  • Copy at pick. Picked rows are copies the player can edit or delete like any other row. The only link back is a reserved row key, _catalog (<catalogId>/<entryId>). Column ids cannot start with _, and every sheet path already keeps unknown row keys, so nothing else had to change to carry it.
  • Optional mechanics. An entry may carry a strict, typed block (kind, range, area, targets, amount, damage type, save, cost, and so on). It is validated (the save and the pools must exist) and shown as one line in the picker, built from the ruleset's own labels. The Engine does not consume it yet; a later combat bridge will. The picker says so.
  • Inline or package asset. Small catalogs ride inline in ruleset.json. A package may ship a large one as catalogs/<id>.json (1 MB, 2000 entries), declared and hash-pinned like ruleset.json. Capability API 1.21 gates that asset family. A package is refused at install, with a readable message, when its ruleset has catalogs on an older declaration or names a catalog file the package does not declare.
  • Serving. GET /capability-packages/rulesets strips inline entries and reports entryCount, so that payload stays small. New GET /capability-packages/rulesets/catalog?rulesetId=&catalogId=&version= returns one catalog's validated entries, for the exact version an imported ruleset's game pinned. A packaged catalog answers a repeated request with 304; its ETag is the pinned file hash, the ruleset version and a digest of the catalog header.
  • Community rulesets carry catalogs inline only, inside the 256 KB file. A file whose catalog points at a separate asset is refused at import with the reason. Separate catalog files for the community lanes are recorded in the plan as a later step.
  • The picker. Every list a catalog feeds gets Add from catalog beside Add row, in the one shared sheet editor, so the character and persona Stats editors and the in-game Edit sheet all get it. Search, filters from the catalog header (a filter can start from a sheet field, for example the character's calling), multi-select, an Added mark on entries the sheet already holds, per-list room counts, and Add is disabled when a list would overflow. An entry is added whole or not at all, rows meant for a list that hideWhen hides on this sheet are left out, and one commit writes every target list.
  • Docs and example. The authoring guide gains a Catalogs section, docs/development/optional-agent-packages.md documents the asset family and 1.21, the Ember Roads example gains a knacks catalog (it still rolls 2d6), and the JSON Schema is regenerated.
  • Regressions: game-ruleset-catalogs (header and entry checks, the row validator, _catalog, the listing, the route for inline and packaged catalogs, 304, refusals, the 1.21 gate) and the client-lane ruleset-catalog-picker (filter options, startFrom, already-added detection, overflow planning, the mechanics line).

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), pnpm localization:check, the full node regression lane (pnpm regression:node: 313 of 314 on the first run, where gallery-recovery.regression.ts hit the 30 s timeout while another gate and a review were running on the same machine; it passes alone in under a second and this PR does not touch it), and the two new regressions. Sixteen complete local CodeRabbit sweeps were run before opening (one more was cut short by the CLI's rate limit and not counted). Their findings were fixed (all-or-nothing entries, rows kept out of lists hidden on the sheet, the 304 answer and its ETag, the install-time asset check, no retry on a 4xx, tolerant reads of stored lists, labelled number chips, and three editor schema points), and the last complete one returned no findings. One suggestion was declined: an in-process cache of parsed catalogs. The 304 answer and the client's query cache already avoid the repeated work, and a second cache would need its own invalidation. The e2e suite was checked by reading it: no spec locates or mocks the ruleset sheet editor or the ruleset routes, and every read of definition.catalogs tolerates it being absent. Playwright was not run locally.

The agent also drove a scratch server on port 7820 with a fresh data folder: imported the Ember Roads example, confirmed the listing carries entryCount: 6 and no entries, and the catalog route returned the six entries. In a character's Stats tab, Add a sheet showed Add from catalog on both fed lists. The picker opened with focus in the search box, three filters, chips and the mechanics line ("Healing · self or touch · allies · 3 · costs 1 Grit"). Choosing three entries showed "Knacks gains 3, with room for 20" and "Limited tricks gains 1, with room for 12"; Add wrote three knacks and one trick in one change, _catalog was never shown as a column, reopening the picker marked the three as Added, and after saving the character the stored rows carried _catalog. At 375 px the picker fit the screen with nothing past the right edge and the Add button on screen (live geometry, not a screenshot).

Still to verify by hand:

  • Manually pick from a catalog in a persona's Stats editor and in a game's Edit sheet.
  • Manually fill a list to its maximum and confirm Add is disabled and names the full list.
  • Manually check the picker's error state (for example by uninstalling the ruleset in another tab) and Try again.
  • Manually install a PACKAGE that ships catalogs/<id>.json; only the regression covers the packaged path, because no published package has one yet.
  • Manually verify light mode.

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/extending/writing-rulesets.md, docs/development/optional-agent-packages.md, the plan, the example and the generated schema. The [docs-i18n] follow-up is batched for the ruleset slices.

UI evidence (if applicable)

To be added by a human: the Add from catalog button and the picker, in light, dark and phone width.

Summary by CodeRabbit

  • New Features

    • Added ruleset catalogs for ready-made spells, features, gear, and other sheet entries.
    • Added an Add from catalog picker with search, filters, duplicate detection, and list capacity previews.
    • Catalog entries are copied to sheets as editable rows.
    • Added support for inline catalogs and separate catalog files through Capability API 1.21.
    • Added mechanics summaries and filters for catalog entries.
  • Documentation

    • Documented catalog formats, validation, limits, API behavior, and authoring guidelines.
    • Added an Ember Roads example featuring catalogs and new sheet lists.

🔄 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/6345 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/19/2026 **Status:** ✅ Merged **Merged:** 9/19/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/rulesets-catalogs` --- ### 📝 Commits (10+) - [`34073bb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/34073bb15667d620865b3ba0a276c9a44f86f554) feat(game): ruleset catalogs, the shared format, Capability API 1.21 and the catalog route - [`0daff86`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0daff86c7ab1b34760b10cc777906c100009c658) fix(game): refuse an imported ruleset whose catalog points at a separate file - [`4e40fea`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4e40fea2f8141bb8b7eb5066b90fcfa6bbb28e5c) feat(game): pick sheet rows from a ruleset's catalogs - [`a168ba5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a168ba583050359708ea34c24c5d15139ea362e4) fix(game): answer a repeated catalog request with 304 and tidy the picker note and the plan status - [`c38bcd9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c38bcd900f84f9886ceb001ae45e91a21b8dd189) refactor(game): use the shared If-None-Match helper for the catalog route - [`e1999c0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e1999c026eb74b97273b319a0dfba48479e5c4c9) fix(docs): tell the editor schema a catalog has exactly one of entries or asset - [`4a0b4df`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4a0b4dfabf421e401cd8f3d815cd2902be780f13) fix(game): add a catalog entry whole or not at all, and tag the catalog answer with its header too - [`bfae63e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bfae63e2b74e3d43e6e51c193eac54186390dc69) refactor(game): share the tolerant archive path helper and write the summary pattern as plain ranges - [`325ae69`](https://github.com/Pasta-Devs/Marinara-Engine/commit/325ae6974a5ad7b3684217b578f8db5fcd855148) docs(game): drop a stale comment on the catalog addition plan - [`3fa3a5a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3fa3a5ab344e9341aec5f6d8e7d66b8c39483067) fix(game): refuse at install a ruleset that names a catalog file the package does not declare ### 📊 Changes **22 files changed** (+3214 additions, -89 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/development/game-rulesets-and-sheets-implementation.md` (+19 -16) 📝 `docs/development/optional-agent-packages.md` (+39 -0) 📝 `docs/examples/rulesets/ember-roads.json` (+157 -3) 📝 `docs/extending/ruleset.schema.json` (+377 -0) 📝 `docs/extending/writing-rulesets.md` (+105 -0) ➕ `packages/client/src/components/rulesets/RulesetCatalogPicker.tsx` (+313 -0) 📝 `packages/client/src/components/rulesets/RulesetSheetEditor.tsx` (+72 -26) 📝 `packages/client/src/hooks/use-capability-packages.ts` (+25 -1) ➕ `packages/client/src/lib/ruleset-catalog.ts` (+362 -0) 📝 `packages/client/src/localization/locales/en.json` (+53 -0) 📝 `packages/server/src/routes/capability-packages.routes.ts` (+108 -3) 📝 `packages/server/src/services/capability-packages/package-manager.service.ts` (+136 -29) 📝 `packages/server/src/services/storage/game-rulesets.storage.ts` (+8 -0) 📝 `packages/shared/src/schemas/capability-package.schema.ts` (+27 -2) 📝 `packages/shared/src/schemas/ruleset.schema.ts` (+365 -3) 📝 `scripts/generate-ruleset-schema.mjs` (+12 -0) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+5 -5) ➕ `scripts/regressions/game-ruleset-catalogs.regression.ts` (+664 -0) 📝 `scripts/regressions/game-ruleset-community.regression.ts` (+14 -0) _...and 2 more files_ </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 8a; it does not close the issue). Builds on #6343 (slice 7a, merged). ## Why this change - The first hands-on use of the 5e sheet showed that typing spells, attacks and class features row by row is miserable. A community author will want to ship their system's content the same way an official package does. - This slice is the format and the picker. The first-party SRD content is a later package release in Marinara-Agents, and battles do not read any of this yet. ## What changed - **Catalogs.** A ruleset may ship up to 12 catalogs: named collections of ready-made entries that fill the sheet's lists. A catalog names the lists it feeds and the filters its picker offers. Nothing is 5e-shaped: every list, column, filter and word comes from the ruleset file. - **One entry can fill several lists.** Each entry carries `rows`, one per list it writes. In the docs example, one knack adds a row to `knacks` and a limited-use row to `tricks`. Every row's values are checked against the target list's columns when the ruleset loads, by a new shared helper `rulesetListRowIssues`, so a catalog can never write what the sheet could not hold. - **Copy at pick.** Picked rows are copies the player can edit or delete like any other row. The only link back is a reserved row key, `_catalog` (`<catalogId>/<entryId>`). Column ids cannot start with `_`, and every sheet path already keeps unknown row keys, so nothing else had to change to carry it. - **Optional `mechanics`.** An entry may carry a strict, typed block (kind, range, area, targets, amount, damage type, save, cost, and so on). It is validated (the save and the pools must exist) and shown as one line in the picker, built from the ruleset's own labels. The Engine does not consume it yet; a later combat bridge will. The picker says so. - **Inline or package asset.** Small catalogs ride inline in `ruleset.json`. A package may ship a large one as `catalogs/<id>.json` (1 MB, 2000 entries), declared and hash-pinned like `ruleset.json`. **Capability API 1.21** gates that asset family. A package is refused at install, with a readable message, when its ruleset has catalogs on an older declaration or names a catalog file the package does not declare. - **Serving.** `GET /capability-packages/rulesets` strips inline entries and reports `entryCount`, so that payload stays small. New `GET /capability-packages/rulesets/catalog?rulesetId=&catalogId=&version=` returns one catalog's validated entries, for the exact version an imported ruleset's game pinned. A packaged catalog answers a repeated request with 304; its ETag is the pinned file hash, the ruleset version and a digest of the catalog header. - **Community rulesets** carry catalogs inline only, inside the 256 KB file. A file whose catalog points at a separate asset is refused at import with the reason. Separate catalog files for the community lanes are recorded in the plan as a later step. - **The picker.** Every list a catalog feeds gets **Add from catalog** beside **Add row**, in the one shared sheet editor, so the character and persona Stats editors and the in-game **Edit sheet** all get it. Search, filters from the catalog header (a filter can start from a sheet field, for example the character's calling), multi-select, an **Added** mark on entries the sheet already holds, per-list room counts, and **Add** is disabled when a list would overflow. An entry is added whole or not at all, rows meant for a list that `hideWhen` hides on this sheet are left out, and one commit writes every target list. - **Docs and example.** The authoring guide gains a Catalogs section, `docs/development/optional-agent-packages.md` documents the asset family and 1.21, the Ember Roads example gains a `knacks` catalog (it still rolls 2d6), and the JSON Schema is regenerated. - **Regressions:** `game-ruleset-catalogs` (header and entry checks, the row validator, `_catalog`, the listing, the route for inline and packaged catalogs, 304, refusals, the 1.21 gate) and the client-lane `ruleset-catalog-picker` (filter options, `startFrom`, already-added detection, overflow planning, the mechanics line). ## 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), `pnpm localization:check`, the full node regression lane (`pnpm regression:node`: 313 of 314 on the first run, where `gallery-recovery.regression.ts` hit the 30 s timeout while another gate and a review were running on the same machine; it passes alone in under a second and this PR does not touch it), and the two new regressions. Sixteen complete local CodeRabbit sweeps were run before opening (one more was cut short by the CLI's rate limit and not counted). Their findings were fixed (all-or-nothing entries, rows kept out of lists hidden on the sheet, the 304 answer and its ETag, the install-time asset check, no retry on a 4xx, tolerant reads of stored lists, labelled number chips, and three editor schema points), and the last complete one returned no findings. One suggestion was declined: an in-process cache of parsed catalogs. The 304 answer and the client's query cache already avoid the repeated work, and a second cache would need its own invalidation. The e2e suite was checked by reading it: no spec locates or mocks the ruleset sheet editor or the ruleset routes, and every read of `definition.catalogs` tolerates it being absent. Playwright was not run locally. The agent also drove a scratch server on port 7820 with a fresh data folder: imported the Ember Roads example, confirmed the listing carries `entryCount: 6` and no entries, and the catalog route returned the six entries. In a character's **Stats** tab, **Add a sheet** showed **Add from catalog** on both fed lists. The picker opened with focus in the search box, three filters, chips and the mechanics line ("Healing · self or touch · allies · 3 · costs 1 Grit"). Choosing three entries showed "Knacks gains 3, with room for 20" and "Limited tricks gains 1, with room for 12"; **Add** wrote three knacks and one trick in one change, `_catalog` was never shown as a column, reopening the picker marked the three as **Added**, and after saving the character the stored rows carried `_catalog`. At 375 px the picker fit the screen with nothing past the right edge and the **Add** button on screen (live geometry, not a screenshot). Still to verify by hand: - Manually pick from a catalog in a persona's Stats editor and in a game's **Edit sheet**. - Manually fill a list to its maximum and confirm **Add** is disabled and names the full list. - Manually check the picker's error state (for example by uninstalling the ruleset in another tab) and **Try again**. - Manually install a PACKAGE that ships `catalogs/<id>.json`; only the regression covers the packaged path, because no published package has one yet. - Manually verify light mode. ## 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/extending/writing-rulesets.md`, `docs/development/optional-agent-packages.md`, the plan, the example and the generated schema. The `[docs-i18n]` follow-up is batched for the ruleset slices. ## UI evidence (if applicable) To be added by a human: the **Add from catalog** button and the picker, in light, dark and phone width. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added ruleset catalogs for ready-made spells, features, gear, and other sheet entries. * Added an **Add from catalog** picker with search, filters, duplicate detection, and list capacity previews. * Catalog entries are copied to sheets as editable rows. * Added support for inline catalogs and separate catalog files through Capability API 1.21. * Added mechanics summaries and filters for catalog entries. * **Documentation** * Documented catalog formats, validation, limits, API behavior, and authoring guidelines. * Added an Ember Roads example featuring catalogs and new sheet lists. <!-- 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:56 +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#7145
No description provided.