Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decision trees #12

Open
RieksJ opened this issue Nov 30, 2020 · 0 comments
Open

decision trees #12

RieksJ opened this issue Nov 30, 2020 · 0 comments

Comments

@RieksJ
Copy link

RieksJ commented Nov 30, 2020

Work in progress on the new Sovrin guardianship paper has the following text (more or less), of which I wonder whether or not SGL could be a tool to actually help execute the generic decision-making algorithm identified at the bottom of this text.

In the Mya use-case, Malcolm immediately asks for a guardianship credential when Zo and Mya appear in his food tent. However, in general a visit from some arbitrary (set) of person(s) would go more like this:

A person in the shop says:

[I (the requester)] want to get a food ration for [someone].

The shopkeeper then executes the following algorithm:

Evaluate [someone] (i.e. replace it with an actual value);
IF (a ration has been dispensed for [someone] today)
THEN deny the request and stop.
ELSE	evaluate [I (the requester)];
IF ([someone] == [I (the requester)])
THEN dispense a ration for [someone] and stop.
IF (a [guardianship] exists, such that:
     ( [guardianship].dependent == [someone] AND
	  [guardianship].grant == “food” AND
	  [guardianship].guardian == 
	    (    [I (the requester)]
	    OR ( [party] 
		  AND a [mandate] exists, such that:
		    ( [mandate].mandator == [party] AND
			[mandate].mandatee == [I (the requester)]
			[mandate].grant == “food”
		    )
	       )
	    )
       )
    )
THEN dispense a ration for [someone] and stop.
IF (a [mandate] exists, such that
      ( [mandate].mandator == [someone] AND
	  [mandate].mandatee == [I (the requester)]
	  [mandate].grant == “food”
	 )
    )
THEN dispense a ration for [someone] and stop.
deny the request and stop.

As you may see, this algorithm could be made generic, with three arguments:

  1. a condition that, when satisfied, immediately denies the request (e.g. 'a ration has been dispensed for [someone] today').
  2. a permission (e.g. "food");
  3. the action that is executed when the request is granted (e.g. 'dispense a ration for [someone]' - b.t.w., note that this dispensing implies logging (date(today), [someone]), so that it can be checked that a ration has been dispensed to [someone] on [date]).

Would it be useful to be able to express the following JSON? Would that be executable?

{
    "actionid": "dispense daily food ration",
    "postcondition": {
        "all": [
            { "a ration has been dispensed for [someone] today" },
            { "[logfile] += '{date(TODAY)}, {[someone]} has been provided a food ration')" },
        ]
    },
    "boundarycondition": {
        "[provider] has role:'shopkeeper'"
    },
    "precondition": { 
        "any": [
            { "[someone] == [requester]"
            },
            { "[someone] ==    [guardianship].[dependent] 
                            /\\ [guardianship].grant == 'food'
                            /\\ [guardianship].guardian == [requester] "
            },
            { "[someone] ==    [guardianship].[dependent] 
                            /\\ [guardianship].grant == 'food'
                            /\\ [guardianship].guardian == [party]
                                /\\ [mandate].mandator == [party]
                                /\\ [mandate].mandatee == [requester]
                                /\\ [mandate].grant == 'food'"
            },
            { "[someone] == [mandate].mandator
                            /\\ [mandate].mandatee == [requester]
                            /\\ [mandate].grant == 'food'"
            }
        ]
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant