Repository navigation
Expand file tree
/
Copy pathm9-zero-level-enable.patch
More file actions
77 lines (68 loc) · 3.1 KB
/
Copy pathm9-zero-level-enable.patch
File metadata and controls
77 lines (68 loc) · 3.1 KB
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
--- a/mission-shell/experiment/gatekeeper_field.c
+++ b/mission-shell/experiment/gatekeeper_field.c
@@ -356,6 +356,10 @@
return "empty_U_no_achieve_tag";
}
#endif
+ /* M-9(示例规则):强度为 0 的使能请求没有可交付内容,拒绝 */
+ if (q->action == ACT_ENABLE_SIM && q->level == 0) {
+ return "zero_level_enable";
+ }
#endif /* GATE_VARIANT_M */
return 0;
}
--- a/mission-shell/experiment/oracle/oracle.py
+++ b/mission-shell/experiment/oracle/oracle.py
@@ -45,6 +45,7 @@
("S-P1", "advisor_cannot_enable"),
("S-U1", "empty_U_no_achieve_tag"),
("S-U2", "achievement_not_claimable"),
+ ("S-L0", "zero_level_enable"), # M-9(示例规则)
]
REASON_OF = dict(CLAUSE_ORDER)
@@ -160,6 +161,8 @@
bad.add("S-U1")
if a == CLAIM and u != 0:
bad.add("S-U2")
+ if a == ENABLE and level == 0:
+ bad.add("S-L0")
return [c for c, _ in CLAUSE_ORDER if c in bad]
--- a/mission-shell/experiment/tests/run_unit_tests.py
+++ b/mission-shell/experiment/tests/run_unit_tests.py
@@ -33,6 +33,8 @@
# (名称, now, 步骤, 预期 {B, Bplus, M});M 的放行写作 ALLOW,比较时映射为 ALLOW_SIM
UNIT = [
+ ("M-9 示例反例:强度 0 的使能", 150, [G(1), ev(level=0)], {"B": A_OK, "Bplus": A_OK, "M": (D, "zero_level_enable")}),
+ ("M-9 示例正例:强度 1 的使能", 150, [G(1), ev(level=1)], {"B": A_OK, "Bplus": A_OK, "M": A_OK}),
("合法名义请求(B-1…B-5 正例)", 150, [G(1), ev()], {"B": A_OK, "Bplus": A_OK, "M": A_OK}),
("B-1 反例:动作枚举 9", 150, [G(1), ev(action=9)], {k: (D, "invalid_enum") for k in ("B", "Bplus", "M")}),
("B-1 反例:角色 3", 150, [G(1), ev(role=3)], {k: (D, "invalid_enum") for k in ("B", "Bplus", "M")}),
--- a/mission-shell/experiment/corpus/gen_corpus.py
+++ b/mission-shell/experiment/corpus/gen_corpus.py
@@ -39,7 +39,7 @@
ENABLE, RECOMMEND, QUERY, CLAIM = 1, 2, 3, 4
OPERATOR, ADVISOR = 1, 2
-F_CATS = ["F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9"]
+F_CATS = ["F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10"]
L_CATS = ["L1", "L2", "L3", "L4", "L5"]
@@ -203,6 +203,11 @@
clause = "S-V1"
return self.case(self.now_in(old), pre, tgt), sub, clause
+ def F10(self, i):
+ # M-9(示例规则):强度为 0 的使能请求
+ e = self.r.choice(self.enable_cur)
+ return self.case(self.now_in(e), [self.grant(e)], self.req(e, action=ENABLE, level=0)), "zero_level", "S-L0"
+
def F9(self, i):
sub = ["never_granted", "after_revoke", "bound_other"][i % 3]
e = self.r.choice(self.enable_cur)
--- a/mission-shell/experiment/analysis/analyze.py
+++ b/mission-shell/experiment/analysis/analyze.py
@@ -44,7 +44,7 @@
tm = _load("tamper_mod", os.path.join(EXP, "tamper", "tamper.py"))
loc = _load("loc_count", os.path.join(HERE, "loc_count.py"))
-F_CATS = ["F%d" % i for i in range(1, 10)]
+F_CATS = ["F%d" % i for i in range(1, 11)]
L_CATS = ["L%d" % i for i in range(1, 6)]
D_CATS = F_CATS + ["M1", "X1"]
MISSION_ONLY = ["F1", "F2", "F3", "F5", "F6", "F7", "F8", "F9"]