Skip to content

CFE-4681: Add timer_policy to classes: promise type#6160

Closed
nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:CFE-4681/timer-policy-classes-promises
Closed

CFE-4681: Add timer_policy to classes: promise type#6160
nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:CFE-4681/timer-policy-classes-promises

Conversation

@nickanderson
Copy link
Copy Markdown
Member

@nickanderson nickanderson commented Jun 4, 2026

Summary

  • Add timer_policy attribute support to classes: type promises
  • Previously, timer_policy was only available in classes bodies (outcome classes on other promise types)
  • VerifyClassPromise hardcoded CONTEXT_STATE_POLICY_RESET, so persistent classes defined via classes: promises always reset their timer with no way to use absolute/preserve behavior

Example

classes:
  "my_class"
    expression => "any",
    persistence => "60",
    timer_policy => "absolute";  # NEW — preserves the original expiry

Changes

File Change
libpromises/cf3.defs.h Add PersistentClassPolicy timer field to ContextConstraint struct
libpromises/mod_common.c Add timer_policy option to CF_CLASSBODY syntax array
libpromises/attributes.c Parse timer_policy in GetContextConstraints(), add to expression-loop skip list
libpromises/verify_classes.c Replace hardcoded CONTEXT_STATE_POLICY_RESET with a.context.timer

Default behavior is unchanged — when timer_policy is absent, it defaults to reset.

Ticket

CFE-4681

The timer_policy attribute (absolute vs reset) was available in classes
bodies (outcome classes on other promise types) but missing from
classes: type promises.  As a result, VerifyClassPromise hardcoded
CONTEXT_STATE_POLICY_RESET and persistent classes defined via classes:
promises always reset their timer with no way to opt into preserve
(absolute) behavior.

- Add timer_policy option to CF_CLASSBODY syntax (mod_common.c)
- Add PersistentClassPolicy timer field to ContextConstraint (cf3.defs.h)
- Parse timer_policy in GetContextConstraints (attributes.c)
- Pass parsed policy instead of hardcoded RESET (verify_classes.c)
- Add unit test for persistent class timer policy behavior
- Add acceptance test for timer_policy on classes: promises

Ticket: CFE-4681
Changelog: Title
@nickanderson nickanderson force-pushed the CFE-4681/timer-policy-classes-promises branch from 61fe2a7 to 855f3e2 Compare June 4, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant