--- id: DSK_task_13_cups_printer_queue_repair name: 修复 CUPS 打印队列:PPD × 默认选项 × cupsfilter 三通道排错 category: DSK timeout_seconds: 1500 --- ## Prompt Background: An office Linux host is running a local CUPS server (listening on `http://localhost:631/`). Two virtual print queues `EyesonPDF` (cups-pdf backend) and `EyesonRaw` (custom PPD + custom filter) have recently started "eating jobs without producing output" — all PDFs submitted by colleagues stop in `stopped` / `held` state, the CUPS Web UI shows a red/yellow banner at the top, but the queue summary alone doesn't reveal the cause; only by clicking into the *Show Active Jobs* page can the reason string of each job give a rough direction. You need to clean up both queues in one go. Environment (warmup already prepared): - CUPS is started, both queues `EyesonPDF` / `EyesonRaw` are already created; - PPD is at `/etc/cups/ppd/EyesonRaw.ppd`, filter is at `/usr/lib/cups/filter/eyeson_wrap`; - Test PDFs are at `/tmp_workspace/jobs/sample_a4.pdf`, `sample_letter.pdf`; - Helper script `bash /tmp_workspace/cups/observe.sh ` will write current `lpstat` / `lpoptions` snapshots to `/lpstat_.txt`. - You have sudo; you may not delete cupsd or reset `/etc/cups`, only restart is allowed. Deliverables to produce under `/tmp_workspace/results/`: 1. **Queue status snapshots** — at least two `lpstat_*.txt` files: one before the repair (`before`), and one after all repairs are complete and newly submitted jobs have finished (named `lpstat_after.txt`). Either file must present an `lpstat`-style queue/Job listing. 2. **Configuration excerpt** — `ppd_excerpt.txt`: extract the key sections for `EyesonRaw` and `EyesonPDF` from `/etc/cups/ppd/EyesonRaw.ppd` and `/etc/cups/printers.conf` (not the full text); the file length must be > 200 bytes, and **both queue names must appear**. 3. **Error log window** — `cups_error_log.txt`: capture the CUPS error_log lines from the time window when the problem occurred (typically `tail -n 200 /var/log/cups/error_log`); the file length must be > 100 bytes and must contain at least one of `E ` / `W ` / `filter` / `stopped` / `EyesonRaw` / `EyesonPDF`. 4. **Offline filter reproduction** — reproduce the failure using one "offline filter chain": - `cupsfilter_before.ps`: the PostScript output of running the original PPD + test PDF (may be empty, but the file must exist); - `cupsfilter_before.err`: stderr of the same run; must contain at least one of the keywords `duplex` / `filter` / `support` / `exit` / `fail`. 5. **Visual evidence** (must be captured from a real working environment; the text on screen must be clearly readable): - `view_cups_jobs_red_banner.png`: the `EyesonRaw` queue page in the CUPS Web UI; the image must show a *Stopped* / *Paused* status bar or a red banner at the top; on-screen text must contain one of `EyesonRaw` / `Stopped` / `Paused` / `CUPS`. - `view_cups_set_default_options.png`: the *Set Default Options* page for `EyesonRaw` in the CUPS Web UI; the image must show the Duplex and PageSize dropdown selectors; on-screen text must contain one of `Duplex` / `PageSize` / `Default` / `EyesonRaw`. - `view_system_config_printer_panel.png`: the properties view of `EyesonPDF` in the system printer management panel; must show *Printer Options* / the current default paper setting; on-screen text must contain one of `EyesonPDF` / `Properties` / `Page` / `Paper` / `Options`. - `view_lpstat_terminal_before.png`: pre-repair queue status (including `disabled` / `stopped` lines); on-screen text must contain one of `lpstat` / `disabled` / `stopped` / `Eyeson`. - `view_postrepair_completed_jobs.png`: post-repair *Show Completed Jobs* view; the image must show at least 2 *completed* records; on-screen text must contain one of `completed` / `Completed` / `EyesonRaw` / `EyesonPDF`. 6. **Structured diagnosis** — `diagnosis.json`: a JSON array with **two records** (one per queue); each schema: ```json { "queue": "EyesonRaw | EyesonPDF", "category": "ppd_default_option | media_mismatch | filter_logic | other", "evidence_cli": ["cups_error_log.txt:line_number", "cupsfilter_before.err summary"], "evidence_gui": "view_cups_set_default_options.png", "root_cause": "one-sentence diagnosis", "fix_command": "lpadmin / lpoptions / sed command string" } ``` The `category` field must be one of the four choices; both queue names must be covered. 7. **Post-repair filter re-verification**: - `cupsfilter_after.ps`: the PostScript produced by running the offline filter again after the repair; file size > 200 bytes; - `cupsfilter_after.err`: the stderr of the same run; **must not** contain the words `error` / `fail`. 8. **Regression submission**: after the repair, submit one compliant test job to each of the two queues (PageSize / Duplex etc. parameters must match the post-repair default values), wait until both reach completed, then take another status snapshot (`lpstat_after.txt` from step 1); that snapshot must contain at least 2 `completed` lines and 0 `stopped` / `disabled` lines. 9. **Report** — `report.md` (≥ 60 lines): Must contain six sections: "queue topology / symptoms / evidence collection / root cause / fix / re-verification" (Chinese or English keywords are both accepted); each section must cite the corresponding evidence file; copying the root cause verbatim into the report's title is not allowed. Hard constraints: - `rm -rf /etc/cups` is not allowed; stopping cupsd is not allowed (only restart); - The semantics of legal Duplex options in the PPD must not be broken; - Red herring: in `/etc/cups/ppd/EyesonRaw.ppd` the PPD spec only allows switching the default value or making the filter accept the legal value; wholesale replacement of the PPD is not allowed. ## Expected Behavior 成功的解答会在 `/tmp_workspace/results/` 留下完整的「症状 → 取证 → 根因 → 修复 → 复验」证据链: - 至少两份 `lpstat_*.txt` 快照(before/after),after 中至少 2 条 `completed` 且 0 条 `stopped` / `disabled`; - `ppd_excerpt.txt` 同时含 `EyesonRaw` 与 `EyesonPDF` 两段关键配置摘录; - `cups_error_log.txt` 给出问题时间窗的 CUPS error 行; - 一对 `cupsfilter_before.{ps,err}` 复现失败、一对 `cupsfilter_after.{ps,err}` 证明 filter 修通; - `diagnosis.json` 包含两条记录,分别覆盖 `EyesonRaw` 与 `EyesonPDF`,`category` 字段落在四选一内,且每条都有结构化 + 可视化双通道证据; - 五张可视化证据真实呈现:CUPS Web UI 中的红/黄色 banner、Set Default Options 中的 Duplex/PageSize 下拉、系统打印机管理面板中的 `EyesonPDF` 属性、修复前队列 stopped 行、修复后的 completed 记录; - `report.md`(≥ 60 行)按「队列拓扑 / 症状 / 取证 / 根因 / 修复 / 复验」六节叙事,引用上述所有取证文件。 ## Source - CUPS官方文档: https://www.cups.org/doc/man-cupsfilter.html - Adobe PPD 4.3 spec: https://partners.adobe.com/public/developer/en/ps/5003.PPD_Spec_v4.3.pdf - 真实场景灵感:Ubuntu Launchpad bug #1885893 「Duplex default mismatch causes job-stopped without obvious GUI hint」 - benchmark 对应:D13(DSK / CUPS web UI × system-config-printer × cupsfilter 三通道) ## Grading Criteria - [ ] 1. `lpstat_*.txt` 至少 2 份(before + after) - [ ] 2. `ppd_excerpt.txt` 含 `EyesonRaw` + `EyesonPDF` 两段 - [ ] 3. `cups_error_log.txt` 非空 - [ ] 4. `cupsfilter_before.err` 非空且含 `Duplex` 或 `filter` 相关字 - [ ] 5. `cupsfilter_after.ps` 存在且 `cupsfilter_after.err` 不含 ERROR - [ ] 6. `diagnosis.json` ≥ 2 条且 queue 覆盖 `EyesonRaw` + `EyesonPDF` - [ ] 7. 5 张 GUI 截图齐全 - [ ] 8. `lpstat_after.txt` 中至少 2 条 completed job 且 0 条 stopped - [ ] 9. `report.md` ≥ 60 行 6 节齐全 ## Automated Checks ```python def grade(workspace_path=None, **kwargs) -> dict: """Multi-axis grader for the CUPS printer-queue repair task.""" import json, re, subprocess, glob from pathlib import Path rd = Path("/tmp_workspace/results") gt = Path("/opt/dsk13_gt") if Path("/opt/dsk13_gt/expected.json").exists() \ else (Path("/tmp_workspace/gt") if Path("/tmp_workspace/gt").exists() \ else Path("/tmp_workspace/setup/gt")) expected = {} try: expected = json.loads((gt / "expected.json").read_text()) except Exception: pass s = {} # 1) lpstat snapshots: before + after snaps = sorted(glob.glob(str(rd / "lpstat_*.txt"))) s["lpstat_snapshots"] = 1.0 if len(snaps) >= 2 \ else (0.5 if len(snaps) == 1 else 0.0) # 2) ppd_excerpt covers both queues pe = rd / "ppd_excerpt.txt"; pe_ok = False if pe.exists(): try: t = pe.read_text(errors="replace") pe_ok = ("EyesonRaw" in t) and ("EyesonPDF" in t) and len(t) > 200 except Exception: pass s["ppd_excerpt"] = 1.0 if pe_ok else (0.4 if pe.exists() else 0.0) # 3) cups error log non-empty + topical cel = rd / "cups_error_log.txt"; cel_ok = False if cel.exists(): try: t = cel.read_text(errors="replace") cel_ok = (len(t.strip()) > 300 and ("EyesonRaw" in t and "EyesonPDF" in t) and sum(k in t for k in ["E ", "W ", "filter", "Duplex", "media", "stopped"]) >= 3 and re.search(r"\[\d{2}/[A-Za-z]{3}/\d{4}", t) is not None) except Exception: pass s["cups_error_log"] = 1.0 if cel_ok else (0.4 if cel.exists() else 0.0) # 4) cupsfilter before err mentions duplex / filter / supported cb = rd / "cupsfilter_before.err"; cb_ok = False if cb.exists(): try: t = cb.read_text(errors="replace").lower() cb_ok = ("duplex" in t and any(k in t for k in ["unsupported","not supported","reject"]) and any(k in t for k in ["cupsfilter","eyeson_wrap","filter failed"])) except Exception: pass s["cupsfilter_before"] = 1.0 if cb_ok else (0.3 if cb.exists() else 0.0) # 5) cupsfilter after: ps non-empty + err clean ca_ps = rd / "cupsfilter_after.ps"; ca_err = rd / "cupsfilter_after.err" after_ok = False if ca_ps.exists() and ca_ps.stat().st_size > 200: try: t = ca_err.read_text(errors="replace").lower() if ca_err.exists() else "" after_ok = "error" not in t and "fail" not in t except Exception: pass s["cupsfilter_after"] = 1.0 if after_ok else 0.0 # 6) diagnosis.json: 2 entries covering EyesonRaw + EyesonPDF dj = rd / "diagnosis.json"; entries = [] if dj.exists(): try: entries = json.loads(dj.read_text()) if isinstance(entries, dict): entries = [entries] except Exception: entries = [] queues = {e.get("queue") for e in entries if isinstance(e, dict)} exp_cat = {x["queue"]: x for x in expected.get("expected_root_causes", [])} good = 0 for e in entries: if not isinstance(e, dict): continue ref = exp_cat.get(e.get("queue"), {}) cat_ok = e.get("category") == ref.get("category") blob = (str(e.get("root_cause","")) + " " + " ".join(e.get("evidence_cli", []) or [])).lower() kw_ok = sum(k.lower() in blob for k in ref.get("keywords", [])) >= 2 fix_ok = any(c in str(e.get("fix_command","")).lower() for c in ["lpadmin","lpoptions","sed "]) if cat_ok and kw_ok and fix_ok: good += 1 s["diagnosis_count"] = 1.0 if len(entries) >= 2 else len(entries)/2.0 s["diagnosis_coverage"] = 1.0 if {"EyesonRaw", "EyesonPDF"} <= queues \ else (len(queues & {"EyesonRaw", "EyesonPDF"})/2.0) s["diagnosis_categories"] = good/2.0 # 7) GUI screenshots + OCR gui_shots = expected.get("expected_screens", [ "view_cups_jobs_red_banner.png", "view_cups_set_default_options.png", "view_system_config_printer_panel.png", "view_lpstat_terminal_before.png", "view_postrepair_completed_jobs.png", ]) import hashlib present, _seen = [], set() for n in gui_shots: p = rd/n if not p.exists(): continue h = hashlib.md5(p.read_bytes()).hexdigest() if h in _seen: continue _seen.add(h); present.append(n) s["gui_screens_count"] = len(present)/float(len(gui_shots)) ocr_kws = { "view_cups_jobs_red_banner.png": [["EyesonRaw"], ["Stopped","Paused","disabled"]], "view_cups_set_default_options.png": [["EyesonRaw"], ["Duplex"], ["PageSize","Media"]], "view_system_config_printer_panel.png": [["EyesonPDF"], ["Properties","Settings","Options"]], "view_lpstat_terminal_before.png": [["lpstat"], ["disabled","stopped"], ["Eyeson"]], "view_postrepair_completed_jobs.png": [["completed","Completed"], ["EyesonRaw","EyesonPDF"]], } ocr_hits = 0 try: import pytesseract from PIL import Image for n in present: try: tx = pytesseract.image_to_string(Image.open(rd/n)) if all(any(k.lower() in tx.lower() for k in grp) for grp in ocr_kws.get(n, [])): ocr_hits += 1 except Exception: pass s["gui_screens_ocr"] = ocr_hits/float(len(gui_shots)) except Exception: s["gui_screens_ocr"] = 0.5 * (len(present)/float(len(gui_shots))) # 8) lpstat_after has completed jobs and no stopped laf = rd / "lpstat_after.txt" if not laf.exists() and snaps: laf = Path(snaps[-1]) completed_ok = stopped_clean = False if laf.exists(): try: t = laf.read_text(errors="replace") has_struct = ("lpstat" in t.lower() or re.search(r"^\s*\S+-\d+\s+\S+\s+\d+", t, re.M) is not None) has_both = "EyesonRaw" in t and "EyesonPDF" in t n_completed = len(re.findall(r"\bcompleted\b", t, re.I)) n_stopped = len(re.findall(r"\b(?:stopped|disabled|paused)\b", t, re.I)) completed_ok = has_struct and has_both and n_completed >= 2 stopped_clean = has_struct and n_stopped == 0 except Exception: pass s["jobs_completed"] = 1.0 if completed_ok else 0.0 s["jobs_no_stopped"] = 1.0 if stopped_clean else 0.0 # 9) report.md rm = rd / "report.md"; n_lines = 0; sec_hits = 0 if rm.exists(): try: txt = rm.read_text(errors="replace") n_lines = len([1 for ln in txt.splitlines() if ln.strip()]) for kw in ["拓扑", "症状", "取证", "根因", "修复", "复验", "topology", "symptom", "evidence", "root cause", "fix", "regression"]: if kw.lower() in txt.lower(): sec_hits += 1 except Exception: pass s["report_present"] = 1.0 if n_lines >= 60 else n_lines/60.0 s["report_sections"] = 1.0 if sec_hits >= 6 else sec_hits/6.0 # 10) cross-channel: at least 2 CLI artifacts + 2 GUI screenshots cli_artifacts = sum(1 for p in [pe, cel, cb, ca_ps, dj, rm] if p.exists()) s["cross_channel_evidence"] = 1.0 if (cli_artifacts >= 4 and len(present) >= 2) \ else 0.0 # 11) VLM rubric try: from _judge_helper import vlm_score_rubric except Exception: vlm_score_rubric = None vlm_imgs = [str(rd/n) for n in [ "view_cups_jobs_red_banner.png", "view_cups_set_default_options.png", "view_postrepair_completed_jobs.png", ] if (rd/n).exists()] if vlm_score_rubric and vlm_imgs: rubric = { "vlm_cups_banner_visible": "截图清楚显示 CUPS Web UI 的 stopped/paused 状态条", "vlm_options_panel": "截图显示 Set Default Options 中的 Duplex / PageSize 下拉选择器", "vlm_completed_state": "post-repair 截图显示至少 2 条 completed 记录、不再有 stopped", "vlm_layout_clean": "整体截图布局整齐、文字可读、无明显裁切", } try: vlm = vlm_score_rubric(vlm_imgs[:3], rubric, instruction="评估 CUPS 队列修复前后的 GUI 截图质量") for k in rubric: s[k] = float(vlm.get(k, 0.0)) except Exception: for k in rubric: s[k] = 0.5 else: s["vlm_cups_banner_visible"] = 0.5 s["vlm_options_panel"] = 0.5 s["vlm_completed_state"] = 0.5 s["vlm_layout_clean"] = 0.5 nums = [v for v in s.values() if isinstance(v, (int, float))] base = sum(nums)/len(nums) if nums else 0.0 # Hard gates if not (cel.exists() or cb.exists() or pe.exists()): base = min(base, 0.4) # GUI hard-cap removed: rely on per-shot VLM/OCR sub-scores instead. vlm_avg = (s["vlm_cups_banner_visible"] + s["vlm_options_panel"] + s["vlm_completed_state"] + s["vlm_layout_clean"])/4.0 if vlm_score_rubric is not None and vlm_imgs and vlm_avg < 0.6: base = min(base, 0.6) if not (completed_ok and stopped_clean): base = min(base, 0.55) if not after_ok: base = min(base, 0.6) s["overall_score"] = round(base, 3) return s ``` ## Workspace Path ``` workspace/DSK/task_13_cups_printer_queue_repair ``` ## Skills ``` ``` ## Env ``` ``` ## Warmup ```bash mkdir -p /tmp_workspace/results /tmp_workspace/state /tmp_workspace/jobs /opt/dsk13_gt chmod 1777 /tmp_workspace/results /tmp_workspace/state /tmp_workspace/jobs 2>/dev/null || true chmod 700 /opt/dsk13_gt 2>/dev/null || true cat > /opt/dsk13_gt/expected.json <<'JSON' { "queues": ["EyesonPDF", "EyesonRaw"], "expected_root_causes": [ {"queue": "EyesonRaw", "category": "ppd_default_option", "keywords": ["Duplex","DuplexNoTumble","filter-failed","PPD"]}, {"queue": "EyesonPDF", "category": "media_mismatch", "keywords": ["media","A5","A4","PageSize","Letter"]} ], "min_findings": 2, "post_repair_required": {"no_stopped_jobs": true, "completed_jobs_min": 2, "cupsfilter_returncode": 0}, "expected_screens": ["view_cups_jobs_red_banner.png","view_cups_set_default_options.png","view_system_config_printer_panel.png","view_lpstat_terminal_before.png","view_postrepair_completed_jobs.png"], "min_cross_channel_switches": 5, "min_lpstat_snapshots": 2 } JSON chmod 600 /opt/dsk13_gt/expected.json 2>/dev/null || true chown -R root:root /opt/dsk13_gt 2>/dev/null || true export DEBIAN_FRONTEND=noninteractive export DISPLAY=${DISPLAY:-:0} which python3 || (apt-get update -o Acquire::Retries=10 -qq && DEBIAN_FRONTEND=noninteractive apt-get install -o Acquire::Retries=10 -y -qq python3 python3-pip tesseract-ocr poppler-utils ghostscript) || true pip install -q --break-system-packages reportlab pillow pytesseract 2>/dev/null || pip install -q reportlab pillow pytesseract 2>/dev/null || true python3 - <<'PYEOF' import pathlib B = "c" + "u" + "p" + "s" ppd_dir = pathlib.Path("/etc") / B / "ppd" ppd_dir.mkdir(parents=True, exist_ok=True) conf_path = pathlib.Path("/etc") / B / "printers.conf" log_dir = pathlib.Path("/var/log") / B log_dir.mkdir(parents=True, exist_ok=True) ppd = '''*PPD-Adobe: "4.3" *FormatVersion: "4.3" *FileVersion: "1.0" *LanguageVersion: English *PCFileName: "EYESONRAW.PPD" *Manufacturer: "Eyeson" *Product: "(EyesonRaw)" *ModelName: "EyesonRaw" *NickName: "EyesonRaw Virtual Queue" *PSVersion: "(3010.000) 0" *LanguageLevel: "3" *ColorDevice: True *DefaultColorSpace: RGB *OpenUI *PageSize/Media Size: PickOne *OrderDependency: 10 AnySetup *PageSize *DefaultPageSize: A4 *PageSize A4/A4: "<>setpagedevice" *PageSize Letter/US Letter: "<>setpagedevice" *CloseUI: *PageSize *OpenUI *Duplex/2-Sided Printing: PickOne *OrderDependency: 10 AnySetup *Duplex *DefaultDuplex: DuplexNoTumble *Duplex None/Off: "<>setpagedevice" *Duplex DuplexNoTumble/Long Edge: "<>setpagedevice" *CloseUI: *Duplex *%% Filter eyeson_wrap rejects DuplexNoTumble when PageSize=Letter (broken default) ''' (ppd_dir / "EyesonRaw.ppd").write_text(ppd) conf = '''# Printer configuration file written by warmup NextPrinterId 3 UUID urn:uuid:eyeson-pdf-0001 Info Eyeson Virtual PDF Queue Location Local MakeModel Generic PDF Printer DeviceURI pdf:/ State Stopped StateMessage "Filter failed: media mismatch" StateTime 1714000000 ConfigTime 1713999000 Accepting Yes Shared No JobSheets none none QuotaPeriod 0 PageLimit 0 KLimit 0 OpPolicy default ErrorPolicy stop-printer Option media A5 UUID urn:uuid:eyeson-raw-0002 Info Eyeson Raw Virtual Queue Location Local MakeModel EyesonRaw Virtual Queue DeviceURI file:///dev/null State Stopped StateMessage "Filter eyeson_wrap stopped: Duplex DuplexNoTumble unsupported on Letter" StateTime 1714000100 ConfigTime 1713999100 Accepting Yes Shared No JobSheets none none OpPolicy default ErrorPolicy stop-printer ''' conf_path.write_text(conf) log = '''I [01/May/2026:10:00:01 +0000] [Job 101] Starting filter chain for EyesonRaw. W [01/May/2026:10:00:02 +0000] [Job 101] Unsupported Duplex value "DuplexNoTumble" on PageSize Letter. E [01/May/2026:10:00:02 +0000] [Job 101] Filter "eyeson_wrap" stopped (exit status 1) E [01/May/2026:10:00:02 +0000] [Job 101] EyesonRaw stopped: filter exit code 1 W [01/May/2026:10:00:05 +0000] [Job 102] EyesonPDF: media A5 mismatch with submitted A4 page. E [01/May/2026:10:00:05 +0000] [Job 102] EyesonPDF stopped: media mismatch. I [01/May/2026:10:00:30 +0000] Printer "EyesonRaw" stopped by scheduler. I [01/May/2026:10:00:31 +0000] Printer "EyesonPDF" stopped by scheduler. ''' (log_dir / "error_log").write_text(log) pathlib.Path("/tmp_workspace/state/lpstat_stub.txt").write_text( 'printer EyesonPDF disabled since Wed 01 May 2026 10:00:31 -\n' ' Filter failed: media mismatch\n' 'printer EyesonRaw disabled since Wed 01 May 2026 10:00:30 -\n' ' Filter eyeson_wrap stopped (Duplex DuplexNoTumble unsupported on Letter)\n' ) out = pathlib.Path("/tmp_workspace/jobs"); out.mkdir(parents=True, exist_ok=True) try: from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import A4, letter for name, ps in (("sample_a4.pdf", A4), ("sample_letter.pdf", letter)): p = out / name if not p.exists(): c = canvas.Canvas(str(p), pagesize=ps) c.drawString(72, 720, "Eyeson sample: " + name) c.showPage(); c.save() except Exception: for name in ("sample_a4.pdf", "sample_letter.pdf"): p = out / name if not p.exists(): p.write_bytes(b"%PDF-1.4\n%EOF\n") PYEOF ls -l /etc/c"ups"/ppd/EyesonRaw.ppd /etc/c"ups"/printers.conf /var/log/c"ups"/error_log 2>/dev/null || true echo "[warmup-dsk13] done" ```