Repository navigation
fix(benchmark): stop reading oversized preparation resources - #550
Inference1 wants to merge 1 commit into
Conversation
Bound each preparation read by the frozen resource size. Report the first excess byte as an integrity failure and continue to verify exact-size resources by digest. Agent-assisted-by: Codex (author) Signed-off-by: Inference1 <3617237115@qq.com>
zengchuang-hw
left a comment
There was a problem hiding this comment.
NO PASS
首轮独立检视:9466bc8d910c9fef55d4a9e23ee1a82950280c30 → fcecdc547566c740f67e41d46b47e1cb6e5a6dc7。这两处改动属于 #430 的冻结资源校验范围,不代表整个 P1 已验收。
批准前必修:关闭流失败仍会掩盖已确定的超长错误。 preparation.py:352–362 在退出 closing(source) 后才报告完整性错误。如果已读到第一个多余字节,但 close() 抛出 OSError,_prepare 的异常映射 仍会把结果变成 ArtifactUnavailable。请保留关闭尝试,但不要让它覆盖已确定的 ArtifactIntegrityError;建议在现有 Apps 回归旁补测该路径,断言错误阶段仍为 prepare 且无 PreparedRef、无归档。尚未取得完整性结论时的 I/O 失败不需要改分类。
实际验证:独立执行该 head 的校验函数,9 个聚焦用例通过,覆盖零长度、短分块、跨 1 MiB、首个多余字节、截断和摘要不符等;另确认读到超长后 close() 的 OSError 会逃出校验函数,并静态核对其外层映射。未运行完整 Apps/P1 测试或查看 CI。
|
Thanks for the tightly scoped fix. I reviewed The bounded read in I also checked the current-head review from @zengchuang-hw and agree it is still blocking:
Please still attempt to close the stream, but do not let a close failure replace an already determined I am not approving this head. |
Governing Issue and delivery slice
Refs #430
This proposed follow-up covers the fixed size and digest checks in the existing P1 preparation port. The accepted preparation scope defines Benchmark's verification and Apps' archival responsibilities.
Problem
PreparationService.preparereads each resource stream to EOF before checking its frozen length. Once an extra byte establishes a mismatch, another read can still fail and turn that integrity failure intoArtifactUnavailable.What
Bound each binary read by the declared remaining length plus one byte, up to the existing 1 MiB chunk size. Close an oversized stream and return
ArtifactIntegrityErroras soon as it supplies the first extra byte.Why needed
Preparation can reject an invalid resource promptly and give callers the reason already established by the bytes. Apps receives a prepared reference only after the resource closure passes verification.
Design and implementation
The private Benchmark verifier retains the injected role-keyed opener and stream ownership. It checks exact length and SHA-256, including streams that supply short chunks or resources with a declared length of zero. Apps still verifies the bytes it reopens for archival. The fix adds no dependencies or contract fields.
Checks and dependencies
ArtifactUnavailableon9466bc8. At the fix, it returnsArtifactIntegrityErrorat prepare, reads once, closes the source and leaves the archive empty.git diff --checkpassed.9466bc8already failstest_project_explanation.py::test_recovered_attempt_does_not_trust_a_rewritable_declarationdue to its import of the removedinferrsi.infra.artifactsmodule.Remaining work and Issue closure
This draft requests maintainer scope confirmation and formal review of the preparation follow-up. Broader P1 acceptance remains with the governing Issue owner.