T06 · System Persistence
- Location
lib/state_manager.py:560- Finding
Cross-session persistence through scheduled verification tasks
- Content
View full analysis
"" # 输出格式: cron action=add schedule.kind=every everyMs= ... ``` ``` ```python def schedule_verification(bug_id, hours_list=None, path=None): """安排验证计划 — 带文件锁保护""" if hours_list is None: hours_list = [24, 168, 720] fp = path or locate() lock_held = _acquire_file_lock(fp) try: state = read(fp) state.setdefault("verifications", {})[bug_id] = { "scheduled_at": hours_list, "checks": {}, "status": "pending", "created_at": now_iso(), } state.setdefault("_verify_needs_cron", []).append({ "bug_id": bug_id, "hours": hours_list, "created_at": now_iso(), }) state["updated_at"] = now_iso() write(state, fp) return state finally: if lock_held: _release_file_lock(fp) ``` ```python def generate_cron_instructions(bug_id, test_cmd, path=None): state = read(path) vinfo = state.get("verifications", {}).get(bug_id) if vinfo is None: log.error("%s 无验证计划", bug_id) return [] instructions = [] now = datetime.now(TZ) for h in vinfo.get("scheduled_at", []): future = now + timedelta(hours=h) at_iso = future.isoformat(timespec="seconds") instructions.append({ "bug_id": bug_id, "hours": h, "at": at_iso, "message": f"验证 {bug_id} ({h}h复查): 运行 {test_cmd}", "sessionTarget": "isolated", "hint": f"cron add schedule.kind=at at={at_iso} sessionTarget=isolated", }) return instructions ``` ...[truncated 1711 chars]- Remediation
View remediation
