80 / 90

第 80 天:差异审查、独立测试与 CI 故障恢复

以评审者视角逐行检查 Agent 的 diff,用独立测试证明变更,并把一次故意失败的 Agent 变更从 CI 诊断带到已验证修复。

Self-Directed Learning & Python 480 分钟有效研习(8 小时)
01 120 分钟

Agent 差异检查与 PR 式评审清单

Agent 辅助工程检查

前置要求

第 79 天;第 14-15 天 Git 协作基础;Ticket 24 评审清单(curriculum/engineering/ci_delivery_rollback)。

学习目标

像 pull request 评审者一样逐行检查 Agent 产出的 diff,在任何变更获准进入 CI 之前应用六点检查清单。

操作指引

1. 先不暂存:运行 git diff 与 git status,通读 Agent 产出的每个 hunk。
2. 对每个 hunk 应用 Ticket 24 清单:正确性与规格对齐;测试充分性;无断言篡改;API 与文件格式向后兼容;零机密或危险 shell 调用;干净非破坏的历史。
3. 将每个 hunk 分类为 accept / question / reject 并附一行理由。
4. 可以让 Agent 汇总 hunk、定位可疑行,但判定权在你——Agent 辅助止于决策之前。
5. 出现以下情形立即 reject:测试断言被弱化、越界文件、硬编码凭据、无法解释的重新格式化。

自主演练与记录

产出 review_notes.md:每个 diff hunk 一行(文件、hunk 区间、判定、理由),外加三条最重要的清单发现,每条都引用具体行。

独立掌握标准

完成一次结构化代码评审,其中每个 diff hunk 都带有明确且有据的判定。

权威源资源与权利证明

linking CC BY-NC-SA 3.0 noncommercial share-alike

Pro Git, Second Edition

作者 / 机构: Scott Chacon and Ben Straub | 原始出处链接 ↗

对应章节 / 时间戳: Chapter 3 (Git Branching), Section 7.7 (Reset Demystified), Sections 5.2/6.2 (Contributing to a Project)

验证版本与日期: Second edition (Apress, 2014) (Verified: 2026-10-30)

入选理由:

Freely licensed reference for branching, merging, conflict resolution, and safe recovery vocabulary used through the delivery workflow.

来源前置条件:

Basic git status/log/diff vocabulary from earlier study days

安全回退方案(离线弹性):

git help <command> and the Git manual pages ship with Git and cover the same commands offline; every required workflow is stated locally in the lesson.

对比候选资源与选型分析 (2)
GitHub Skills interactive courses ↗ compared_alternative [MIT (varies by course)]

Interactive but requires a GitHub account and an external service; disposable local repositories keep the exercise self-contained.

Atlassian Git Tutorials ↗ compared_alternative [All Rights Reserved]

Vendor-owned prose with no permissive license; Pro Git covers the same ground under CC BY-NC-SA.

linking All Rights Reserved (martinfowler.com) Article is linked, not copied; pipeline practice uses the repository's own runner

Continuous Integration

作者 / 机构: Martin Fowler | 原始出处链接 ↗

对应章节 / 时间戳: Practices of Continuous Integration: Everyone can see what's happening

验证版本与日期: Second edition web article (May 2006) (Verified: 2026-10-30)

入选理由:

Standard practitioner reference defining the CI contract this block rehearses: every change merges to a mainline verified by an automated build and test run, and failures are fixed before further work proceeds.

来源前置条件:

Version control basics, automated test suites, and build vocabulary.

安全回退方案(离线弹性):

The CI gate contract (lint, test, package, verdict) is executed locally by scripts/ci_practice_runner.py with no external dependency.

对比候选资源与选型分析 (2)
GitHub Actions Documentation ↗ compared_alternative [CC BY 4.0]

Provider-specific workflow syntax; Fowler's article states the vendor-neutral CI discipline the learner must internalize first, while the docs are kept as the pipeline-mechanics source.

