openenvforge commited on
Commit
f3b0a91
·
verified ·
1 Parent(s): d4c618d

3amBench v0.1.0

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -59
  2. .gitignore +13 -0
  3. LICENSE +201 -0
  4. NOTICE.md +17 -0
  5. README.md +199 -0
  6. generator/generate.py +24 -0
  7. manifest.jsonl +30 -0
  8. null/af-001-slo-onboarding-easy-s1/solve.sh +3 -0
  9. null/af-002-slo-onboarding-easy-s2/solve.sh +3 -0
  10. null/af-003-slo-onboarding-medium-s1/solve.sh +3 -0
  11. null/af-004-slo-onboarding-medium-s2/solve.sh +3 -0
  12. null/af-005-slo-onboarding-hard-s1/solve.sh +3 -0
  13. null/af-006-slo-onboarding-hard-s2/solve.sh +3 -0
  14. null/af-007-alert-storm-cleanup-easy-s1/solve.sh +3 -0
  15. null/af-008-alert-storm-cleanup-easy-s2/solve.sh +3 -0
  16. null/af-009-alert-storm-cleanup-medium-s1/solve.sh +3 -0
  17. null/af-010-alert-storm-cleanup-medium-s2/solve.sh +3 -0
  18. null/af-011-alert-storm-cleanup-hard-s1/solve.sh +3 -0
  19. null/af-012-alert-storm-cleanup-hard-s2/solve.sh +3 -0
  20. null/af-013-missed-page-postmortem-easy-s1/solve.sh +3 -0
  21. null/af-014-missed-page-postmortem-easy-s2/solve.sh +3 -0
  22. null/af-015-missed-page-postmortem-medium-s1/solve.sh +3 -0
  23. null/af-016-missed-page-postmortem-medium-s2/solve.sh +3 -0
  24. null/af-017-missed-page-postmortem-hard-s1/solve.sh +3 -0
  25. null/af-018-missed-page-postmortem-hard-s2/solve.sh +3 -0
  26. null/af-019-latency-slo-easy-s1/solve.sh +3 -0
  27. null/af-020-latency-slo-easy-s2/solve.sh +3 -0
  28. null/af-021-latency-slo-medium-s1/solve.sh +3 -0
  29. null/af-022-latency-slo-medium-s2/solve.sh +3 -0
  30. null/af-023-latency-slo-hard-s1/solve.sh +3 -0
  31. null/af-024-latency-slo-hard-s2/solve.sh +3 -0
  32. null/af-025-team-reorg-migration-easy-s1/solve.sh +3 -0
  33. null/af-026-team-reorg-migration-easy-s2/solve.sh +3 -0
  34. null/af-027-team-reorg-migration-medium-s1/solve.sh +3 -0
  35. null/af-028-team-reorg-migration-medium-s2/solve.sh +3 -0
  36. null/af-029-team-reorg-migration-hard-s1/solve.sh +3 -0
  37. null/af-030-team-reorg-migration-hard-s2/solve.sh +3 -0
  38. openenv/alertforge_env/README.md +51 -0
  39. openenv/alertforge_env/__init__.py +5 -0
  40. openenv/alertforge_env/client.py +7 -0
  41. openenv/alertforge_env/models.py +37 -0
  42. openenv/alertforge_env/openenv.yaml +23 -0
  43. openenv/alertforge_env/pyproject.toml +17 -0
  44. openenv/alertforge_env/server/Dockerfile +19 -0
  45. openenv/alertforge_env/server/__init__.py +0 -0
  46. openenv/alertforge_env/server/alertforge_environment.py +100 -0
  47. openenv/alertforge_env/server/app.py +20 -0
  48. partial/af-001-slo-onboarding-easy-s1/solve.sh +176 -0
  49. partial/af-002-slo-onboarding-easy-s2/solve.sh +176 -0
  50. partial/af-003-slo-onboarding-medium-s1/solve.sh +259 -0
.gitattributes CHANGED
@@ -1,60 +1,2 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.avro filter=lfs diff=lfs merge=lfs -text
4
- *.bin filter=lfs diff=lfs merge=lfs -text
5
- *.bz2 filter=lfs diff=lfs merge=lfs -text
6
- *.ckpt filter=lfs diff=lfs merge=lfs -text
7
- *.ftz filter=lfs diff=lfs merge=lfs -text
8
- *.gz filter=lfs diff=lfs merge=lfs -text
9
- *.h5 filter=lfs diff=lfs merge=lfs -text
10
- *.joblib filter=lfs diff=lfs merge=lfs -text
11
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
12
- *.lz4 filter=lfs diff=lfs merge=lfs -text
13
- *.mds filter=lfs diff=lfs merge=lfs -text
14
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
15
- *.model filter=lfs diff=lfs merge=lfs -text
16
- *.msgpack filter=lfs diff=lfs merge=lfs -text
17
- *.npy filter=lfs diff=lfs merge=lfs -text
18
- *.npz filter=lfs diff=lfs merge=lfs -text
19
- *.onnx filter=lfs diff=lfs merge=lfs -text
20
- *.ot filter=lfs diff=lfs merge=lfs -text
21
- *.parquet filter=lfs diff=lfs merge=lfs -text
22
- *.pb filter=lfs diff=lfs merge=lfs -text
23
- *.pickle filter=lfs diff=lfs merge=lfs -text
24
- *.pkl filter=lfs diff=lfs merge=lfs -text
25
- *.pt filter=lfs diff=lfs merge=lfs -text
26
- *.pth filter=lfs diff=lfs merge=lfs -text
27
- *.rar filter=lfs diff=lfs merge=lfs -text
28
- *.safetensors filter=lfs diff=lfs merge=lfs -text
29
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
30
- *.tar.* filter=lfs diff=lfs merge=lfs -text
31
- *.tar filter=lfs diff=lfs merge=lfs -text
32
- *.tflite filter=lfs diff=lfs merge=lfs -text
33
- *.tgz filter=lfs diff=lfs merge=lfs -text
34
- *.wasm filter=lfs diff=lfs merge=lfs -text
35
- *.xz filter=lfs diff=lfs merge=lfs -text
36
- *.zip filter=lfs diff=lfs merge=lfs -text
37
- *.zst filter=lfs diff=lfs merge=lfs -text
38
- *tfevents* filter=lfs diff=lfs merge=lfs -text
39
- # Audio files - uncompressed
40
- *.pcm filter=lfs diff=lfs merge=lfs -text
41
- *.sam filter=lfs diff=lfs merge=lfs -text
42
- *.raw filter=lfs diff=lfs merge=lfs -text
43
- # Audio files - compressed
44
- *.aac filter=lfs diff=lfs merge=lfs -text
45
- *.flac filter=lfs diff=lfs merge=lfs -text
46
- *.mp3 filter=lfs diff=lfs merge=lfs -text
47
- *.ogg filter=lfs diff=lfs merge=lfs -text
48
- *.wav filter=lfs diff=lfs merge=lfs -text
49
- # Image files - uncompressed
50
- *.bmp filter=lfs diff=lfs merge=lfs -text
51
- *.gif filter=lfs diff=lfs merge=lfs -text
52
  *.png filter=lfs diff=lfs merge=lfs -text
