summaryrefslogtreecommitdiff
path: root/rt/docs/design_docs/ruleset-workflow.txt
blob: f19dbd765fd212ea9d1138aee05fd2ffd3b7e0c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# For an online version, see http://wiki.bestpractical.com/?RulesetWorkflow

_*This is a design document for a work in progress.
It describes features that do not exist today and may never exist*_

== Text Description

* The user of PurchaseOrder queue fill in a numeric "CF", called "Price".
* On creation, it needs to create following approvals:
** "ManagerApproval" if CF.Price is > 1000
** "PresidentApproval" if CF.Price is > 2000
* When all of "M", "P" are resolved (or if there were none to begin with), Create "FinanceApproval".
* If any approvals above is rejected, reject the original ticket.
* If "FinanceApproval" is resolved, resolve original ticket.
* If "FinanceApproval" is rejected, create an approval for "CEOApproval".
* If "CEOApproval" is resolved, resolve the original ticket.
* If "CEOApproval" is rejected, reject the original ticket.

== ASCII Diagram

       ,----------.      ,---------------------->[DONE]
       |           \    /                           ^
 [TOP]-+-?---->[M]---->[F]                          |
       |        |  /    \                           |
       `-?->[P]-+-'      `-(!)->[C]-----------------'
             |  |                |
             |  |                `-(!)---------->[FAIL]
             |  |                                   ^
             `-(!)----------------------------------'

== Objects

Note that "Scrips" are now called "Rules".

=== RuleAction "AquireMyLocks"

  FOREACH $Scrip IN $TicketObj->Scrips
    WHERE $Scrip.Action.Type == "TryCreateTicketWithRuleset"
       DO LockRuleset $Scrip.Action.Argument

=== RuleAction "TryCreateTicketWithRuleset"

  DO ReleaseMyLockOnRuleset $Argument
  UNLESS RulesetLocked $Argument
      DO CreateTicketWithRuleset $Argument

=== RuleAction "CreateTicketWithRuleset"

  GIVEN $Ticket AS CreateTicket(@OtherArguments)
     DO SetTicketRuleSet $Argument
     DO RunTicketRuleSet $Argument
  
=== GlobalRule "AquireLocks"

* AppliesTo: All Objects
* Condition: OnCreate
* Action: AquireMyLocks

=== Queue "PurchaseOrder"

* Rule:
** Condition: OnCreate
** Action: SetTicketRuleSet "PurchaseFlow"
** Action: RunTicketRuleSet "PurchaseFlow"

=== RuleSet "PurchaseFlow"

* Rule (implicitly run by AcquireMyLocks):
** Condition: OnCreate
** Action: LockRuleSet "ManagerApproval"
** Action: LockRuleSet "PresidentApproval"
** Action: LockRuleSet "FinanceApproval"

* Rule:
** Condition: OnCreate 
** Condition: CF.Price > 1000
** Action: TryCreateTicketWithRuleset "ManagerApproval"

* Rule:
** Condition: OnCreate 
** Condition: CF.Price > 2000
** Action: TryCreateTicketWithRuleset "PresidentApproval"

* Rule:
** Condition: OnCreate 
** Condition: "Finance" is not blocked
** Action: TryCreateTicketWithRuleset "FinanceApproval"

* Rule:
** Condition: OnReject
** Action: DeleteTree

=== RuleSet: "ManagerApproval"

* Rule (implicitly run by AcquireMyLocks):
** Condition: OnCreate
** Action: LockRuleSet "FinanceApproval"

* Rule:
** Condition: OnResolve
** Action: TryCreateTicketWithRuleset "FinanceApproval"

* Rule:
** Condition: OnReject
** Action: RejectTicket "PurchaseFlow"

=== RuleSet: "PresidentApproval"

* Rule (implicitly run by AcquireMyLocks):
** Condition: OnCreate
** Action: LockRuleSet "FinanceApproval"

* Rule:
** Condition: OnResolve
** Action: TryCreateTicketWithRuleset "FinanceApproval"

* Rule:
** Condition: OnReject
** Action: RejectTicket "PurchaseFlow"

=== RuleSet: "FinanceApproval"

* Rule:
** Condition: OnResolve
** Action: ResolveTicket "PurchaseFlow"

* Rule:
** Condition: OnReject
** Action: ForceCreateTicketWithRuleset "CEOApproval"

=== RuleSet: "CEOApproval"

* Rule:
** Condition: OnResolve
** Action: ResolveTicket "PurchaseFlow"

* Rule:
** Condition: OnReject
** Action: RejectTicket "PurchaseFlow"

### FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD FNORD ###

== Another Text Description

* I have a MonitoredQueue that sets tickets to "Monitored" if its subject matches /monitored/.
* I want to have a kind of Ticket that are 'Monitored'.
* I want all monitored tickets, when they are overdue for 14 days, to:
** Send notification to manager
** Mark as stalled
* I want all monitored tickets, when they are overdue for 28 days, to:
** Mark as rejected
* I want to query all tickets that are monitored as such
* I want to modify 14 => 15 and have it affect all existing tickets that are monitored
* I want to add a new "overdue for 27 days, add a 'ultimatum' correspondence to it" rule
** For all monitored tickets.
* I want to add a new "overdue for 27 days, add a 'ultimatum' correspondence to it" rule
** For all _new_ monitored tickets.
** Without affecting existing ones.