Skip to content

feat: add species eligibility foundation#63

Merged
StreamDemon merged 10 commits into
mainfrom
feat/species-eligibility
Jul 22, 2026
Merged

feat: add species eligibility foundation#63
StreamDemon merged 10 commits into
mainfrom
feat/species-eligibility

Conversation

@StreamDemon

@StreamDemon StreamDemon commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Closes #60.

Adds source-stamped Human and deferred Psi-Stalker identity, structured O.C.C. species eligibility, shared species/attribute enforcement, explicit new-character persistence, legacy Human compatibility, and locked-Human builder/sheet presentation.

Validation:

  • vp check: 139 files formatted; 101 lint/typecheck files clean
  • vp test: 26 files; 559 tests passed
  • affected rules/backend/web package checks and tests passed
  • live browser acceptance passed for locked Human identity, shared O.C.C. eligibility, forge/persist/reload, vitals, spell casting, same-document route navigation, responsive layouts, keyboard access, and a clean console

The human maintainer retains merge authority.


Summary by cubic

Adds source-validated species identity and structured O.C.C. species eligibility with hardened checks across rules, web, and backend. Human is the only playable species; the builder is locked to Human and the sheet shows species (implements #60).

  • New Features

    • @riftforge/rules
      • Added a species catalog with Human (playable) and Psi-Stalker (unavailable), exposed as immutable entries.
      • Replaced O.C.C. prose with speciesEligibility (any | oneOf) and validate via validateOccEligibility (+ failure descriptions).
      • deriveSheet now projects species and rejects unknown/unavailable identities; LLW set to { kind: "any" }.
      • O.C.C. species references are validated at load.
    • Web
      • Identity step shows “HUMAN // LOCKED” with a note about current catalog scope.
      • O.C.C. step uses the unified eligibility validator, shows allowed species, and adds recovery guidance.
      • Character sheet identity line includes species.
    • Backend
      • characters.create requires speciesId and sheet returns resolved species.
      • Eligibility is enforced server-side (unknown, unavailable, disallowed species, and attribute shortfalls are rejected).
  • Migration

    • API: pass speciesId: "human" to characters.create for new characters.
    • Legacy characters without speciesId still load and default to Human.
    • No data migration required; schema allows missing speciesId only for existing documents.

Written for commit cdf5f70. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a source-backed Human/Psi-Stalker catalog, structured O.C.C. species eligibility, shared validation for species and attributes, legacy-compatible backend persistence, Human-locked builder identity, and species display in derived sheets.

Changes

Species Eligibility Foundation

Layer / File(s) Summary
Foundation plans and delivery contracts
.codex/superpowers/plans/..., .codex/superpowers/specs/...
Documents the species catalog, eligibility contracts, compatibility rules, integration boundaries, validation gates, and handoff workflow.
Species catalog and structured O.C.C. contracts
packages/rules/src/schema/*, packages/rules/src/content/*, packages/rules/src/engine/species.ts, packages/rules/src/engine/occ.ts, packages/rules/tests/species.test.ts, packages/rules/tests/occ.test.ts
Adds Human and deferred Psi-Stalker catalog entries, structured any/oneOf eligibility, legacy-field rejection, duplicate detection, and unknown-reference validation.
Shared eligibility and sheet derivation
packages/rules/src/engine/eligibility.ts, packages/rules/src/engine/character.ts, packages/rules/src/engine/builder.ts, packages/rules/tests/*
Centralizes species and attribute checks, formats failures, removes the prior attribute-only validator, and includes resolved species in derived sheets.
Backend species persistence and compatibility
packages/backend/convex/*, packages/backend/tests/*
Requires speciesId for new character creation while keeping legacy storage optional, validates writes, and verifies Human fallback for legacy documents.
Human-locked builder and resolved sheet display
apps/web/src/builder/*, apps/web/src/components/sheet-view.tsx, apps/web/tests/*, README.md
Locks the builder to Human, uses shared eligibility for O.C.C. gating and explanations, and displays resolved species in identity and dossier metadata.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Builder
  participant Eligibility
  participant CharacterCreate
  participant CharacterSheet
  Builder->>Eligibility: validate OCC, species, and attributes
  Eligibility-->>Builder: eligibility result and failure descriptions
  Builder->>CharacterCreate: character input with speciesId
  CharacterCreate->>Eligibility: validate character eligibility
  Eligibility-->>CharacterCreate: valid result or combined failures
  CharacterSheet->>Eligibility: resolve species during deriveSheet
  Eligibility-->>CharacterSheet: resolved species and validated sheet
Loading

Possibly related issues

  • #57 — This PR implements the species and shared eligibility prerequisite that #57 depends on for Coalition Grunt integration.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR implements the #60 foundation: Human-only defaulting, structured eligibility, shared validation, and locked builder/sheet behavior.
Out of Scope Changes check ✅ Passed The extra docs and test updates still support the same species-eligibility foundation; no clearly unrelated code changes stand out.
Title check ✅ Passed The title clearly matches the main change: introducing a species eligibility foundation.
Description check ✅ Passed The description is directly about the species identity and O.C.C. eligibility changes in this PR.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@StreamDemon
StreamDemon marked this pull request as ready for review July 22, 2026 13:28

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.codex/superpowers/specs/2026-07-22-occ-breadth-foundation-design.md:
- Around line 456-457: Update the wrapped text in the “next-up” section so
“#58.” remains at the end of the preceding sentence rather than starting the
next line, eliminating the MD018 warning while preserving the content and
meaning.
- Line 5: Update the Status declaration in the foundation design specification
to reflect that implementation has begun or is completed, replacing
“implementation not started” with the appropriate current status.

In `@apps/web/src/builder/steps/occ.tsx`:
- Around line 63-71: Update the failure-message rendering in the OCC eligibility
block using the failures returned by check(occ): show an
identity/O.C.C.-unavailable message when any failure is species-related, and
show the existing “REROLL ATTRIBUTES TO QUALIFY” guidance only for
attribute-only failures. Keep the existing failure descriptions and danger alert
intact.

In `@apps/web/tests/builder.test.ts`:
- Around line 28-39: Replace source-text assertions in
apps/web/tests/builder.test.ts lines 28-39 with behavioral tests that
instantiate the builder store and verify valid and species-ineligible O.C.C.
results through its accessors. In apps/web/tests/character-sheet.test.ts lines
46-48, render SheetView with a resolved sheet and assert the visible species
identity line, including the locked Human display. Ensure rule assertions use
printed rulebook values and cite the printed page via the content JSON page
field.

In `@packages/rules/src/engine/species.ts`:
- Around line 4-25: Make the exported species data immutable before it is
indexed or returned: freeze the parsed species catalog and each species entry,
then build speciesById from those frozen values. Update speciesCatalog,
humanSpecies, and getSpecies to expose only immutable entries while preserving
existing lookup and validation behavior in buildSpeciesIndex.

In `@packages/rules/tests/species.test.ts`:
- Around line 11-20: Extend the humanSpecies expectation in the “pins the
complete two-entry catalog and p.233 source” test to assert source metadata
matching the printed rulebook: book “Rifts Ultimate Edition” and page 233,
alongside the existing Human fields.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d1df2f8f-873a-48b8-b4fe-6e0248d8e02a

📥 Commits

Reviewing files that changed from the base of the PR and between 87fe6af and 4b35744.

📒 Files selected for processing (30)
  • .codex/superpowers/plans/2026-07-22-species-eligibility-foundation.md
  • .codex/superpowers/specs/2026-07-22-occ-breadth-foundation-design.md
  • README.md
  • apps/web/src/builder/steps/identity.tsx
  • apps/web/src/builder/steps/occ.tsx
  • apps/web/src/builder/store.ts
  • apps/web/src/components/sheet-view.tsx
  • apps/web/tests/builder.test.ts
  • apps/web/tests/character-sheet.test.ts
  • packages/backend/convex/characters.ts
  • packages/backend/convex/schema.ts
  • packages/backend/tests/characters.test.ts
  • packages/backend/tests/combat.test.ts
  • packages/backend/tests/healing-cast.test.ts
  • packages/rules/src/content/occ/ley-line-walker.json
  • packages/rules/src/content/species/species.json
  • packages/rules/src/engine/builder.ts
  • packages/rules/src/engine/character.ts
  • packages/rules/src/engine/eligibility.ts
  • packages/rules/src/engine/occ.ts
  • packages/rules/src/engine/species.ts
  • packages/rules/src/index.ts
  • packages/rules/src/schema/character.ts
  • packages/rules/src/schema/occ.ts
  • packages/rules/src/schema/species.ts
  • packages/rules/tests/builder.test.ts
  • packages/rules/tests/character.test.ts
  • packages/rules/tests/eligibility.test.ts
  • packages/rules/tests/occ.test.ts
  • packages/rules/tests/species.test.ts
💤 Files with no reviewable changes (1)
  • packages/rules/src/engine/builder.ts

Comment thread .codex/superpowers/specs/2026-07-22-occ-breadth-foundation-design.md Outdated
Comment thread .codex/superpowers/specs/2026-07-22-occ-breadth-foundation-design.md Outdated
Comment thread apps/web/src/builder/steps/occ.tsx Outdated
Comment thread apps/web/tests/builder.test.ts Outdated
Comment thread packages/rules/src/engine/species.ts Outdated
Comment thread packages/rules/tests/species.test.ts
@StreamDemon
StreamDemon merged commit 25b9231 into main Jul 22, 2026
3 checks passed
@StreamDemon
StreamDemon deleted the feat/species-eligibility branch July 22, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Species identity and O.C.C. eligibility foundation

1 participant