Skip to main content

Diagnostics

Decisions4s aims to help not only evaluate and visualize the decisions but also to understand them.

Results of evaluation carry all the information needed, such as:

  • Table that was evaluated
  • Input that was provided
  • Results of individual rules
import decisions4s.*

val decisionTable: DecisionTable[Input, Output, HitPolicy.Distinct] = ???
val input: Input[Value] = ???

decisionTable.evaluateDistinct(input).makeDiagnosticsString

Which produces a debug string containing

  • Name of the decision
  • Hit policy
  • Result of the evaluation
  • Input used
  • All the evaluated rules, including:
    • Their predicates
    • Predicates' results (satisfied or not)
    • Rule output

Example

Evaluation diagnostics for "PullRequestDecision"
Hit policy: First
Result: Some(Output(true,false))
Input:
numOfApprovals: 2
isTargetBranchProtected: true
authorIsAdmin: false
Rule 0 [✗]:
numOfApprovals [✓]: > 0
isTargetBranchProtected [✗]: false
authorIsAdmin [✓]: -
== ✗
Rule 1 [✓]:
numOfApprovals [✓]: > 1
isTargetBranchProtected [✓]: true
authorIsAdmin [✓]: -
== Output(true,false)

Customization

Currently, there is no option to customize the message but users are encouraged to implement their own formats by replicating the logic from DiagnosticsPrinter. If you believe it's worth exposing some customization options from the library itself, or to modify the format in general, please reach out!