schemas: add tags_schema.json and wire tags into the schema test#1194
Open
VasilisDragon wants to merge 1 commit into
Open
schemas: add tags_schema.json and wire tags into the schema test#1194VasilisDragon wants to merge 1 commit into
VasilisDragon wants to merge 1 commit into
Conversation
rom1504 asked for a schema for the tags file on PrismarineJS#1080; this adds it, derived from that PR's generated data (head 4edb806) rather than written ahead of it, per the review direction on PrismarineJS#464. Shape: registry kind -> namespaced tag -> flattened member list. block/item required; fluid, entity_type, and future registries accepted with the same shape, with registry keys constrained to ^[a-z_/]+$ so path-shaped kinds (game_event, worldgen/biome) stay valid while malformed keys fail. Tag keys and members must match the ResourceLocation grammar (0 of 414 tags / 5421 members violate it), members must not be unflattened #tag references (0 in the data; a regression becomes a CI failure), uniqueItems on members (0 duplicates), and empty member lists stay valid because vanilla ships empty tags (incorrect_for_diamond_tool, incorrect_for_netherite_tool on 1.21.8). All 5417 block/item/entity_type members cross-resolve against the same head's blocks/items/entities files. Registering tags in test.js is inert while no tags.json exists (existsSync guard): full tools/js suite is 1762 passing / 1 pending both before and after this change. With PrismarineJS#1080's files applied locally, pc 1.21.8 tags.json validates (1763 passing) and audit dataPaths stays green.
This was referenced Jun 12, 2026
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
#1080 has been waiting on one review ask (@rom1504: "We would need a schema for the tags file"). This adds that schema and registers
tagsintools/js/test/test.jsso the file is validated by CI wherever atags.jsonexists. No data files change here: with notags.jsonin the tree yet, the new test entry is inert (fs.existsSyncguard), so this merges independently of #1080 and starts guarding it the moment it lands.The schema is derived from the generated data rather than written ahead of it — every constraint below was checked against
data/pc/1.21.8/tags.jsonat #1080's head (4edb806). That ordering follows the review note on #464 ("generate the data … you will need to adapt the schema once you have the data"); #1080 now provides the data half, this is the schema half.Shape
Registry kind → namespaced tag → flattened member list. Modeled on
blockMappings_schema.json(draft-07,$defs,additionalProperties: false).blockanditemare required;fluid,entity_type, and any future registry the generator emits are accepted with the same tag-map shape, so a new registry kind is not a schema-breaking change. Registry keys themselves must match^[a-z_/]+$— this admits path-shaped kinds the game actually has tags for (game_event,worldgen/biome,worldgen/structure) while rejecting malformed keys.ResourceLocationgrammar (^[a-z0-9_.-]+:[a-z0-9_./-]+$). 0 of 414 tags / 5,421 members in the Add Minecraft pc 1.21.8 tags #1080 data violate it. The pattern is not pinned tominecraft:so datapack/mod namespaces remain representable.#tagreferences — the generator flattens nested tags (0#members in the real data), and consumers should never see one. An unflattened emission becomes a CI failure instead of a silent regression downstream.uniqueItemson member lists (0 duplicates in the real data; catches double-emits).minecraft:incorrect_for_diamond_toolandminecraft:incorrect_for_netherite_toolare empty. A min-1 constraint (as drafted in Tag schemas #464) would reject the real file.Verification
tags.jsonvalidates with the repo's Ajv setup (new Ajv({ verbose: true }), same astest.js).game_event,worldgen/biome), modded namespaces, and empty-array cases pass; root-as-array, missing registry, non-array tag value, non-string member, malformed tag key,#tagmember, duplicate members, malformed/miscased registry keys, null/array registry values, and empty-string members are all rejected.block/item/entity_typemembers in the Add Minecraft pc 1.21.8 tags #1080 file exist in the same head'sblocks.json/items.json/entities.json— 0 dangling references. (fluid's 4 members have no data file to check against.)tools/jssuite: 1762 passing / 1 pending before and after this change — no behavior change while notags.jsonexists.tags.json+dataPathsentry applied locally, the suite goes to 1763 passing / 1 pending — the +1 ispc 1.21.8: tags.json is valid— andaudit dataPathsstays green both directions. Corrupting one member to#minecraft:planksflips exactly that one test red (should match pattern "^[a-z0-9_.-]+:[a-z0-9_./-]+$").json-schema-to-typescript(which node-minecraft-data generates its typings from, walkingschemas/) compiles this schema to a usableTagsinterface.On the second question in #1080 ("are we adding it only for 1.21.8?"): the schema is version-agnostic — coverage can grow as PrismarineJS/minecraft-data-generator#56 stabilizes on older versions (extremeheat noted pre-1.20.5 versions lack Mojang mappings there). Versions without a
tags.jsonare not validated against it.I left README's "Data provided" row and the
doc/add-data-new-version.mdentry for when the data itself lands (#1080 / the generator work) rather than advertise tags the repo doesn't provide yet.Context: #463 (2021) proposed a tags schema and #464 closed waiting on generated data to derive one from. With #1080 staged, this is the remaining half of that sequence, and the data-side prerequisite for exposing
mcData.tagsin node-minecraft-data (#412 discussion).