一键导入
new-export-version
Create a new game export schema version, migration module, and related tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create a new game export schema version, migration module, and related tests.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Debug a failing golden test from GitHub Actions logs and fix the root cause without papering over nondeterminism.
Investigate a game from raw logs, trace bugs to source code, and file detailed issues. Use for deeper debugging than export-only analysis.
Repo-specific validation and PR instructions for mage-bench.
Find Magic cards for compact golden-test scenarios using existing repo goldens, curated references, and Scryfall search recipes.
Analyze exported game files to assess gameplay, model decisions, and likely bugs without raw logs. Use for quick game triage.
Write or update low-noise golden prompt tests in tests/, including minimal decks, replay scripts, and golden regeneration.
| name | new-export-version |
| description | Create a new game export schema version, migration module, and related tests. |
Cut a new game export format version. This creates a standalone schema, migration module, and updates all references.
Each export version has its own schema file (src/magebench/game/game-export-vN.schema.json). In this repo, export migrations live in the single module src/magebench/game/game_export_migrations.py, and raw export file I/O lives in src/magebench/game/game_exports.py.
Key files:
src/magebench/game/game-export-v*.schema.json — per-version JSON Schemassrc/magebench/game/game_export_migrations.py — current/legacy version constants and normalization helperssrc/magebench/game/game_exports.py — raw export load/write helpers used by scripts and testssrc/magebench/game/export_game.py — export producer (sets version, computes new fields)tests/test_game_export_migrations.py — roundtrip migration teststests/test_export_schema.py — schema validation testsAsk the user what fields are being added, removed, or modified. Determine:
"version" line in src/magebench/game/export_game.py)up() migration needs external data or is purely derived from existing fieldsdown() migration is lossless (can we reconstruct N from N+1?)Before deciding on a version bump for a semantics-only fix, check whether the
latest typed loaders (load_game_export, load_built_game_export) are used
directly against committed exports in tests or scripts. If they only accept the
newest version, a code-only version bump can break local consumers until the
repo's game exports are migrated too. In that case, consider whether an
in-place backfill on the existing version is the safer path.
Copy src/magebench/game/game-export-vN.schema.json to src/magebench/game/game-export-v{N+1}.schema.json:
"const": N to "const": N+1 in the version property$id, title, description to reference v{N+1}properties$defs if neededAdd vN <-> v{N+1} support to src/magebench/game/game_export_migrations.py:
"""Migration: vN -> v{N+1} (description of what changes)."""
SOURCE_VERSION = N
TARGET_VERSION = N + 1
def up(data: dict) -> dict:
"""Migrate from vN to v{N+1}."""
assert data["version"] == N, f"Expected vN, got v{data['version']}"
# Add new fields here
data["version"] = N + 1
return data
def down(data: dict) -> dict:
"""Migrate from v{N+1} to vN."""
assert data["version"] == N + 1, f"Expected v{N+1}, got v{data['version']}"
# Remove new fields here
data["version"] = N
return data
The migration must satisfy: down(up(game)) == game for all exported games.
src/magebench/game/export_game.py"version": N to "version": N+1 in build_export()build_export()_validate_export(): change version == N to version == N+1These files reference the schema filename and need updating:
Makefile (regen-schema-types and verify-schema-types targets) → game-export-v{N+1}.schema.json.claude/hooks/enforce-agents-rules.py — no change needed (uses glob pattern)doc/export-schema.md — update prose reference if it mentions a specific versionmake regen-schema-types
Verify the generated types look correct in website/src/types/game-export.d.ts.
In tests/test_export_schema.py, add:
test_v{N+1}_schema_is_valid — validates the new schema structuretest_v{N+1}_schema_accepts_v{N+1} — minimal valid export passestest_v{N+1}_schema_rejects_vN — old version is rejectedIn tests/test_game_export_migrations.py, add migration tests:
test_vN_to_v{N+1}_up_adds_fields — verify up() adds the right fieldstest_v{N+1}_to_vN_down_removes_fields — verify down() strips themtest_round_trip_preserves_vN_structure — down(up(game)) == gameWhen raw-export helpers are intentionally schema-light (for example load_raw_game_export() tests), make the migration functions tolerant of partial payloads. Only assert on version and transform optional sections when they are present.
make check
All lint, typecheck, and tests must pass before proceeding.
Default to a code-only PR. Game migrations touch hundreds of JSON files and GitHub cannot render large diffs. If the issue explicitly asks for a bounded in-repo migration (for example one season only), migrate only that slice and file a follow-up issue for the remaining historical exports.
This repo does not currently have a generic export migration runner. For bounded migrations, use src/magebench/game/game_exports.py helpers (load_raw_game_export() / write_raw_game_export()) or add a one-off script in the PR. Verify the migrated files with make check.