[Game Systems] Carry the stats envelope through campaign export/import #214
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Motivation/Context
v3.9.0 follow-up (flagged in #139 / #145). #139 added the validated
statsJSONB envelope ({system, schema_version, values, visibility}) onlore_entries, but the campaign export bundle builders (routers/campaigns.py, the lore-entry export dict ~:3651) andimport_serviceconstruct lore dicts from an explicit key list that does not includestats. Result: exporting a campaign and re-importing it silently drops every entry's stat block — imported entries come back withstats = NULL. That's data loss on a round-trip, and undercuts the conversion wizard (#145) work a GM just did.Approach
Export — add
statsto the lore-entry export dict alongsidesidebar_fields/timeline_events.Import — restore
statsinimport_servicewhen creating lore entries. The envelope self-describes itssystem+schema_version(it stores the system key, not a UUID), so store it verbatim — do NOT re-validate against the importing campaign's linked system. If the destination campaign links a different system (or none), the stored envelope simply renders read-only/"dormant" per #140's edge-state handling, and the GM can delete or re-link — exactly the designed unlink/relink behaviour. This keeps import non-destructive and preserves the GM's work.Bundle version —
statsis an additive optional key. Check howimport_servicevalidates the export schema version (there are existingtest_import_rejects_invalid_schema_versiontests): if importers ignore unknown keys and tolerate a missingstats, no version bump is needed; bump only if the version gate is strict. Older bundles (nostatskey) must import fine withstats = None.Out of scope
statsversion-mismatch/"update to v{n}" flow (that's #140, already shipped).Acceptance criteria
stats, then importing that bundle, yields entries whosestatsenvelope matches the original (system/schema_version/values/visibility preserved).statskey succeeds, leavingstats = None.Picking this up as part of the v3.9.1 patch (with #213), on
fix/v3.9.1-game-aware-followups→ PR tomain. Addsstatsto the lore-entry export dict and restores it verbatim on import (self-describing envelope → dormant-state UI handles a system mismatch, no re-validation), with old-bundle (nostats) tolerance.