File size: 29,550 Bytes
71e9dba | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 | ---
id: OPS_task_17_rabbitmq_dlq_topology_mgmt
name: RabbitMQ DLQ 路由黑洞 CLI×Management UI 联合溯源
category: OPS
timeout_seconds: 1800
---
## Prompt
Task background: The order-system SRE has received an alert — the `orders.dlq` dead-letter queue depth is stuck at 0, yet the `orders` ingress publish rate is steady at ~20 msg/s, and the main consumer queue `orders.q` shows a deliver/ack rate clearly below publish, with the gap persistently ≥ 4 msg/s — roughly 30% of "poison" orders, after being nack'd, neither land in the DLQ nor get redelivered in place; they silently disappear inside the broker. The warmup has already pinned the scene:
- RabbitMQ Server listens on `127.0.0.1:5672` (AMQP) and `127.0.0.1:15672` (management plugin HTTP API + Management control panel), credentials `guest:guest`, the business runs under the default vhost `/`, and `rabbitmq_management` is already enabled.
- The producer / consumer background daemons are running (pid files `/tmp_workspace/state/rmq_producer.pid`, `rmq_consumer.pid`, stdout in the same directory as `*.out`); the producer continuously pushes ~20 msg/s into the topic exchange `orders`, of which about 30% have routing key `orders.poison` (which the consumer nacks 100%).
- Three core queues in the topology: `orders.q` (main consumer, bound on `orders` / `orders.#`, declared with `x-dead-letter-exchange=orders.dlx`), `orders.dlq` (dead-letter, bound on `orders.dlx`), and `orders.audit` (side-channel audit, a distractor).
- The real fault is buried in the routing key of the `orders.dlx → orders.dlq` binding: the `x-dead-letter-routing-key` declared on `orders.q` does not literally match the routing key of that binding — the topic exchange finds no match, and all nack'd messages fall into the black hole.
Task goal: produce a "diagnosis + fix + re-verification" report ready to paste straight into the post-mortem channel; all artifacts go under `/tmp_workspace/results/`; the evidence must cross-validate two channels — broker-side text/JSON dumps and Management control-panel screenshots.
### Hard constraints for the main deliverable `diagnosis.json`
- All 10 schema fields must be present: `vhost` / `broken_binding_source` / `broken_binding_destination` / `broken_binding_routing_key` / `expected_routing_key` / `remediation` / `dlq_depth_before_fix` / `dlq_depth_after_fix` / `publish_rate_msgps` / `deliver_rate_msgps`.
- `expected_routing_key` must equal `dead.unrouted` exactly.
- `broken_binding_routing_key` must hit the literal `dead.routed` value (taken from the broker's real binding table).
- `remediation` must contain both `dead.unrouted` and the word `bind` / `binding`.
- `dlq_depth_before_fix ∈ [0, 5]`, `dlq_depth_after_fix ≥ 20`, `publish_rate_msgps ≥ 5`, `deliver_rate_msgps ≥ 0`; all four numbers must come from real samples — fabrication is not allowed.
### Companion deliverables (under `/tmp_workspace/results/`)
| File | Requirement |
|---|---|
| `01_rmq_status.txt` | Broker liveness snapshot; must contain the string `RabbitMQ` and identifier lines such as node name / version / enabled plugins |
| `02_queues.txt` | Queue listing for vhost `/`; must contain all three lines `orders.q` / `orders.dlq` / `orders.audit`, with the `orders.dlq` row's messages count ≤ 5 |
| `03_bindings.txt` | Full binding-table dump; must contain the row with source=`orders.dlx` and destination=`orders.dlq`, whose routing_key field falls under `dead.routed.*` (the literal mismatch is the root-cause evidence) |
| `04_queue_args.txt` | Complete queue arguments for `orders.q`; must contain the field name `x-dead-letter-routing-key` with value `dead.unrouted` |
| `05_rates_t0.json` + `05_rates_t1.json` | Two `orders.q` rate snapshots separated by ≥ 5 s, structurally aligned with the `message_stats` subtree of `/api/queues/<vhost>/<name>`, containing `publish_details.rate` and `deliver_get_details.rate` (or `deliver_details.rate`); at least one of them must show `publish - deliver_get` ≥ 4 msg/s |
| `06_remediation.sh` | Mitigation script that re-binds `orders.dlx → orders.dlq` to a routing key that matches `dead.unrouted` (the literal `dead.unrouted` or the `#` wildcard); the text must also contain `dead.unrouted` together with at least one binding-action keyword among `declare binding` / `Add binding` / `queue_bind` / `x-dead-letter-routing-key`; the script must be re-entrant |
| `07_bindings_after.txt` | Binding-table dump taken after running `06_remediation.sh`; must contain both `orders.dlx` and `orders.dlq`, with the routing_key field containing `dead.unrouted` |
| `08_queues_after.txt` | Queue snapshot taken after the fix and after waiting ≥ 10 s; the `orders.dlq` row's messages count must be ≥ 20 |
| `postmortem.md` | ≥ 600 characters; must contain all four section headings `## 时间线` / `## 根因` / `## 修复` / `## 跨通道证据链`; must hit ≥ 5 of the seven keywords `dead-letter` / `binding` / `routing key` / `broker` / `management` / `dlx` / `topic` |
| `cross_channel.json` | `{"switches": int, "trace": [...]}`, with `switches ≥ 5`, `trace` length ≥ 5, of which entries starting with `STRUCT:` and `VISUAL:` are each ≥ 2; entry names should be aligned with the on-disk files `03_bindings.txt` / `04_queue_args.txt` / `07_bindings_after.txt` / `08_queues_after.txt` and `view_02` / `view_04` / `view_06` / `view_07` |
### Seven workflow screenshots (fixed filenames, under `/tmp_workspace/results/`)
Real screenshots of the **same** RabbitMQ Management control panel. Common spec: each ≥ 1024×700 real pixels, ≥ 30 KB, not a flat-color collage; grading runs OCR keyword checks and a VLM rubric, so the file contents must be self-consistent with what the filename describes.
- `view_01_mgmt_overview.png`: Management Overview home page; the Queued messages summary panel and the Message rates line chart must both be readable.
- `view_02_mgmt_rates_tooltip.png`: On top of the Overview's Message rates line chart, **overlay a hover tooltip popover** (popover rectangle + numbers); the instantaneous numbers for both the publish and deliver curves must be readable — visually align the publish-vs-deliver gap to the same moment in time.
- `view_03_mgmt_queues.png`: Queues list page; the three rows `orders.q` / `orders.dlq` / `orders.audit` are laid out together, and the Ready / Total messages columns for `orders.dlq` clearly read near 0.
- `view_04_dlq_bindings.png`: The Bindings sub-panel on the `orders.dlq` queue detail page; the "From exchange" column contains `orders.dlx`, and the **broken literal value** (shaped like `dead.routed.*`) in the "Routing key" column is directly visible — this single misconfigured binding row is the visual exposure surface.
- `view_05_dlx_detail.png`: The `orders.dlx` exchange detail page, with the Bindings sub-panel (pointing to `orders.dlq`) and the Message rate sub-panel visible on the same screen.
- `view_06_mgmt_overview_after.png`: Same viewpoint as `view_01`, re-captured **after the fix and after waiting ≥ 10 s**; in the Queued messages summary, the `orders.dlq` count is clearly non-zero (≥ 20).
- `view_07_dlq_after.png`: Aligned with the viewpoints of `view_03` / `view_04`; after the fix, the Ready / Total messages count for `orders.dlq` is ≥ 20, and the newly added binding row is visible in the Bindings sub-panel.
### Anti-cheating and runtime constraints
- The producer / consumer must stay running until all artifacts are collected; you may not `kill` the processes whose pids are in `/tmp_workspace/state/rmq_producer.pid` and `rmq_consumer.pid`, otherwise during re-verification the publish rate and DLQ growth will both go to zero.
- You may not copy any file under `/tmp_workspace/gt/` into `results/` (detected via hash comparison).
- Text/JSON dumps must come from real broker queries (`rabbitmqctl` / `rabbitmqadmin` / management API); you may not just `echo` / `cat` the literal values given in the task to fabricate file contents.
## Expected Behavior
设计意图与典型解题路径(仅供出题人参考,不发给 agent):
1. 工具通道自由,不强制走某一种:broker 端结构化取证可走 `rabbitmqctl` / `rabbitmqadmin` / Management HTTP API(`curl http://127.0.0.1:15672/api/...` + `guest:guest` Basic Auth);控制面截图走 Management Web UI(默认 `http://127.0.0.1:15672`)。两条通道都要走,单走任何一条都形成不了证据链。
2. step 1:取 broker 状态与队列列表(`01_rmq_status.txt` / `02_queues.txt`),看到 `orders.dlq` messages ≤ 5 但 `orders.audit` 仍在涨——首发异常信号。
3. step 2:dump 全量 bindings(`03_bindings.txt`)+ `orders.q` 的 queue arguments(`04_queue_args.txt`),把 `x-dead-letter-routing-key=dead.unrouted` 与 `orders.dlx → orders.dlq` binding 的 `dead.routed.*` 字面值对齐 → 锁定根因(不是缺 binding,是 routing key 字面值不匹配;topic exchange 不会把 `dead.routed.#` 当通配匹配 `dead.unrouted`)。
4. step 3:间隔 ≥ 5 s 采两次 `/api/queues/%2F/orders.q` JSON(`05_rates_t0/t1.json`),确认 `publish - deliver_get` gap ≥ 4 msg/s;同时在 Web UI Overview 的 Message rates 图上 hover 出 tooltip 截 `view_02`,把同一 gap 视觉化对齐。
5. step 4:补齐 `view_01` / `view_03` / `view_04` / `view_05` 四张修复前截图,确认根因在 UI 上同样可见。
6. step 5:写 `06_remediation.sh`:声明一条新的 `orders.dlx → orders.dlq` binding,routing key 用 `dead.unrouted`(或 `#` 通配),脚本可重入(如 `rabbitmqadmin declare binding ...` 或 `rabbitmqctl eval` + `queue_bind`);执行后等 ≥ 10 s 让 producer 持续灌入的中毒消息把 DLQ 涨到 ≥ 20。
7. step 6:复采 `07_bindings_after.txt` / `08_queues_after.txt`,截 `view_06` / `view_07` 修复后视图作为对比证据。
8. step 7:写 `diagnosis.json`(10 字段,数值都从前面真实采样里取)、`postmortem.md`(≥ 600 字符 + 4 段标题 + ≥ 5 关键词)、`cross_channel.json`(trace 同时引用 STRUCT 与 VISUAL 两类证据条目)收尾。
约束说明(actions.log 反作弊):
- `actions.log` / 操作轨迹中不得通过 `echo` / `printf` / `cat <<EOF` 直接构造 `02_queues.txt` / `03_bindings.txt` / `04_queue_args.txt` / `07_bindings_after.txt` / `08_queues_after.txt` 的内容来伪造数值;这些文件必须能在轨迹中追溯到对应的 broker 查询命令或 HTTP 请求。
- `view_*` 截图必须来自真实 Management UI 渲染,禁止 PIL 拼接 / 文本渲染伪造(VLM rubric 会对截图真实性打分)。
评分要点(hard gates,从 grader cap 反推):
- 结构通道齐全:`bindings_broken_visible ≥ 0.5`(`03_bindings.txt` 含 `orders.dlx` / `orders.dlq` / `dead.routed`)、`queue_args_expected_rk ≥ 0.4`(`04_queue_args.txt` 含 `x-dead-letter-*`)、`bindings_after_ok ≥ 0.4`(`07_bindings_after.txt` 含新 binding 行);任一不满足则总分被 cap 到 0.4。
- 视觉通道齐全:7 张截图至少一半通过尺寸/色彩/真实性校验;不满足则总分被 cap 到 0.4。
- 修复后量化证据:`08_queues_after.txt` 中 `orders.dlq` ≥ 20,且 VLM 在 `view_06` / `view_07` 上能确认 DLQ 已涨;不满足则被 cap 到 0.55。
- 速率 gap 真实采到(两次中至少一次 `publish - deliver ≥ 4 msg/s`)且 `cross_channel.json` 满足 `switches ≥ 5` + STRUCT/VISUAL 各 ≥ 2;不满足则被 cap 到 0.6。
- VLM rubric 平均分 ≥ 0.6(管理 UI 真实性 / rates tooltip / bindings 子面板 / 修复后图表);不满足被 cap 到 0.55。
## Source
- RabbitMQ Dead Letter Exchanges 官方文档
https://www.rabbitmq.com/dlx.html
- RabbitMQ Management plugin 文档
https://www.rabbitmq.com/management.html
- Stack Overflow 实例:DLX with topic exchange + routing key mismatch
https://stackoverflow.com/questions/45726833/
- 对应 EyesOn-Bench OPS 维度:O17 — message-broker DLQ routing
triage via rabbitmqctl bindings × Management UI rate-chart tooltip
## Grading Criteria
- [ ] 1. `01_rmq_status.txt` 含 RabbitMQ + 节点信息
- [ ] 2. `02_queues.txt` 三个核心队列都在;`orders.dlq` messages ≈ 0
- [ ] 3. `03_bindings.txt` 含 source=orders.dlx + destination=orders.dlq
行;routing_key 字段含 `dead.routed`
- [ ] 4. `04_queue_args.txt` 含 `x-dead-letter-routing-key`
+ `dead.unrouted`
- [ ] 5. `05_rates_t0.json` + `05_rates_t1.json` 都是合法 JSON 且
publish - deliver_get ≥ 4 msg/s
- [ ] 6. `view_01_mgmt_overview.png` 存在 ≥ 800×600,OCR 命中
"RabbitMQ"/"Overview"/"Queued messages" 之一
- [ ] 7. `view_02_mgmt_rates_tooltip.png` 存在;VLM 能识别 chart
tooltip 浮窗
- [ ] 8. `view_03_mgmt_queues.png` 存在;OCR 命中
"orders"/"Queues"/"Messages" 之一
- [ ] 9. `view_04_dlq_bindings.png` 存在;VLM 能识别 bindings 子面板
- [ ] 10. `view_05_dlx_detail.png` 存在
- [ ] 11. `diagnosis.json` 10 字段全在;
`expected_routing_key` 等于 `dead.unrouted`
- [ ] 12. `06_remediation.sh` 含 `dead.unrouted` + 绑定动作
- [ ] 13. `07_bindings_after.txt` 含新绑定行
- [ ] 14. `08_queues_after.txt` 中 `orders.dlq` messages ≥ 20
- [ ] 15. `view_06_mgmt_overview_after.png` 存在
- [ ] 16. `view_07_dlq_after.png` 存在
- [ ] 17. `postmortem.md` ≥ 600 字符 + 关键词 ≥ 5/7 + 4 段标题齐
- [ ] 18. `cross_channel.json` switches ≥ 5;CLI/GUI 各 ≥ 2
- [ ] 19. Hard gate:缺 CLI/GUI 任一通道证据 → 封顶 0.4
## Automated Checks
```python
def grade(workspace_path=None, **kwargs) -> dict:
"""OPS_task_17 grader: RabbitMQ DLQ routing-key mismatch triage via
broker management HTTP API structured evidence and Management UI
visual screenshots. Sub-scores cover topology dump quality, rate-gap
quantification, screenshot presence + OCR + VLM, the binding
fix evidence, post-fix DLQ growth, diagnosis JSON, postmortem
quality, and cross-channel switch count."""
import json, re
from pathlib import Path
rd = Path("/tmp_workspace/results")
gt_dir = Path("/opt/ops17_gt") if Path("/opt/ops17_gt/expected.json").exists() else Path("/tmp_workspace/gt")
s = {}
expected = {}
if (gt_dir / "expected.json").exists():
try: expected = json.loads((gt_dir / "expected.json").read_text())
except Exception: expected = {}
main_q = expected.get("main_queue", "orders.q")
dlq = expected.get("dlq_queue", "orders.dlq")
dlx = expected.get("dlx_exchange", "orders.dlx")
expect_rk = expected.get("expected_dead_letter_routing_key_on_queue",
"dead.unrouted")
broken_rk = expected.get("broken_dlx_binding_routing_key",
"dead.routed.#")
req_keys = expected.get("report_required_keys", [])
min_dlq_growth = int(expected.get("min_dlq_growth_after_fix", 20))
def _read(name):
p = rd / name
return p.read_text(errors="ignore") if p.exists() else ""
# 1. status
st = _read("01_rmq_status.txt")
s["rmq_status_present"] = 1.0 if st and "RabbitMQ" in st else (0.4 if st else 0.0)
# 2. queues snapshot — three queues + dlq ~0
qs = _read("02_queues.txt")
has_three = (main_q in qs and dlq in qs and "orders.audit" in qs)
dlq_zero = False
for ln in qs.splitlines():
if dlq in ln:
nums = re.findall(r"\b\d+\b", ln)
if nums:
try:
if int(nums[0]) <= 5:
dlq_zero = True
except Exception:
pass
if has_three and dlq_zero:
s["queues_initial_anomaly"] = 1.0
elif has_three:
s["queues_initial_anomaly"] = 0.6
elif qs:
s["queues_initial_anomaly"] = 0.3
else:
s["queues_initial_anomaly"] = 0.0
# 3. bindings show broken routing key
bnd = _read("03_bindings.txt")
has_broken = (dlx in bnd and dlq in bnd
and re.search(r"dead\.routed", bnd) is not None)
s["bindings_broken_visible"] = 1.0 if has_broken else (0.5 if (dlx in bnd and dlq in bnd) else 0.0)
# 4. queue arguments expose x-dead-letter-*
qa = _read("04_queue_args.txt")
if qa and "x-dead-letter-routing-key" in qa and expect_rk in qa:
s["queue_args_expected_rk"] = 1.0
elif qa and "x-dead-letter" in qa:
s["queue_args_expected_rk"] = 0.5
else:
s["queue_args_expected_rk"] = 0.0
# 5. rate gap quantified
def _rates(name):
try:
d = json.loads(_read(name) or "{}")
except Exception:
return None, None
ms = d.get("message_stats", {}) or {}
pub = ms.get("publish_details", {}).get("rate")
deliv = ms.get("deliver_get_details", {}).get("rate")
if deliv is None:
deliv = ms.get("deliver_details", {}).get("rate")
return pub, deliv
p0, d0 = _rates("05_rates_t0.json")
p1, d1 = _rates("05_rates_t1.json")
gap_ok = False
try:
gaps = []
for p, d in [(p0, d0), (p1, d1)]:
if p is not None and d is not None:
gaps.append(float(p) - float(d))
if gaps and max(gaps) >= 4.0:
gap_ok = True
elif gaps and max(gaps) >= 1.5:
s["rate_gap_observed"] = 0.6
except Exception:
pass
if gap_ok:
s["rate_gap_observed"] = 1.0
elif "rate_gap_observed" not in s:
s["rate_gap_observed"] = 0.3 if (p0 is not None or p1 is not None) else 0.0
# 6. screenshots existence + size
shots = ["view_01_mgmt_overview.png",
"view_02_mgmt_rates_tooltip.png",
"view_03_mgmt_queues.png",
"view_04_dlq_bindings.png",
"view_05_dlx_detail.png",
"view_06_mgmt_overview_after.png",
"view_07_dlq_after.png"]
def _real_shot(p):
if not p.exists() or p.stat().st_size < 30000:
return False
try:
from PIL import Image
im = Image.open(p)
w, h = im.size
if w < 1024 or h < 700:
return False
ex = im.convert("RGB").getextrema()
return max(hi - lo for lo, hi in ex) > 60
except Exception:
return False
present = sum(1 for n in shots if _real_shot(rd / n))
s["gui_screenshots_count"] = present / len(shots)
# 7. OCR
ocr_hits = 0
try:
import pytesseract
from PIL import Image
kws = {
"view_01_mgmt_overview.png":
["RabbitMQ", "Overview", "Queued messages", "Message rates",
"Connections"],
"view_02_mgmt_rates_tooltip.png":
["msg/s", "publish", "deliver", "redeliver", "ack"],
"view_03_mgmt_queues.png":
["orders.dlq", "orders.audit", "Ready"],
"view_04_dlq_bindings.png":
["orders.dlx", "dead.routed", "Routing key"],
"view_05_dlx_detail.png":
["Exchange", "orders.dlx", "Bindings", "Message rate"],
"view_06_mgmt_overview_after.png":
["RabbitMQ", "Overview", "Queued messages", "Message rates"],
"view_07_dlq_after.png":
["orders.dlq", "Ready"],
}
for n, ks in kws.items():
p = rd / n
if p.exists():
try:
tx = pytesseract.image_to_string(Image.open(p))
if any(k in tx for k in ks): ocr_hits += 1
except Exception:
pass
s["gui_screenshots_ocr"] = ocr_hits / len(shots)
except ImportError:
s["gui_screenshots_ocr"] = 0.5
# 8. diagnosis JSON
diag = rd / "diagnosis.json"
diag_keys_score = 0.0; diag_rk = 0.0; diag_rem = 0.0
if diag.exists():
try:
d = json.loads(diag.read_text())
def _numok(v, lo, hi=None):
try:
x = float(v)
return x >= lo and (hi is None or x <= hi)
except Exception:
return False
num_ok = (_numok(d.get("dlq_depth_before_fix"), 0, 5)
and _numok(d.get("dlq_depth_after_fix"), min_dlq_growth)
and _numok(d.get("publish_rate_msgps"), 5)
and _numok(d.get("deliver_rate_msgps"), 0))
present_keys = sum(1 for k in req_keys if k in d and d.get(k) not in (None, "", 0))
diag_keys_score = (present_keys / max(1, len(req_keys))) * (1.0 if num_ok else 0.4)
if str(d.get("expected_routing_key", "")).strip() == expect_rk:
diag_rk = 1.0
elif expect_rk in str(d.get("expected_routing_key", "")):
diag_rk = 0.7
rem = str(d.get("remediation", ""))
if expect_rk in rem and ("bind" in rem.lower() or "binding" in rem.lower()):
diag_rem = 1.0
elif expect_rk in rem:
diag_rem = 0.6
except Exception:
pass
s["diagnosis_keys"] = diag_keys_score
s["diagnosis_routing_key_match"] = diag_rk
s["diagnosis_remediation_match"] = diag_rem
# 9. remediation script
rem = _read("06_remediation.sh")
rem_ok = False
if rem and expect_rk in rem and re.search(
r"declare\s+binding|Add\s+binding|queue_bind|x-dead-letter-routing-key",
rem, re.I):
rem_ok = True
s["remediation_script_ok"] = 1.0 if rem_ok else (0.5 if rem else 0.0)
# 10. bindings after — new row visible
ba = _read("07_bindings_after.txt")
# Tolerate any whitespace/column-separator (tab, multi-space, JSON commas)
# between dlx, dlq, and expect_rk on the same logical row.
_row_re = rf"{re.escape(dlx)}[^\n]*{re.escape(dlq)}[^\n]*{re.escape(expect_rk)}"
if ba and dlx in ba and dlq in ba and expect_rk in ba and re.search(_row_re, ba):
s["bindings_after_ok"] = 1.0
elif ba and dlx in ba and dlq in ba and expect_rk in ba:
s["bindings_after_ok"] = 0.6
elif ba and dlx in ba:
s["bindings_after_ok"] = 0.4
else:
s["bindings_after_ok"] = 0.0
# 11. DLQ growth
qa2 = _read("08_queues_after.txt")
dlq_count = 0
for ln in qa2.splitlines():
if dlq in ln:
nums = re.findall(r"\b\d+\b", ln)
if nums:
try:
dlq_count = max(dlq_count, int(nums[0]))
except Exception:
pass
if dlq_count >= min_dlq_growth:
s["dlq_growth_after_fix"] = 1.0
elif dlq_count >= max(5, min_dlq_growth // 2):
s["dlq_growth_after_fix"] = 0.6
else:
s["dlq_growth_after_fix"] = 0.2 if qa2 else 0.0
# 12. postmortem
pm = _read("postmortem.md")
pm_chars = len(pm)
s["postmortem_length"] = 1.0 if pm_chars >= 600 else pm_chars / 600.0
pm_kws = expected.get("expected_postmortem_keywords",
["dead-letter", "binding", "routing key",
"broker", "management", "dlx", "topic"])
hits = sum(1 for k in pm_kws if k.lower() in pm.lower())
s["postmortem_keywords"] = hits / max(1, len(pm_kws))
sects = expected.get("expected_postmortem_sections",
["## 时间线", "## 根因", "## 修复",
"## 跨通道证据链"])
sect_hits = sum(1 for h in sects if h in pm)
s["postmortem_sections"] = sect_hits / max(1, len(sects))
# 13. cross-channel switches
cc = rd / "cross_channel.json"
cc_ok = 0.0
if cc.exists():
try:
d = json.loads(cc.read_text())
sw = int(d.get("switches", 0))
tr = d.get("trace", [])
required_struct = {"03_bindings.txt", "04_queue_args.txt", "07_bindings_after.txt", "08_queues_after.txt"}
required_visual = {"view_02_mgmt_rates_tooltip.png", "view_04_dlq_bindings.png", "view_06_mgmt_overview_after.png", "view_07_dlq_after.png"}
struct_refs = sum(1 for x in tr if isinstance(x, str) and x.startswith("STRUCT:") and any((rd / f).exists() for f in required_struct if x.split(":", 1)[1] in f or f.startswith(x.split(":", 1)[1])))
visual_refs = sum(1 for x in tr if isinstance(x, str) and x.startswith("VISUAL:") and any((rd / f).exists() for f in required_visual if x.split(":", 1)[1] in f or f.startswith(x.split(":", 1)[1])))
cc_ok = 1.0 if (sw >= 5 and len(tr) >= 5 and struct_refs >= 2 and visual_refs >= 2) else (0.4 if sw >= 3 else 0.0)
except Exception:
pass
s["cross_channel_switches"] = cc_ok
# 14. VLM rubric
try:
from _judge_helper import vlm_score_rubric
except Exception:
vlm_score_rubric = None
vlm_imgs = [str(rd / n) for n in shots if (rd / n).exists()]
vlm_judge = 0.0
if vlm_score_rubric and vlm_imgs:
rubric = {
"vlm_mgmt_ui_real":
"至少一张截图清晰显示 RabbitMQ Management UI 主窗口(顶部 Overview/Connections/Channels/Exchanges/Queues 导航栏 + Queued messages / Message rates 图)",
"vlm_rates_tooltip":
"view_02 显示 Message rates 折线图上有 hover tooltip 浮窗,且 publish 与 deliver 的数字可读",
"vlm_bindings_panel":
"view_04 显示某队列详情页的 Bindings 子面板,包含 source exchange + routing key 列",
"vlm_after_fix_chart":
"view_06 / view_07 显示修复后 publish 与 deliver 收敛 或 DLQ messages 计数 ≥ 20",
}
vlm = vlm_score_rubric(vlm_imgs[:7], rubric,
instruction="评估 SRE 用 RabbitMQ Management UI 排查 DLQ 路由黑洞的截图。")
for k in rubric: s[k] = vlm.get(k, 0.0)
s["judge_method"] = vlm.get("judge_method", "failed")
vlm_judge = sum(s.get(k, 0.0) for k in rubric) / max(1, len(rubric))
else:
for k in ("vlm_mgmt_ui_real", "vlm_rates_tooltip",
"vlm_bindings_panel", "vlm_after_fix_chart"):
s[k] = 0.5
vlm_judge = 0.5
# Aggregate
nums = [v for k, v in s.items()
if isinstance(v, (int, float)) and k != "judge_method"]
base = sum(nums) / max(1, len(nums))
# Hard gates
has_struct = (s["bindings_broken_visible"] >= 0.5
and s["queue_args_expected_rk"] >= 0.4
and s["bindings_after_ok"] >= 0.4)
has_visual = s["gui_screenshots_count"] >= 0.5
if not has_struct: base = min(base, 0.4)
if not has_visual: base = min(base, 0.4)
# Only apply the VLM cap when the VLM judge actually ran. When the
# helper is unavailable (vlm_score_rubric is None), the 0.5 fallback
# would otherwise penalise a perfect run for an environment defect.
if vlm_score_rubric is not None and vlm_judge < 0.6:
base = min(base, 0.55)
if s["dlq_growth_after_fix"] < 1.0 or s.get("vlm_after_fix_chart", 0) < 0.5:
base = min(base, 0.55)
if s["rate_gap_observed"] < 0.6 or s["cross_channel_switches"] < 1.0:
base = min(base, 0.6)
s["overall_score"] = round(base, 3)
return s
```
## Workspace Path
```
workspace/OPS/task_17_rabbitmq_dlq_topology_mgmt
```
## Skills
```
```
## Env
```
```
## Warmup
```bash
set +e
export DEBIAN_FRONTEND=noninteractive
umask 0000
mkdir -p /tmp_workspace/results /tmp_workspace/state /opt/ops17_gt
chmod 0777 /tmp_workspace /tmp_workspace/results /tmp_workspace/state 2>/dev/null || true
which rabbitmqctl >/dev/null 2>&1 || timeout 120 apt-get -o Acquire::Retries=10 update -qq || true
which rabbitmqctl >/dev/null 2>&1 || timeout 600 apt-get -o Acquire::Retries=10 install -y -qq rabbitmq-server python3-pika curl procps psmisc tesseract-ocr || true
python3 -c 'import PIL, pytesseract' >/dev/null 2>&1 || timeout 120 pip install --quiet --no-input pillow pytesseract 2>/dev/null || true
# Framework mounts workspace/exec/* directly under /tmp_workspace/ (NOT /tmp_workspace/exec/).
chmod +x /tmp_workspace/start_services.sh 2>/dev/null || true
nohup bash /tmp_workspace/start_services.sh >/tmp_workspace/state/start_services.out 2>&1 &
disown || true
for i in $(seq 1 30); do curl -fsS --max-time 2 -u guest:guest http://127.0.0.1:15672/api/overview >/dev/null 2>&1 && break; sleep 2; done
[ -x /usr/local/bin/rabbitmqadmin ] || (timeout 30 curl -fsS -o /usr/local/bin/rabbitmqadmin http://127.0.0.1:15672/cli/rabbitmqadmin 2>/dev/null && chmod +x /usr/local/bin/rabbitmqadmin) || true
[ -x /usr/local/bin/rabbitmqadmin ] || (timeout 60 curl -fsSL -o /usr/local/bin/rabbitmqadmin https://raw.githubusercontent.com/rabbitmq/rabbitmq-server/v3.12.0/deps/rabbitmq_management/bin/rabbitmqadmin 2>/dev/null && chmod +x /usr/local/bin/rabbitmqadmin) || true
chmod -R a+rwX /tmp_workspace/state /tmp_workspace/results 2>/dev/null || true
# Move expected.json (contains expected_dead_letter_routing_key /
# fix_acceptable_remediations / postmortem keywords) to root-only /opt/ops17_gt.
if [ -f /tmp_workspace/gt/expected.json ]; then
mv /tmp_workspace/gt/expected.json /opt/ops17_gt/expected.json 2>/dev/null || true
chown -R root:root /opt/ops17_gt 2>/dev/null || true
chmod 700 /opt/ops17_gt 2>/dev/null || true
chmod 600 /opt/ops17_gt/expected.json 2>/dev/null || true
rmdir /tmp_workspace/gt 2>/dev/null || true
fi
echo "[warmup] OPS_task_17 services bootstrap kicked"
```
|