Skip to content

Commit d0bdb87

Browse files
Implement Explanations in RPC (#131)
## What is the goal of this PR? We add Explanations, and the explain() query endpoint to the protocol. This enables all clients to retrieve all available explanations for a particular explainable concept map. ## What are the changes implemented in this PR? * Implement `Explainable` and `Explainables` as part of `Answer` protocol * Implement `Explanation` as part of `Logic` protocol * Add `Explain.Req` and `Explain.Res` as part of the explain QueryManager endpoing
1 parent 71b277a commit d0bdb87

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

common/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ proto_library(
3232

3333
proto_library(
3434
name = "logic-proto",
35-
srcs = ["logic.proto"]
35+
srcs = ["logic.proto"],
36+
deps = [":answer-proto"]
3637
)
3738

3839
proto_library(
@@ -45,6 +46,7 @@ proto_library(
4546
srcs = ["query.proto"],
4647
deps = [
4748
":answer-proto",
49+
":logic-proto",
4850
":options-proto",
4951
],
5052
)

common/answer.proto

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,22 @@ package grakn.protocol;
2626

2727
message ConceptMap {
2828
map<string, Concept> map = 1;
29-
string pattern = 2;
29+
Explainables explainables = 2;
30+
}
31+
32+
message Explainables {
33+
map<string, Explainable> relations = 1;
34+
map<string, Explainable> attributes = 2;
35+
map<string, Owned> ownerships = 3;
36+
37+
message Owned {
38+
map<string, Explainable> owned = 1;
39+
}
40+
}
41+
42+
message Explainable {
43+
string conjunction = 1;
44+
int64 id = 2;
3045
}
3146

3247
message ConceptMapGroup {

common/logic.proto

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ syntax = "proto3";
2020
option java_package = "grakn.protocol";
2121
option java_outer_classname = "LogicProto";
2222

23+
import "common/answer.proto";
24+
25+
2326
package grakn.protocol;
2427

2528
message LogicManager {
@@ -106,3 +109,14 @@ message Rule {
106109
message Res {}
107110
}
108111
}
112+
113+
message Explanation {
114+
Rule rule = 1;
115+
map<string, VarList> var_mapping = 2;
116+
ConceptMap condition = 3;
117+
ConceptMap conclusion = 4;
118+
119+
message VarList {
120+
repeated string vars = 1;
121+
}
122+
}

common/query.proto

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ option java_package = "grakn.protocol";
2121
option java_outer_classname = "QueryProto";
2222

2323
import "common/answer.proto";
24+
import "common/logic.proto";
2425
import "common/options.proto";
2526

2627
package grakn.protocol;
@@ -39,6 +40,7 @@ message QueryManager {
3940
Insert.Req insert_req = 106;
4041
Delete.Req delete_req = 107;
4142
Update.Req update_req = 108;
43+
Explain.Req explain_req = 109;
4244
}
4345
}
4446

@@ -58,6 +60,7 @@ message QueryManager {
5860
MatchGroupAggregate.ResPart match_group_aggregate_res_part = 102;
5961
Insert.ResPart insert_res_part = 103;
6062
Update.ResPart update_res_part = 104;
63+
Explain.ResPart explain_res_part = 105;
6164
}
6265
}
6366

@@ -100,6 +103,16 @@ message QueryManager {
100103
}
101104
}
102105

106+
message Explain {
107+
message Req {
108+
int64 explainable_id = 1;
109+
}
110+
111+
message ResPart {
112+
repeated Explanation explanations = 1;
113+
}
114+
}
115+
103116
message Insert {
104117
message Req {
105118
string query = 1;

0 commit comments

Comments
 (0)