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.