7d8cbe4299
- DECISIONS §8 釐清:執行鏈路(高頻)不依賴 CI;零件投稿(稀有)走 PR/CI 是例外、不違反精神 (CF Workers 不能 runtime 編譯 wasm,CI 是唯一能跑 wasm 又執行者碰不到的 venue) - BACKLOG 步驟 4 收尾(投稿改 PR,標已做/不做/未來搬 CI) - BACKLOG 步驟 5 被 PR 方向取代;新增步驟 5b 資料外流警示(先做,需新 SDD) - BACKLOG 待決策加:用戶 API 保護機制(入站認證,資安優勢)、recipe/part/function 架構釐清 - component-gatekeeping tasks.md 收尾狀態 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4.9 KiB
4.9 KiB
Tasks: Component Gatekeeping
對應 design.md。每完成一個 task 立刻標 [x],不批次。 Design 已 richblack 確認(2026-05-29,含 Q1-Q3 決議)。
⚠️ 收尾狀態(2026-05-30,方向修正後)
投稿改走 GitHub PR(廢 registry self-service,見 design 頂部「方向修正」)。本 SDD 收尾於:
- 已完成且 commit:G1(detectFakeComponent)、G3(wasmImports)、G5/G6(unimplemented_steps)、 G0 registry 人類閘門(保留不刪)。測試 15 綠。
- 改去向:G4 Gherkin / 覆蓋檢查 → 未來接 CI PR check(CI 能跑 wasm)。G1/G3 邏輯可複用。
- 不做:CI PR check(richblack:人工 review 就夠,primitive 極少)、R5 本機 hook (PR/merge + G1 + 沙箱已防「未經同意變公共零件」,hook 過度工程)、registry self-service、 acr parts publish 加閘門、平台 sandbox 重跑。
- 黃金向量:人工核對(另起 session 從語義寫),不急、不機器自動化。
- 轉出範圍:真正的裸奔風險在「資料外流」(recipe/webhook 把資料送出去),不分公私庫
→ 另開新 SDD「資料外流警示」(API 層警示 + AI 動手前 hook)。用戶 API 保護(入站認證)
- recipe/part/function 架構釐清 → 記 BACKLOG 待決策。
G1 假零件偵測(R2,Q2=兩者硬擋)
- 1.1
registry/src/actions/detectFakeComponent.ts:(a) 外部 URL/domain 偵測(掃 contract 文字 + wasm binary 文字)硬擋;(b) http_request 子集偵測硬擋 - 1.2 排除
auth_*primitive 與http_request自己 - 1.3 接進 sandboxAcceptance 步驟鏈(fake_component_scan 為第一步)
- 1.4 退稿訊息指回正路(「這該是 recipe/工作流」)
G3 純 WASI 把關(R3)
- 3.1
wasmImports.ts解析 wasm import section,取出所有 import module name(已對真實零件驗證) - 3.2 白名單:只准
wasi_snapshot_preview1+u6u;其他 module → 退稿 - 3.3 接進 scanSyscalls(白名單為主,黑名單為次)
G4 Gherkin 真實作(R1)— venue 修訂:CLI 本地跑,非 registry(design §4 修訂)
CF Worker 不能 runtime 編譯 wasm + §8 不依賴 CI → Gherkin 在投稿指令本地(Node)跑。 在第一段(tinygo build→wasm 之後)測,跟 worker 無關。registry 只存 evidence 不重跑。
- 4.1
runGherkin.ts(createWasiShim 跑 wasm,邏輯正確)—— 但 venue 要從 registry 改 CLI - 4.2 回退 sandboxAcceptance:registry 不跑 Gherkin(移除 await runGherkin),改回靜態步驟
- 4.3 Gherkin 邏輯搬到 CLI 投稿指令(Node 環境 instantiate wasm)
- 4.4 投稿 payload 帶 gherkin_evidence(scenario/given/actual_stdout/passed),registry 存 metadata 可審
- 4.5 誠實標明第一期 evidence 可造假(mindset + 文件);平台重跑列未來
- 4.6 投稿指令(暫名 acr component submit)+ 公私庫分流(-p 公共)— 新 CLI 工程
G5/G6 誠實標未實作(R3 禁假綠)
- 5.1 SandboxResult 增
unimplemented_steps: string[] - 5.2 cold_start / runtime_compat 列入 unimplemented_steps,submit 回應明示
G0 人類閘門(R4,核心)
- 0.1 submit 請求增
human_confirmation(SubmitOptions in submitComponent.ts)+ route 解析(multipart/JSON 皆支援) - 0.2 submit 邏輯:非 skip_acceptance 的新投稿,無 human_confirmation/空 reason → gateError(指回正路)
- 0.3 human_confirmation + gherkin_evidence 寫進 KV metadata(軌跡可審)
- 0.4 CLI
acr parts publish(既有指令):互動式問人類(工作流為何做不到 + 確認),非 TTY 拒絕 - 0.5 MCP / Python lib / JS lib 補 human_confirmation 欄位支援(薄)
- 0.6 誠實限制寫進 mindset Skill(步驟 7)+ SDK 文件
命名修正(2026-05-29):投稿走既有
acr parts publish(cli/src/commands/parts.ts), 非另建 acr component create(符合「修改現有不重建」)。G0-CLI(0.4)與 G4-CLI 合併在此指令做。
R5 白名單 + 本機 hook
- 5.3
registry/MVP_COMPONENTS.txt(現役 22 個 canonical_id) - 5.4 submit 過閘門成功 → 自動 append canonical_id 進白名單(Q3)
- 5.5 pre-write-guard.sh:寫
registry/components/{白名單外}/→ exit 2 - 5.6 pre-bash-guard.sh:mkdir
registry/components/{白名單外}→ exit 2
驗收(design §8)
- V1 投寫死 endpoint 假零件 → G1 退稿(終端輸出)
- V2 投
.ts進 registry/components → hook exit 2 - V3 本機造白名單外零件目錄 → hook exit 2
- V4 無 human_confirmation 的 submit → 403
- V5 帶 human_confirmation + 過 Gherkin 真零件 → 通過 + reason 留 metadata + 白名單 append
- V6 故意改壞 then_contains → Gherkin 退稿
- V7 回應含 unimplemented_steps(cold_start/runtime_compat 不假綠)