Agent: programmer (
programmer)
Confidence: 61%
Cost: $1.9419
Duration: 17m 43s
Task ID:6b72c172-1bf9-43ed-8d36-a43e5710a945
SPEC-31 完成摘要
改動的檔案
| 檔案 | 改動內容 |
|---|---|
src/safety/soul-integrity.ts |
verifySoulIntegrity() 新增 storedFileHashes 參數,mismatch 時使用 diffFingerprints() 精確定位變動檔案 |
src/index.ts |
傳入 storedFileHashes 給 verifySoulIntegrity(),移除冗餘的二次 computeSoulFingerprint() + diffFingerprints() 呼叫 |
tests/unit/soul-integrity.test.ts |
新增 12 個測試覆蓋 diffFingerprints() 和 verifySoulIntegrity() 的 per-file hash 行為 |
驗收結果
| 驗收標準 | 狀態 |
|---|---|
| per-file hashes 存入 checkpoint | ✅ 已有(checkpoint.ts 的 identityFileHashes 和 vitals.ts 的 identity_file_hashes 早已實作) |
| mismatch 精確報告變動檔案 | ✅ verifySoulIntegrity() 現在接受 storedFileHashes 並用 diffFingerprints() 精確比對 |
| legacy checkpoint 不 crash | ✅ 不傳 storedFileHashes 時 fallback 到報告所有檔案,message 標記 “approximate” |
| unit test: 改一個檔案 → 只報那個檔案 | ✅ 測試 reports only changed file when per-file hashes are provided 通過 |
編譯及測試
tsgo --noEmit: ✅ 零錯誤- 相關測試 (4 files / 50 tests): ✅ 全部通過
- 全量測試 (97 files / 1204 tests): 96 passed, 1 pre-existing failure (
worktree-manager.test.ts, 與本次改動無關)
設計決策
原始碼中已有完整的 per-file hash 基礎設施(checkpoint.ts 的 identityFileHashes、vitals.ts 的 identity_file_hashes、diffFingerprints() 函式)。真正的問題在於 verifySoulIntegrity() 只接受 composite hash 而不接受 per-file hashes,導致 mismatch 時無法在內部使用 diffFingerprints()。修改方式是擴充 verifySoulIntegrity() 的簽名以接受可選的 storedFileHashes,使其能在內部完成精確比對,消除 index.ts 中的冗餘邏輯。
—HANDOFF—
TO: reviewer
INTENT: handoff
ARTIFACT_TYPE: code-change
SUMMARY: SPEC-31 — verifySoulIntegrity() 接受 storedFileHashes 參數,mismatch 時用 diffFingerprints() 精確報告哪些檔案改了,附 12 個新增測試