proactive-gate 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +95 -15
  2. package/README.tr.md +56 -17
  3. package/package.json +4 -2
  4. package/spec/CONFORMANCE.md +83 -0
  5. package/spec/SPEC.md +140 -0
  6. package/spec/SPEC_VERSION +1 -0
  7. package/spec/fixtures/adaptive-timing/placeholder.json +58 -0
  8. package/spec/fixtures/budget/bypass-priority.json +100 -0
  9. package/spec/fixtures/budget/daily-atomic-commit.json +140 -0
  10. package/spec/fixtures/budget/near-limit.json +103 -0
  11. package/spec/fixtures/budget/race-second-commit-loses.json +93 -0
  12. package/spec/fixtures/budget/weekly-iso-week.json +134 -0
  13. package/spec/fixtures/consent/required.json +116 -0
  14. package/spec/fixtures/cooldown/three-dismissals.json +132 -0
  15. package/spec/fixtures/dedupe/already-delivered.json +87 -0
  16. package/spec/fixtures/dedupe/no-key-skips.json +49 -0
  17. package/spec/fixtures/defer/snooze-as-defer.json +138 -0
  18. package/spec/fixtures/mode/allow-list.json +139 -0
  19. package/spec/fixtures/ordering/kill-switch.json +56 -0
  20. package/spec/fixtures/ordering/short-circuit.json +235 -0
  21. package/spec/fixtures/policy/unknown-check-is-an-error.json +50 -0
  22. package/spec/fixtures/presets/cn-minor-mode.json +170 -0
  23. package/spec/fixtures/presets/kakao-brand-message.json +93 -0
  24. package/spec/fixtures/presets/kr-network-act-50.json +168 -0
  25. package/spec/fixtures/presets/telegram-bot.json +162 -0
  26. package/spec/fixtures/presets/us-tcpa.json +90 -0
  27. package/spec/fixtures/quiet-hours/apia.json +90 -0
  28. package/spec/fixtures/quiet-hours/caller-supplied-dates.json +197 -0
  29. package/spec/fixtures/quiet-hours/crosses-midnight-by-day.json +221 -0
  30. package/spec/fixtures/quiet-hours/dst-new-york.json +126 -0
  31. package/spec/fixtures/quiet-hours/istanbul.json +160 -0
  32. package/spec/fixtures/quiet-hours/wall-clock.json +94 -0
  33. package/spec/fixtures/quiet-hours/weekday-schedule.json +262 -0
  34. package/spec/fixtures/shadow/reject-continues.json +143 -0
  35. package/spec/fixtures/trust-ramp/first-week.json +154 -0
  36. package/spec/fixtures/utility/bounded-deferral-cap.json +60 -0
  37. package/spec/fixtures/utility/bounded-deferral.json +95 -0
  38. package/spec/fixtures/utility/floor.json +168 -0
  39. package/spec/schema/fixture.schema.json +58 -0
  40. package/spec/schema/policy.schema.json +23 -0
  41. package/spec/skip/python.txt +0 -0
  42. package/spec/skip/ts.txt +0 -0