Atlassian Continuous Integration Guide ↗ compared_alternative [All Rights Reserved]

Vendor-oriented tutorial; Fowler's original definition keeps the explanation tool-agnostic and historically important.

02 120 分钟

公共接缝处的独立验证测试

独立掌握检查(无 AI 辅助)

前置要求

第 80 天 活动 1。

学习目标

不借助 Agent,在公开接口接缝处为验收标准编写你自己的验证测试,使变更由独立证据而非 Agent 的声明来证明。

操作指引

1. 从第 79 天活动 1 的每条验收标准各推导一个 unittest 用例。
2. 在公共接缝处测试:调用 cli.evaluate / run_task / 公开工具函数,不触碰私有内部实现。
3. 遵循红-绿流程:运行前先预测期望值,看真正会失败的测试先失败,再验证它对真实实现通过。
4. 除正常路径外,再覆盖一条故障路径(非法参数)与一条预算不变量(steps <= 6)。
5. 绝不让 Agent 编写或弱化裁决它自身工作的测试。

自主演练与记录

创建 tests/projects/test_day79_change.py,含三个对应验收标准的 unittest 用例;运行 python -m unittest tests.projects.test_day79_change -v 并记录输出。

独立掌握标准

在公共接缝处编写独立测试,即使 Agent 声称成功也能捕获错误实现。

权威源资源与权利证明

linking All Rights Reserved (martinfowler.com) Article is linked, not copied; pipeline practice uses the repository's own runner

Continuous Integration

作者 / 机构: Martin Fowler | 原始出处链接 ↗

对应章节 / 时间戳: Practices of Continuous Integration: Make the Build Self-Testing; Fix Broken Builds Immediately

验证版本与日期: Second edition web article (May 2006) (Verified: 2026-10-30)

入选理由:

Standard practitioner reference defining the CI contract this block rehearses: every change merges to a mainline verified by an automated build and test run, and failures are fixed before further work proceeds.

来源前置条件:

Version control basics, automated test suites, and build vocabulary.

安全回退方案(离线弹性):

The CI gate contract (lint, test, package, verdict) is executed locally by scripts/ci_practice_runner.py with no external dependency.

对比候选资源与选型分析 (2)
GitHub Actions Documentation ↗ compared_alternative [CC BY 4.0]

Provider-specific workflow syntax; Fowler's article states the vendor-neutral CI discipline the learner must internalize first, while the docs are kept as the pipeline-mechanics source.

Atlassian Continuous Integration Guide ↗ compared_alternative [All Rights Reserved]

Vendor-oriented tutorial; Fowler's original definition keeps the explanation tool-agnostic and historically important.

linking Open Access / CC BY 4.0

SWE-bench: Can Language Models Resolve Real-World GitHub Issues?

作者 / 机构: Carlos E. Jimenez, John Yang, Alexander Wettig, Shunyu Yao, Kexin Pei, Ofir Press, Karthik R. Narasimhan | 原始出处链接 ↗

对应章节 / 时间戳: Appendix A.3 Execution-Based Validation

验证版本与日期: ICLR 2024 / arXiv:2310.06770v3 (Verified: 2026-10-30)

入选理由:

Defines the standard pattern this block teaches: a bounded issue statement paired with executable fail-to-pass tests as verifiable acceptance criteria for agent-produced changes.

来源前置条件:

Unit testing, issue descriptions, and repository evaluation vocabulary.

安全回退方案(离线弹性):

The acceptance-criteria pattern is exercised locally through the Ticket 22 fixture scorer and the Ticket 24 regression exercise without external datasets.

对比候选资源与选型分析 (2)
HumanEval: Evaluating Large Language Models Trained on Code ↗ compared_alternative [arXiv non-exclusive license / Open Access]

Function-level synthesis benchmark; SWE-bench models the repository-scoped issue-to-diff workflow that this delivery block rehearses.

Multi-SWE-bench: A Multilingual Benchmark for Issue Resolving ↗ compared_alternative [Open Access / CC BY 4.0]

Extends issue resolution to multiple programming languages; the original Python-centric SWE-bench provides a cleaner pedagogical anchor.

03 120 分钟

失败的 Agent 变更:CI 诊断与纠正后重提

Agent 辅助工程检查

前置要求

第 80 天 活动 2。

学习目标

把一次故意失败的 Agent 变更走完整个 CI 闭环:观测红色失败、从回溯中诊断根因、指挥修正 diff、并在绝不改动测试断言的前提下验证转绿。

操作指引

1. 执行回归阶段:python3 scripts/ci_practice_runner.py --stage regression --json。它注入受控缺陷(unicode_multibyte_stripping)并运行测试套件。
2. 读取真实失败:test_failed_red=true,test_multilingual_unicode_handling 中 AssertionError: 11 != 17 ——缺陷在实现中剥除了多字节字符,而非测试有误。
3. 像评审者一样诊断:在实现代码而非断言中定位根因行;重跑前先预测修正后的值。
4. 应用经评审的修复,确认 test_restored_green=true 且原始断言原封不动。
5. 逐字记录 RED 的回溯与 GREEN 的输出作为证据。

自主演练与记录

撰写 diagnosis.md:确切的失败断言行、实现中的根因行、所应用修复的说明,以及最终 'Ran N tests ... OK' 输出。

独立掌握标准

诊断并修正一个由未改动断言转绿所证实的真实缺陷——靠证据而非断言篡改来恢复一次失败的 Agent 变更。

权威源资源与权利证明

linking CC BY 4.0

GitHub Actions Documentation

作者 / 机构: GitHub, Inc. | 原始出处链接 ↗

对应章节 / 时间戳: N/A

验证版本与日期: GitHub Docs continuous publication (Verified: 2026-10-30)

入选理由:

Primary reference for pipeline stages, required status checks, and branch protection mechanics that the local CI practice runner mirrors in a disposable environment.

来源前置条件:

YAML familiarity, shell commands, and Git hosting vocabulary.

安全回退方案(离线弹性):

Pipeline stage semantics (lint, test, package, deploy gate) are exercised offline by scripts/ci_practice_runner.py; no GitHub account or push authorization is required for the practice.

对比候选资源与选型分析 (2)
GitLab CI/CD Documentation ↗ compared_alternative [CC BY-SA 4.0]

Equivalent pipeline concepts under a different provider; GitHub Actions matches the hosted-workflow conventions used in this project's delivery story.

Jenkins User Documentation ↗ compared_alternative [CC BY-SA 4.0]

Self-hosted CI server documentation; GitHub Actions better matches the hosted pipeline model the learner will meet first.

linking All Rights Reserved (martinfowler.com) Article is linked, not copied; pipeline practice uses the repository's own runner

Continuous Integration

作者 / 机构: Martin Fowler | 原始出处链接 ↗

对应章节 / 时间戳: Practices of Continuous Integration: Make the Build Self-Testing; Fix Broken Builds Immediately

验证版本与日期: Second edition web article (May 2006) (Verified: 2026-10-30)

入选理由:

Standard practitioner reference defining the CI contract this block rehearses: every change merges to a mainline verified by an automated build and test run, and failures are fixed before further work proceeds.

来源前置条件:

Version control basics, automated test suites, and build vocabulary.

安全回退方案(离线弹性):

The CI gate contract (lint, test, package, verdict) is executed locally by scripts/ci_practice_runner.py with no external dependency.

对比候选资源与选型分析 (2)
GitHub Actions Documentation ↗ compared_alternative [CC BY 4.0]

Provider-specific workflow syntax; Fowler's article states the vendor-neutral CI discipline the learner must internalize first, while the docs are kept as the pipeline-mechanics source.

