Skip to content

feat(templates): infer transactional flag from apply payload metadata#860

Merged
dieppa merged 2 commits intomasterfrom
feature/template_transaction_inference
Mar 10, 2026
Merged

feat(templates): infer transactional flag from apply payload metadata#860
dieppa merged 2 commits intomasterfrom
feature/template_transaction_inference

Conversation

@dieppa
Copy link
Member

@dieppa dieppa commented Mar 9, 2026

When the user omits transactional in YAML, the builder now inspects
apply payloads' TemplatePayloadInfo.getSupportsTransactions() to
determine the correct value, instead of always defaulting to true.

  • If any apply payload claims supportsTransactions=false → infer false
  • Otherwise → infer true (all claim true, unclaimed, mix, or null/empty)
  • Explicit YAML values (transactional: true/false) always take precedence

Changes:

  • TemplateLoadedTaskBuilder: add inferTransactionalFromPayloads(),
    resolveTransactional(), and resolveTransactionalFromSteps() methods
    replacing the hardcoded null → true fallback
  • SimpleTemplateLoadedTaskBuilderTest: add NonTxPayload, TxPayload,
    NonTxTemplate, TxTemplate test infrastructure and 6 inference tests
  • SteppableTemplateLoadedTaskBuilderTest: add equivalent test
    infrastructure with steppable templates and 7 inference tests

@dieppa dieppa force-pushed the feature/template_transaction_inference branch from 00b94bc to 8d57015 Compare March 9, 2026 11:51
When the user omits `transactional` in YAML, the builder now inspects
apply payloads' `TemplatePayloadInfo.getSupportsTransactions()` to
determine the correct value, instead of always defaulting to `true`.

- If **any** apply payload claims `supportsTransactions=false` → infer `false`
- Otherwise → infer `true` (all claim true, unclaimed, mix, or null/empty)
- Explicit YAML values (`transactional: true/false`) always take precedence

Additionally, preserves the original `transactionalFlag` (raw user input)
separately from the resolved `transactional` boolean throughout the
loaded/executable layer:

- `getTransactionalFlag()` → `Optional<Boolean>` — original raw flag from
  YAML/annotation, preserved unchanged in `AbstractTaskDescriptor`
- `isTransactional()` → `boolean` — resolved truth, stored in a dedicated
  field in `AbstractLoadedTask`

**Changes:**

- **AbstractLoadedTask**: add `private final boolean transactional` field;
  constructor now accepts both `Boolean transactionalFlag` and
  `boolean transactional`, passing the original flag to `super()` and
  storing the resolved value separately
- **Constructor chain** (AbstractReflectionLoadedTask, AbstractLoadedChange,
  CodeLoadedChange, AbstractTemplateLoadedChange, SimpleTemplateLoadedChange,
  MultiStepTemplateLoadedChange): thread both parameters through
- **CodeLoadedTaskBuilder / TemplateLoadedTaskBuilder**: pass both
  `transactionalFlag` (original) and `resolvedTransactional` (computed)
  to loaded change constructors
- **TemplateLoadedTaskBuilder**: add `inferTransactionalFromPayloads()`,
  `resolveTransactional()`, and `resolveTransactionalFromSteps()` methods
  replacing the hardcoded `null → true` fallback
- **SimpleTemplateLoadedTaskBuilderTest**: add `NonTxPayload`, `TxPayload`,
  `NonTxTemplate`, `TxTemplate` test infrastructure and 6 inference tests
- **SteppableTemplateLoadedTaskBuilderTest**: add equivalent test
  infrastructure with steppable templates and 7 inference tests
@dieppa dieppa force-pushed the feature/template_transaction_inference branch from 8d57015 to 8bc767b Compare March 10, 2026 04:11
@dieppa dieppa merged commit 7cfd423 into master Mar 10, 2026
4 checks passed
@dieppa dieppa deleted the feature/template_transaction_inference branch March 10, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant