This repository was archived by the owner on Sep 23, 2026. It is now read-only.
feat(2024): validate and reshape generated monster data - #1228
Merged
Merged
Conversation
Contributor
Collaborator
Author
|
Thanks for catching that. You're right, the 2024 SRD has no text after the AC value, so What changed:
The existing hand-made entries in This PR is stacked on #1226. Its base is a copy of your branch ( |
bagelbits
added this pull request to stack #1232
September 22, 2026 21:46
Normalize the PDF text (ability scores, wrapped and merged header lines) and pair text blocks to monsters by ability scores plus CR instead of array position, which had swapped several monsters' skills and PB. Reshape output to MonsterSchema: numeric CR, xp/xp_in_lair, armor_class array, condition references, senses parsing, dc and multi-type damage parsed from descriptions. Add optional damage to reactions. Add monsterGeneration test that runs the script into a temp dir and checks schema, PB vs CR, skill bonuses, senses, XP, DC and damage. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Read At Will and N/Day spell lists from the stat block text, since the gist descriptions stop at the intro line. Match each list to its entry by the intro's ability, save DC and to-hit bonus, because the PDF layout can put one block's spellcasting inside the previous block's text. Resolve every spell against 5e-SRD-Spells.json, map "(level N version)" to the spell level and other parentheticals to capitalized notes. Fail the script on any unknown spell or unused list. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Validate the generated monsters against the real schema instead of a test-only extension. Omit skills and gear when the source says None. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Build spellcasting for entries that cast named spells inline, including Coven Magic and bonus actions, reactions and legendary actions. Inherit ability, DC and to-hit from the monster's Spellcasting entry when the text says "the same spellcasting ability". Take per-day usage from the action name. Allow spellcasting on reactions and legendary actions in the schema. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Stacked PRs target a non-main base, so the main-only filter skipped lint and tests on them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Drop spell list lines the gist parsed as entries, strip the next block's title from the last entry of a block, split entries the gist merged, and complete descriptions truncated at page breaks from the stat block text. A completion is only accepted when the gist text is an exact prefix of the text paragraph. Link Nightmare Haunting's Dream cast. chain-devil Unnerving Gaze is cut off in the source text itself and stays listed as a known truncation in the test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The gist split the reaction in two. The text has the full sentence; the em dash in the gist stopped the prefix match. Normalize dashes and drop the known-truncation allow-list from the test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Move text normalization, stat block parsing, entry cleanup and spellcasting out of processMonsterData.mjs. Generated JSON and normalized text are byte-identical before and after. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Parse Multiattack descriptions into multiattack_type, actions and action_options, using the same Choice shape as the 2014 and existing 2024 monsters. Handle fixed sequences, ability uses, alternatives, "any combination" choices and "can replace one attack with" clauses. Attack type comes from the monster's own entry, or the spell for casts. Shapes that do not fit stay as plain descriptions and are listed in the test: any-combination plus replacement, and three one-off phrasings. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
In a Choice, an action option's count is the most times it can be picked, so "three attacks, Claw or Tail in any combination" is choose 3 with each option at count 3. Replacements join the choice with count 1 (or the number of attacks they replace), which structures the remaining any-combo plus replacement entries, oni, dryad and guardian naga. Description text is unchanged. Also split Hand Crossbow (... Form Only) out of the wererat's Scratch, where the gist had merged them. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Mirror the 2014 data: werebear, wereboar, wererat, weretiger and werewolf become human, hybrid and animal forms; vampire becomes vampire, bat and mist. Each form links the others through forms and reuses the 2014 index, name and image. Entries tagged "Form Only" go only to their forms and lose the tag. Multiattack options for actions a form lacks are dropped. Sizes come from Shape-Shift; speeds come from the Speed line in the text (the gist had the animal-form value) or from Shape-Shift for the vampire's bat and mist. Also merge fake entries the gist made from the tail of a Failure: or Success: line, such as the lycanthropes' curse and steam mephit. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The 2024 SRD has no text after the AC value, so armor_class.type does not exist in the source. Make it optional in the schema and stop emitting the natural/armor guess. Link armor and shields named in a monster's Gear line to their 2024 equipment entries through armor_class.armor. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…leed
The gist splits "Medium or Small Humanoid" at the wrong point for 47
monsters, leaving size as just "Medium" and type as "or small humanoid".
Repair both from the gist's own fields before the form split, so lycanthrope
and vampire forms that need a single size still get one.
13 monsters have a languages string truncated mid-sentence in the gist
(dretch, kraken, and others); read it from the stat block text instead,
where the header-wrapping normalizer already joins it into one line.
The tarrasque's World-Shaking Movement description was already cut short in
the gist ("...next turn. Toughs", a page-break artifact), which failed the
completeness check and triggered completeFromText's repair pass. That pass
had no way to recognize "Toughs" as a title, since it has no AC line of its
own, so it kept accumulating text straight through the next stat block's
ability-score table, gear, senses, languages and CR line. Stop the repair
at the ability-score table header, which every stat block has, regardless
of whether its title was recognized, and recognize a title followed
directly by that header (no AC/HP/Speed of its own) as a title too.
Found by an independent audit subagent; see the four findings it confirmed.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The gist leaves an entry's usage as unparsed text in its name, e.g. "Legendary Resistance (3/Day, or 4/Day in Lair)" or "Acid Breath (Recharge 5-6)", and the schema's usage field (present on the 3 hand-authored reference monsters) was left empty for all 341 monsters. Parse per day, per day in lair (special abilities only), recharge on roll, and recharge after a rest, matching the existing 2014/reference shapes exactly. A trailing note that isn't itself a usage (night hag's "Requires Soul Bag") is kept in the name; a suffix that isn't a usage at all (a spell's "(level N version)", "(Requires Magic Rope)", the mimic's leftover form tag) is left untouched. Add rest_types to ActionUsageSchema and usage to Reaction/LegendaryAction, since the data has these on reactions and bonus actions, not just special abilities and actions. Found by an independent audit subagent (finding #2). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2014 monsters have no separate skills field: a skill is just another proficiencies entry, alongside saving throws. Convert the "History +12, Perception +10" string the same way instead of keeping it as a field no 2014 or reference 2024 monster carries. Drop skills from the schema. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
440 attack entries had no attack_bonus even though the schema supports it and the reference aboleth's Tentacle has one. The gist's own attack_bonus was a leftover spell-attack modifier on 5 dragons' Spellcasting action (already covered correctly by spellcasting.modifier), never a weapon attack roll bonus, so it is dropped in favor of parsing "Attack Roll: +N" from the description, same as damage and dc. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The gist's own "Immunities" extraction lands a conditions-only line (no damage type present, so no semicolon) whole in damage_immunities, leaving condition_immunities empty. Confirmed for 23 monsters (gray-ooze, ettin, cloaker, and 20 others). Read Resistances/Vulnerabilities/ Immunities from the stat block text instead, classifying an unsemicoloned Immunities line word-by-word against the known damage types and conditions. This also repairs 4 monsters (ghost, specter, will-o-wisp, wraith) whose damage_resistances was truncated with a trailing empty string, and rakshasa/half-dragon's single-phrase vulnerability/resistance. Also capture a condition's parenthetical note (e.g. archmage's "Charmed (with Mind Blank)") into APIReferenceSchema's existing optional `note` field instead of discarding it. Found by a second independent audit subagent, scoped to the final PR. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
bagelbits
force-pushed
the
claude/pr-data-validation-ad996c
branch
from
September 22, 2026 22:19
7b01b0f to
3da9335
Compare
…data-validation-ad996c # Conflicts: # src/2024/en/5e-SRD-Monsters-New.json # src/2024/en/processMonsterData.mjs
bagelbits
added a commit
that referenced
this pull request
Sep 22, 2026
## What does this do? Stacked on #1228, which is stacked on #1226. Retarget to `main` after #1226 and #1228 both merge. This is the final step: land the generated data and remove everything that generated it. - Replace `5e-SRD-Monsters.json` (previously 3 hand-authored monsters) with the full 341-monster generated output from #1228, including the second audit pass's damage/condition immunities fix. - Delete the generator script (`processMonsterData.mjs` and its `monster*.mjs` modules), its raw inputs (`monsters.json`, `monster-text-data.txt`), its normalized-text output, and its own test (`monsterGeneration.test.ts`). None of these are needed once the data they produce is committed. - Remove `tables.test.ts`'s bypass for the raw gist file, now that the file it skipped no longer exists. ## How was it tested? Full existing 2024 test suite (schema validation, duplicate indices, broken API references, translations) run against the final file with no bypass: 92 tests pass. ## Is there a Github issue this is resolving? NA ## Did you update the docs in the API? Please link an associated PR if applicable. No. A separate `5e-srd-api` PR is needed for the new/changed 2024 monster shape (armor_class.type now optional, skills folded into proficiencies, new usage/spellcasting/damage/bonus_actions fields, and so on); not filed yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: G.Ambatte <sean@robertson-family.nz> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
bagelbits
pushed a commit
that referenced
this pull request
Sep 22, 2026
🤖 I have created a release *beep* *boop* --- ## [5.12.0](v5.11.1...v5.12.0) (2026-09-22) ### Features * **2024:** Add 2024 monsters ([#1229](#1229)) ([cb70dd4](cb70dd4)) * **2024:** finalize generated monster data ([#1231](#1231)) ([6f6299e](6f6299e)) * **2024:** validate and reshape generated monster data ([#1228](#1228)) ([8693259](8693259)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: 5e-bits-deploy-bot[bot] <209387221+5e-bits-deploy-bot[bot]@users.noreply.github.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

What does this do?
Stacked on #1226. Base branch
add2024Monsters-baseis copy of that PR head. Retarget tomainafter #1226 merge.Script output now match
MonsterSchema. New test check it. CI now run on PRs to any base branch, so stacked PRs get lint + tests.monster-text-data.normalized.txt.xp,xp_in_lair,armor_classarray, condition references, senses parsing, hit dice minus sign.damage(all types, one entry each) anddc(saving throw, escape, ability check) from descriptions for traits, actions, bonus actions, reactions, legendary actions.spellcasting. List entries (48): spell lists come from stat block text, gist stop at intro line; match list to entry by ability + save DC + to-hit since PDF put some blocks inside previous block text. Single-spell casts (Invisibility, Fear, Coven Magic, Divine Aid, and similar): link spell, inherit ability/DC from main Spellcasting when text say "same spellcasting ability", per-day usage from action name. Every spell resolve against5e-SRD-Spells.json; script throw on unknown spell or unused list.(level N version)set spell level, other parentheticals become capitalizednotes.damagetoReactionSchema. Add optionalspellcastingto reactions and legendary actions. Add optionalskills,gear,bonus_actionstoMonsterSchema. Omitskills/gearwhen source say None.monsterText.mjs(normalize, parse blocks, pair to monsters),monsterEntries.mjs(damage, dc, debris cleanup),monsterSpellcasting.mjs,monsterCommon.mjs. Output byte-identical before and after split.Multiattackentries:multiattack_type,actions,action_options. Same Choice shape as 2014 and existing 2024 monsters. Attacktypefrom the monster's own action (melee/ranged/special), or the spell'sattack_typefor casts. Description text unchanged.countis the most times that option can be picked. "Three attacks, Claw or Tail in any combination" =choose: 3, Clawcount: 3, Tailcount: 3. Replacements join the choice (count = attacks replaced). No existing data usecount> 1 insidechoose> 1, so this is new. Please check it fits API consumers.forms. Entries tagged "Form Only" go only to their forms (tag removed), untagged go to every form. Multiattack options pruned to actions the form has. Size from Shape-Shift. Speed from textSpeedline (gist had animal-form value, e.g. werewolf 40 ft. for every form) or from Shape-Shift for vampire bat and mist. Human and vampire form keep base size "Medium or Small".Failure:/Success:lines (lycanthrope curse, steam mephit Steam Breath).armor_class: notype(2024 SRD has no text after AC value, per review comment).typenow optional in schema. Armor and shields named inGearlink to 2024 equipment througharmor_class.armor(28 monsters). Half Plate Armor matches Half-Plate Armor.size/typesplit wrong for 47 monsters ("Medium or Small Humanoid" -> size "Medium", type "or small humanoid"). Split repaired from the gist's own two fields; form-split monsters (finding Add the rest of the races and subraces #1) still get a single size per form.languagestruncated mid-sentence for 13 monsters in the gist (dretch, kraken, and 11 others); now read from the stat block text instead.usage(finding Reviewed data -- Added consistency and fixed a few typos. #2, 0 -> 150 entries): parsed out of recharge/per-day name suffixes. "Legendary Resistance (3/Day, or 4/Day in Lair)" -> name "Legendary Resistance",usage: {type: "per day", times: 3, times_in_lair: 4}, matching the 3 reference monsters exactly. Covers per day, per day in lair (special abilities only), recharge on roll (dice always "1d6"), recharge after a rest. Non-usage suffixes ("level N version", "Requires Magic Rope", mimic's form tag) left alone; a trailing non-usage note (night hag "Requires Soul Bag") kept in the name. Addedrest_typestoActionUsageSchemaandusagetoReaction/LegendaryActionschemas, since the data has recharge/per-day on reactions and bonus actions too, not just special abilities and actions.skills/proficiencies(finding Add spells from Xanathar's Guide to Everything #5): decided in favor of matching 2014. Skills now encoded asproficienciesentries (skill-history,skill-perception, and so on, looked up from5e-SRD-Proficiencies.json), alongside saving throws, same as every 2014 monster.skillsstring field dropped from output and schema.attack_bonus: 440 attacks had none set, though schema support it and reference aboleth's Tentacle has one. Gist's ownattack_bonuswas a leftover spell-attack modifier on 5 dragons' Spellcasting action (already correct inspellcasting.modifier), never a weapon attack bonus; dropped, and parsed properly from "Attack Roll: +N" in the description, same as damage and dc. Found while comparing generated output against the reference monsters ahead of a final cleanup PR.damage_immunities/condition_immunities: the gist's own "Immunities" extraction lands a conditions-only line (no damage type, so no semicolon in the source) whole indamage_immunities, leavingcondition_immunitiesempty. Confirmed for 23 monsters (gray-ooze, ettin, cloaker, and 20 others). Fixed by readingResistances/Vulnerabilities/Immunitiesfrom the stat block text, classifying an unsemicoloned Immunities line word-by-word against the known damage types and conditions.damage_resistancestruncated (trailing empty string) for 4 undead (ghost, specter, will-o-wisp, wraith); rakshasa/half-dragon's single-phrase vulnerability/resistance also truncated. Same fix.APIReferenceSchema's existing optionalnotefield.5e-SRD-Monsters-New.json.How was it tested?
New
src/2024/tests/monsterGeneration.test.ts. Run script into temp dir, no overwrite of real files. Check: count + unique index, schema, hit dice format, passive perception, sense format, XP, PB vs CR, skill bonus = mod + PB or 2 x PB, every save DC and damage roll in description present in output, every spell cast has valid spell URL, no spell list entries or unterminated descriptions. Every Multiattack must be structured and simple counts must round trip. Forms split, linked and pruned; werewolf human/wolf entries and speeds checked. Armor links checked against equipment. Full suite 113 pass (7 new tests total for both audit passes).Known gaps
spell save DCnot put indc. It live inspellcasting.dc.desc, not structured.components_requiredcomputed from text: "no Material components" give["V","S"].5e-SRD-Monsters.json) has extraacid-arrowandmodifier: 5. Book text has neither. Output follow book text.charmed.Adhesive (Object Form Only)keeps tag. Not split in 2014.5-footwide.(... Form Only)headings (wererat Hand Crossbow).Is there a Github issue this is resolving?
NA
Did you update the docs in the API? Please link an associated PR if applicable.
No
🤖 Generated with Claude Code