Atlassian Continuous Integration Guide ↗ compared_alternative [All Rights Reserved]

Vendor-oriented tutorial; Fowler's original definition keeps the explanation tool-agnostic and historically important.

04 120 分钟

评估:有据评审判定与合并决定

独立掌握检查(无 AI 辅助)

前置要求

第 80 天 活动 1-3。

学习目标

组装完整的 pull request 评审包——差异判定、独立测试结果、CI 阶段输出——并给出完全由可重跑证据支撑的通过/驳回合并决定。

操作指引

1. 汇总 review_notes.md、你的 unittest 输出与回归阶段 JSON 为一个评审包。
2. 亲自重跑其中一项证据(unittest 或 CI 阶段),确认结论仍然成立。
3. 决定 APPROVE 或 REJECT:仅当每个清单项都以重跑证据通过时才批准,否则附具体阻塞标准驳回。
4. 撰写合并就绪说明:风险等级、回滚提示(哪个版本可恢复服务)与残余限制。
5. 明确区分独立/辅助:你的测试与判定是独立证据;产出的 diff 属 Agent 辅助绩效。

自主演练与记录

撰写 review_packet.md:决定(APPROVE/REJECT)、六项清单结果各附一行证据、重跑命令及其输出、回滚注记。

独立掌握标准

给出可辩护的合并决定,每条批准标准都有可重跑证据支撑。

权威源资源与权利证明

linking CC BY-NC-SA 3.0 noncommercial share-alike

Pro Git, Second Edition

作者 / 机构: Scott Chacon and Ben Straub | 原始出处链接 ↗

对应章节 / 时间戳: Chapter 3 (Git Branching), Section 7.7 (Reset Demystified), Sections 5.2/6.2 (Contributing to a Project)

验证版本与日期: Second edition (Apress, 2014) (Verified: 2026-10-30)

入选理由:

Freely licensed reference for branching, merging, conflict resolution, and safe recovery vocabulary used through the delivery workflow.

来源前置条件:

Basic git status/log/diff vocabulary from earlier study days

安全回退方案(离线弹性):

git help <command> and the Git manual pages ship with Git and cover the same commands offline; every required workflow is stated locally in the lesson.

对比候选资源与选型分析 (2)
GitHub Skills interactive courses ↗ compared_alternative [MIT (varies by course)]

Interactive but requires a GitHub account and an external service; disposable local repositories keep the exercise self-contained.

Atlassian Git Tutorials ↗ compared_alternative [All Rights Reserved]

Vendor-owned prose with no permissive license; Pro Git covers the same ground under CC BY-NC-SA.

linking Open Access / CC BY 4.0

SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering

作者 / 机构: John Yang, Carlos E. Jimenez, Alexander Wettig, Kilian Lieret, Shunyu Yao, Karthik Narasimhan, Ofir Press | 原始出处链接 ↗

对应章节 / 时间戳: Appendix B.4 Failure Modes

验证版本与日期: NeurIPS 2024 / arXiv:2405.15793v2 (Verified: 2026-10-30)

入选理由:

Primary literature on agent-computer interfaces showing that bounded tool commands, trajectory inspection, and environment constraints determine whether an agent can carry an engineering task to verifiable completion.

来源前置条件:

Agent loops, tool protocols, and basic software engineering workflow vocabulary.

安全回退方案(离线弹性):

The permission/budget control profile, tool contract schema, and trace audit procedure are fully implemented in the local bounded agent fixture (projects/agent_learning).

对比候选资源与选型分析 (2)

Broader generalist agent platform; SWE-agent isolates the agent-computer interface design principles most relevant to bounded task delivery.

AutoCodeRover: Autonomous Program Improvement ↗ compared_alternative [Open Access / CC BY 4.0]

Focuses on autonomous program repair via code search; SWE-agent better matches the curriculum's bounded-tool and human-verification emphasis.