---
name: bioinformatics-log-resume
description: 为生物信息学多样本批处理脚本设计、实现或审查基于日志的断点续跑。用于 bash/shell 主控脚本需要支持中断后重跑、并行写日志防竞争、按样本写入 success.log 和 fail.log、并且明确禁止通过扫描输出目录或输出文件判断完成状态的场景。适用于给现有流水线补加断点续跑、重构样本循环、或检查实现是否只依赖日志判定完成。
title: bioinformatics-log-resume
canonical_url: https://skilld.dev/gh/victory-hugo/s2-agent-skill/bioinformatics-log-resume
last_updated: 2026-10-07T11:02:39.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [references/log-contract.md](https://skilld.dev/api/skills-raw/victory-hugo/s2-agent-skill/bioinformatics-log-resume/references/log-contract.md), [references/shell-patterns.md](https://skilld.dev/api/skills-raw/victory-hugo/s2-agent-skill/bioinformatics-log-resume/references/shell-patterns.md).
>
> If the user asked to install this Skill, run `npx skilld install victory-hugo/s2-agent-skill/bioinformatics-log-resume`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/bioinformatics-log-resume`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/victory-hugo/s2-agent-skill/bioinformatics-log-resume) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/bioinformatics-log-resume`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/bioinformatics-log-resume --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/bioinformatics-log-resume --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Bioinformatics Log Resume

## 概述

使用这个 skill 为生物信息学多样本批处理脚本添加或审查断点续跑。该 skill 采用固定的日志驱动协议，只允许通过 `log/` 下的日志文件判断样本是否已完成，禁止通过扫描输出目录、结果文件或中间文件来推断完成状态。

## 固定协议

始终遵循以下规则：

- 在项目脚本启动时创建 `log/` 目录。
- 在 `log/` 下固定使用 `log/.resume.lock`、`log/success.log`、`log/fail.log`。
- 每个样本执行结束后立刻写日志，不能批量补写。
- 只从 `success.log` 第一列的样本 ID 判断是否完成。
- `fail.log` 只记录失败历史，不作为下次运行时的跳过依据。
- 如果样本同时出现在 `success.log` 和 `fail.log`，以成功为准，下次运行跳过。
- 并行场景必须对日志写入加锁，避免多个进程竞争写文件。
- 明确禁止扫盘，不能通过输出目录、结果文件、flag 文件或文件大小判断样本是否已完成。

## 实施流程

按以下顺序组织实现：

1. 识别样本循环的位置，以及样本 ID 的唯一来源。
2. 确定项目根目录，设置 `LOG_DIR`、`LOCK_FILE`、`SUCCESS_LOG`、`FAIL_LOG`。
3. 在主控脚本开始阶段执行 `mkdir -p "$LOG_DIR"` 并初始化日志文件。
4. 在正式处理样本前，从 `success.log` 第一列读取已完成样本集合。
5. 每次准备处理样本时，只检查该样本是否已在已完成集合中；如果在，则跳过。
6. 样本成功完成后，在锁保护下向 `success.log` 追加 `sample_id<TAB>timestamp`。
7. 样本失败后，在锁保护下向 `fail.log` 追加 `sample_id`。
8. 审查并删除任何基于输出文件存在性、输出目录扫描或结果文件完整性的完成判定逻辑。

## Shell 实现要求

- 优先面向 `bash` 或兼容 shell 的主控脚本。
- 默认使用 `flock` 操作 `log/.resume.lock`。
- 成功日志使用 `sample_id<TAB>timestamp` 格式，时间戳推荐 `date -Iseconds`。
- 失败日志默认只写样本 ID；如果需要附加错误信息，应另建独立诊断日志，不要改变 `fail.log` 作为失败样本列表的职责。
- 失败样本默认在下次运行时继续重试，只要其样本 ID 不在 `success.log` 中。
- 默认采用 continue-on-error 的逐样本处理方式，不因单一样本失败而直接让整个批处理退出；只有用户明确要求 fail-fast 时才改变该策略。

## 审查清单

交付前逐项核查：

- 是否只依赖 `success.log` 判断完成状态。
- 是否完全禁止扫盘判断完成。
- 是否每个样本结束后立刻写日志。
- 是否所有日志追加都受锁保护。
- 是否失败样本默认会在后续运行中重试。
- 是否存在样本 ID 重复匹配、模糊匹配或部分匹配问题。
- 是否把日志目录错误地放在 `output/` 内。

## 参考资料

- 日志协议：读取 `references/log-contract.md`
- Shell 模式与反例：读取 `references/shell-patterns.md`
