Files
Library/tests
faumarayandClaude Fable 5 d9842129c7 FSM v2 (C): retry/error policies, transition interceptors, introspection
Error policies (State helpers; no engine change beyond timer-driven delay):
- delay(duration) suspends a state via a timer then resumes.
- with_retry(times, backoff, attempt) retries an async sub-step
  (Coro::Task<bool>) with backoff between tries, returning whether it
  eventually succeeded.
- next_or<Fallback>(step) routes a failing Step to a fallback state
  instead of failing the whole machine.

Interceptors / middleware:
- Machine::add_interceptor({before(Transition), after(state_name)}) runs
  ordered hooks around each transition (before = state entered, after =
  state finished running) for logging/metrics/validation. observe() stays
  the single read-only observer.

Introspection / diagram:
- Reactive transition entries now carry event/target names; describe()
  enumerates registered states (name, reactive?, initial?) plus the
  transitions declared by reactive states (event, target, guarded);
  imperative run()-chosen edges aren't statically knowable so those states
  appear as edgeless nodes. to_mermaid() renders a stateDiagram-v2 string.

12 new tests (Policies): with_retry success/exhaustion->fallback,
interceptor before/after ordering + registration order, describe() lists
states + reactive edges, to_mermaid() edge rendering. 979 green,
ASan+UBSan clean, stable across 10 runs, -Werror clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-14 15:06:17 +03:00
..