# Computational Accountability in MAS Organizations with ADOPT
## 5 Case Study: Accountability in the JaCaMo Framework
### Building-a-House Revisited  
Let us, now, see how the AccountabilityBoard artifact supports the execution of the ADOPT protocol with the help of a revised version of our example. (The full code of the revised example is available here: [[http://di.unito.it/buildingahouse](http://di.unito.it/buildingahouse)]([http://di.unito.it/buildingahouse](http://di.unito.it/buildingahouse)).) In this case, before starting with the actual house construction, [PERSON] will create an instance of the AccountabilityBoard artifact, thereby becoming the organization's owner. This will allow it to execute organization-reserved operations on the artifact, such as acceptProposal, acceptProvision, confirmProvision, and so on. The original implementation of the example presented in [11] also includes a contracting phase before the building one, in which [PERSON] hires the needed company agents and assigns roles to them through an auction mechanism. Thus, we mainly focus here on the agreement of goals. With respect to the first part of the protocol, however, agents, after having adopted their roles in the bh_group, still have to declare their awareness of the powers they are endowed with when the bh_scheme is assigned to the group. This is achieved by means of the plan reported in Listing 2. As soon as the scheme is added to the ones the bh_group is responsible for, agents inside it will focus on it (lines 7 and 11) and declare power awareness with respect to the bh_group and bh_scheme (line 8). At the same time, they will commit to their missions as requested by the organizational infrastructure. Role players will now have the possibility to explicitly refuse or agree to pursue the organizational goals assigned to them (possibly asking for some provisions to hold) when asked by the organization's owner. This is achieved by means of the plans reported in Listing 3. For instance, the plan at line 2 is triggered when an acceptable goal (line 4) is proposed to the agent and there is no need to ask for provisions (line 5). In this case, the agent will simply propose a dummy _true_prov_ provision to achieve the goal (line 6). The plan at line 9 deals with an unacceptable goal (line 11). In this case the agent simply refuses it (line 12). The plan at line 15 allows the agent to propose a provision for a pending goal (line 17). Should the provision be accepted (line 22) and the goal requested (line 20), the agent would then agree to pursue the goal given the provision (line 23). Finally, the plan at line 26 is triggered when a provision for a previously agreed-upon goal is declared to hold. In this case the agent works in order to achieve the goal. An internal goal corresponding to the organizational one will be generated 30 and, if achieved, the organizational goal will be set to achieved (line 31), as well. As a final step, the goal must be declared as achieved on the AccountabilityBoard, too (line 32). ```
1//declarepowersawareness
2+schemes(L)[artifact_name(_,Group),workspace(_,_,W)]
3:my_name(Ag)&
4 play(Ag,Role,Group)
5<-for(.member(Scheme,L)){
6 lookupArtifact(Scheme,ArtId)[wid(W)];
7 focus(ArtId)[wid(W)];
8 declareAdoptionSuccess(Role,Group,Scheme);
9.concat(Group,\".,Scheme,NBName);
10 lookupArtifact(NBName,NBId)[wid(W)];
11 focus(NBId)[wid(W)];
12}. ```  
Listing 2: [PERSON] plan needed by an agent to declare powers awareness. ```
1//noprovisionneeded
2+pendingGoal(Ag,Goal)
3:my_name(Ag)&
4 acceptableGoal(Goal)&
5 notprovision(Goal,Prov)
6<-proposeProvision(Goal,true_prov). 7
8//refusegoal
9+pendingGoal(Ag,Goal)
10:my_name(Ag)&
11 notacceptableGoal(Goal)
12<-refuseGoal(Goal). 13
14//proposeprovision
15+pendingGoal(Ag,Goal)
16:my_name(Ag)&
17<-proposeProvision(Goal,Prov). 18
19//agreegoal,provisionaccepted
20+requestedGoal(Ag,Goal)
21:my_name(Ag)&
22 acceptedProposition(Ag,Goal,_)
23<-agreeGoal(Goal). 24
25//provisionconfirmed,mustsatisfyggoal
26+holdingProvision(Goal,Prov)
27:my_name(Ag)&
28 agreedGoal(Ag,Goal)&
29 acceptedProvision(Ag,Goal,Prov)
30<-!Goal[scheme(Scheme)];
31 goalAchieved(Goal)[artifact_id(ArtId)];
32 informGoal(Goal).