Skip to content

feat(scripts): 002 記分 pre-commit 自動守門(issue 608) - #652

Merged
s123104 merged 1 commit into
experiment/ratewise-product-2026h2from
fix/608-002-score-guard
Jul 6, 2026
Merged

feat(scripts): 002 記分 pre-commit 自動守門(issue 608)#652
s123104 merged 1 commit into
experiment/ratewise-product-2026h2from
fix/608-002-score-guard

Conversation

@s123104

@s123104 s123104 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Closes #608

摘要

  • 新增 scripts/verify-002-log.mjs:002 記分自動守門,掛入 .husky/pre-commit 第 6 步(僅 docs/dev/002_development_reward_penalty_log.md 在 staged set 時執行,對齊既有 verify-ssot-sync / verify-version-ssot 條件執行模式)。
  • 新增 18 例 vitest 單元測試(scripts/__tests__/verify-002-log.test.ts,純函式 fixture,沿用 repo scripts 測試慣例)並掛入 test:root
  • AGENTS.md / CLAUDE.md 同步:pre-commit 5 步驟 → 6 步驟、002 記分行固定格式與守門規則、rebase --continue 不觸發 hook 的手動驗證註記(Documentation Sync Rules MUST)。

守門規則

檔頭記分行固定格式:> 本次分數變化:+N(reward a、penalty b、neutral c)|累計總分:+T

規則 驗證方式
計數對帳 a+b+c = 本次 staged 新增條目數(staged vs HEAD 以 ID 差集判定);a/b/c 依條目 ID 前綴 reward-/penalty-/neutral- 分類
分數算式 N = a − b
總分鏈 T = git show HEAD:docs/dev/002... 前版累計 + N;前版檔頭為歷史自由格式仍可取累計(相容);初始 commit 情境跳過
條目格式 四行模板(日期/ID/原因/解法)、日期 YYYY-MM-DD、新增條目 ID 前綴必須合法
ID 唯一性 對全檔驗證重複
歷史條目不可刪除(S1) HEAD 全部條目 ID 必須 ⊆ staged 條目 ID(不限標準前綴,涵蓋 411 條中 218 條 legacy ID);缺失即擋下並列出被刪 ID,防湮滅 penalty 證據
不回溯 歷史條目格式問題不擋 commit;002 純 typo 修正(檔頭未動、無新增條目)不驗記分

自舉驗證(本 PR 的 002 條目通過自己的守門)

本 PR 新增 002 條目 reward-608-002-score-precommit-guard,rebase 至最新 base(#657/#658 後檔頭 +173)重算為 +1(reward 1、penalty 0、neutral 0)|累計總分:+174。commit 時 pre-commit 實錄(rebase 解衝突後依文件註記手動執行 node scripts/verify-002-log.mjs 通過):

Step 6/6: 002 記分守門...
002 記分守門通過

所有 Pre-commit 檢查通過

擋下證據 1:計數不符(宣稱 reward 3 實際新增 1 筆、總分亂寫 +199)

Step 6/6: 002 記分守門...
002 記分守門失敗:
- 檔頭計數(reward 3、penalty 0、neutral 0)與本次新增條目(reward 1、penalty 0、neutral 0)不符
- 本次分數變化應為 1(reward - penalty),檔頭為 3
- 累計總分斷鏈:前版 171 + 本次 3 = 174,檔頭為 199(擋下當時 base 檔頭為 +170、本線條目 +171)
husky - pre-commit script failed (code 1)

擋下證據 2:靜默刪除歷史條目(S1——刪一筆歷史條目、檔頭完全不動)

002 記分守門失敗:
- 歷史條目不可刪除,缺失 ID:「reward-rw-custom-theme-wave-d-fullpage-picker」
guard-exit=1

Changeset

不需要:僅 root scripts、husky hook、docs 與 root package.jsontest:root 清單,未觸及 apps/ratewise runtime;verify-version-ssot 的 isRuntimeChange 判定不涵蓋上述路徑,pre-commit Step 5 實測通過、未要求 changeset。

並行線注意

fix/content-page-skeleton#658)已先合;本線作為後合者已 rebase 兩輪並重算檔頭(+170 → +172 → +173 base,各輪守門直接給出正確期望值)。rebase 解 002 衝突後 rebase --continue 不觸發 pre-commit,需手動 node scripts/verify-002-log.mjs 或 amend 觸發(已寫入 AGENTS.md/CLAUDE.md)。

測試

  • npx vitest run scripts/__tests__/verify-002-log.test.ts:18 passed(原 15 例+S1 刪除防護 3 例)
  • pnpm --filter @app/ratewise exec vitest run:4814 passed(1 skipped file)
  • pre-commit 6 步驟全過;pre-push(typecheck + test + build:ratewise)全過

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@s123104

s123104 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

重新觸發 CI(force-push 後 Actions 未收到 synchronize 事件),隨即 reopen。

@s123104 s123104 closed this Jul 6, 2026
@s123104 s123104 reopened this Jul 6, 2026
@s123104
s123104 force-pushed the fix/608-002-score-guard branch 2 times, most recently from 4f51e30 to 009e341 Compare July 6, 2026 22:12
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

- 新增 scripts/verify-002-log.mjs:驗證 002 檔頭「本次分數變化:+N(reward a、penalty b、neutral c)」
- 與 staged 新增條目前綴計數對帳(a+b+c = 新增條目數、N = a - b),累計總分鏈以 HEAD 前版 + N 驗證
- 條目格式守門:四行模板(日期/ID/原因/解法)、日期 YYYY-MM-DD、ID 全檔唯一;歷史條目不回溯擋 commit
- 歷史條目不可靜默刪除:HEAD 條目 ID 必須為 staged 子集(不限標準前綴),缺失列出 ID 並擋下
- 掛入 .husky/pre-commit 第 6 步,僅 002 檔在 staged set 時執行(對齊既有條件執行模式)
- 新增 18 例 vitest 單元測試並掛入 test:root;AGENTS.md/CLAUDE.md 同步 6 步驟清單、記分行固定格式
- 文件註記 rebase --continue 不觸發 pre-commit,需手動跑守門腳本或 amend 觸發

測試:npx vitest run scripts/__tests__/verify-002-log.test.ts(18 passed);pre-commit 6 步驟全過

Co-authored-by: Cursor <cursoragent@cursor.com>
@s123104
s123104 force-pushed the fix/608-002-score-guard branch from 009e341 to e90c183 Compare July 6, 2026 22:23
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

✅ SEO 審計通過!所有 2026 標準驗證項目都符合要求。

  • ✅ Sitemap 2026 標準
  • ✅ Breadcrumb Schema
  • ✅ JSON-LD 結構化數據
  • ✅ 內部連結結構

@s123104
s123104 merged commit 3321f3e into experiment/ratewise-product-2026h2 Jul 6, 2026
11 checks passed
@s123104
s123104 deleted the fix/608-002-score-guard branch July 6, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant