v3.12.0: the card preset carries the card's CAT (USAT) release

The release selector lives in the preset rather than a global chip: presets
already travel with the card (ICCID auto-selection, export/import), and the
operations that will consume the release are preset-aware.

- presets.py: the optional `release` field (4-18; empty = unspecified) joins
  PRESET_FIELDS; a value outside 4-18 is refused on save/import; the store
  schema version is 5.
- catrelease.py: DEFAULT_RELEASE = 12 and preset_release() - the effective
  release is the preset's own value, else Rel-12 (the safe level for cards
  whose release is not known; an unset release never filters anything away).
  The PWA mirrors both (CAT_RELEASE_DEFAULT + presetRelease()), drift-guarded.
- Cards tab: the editor's header row gains a compact CAT release select
  (unspecified / pre-Rel-6 stored as 5 / Rel-6 ... Rel-18); the empty option
  names the Rel-12 default and the tooltip explains the guard; the field is
  collected, cleared and restored with the other form fields.
- Nothing filters yet: the Simulator's event parameters (stage 3) will use
  the effective release.
- docs/api.md + help EN/RU updated; sw cache simple-v368.
This commit is contained in:
2026-10-02 11:28:33 +03:00
parent 2bb1528ca9
commit 3660a7e173
13 changed files with 149 additions and 13 deletions
+24 -1
View File
@@ -16,7 +16,9 @@ histories do not pin down - never filter on it.
The PWA mirrors this table (``CAT_RELEASE`` in frontend/index.html); the drift
guard is tests/test_catrelease.py. Releases below 6 display as "pre-Rel-6"
(``release_label``).
(``release_label``). ``DEFAULT_RELEASE`` (Rel-12) is the release a card
preset's empty ``release`` resolves to (``preset_release``) - the safe level
for cards whose release is not known.
"""
# Keyed by: events - the event code (TS 102 223 8.25 / TS 31.111 7.5);
@@ -117,3 +119,24 @@ def release_label(rel):
def item_release(kind, key, default=None):
"""The introduction release of an item, or `default` when unknown."""
return CAT_RELEASE.get(kind, {}).get(key, default)
# The release a preset's empty `release` resolves to: Rel-12 is the safe level
# for cards whose release is not known (the CAT items the tool sends stay
# within what a modern card implements). Mirrored in the PWA
# (`CAT_RELEASE_DEFAULT`), drift-guarded by tests/test_catrelease.py.
DEFAULT_RELEASE = 12
def preset_release(preset):
"""The effective CAT release of a card preset.
The preset's own `release` when it names one (4-18), else the default.
Empty or invalid values resolve to the default - an unset release must
never filter anything away.
"""
try:
rel = int((preset or {}).get('release') or 0)
except (TypeError, ValueError):
rel = 0
return rel if 4 <= rel <= 18 else DEFAULT_RELEASE