1"""Reference interceptor extension for little-loops.

2

3 Demonstrates passthrough ``before_route()`` and ``before_issue_close()``

4 behavior. Copy this class, rename it, and replace the return values with

5 real veto or routing logic.

6"""

7

8 from __future__ import annotations

9

10 from little_loops import RouteContext, RouteDecision

11 from little_loops.issue_parser import IssueInfo

12

13

14 class ReferenceInterceptorExtension:

15 """Reference implementation demonstrating passthrough interceptor behavior.

16

17 ``before_route()`` and ``before_issue_close()`` both return ``None``,

18 which means "pass through without modifying the decision."

19

20 To build a real interceptor:

21 1. Copy this class and rename it.

22 2. Implement ``before_route`` to redirect or veto FSM routing by returning

23 a ``RouteDecision`` instance (``RouteDecision(None)`` vetoes the

24 transition; ``RouteDecision("state_name")`` redirects to that state).

25 3. Implement ``before_issue_close`` to veto an issue close by returning

26 ``False``; return ``None`` to allow the close to proceed.

27 4. Register your class in ``ll-config.json`` under the ``extensions`` key

28 as ``"your_package.module:YourClassName"``.

29 """

30

31 def before_route(self, context: RouteContext) -> RouteDecision | None:

32 """Return None to pass through without modifying routing.

33

34 Return a ``RouteDecision`` to redirect or veto the FSM transition:

35 - ``RouteDecision("state_name")`` — redirect to a different state

36 - ``RouteDecision(None)`` — veto the transition (no state change)

37 """

38 return None

39

40 def before_issue_close(self, info: IssueInfo) -> bool | None:

41 """Return None to pass through; return False to veto the close.

42

43 Args:

44 info: Parsed issue information for the issue being closed.

45

46 Returns:

47 ``None`` to allow the close to proceed, ``False`` to veto it.

48 """

49 return None