53
- *.tiff filter=lfs diff=lfs merge=lfs -text
54
- # Image files - compressed
55
- *.jpg filter=lfs diff=lfs merge=lfs -text
56
- *.jpeg filter=lfs diff=lfs merge=lfs -text
57
- *.webp filter=lfs diff=lfs merge=lfs -text
58
- # Video files - compressed
59
- *.mp4 filter=lfs diff=lfs merge=lfs -text
60
- *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  *.png filter=lfs diff=lfs merge=lfs -text
2
+ *.parquet filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
.gitignore ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ .venv/
5
+ .DS_Store
6
+ dist/
7
+ .claude/
8
+ .claude-flow/
9
+ CLAUDE.md
10
+ .mcp.json
11
+ .swarm/
12
+ .hive-mind/
13
+ *.egg-info/
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
NOTICE.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NOTICE
2
+
3
+ 3amBench / AlertForge is licensed under the Apache License 2.0 (see LICENSE).
4
+
5
+ ## Third-party material
6
+
7
+ - **Distractor alert rules** (`src/alertforge/distractors.py`, and the `rules/{node-exporter,kubernetes,blackbox,
8
+ postgres,redis,kafka,nginx,jvm}.yml` files in generated tasks) are written in the style of, and several are
9
+ adapted from, [samber/awesome-prometheus-alerts](https://github.com/samber/awesome-prometheus-alerts)
10
+ (CC BY 4.0) and [kubernetes-monitoring/kubernetes-mixin](https://github.com/kubernetes-monitoring/kubernetes-mixin)
11
+ (Apache-2.0). Changes: rule names kept, expressions simplified, `for`/thresholds adjusted, labels set to
12
+ `{severity, team}`, runbook URLs rewritten to each task's fictional domain.
13
+ - **Tools** used by the grader, shipped inside the task image (not in this repository):
14
+ `promtool` from Prometheus v3.5.0 and `amtool` from Alertmanager v0.28.1 (Apache-2.0).
15
+ - The multiwindow, multi-burn-rate recipe follows the Google SRE Workbook, chapter 5 "Alerting on SLOs".
16
+
17
+ All companies, services, teams and incidents in the tasks are fictional.
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pretty_name: "3amBench (AlertForge)"
4
+ language: [en]
5
+ task_categories: [other]
6
+ size_categories: [n<1K]
7
+ tags: [harbor, openenv, rl-environment, agent, benchmark, dense-reward, prometheus, alertmanager, promql, sre, slo, observability]
8
+ configs:
9
+ - config_name: default
10
+ data_files: manifest.jsonl
11
+ ---
12
+
13
+ # 3amBench: can your agent write alerts that page the right human at 3 a.m., and only then?
14
+
15
+ 3amBench (package `alertforge`) is an RL environment and benchmark for a job SRE teams do every week:
16
+ owning **Prometheus alerting rules and Alertmanager routing as code**. Each task drops the agent into a realistic
17
+ `monitoring/` repo for a fictional company with a handful of change requests: onboard a service onto
18
+ multi-window burn-rate SLO alerts, fix the alert that paged 30 times last night, find out why nobody was paged
19
+ when a service was down for 47 minutes, route a newly formed team, add inhibition so an outage produces one page
20
+ instead of forty.
21
+
22
+ **Grading is behavioral.** Nothing is judged by an LLM, and nothing is compared as text. Hidden, seed-varied
23
+ outage replays run through Prometheus' own `promtool test rules`, and routing runs through Alertmanager's own
24
+ `amtool`. Every alert must **fire** during the outage, stay **silent** during normal traffic, short spikes,
25
+ recovery, low traffic and near-threshold traffic, fire **on time** (not before `for` elapses), fire **once per
26
+ service** (not per pod), carry the right **labels**, and reach the right **receivers**. A task has 59-189
27
+ atomic checks, so the reward is dense.
28
+
29
+ | | |
30
+ |---|---|
31
+ | Tasks | 30 (5 workflows × 3 tiers × 2 seeds), plus unlimited fresh ones from the generator / OpenEnv server |
32
+ | Checks per task | 59-189 (easy 59-67, medium 112-139, hard 167-189) |
33
+ | Reward | `reward` in [0, 1] plus 15 diagnostic keys, identical in every task |
34
+ | Grader | promtool 3.5.0 + amtool 0.28.1 + stdlib Python + PyYAML; 0.7-7 s per grade, deterministic |
35
+ | Formats | Harbor tasks (this repo) and an OpenEnv server with per-step reward (`openenv/alertforge_env`) |
36
+
37
+ ## Quick start
38
+
39
+ ```bash
40
+ # oracle (expect mean 1.0) and no-op (expect 0.0)
41
+ uvx harbor run --repo https://huggingface.co/datasets/openenvforge/3ambench@v0.1.0 -d 3ambench@0.1.0 -a oracle -n 4
42
+ uvx harbor run --repo https://huggingface.co/datasets/openenvforge/3ambench@v0.1.0 -d 3ambench@0.1.0 -a nop -n 4
43
+ # your model on the 5-task smoke set
44
+ uvx harbor run --repo https://huggingface.co/datasets/openenvforge/3ambench@v0.1.0 -d 3ambench-mini@0.1.0 -a terminus-2 -m <model>
45
+ ```
46
+
47
+ Tasks set `[agent] network_mode = "no-network"`, because this repo ships the solutions (see Anti-hacking).
48
+ Harbor enforces that on Linux Docker hosts and sandboxed providers. **Docker Desktop on macOS cannot enforce it**
49
+ (its VM kernel lacks `CONFIG_NFT_FIB_INET`), and Harbor refuses the task. For local smoke runs on a Mac, use
50
+ `scripts/harbor_local.sh`, which runs a temp copy without the network override. Those runs are not leaderboard-safe.
51
+
52
+ **OpenEnv (multi-turn, per-step reward):**
53
+ ```python
54
+ from alertforge_env.client import AlertForgeEnv
55
+ with AlertForgeEnv(base_url="https://openenvforge-3ambench-env.hf.space").sync() as env:
56
+ obs = env.reset(seed=7, split="train", workflow="missed-page-postmortem", tier="medium")
57
+ obs = env.step({"tool": "read_file", "path": "README.md"})
58
+ obs = env.step({"tool": "write_file", "path": "rules/service-health.yml", "content": "..."})
59
+ print(obs.reward, obs.done) # parity mode: rewards sum to the Harbor reward
60
+ ```
61
+
62
+ **Fresh tasks (training, private held-out sets):** `python generator/generate.py --master-seed <secret>`.
63
+
64
+ ## What a task looks like
65
+
66
+ `af-001-slo-onboarding-easy-s1` (instruction excerpt; change requests are shuffled):
67
+
68
+ > - **P1.** `HighErrorRatio` is misbehaving; see `postmortems/PM-4043.md`. Fix the rule, keeping its purpose.
69
+ > - **I1.** While `ChatGwDown` is firing for a service, suppress `ChatGwErrorBudgetBurnFast`, `HighErrorRatio` for that same service only.
70
+ > - **A1.** Add `ChatGwErrorBudgetBurnFast` for `chat-gw` (SLO 0.995): fire when both `slo:sli_error:ratio_rate1h` and `slo:sli_error:ratio_rate5m` exceed 14.4 × (1 − 0.995), `for: 2m`, ...
71
+ > - **R1.** Team `payments` is now on call for `chat-gw`, but nothing routes to them yet. ...
72
+ > - **C1.** Add SLI recording rules `slo:sli_error:ratio_rate5m`, `slo:sli_error:ratio_rate1h` for the `grpc` SLI family ...
73
+
74
+ The postmortem describes a *symptom* ("pages at 4 a.m. when there are only a handful of requests"), never the
75
+ fix. At the `practitioner`/`expert` levels, requirements are stated as outcomes ("page payments when chat-gw is
76
+ burning its error budget fast") and the agent has to find names, windows, `for` values, labels and routing
77
+ policy in the repo's `README.md`, like a new hire would.
78
+
79
+ Workflows: `slo-onboarding`, `alert-storm-cleanup`, `missed-page-postmortem` (including total outages where
80
+ series disappear, so only `absent()` can page), `latency-slo` (histogram SLIs), `team-reorg-migration`.
81
+ Rules come as plain files or as Kubernetes `PrometheusRule` manifests.
82
+
83
+ ## Reward
84
+
85
+ Each requirement r gets a score q_r from its check families (`mean(∅) = 1`):
86
+
87
+ ```
88
+ Alert (new or repair): q = E · dup · mean(Fire ∪ Timing) · mean(Silent) · (0.7 + 0.3·mean(Label ∪ Annotation))
89
+ (burn alerts: q = ½·q_integrated + ½·q_with_reference_SLI_records)
90
+ Recording: q = dup · mean(Value ∪ Cardinality)
91
+ Route: q = mean_positive Jaccard(expected, resolved receivers) · mean_negative [no forbidden receiver]
92
+ Inhibit: q = mean(Suppressed) · mean(NotSuppressed)
93
+ s_r = clip((q_r − q_r^pristine) / (1 − q_r^pristine), −0.25, 1) # pristine → 0, oracle → 1, regressions < 0
94
+ progress = max(0, (0.5 + 0.5·preservation) · Σ w_r s_r / Σ w_r) # weights: alert 3, repair 3, others 2
95
+ reward = 0.6 · [every s_r = 1 ∧ preservation = 1 ∧ syntax_ok ∧ ¬tamper] + 0.4 · progress
96
+ ```
97
+
98
+ Why products: an always-firing rule fails every silent check, and a renamed or never-firing rule fails every
99
+ fire check, so both score 0. A catch-all route passes positives and fails negatives. An inhibit-everything rule
100
+ fails the not-suppressed cases. Partial work still counts: a wrong severity costs the label family only, a
101
+ missing `continue` gives Jaccard ½, and a correct burn alert on top of broken SLI records keeps half its credit.
102
+
103
+ | Key | Meaning |
104
+ |---|---|
105
+ | `reward` | primary scalar |
106
+ | `solved` / `outcome` | 1 iff everything is fully correct (use for pass@k) |
107
+ | `progress` | the dense part (plot this separately; `reward` has a gap between 0.4 and 0.6 by construction) |
108
+ | `preservation` | untouched rules, receivers, routes and inhibitions still intact |
109
+ | `req_alerts`, `req_repairs`, `req_recording`, `req_routing`, `req_inhibit` | per-category scores |
110
+ | `fire_rate`, `silent_rate`, `label_rate`, `check_pass_rate` | raw diagnostic pass rates (non-zero for a no-op) |
111
+ | `syntax_ok`, `tamper` | all files load / a forbidden construct was used (tamper zeroes the reward) |
112
+
113
+ ## Reward spread (measured, v0.1.0)
114
+
115
+ | Policy | reward | notes |
116
+ |---|---|---|
117
+ | oracle (`solution/solve.sh`) | **1.0** on 30/30 | Harbor `-a oracle`: 1.0 on `af-001` (easy), `af-017` (hard, PrometheusRule), `af-023` (hard, latency), `af-029` (hard, reorg) |
118
+ | no-op (`-a nop`) | **0.0** on 30/30 | `preservation` = 1 |
119
+ | partial (`partial/<task>/solve.sh`: half the requirements plus one plausible mistake) | 0.17-0.29 | Harbor = local grader exactly (`af-017` 0.21644, `af-011` 0.208481) |
120
+ | P-mut: oracle + 1-3 agent-style mistakes (duplicate alert, missing `by`, missing `continue`, scratch file, YAML indent slip, wrong `for`), 120 episodes | mean 0.386, 0% at 0, 10% at 1, 94 distinct values | `progress` mean 0.81 |
121
+ | OpenEnv per step (read → write oracle files one at a time with one YAML slip → submit), 30 tasks | 54% of steps and 97% of writes change the reward | Σ step rewards = Harbor reward exactly (parity mode) |
122
+
123
+ Adversaries (all 30 tasks, local gate): always-fire, rename, catch-all route, inhibit-all → targeted
124
+ `req_*` ≤ 0.05. `ALERTS` injection, input-series shadowing, group `interval` changes → `tamper`, reward 0.
125
+ Receiver nulling, over-broad inhibition, band thresholds, per-pod alerts, `for`-only fixes, deleting untouched
126
+ rules → `outcome` 0 and reward ≤ 0.4.
127
+
128
+ Real-model baselines are **not published yet**; they need API spend (planned milestone M-H: leaderboard,
129
+ failure gallery, dense-vs-outcome GRPO curve).
130
+
131
+ ## How it was built: Skill2Env, but procedural
132
+
133
+ This mirrors NVIDIA's [Skill2Env](https://github.com/NVlabs/Skill2Env) pipeline:
134
+ `skill/prometheus-alerting/SKILL.md` → `workflows/workflows.yaml` (the "planner output", same keys) → sampled
135
+ axes (archetype, verifier pattern, persona, tone, expertise, tier, rules format) → **a deterministic, seeded
136
+ creator** instead of an LLM → acceptance gate (oracle = 1, nop = 0, partial band, 14 adversaries, a
137
+ "missing `for` must fail Timing" mutant check, structural leak scan, determinism).
138
+
139
+ Checks are derived from the world spec through a **reference evaluator** (`promsim.py`: Prometheus `rate`
140
+ extrapolation, left-open windows, `histogram_quantile`, staleness, the `for` state machine, in exact fractions),
141
+ never from the oracle's rule text. The gate proves the oracle against real promtool, which is the structural
142
+ equivalent of Skill2Env's freeze boundary.
143
+
144
+ ## Anti-hacking
145
+
146
+ | Threat | Defense |
147
+ |---|---|
148
+ | Downloading this repo's solutions | `[agent] network_mode = "no-network"`; no seeds in `task.toml`; hidden checks live only in the verifier image; evaluate headline numbers on a private-seed build |
149
+ | Editing the grader or pre-writing rewards | separate verifier container built from `tests/Dockerfile`; `test.sh` deletes old outputs and verifies `checksums.sha256` |
150
+ | Always-fire / never-fire / rename | fire × silent product; existence gate |
151
+ | Per-pod alerts, threshold bands, `for`-only fixes | `count(ALERTS{...}) == 1` per service, bracketing scenarios at 0.85T/1.15T, random spikes, long spikes that must fire |
152
+ | Faking `ALERTS`, shadowing input series, eval knobs | tamper: reserved record names, `label_replace` onto reserved labels, group `interval`/`query_offset`/`limit` |
153
+ | Null receivers, mute intervals, inhibit-everything | receivers, `global` hashed into preservation; time intervals are tamper; not-suppressed and bystander cases |
154
+ | Copying a healthy sibling | hard tier has no healthy sibling burn alerts; structural leak scan |
155
+ | Postmortem lookup tables | 3-4 paraphrases per symptom, decoy postmortems, defects with no postmortem on hard |
156
+ | Reward oracle in OpenEnv | `heldout`/`public` splits force outcome-only reward and hide `phi` |
157
+
158
+ ## Related work
159
+
160
+ - [NVlabs/Skill2Env](https://github.com/NVlabs/Skill2Env): the SkillHub `sre-engineer` skill contains a literal
161
+ 14.4x burn-rate rule, and `slo-architect` covers burn-rate alerting. We downloaded ten SRE-adjacent Skill2Env
162
+ tasks. The closest one (`task_slo-architect_lgre556n`) grades burn-rate policy by comparing YAML fields, and none
163
+ run promtool or amtool.
164
+ - [camel-ai/seta-env](https://github.com/camel-ai/seta-env) task 1114: Alertmanager routing and inhibition checked with
165
+ amtool. 3amBench's routing checks are end-to-end: the chain case routes the labels the agent's own alert
166
+ carries.
167
+ - Community rule sets: [samber/awesome-prometheus-alerts](https://github.com/samber/awesome-prometheus-alerts),
168
+ [kubernetes-mixin](https://github.com/kubernetes-monitoring/kubernetes-mixin); Google SRE Workbook ch. 5.
169
+
170
+ ## Limitations
171
+
172
+ - Traffic is synthetic (diurnal shape plus jitter), and services are fictional.
173
+ - Inhibition is graded by a strict simulator of Alertmanager's semantics, not by the Alertmanager process.
174
+ Unsupported constructs fail closed.
175
+ - Seven alert templates host the defects, not a large upstream corpus.
176
+ - The routing chain case uses the agent's static labels, not labels observed in `ALERTS`.
177
+ - The easy tier may saturate for frontier models; this is unmeasured.
178
+ - **Contamination:** SkillHub skills (and any skill-augmented agent) already contain near-identical burn-rate
179
+ recipes, and this repo ships solutions. Evaluate on a private-seed build, and report whether the agent had
180
+ `SKILL.md`.
181
+ - English only.
182
+
183
+ ## Repository layout
184
+
185
+ `tasks/` (Harbor tasks) · `registry.json` (`3ambench`, `3ambench-mini`) · `manifest.jsonl` (one row per
186
+ task) · `partial/`, `null/` (reference policies) · `skill/`, `workflows/` · `generator/generate.py` + `src/alertforge/` (the generator and grader source) ·
187
+ `openenv/alertforge_env/` (OpenEnv server) · `scripts/` · `tests/` (pytest).
188
+
189
+ ## License and citation
190
+
191
+ Apache-2.0; see `NOTICE.md` for attribution of adapted community rules (CC BY 4.0 / Apache-2.0).
192
+
193
+ ```bibtex
194
+ @misc{3ambench2026,
195
+ title = {3amBench: a behaviorally graded, dense-reward RL environment for Prometheus alerting as code},
196
+ year = {2026},
197
+ note = {Harbor dataset and OpenEnv environment; generator package alertforge v0.1.0}
198
+ }
199
+ ```
generator/generate.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Render the 3amBench tasks from templates + seed data, deterministically by master seed.
3
+
4
+ python generator/generate.py # the released 30 tasks (master seed 20260928)
5
+ python generator/generate.py --master-seed 4242 # a private held-out build with the same layout
6
+ python generator/generate.py --only latency-slo # a subset
7
+
8
+ Needs promtool and amtool (PATH, or AF_PROMTOOL / AF_AMTOOL): the builder grades the pristine repo to
9
+ compute q_pristine and runs the local acceptance gate (oracle 1.0, null 0.0, partial band, adversaries).
10
+ The generator code itself lives in src/alertforge (world.py → checks.py → render.py → gate.py).
11
+ """
12
+ import os
13
+ import sys
14
+
15
+ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
16
+ sys.path.insert(0, os.path.join(ROOT, "src"))
17
+
18
+ from alertforge.cli import main # noqa: E402
19
+
20
+ if __name__ == "__main__":
21
+ args = sys.argv[1:]
22
+ if "--out" not in args:
23
+ args = ["--out", ROOT, *args]
24
+ sys.exit(main(["build", *args]))
manifest.jsonl ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"task_id": "af-001-slo-onboarding-easy-s1", "workflow": "slo-onboarding", "tier": "easy", "archetype": "operate_configure", "primary_verifier_pattern": "regression_suite", "persona": "platform_engineer", "tone": "terse", "expertise": "novice", "rules_format": "plain", "services": ["chat-gw"], "n_requirements": 5, "n_checks": 66, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.167133, "null_reward": 0.0, "grader_seconds": 1.27, "generator_version": "0.1.0"}
2
+ {"task_id": "af-002-slo-onboarding-easy-s2", "workflow": "slo-onboarding", "tier": "easy", "archetype": "operate_configure", "primary_verifier_pattern": "regression_suite", "persona": "platform_engineer", "tone": "urgent-pager", "expertise": "novice", "rules_format": "plain", "services": ["loyalty-api"], "n_requirements": 5, "n_checks": 66, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.258651, "null_reward": 0.0, "grader_seconds": 1.27, "generator_version": "0.1.0"}
3
+ {"task_id": "af-003-slo-onboarding-medium-s1", "workflow": "slo-onboarding", "tier": "medium", "archetype": "author_to_constraints", "primary_verifier_pattern": "behavioral_simulation", "persona": "site_reliability_engineer", "tone": "neutral", "expertise": "practitioner", "rules_format": "prometheusrule", "services": ["loyalty-svc", "ingest-gw"], "n_requirements": 9, "n_checks": 139, "req_counts": {"req_alerts": 2, "req_repairs": 3, "req_recording": 1, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.254341, "null_reward": 0.0, "grader_seconds": 3.0, "generator_version": "0.1.0"}
4
+ {"task_id": "af-004-slo-onboarding-medium-s2", "workflow": "slo-onboarding", "tier": "medium", "archetype": "operate_configure", "primary_verifier_pattern": "regression_suite", "persona": "platform_engineer", "tone": "terse", "expertise": "practitioner", "rules_format": "prometheusrule", "services": ["orders-worker", "media-api"], "n_requirements": 9, "n_checks": 138, "req_counts": {"req_alerts": 2, "req_repairs": 3, "req_recording": 1, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.250639, "null_reward": 0.0, "grader_seconds": 2.61, "generator_version": "0.1.0"}
5
+ {"task_id": "af-005-slo-onboarding-hard-s1", "workflow": "slo-onboarding", "tier": "hard", "archetype": "author_to_constraints", "primary_verifier_pattern": "behavioral_simulation", "persona": "site_reliability_engineer", "tone": "urgent-pager", "expertise": "practitioner", "rules_format": "plain", "services": ["shipping-api", "chat-edge", "cart-edge"], "n_requirements": 14, "n_checks": 176, "req_counts": {"req_alerts": 3, "req_repairs": 5, "req_recording": 2, "req_routing": 2, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.212933, "null_reward": 0.0, "grader_seconds": 4.26, "generator_version": "0.1.0"}
6
+ {"task_id": "af-006-slo-onboarding-hard-s2", "workflow": "slo-onboarding", "tier": "hard", "archetype": "author_to_constraints", "primary_verifier_pattern": "behavioral_simulation", "persona": "site_reliability_engineer", "tone": "terse", "expertise": "expert", "rules_format": "prometheusrule", "services": ["fraud-svc", "wishlist-api", "inventory-svc"], "n_requirements": 14, "n_checks": 181, "req_counts": {"req_alerts": 3, "req_repairs": 5, "req_recording": 2, "req_routing": 2, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.208439, "null_reward": 0.0, "grader_seconds": 4.51, "generator_version": "0.1.0"}
7
+ {"task_id": "af-007-alert-storm-cleanup-easy-s1", "workflow": "alert-storm-cleanup", "tier": "easy", "archetype": "harden_secure", "primary_verifier_pattern": "adversarial_corpus", "persona": "on_call_engineer", "tone": "terse", "expertise": "novice", "rules_format": "plain", "services": ["orders-svc"], "n_requirements": 5, "n_checks": 64, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.285102, "null_reward": 0.0, "grader_seconds": 1.03, "generator_version": "0.1.0"}
8
+ {"task_id": "af-008-alert-storm-cleanup-easy-s2", "workflow": "alert-storm-cleanup", "tier": "easy", "archetype": "harden_secure", "primary_verifier_pattern": "adversarial_corpus", "persona": "on_call_engineer", "tone": "urgent-pager", "expertise": "novice", "rules_format": "plain", "services": ["catalog-api"], "n_requirements": 5, "n_checks": 64, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.262312, "null_reward": 0.0, "grader_seconds": 1.0, "generator_version": "0.1.0"}
9
+ {"task_id": "af-009-alert-storm-cleanup-medium-s1", "workflow": "alert-storm-cleanup", "tier": "medium", "archetype": "harden_secure", "primary_verifier_pattern": "adversarial_corpus", "persona": "on_call_engineer", "tone": "urgent-pager", "expertise": "novice", "rules_format": "prometheusrule", "services": ["report-worker", "billing-svc"], "n_requirements": 10, "n_checks": 124, "req_counts": {"req_alerts": 2, "req_repairs": 4, "req_recording": 1, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.253641, "null_reward": 0.0, "grader_seconds": 2.01, "generator_version": "0.1.0"}
10
+ {"task_id": "af-010-alert-storm-cleanup-medium-s2", "workflow": "alert-storm-cleanup", "tier": "medium", "archetype": "repair_debug", "primary_verifier_pattern": "regression_suite", "persona": "site_reliability_engineer", "tone": "urgent-pager", "expertise": "novice", "rules_format": "plain", "services": ["checkout-worker", "cart-edge"], "n_requirements": 10, "n_checks": 116, "req_counts": {"req_alerts": 2, "req_repairs": 4, "req_recording": 1, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.230701, "null_reward": 0.0, "grader_seconds": 1.67, "generator_version": "0.1.0"}
11
+ {"task_id": "af-011-alert-storm-cleanup-hard-s1", "workflow": "alert-storm-cleanup", "tier": "hard", "archetype": "harden_secure", "primary_verifier_pattern": "adversarial_corpus", "persona": "on_call_engineer", "tone": "terse", "expertise": "practitioner", "rules_format": "plain", "services": ["inventory-svc", "ledger-gw", "ratings-svc"], "n_requirements": 14, "n_checks": 176, "req_counts": {"req_alerts": 2, "req_repairs": 6, "req_recording": 2, "req_routing": 2, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.208481, "null_reward": 0.0, "grader_seconds": 4.55, "generator_version": "0.1.0"}
12
+ {"task_id": "af-012-alert-storm-cleanup-hard-s2", "workflow": "alert-storm-cleanup", "tier": "hard", "archetype": "harden_secure", "primary_verifier_pattern": "adversarial_corpus", "persona": "on_call_engineer", "tone": "neutral", "expertise": "expert", "rules_format": "prometheusrule", "services": ["fraud-api", "promo-svc", "auth-edge"], "n_requirements": 14, "n_checks": 182, "req_counts": {"req_alerts": 2, "req_repairs": 6, "req_recording": 2, "req_routing": 2, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.182729, "null_reward": 0.0, "grader_seconds": 5.79, "generator_version": "0.1.0"}
13
+ {"task_id": "af-013-missed-page-postmortem-easy-s1", "workflow": "missed-page-postmortem", "tier": "easy", "archetype": "repair_debug", "primary_verifier_pattern": "behavioral_simulation", "persona": "incident_commander", "tone": "neutral", "expertise": "novice", "rules_format": "plain", "services": ["pricing-gw"], "n_requirements": 5, "n_checks": 62, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.239609, "null_reward": 0.0, "grader_seconds": 1.16, "generator_version": "0.1.0"}
14
+ {"task_id": "af-014-missed-page-postmortem-easy-s2", "workflow": "missed-page-postmortem", "tier": "easy", "archetype": "data_query", "primary_verifier_pattern": "exact_state", "persona": "site_reliability_engineer", "tone": "terse", "expertise": "novice", "rules_format": "plain", "services": ["coupon-svc"], "n_requirements": 5, "n_checks": 59, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.283333, "null_reward": 0.0, "grader_seconds": 0.73, "generator_version": "0.1.0"}
15
+ {"task_id": "af-015-missed-page-postmortem-medium-s1", "workflow": "missed-page-postmortem", "tier": "medium", "archetype": "repair_debug", "primary_verifier_pattern": "behavioral_simulation", "persona": "incident_commander", "tone": "urgent-pager", "expertise": "practitioner", "rules_format": "prometheusrule", "services": ["coupon-api", "orders-svc"], "n_requirements": 10, "n_checks": 137, "req_counts": {"req_alerts": 2, "req_repairs": 3, "req_recording": 2, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.260517, "null_reward": 0.0, "grader_seconds": 3.07, "generator_version": "0.1.0"}
16
+ {"task_id": "af-016-missed-page-postmortem-medium-s2", "workflow": "missed-page-postmortem", "tier": "medium", "archetype": "repair_debug", "primary_verifier_pattern": "behavioral_simulation", "persona": "incident_commander", "tone": "urgent-pager", "expertise": "practitioner", "rules_format": "prometheusrule", "services": ["orders-edge", "tax-edge"], "n_requirements": 10, "n_checks": 132, "req_counts": {"req_alerts": 2, "req_repairs": 3, "req_recording": 2, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.236505, "null_reward": 0.0, "grader_seconds": 2.2, "generator_version": "0.1.0"}
17
+ {"task_id": "af-017-missed-page-postmortem-hard-s1", "workflow": "missed-page-postmortem", "tier": "hard", "archetype": "data_query", "primary_verifier_pattern": "exact_state", "persona": "site_reliability_engineer", "tone": "urgent-pager", "expertise": "practitioner", "rules_format": "prometheusrule", "services": ["ledger-api", "payments-edge", "billing-api"], "n_requirements": 14, "n_checks": 173, "req_counts": {"req_alerts": 2, "req_repairs": 5, "req_recording": 2, "req_routing": 3, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.21644, "null_reward": 0.0, "grader_seconds": 4.44, "generator_version": "0.1.0"}
18
+ {"task_id": "af-018-missed-page-postmortem-hard-s2", "workflow": "missed-page-postmortem", "tier": "hard", "archetype": "repair_debug", "primary_verifier_pattern": "behavioral_simulation", "persona": "incident_commander", "tone": "urgent-pager", "expertise": "expert", "rules_format": "prometheusrule", "services": ["feed-edge", "search-edge", "geo-gw"], "n_requirements": 14, "n_checks": 167, "req_counts": {"req_alerts": 2, "req_repairs": 5, "req_recording": 2, "req_routing": 3, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.213061, "null_reward": 0.0, "grader_seconds": 3.48, "generator_version": "0.1.0"}
19
+ {"task_id": "af-019-latency-slo-easy-s1", "workflow": "latency-slo", "tier": "easy", "archetype": "author_to_constraints", "primary_verifier_pattern": "differential_equivalence", "persona": "performance_engineer", "tone": "urgent-pager", "expertise": "novice", "rules_format": "plain", "services": ["ledger-gw"], "n_requirements": 5, "n_checks": 61, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.167133, "null_reward": 0.0, "grader_seconds": 1.3, "generator_version": "0.1.0"}
20
+ {"task_id": "af-020-latency-slo-easy-s2", "workflow": "latency-slo", "tier": "easy", "archetype": "author_to_constraints", "primary_verifier_pattern": "differential_equivalence", "persona": "performance_engineer", "tone": "terse", "expertise": "novice", "rules_format": "plain", "services": ["wishlist-api"], "n_requirements": 5, "n_checks": 67, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.250133, "null_reward": 0.0, "grader_seconds": 1.3, "generator_version": "0.1.0"}
21
+ {"task_id": "af-021-latency-slo-medium-s1", "workflow": "latency-slo", "tier": "medium", "archetype": "author_to_constraints", "primary_verifier_pattern": "differential_equivalence", "persona": "performance_engineer", "tone": "urgent-pager", "expertise": "practitioner", "rules_format": "prometheusrule", "services": ["export-edge", "refund-gw"], "n_requirements": 9, "n_checks": 137, "req_counts": {"req_alerts": 2, "req_repairs": 3, "req_recording": 1, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.213043, "null_reward": 0.0, "grader_seconds": 2.79, "generator_version": "0.1.0"}
22
+ {"task_id": "af-022-latency-slo-medium-s2", "workflow": "latency-slo", "tier": "medium", "archetype": "author_to_constraints", "primary_verifier_pattern": "differential_equivalence", "persona": "performance_engineer", "tone": "urgent-pager", "expertise": "practitioner", "rules_format": "prometheusrule", "services": ["invoice-api", "notify-worker"], "n_requirements": 9, "n_checks": 132, "req_counts": {"req_alerts": 2, "req_repairs": 3, "req_recording": 1, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.261538, "null_reward": 0.0, "grader_seconds": 2.45, "generator_version": "0.1.0"}
23
+ {"task_id": "af-023-latency-slo-hard-s1", "workflow": "latency-slo", "tier": "hard", "archetype": "author_to_constraints", "primary_verifier_pattern": "differential_equivalence", "persona": "performance_engineer", "tone": "terse", "expertise": "expert", "rules_format": "plain", "services": ["ingest-worker", "chat-gw", "tax-edge"], "n_requirements": 14, "n_checks": 178, "req_counts": {"req_alerts": 3, "req_repairs": 5, "req_recording": 2, "req_routing": 2, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.2056, "null_reward": 0.0, "grader_seconds": 4.35, "generator_version": "0.1.0"}
24
+ {"task_id": "af-024-latency-slo-hard-s2", "workflow": "latency-slo", "tier": "hard", "archetype": "author_to_constraints", "primary_verifier_pattern": "differential_equivalence", "persona": "performance_engineer", "tone": "urgent-pager", "expertise": "expert", "rules_format": "prometheusrule", "services": ["wishlist-gw", "fraud-worker", "stock-gw"], "n_requirements": 14, "n_checks": 179, "req_counts": {"req_alerts": 3, "req_repairs": 5, "req_recording": 2, "req_routing": 2, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.177933, "null_reward": 0.0, "grader_seconds": 4.58, "generator_version": "0.1.0"}
25
+ {"task_id": "af-025-team-reorg-migration-easy-s1", "workflow": "team-reorg-migration", "tier": "easy", "archetype": "operate_configure", "primary_verifier_pattern": "regression_suite", "persona": "platform_engineer", "tone": "urgent-pager", "expertise": "novice", "rules_format": "plain", "services": ["loyalty-gw"], "n_requirements": 5, "n_checks": 61, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.208333, "null_reward": 0.0, "grader_seconds": 0.81, "generator_version": "0.1.0"}
26
+ {"task_id": "af-026-team-reorg-migration-easy-s2", "workflow": "team-reorg-migration", "tier": "easy", "archetype": "operate_configure", "primary_verifier_pattern": "regression_suite", "persona": "platform_engineer", "tone": "urgent-pager", "expertise": "novice", "rules_format": "plain", "services": ["ingest-worker"], "n_requirements": 5, "n_checks": 61, "req_counts": {"req_alerts": 1, "req_repairs": 1, "req_recording": 1, "req_routing": 1, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.208333, "null_reward": 0.0, "grader_seconds": 0.82, "generator_version": "0.1.0"}
27
+ {"task_id": "af-027-team-reorg-migration-medium-s1", "workflow": "team-reorg-migration", "tier": "medium", "archetype": "transform_convert", "primary_verifier_pattern": "exact_state", "persona": "site_reliability_engineer", "tone": "neutral", "expertise": "novice", "rules_format": "plain", "services": ["pricing-worker", "inventory-worker"], "n_requirements": 9, "n_checks": 112, "req_counts": {"req_alerts": 2, "req_repairs": 3, "req_recording": 1, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.267826, "null_reward": 0.0, "grader_seconds": 1.93, "generator_version": "0.1.0"}
28
+ {"task_id": "af-028-team-reorg-migration-medium-s2", "workflow": "team-reorg-migration", "tier": "medium", "archetype": "operate_configure", "primary_verifier_pattern": "regression_suite", "persona": "platform_engineer", "tone": "neutral", "expertise": "practitioner", "rules_format": "prometheusrule", "services": ["report-svc", "export-svc"], "n_requirements": 9, "n_checks": 112, "req_counts": {"req_alerts": 2, "req_repairs": 3, "req_recording": 1, "req_routing": 2, "req_inhibit": 1}, "oracle_reward": 1.0, "partial_reward": 0.27513, "null_reward": 0.0, "grader_seconds": 1.92, "generator_version": "0.1.0"}
29
+ {"task_id": "af-029-team-reorg-migration-hard-s1", "workflow": "team-reorg-migration", "tier": "hard", "archetype": "transform_convert", "primary_verifier_pattern": "exact_state", "persona": "site_reliability_engineer", "tone": "terse", "expertise": "expert", "rules_format": "prometheusrule", "services": ["payments-gw", "fraud-svc", "profile-edge"], "n_requirements": 14, "n_checks": 181, "req_counts": {"req_alerts": 3, "req_repairs": 5, "req_recording": 2, "req_routing": 2, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.202898, "null_reward": 0.0, "grader_seconds": 5.37, "generator_version": "0.1.0"}
30
+ {"task_id": "af-030-team-reorg-migration-hard-s2", "workflow": "team-reorg-migration", "tier": "hard", "archetype": "transform_convert", "primary_verifier_pattern": "exact_state", "persona": "site_reliability_engineer", "tone": "neutral", "expertise": "expert", "rules_format": "plain", "services": ["media-edge", "identity-svc", "payments-api"], "n_requirements": 14, "n_checks": 189, "req_counts": {"req_alerts": 3, "req_repairs": 5, "req_recording": 2, "req_routing": 2, "req_inhibit": 2}, "oracle_reward": 1.0, "partial_reward": 0.253119, "null_reward": 0.0, "grader_seconds": 6.29, "generator_version": "0.1.0"}
null/af-001-slo-onboarding-easy-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-002-slo-onboarding-easy-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-003-slo-onboarding-medium-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-004-slo-onboarding-medium-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-005-slo-onboarding-hard-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-006-slo-onboarding-hard-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-007-alert-storm-cleanup-easy-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-008-alert-storm-cleanup-easy-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-009-alert-storm-cleanup-medium-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-010-alert-storm-cleanup-medium-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-011-alert-storm-cleanup-hard-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-012-alert-storm-cleanup-hard-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-013-missed-page-postmortem-easy-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-014-missed-page-postmortem-easy-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-015-missed-page-postmortem-medium-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-016-missed-page-postmortem-medium-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-017-missed-page-postmortem-hard-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-018-missed-page-postmortem-hard-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-019-latency-slo-easy-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-020-latency-slo-easy-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-021-latency-slo-medium-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-022-latency-slo-medium-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-023-latency-slo-hard-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-024-latency-slo-hard-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-025-team-reorg-migration-easy-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-026-team-reorg-migration-easy-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-027-team-reorg-migration-medium-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-028-team-reorg-migration-medium-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-029-team-reorg-migration-hard-s1/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
null/af-030-team-reorg-migration-hard-s2/solve.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/bin/bash
2
+ # null: no-op (equivalent to harbor -a nop)
3
+ exit 0
openenv/alertforge_env/README.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: 3amBench AlertForge Env
3
+ emoji: 📟
4
+ colorFrom: indigo
5
+ colorTo: red
6
+ sdk: docker
7
+ app_port: 8000
8
+ base_path: /web
9
+ pinned: false
10
+ license: apache-2.0
11
+ tags: [openenv, rl-environment, harbor, prometheus, alertmanager, sre, dense-reward]
12
+ ---
13
+
14
+ # 3amBench / AlertForge: OpenEnv server
15
+
16
+ Multi-turn version of the [3amBench Harbor dataset](https://huggingface.co/datasets/<you>/3ambench): the agent edits a Prometheus/Alertmanager
17
+ repo with tools, and every step is graded by the same `grade.py` Harbor uses (promtool + amtool replays of hidden
18
+ outage scenarios).
19
+
20
+ ## Actions
21
+ `{"tool": ...}` with one of `list_files`, `read_file{path}`, `write_file{path, content}`,
22
+ `replace_in_file{path, old, new}`, `run_checks`, `route_test{labels}`, `submit`.
23
+
24
+ ## Reset
25
+ `reset(seed, split="train"|"heldout"|"public", index=None, workflow=None, tier=None)`
26
+ - `train`: a fresh task generated in-process (unlimited instances; use this for training).
27
+ - `heldout`: generated from the server-side secret `AF_HELDOUT_SEED`.
28
+ - `public`: the 30 released Harbor tasks (evaluation only).
29
+
30
+ ## Reward (`AF_REWARD_MODE`)
31
+ | mode | per step | terminal | sum |
32
+ |---|---|---|---|
33
+ | `parity` (default) | `0.4·ΔΦ` | `+0.6·outcome` | exactly the Harbor `reward` |
34
+ | `shaped` | `0.3·ΔΦ − 0.002 − 0.01·invalid` (cost cap 0.1) | `+0.6·outcome` | |
35
+ | `outcome` | 0 | Harbor `reward` | Harbor `reward` |
36
+
37
+ On `heldout` and `public`, the mode is forced to `outcome` and `metadata.phi` is `null`, so the reward stream
38
+ cannot be used to probe the hidden checks. (openenv-core 0.3 does not send `metadata` over the wire at all;
39
+ `phi`/`delta_phi` are available in-process for trainer logging.)
40
+
41
+ ## Run locally
42
+ ```bash
43
+ docker build -t alertforge-env -f openenv/alertforge_env/server/Dockerfile . # from env/alertforge
44
+ docker run -p 8000:8000 alertforge-env
45
+ ```
46
+ ```python
47
+ from alertforge_env.client import AlertForgeEnv
48
+ with AlertForgeEnv(base_url="http://localhost:8000").sync() as env:
49
+ obs = env.reset(seed=1, split="train", workflow="slo-onboarding", tier="easy")
50
+ obs = env.step({"tool": "read_file", "path": "README.md"})
51
+ ```
openenv/alertforge_env/__init__.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ """OpenEnv package for 3amBench / AlertForge."""
2
+
3
+ from .models import AlertForgeAction, AlertForgeObservation, AlertForgeState
4
+
5
+ __all__ = ["AlertForgeAction", "AlertForgeObservation", "AlertForgeState"]
openenv/alertforge_env/client.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ """Minimal client: `AlertForgeEnv(base_url=...)` over the OpenEnv WebSocket protocol."""
2
+
3
+ from openenv.core.generic_client import GenericEnvClient
4
+
5
+
6
+ class AlertForgeEnv(GenericEnvClient):
7
+ """Actions are plain dicts, e.g. {"tool": "read_file", "path": "README.md"}."""
openenv/alertforge_env/models.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Typed OpenEnv contracts. State carries no answers, checks or scores (OpenEnv gotcha G5)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Literal, Optional
6
+
7
+ from pydantic import ConfigDict
8
+
9
+ from openenv.core.env_server.types import Action, Observation, State
10
+
11
+
12
+ class AlertForgeAction(Action):
13
+ model_config = ConfigDict(extra="forbid")
14
+
15
+ tool: Literal["list_files", "read_file", "write_file", "replace_in_file", "run_checks", "route_test", "submit"]
16
+ path: Optional[str] = None # relative to monitoring/
17
+ content: Optional[str] = None # write_file
18
+ old: Optional[str] = None # replace_in_file (must match exactly once)
19
+ new: Optional[str] = None
20
+ labels: Optional[dict[str, str]] = None # route_test
21
+
22
+
23
+ class AlertForgeObservation(Observation):
24
+ output: str = ""
25
+ ok: bool = True
26
+ step: int = 0
27
+ steps_left: int = 0
28
+ task_id: str = ""
29
+ instruction: str = "" # filled on reset only
30
+
31
+
32
+ class AlertForgeState(State):
33
+ task_id: str = ""
34
+ tier: str = ""
35
+ workflow: str = ""
36
+ split: str = "train"
37
+ submitted: bool = False
openenv/alertforge_env/openenv.yaml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ spec_version: 1
2
+ name: alertforge_env
3
+ version: 0.1.0
4
+ type: space
5
+ runtime: fastapi
6
+ app: alertforge_env.server.app:app
7
+ port: 8000
8
+ validation:
9
+ reward:
10
+ range: [-0.5, 1.0] # parity/shaped modes emit negative steps on regressions
11
+ oracle_tolerance: 0.0 # oracle episode sums to exactly 1.0 (parity mode)
12
+ floor_margin: 0.5 # no-op episode sums to 0.0
13
+ resources:
14
+ cpu: 1.0
15
+ memory_mb: 2048
16
+ disk_mb: 1024
17
+ episode_timeout_s: 600.0 # 40 steps, grader 0.7-7 s per write
18
+ capabilities:
19
+ verifier:
20
+ kind: reward_channel
21
+ declared_tools: [list_files, read_file, write_file, replace_in_file, run_checks, route_test, submit]
22
+ types:
23
+ tags: [rl-environment, prometheus, alertmanager, sre, dense-reward]
openenv/alertforge_env/pyproject.toml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "alertforge-env"
3
+ version = "0.1.0"
4
+ description = "OpenEnv server for 3amBench (AlertForge): Prometheus alerting-as-code with per-step shaped reward."
5
+ requires-python = ">=3.11"
6
+ dependencies = ["openenv-core==0.3.0", "fastapi", "uvicorn", "pyyaml>=6.0", "alertforge"]
7
+
8
+ [project.scripts]
9
+ server = "alertforge_env.server.app:main"
10
+
11
+ [build-system]
12
+ requires = ["setuptools>=68"]
13
+ build-backend = "setuptools.build_meta"
14
+
15
+ [tool.setuptools]
16
+ packages = ["alertforge_env", "alertforge_env.server"]
17
+ package-dir = {"alertforge_env" = "."}
openenv/alertforge_env/server/Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Build context: env/alertforge (the project root), e.g.
2
+ # docker build -t alertforge-env -f openenv/alertforge_env/server/Dockerfile .
3
+ FROM prom/prometheus:v3.5.0@sha256:63805ebb8d2b3920190daf1cb14a60871b16fd38bed42b857a3182bc621f4996 AS prom
4
+ FROM prom/alertmanager:v0.28.1@sha256:27c475db5fb156cab31d5c18a4251ac7ed567746a2483ff264516437a39b15ba AS am
5
+ FROM python:3.12-slim@sha256:2f17fc044b579bab302c2e8054d3a686e2cb9a83de48e70534b94cd8ebbe06a9
6
+ COPY --from=prom /bin/promtool /usr/local/bin/promtool
7
+ COPY --from=am /bin/amtool /usr/local/bin/amtool
8
+ COPY pyproject.toml README.md /app/alertforge/
9
+ COPY src /app/alertforge/src
10
+ COPY workflows /app/alertforge/workflows
11
+ RUN pip install --no-cache-dir -e /app/alertforge "openenv-core==0.3.0" fastapi uvicorn
12
+ COPY tasks /app/dataset/tasks
13
+ COPY openenv/alertforge_env /app/env/alertforge_env
14
+ ENV PYTHONPATH=/app/env AF_DATASET_DIR=/app/dataset AF_REWARD_MODE=parity
15
+ WORKDIR /app/env
16
+ EXPOSE 8000
17
+ HEALTHCHECK --interval=30s --timeout=5s CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"
18
+ # exec: uvicorn becomes PID 1 and receives SIGTERM (build-guide G1)
19
+ CMD ["sh", "-c", "cd /app/env && exec uvicorn alertforge_env.server.app:app --host 0.0.0.0 --port 8000"]
openenv/alertforge_env/server/__init__.py ADDED
File without changes
openenv/alertforge_env/server/alertforge_environment.py ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """OpenEnv Environment for 3amBench / AlertForge.
2
+
3
+ reset(seed, split="train"|"heldout"|"public", index=None, workflow=None, tier=None)
4
+ - public: one of the released Harbor tasks (AF_DATASET_DIR/tasks, sorted), chosen by `index` or seed
5
+ - train: a fresh task generated in-process from (workflow, tier, seed); unlimited instances
6
+ - heldout: like train, but with the server-side secret master seed AF_HELDOUT_SEED
7
+ step(action) → tool output + per-step reward from the same grader Harbor uses (alertforge.episode).
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import os
13
+ import random
14
+ import shutil
15
+ import tempfile
16
+ from typing import Any, Optional
17
+ from uuid import uuid4
18
+
19
+ from openenv.core.env_server.interfaces import Environment
20
+
21
+ from alertforge.cli import TIERS, WORKFLOWS
22
+ from alertforge.episode import Episode
23
+ from alertforge_env.models import AlertForgeAction, AlertForgeObservation, AlertForgeState
24
+
25
+ DATASET_DIR = os.environ.get("AF_DATASET_DIR", os.path.join(os.path.dirname(__file__), "..", "..", ".."))
26
+ TRAIN_MASTER_SEED = 20260928
27
+ _PUBLIC_CACHE: list[str] | None = None
28
+
29
+
30
+ def public_tasks() -> list[str]:
31
+ """Sorted released task dirs (cached at module level; OpenEnv routes use throwaway instances)."""
32
+ global _PUBLIC_CACHE
33
+ if _PUBLIC_CACHE is None:
34
+ root = os.path.join(os.path.abspath(DATASET_DIR), "tasks")
35
+ _PUBLIC_CACHE = sorted(os.path.join(root, d) for d in os.listdir(root)) if os.path.isdir(root) else []
36
+ return _PUBLIC_CACHE
37
+
38
+
39
+ class AlertForgeEnvironment(Environment[AlertForgeAction, AlertForgeObservation, AlertForgeState]):
40
+ SUPPORTS_CONCURRENT_SESSIONS = True
41
+
42
+ def __init__(self) -> None:
43
+ super().__init__()
44
+ self._ep: Episode | None = None
45
+ self._tmp: str | None = None
46
+ self._state = AlertForgeState()
47
+
48
+ def reset(self, seed: Optional[int] = None, episode_id: Optional[str] = None, split: str = "train",
49
+ index: Optional[int] = None, workflow: Optional[str] = None, tier: Optional[str] = None,
50
+ **kwargs: Any) -> AlertForgeObservation:
51
+ self.close()
52
+ rng = random.Random(seed)
53
+ if split == "public":
54
+ tasks = public_tasks()
55
+ if not tasks:
56
+ return AlertForgeObservation(output="no public tasks found (set AF_DATASET_DIR)", ok=False, done=True)
57
+ task_dir = tasks[(index if index is not None else rng.randrange(len(tasks))) % len(tasks)]
58
+ task_id = os.path.basename(task_dir)
59
+ tier = next((t for t in TIERS if f"-{t}-" in task_id), "medium")
60
+ wf = next((w for w in WORKFLOWS if w in task_id), "")
61
+ else:
62
+ if split == "heldout" and not os.environ.get("AF_HELDOUT_SEED"):
63
+ return AlertForgeObservation(output="heldout split needs AF_HELDOUT_SEED on the server", ok=False, done=True)
64
+ master = int(os.environ["AF_HELDOUT_SEED"]) if split == "heldout" else TRAIN_MASTER_SEED
65
+ wf = workflow if workflow in WORKFLOWS else rng.choice(WORKFLOWS)
66
+ tier = tier if tier in TIERS else rng.choice(TIERS)
67
+ task_seed = seed if seed is not None else rng.randrange(10**9)
68
+ from alertforge import render
69
+ self._tmp = tempfile.mkdtemp(prefix="af-env-task-")
70
+ task_id = f"af-{split}-{wf}-{tier}-{task_seed}"
71
+ render.build_task(wf, tier, 1000 + task_seed, self._tmp, task_id, master)
72
+ task_dir = os.path.join(self._tmp, task_id)
73
+ self._ep = Episode(task_dir, split=split, tier=tier)
74
+ self._state = AlertForgeState(episode_id=episode_id or str(uuid4()), step_count=0, task_id=task_id,
75
+ tier=tier, workflow=wf, split=split)
76
+ return AlertForgeObservation(output="", ok=True, step=0, steps_left=self._ep.steps_left, task_id=task_id,
77
+ instruction=self._ep.instruction, reward=0.0, done=False,
78
+ metadata={"reward_mode": self._ep.mode})
79
+
80
+ def step(self, action: AlertForgeAction, timeout_s: Optional[float] = None, **kwargs: Any) -> AlertForgeObservation:
81
+ if self._ep is None:
82
+ return AlertForgeObservation(output="call reset() first", ok=False, done=True, reward=0.0)
83
+ res = self._ep.step(action.model_dump(exclude={"metadata"}, exclude_none=True))
84
+ self._state.step_count += 1
85
+ self._state.submitted = self._state.submitted or action.tool == "submit"
86
+ return AlertForgeObservation(output=res["output"], ok=res["ok"], step=self._ep.step_no,
87
+ steps_left=self._ep.steps_left, task_id=self._state.task_id,
88
+ reward=res["reward"], done=res["done"], metadata=res["metadata"])
89
+
90
+ @property
91
+ def state(self) -> AlertForgeState:
92
+ return self._state
93
+
94
+ def close(self) -> None:
95
+ if self._ep is not None:
96
+ self._ep.close()
97
+ self._ep = None
98
+ if self._tmp:
99
+ shutil.rmtree(self._tmp, ignore_errors=True)
100
+ self._tmp = None
openenv/alertforge_env/server/app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ASGI app: `uvicorn alertforge_env.server.app:app` with the parent of alertforge_env on PYTHONPATH (the Dockerfile uses /app/env)."""
2
+
3
+ import os
4
+
5
+ from openenv.core.env_server.http_server import create_app
6
+
7
+ from alertforge_env.models import AlertForgeAction, AlertForgeObservation
8
+ from alertforge_env.server.alertforge_environment import AlertForgeEnvironment
9
+
10
+ app = create_app(AlertForgeEnvironment, AlertForgeAction, AlertForgeObservation, env_name="alertforge_env",
11
+ max_concurrent_envs=int(os.environ.get("AF_MAX_CONCURRENT_ENVS", "16")))
12
+
13
+
14
+ def main() -> None:
15
+ import uvicorn
16
+ uvicorn.run(app, host="0.0.0.0", port=int(os.environ.get("PORT", "8000")))
17
+
18
+
19
+ if __name__ == "__main__":
20
+ main()
partial/af-001-slo-onboarding-easy-s1/solve.sh ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # partial: even-indexed requirements + one plausible mistake
3
+ set -euo pipefail
4
+ cd /workspace/monitoring
5
+ mkdir -p 'alertmanager'
6
+ cat > 'alertmanager/alertmanager.yml' <<'AF_EOF'
7
+ global:
8
+ resolve_timeout: 5m
9
+ slack_api_url: https://hooks.slack.invalid/services/T000/B000/XXXX
10
+ route:
11
+ receiver: slack-sre-catchall
12
+ group_by:
13
+ - alertname
14
+ - service
15
+ group_wait: 30s
16
+ group_interval: 5m
17
+ repeat_interval: 4h
18
+ routes:
19
+ - matchers:
20
+ - severity="ticket"
21
+ receiver: jira-sre
22
+ continue: true
23
+ - matchers:
24
+ - team="data-ingest"
25
+ receiver: slack-data-ingest
26
+ routes:
27
+ - matchers:
28
+ - severity="page"
29
+ receiver: pagerduty-data-ingest
30
+ continue: true
31
+ - matchers:
32
+ - severity=~"page|warning"
33
+ receiver: slack-data-ingest
34
+ - matchers:
35
+ - team="infra"
36
+ receiver: slack-infra
37
+ routes:
38
+ - matchers:
39
+ - severity="page"
40
+ receiver: pagerduty-infra
41
+ continue: true
42
+ - matchers:
43
+ - severity=~"page|warning"
44
+ receiver: slack-infra
45
+ - matchers:
46
+ - team="messaging"
47
+ receiver: slack-messaging
48
+ routes:
49
+ - matchers:
50
+ - severity="page"
51
+ receiver: pagerduty-messaging
52
+ continue: true
53
+ - matchers:
54
+ - severity=~"page|warning"
55
+ receiver: slack-messaging
56
+ - matchers:
57
+ - team="payments"
58
+ receiver: slack-payments
59
+ routes:
60
+ - matchers:
61
+ - severity="page"
62
+ receiver: pagerduty-payments
63
+ continue: true
64
+ - matchers:
65
+ - severity=~"page|warning"
66
+ receiver: slack-payments
67
+ receivers:
68
+ - name: slack-sre-catchall
69
+ slack_configs:
70
+ - channel: '#sre-alerts'
71
+ send_resolved: true
72
+ - name: jira-sre
73
+ webhook_configs:
74
+ - url: http://jira-bridge.quillon.dev:9095/alerts/SRE
75
+ - name: null-sink
76
+ - name: pagerduty-data-ingest
77
+ pagerduty_configs:
78
+ - routing_key: PD_DATA_INGEST_KEY
79
+ - name: slack-data-ingest
80
+ slack_configs:
81
+ - channel: '#data-ingest-alerts'
82
+ send_resolved: true
83
+ - name: pagerduty-infra
84
+ pagerduty_configs:
85
+ - routing_key: PD_INFRA_KEY
86
+ - name: slack-infra
87
+ slack_configs:
88
+ - channel: '#infra-alerts'
89
+ send_resolved: true
90
+ - name: pagerduty-messaging
91
+ pagerduty_configs:
92
+ - routing_key: PD_MESSAGING_KEY
93
+ - name: slack-messaging
94
+ slack_configs:
95
+ - channel: '#messaging-alerts'
96
+ send_resolved: true
97
+ - name: pagerduty-payments
98
+ pagerduty_configs:
99
+ - routing_key: PD_PAYMENTS_KEY
100
+ - name: slack-payments
101
+ slack_configs:
102
+ - channel: '#payments-alerts'
103
+ send_resolved: true
104
+ inhibit_rules:
105
+ - source_matchers:
106
+ - severity="page"
107
+ target_matchers:
108
+ - severity="warning"
109
+ equal:
110
+ - alertname
111
+ - service
112
+ - source_matchers:
113
+ - alertname="ChatGwDown"
114
+ target_matchers:
115
+ - alertname=~"ChatGwErrorBudgetBurnFast|HighErrorRatio"
116
+ equal:
117
+ - service
118
+ AF_EOF
119
+ mkdir -p 'rules'
120
+ cat > 'rules/fleet.yml' <<'AF_EOF'
121
+ groups:
122
+ - name: fleet
123
+ rules:
124
+ - alert: HighErrorRatio
125
+ expr: (sum by (service) (rate(grpc_server_handled_total{grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[5m])) / sum by (service) (rate(grpc_server_handled_total[5m]))) > 0.02 and sum by (service) (rate(grpc_server_handled_total[5m])) > 1
126
+ for: 1m
127
+ labels:
128
+ severity: warning
129
+ team: infra
130
+ annotations:
131
+ summary: '{{ $labels.service }} error ratio is {{ $value | humanizePercentage }}'
132
+ runbook_url: https://runbooks.quillon.dev/alerts/HighErrorRatio
133
+ - alert: ContainerMemoryNearLimit
134
+ expr: max by (service) (container_memory_working_set_bytes{container="app"} / container_spec_memory_limit_bytes{container="app"}) > 0.85
135
+ for: 5m
136
+ labels:
137
+ severity: warning
138
+ team: infra
139
+ annotations:
140
+ summary: '{{ $labels.service }} has a container above its memory limit threshold'
141
+ runbook_url: https://runbooks.quillon.dev/alerts/ContainerMemoryNearLimit
142
+ - alert: PodCrashLooping
143
+ expr: sum by (service) (increase(kube_pod_container_status_restarts_total[15m])) > 3
144
+ for: 10m
145
+ labels:
146
+ severity: warning
147
+ team: infra
148
+ annotations:
149
+ summary: '{{ $labels.service }} containers restarted more than {{ $value }} times in 15m'
150
+ runbook_url: https://runbooks.quillon.dev/alerts/PodCrashLooping
151
+ - alert: SlowRequestsP99
152
+ expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket[5m]))) > 1
153
+ for: 10m
154
+ labels:
155
+ severity: warning
156
+ team: infra
157
+ annotations:
158
+ summary: '{{ $labels.service }} p99 latency is {{ $value | humanizeDuration }}'
159
+ runbook_url: https://runbooks.quillon.dev/alerts/SlowRequestsP99
160
+ AF_EOF
161
+ mkdir -p 'rules'
162
+ cat > 'rules/slo-chat-gw.yml' <<'AF_EOF'
163
+ groups:
164
+ - name: slo-chat-gw
165
+ rules:
166
+ - alert: ChatGwErrorBudgetBurnFast
167
+ expr: slo:sli_error:ratio_rate1h{service="chat-gw"} > (14.4 * 0.005) and slo:sli_error:ratio_rate5m{service="chat-gw"} > (14.4 * 0.005)
168
+ for: 2m
169
+ labels:
170
+ severity: page
171
+ team: payments
172
+ slo: chat-gw-availability
173
+ annotations:
174
+ summary: '{{ $labels.service }} is burning its error budget fast (14.4x over 1h and 5m)'
175
+ runbook_url: https://runbooks.quillon.dev/alerts/ChatGwErrorBudgetBurnFast
176
+ AF_EOF
partial/af-002-slo-onboarding-easy-s2/solve.sh ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # partial: even-indexed requirements + one plausible mistake
3
+ set -euo pipefail
4
+ cd /workspace/monitoring
5
+ mkdir -p 'alertmanager'
6
+ cat > 'alertmanager/alertmanager.yml' <<'AF_EOF'
7
+ global:
8
+ resolve_timeout: 5m
9
+ slack_api_url: https://hooks.slack.invalid/services/T000/B000/XXXX
10
+ route:
11
+ receiver: slack-sre-catchall
12
+ group_by:
13
+ - alertname
14
+ - service
15
+ group_wait: 30s
16
+ group_interval: 5m
17
+ repeat_interval: 4h
18
+ routes:
19
+ - matchers:
20
+ - severity="ticket"
21
+ receiver: jira-sre
22
+ continue: true
23
+ - matchers:
24
+ - team="infra"
25
+ receiver: slack-infra
26
+ routes:
27
+ - matchers:
28
+ - severity="page"
29
+ receiver: pagerduty-infra
30
+ continue: true
31
+ - matchers:
32
+ - severity=~"page|warning"
33
+ receiver: slack-infra
34
+ - matchers:
35
+ - team="logistics"
36
+ receiver: slack-logistics
37
+ routes:
38
+ - matchers:
39
+ - severity="page"
40
+ receiver: pagerduty-logistics
41
+ continue: true
42
+ - matchers:
43
+ - severity=~"page|warning"
44
+ receiver: slack-logistics
45
+ - matchers:
46
+ - team="storefront"
47
+ receiver: slack-storefront
48
+ routes:
49
+ - matchers:
50
+ - severity="page"
51
+ receiver: pagerduty-storefront
52
+ continue: true
53
+ - matchers:
54
+ - severity=~"page|warning"
55
+ receiver: slack-storefront
56
+ - matchers:
57
+ - team="trust-safety"
58
+ receiver: slack-trust-safety
59
+ routes:
60
+ - matchers:
61
+ - severity="page"
62
+ receiver: pagerduty-trust-safety
63
+ continue: true
64
+ - matchers:
65
+ - severity=~"page|warning"
66
+ receiver: slack-trust-safety
67
+ receivers:
68
+ - name: slack-sre-catchall
69
+ slack_configs:
70
+ - channel: '#sre-alerts'
71
+ send_resolved: true
72
+ - name: jira-sre
73
+ webhook_configs:
74
+ - url: http://jira-bridge.quillon.dev:9095/alerts/SRE
75
+ - name: null-sink
76
+ - name: pagerduty-infra
77
+ pagerduty_configs:
78
+ - routing_key: PD_INFRA_KEY
79
+ - name: slack-infra
80
+ slack_configs:
81
+ - channel: '#infra-alerts'
82
+ send_resolved: true
83
+ - name: pagerduty-logistics
84
+ pagerduty_configs:
85
+ - routing_key: PD_LOGISTICS_KEY
86
+ - name: slack-logistics
87
+ slack_configs:
88
+ - channel: '#logistics-alerts'
89
+ send_resolved: true
90
+ - name: pagerduty-storefront
91
+ pagerduty_configs:
92
+ - routing_key: PD_STOREFRONT_KEY
93
+ - name: slack-storefront
94
+ slack_configs:
95
+ - channel: '#storefront-alerts'
96
+ send_resolved: true
97
+ - name: pagerduty-trust-safety
98
+ pagerduty_configs:
99
+ - routing_key: PD_TRUST_SAFETY_KEY
100
+ - name: slack-trust-safety
101
+ slack_configs:
102
+ - channel: '#trust-safety-alerts'
103
+ send_resolved: true
104
+ inhibit_rules:
105
+ - source_matchers:
106
+ - severity="page"
107
+ target_matchers:
108
+ - severity="warning"
109
+ equal:
110
+ - alertname
111
+ - service
112
+ - source_matchers:
113
+ - alertname="LoyaltyApiDown"
114
+ target_matchers:
115
+ - alertname=~"HTTPErrorRatioHigh|LoyaltyApiErrorBudgetBurnFast"
116
+ equal:
117
+ - service
118
+ AF_EOF
119
+ mkdir -p 'rules'
120
+ cat > 'rules/fleet.yml' <<'AF_EOF'
121
+ groups:
122
+ - name: fleet
123
+ rules:
124
+ - alert: HTTPErrorRatioHigh
125
+ expr: (sum by (service) (rate(http_requests_total{code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total[5m]))) > 0.05 and sum by (service) (rate(http_requests_total[5m])) > 1
126
+ for: 1m
127
+ labels:
128
+ severity: warning
129
+ team: infra
130
+ annotations:
131
+ summary: '{{ $labels.service }} error ratio is {{ $value | humanizePercentage }}'
132
+ runbook_url: https://runbooks.quillon.dev/alerts/HTTPErrorRatioHigh
133
+ - alert: ContainerMemoryNearLimit
134
+ expr: max by (service) (container_memory_working_set_bytes{container="app"} / container_spec_memory_limit_bytes{container="app"}) > 0.85
135
+ for: 5m
136
+ labels:
137
+ severity: warning
138
+ team: infra
139
+ annotations:
140
+ summary: '{{ $labels.service }} has a container above its memory limit threshold'
141
+ runbook_url: https://runbooks.quillon.dev/alerts/ContainerMemoryNearLimit
142
+ - alert: ContainerRestartingOften
143
+ expr: sum by (service) (increase(kube_pod_container_status_restarts_total[15m])) > 3
144
+ for: 10m
145
+ labels:
146
+ severity: warning
147
+ team: infra
148
+ annotations:
149
+ summary: '{{ $labels.service }} containers restarted more than {{ $value }} times in 15m'
150
+ runbook_url: https://runbooks.quillon.dev/alerts/ContainerRestartingOften
151
+ - alert: LatencyP99High
152
+ expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket[5m]))) > 1
153
+ for: 10m
154
+ labels:
155
+ severity: warning
156
+ team: infra
157
+ annotations:
158
+ summary: '{{ $labels.service }} p99 latency is {{ $value | humanizeDuration }}'
159
+ runbook_url: https://runbooks.quillon.dev/alerts/LatencyP99High
160
+ AF_EOF
161
+ mkdir -p 'rules'
162
+ cat > 'rules/slo-loyalty-api.yml' <<'AF_EOF'
163
+ groups:
164
+ - name: slo-loyalty-api
165
+ rules:
166
+ - alert: LoyaltyApiErrorBudgetBurnFast
167
+ expr: slo:sli_error:ratio_rate1h{service="loyalty-api"} > (14.4 * 0.001) and slo:sli_error:ratio_rate5m{service="loyalty-api"} > (14.4 * 0.001)
168
+ for: 2m
169
+ labels:
170
+ severity: page
171
+ team: logistics
172
+ slo: loyalty-api-availability
173
+ annotations:
174
+ summary: '{{ $labels.service }} is burning its error budget fast (14.4x over 1h and 5m)'
175
+ runbook_url: https://runbooks.quillon.dev/alerts/LoyaltyApiErrorBudgetBurnFast
176
+ AF_EOF
partial/af-003-slo-onboarding-medium-s1/solve.sh ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # partial: even-indexed requirements + one plausible mistake
3
+ set -euo pipefail
4
+ cd /workspace/monitoring
5
+ mkdir -p 'alertmanager'
6
+ cat > 'alertmanager/alertmanager.yml' <<'AF_EOF'
7
+ global:
8
+ resolve_timeout: 5m
9
+ slack_api_url: https://hooks.slack.invalid/services/T000/B000/XXXX
10
+ route:
11
+ receiver: slack-sre-catchall
12
+ group_by:
13
+ - alertname
14
+ - service
15
+ group_wait: 30s
16
+ group_interval: 5m
17
+ repeat_interval: 4h
18
+ routes:
19
+ - matchers:
20
+ - severity="ticket"
21
+ receiver: jira-sre
22
+ continue: true
23
+ - matchers:
24
+ - team="discovery"
25
+ receiver: slack-discovery
26
+ routes:
27
+ - matchers:
28
+ - severity="page"
29
+ receiver: pagerduty-discovery
30
+ continue: true
31
+ - matchers:
32
+ - severity=~"page|warning"
33
+ receiver: slack-discovery
34
+ - matchers:
35
+ - team="finance-eng"
36
+ receiver: slack-finance-eng
37
+ routes:
38
+ - matchers:
39
+ - severity="page"
40
+ receiver: pagerduty-finance-eng
41
+ continue: true
42
+ - matchers:
43
+ - severity=~"page|warning"
44
+ receiver: slack-finance-eng
45
+ - matchers:
46
+ - team="logistics"
47
+ receiver: slack-logistics
48
+ routes:
49
+ - matchers:
50
+ - severity="page"
51
+ receiver: pagerduty-logistics
52
+ continue: true
53
+ - matchers:
54
+ - severity=~"page|warning"
55
+ receiver: slack-logistics
56
+ - matchers:
57
+ - team="platform"
58
+ receiver: slack-platform
59
+ routes:
60
+ - matchers:
61
+ - severity="page"
62
+ receiver: pagerduty-platform
63
+ continue: true
64
+ - matchers:
65
+ - severity=~"page|warning"
66
+ receiver: slack-platform
67
+ receivers:
68
+ - name: slack-sre-catchall
69
+ slack_configs:
70
+ - channel: '#sre-alerts'
71
+ send_resolved: true
72
+ - name: jira-sre
73
+ webhook_configs:
74
+ - url: http://jira-bridge.northwind-freight.dev:9095/alerts/SRE
75
+ - name: null-sink
76
+ - name: pagerduty-billing-eng
77
+ pagerduty_configs:
78
+ - routing_key: PD_BILLING_ENG_KEY
79
+ - name: slack-billing-eng
80
+ slack_configs:
81
+ - channel: '#billing-eng-alerts'
82
+ send_resolved: true
83
+ - name: pagerduty-discovery
84
+ pagerduty_configs:
85
+ - routing_key: PD_DISCOVERY_KEY
86
+ - name: slack-discovery
87
+ slack_configs:
88
+ - channel: '#discovery-alerts'
89
+ send_resolved: true
90
+ - name: pagerduty-finance-eng
91
+ pagerduty_configs:
92
+ - routing_key: PD_FINANCE_ENG_KEY
93
+ - name: slack-finance-eng
94
+ slack_configs:
95
+ - channel: '#finance-eng-alerts'
96
+ send_resolved: true
97
+ - name: pagerduty-logistics
98
+ pagerduty_configs:
99
+ - routing_key: PD_LOGISTICS_KEY
100
+ - name: slack-logistics
101
+ slack_configs:
102
+ - channel: '#logistics-alerts'
103
+ send_resolved: true
104
+ - name: pagerduty-platform
105
+ pagerduty_configs:
106
+ - routing_key: PD_PLATFORM_KEY
107
+ - name: slack-platform
108
+ slack_configs:
109
+ - channel: '#platform-alerts'
110
+ send_resolved: true
111
+ inhibit_rules:
112
+ - source_matchers:
113
+ - severity="page"
114
+ target_matchers:
115
+ - severity="warning"
116
+ equal:
117
+ - alertname
118
+ - service
119
+ AF_EOF
120
+ mkdir -p 'rules'
121
+ cat > 'rules/fleet.yml' <<'AF_EOF'
122
+ apiVersion: monitoring.coreos.com/v1
123
+ kind: PrometheusRule
124
+ metadata:
125
+ name: fleet
126
+ namespace: monitoring
127
+ labels:
128
+ role: alert-rules
129
+ spec:
130
+ groups:
131
+ - name: fleet
132
+ rules:
133
+ - alert: HighErrorRatio
134
+ expr: (sum by (service) (rate(grpc_server_handled_total{grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[5m])) / sum by (service) (rate(grpc_server_handled_total[5m]))) > 0.05 and sum by (service) (rate(grpc_server_handled_total[5m])) > 1
135
+ for: 5m
136
+ labels:
137
+ severity: warning
138
+ team: platform
139
+ annotations:
140
+ summary: '{{ $labels.service }} error ratio is {{ $value | humanizePercentage }}'
141
+ runbook_url: https://runbooks.northwind-freight.dev/alerts/HighErrorRatio
142
+ - alert: ContainerMemoryNearLimit
143
+ expr: max by (service) (container_memory_working_set_bytes{container="app"} / container_spec_memory_limit_bytes{container="app"}) > 0.85
144
+ for: 5m
145
+ labels:
146
+ severity: warning
147
+ team: platform
148
+ annotations:
149
+ summary: '{{ $labels.service }} has a container above its memory limit threshold'
150
+ runbook_url: https://runbooks.northwind-freight.dev/alerts/ContainerMemoryNearLimit
151
+ - alert: PodCrashLooping
152
+ expr: sum by (service) (increase(kube_pod_container_status_restarts_total[15m])) > 3
153
+ for: 10m
154
+ labels:
155
+ severity: warning
156
+ team: platform
157
+ annotations:
158
+ summary: '{{ $labels.service }} containers restarted more than {{ $value }} times in 15m'
159
+ runbook_url: https://runbooks.northwind-freight.dev/alerts/PodCrashLooping
160
+ - alert: SlowRequestsP99
161
+ expr: histogram_quantile(0.99, sum by (service, le) (rate(http_request_duration_seconds_bucket[5m]))) > 1
162
+ for: 10m
163
+ labels:
164
+ severity: warning
165
+ team: platform
166
+ annotations:
167
+ summary: '{{ $labels.service }} p99 latency is {{ $value | humanizeDuration }}'
168
+ runbook_url: https://runbooks.northwind-freight.dev/alerts/SlowRequestsP99
169
+ AF_EOF
170
+ mkdir -p 'rules'
171
+ cat > 'rules/slo-ingest-gw.yml' <<'AF_EOF'
172
+ apiVersion: monitoring.coreos.com/v1
173
+ kind: PrometheusRule
174
+ metadata:
175
+ name: slo-ingest-gw
176
+ namespace: monitoring
177
+ labels:
178
+ role: alert-rules
179
+ spec:
180
+ groups:
181
+ - name: slo-ingest-gw
182
+ rules:
183
+ - alert: IngestGwErrorBudgetBurnFast
184
+ expr: slo:sli_error:ratio_rate5m{service="ingest-gw"} > (14.4 * 0.01)
185
+ for: 2m
186
+ labels:
187
+ severity: page
188
+ team: logistics
189
+ slo: ingest-gw-availability
190
+ annotations:
191
+ summary: '{{ $labels.service }} is burning its error budget fast (14.4x over 1h and 5m)'
192
+ runbook_url: https://runbooks.northwind-freight.dev/alerts/IngestGwErrorBudgetBurnFast
193
+ - alert: IngestGwErrorBudgetBurnSlow
194
+ expr: slo:sli_error:ratio_rate6h{service="ingest-gw"} > (6 * 0.01) and slo:sli_error:ratio_rate30m{service="ingest-gw"} > (6 * 0.01)
195
+ for: 15m
196
+ labels:
197
+ severity: ticket
198
+ team: logistics
199
+ slo: ingest-gw-availability
200
+ annotations:
201
+ summary: '{{ $labels.service }} is burning its error budget steadily (6x over 6h and 30m)'
202
+ runbook_url: https://runbooks.northwind-freight.dev/alerts/IngestGwErrorBudgetBurnSlow
203
+ AF_EOF
204
+ mkdir -p 'rules'
205
+ cat > 'rules/slo-loyalty-svc.yml' <<'AF_EOF'
206
+ apiVersion: monitoring.coreos.com/v1
207
+ kind: PrometheusRule
208
+ metadata:
209
+ name: slo-loyalty-svc
210
+ namespace: monitoring
211
+ labels:
212
+ role: alert-rules
213
+ spec:
214
+ groups:
215
+ - name: slo-loyalty-svc
216
+ rules:
217
+ - alert: LoyaltySvcErrorBudgetBurnFast
218
+ expr: slo:sli_error:ratio_rate1h{service="loyalty-svc"} > (14.4 * 0.0005) and slo:sli_error:ratio_rate5m{service="loyalty-svc"} > (14.4 * 0.0005)
219
+ for: 2m
220
+ labels:
221
+ severity: page
222
+ team: billing-eng
223
+ slo: loyalty-svc-availability
224
+ annotations:
225
+ summary: '{{ $labels.service }} is burning its error budget fast (14.4x over 1h and 5m)'
226
+ runbook_url: https://runbooks.northwind-freight.dev/alerts/LoyaltySvcErrorBudgetBurnFast
227
+ AF_EOF
228
+ mkdir -p 'rules'
229
+ cat > 'rules/slo-recording.yml' <<'AF_EOF'
230
+ apiVersion: monitoring.coreos.com/v1
231
+ kind: PrometheusRule
232
+ metadata:
233
+ name: slo-recording
234
+ namespace: monitoring
235
+ labels:
236
+ role: alert-rules
237
+ spec:
238
+ groups:
239
+ - name: sli-grpc
240
+ rules:
241
+ - record: slo:sli_error:ratio_rate5m
242
+ expr: sum by (service) (rate(grpc_server_handled_total{grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[5m])) / sum by (service) (rate(grpc_server_handled_total[5m]))
243
+ - record: slo:sli_error:ratio_rate30m
244
+ expr: sum by (service) (rate(grpc_server_handled_total{grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[30m])) / sum by (service) (rate(grpc_server_handled_total[30m]))
245
+ - record: slo:sli_error:ratio_rate1h
246
+ expr: sum by (service) (rate(grpc_server_handled_total{grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[1h])) / sum by (service) (rate(grpc_server_handled_total[1h]))
247
+ - record: slo:sli_error:ratio_rate6h
248
+ expr: sum by (service) (rate(grpc_server_handled_total{grpc_code=~"Unavailable|Internal|DeadlineExceeded|Unknown|DataLoss"}[6h])) / sum by (service) (rate(grpc_server_handled_total[6h]))
249
+ - name: sli-http
250
+ rules:
251
+ - record: slo:sli_error:ratio_rate5m
252
+ expr: sum by (service) (rate(http_requests_total{code=~"5.."}[5m])) / sum by (service) (rate(http_requests_total[5m]))
253
+ - record: slo:sli_error:ratio_rate30m
254
+ expr: sum by (service) (rate(http_requests_total{code=~"5.."}[30m])) / sum by (service) (rate(http_requests_total[30m]))
255
+ - record: slo:sli_error:ratio_rate1h
256
+ expr: sum by (service) (rate(http_requests_total{code=~"5.."}[1h])) / sum by (service) (rate(http_requests_total[1h]))
257
+ - record: slo:sli_error:ratio_rate6h
258
+ expr: sum by (service) (rate(http_requests_total{code=~"5.."}[6h])) / sum by (service) (rate(http_requests_total[6h]))
259
+ AF_EOF