@@ -0,0 +1,235 @@
1
+ {
2
+ "spec_version": "1.2.0",
3
+ "since": "1.0.0",
4
+ "name": "ordering/short-circuit",
5
+ "description": "Checks run in policy order and stop at the first rejection.",
6
+ "policy": {
7
+ "specVersion": "1.0.0",
8
+ "checks": [
9
+ {
10
+ "id": "killSwitch"
11
+ },
12
+ {
13
+ "id": "consent"
14
+ },
15
+ {
16
+ "id": "enabled"
17
+ },
18
+ {
19
+ "id": "mode",
20
+ "allow": [
21
+ "normal"
22
+ ]
23
+ },
24
+ {
25
+ "id": "snooze"
26
+ },
27
+ {
28
+ "id": "mute"
29
+ },
30
+ {
31
+ "id": "intensity"
32
+ },
33
+ {
34
+ "id": "quietHours",
35
+ "priorityFloor": "critical"
36
+ },
37
+ {
38
+ "id": "trustRamp"
39
+ },
40
+ {
41
+ "id": "dismissalCooldown"
42
+ },
43
+ {
44
+ "id": "adaptiveTiming"
45
+ },
46
+ {
47
+ "id": "dailyBudget",
48
+ "limit": 5
49
+ }
50
+ ]
51
+ },
52
+ "tests": [
53
+ {
54
+ "description": "everything passes; the trace lists all twelve",
55
+ "input": {
56
+ "user": {
57
+ "id": "u1",
58
+ "consent": true,
59
+ "proactiveEnabled": true,
60
+ "mode": "normal",
61
+ "intensity": "normal",
62
+ "timezone": "Europe/Istanbul",
63
+ "quietHours": {
64
+ "start": "22:00",
65
+ "end": "08:00"
66
+ },
67
+ "createdAt": "2026-01-01T00:00:00Z"
68
+ },
69
+ "candidate": {
70
+ "id": "c1",
71
+ "type": "reminder",
72
+ "priority": "normal",
73
+ "surfaces": [
74
+ "push",
75
+ "feed"
76
+ ]
77
+ },
78
+ "now": "2026-09-04T09:00:00Z"
79
+ },
80
+ "expect": {
81
+ "allowed": true,
82
+ "surfaces": [
83
+ "push",
84
+ "feed"
85
+ ],
86
+ "trace": [
87
+ "killSwitch",
88
+ "consent",
89
+ "enabled",
90
+ "mode",
91
+ "snooze",
92
+ "mute",
93
+ "intensity",
94
+ "quietHours",
95
+ "trustRamp",
96
+ "dismissalCooldown",
97
+ "adaptiveTiming",
98
+ "dailyBudget"
99
+ ]
100
+ }
101
+ },
102
+ {
103
+ "description": "consent rejects before quiet hours gets a chance",
104
+ "input": {
105
+ "user": {
106
+ "id": "u1",
107
+ "consent": false,
108
+ "proactiveEnabled": true,
109
+ "mode": "normal",
110
+ "intensity": "normal",
111
+ "timezone": "Europe/Istanbul",
112
+ "quietHours": {
113
+ "start": "22:00",
114
+ "end": "08:00"
115
+ },
116
+ "createdAt": "2026-01-01T00:00:00Z"
117
+ },
118
+ "candidate": {
119
+ "id": "c1",
120
+ "type": "reminder",
121
+ "priority": "normal",
122
+ "surfaces": [
123
+ "push",
124
+ "feed"
125
+ ]
126
+ },
127
+ "now": "2026-09-04T20:30:00Z"
128
+ },
129
+ "expect": {
130
+ "allowed": false,
131
+ "rejectedBy": "consent",
132
+ "trace": [
133
+ "killSwitch",
134
+ "consent"
135
+ ]
136
+ }
137
+ },
138
+ {
139
+ "description": "surfaces are the candidate's filtered by the user's",
140
+ "input": {
141
+ "user": {
142
+ "id": "u1",
143
+ "consent": true,
144
+ "proactiveEnabled": true,
145
+ "mode": "normal",
146
+ "intensity": "normal",
147
+ "timezone": "Europe/Istanbul",
148
+ "quietHours": {
149
+ "start": "22:00",
150
+ "end": "08:00"
151
+ },
152
+ "createdAt": "2026-01-01T00:00:00Z",
153
+ "surfaces": [
154
+ "feed"
155
+ ]
156
+ },
157
+ "candidate": {
158
+ "id": "c1",
159
+ "type": "reminder",
160
+ "priority": "normal",
161
+ "surfaces": [
162
+ "push",
163
+ "feed"
164
+ ]
165
+ },
166
+ "now": "2026-09-04T09:00:00Z"
167
+ },
168
+ "expect": {
169
+ "allowed": true,
170
+ "surfaces": [
171
+ "feed"
172
+ ],
173
+ "trace": [
174
+ "killSwitch",
175
+ "consent",
176
+ "enabled",
177
+ "mode",
178
+ "snooze",
179
+ "mute",
180
+ "intensity",
181
+ "quietHours",
182
+ "trustRamp",
183
+ "dismissalCooldown",
184
+ "adaptiveTiming",
185
+ "dailyBudget"
186
+ ]
187
+ }
188
+ },
189
+ {
190
+ "description": "critical priority passes quiet hours",
191
+ "input": {
192
+ "user": {
193
+ "id": "u1",
194
+ "consent": true,
195
+ "proactiveEnabled": true,
196
+ "mode": "normal",
197
+ "intensity": "normal",
198
+ "timezone": "Europe/Istanbul",
199
+ "quietHours": {
200
+ "start": "22:00",
201
+ "end": "08:00"
202
+ },
203
+ "createdAt": "2026-01-01T00:00:00Z"
204
+ },
205
+ "candidate": {
206
+ "id": "c1",
207
+ "type": "reminder",
208
+ "priority": "critical",
209
+ "surfaces": [
210
+ "push",
211
+ "feed"
212
+ ]
213
+ },
214
+ "now": "2026-09-04T20:30:00Z"
215
+ },
216
+ "expect": {
217
+ "allowed": true,
218
+ "trace": [
219
+ "killSwitch",
220
+ "consent",
221
+ "enabled",
222
+ "mode",
223
+ "snooze",
224
+ "mute",
225
+ "intensity",
226
+ "quietHours",
227
+ "trustRamp",
228
+ "dismissalCooldown",
229
+ "adaptiveTiming",
230
+ "dailyBudget"
231
+ ]
232
+ }
233
+ }
234
+ ]
235
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "spec_version": "1.2.0",
3
+ "since": "1.0.0",
4
+ "name": "policy/unknown-check-is-an-error",
5
+ "description": "The runner never sees this fixture's expectation matter; it documents that compile errors are for the schema, not the runtime. A minimal valid policy passes.",
6
+ "policy": {
7
+ "specVersion": "1.0.0",
8
+ "checks": [
9
+ {
10
+ "id": "consent"
11
+ }
12
+ ]
13
+ },
14
+ "tests": [
15
+ {
16
+ "description": "consent only",
17
+ "input": {
18
+ "user": {
19
+ "id": "u1",
20
+ "consent": true,
21
+ "proactiveEnabled": true,
22
+ "mode": "normal",
23
+ "intensity": "normal",
24
+ "timezone": "Europe/Istanbul",
25
+ "quietHours": {
26
+ "start": "22:00",
27
+ "end": "08:00"
28
+ },
29
+ "createdAt": "2026-01-01T00:00:00Z"
30
+ },
31
+ "candidate": {
32
+ "id": "c1",
33
+ "type": "reminder",
34
+ "priority": "normal",
35
+ "surfaces": [
36
+ "push",
37
+ "feed"
38
+ ]
39
+ },
40
+ "now": "2026-09-04T09:00:00Z"
41
+ },
42
+ "expect": {
43
+ "allowed": true,
44
+ "trace": [
45
+ "consent"
46
+ ]
47
+ }
48
+ }
49
+ ]
50
+ }
@@ -0,0 +1,170 @@
1
+ {
2
+ "spec_version": "1.2.0",
3
+ "since": "1.0.0",
4
+ "name": "presets/cn-minor-mode",
5
+ "description": "cnMinorMode restricts minors to 06:00 to 22:00 China time and one message a day; adults pass.",
6
+ "policy": {
7
+ "specVersion": "1.0.0",
8
+ "checks": [
9
+ {
10
+ "id": "consent"
11
+ },
12
+ {
13
+ "preset": "cnMinorMode"
14
+ }
15
+ ]
16
+ },
17
+ "tests": [
18
+ {
19
+ "description": "minor at 23:00 CST rejects",
20
+ "input": {
21
+ "user": {
22
+ "id": "u1",
23
+ "consent": true,
24
+ "proactiveEnabled": true,
25
+ "mode": "normal",
26
+ "intensity": "normal",
27
+ "timezone": "Europe/Istanbul",
28
+ "quietHours": {
29
+ "start": "22:00",
30
+ "end": "08:00"
31
+ },
32
+ "createdAt": "2026-01-01T00:00:00Z",
33
+ "minor": true
34
+ },
35
+ "candidate": {
36
+ "id": "c1",
37
+ "type": "reminder",
38
+ "priority": "normal",
39
+ "surfaces": [
40
+ "push",
41
+ "feed"
42
+ ]
43
+ },
44
+ "now": "2026-09-04T15:00:00Z"
45
+ },
46
+ "expect": {
47
+ "allowed": false,
48
+ "rejectedBy": "window:minor",
49
+ "trace": [
50
+ "consent",
51
+ "window:minor"
52
+ ]
53
+ }
54
+ },
55
+ {
56
+ "description": "adult at 23:00 CST passes both",
57
+ "input": {
58
+ "user": {
59
+ "id": "u1",
60
+ "consent": true,
61
+ "proactiveEnabled": true,
62
+ "mode": "normal",
63
+ "intensity": "normal",
64
+ "timezone": "Europe/Istanbul",
65
+ "quietHours": {
66
+ "start": "22:00",
67
+ "end": "08:00"
68
+ },
69
+ "createdAt": "2026-01-01T00:00:00Z",
70
+ "minor": false
71
+ },
72
+ "candidate": {
73
+ "id": "c1",
74
+ "type": "reminder",
75
+ "priority": "normal",
76
+ "surfaces": [
77
+ "push",
78
+ "feed"
79
+ ]
80
+ },
81
+ "now": "2026-09-04T15:00:00Z"
82
+ },
83
+ "expect": {
84
+ "allowed": true,
85
+ "trace": [
86
+ "consent",
87
+ "window:minor",
88
+ "dailyBudget"
89
+ ]
90
+ }
91
+ },
92
+ {
93
+ "description": "minor at noon CST: first message allowed and consumed",
94
+ "input": {
95
+ "user": {
96
+ "id": "u1",
97
+ "consent": true,
98
+ "proactiveEnabled": true,
99
+ "mode": "normal",
100
+ "intensity": "normal",
101
+ "timezone": "Europe/Istanbul",
102
+ "quietHours": {
103
+ "start": "22:00",
104
+ "end": "08:00"
105
+ },
106
+ "createdAt": "2026-01-01T00:00:00Z",
107
+ "minor": true
108
+ },
109
+ "candidate": {
110
+ "id": "c2",
111
+ "type": "reminder",
112
+ "priority": "normal",
113
+ "surfaces": [
114
+ "push",
115
+ "feed"
116
+ ]
117
+ },
118
+ "now": "2026-09-04T04:00:00Z"
119
+ },
120
+ "commit": true,
121
+ "expect": {
122
+ "allowed": true,
123
+ "trace": [
124
+ "consent",
125
+ "window:minor",
126
+ "dailyBudget"
127
+ ],
128
+ "commit": true
129
+ }
130
+ },
131
+ {
132
+ "description": "minor at noon CST: second message rejected",
133
+ "input": {
134
+ "user": {
135
+ "id": "u1",
136
+ "consent": true,
137
+ "proactiveEnabled": true,
138
+ "mode": "normal",
139
+ "intensity": "normal",
140
+ "timezone": "Europe/Istanbul",
141
+ "quietHours": {
142
+ "start": "22:00",
143
+ "end": "08:00"
144
+ },
145
+ "createdAt": "2026-01-01T00:00:00Z",
146
+ "minor": true
147
+ },
148
+ "candidate": {
149
+ "id": "c3",
150
+ "type": "reminder",
151
+ "priority": "normal",
152
+ "surfaces": [
153
+ "push",
154
+ "feed"
155
+ ]
156
+ },
157
+ "now": "2026-09-04T04:00:00Z"
158
+ },
159
+ "expect": {
160
+ "allowed": false,
161
+ "rejectedBy": "dailyBudget",
162
+ "trace": [
163
+ "consent",
164
+ "window:minor",
165
+ "dailyBudget"
166
+ ]
167
+ }
168
+ }
169
+ ]
170
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "spec_version": "1.2.0",
3
+ "since": "1.0.0",
4
+ "name": "presets/kakao-brand-message",
5
+ "description": "kakaoBrandMessage runs 08:00 to 20:50 Korea time regardless of the recipient's zone.",
6
+ "policy": {
7
+ "specVersion": "1.0.0",
8
+ "checks": [
9
+ {
10
+ "preset": "kakaoBrandMessage"
11
+ }
12
+ ]
13
+ },
14
+ "tests": [
15
+ {
16
+ "description": "21:00 KST rejects even for a user in Istanbul",
17
+ "input": {
18
+ "user": {
19
+ "id": "u1",
20
+ "consent": true,
21
+ "proactiveEnabled": true,
22
+ "mode": "normal",
23
+ "intensity": "normal",
24
+ "timezone": "Europe/Istanbul",
25
+ "quietHours": {
26
+ "start": "22:00",
27
+ "end": "08:00"
28
+ },
29
+ "createdAt": "2026-01-01T00:00:00Z",
30
+ "consents": {
31
+ "ad": true
32
+ }
33
+ },
34
+ "candidate": {
35
+ "id": "c1",
36
+ "type": "reminder",
37
+ "priority": "normal",
38
+ "surfaces": [
39
+ "push",
40
+ "feed"
41
+ ]
42
+ },
43
+ "now": "2026-09-04T12:00:00Z"
44
+ },
45
+ "expect": {
46
+ "allowed": false,
47
+ "rejectedBy": "window:kakao",
48
+ "trace": [
49
+ "consent:ad",
50
+ "window:kakao"
51
+ ]
52
+ }
53
+ },
54
+ {
55
+ "description": "10:00 KST passes",
56
+ "input": {
57
+ "user": {
58
+ "id": "u1",
59
+ "consent": true,
60
+ "proactiveEnabled": true,
61
+ "mode": "normal",
62
+ "intensity": "normal",
63
+ "timezone": "Europe/Istanbul",
64
+ "quietHours": {
65
+ "start": "22:00",
66
+ "end": "08:00"
67
+ },
68
+ "createdAt": "2026-01-01T00:00:00Z",
69
+ "consents": {
70
+ "ad": true
71
+ }
72
+ },
73
+ "candidate": {
74
+ "id": "c1",
75
+ "type": "reminder",
76
+ "priority": "normal",
77
+ "surfaces": [
78
+ "push",
79
+ "feed"
80
+ ]
81
+ },
82
+ "now": "2026-09-04T01:00:00Z"
83
+ },
84
+ "expect": {
85
+ "allowed": true,
86
+ "trace": [
87
+ "consent:ad",
88
+ "window:kakao"
89
+ ]
90
+ }
91
+ }
92
+ ]
93
+ }