Repository navigation
Conversation
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
APPROVE.
Direction (issue #6087). Verified the defect independently before reviewing the code: the fast path in writeRestoredImage (src/image-restore.ts:441) used existsSync(path) alone, so once a spill file existed — even zero-byte or partial after an interrupted writeFileSync — every later turn skipped the write forever, and decompress({ imageRef }) kept serving truncated bytes. The fix targets the PREDICATE (the producer of the wrong decision), not a downstream mask: skip only when the path is a regular file of exactly the expected decoded size; anything else falls through and is rewritten from the resent original. The module header already documents that clients re-send full raw history every turn, so the repair opportunity arrives naturally each turn. Root cause, not symptom.
Verification (evidence, not "should work").
- Ran the PR's test file against the PRE-FIX source (parent commit
541cf260c4): exactly the two new repair tests fail — 11 pass / 2 fail, matching the author's before-report byte-for-byte. At head6f2a54640: 13/13 pass. npm run typecheckclean at head; no leftover references to the removedexistsSyncimport.- CI on head
6f2a54640: green per lane status; mirror-cache snapshot shows 0 failed checks. - Master has moved 10 commits since the PR base but ZERO of them touch
src/image-restore.tsortests/image-restore.test.ts; PR reportsmergeable: true. BEHIND is not a blocker.
Regression inventory (existing behaviors on the touched paths, each judged):
- Steady-state skip cost — PRESERVED: still exactly one stat per image per turn (
existsSync→statSync, same order); the new mtime-control pass pins "complete file ⇒ no rewrite". - Content-salt idempotency & rebase protection (#1995 F1) — PRESERVED: same bytes ⇒ same digest-named path ⇒ size matches ⇒ skip; the rebase-generation test still passes.
- Cross-session isolation (per-session dirs) — UNTOUCHED.
- Write-failure handling — UNCHANGED (warn + null, caller skips the entry). One degenerate-case delta, disclosed: if a DIRECTORY ever sat at the content-addressed file path, old code returned the broken path silently; new code hits
isFile()==false,writeFileSyncthrows EISDIR into the existing catch → warn log + null (image simply not indexed that turn). Strictly more honest than silent broken-path return; degenerate state only. - 7-day spill prune (
pruneRetrieveImgExports) — UNTOUCHED. - Wire / both compression modes / caches — UNTOUCHED: this module only writes local spill files; no wire bytes, no prompt-cache surface.
Behavior change disclosure (old → new). Skip-write condition: "path exists" → "path is a regular file with size == decoded byte count". Consequence: zero-byte/partial spills are now REPAIRED from the resent original on the next index pass instead of staying broken indefinitely — the intended fix. Author-documented boundary: same-size content corruption remains outside this size-based repair (digest salt makes same-path-different-content practically unreachable otherwise). Comparison uses body.length (the actual buffer written), correctly avoiding the padding-sensitive floor(b64len×3/4) approximation in img.bytes.
Test quality. Real wire conversion (openaiToCore) + real disk + byte-exact comparison; both gate directions pinned per #3617 discipline (repair fires for 0-byte AND 8-byte truncation; third pass proves the fast path still skips when complete — via mtime equality, granularity-safe on Windows too). Isolated XDG_STATE_HOME, unique session ids, deterministic, no ports.
Diff cleanliness. 2 files, +20/−3; every line in scope; dead import removed. No lockfile/generated churn.
八问(结构化审核结论)
- 是什么问题:图片溢出文件(spill)被截断成零字节/部分字节后,即使客户端后续轮次重新携带完整原图,恢复路径也永远指向截断的字节——
decompress({ imageRef })还原出坏图。 - 什么原因导致的:快路径谓词只查
existsSync(path),不校验文件是否完整;写一半被打断(进程崩溃/磁盘故障)后路径永久存在,后续所有轮次都被「已存在」跳过。根因在谓词本身,修复打在谓词上而非下游掩盖。 - 影响范围与严重程度:仅影响发生过写中断的会话中的对应图片(触发条件窄:需要 writeFileSync 中途失败);一旦命中该图永久不可恢复,手动删除坏文件可绕行——特定条件下的可用性缺陷,p2 级,非会话级数据丢失。
- 怎么修复的:收紧跳过条件为「常规文件且大小 == 解码字节数」,其余情况一律用重传的原字节重写修复;比较用实际写入缓冲
body.length(避免 base64 padding 近似误差)。 - 是否有回归问题:逐项清点既有行为——稳态成本(每图每轮一次 stat,保持)、幂等与内容盐 rebase 保护(#1995 F1,保持)、跨会话隔离(未动)、错误处理(保持;唯一差异是「目录占据文件路径」退化态从静默返回坏路径变为 warn+null,更诚实)、7 天清理(未动)、双压缩模式线协议与缓存(未触)。无回归。
- 是否破坏缓存:不涉及——只写本地溢出文件,不触碰 prompt cache/前缀缓存/重试策略。
- 是否改了设计方向:否——同模块内单谓词收紧,架构、边界、数据流不变。
- 是否引入了新的配置:无新 env/config/默认值。
判定:APPROVE。 单模块纯 fix:、回归测试有牙(旧码上实测红、head 上绿)、diff 干净、引用 Closes #6087、CI 绿;满足 §7.4 auto-merge 条件(未触 kernel/、未触承重设施),合并判定交人工/auto-merge 管道。
Review lane done: PR #6089 reviewed end-to-end — APPROVE (red/green A/B on the new tests, typecheck clean, regression inventory 6/6 preserved).
[bot] 🏷 Review complete — APPROVE posted on the PR (review #5837317071) at head What was done & verified:
八问(结构化审核结论)
判定:APPROVE。 单模块纯 |
|
Landed via batch PR #6439 (merged) — closing as superseded. |
[bot] 🏷 Acknowledged — verified before closing the loop on my side: the batch PR (GitHub #6439, merged 2026-11-12T14:01:25Z) landed this fix on master as commit |
[bot] 🏷 Status: already complete — no further action needed. This is a re-trigger of an already-finished thread. I verified the current state live before replying (not from memory):
The fix is in, the PR is closed as superseded, and the owner's floor-6 ruling ("Landed via batch PR #6439 (merged) — closing as superseded") is the final word. Nothing to re-review, re-label, or re-open — closing the loop on my side. |
Problem
persistImageToDisk treats every existing path as a complete image. Zero-byte or partial spill files stay broken even after a later request provides the complete original image again, so restored references keep pointing at truncated bytes.
Changes
Skip writing only when the existing path is a regular file with the expected decoded byte count. Repair incomplete spills from original bytes. A third unchanged indexing pass preserves the completed file mtime; same-size corruption is outside this size-based repair.
Validation
The full remote-suite verdict belongs to CI. #2022 introduced image references and the existing-path fast path. Prior identity/collision and session cleanup work does not restore incomplete image bytes. All 3,221 historical PRs were screened; independent of #6046–#6055.
Closes #6087