修复抓取收据验证边界并接入 Autopilot lineage - #2
Merged
Merged
Conversation
Merged
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.
What
O_NOFOLLOW | O_NONBLOCK、单一文件描述符、16 MiB 上限、完整 chunk 检查和前后fstat,避免 symlink 跟随、FIFO open 阻塞、无界读取和路径替换窗口O_NOFOLLOW或O_NONBLOCK时 fail closed,不静默削弱安全语义Why
原有 crawl verification 有四个相连缺口:
status可与页面投影矛盾但仍通过;Path.read_text()整体读取,缺少输入上限和同一 open handle 的稳定性检查;O_NOFOLLOW打开后再检查 regular file,FIFO 可在fstat前阻塞;缺失 safe-open flag 还会逃逸AttributeError。这条 lineage 通过 frozen candidate review 收敛这些边界。
SDW-AUTO-903因未处理 readOSError和非空短读被正式拒绝;905 修正后,post-push review 又发现 open 阶段阻塞风险,最终由SDW-AUTO-906封闭。Impact and risk
crawl receipt is unreadablecrawl receipt changed during verificationO_NOFOLLOW或O_NONBLOCK时 crawl receipt verification fail closedtracefetch.error.v1对象且不回显输入autopilot/tasks/保存历史冻结 TaskSpec;它们是 lineage 输入,不表示可以在新的 HEAD 上重放Checks
30690203375:Python 3.11 / 3.12 / 3.13 全部成功uv run --locked pytest tests/test_cli.py:16 passeduv run --locked pytest tests/test_crawl.py:29 passedCLOSED_SNAPSHOT,closed evidence 已通过离线verify-exportverify-deliveryEvidence boundary
Autopilot evidence 证明 frozen snapshot、结构化 review decision、产品直接后继 commit、diff match 和一次远端 ref-match observation 的内部一致性;它不证明 reviewer 身份、PR 已创建、merge、release、上线或外部业务结果。
Note
High Risk
Touches security-sensitive local file verification (symlinks, FIFO blocking, size limits, TOCTOU) and changes public crawl verify failure semantics and CLI exit behavior; ordinary evidence bundle verification is unchanged.
Overview
Adds Autopilot project config (
autopilot/project.json), frozen SDW-AUTO-901–906 task specs, and ignores.autopilot/runtime output.Crawl verification in
verify.pyis refactored around a shared_crawl_verification_resultpath soverify_crawl_bundleandcrawl_verification_payloaduse one receipt load. Top-levelstatusis recomputed from page records and rejected when it disagrees (crawl status does not match page records).Receipt loading replaces
Path.read_text()with a boundedO_RDONLY | O_NOFOLLOW | O_NONBLOCKopen-handle read: 16 MiB cap, chunked reads with exact-length checks, pre/postfstatidentity/size, and fixed messages for oversized, changed-during-read, unreadable, invalid UTF-8, and schema failures—without echoing input or tracebacks. MissingO_NOFOLLOW/O_NONBLOCKfails closed.SQLite state errors (
sqlite3.Error, bad row conversion, close failures) map tocrawl SQLite state is invalid; valid modeled receipts still expose realcrawl_idand verified-page counts when state is bad.Tests in
test_cli.pyandtest_crawl.pycover malformed receipts (exit 6, bounded stderr), size/truncation/read/FIFO/safe-open flags, status tampering, and corrupt SQLite rows.Reviewed by Cursor Bugbot for commit 49e0fd0. Bugbot is set up for automated code reviews on this repo. Configure here.