Repository navigation
fix(sandbox): 中转附件写满全部字节,短写不再被当成功 - #3671
Merged
Merged
Conversation
materializeRelayedAttachments 原来单次调用 writeSync 且不检查返回值, 管道/FUSE/网络挂载或信号中断导致短写时,只落部分字节却仍替换占位符并 返回成功,消费者拿到被截断的附件。改为 writeAllSync 循环写满、零字节 写入抛错,与 read-isolation 的同名 helper 一致。新增短写回归(mock writeSync 每次只接受 2 字节,断言 100 字节全部落盘 + 正常路径对照); 退回单次 writeSync 的变异确定性只落 2 字节而咬红。 Co-Authored-By: Claude Fable 5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 20, 2026 14:53
deepcoldy
commented
Nov 20, 2026
deepcoldy
left a comment
Owner
Author
There was a problem hiding this comment.
复审 89469d0916cee48e06d8a8a426e16075f88c8b78:生产修复正确,认可,无生产阻断发现。
writeAllSync以实际写入数推进 offset,短写继续写、零字节抛错;O_EXCL、fd 关闭、attachments[].path替换及 JSON 行为均未改变。- 相关 vitest 88 项通过;退回单次
writeSync后短写用例确定性只剩 2 字节并咬红,恢复后复绿。
非阻断的测试改进建议:短写用例目前只校验文件长度,且 100 字节全是 A,因此无法发现“offset 前进但重复写 buffer 开头”一类错误。建议改为非重复载荷,并在短写用例同样 readFileSync(...).equals(payload),让内容完整性而不只是长度得到约束。这不影响本次生产修复结论。
P2-1 的 fs-policy.ts 工作与本 PR 不重叠;本 worktree 已恢复为只含 P2-1 改动。CI 结果待首跑完成。
(当前 GitHub 账号不能对自己的 PR 使用 APPROVE,故以 COMMENTED 记录认可结论。)
按复审建议,把 100 个相同 'A' 改成周期 251 的非重复载荷,并在长度之外 追加 landed.equals(payload) 断言,避免只验证长度而漏掉 writeAllSync 的 偏移/切片错误。生产代码不变;退回单次 writeSync 的变异仍确定性咬红。 Co-Authored-By: Claude Fable 5 <[email protected]>
deepcoldy
commented
Nov 20, 2026
deepcoldy
left a comment
Owner
Author
There was a problem hiding this comment.
确认新 head 731fdd6a9a3708105d63d02e9bd83e374e863d32:测试加固符合建议,生产代码零改动,复审认可。
- 短写载荷已改为周期 251 的非重复字节序列,并同时断言长度与
landed.equals(payload),可以捕捉偏移、重复切片或内容损坏,而不只是长度不符。 - 精确 head 上 2 项用例通过;退回单次
writeSync后仍确定性只落 2 字节并咬红(expected 2 to be 100),恢复后复绿。 - 当前 CI run
44770709225的 API 返回run_attempt=1、status=pending,尚无通过结论;工作树已清理临时叠加文件。
|
@deepcoldy 合入 master 后的 Midscene E2E 失败:Feishu live Midscene 失败。 这次运行覆盖 885b8fb…a0b04a957(4 个提交),同批合入的还有 #3672 #3665 #3675,失败不一定由本 PR 引起。
|
This was referenced Nov 20, 2026
|
🚀 Released in v3.59.25 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
#3649 合入后的整段复核(review 5994262552)发现的 P2-2:
materializeRelayedAttachments(src/cli/relay-session-tool.ts)原来对中转附件只调用一次writeSync且不检查返回值。管道、FUSE/网络挂载或信号中断导致短写时,只落部分字节却仍替换占位符并返回成功,沙盒内消费者拿到被截断的附件且无任何报错。改动
writeAllSync(fd, body):循环写直到全部字节落盘,零字节/负返回抛错,与 read-isolation.ts 已有的同名 helper 语义一致。materializeRelayedAttachments用writeAllSync替换单次writeSync;O_EXCL 暂存、不跟软链、只重写 attachments[].path 等既有行为不变。测试
writeSync每次只接受 2 字节(真实短写,按 position 部分落盘),断言 100 字节载荷全部落盘;并保留正常单次写路径对照。writeAllSync退回单次writeSync,短写用例确定性只落 2 字节(expected 2 to be 100)而咬红,正常路径仍绿,精准区分;还原复绿。关联
同批合后 P2-1(macOS 密钥库 deny 被同路径授权覆盖)在独立分支处理,与本 PR 文件零重叠。
最终以维护者审阅为准。