Skip to content

docs(agents): os-dev isolates scratchpad temp files in a per-issue subdir (#5614) - #5727

Merged
os-zhuang merged 1 commit into
mainfrom
claude/issue-5614-scratchpad-isolation
Aug 6, 2026
Merged

docs(agents): os-dev isolates scratchpad temp files in a per-issue subdir (#5614)#5727
os-zhuang merged 1 commit into
mainfrom
claude/issue-5614-scratchpad-isolation

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Fixes #5614

采 issue 建议的方案 2(结构式),PM 已裁定:结构优于纪律。单文件文档改动,仅 .claude/agents/os-dev.md,+10/-0。

失败形状(issue 实测)

同一 PM 会话并行派发的 os-dev subagent 共享同一个容器 scratchpad 目录,目录里没有任何东西区隔各单的临时文件。于是最自然的文件名(pr-body.mdnotes.mddiff.txt)天然撞车:后写者覆盖先写者,双方都拿到成功回执,受害面是「拿自己的名字读回别人的内容」。已实咬一次——#5483 的 dev 写的 PR 正文草稿被同批 #5176 的 dev 覆写,直到回读才发现内容换了主(PR #5609 因该 dev 当场改名规避而未受影响)。批次越大碰撞概率越高。

改动

开工步骤区的 worktree-first 条目下新增一条子项:开工即在 scratchpad 下建本单专属 issue- + 单号 子目录,所有临时文件(PR 正文草稿、报告草稿、中间测量、探针输出)只写在其中;附一两句静默覆写的失败形状与 #5614/#5483/#5176 实例;并给出与 worktree-per-task 同构的定位——靠结构隔离,不靠记性

放置位置的取舍:写成 worktree-first 的子项而非新编号项。两个理由——(1) 形状同构、位置紧邻,worktree 隔离共享检出、scratchpad 隔离共享临时目录,后者正是前者「低一级」的同一条规则;(2) 插入新编号项会把原 2–6 项整体顺延,而文件后段「premise_still_valid: false …(rule 6)」是按编号交叉引用的,顺延即断链——本单要求现有段落一字不动,故不改编号。列表层级/缩进(3 空格 - + 5 空格续行)与既有第 3 条子项完全一致。

范围严格限于该一条:收尾清单、Byte discipline、Toolchain traps、Resource discipline、报告模板等段落一字未动;AGENTS.md 与 SKILL.md 未触碰(治理面一处落点够用)。

验证

纯 prompt 文档改动,没有可执行断言面,因此逆向验证(还原被删分支看诊断转红)对本单不适用——没有被删除的代码分支,也没有会因此变色的测试;这里如实说明,不编造形状相符的证据。实际做的是:

  • git diff --numstat = 10 0,单文件单 hunk;前后上下文行逐字节未变(-U6 复核)。
  • node scripts/check-nul-bytes.mjs 绿:OK (scanned 5614 tracked text file(s); …; no raw ASCII control bytes),含 test(devx): check-nul-bytes 的 --self-test 断言字符类引用面逐字节相等,终结该族漂移 (#5646) #5680 的字符类引用面断言(该行未触碰)。
  • 改动文件自扫控制字节零命中:grep -naP '[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]' 退出码 1。
  • markdown 结构:反引号与 ** 强调全文成对,新增行无行尾空白、无超 80 列(全文 3 处超宽均为改动前既有行)。
  • 实践自证:本 PR 正文草稿本身就写在 scratchpad 的 issue-5614/ 子目录里,按本 PR 新增的这条纪律执行。

发布面

.claude/ 文档-only,不发布任何包,无 changeset → 走 skip-changeset 标签路线(按 os-dev.md 现行收尾清单:回读 labels → 写并集 → 再回读)。


Generated by Claude Code

…bdir (#5614)

Parallel os-dev agents dispatched in one batch share a single container
scratchpad directory. Nothing separates their temp files, so the natural
filenames — `pr-body.md`, `notes.md`, `diff.txt` — collide: whoever writes
last wins, both writers get a success receipt, and the loser reads the other
agent's content back under its own name. Measured once already (#5614): the
#5483 agent's PR body draft came back as the #5176 agent's, discovered only
on read-back.

Fixed structurally rather than by convention, one level down from the
worktree-first rule it mirrors: the agent creates an `issue-<n>/` subdir
under the scratchpad as a first step and writes every temp file only there,
so isolation does not depend on each agent remembering to decorate filenames.

Added as a sub-bullet of the worktree-first rule (same shape, adjacent
location) instead of a new numbered item, which would renumber items 2-6 and
break the `(rule 6)` cross-reference further down the file.
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 6, 2026 2:13am

Request Review

@github-actions github-actions Bot added the size/s label Aug 6, 2026
@os-zhuang os-zhuang added the skip-changeset PR has no user-facing published change; bypasses the changeset gate label Aug 6, 2026 — with Claude
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 6, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review August 6, 2026 02:26
@os-zhuang
os-zhuang added this pull request to the merge queue Aug 6, 2026
Merged via the queue into main with commit 50f04dc Aug 6, 2026
24 of 25 checks passed
@os-zhuang
os-zhuang deleted the claude/issue-5614-scratchpad-isolation branch August 6, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s skip-changeset PR has no user-facing published change; bypasses the changeset gate

Projects

None yet

2 participants