clarent-methods 0.1.0__py3-none-any.whl
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.
- clarent/__init__.py +2 -0
- clarent/__main__.py +5 -0
- clarent/_methods/ach/CARD.md +46 -0
- clarent/_methods/ach/clarent_ach/__init__.py +6 -0
- clarent/_methods/ach/clarent_ach/__main__.py +5 -0
- clarent/_methods/ach/clarent_ach/cli.py +123 -0
- clarent/_methods/ach/clarent_ach/engine.py +214 -0
- clarent/_methods/ach/clarent_ach/i18n.py +160 -0
- clarent/_methods/ach/clarent_ach/model.py +174 -0
- clarent/_methods/ach/clarent_ach/render.py +72 -0
- clarent/_methods/ach/examples/flaky-test.es.json +156 -0
- clarent/_methods/ach/examples/flaky-test.json +156 -0
- clarent/_methods/ach/method.toml +43 -0
- clarent/_methods/ach/skill/SKILL.md +58 -0
- clarent/_methods/ach/tests/test_ach.py +231 -0
- clarent/_methods/redteam/CARD.md +66 -0
- clarent/_methods/redteam/clarent_redteam/__init__.py +6 -0
- clarent/_methods/redteam/clarent_redteam/__main__.py +5 -0
- clarent/_methods/redteam/clarent_redteam/catalog.py +192 -0
- clarent/_methods/redteam/clarent_redteam/cli.py +189 -0
- clarent/_methods/redteam/clarent_redteam/engine.py +281 -0
- clarent/_methods/redteam/clarent_redteam/i18n.py +199 -0
- clarent/_methods/redteam/clarent_redteam/model.py +320 -0
- clarent/_methods/redteam/clarent_redteam/render.py +103 -0
- clarent/_methods/redteam/examples/design-doc/design.es.md +27 -0
- clarent/_methods/redteam/examples/design-doc/design.md +27 -0
- clarent/_methods/redteam/examples/design-doc/findings.es.json +132 -0
- clarent/_methods/redteam/examples/design-doc/findings.json +132 -0
- clarent/_methods/redteam/examples/design-doc/findings.rejected.json +130 -0
- clarent/_methods/redteam/examples/pr/change.diff +34 -0
- clarent/_methods/redteam/examples/pr/description.md +13 -0
- clarent/_methods/redteam/examples/pr/findings.json +114 -0
- clarent/_methods/redteam/method.toml +43 -0
- clarent/_methods/redteam/skill/SKILL.md +52 -0
- clarent/_methods/redteam/tests/test_redteam.py +640 -0
- clarent/_methods/triz-matrix/CARD.md +50 -0
- clarent/_methods/triz-matrix/clarent_triz/__init__.py +6 -0
- clarent/_methods/triz-matrix/clarent_triz/__main__.py +5 -0
- clarent/_methods/triz-matrix/clarent_triz/cli.py +184 -0
- clarent/_methods/triz-matrix/clarent_triz/data/DATA_LICENSE.md +51 -0
- clarent/_methods/triz-matrix/clarent_triz/data/catalog.json +89 -0
- clarent/_methods/triz-matrix/clarent_triz/data/matrix.json +11920 -0
- clarent/_methods/triz-matrix/clarent_triz/engine.py +103 -0
- clarent/_methods/triz-matrix/clarent_triz/i18n.py +134 -0
- clarent/_methods/triz-matrix/clarent_triz/model.py +179 -0
- clarent/_methods/triz-matrix/clarent_triz/render.py +101 -0
- clarent/_methods/triz-matrix/examples/search-api.es.json +9 -0
- clarent/_methods/triz-matrix/examples/search-api.json +9 -0
- clarent/_methods/triz-matrix/method.toml +58 -0
- clarent/_methods/triz-matrix/skill/SKILL.md +50 -0
- clarent/_methods/triz-matrix/tests/test_triz.py +306 -0
- clarent/cli.py +95 -0
- clarent/registry.py +175 -0
- clarent_methods-0.1.0.dist-info/METADATA +227 -0
- clarent_methods-0.1.0.dist-info/RECORD +59 -0
- clarent_methods-0.1.0.dist-info/WHEEL +4 -0
- clarent_methods-0.1.0.dist-info/entry_points.txt +2 -0
- clarent_methods-0.1.0.dist-info/licenses/LICENSE +202 -0
- clarent_methods-0.1.0.dist-info/licenses/NOTICE +12 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "clarent.redteam/1",
|
|
3
|
+
"title": "Notifications from a stream consumer (SYNTHETIC EXAMPLE)",
|
|
4
|
+
"root": ".",
|
|
5
|
+
"target": { "kind": "design", "files": ["design.md"] },
|
|
6
|
+
"assumptions": [
|
|
7
|
+
{
|
|
8
|
+
"id": "A1",
|
|
9
|
+
"text": "If Redis is down when the API publishes, the notification is not lost: it is sent later from the table.",
|
|
10
|
+
"quote": "if it is not, the notification stays in the table and will be picked up later",
|
|
11
|
+
"status": "contradicted",
|
|
12
|
+
"evidence": [
|
|
13
|
+
{ "ref": "design.md:15", "observation": "Step 4 deletes the cron job, which is the only reader of the table, so nothing picks the row up later." }
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "A2",
|
|
18
|
+
"text": "The provider's rate limit applies per consumer, so adding consumers adds capacity.",
|
|
19
|
+
"quote": "The email provider accepts at most one message per second per consumer",
|
|
20
|
+
"status": "unverified",
|
|
21
|
+
"check": "Read the provider's rate-limit documentation, then send a 50-message burst from two consumers sharing one sandbox account."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "A3",
|
|
25
|
+
"text": "Duplicate notifications are rare, so consumers can skip idempotency.",
|
|
26
|
+
"quote": "Notifications are rarely duplicated, so consumers do not need to be idempotent",
|
|
27
|
+
"status": "unverified",
|
|
28
|
+
"check": "Count notification ids published more than once over the last 30 days (group the publish log by id, keep count > 1)."
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "A4",
|
|
32
|
+
"text": "Load stays under 200 notifications per minute.",
|
|
33
|
+
"quote": "Peak load will stay under 200 notifications per minute",
|
|
34
|
+
"status": "verified",
|
|
35
|
+
"evidence": [
|
|
36
|
+
{
|
|
37
|
+
"ref": "psql -c \"select max(n) from (select count(*) n from notifications group by date_trunc('minute', created_at)) m\"",
|
|
38
|
+
"observation": "peak of 118 per minute over the last 30 days (synthetic result for this example; it says nothing about campaigns)"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "A5",
|
|
44
|
+
"text": "Turning the flag off is a safe rollback.",
|
|
45
|
+
"quote": "The consumer pool ships behind a flag",
|
|
46
|
+
"status": "contradicted",
|
|
47
|
+
"evidence": [
|
|
48
|
+
{ "ref": "design.md:26-27", "observation": "Once the flag is on for everyone the cron job and its code are removed and sent_at is dropped, so switching the flag off restores nothing." }
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"id": "A6",
|
|
53
|
+
"text": "A message acknowledged on read cannot be lost.",
|
|
54
|
+
"quote": "Each consumer acknowledges the message as soon as it is read",
|
|
55
|
+
"status": "unverified",
|
|
56
|
+
"check": "In staging, kill -9 a consumer between the read and the provider call, then count the notifications that were never sent."
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"attacks": [
|
|
60
|
+
{
|
|
61
|
+
"id": "X1",
|
|
62
|
+
"class": "failure-modes",
|
|
63
|
+
"assumption": "A1",
|
|
64
|
+
"quote": "the notification stays in the table and will be picked up later",
|
|
65
|
+
"attack": "If Redis is down when the API publishes, the row stays in the table but nothing reads it once the cron job is gone: those notifications are never sent and nobody is told.",
|
|
66
|
+
"impact": 4,
|
|
67
|
+
"plausibility": 3,
|
|
68
|
+
"check": "Stop Redis in staging, create 20 notifications, restart Redis and count how many are sent."
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "X2",
|
|
72
|
+
"class": "failure-modes",
|
|
73
|
+
"assumption": "A6",
|
|
74
|
+
"quote": "acknowledges the message as soon as it is read",
|
|
75
|
+
"attack": "A consumer that crashes after the read and before the provider answers loses the notification: acknowledging on read gives at-most-once delivery, and the row stays pending for ever.",
|
|
76
|
+
"impact": 4,
|
|
77
|
+
"plausibility": 4,
|
|
78
|
+
"check": "In staging, kill -9 a consumer between the read and the provider call; count the rows still pending after 10 minutes."
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": "X3",
|
|
82
|
+
"class": "reversibility",
|
|
83
|
+
"assumption": "A5",
|
|
84
|
+
"quote": "the cron job and its code are removed",
|
|
85
|
+
"attack": "After the rollout there is no way back: the flag cannot bring back the cron job or the sent_at column, so a bad release can only be fixed by shipping another one while notifications are being lost.",
|
|
86
|
+
"impact": 5,
|
|
87
|
+
"plausibility": 3,
|
|
88
|
+
"check": "Apply the migration in staging, then try to revert to the previous release and send a notification."
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "X4",
|
|
92
|
+
"class": "dependency",
|
|
93
|
+
"assumption": "A2",
|
|
94
|
+
"quote": "accepts at most one message per second per consumer",
|
|
95
|
+
"attack": "If the provider's limit applies per account instead of per consumer, the 4 consumers share it, and throttled sends that were already acknowledged are dropped.",
|
|
96
|
+
"impact": 3,
|
|
97
|
+
"plausibility": 3,
|
|
98
|
+
"check": "Ask the provider (or read its docs) whether the limit is per API key or per connection."
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "X5",
|
|
102
|
+
"class": "abuse",
|
|
103
|
+
"assumption": "A3",
|
|
104
|
+
"quote": "publishes its id to a Redis Stream called `notify`",
|
|
105
|
+
"attack": "A client that repeats a request (a password-reset form, a retry loop) creates one notification per request; with no per-user limit the stream fills with duplicates and delays everyone, which is what the assumption says does not happen.",
|
|
106
|
+
"impact": 3,
|
|
107
|
+
"plausibility": 3,
|
|
108
|
+
"check": "Send 1,000 password-reset requests for one address in staging and measure the delay of an unrelated notification."
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"id": "X6",
|
|
112
|
+
"class": "scale",
|
|
113
|
+
"assumption": "A4",
|
|
114
|
+
"quote": "Peak load will stay under 200 notifications per minute",
|
|
115
|
+
"attack": "A marketing blast of 50,000 notifications enters the stream at once; 4 consumers at one message per second need about 3.5 hours to drain it, and transactional emails wait behind it.",
|
|
116
|
+
"impact": 4,
|
|
117
|
+
"plausibility": 4,
|
|
118
|
+
"check": "Compute N / (consumers x rate) for the largest campaign of last quarter, then load-test a 50,000-message burst in staging."
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"id": "X7",
|
|
122
|
+
"class": "key-assumptions",
|
|
123
|
+
"assumption": "A3",
|
|
124
|
+
"quote": "so consumers do not need to be idempotent",
|
|
125
|
+
"attack": "The API publishes inside the request, so any client or load-balancer retry publishes twice. Duplicates come from the publisher, not from the rarity of events, and a consumer that is not idempotent sends two emails.",
|
|
126
|
+
"impact": 2,
|
|
127
|
+
"plausibility": 4,
|
|
128
|
+
"check": "Count notification ids published more than once over the last 30 days."
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"skipped_classes": []
|
|
132
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "clarent.redteam/1",
|
|
3
|
+
"title": "The same design, with findings the engine must refuse (SYNTHETIC EXAMPLE)",
|
|
4
|
+
"root": ".",
|
|
5
|
+
"target": { "kind": "design", "files": ["design.md"] },
|
|
6
|
+
"assumptions": [
|
|
7
|
+
{
|
|
8
|
+
"id": "A1",
|
|
9
|
+
"text": "If Redis is down when the API publishes, the notification is not lost: it is sent later from the table.",
|
|
10
|
+
"quote": "if it is not, the notification stays in the table and will be picked up later",
|
|
11
|
+
"status": "contradicted",
|
|
12
|
+
"evidence": [
|
|
13
|
+
{ "ref": "design.md:15", "observation": "Step 4 deletes the cron job, which is the only reader of the table." }
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "A2",
|
|
18
|
+
"text": "The provider's rate limit applies per consumer.",
|
|
19
|
+
"quote": "The email provider accepts at most one message per second per consumer",
|
|
20
|
+
"status": "unverified",
|
|
21
|
+
"check": "Read the provider's rate-limit documentation."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"id": "A3",
|
|
25
|
+
"text": "The stream never loses a message.",
|
|
26
|
+
"quote": "Redis Streams guarantee that no message is ever lost",
|
|
27
|
+
"status": "unverified",
|
|
28
|
+
"check": "Read the persistence settings of the Redis deployment."
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "A4",
|
|
32
|
+
"text": "Consumers keep up with the stream.",
|
|
33
|
+
"quote": "A pool of 4 consumers reads the stream through a consumer group",
|
|
34
|
+
"status": "verified"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"id": "A5",
|
|
38
|
+
"text": "The migration is reversible.",
|
|
39
|
+
"quote": "the old `notifications.sent_at` column is dropped in the next migration",
|
|
40
|
+
"status": "contradicted",
|
|
41
|
+
"evidence": [
|
|
42
|
+
{ "ref": "design.md:99", "observation": "The rollout section says nothing about restoring the column." }
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"attacks": [
|
|
47
|
+
{
|
|
48
|
+
"id": "X1",
|
|
49
|
+
"class": "failure-modes",
|
|
50
|
+
"assumption": "A1",
|
|
51
|
+
"quote": "the notification stays in the table and will be picked up later",
|
|
52
|
+
"attack": "If Redis is down when the API publishes, the row stays in the table but nothing reads it once the cron job is gone.",
|
|
53
|
+
"impact": 4,
|
|
54
|
+
"plausibility": 3,
|
|
55
|
+
"check": "Stop Redis in staging, create 20 notifications, restart Redis and count how many are sent."
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "X2",
|
|
59
|
+
"class": "dependency",
|
|
60
|
+
"assumption": "A2",
|
|
61
|
+
"quote": "accepts at most one message per second per consumer",
|
|
62
|
+
"attack": "If the provider's limit applies per account, the 4 consumers share it and throttled sends are dropped.",
|
|
63
|
+
"impact": 3,
|
|
64
|
+
"plausibility": 3,
|
|
65
|
+
"check": "Ask the provider whether the limit is per API key or per connection."
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "X3",
|
|
69
|
+
"class": "failure-modes",
|
|
70
|
+
"assumption": "A3",
|
|
71
|
+
"quote": "The stream loses messages when Redis restarts without persistence",
|
|
72
|
+
"attack": "A Redis restart without persistence empties the stream and every pending notification disappears.",
|
|
73
|
+
"impact": 4,
|
|
74
|
+
"plausibility": 3,
|
|
75
|
+
"check": "Restart Redis in staging with persistence off and count the pending messages."
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "X4",
|
|
79
|
+
"class": "scale",
|
|
80
|
+
"assumption": "A2",
|
|
81
|
+
"quote": "Redis",
|
|
82
|
+
"attack": "Redis becomes the bottleneck.",
|
|
83
|
+
"impact": 3,
|
|
84
|
+
"plausibility": 3,
|
|
85
|
+
"check": "Load-test it."
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"id": "X5",
|
|
89
|
+
"class": "dependency",
|
|
90
|
+
"assumption": "A2",
|
|
91
|
+
"quote": "accepts at most one message per second per consumer",
|
|
92
|
+
"attack": "If the limit of the provider applies per account, the 4 consumers share it, and throttled sends are dropped.",
|
|
93
|
+
"impact": 3,
|
|
94
|
+
"plausibility": 3,
|
|
95
|
+
"check": "Ask the provider whether the limit is per API key or per connection."
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"id": "X6",
|
|
99
|
+
"class": "abuse",
|
|
100
|
+
"assumption": "A1",
|
|
101
|
+
"quote": "publishes its id to a Redis Stream called `notify`",
|
|
102
|
+
"attack": "Nothing limits how many notifications one client can trigger, so one client can flood the stream.",
|
|
103
|
+
"impact": 3,
|
|
104
|
+
"plausibility": 3
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"id": "X7",
|
|
108
|
+
"class": "scale",
|
|
109
|
+
"assumption": "A4",
|
|
110
|
+
"quote": "A pool of 4 consumers reads the stream through a consumer group",
|
|
111
|
+
"attack": "Four consumers cannot drain a campaign of 50,000 messages in useful time.",
|
|
112
|
+
"impact": 4,
|
|
113
|
+
"plausibility": 4,
|
|
114
|
+
"check": "Compute N / (consumers x rate) for the largest campaign of last quarter."
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"id": "X8",
|
|
118
|
+
"class": "reversibility",
|
|
119
|
+
"assumption": "A5",
|
|
120
|
+
"quote": "the old `notifications.sent_at` column is dropped in the next migration",
|
|
121
|
+
"attack": "Once the column is dropped, reverting the release cannot restore the sent_at data.",
|
|
122
|
+
"impact": 5,
|
|
123
|
+
"plausibility": 3,
|
|
124
|
+
"check": "Apply the migration in staging and try to revert."
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"skipped_classes": [
|
|
128
|
+
{ "class": "key-assumptions", "reason": "" }
|
|
129
|
+
]
|
|
130
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
diff --git a/webhooks/deliver.py b/webhooks/deliver.py
|
|
2
|
+
index 3f2a1c4..9b7d0e2 100644
|
|
3
|
+
--- a/webhooks/deliver.py
|
|
4
|
+
+++ b/webhooks/deliver.py
|
|
5
|
+
@@ -10,6 +10,11 @@ import requests
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
-def deliver(endpoint, payload):
|
|
10
|
+
- resp = requests.post(endpoint.url, json=payload, timeout=5)
|
|
11
|
+
- return resp.status_code
|
|
12
|
+
+def deliver(endpoint, payload):
|
|
13
|
+
+ delay = 1
|
|
14
|
+
+ while True:
|
|
15
|
+
+ resp = requests.post(endpoint.url, json=payload, timeout=5)
|
|
16
|
+
+ if resp.status_code < 500:
|
|
17
|
+
+ return resp.status_code
|
|
18
|
+
+ time.sleep(delay)
|
|
19
|
+
+ delay *= 2
|
|
20
|
+
diff --git a/tests/test_deliver.py b/tests/test_deliver.py
|
|
21
|
+
new file mode 100644
|
|
22
|
+
index 0000000..4c1e9aa
|
|
23
|
+
--- /dev/null
|
|
24
|
+
+++ b/tests/test_deliver.py
|
|
25
|
+
@@ -0,0 +1,9 @@
|
|
26
|
+
+from unittest import mock
|
|
27
|
+
+
|
|
28
|
+
+from webhooks.deliver import deliver
|
|
29
|
+
+
|
|
30
|
+
+
|
|
31
|
+
+def test_retries_until_success():
|
|
32
|
+
+ answers = [mock.Mock(status_code=503), mock.Mock(status_code=503), mock.Mock(status_code=200)]
|
|
33
|
+
+ with mock.patch("webhooks.deliver.requests.post", side_effect=answers), mock.patch("webhooks.deliver.time.sleep"):
|
|
34
|
+
+ assert deliver(mock.Mock(url="http://x"), {}) == 200
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Retry failed webhook deliveries (SYNTHETIC EXAMPLE)
|
|
2
|
+
|
|
3
|
+
## What
|
|
4
|
+
|
|
5
|
+
Webhook deliveries that fail with a 5xx or a timeout are now retried with exponential backoff, so customers stop losing events during their deploys.
|
|
6
|
+
|
|
7
|
+
## How
|
|
8
|
+
|
|
9
|
+
`deliver()` loops until the endpoint answers with something other than a 5xx. The delay doubles after each failure, starting at 1 second.
|
|
10
|
+
|
|
11
|
+
## Testing
|
|
12
|
+
|
|
13
|
+
Added `test_retries_until_success`. Verified by hand against a local server that answers 503 twice and then 200.
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "clarent.redteam/1",
|
|
3
|
+
"title": "Retry failed webhook deliveries (SYNTHETIC EXAMPLE)",
|
|
4
|
+
"root": ".",
|
|
5
|
+
"target": { "kind": "pr", "files": ["description.md", "change.diff"] },
|
|
6
|
+
"assumptions": [
|
|
7
|
+
{
|
|
8
|
+
"id": "P1",
|
|
9
|
+
"text": "A timeout is retried, as the description says.",
|
|
10
|
+
"quote": "fail with a 5xx or a timeout are now retried with exponential backoff",
|
|
11
|
+
"status": "contradicted",
|
|
12
|
+
"evidence": [
|
|
13
|
+
{ "ref": "change.diff:15", "observation": "The only call is requests.post with timeout=5 and there is no try/except: a timeout raises and leaves deliver() instead of being retried." }
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "P2",
|
|
18
|
+
"text": "The loop ends at some point.",
|
|
19
|
+
"quote": "loops until the endpoint answers with something other than a 5xx",
|
|
20
|
+
"status": "contradicted",
|
|
21
|
+
"evidence": [
|
|
22
|
+
{ "ref": "change.diff:14", "observation": "The loop is `while True` with no maximum number of attempts, and the delay has no cap." }
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "P3",
|
|
27
|
+
"text": "Customers' endpoints tolerate receiving the same event twice.",
|
|
28
|
+
"quote": "so customers stop losing events during their deploys",
|
|
29
|
+
"status": "unverified",
|
|
30
|
+
"check": "Look at one delivered request (body and headers): is there an event id or idempotency key a receiver can deduplicate on?"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "P4",
|
|
34
|
+
"text": "Any answer below 500 is final and must not be retried.",
|
|
35
|
+
"quote": "if resp.status_code < 500:",
|
|
36
|
+
"status": "verified",
|
|
37
|
+
"evidence": [
|
|
38
|
+
{ "ref": "change.diff:16", "observation": "Only status codes of 500 and above continue the loop; every lower code returns at once." }
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "P5",
|
|
43
|
+
"text": "deliver() runs in a background worker, not in a request path or a shared pool.",
|
|
44
|
+
"quote": "time.sleep(delay)",
|
|
45
|
+
"status": "unverified",
|
|
46
|
+
"check": "git grep -n 'deliver(' -- '*.py' and read the callers: which thread or pool runs them?"
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"attacks": [
|
|
50
|
+
{
|
|
51
|
+
"id": "X1",
|
|
52
|
+
"class": "failure-modes",
|
|
53
|
+
"assumption": "P1",
|
|
54
|
+
"quote": "resp = requests.post(endpoint.url, json=payload, timeout=5) if resp.status_code < 500:",
|
|
55
|
+
"attack": "A timeout raises requests.Timeout and nothing catches it: the first slow endpoint aborts the delivery and the event is lost, although the description promises that timeouts are retried.",
|
|
56
|
+
"impact": 3,
|
|
57
|
+
"plausibility": 3,
|
|
58
|
+
"check": "Point deliver() at a server that sleeps 10 seconds and check that Timeout reaches the caller."
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": "X2",
|
|
62
|
+
"class": "failure-modes",
|
|
63
|
+
"assumption": "P2",
|
|
64
|
+
"quote": "while True: resp = requests.post(endpoint.url",
|
|
65
|
+
"attack": "An endpoint that always answers 503 keeps its delivery in the loop for ever, and the delay doubles without a cap: by the 21st failure one sleep lasts about 12 days, so nothing is retried in any useful time.",
|
|
66
|
+
"impact": 3,
|
|
67
|
+
"plausibility": 4,
|
|
68
|
+
"check": "Run deliver() against a server that always answers 503 with time.sleep patched, and count the attempts and the delays."
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"id": "X3",
|
|
72
|
+
"class": "abuse",
|
|
73
|
+
"assumption": "P5",
|
|
74
|
+
"quote": "time.sleep(delay)",
|
|
75
|
+
"attack": "Whoever can register a webhook URL can point it at an endpoint that always answers 503: every event for that customer holds a worker for ever, so one tenant starves the deliveries of all the others.",
|
|
76
|
+
"impact": 4,
|
|
77
|
+
"plausibility": 3,
|
|
78
|
+
"check": "Register a test endpoint that always answers 503, send 50 events and watch worker utilisation."
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"id": "X4",
|
|
82
|
+
"class": "scale",
|
|
83
|
+
"assumption": "P5",
|
|
84
|
+
"quote": "time.sleep(delay)",
|
|
85
|
+
"attack": "Each retrying delivery blocks a worker for its whole backoff: when many customers deploy at the same time, the pool is full of sleeping deliveries and new events wait behind them.",
|
|
86
|
+
"impact": 3,
|
|
87
|
+
"plausibility": 3,
|
|
88
|
+
"check": "Simulate 200 endpoints answering 503 for 5 minutes and measure the queue time of a healthy endpoint."
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "X5",
|
|
92
|
+
"class": "dependency",
|
|
93
|
+
"assumption": "P3",
|
|
94
|
+
"quote": "so customers stop losing events during their deploys",
|
|
95
|
+
"attack": "Retrying a request that timed out can deliver the same event twice, and nothing in the diff adds an event id or idempotency key; receivers that are not idempotent will process it twice.",
|
|
96
|
+
"impact": 3,
|
|
97
|
+
"plausibility": 4,
|
|
98
|
+
"check": "Inspect a delivered payload and its headers for an event id."
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"id": "X6",
|
|
102
|
+
"class": "key-assumptions",
|
|
103
|
+
"assumption": "P4",
|
|
104
|
+
"quote": "if resp.status_code < 500:",
|
|
105
|
+
"attack": "A 429 Too Many Requests or a 408 Request Timeout is a 4xx that means try again later, but the loop treats it as final and drops the event.",
|
|
106
|
+
"impact": 3,
|
|
107
|
+
"plausibility": 3,
|
|
108
|
+
"check": "Run deliver() against a server that answers 429 once and then 200, and check whether the second call happens."
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"skipped_classes": [
|
|
112
|
+
{ "class": "reversibility", "reason": "Pure code change with no schema, queue or persisted state: reverting the commit restores the old behavior." }
|
|
113
|
+
]
|
|
114
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
id = "redteam"
|
|
2
|
+
name = "Red Team"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
family = "military"
|
|
5
|
+
status = "beta" # spec | beta | stable | reference
|
|
6
|
+
summary = "Attack a design doc or a PR with a fixed catalog of six attack classes; the engine rejects findings it cannot anchor in the text, builds an assumption matrix and ranks the top attacks."
|
|
7
|
+
|
|
8
|
+
[python]
|
|
9
|
+
module = "clarent_redteam" # importable package inside this folder; must expose register(subparsers) and main(argv)
|
|
10
|
+
|
|
11
|
+
[surfaces] # what this method ships today (the doctor checks that each 'true' exists)
|
|
12
|
+
cli = true
|
|
13
|
+
skill = true
|
|
14
|
+
agent = false
|
|
15
|
+
hook = false
|
|
16
|
+
mcp = false
|
|
17
|
+
action = false
|
|
18
|
+
|
|
19
|
+
# verification: read = opened and read | exists = confirmed to exist | blocked = exists, server blocks scripts | unverified = from memory
|
|
20
|
+
[[sources]]
|
|
21
|
+
title = "UFMCS Red Team Handbook v5 (15 Apr 2011). Read: Validating Assumptions pp. 85-88; Pre-mortem Analysis pp. 138-140; ADSO String of Pearls p. 140; Key Assumptions Check pp. 151-152; Devil's Advocacy p. 161; High-Impact/Low-Probability Analysis p. 165; What If? Analysis pp. 166-167; Red Team Analysis pp. 173-174"
|
|
22
|
+
url = "https://newandimproved.com/wp-content/uploads/2014/04/ufmcs_red_team_handbook_apr2011.pdf"
|
|
23
|
+
verification = "read"
|
|
24
|
+
|
|
25
|
+
[[sources]]
|
|
26
|
+
title = "Klein, Performing a Project Premortem, IEEE Engineering Management Review 2008 (reprint of the Harvard Business Review article of Sept 2007). Crossref record matched; the article text was not opened"
|
|
27
|
+
url = "https://doi.org/10.1109/EMR.2008.4534313"
|
|
28
|
+
verification = "exists"
|
|
29
|
+
|
|
30
|
+
[[sources]]
|
|
31
|
+
title = "Klein, Sources of Power: How People Make Decisions (MIT Press, 1998), the book the Handbook cites for the pre-mortem. Open Library record matched; not opened"
|
|
32
|
+
url = "https://openlibrary.org/works/OL2731587W"
|
|
33
|
+
verification = "exists"
|
|
34
|
+
|
|
35
|
+
[[sources]]
|
|
36
|
+
title = "Heuer & Pherson, Structured Analytic Techniques for Intelligence Analysis (3rd ed.)"
|
|
37
|
+
citation = "ISBN-10 150636893X (as listed in web search results; not opened)"
|
|
38
|
+
verification = "exists"
|
|
39
|
+
|
|
40
|
+
[novelty]
|
|
41
|
+
checked_on = "2026-11-25"
|
|
42
|
+
status = "exists-but-weak" # none | exists-but-weak | exists-but-abandoned | well-covered
|
|
43
|
+
evidence = "Prompt-only devil's advocate and plan stress-test skills exist (aaddrick/contrarian 43 stars; Hainrixz/abogado-del-diablo 43; orange2ai/devils-advocate-skill 33; five premortem skills of 30-88 stars). Adversarial PR review is established (liliu-z/magpie 180 stars; liatrio-labs/claude-code-gauntlet 13; YahampathChandika/adv-review 6, with a calibration benchmark), but its findings are verified by other LLM passes. None of the READMEs and file lists read describes an engine that rejects findings by checking quotes against the text, an assumption matrix with verified/unverified/contradicted status, or a fixed class catalog with coverage; the code of these repos was not read"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: redteam
|
|
3
|
+
description: Attack a design doc, ADR or PR with six fixed attack classes before approving it. A script rejects findings that are not quoted from the text or not backed by evidence, builds an assumption matrix and ranks the top 3 attacks.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
argument-hint: [path to a design doc | PR number]
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Red team — attack a design or a PR
|
|
9
|
+
|
|
10
|
+
You are the red team. Your job is to find what the author did not, **and to prove each finding is anchored in the text**. A bundled script rejects any finding whose quote is not in the target or whose evidence does not exist; it does not judge whether you are right, so be right.
|
|
11
|
+
|
|
12
|
+
Target: $ARGUMENTS
|
|
13
|
+
|
|
14
|
+
## Tooling
|
|
15
|
+
|
|
16
|
+
Stdlib-only Python. Use whichever of `python3` / `python` exists:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
python3 "${CLAUDE_SKILL_DIR}/scripts/run.py" catalog # the six classes, their questions, the 1-5 scales
|
|
20
|
+
python3 "${CLAUDE_SKILL_DIR}/scripts/run.py" init .clarent/redteam/<slug>.json --target <file>
|
|
21
|
+
python3 "${CLAUDE_SKILL_DIR}/scripts/run.py" check .clarent/redteam/<slug>.json
|
|
22
|
+
python3 "${CLAUDE_SKILL_DIR}/scripts/run.py" top .clarent/redteam/<slug>.json
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Add `--lang es` before the subcommand for Spanish output. In the findings file set `"root"` to the repository root relative to the file (for `.clarent/redteam/x.json`, `"../.."`): target files and `file:line` refs are resolved from there. `init` does this when you run it from the repo root.
|
|
26
|
+
|
|
27
|
+
## Procedure
|
|
28
|
+
|
|
29
|
+
1. **Get the target as files.**
|
|
30
|
+
- A design doc: its path.
|
|
31
|
+
- A PR: `gh pr view <n> --json title,body -q '"# "+.title+"\n\n"+.body' > .clarent/redteam/<slug>/description.md` and `gh pr diff <n> > .clarent/redteam/<slug>/change.diff`; list both under `target.files` with `"kind": "pr"`.
|
|
32
|
+
2. **Read the target and `catalog`.** Do not attack anything you have not read.
|
|
33
|
+
3. **List assumptions** (the key assumptions check): what must be true for this to work, **including what the text never says** (ordering, who calls it, volume, environment, rollback). For each: `id`, `text`, a `quote` copied character by character from a passage it rests on (at least 12 characters), `status: "unverified"` and a `check` (a command or a concrete question that would settle it). Prefer 5–8 that matter over 15 that do not.
|
|
34
|
+
4. **Verify what you can by running things.** Read the code, run the command, grep the callers. Then:
|
|
35
|
+
- `contradicted`: you found something that says it is false → add `evidence: [{ "ref": "path:line" or the command you ran, "observation": "what it showed" }]`.
|
|
36
|
+
- `verified`: you found something that says it holds → same evidence.
|
|
37
|
+
- Anything you merely believe stays `unverified`. A `ref` you did not produce this session is an invented ref.
|
|
38
|
+
5. **Attack, class by class.** For each of `key-assumptions`, `failure-modes`, `abuse`, `scale`, `dependency`, `reversibility`: write at least one attack, or add the class to `skipped_classes` with a real reason. Each attack: `assumption` (the one it attacks), `quote` (literal, from the target), `attack` (what goes wrong if the assumption is false or abused, in concrete terms: no "be careful with scalability"), `check` (how to confirm it), `impact` and `plausibility` 1–5 using the rubric printed by `catalog`. Rate honestly; the script raises plausibility itself where you proved the assumption false.
|
|
39
|
+
6. **Run `check`.** Read **Rejected findings first**. Fix each one by finding the real passage or the real evidence; never loosen a quote to make it match, never delete the check that failed. Re-run until nothing is rejected.
|
|
40
|
+
7. **Verify next.** Do the top items of that list (run the `check` commands), update statuses and evidence, re-run. Stop after 2 rounds or when the top 3 no longer rest on unverified assumptions.
|
|
41
|
+
|
|
42
|
+
## Reporting
|
|
43
|
+
|
|
44
|
+
Paste the Markdown report. Lead with the top 3 attacks and what to verify first. Say that the ranking is a prioritization, **not a probability**, and that the script proves findings are anchored and backed, not that they are correct. If a class was skipped, say why in one line.
|
|
45
|
+
|
|
46
|
+
## Rules
|
|
47
|
+
|
|
48
|
+
- Quote, do not paraphrase: copy the passage. Do not attack text that is not in the target.
|
|
49
|
+
- Never mark `verified` or `contradicted` without evidence you produced; never invent a `file:line`.
|
|
50
|
+
- Do not pad: a rejected or duplicate finding is noise. Three real attacks beat ten generic ones.
|
|
51
|
+
- Do not edit the target while attacking it. If asked to fix the design afterwards, do it as a separate step and re-run `check` on the new text.
|
|
52
|
+
- For CI: `check --fail-on S1` exits 1 if an accepted attack is that severe.
|