policy property

  1. @override
PulseEphemeralPolicy? get policy
override

The lifecycle governance policy for this pulse.

When to use

  • Use this when you need a pulse to self‑destruct — to prevent stale signals from propagating forever, or to limit the number of hops.
  • Preventing stale signals from propagating.
  • Limiting propagation depth (hop limit).
  • Time‑sensitive operations that must expire.
  • Circuit breaker patterns.
  • Automatic cleanup of transient signals.

How it works

The policy enforces a TTL (time‑to‑live) and/or hop limit. The pulse is neutralised if it exceeds either limit. The framework checks this automatically during propagation.

Non‑obvious: the policy is attached to the root

If you evolve a pulse, the policy travels with it — it's inherited through the parent chain, not duplicated.

Example

final pulse = Pulse.governed<int>(
  payload: 42,
  policy: PulseEphemeralPolicy(
    hopLimit: 3,
    duration: Duration(seconds: 5),
    onEvent: (cell, {required policy}) => (hops: policy.hops + 1),
    onInvalidate: (pulse) => print('Pulse expired'),
  ),
);

Implementation

@override
PulseEphemeralPolicy? get policy {
  return get<PulseEphemeralPolicy?>(() => _record.root.primary.policy,
      fallback: () => _parent?.policy, orElse: null);
}