--- id: DSK_task_1_dup_triage name: Nautilus 文件冲突批量解决 category: DSK timeout_seconds: 1200 --- ## Prompt Copy `/tmp_workspace/source/` (contains 135 files, of which 45 filenames collide with destination) into `/tmp_workspace/dest/` (which already has 95 files, 45 of which will collide with source by name). The file manager will pop up a conflict dialog for each duplicate filename during the copy. ### Task Handle conflicts one by one according to the following policy (4 decision classes total): - If source and dest files have mtime difference ≤ 1 day and identical size → skip (`skip`); - If filenames are identical but contents are in entirely different domains (e.g. meeting notes on one side, recipe on the other) → keep both (`keep_both`, the new file gets a ` (copy)` suffix); - If the dst file has a newer mtime but content is obviously truncated (placeholder) → skip and preserve the older but more complete dst (`skip_older`); - Otherwise → replace and preserve the old version (`replace` + old file gets a `.bak.` suffix, i.e. use rename to first rename the old dest file and then overwrite). Specific scale: - source/ contains **135 files**, dest/ contains **95**, with **45 pairs** of name collisions. - Of these, **10 pairs** are "same name, different domain" — identical filenames but entirely different contents (meeting notes on one side, recipe on the other), and must be **keep_both**. - Of these, **5 pairs** are "newer mtime but worse content" — dst is a placeholder (newer mtime), src is 30 days old but more complete; these must be **skip_older** (i.e. preserve the older but better dst and discard src's fake "newer" version). **Looking at mtime alone will misclassify all of them.** ### Deliverables (write to `/tmp_workspace/results/`) - `conflict_log.csv`: columns `filename,decision(skip|replace|keep_both|skip_older),reason`. - `final_inventory.csv`: every file under the dest directory + size + mtime + sha256. - `conflict_.png`: screenshot of the dialog / operation for each conflict decision, **at least 15 images**. - Final `/tmp_workspace/dest/` file count ≥ **150** and no original important dest file is lost (the list of important files is in `keep_list.txt`). - `/tmp_workspace/dest/` must contain ≥ **10** newly added files with the `.bak.` suffix (this format is used when renaming old dest files). ## Expected Behavior 参考解题流程 (设计者参考, 不发给 agent): 1. 用 Nautilus 打开两个窗口 (source / dest), 全选 source 的 135 个文件, 拖拽到 dest。 2. 对弹出的 "Conflict" 对话框, 按以下策略逐项处理 (共 4 类 decision): - 如果 source 与 dest 文件 mtime 差 ≤ 1 天且 size 相同 → 跳过 (`skip`); - 如果文件名相同但内容属于完全不同领域 (例如一边是 meeting notes, 一边是 recipe) → 保留双方 (`keep_both`, Nautilus 会把新文件加 ` (copy)` 后缀); - 如果 dst 文件 mtime 较新但内容明显残缺 (placeholder) → 跳过保留更旧但更完整的 dst (`skip_older`); - 否则 → 替换并保留旧版 (`replace` + 旧文件加 `.bak.` 后缀, 需用对话框 Rename 先把 dest 老文件重命名); - 对每个对话框截图 (`conflict_.png`)。 3. 完成后写 `conflict_log.csv`: 列 `filename,decision(skip|replace|keep_both|skip_older),reason`。 4. 写 `final_inventory.csv`: dest 目录下所有文件 + 大小 + mtime + sha256 (用 Nautilus 的 Properties 面板看 sha256 太麻烦, 可用文件管理器的 "Open Terminal Here" 后跑 sha256sum, 但拷贝/冲突解决必须 GUI)。 判分要点速览: - dest 文件数 ≥ 150 (45 冲突中: 5 skip + 25 replace + 10 keep_both 产生双份 + 5 skip_older + 90 novel src 直接拷入) - keep_list 中文件全部仍存在 (可能被改名 .bak) - conflict_*.png 数量 ≥ 15, 覆盖 4 类 decision 的对话框 - `.bak.` 文件 ≥ 10 - `conflict_log.csv` 行数 ≥ 45, decision 列覆盖 skip/replace/keep_both/skip_older 四类 - `final_inventory.csv` 行数与 dest 实际文件数一致, 含 filename/size/mtime/sha256 四列 ## Source - Reddit: https://www.reddit.com/r/gnome/comments/1bxxxxx/nautilus_conflict_dialog_agent/ - 原文引用:「Agent always silently overwrites with rsync; my real workflow needs case-by-case decisions in the file manager dialog.」 - 对应 benchmark case: DSK / 新增 ## Grading Criteria - [ ] `dest/` 文件数 ≥ 150 - [ ] keep_list.txt 中每个文件名(基名)在 dest 中存在(含 .bak 变体) - [ ] `conflict_log.csv` 行数 ≥ 45,decision 列覆盖 skip/replace/keep_both/skip_older 四类 - [ ] `final_inventory.csv` 行数等于 dest 文件数,schema = filename/size/mtime/sha256 - [ ] `conflict_*.png` ≥ 15 张,至少部分能 OCR 到 "Conflict"/"已存在"/"Replace"/"Skip" - [ ] dest 中至少 10 个文件以 `.bak.` 后缀存在(unix_ts 为 9~10 位数字) - [ ] decision 与 gt/expected.json 真值对齐率 ≥ 0.8 ## Automated Checks ```python from pathlib import Path import csv, re, json, hashlib from PIL import Image def grade(workspace_path=None, **kwargs): workspace = Path(workspace_path) if workspace_path else Path("/tmp_workspace") """Stricter DSK_4: decisions per file must match real diff truth (gt/expected.json).""" try: import pytesseract except: pytesseract=None gt = json.loads(Path("/tmp_workspace/gt/expected.json").read_text()) if Path("/tmp_workspace/gt/expected.json").exists() else {} skip_truth = set(gt.get("skip_files",[])) | set(gt.get("skip_older_files",[])) replace_truth = set(gt.get("replace_files",[])) keep_both_truth = set(gt.get("keep_both_files",[])) skip_older_truth = set(gt.get("skip_older_files",[])) s = {} dest = workspace/"dest" files = list(dest.glob("*")) if dest.exists() else [] s["dest_count"] = 1.0 if len(files) >= gt.get("expected_dst_min_count",150) else len(files)/max(gt.get("expected_dst_min_count",150),1) kl = workspace/"keep_list.txt" if kl.exists(): keep = [l.strip() for l in kl.read_text().splitlines() if l.strip()] existing = set(p.name for p in files) intact = sum(1 for k in keep if any(k==n or n.startswith(k+".bak.") for n in existing)) s["keep_intact"] = intact/max(len(keep),1) else: s["keep_intact"] = 0.0 cl = workspace/"conflict_log.csv" if cl.exists(): rows = list(csv.DictReader(cl.open())) s["log_lines"] = min(1.0, len(rows)/45) decisions_seen = {r.get("decision","") for r in rows} required = {"skip","replace","keep_both","skip_older"} s["log_dual_decisions"] = len(decisions_seen & required) / len(required) # decision-vs-truth alignment (4-class) ok=0 for r in rows: d=r.get("decision",""); fn=r.get("filename","") if d=="skip" and (fn in skip_truth and fn not in skip_older_truth): ok+=1 elif d=="skip_older" and fn in skip_older_truth: ok+=1 elif d=="skip" and fn in skip_older_truth: ok+=1 # tolerate skip merged elif d=="replace" and fn in replace_truth: ok+=1 elif d=="keep_both" and fn in keep_both_truth: ok+=1 s["decision_truth_alignment"] = ok/max(len(rows),1) else: s["log_lines"]=0.0; s["log_dual_decisions"]=0.0; s["decision_truth_alignment"]=0.0 fi = workspace/"final_inventory.csv" if fi.exists(): rows = list(csv.DictReader(fi.open())) s["inventory_match"] = 1.0 if abs(len(rows)-len(files))<=2 else max(0, 1-abs(len(rows)-len(files))/len(files) if files else 0) s["inventory_schema"] = 1.0 if rows and all(k in rows[0] for k in ["filename","size","mtime","sha256"]) else 0.0 else: s["inventory_match"]=0.0; s["inventory_schema"]=0.0 pngs = list(workspace.glob("conflict_*.png")) # Filter out placeholder/blank screenshots (< 5KB) to defeat trivial fakes valid_pngs = [p for p in pngs if p.stat().st_size >= 5120] s["conflict_screenshots"] = min(1.0, len(valid_pngs)/gt.get("min_conflict_screens",15)) # Anti-cheat: md5 uniqueness + min resolution uniq_md5 = set(); res_ok = 0 for p in valid_pngs: try: uniq_md5.add(hashlib.md5(p.read_bytes()).hexdigest()) with Image.open(p) as im: if im.size[0] >= 800 and im.size[1] >= 600: res_ok += 1 except: pass s["conflict_unique"] = min(1.0, len(uniq_md5)/max(gt.get("min_conflict_screens",15),1)) s["conflict_resolution"] = min(1.0, res_ok/max(gt.get("min_conflict_screens",15),1)) if valid_pngs and pytesseract: ok = 0 for p in valid_pngs[:12]: try: tx = pytesseract.image_to_string(Image.open(p)) if any(k in tx for k in ["Conflict","已存在","Replace","Replace All","跳过","Skip","Keep Both","保留"]): ok+=1 except: pass s["conflict_ocr"] = min(1.0, ok/6) vlm_available = True else: s["conflict_ocr"]=0.0 vlm_available = False bak_pat = re.compile(r"\.bak\.\d{9,10}$") bak = sum(1 for p in files if bak_pat.search(p.name)) s["bak_files"] = min(1.0, bak/gt.get("min_bak_files",10)) # keep_both: src 拷贝后 Nautilus 会生成 ` (copy)` 或 ` (1)` 后缀文件,与原 dst 同名基础 if keep_both_truth and files: names = [p.name for p in files] kb_ok = 0 for fn in keep_both_truth: base = fn.rsplit(".",1)[0]; ext = fn.rsplit(".",1)[1] if "." in fn else "" # 原文件存在 + 至少一个变体存在 has_orig = fn in names has_variant = any((fn != n) and (base in n) and (ext == "" or n.endswith("."+ext)) for n in names) if has_orig and has_variant: kb_ok += 1 s["keep_both_kept"] = kb_ok / len(keep_both_truth) else: s["keep_both_kept"] = 0.0 # Forbidden CLI commands log = workspace/"actions.log" if log.exists(): txt = log.read_text(errors="ignore") s["no_cli_copy"] = 0.0 if re.search(r"\b(cp|rsync|mv)\s+-", txt) else 1.0 else: s["no_cli_copy"] = 1.0 # v2 加权评分: 核心交付 60% / GUI 证据 30% / 辅助 10% core_keys = ["dest_count","keep_intact","log_lines","log_dual_decisions", "decision_truth_alignment","inventory_match","inventory_schema", "bak_files","keep_both_kept"] gui_keys = ["conflict_screenshots","conflict_unique","conflict_resolution","conflict_ocr"] aux_keys = ["no_cli_copy"] def _avg(keys): vals = [s[k] for k in keys if k in s and isinstance(s[k],(int,float))] return sum(vals)/len(vals) if vals else 0.0 base = 0.6*_avg(core_keys) + 0.3*_avg(gui_keys) + 0.1*_avg(aux_keys) # Hard gate 1: GUI 证据 (截图数 + 唯一性 + 分辨率) 必须真实 if s.get("conflict_screenshots",0) < 0.7: base = min(base, 0.4) if s.get("conflict_unique",0) < 0.6: base = min(base, 0.40) # 大量重复截图 = 伪造 if s.get("conflict_resolution",0) < 0.6: base = min(base, 0.45) # 缩略图占位 = 退化 # Hard gate 2: CLI 拷贝禁令 if s.get("no_cli_copy",1) < 1.0: base = min(base, 0.35) # Hard gate 3: 核心交付物 (log + inventory + decision) 任一缺失 if min(s.get("log_lines",0), s.get("inventory_schema",0), s.get("decision_truth_alignment",0)) < 0.5: base = min(base, 0.45) # Hard gate 4: decision 对齐严格梯度 dta = s.get("decision_truth_alignment",0) if dta < 0.5: base = min(base, 0.35) elif dta < 0.7: base = min(base, 0.55) # Hard gate 5: dest_count if s.get("dest_count",0) < 0.85: base = min(base, 0.5) if s.get("dest_count",0) < 0.6: base = min(base, 0.35) # Hard gate 6: keep_both/skip_older v2 升级专属——agent 不能整片忽略 if s.get("keep_both_kept",0) < 0.4: base = min(base, 0.55) # Hard gate 7: VLM/OCR 不可用时封顶 0.6 (避免无证据满分) if not vlm_available: base = min(base, 0.6) s["overall_score"] = round(base, 3) # ----- BEGIN CHEAT/VLM HARD-GATE (auto-injected) ----- try: from _judge_helper import audit_chat_jsonl_for_banned as _audit except Exception: _audit = None _BANS = ['rsync --ignore-existing', 'rsync -a --ignore', 'cp -an', 'cp -rn', 'cp --no-clobber', 'cp -fr ', 'cp -rf '] if _audit is not None: try: _a = _audit(_BANS) s["audit_total_tool_calls"] = _a.get("total_tool_calls", 0) s["audit_screenshots"] = _a.get("computer_screenshots", 0) s["audit_any_banned"] = 1.0 if _a.get("any_banned") else 0.0 s["audit_matches"] = ",".join(_a.get("matches", [])[:5]) if _a.get("any_banned") and _a.get("computer_screenshots", 0) == 0: s["overall_score"] = min(float(s.get("overall_score", 1.0)), 0.30) if _a.get("total_tool_calls", 0) >= 5 and _a.get("computer_screenshots", 0) == 0: s["overall_score"] = min(float(s.get("overall_score", 1.0)), 0.45) except Exception as _e: s["audit_error"] = str(_e)[:120] # ----- END CHEAT/VLM HARD-GATE ----- return s ``` ## Workspace Path `workspace/DSK/task_1_dup_triage/` ## Skills ``` ``` ## Env ``` ``` ## Warmup ```bash mkdir -p /tmp_workspace/dest 2>/dev/null || true chown -R user:user /tmp_workspace 2>/dev/null || true rm -f /home/user/.openclaw/agents/main/sessions/*.lock 2>/dev/null || true openclaw config unset agents.defaults.imageModel >/dev/null 2>&1 || true openclaw config set agents.defaults.sandbox.imageModel.primary "" >/dev/null 2>&1 || true ```