@@ -368,8 +368,8 @@ class CancelationMethodTerminate(OpenJDModel_v2023_09):
368368
369369
370370class CancelationMethodDeferred (OpenJDModel_v2023_09 ):
371- """A cancelation whose ``mode`` is a whole-field format string, resolved
372- at run time (Template Schemas 5.3, FEATURE_BUNDLE_1 extension).
371+ """A cancelation whose ``mode`` is a format string, resolved at run
372+ time (Template Schemas 5.3, FEATURE_BUNDLE_1 extension).
373373
374374 What is the problem this solves?
375375
@@ -390,35 +390,38 @@ class CancelationMethodDeferred(OpenJDModel_v2023_09):
390390 wrap hooks impossible (pydantic's discriminated union rejected the
391391 template with "does not match any of the expected tags").
392392
393- The fix is this class: the parser accepts a whole-field ``{{...}} ``
394- expression in ``mode`` as a third, "decided later" state (gated on the
395- FEATURE_BUNDLE_1 extension), and the shape decision moves to resolution
396- time, right before the action runs:
393+ The fix is this class: the parser accepts a format string in ``mode ``
394+ as a third, "decided later" state (gated on the FEATURE_BUNDLE_1
395+ extension), and the shape decision moves to resolution time, right
396+ before the action runs:
397397
398398 1. The runtime seeds ``WrappedAction.Cancelation.Mode`` from the
399399 wrapped action (``"TERMINATE"``, ``"NOTIFY_THEN_TERMINATE"``, or
400400 ``None``).
401401 2. It resolves the ``mode:`` expression against that.
402402 3. ``"TERMINATE"``/``"NOTIFY_THEN_TERMINATE"`` — the cancelation block
403403 now acts as that method, and its sibling fields are validated
404- against that shape. ``None`` (null) — the whole ``cancelation:``
405- block is treated as never written. Anything else — the action fails.
404+ against that shape. ``None`` (null, whole-field expressions only) —
405+ the whole ``cancelation:`` block is treated as never written.
406+ Anything else — the action fails.
406407
407408 Static validation is *not* deferred: at parse time the validator still
408- checks the expression is well-formed, that ``WrappedAction.*`` is only
409- referenced inside wrap hooks, and that the value is a single
410- whole-field expression. You just can't know *which* of the two modes
411- it'll be until the wrapped action is in front of you — which is
412- inherent to forwarding: the same wrap environment gets reused across
413- many steps whose cancelation settings differ.
409+ checks the expression is well-formed and that ``WrappedAction.*`` is
410+ only referenced inside wrap hooks. Any format string is accepted —
411+ normal interpolation like ``"{{Prefix}}_THEN_TERMINATE"`` is permitted;
412+ only the resolved value is constrained. You just can't know *which* of
413+ the two modes it'll be until the wrapped action is in front of you —
414+ which is inherent to forwarding: the same wrap environment gets reused
415+ across many steps whose cancelation settings differ.
414416
415417 Mirrors ``CancelationMode::DeferredMode`` in openjd-rs. See
416418 openjd-specifications Template Schemas 5.3 and RFC 0008 "Cancelation
417419 behavior".
418420
419421 Attributes:
420- mode (FormatString): A single whole-field interpolation expression
421- resolving to "TERMINATE", "NOTIFY_THEN_TERMINATE", or null.
422+ mode (FormatString): A format string resolving to "TERMINATE" or
423+ "NOTIFY_THEN_TERMINATE"; a whole-field interpolation expression
424+ may also resolve to null.
422425 notifyPeriodInSeconds (Optional[Union[int, FormatString]]): As on
423426 CancelationMethodNotifyThenTerminate; only meaningful when the
424427 mode resolves to NOTIFY_THEN_TERMINATE, and must resolve to
@@ -439,24 +442,11 @@ def _validate_mode(cls, v: Any, info: ValidationInfo) -> Any:
439442 raise ValueError (
440443 "a format string in cancelation mode requires the FEATURE_BUNDLE_1 extension."
441444 )
442- raw = v .strip ()
443- # The mode is the schema selector, so partial interpolation
444- # like "TERMIN{{X}}" has no meaningful semantics: require a
445- # literal or a single whole-field expression. Exactly one "{{"
446- # AND exactly one "}}", anchored at both ends — counting only
447- # "{{" would accept partial interpolations like "{{X}}Y}}"
448- # (one open, two closes), which can never resolve to a valid
449- # mode.
450- if not (
451- raw .startswith ("{{" )
452- and raw .endswith ("}}" )
453- and raw .count ("{{" ) == 1
454- and raw .count ("}}" ) == 1
455- ):
456- raise ValueError (
457- "cancelation mode must be a literal or a single "
458- 'whole-field "{{ ... }}" expression.'
459- )
445+ # Any format string is permitted (normal format string
446+ # behavior, Template Schemas 5.3); the resolved value is
447+ # checked against the two mode names at run time. Only a
448+ # whole-field expression additionally gets string? null
449+ # semantics (a null result drops the cancelation object).
460450 return v
461451
462452 @field_validator ("notifyPeriodInSeconds" , mode = "before" )
@@ -583,7 +573,7 @@ class Action(OpenJDModel_v2023_09):
583573 cancelation (Optional[CancelationMethod]): If defined, provides details
584574 regarding how this action should be canceled. One of
585575 CancelationMethodNotifyThenTerminate, CancelationMethodTerminate, or
586- CancelationMethodDeferred (a whole-field format-string mode resolved
576+ CancelationMethodDeferred (a format-string mode resolved
587577 at run time; FEATURE_BUNDLE_1).
588578 Default: CancelationMethodTerminate
589579 """
0 commit comments