6ee6fee8b9
credentials/ was a leftover duplicate — all credential routes already live in cypher-executor/src/routes/credentials.ts. Adds the SDD protocol, tech-stack, forbidden-list, component-architecture, and progress rules that guide Phase 1-6 refactors. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
133 lines
6.0 KiB
Markdown
133 lines
6.0 KiB
Markdown
# 禁止行為清單(零容忍)
|
||
|
||
**這份清單由 `.claude/hooks/*.sh` 強制執行。違反會 block 工具呼叫(exit 2)**。
|
||
|
||
---
|
||
|
||
## 第一類:零件實作層級的禁令
|
||
|
||
### 1.1 禁止在 `registry/components/` 下建立 TypeScript 檔案
|
||
零件**只能**用 TinyGo(`.go`)或 AssemblyScript(`.ts` 但需 `asconfig.json`)實作,並編譯成 `.wasm`。
|
||
cypher-executor/registry Worker 或 `.component-builds/` 內的 TS 不算零件邏輯,那是 WASI shim。
|
||
|
||
**Hook 會擋**:新增 `registry/components/*/{檔案}.ts`(除非目錄內有 `asconfig.json` 明確標記為 AssemblyScript)。
|
||
|
||
### 1.2 禁止建立新的 `auth_*` 目錄以外的 auth 實作
|
||
所有 auth 邏輯只能在:
|
||
- `registry/components/auth_static_key/`
|
||
- `registry/components/auth_oauth2/`
|
||
- `registry/components/auth_service_account/`
|
||
- `registry/components/auth_mtls/`
|
||
|
||
**不可以**出現 `cypher-executor/src/auth-primitive/`、`cypher-executor/src/lib/auth-*.ts`、`auth-worker/`、`credential-worker/` 等目錄。
|
||
|
||
**Hook 會擋**:`mkdir` 或 `Write` 到上述違規路徑。
|
||
|
||
### 1.3 禁止用 `wrangler init/generate` 建立 auth/credential/jwt 相關的 TS Worker
|
||
Auth primitive 必須透過 `component-worker-template/` 搭配 WASM binary 部署。
|
||
|
||
**Hook 會擋**:bash 指令含 `wrangler (init|generate) ... auth_`、`... credential_`、`... jwt_` 的 pattern。
|
||
|
||
---
|
||
|
||
## 第二類:cypher-executor TS 的禁令
|
||
|
||
### 2.1 禁止新增任何 credential / auth / jwt 相關的 TS 檔案
|
||
**已存在但要刪**(Phase 1-3 範圍):
|
||
- `cypher-executor/src/actions/credential-injector.ts` → 刪除(走 WASM auth primitive)
|
||
- `cypher-executor/src/lib/jwt-signer.ts` → 刪除(RS256 移入 auth_service_account WASM)
|
||
- `cypher-executor/src/lib/component-loader.ts` 的 `BUILTIN_API_RECIPES` 和 `BUILTIN_CREDENTIALS_MAP` → 整段刪除
|
||
|
||
**Hook 會擋**:新增任何路徑含以下關鍵字的 `.ts` 檔案:
|
||
- `credential-injector`、`credential_injector`
|
||
- `jwt-signer`、`jwt_signer`
|
||
- `auth-dispatcher` 的 TS 若嘗試在裡面實作 credential 解密 / template 展開 / JWT signing,block
|
||
|
||
### 2.2 禁止在 cypher-executor 任何 TS 裡實作以下邏輯
|
||
這些邏輯全部屬於 WASM 零件職責:
|
||
|
||
- AES-GCM 解密(`crypto.subtle.decrypt`)— 只准出現在 `wasi-shim.ts` 的 `crypto_decrypt` host function
|
||
- RSA-SHA256 簽章(`crypto.subtle.sign` with RSASSA-PKCS1-v1_5)— 只准出現在 `wasi-shim.ts` 的 `crypto_sign_rs256` host function
|
||
- Template 展開(`{{secret.X}}` / `{{runtime.X}}` 替換)— 只能在 WASM 零件內
|
||
- PEM → PKCS8 解析
|
||
- JWT header/payload/signature 組裝
|
||
- Token exchange(拿 service account JWT 換 access_token)
|
||
- 具體 API call 實作(例如 gmail send / telegram sendMessage / google sheets append)
|
||
|
||
**Hook 會擋**:
|
||
- Write/Edit 到 `cypher-executor/src/` 下的 `.ts` 時,內容含:
|
||
- `crypto\.subtle\.decrypt` 且檔名不是 `wasi-shim.ts`
|
||
- `crypto\.subtle\.sign.*RSASSA` 且檔名不是 `wasi-shim.ts`
|
||
- `interpolateTemplate`、`\{\{secret\.` 的模板邏輯
|
||
- `BUILTIN_API_RECIPES`、`BUILTIN_CREDENTIALS_MAP`(新增用)
|
||
- `gmail.googleapis.com/gmail/v1/users/me/messages/send` 類 hard-code API URL
|
||
- `api.telegram.org/bot.*sendMessage`
|
||
- `sheets.googleapis.com/v4/spreadsheets`
|
||
- `notify-api.line.me/api/notify`
|
||
|
||
### 2.3 cypher-executor TS 的合法職責(允許)
|
||
- HTTP routing(Hono routes)
|
||
- workflow 執行排程(`graph-executor.ts`)
|
||
- 呼叫 WASM 零件(透過 HTTP fetch 到對應 Worker URL,或 Service Binding fallback)
|
||
- 提供 host function(`wasi-shim.ts` 的 `kv_get` / `crypto_decrypt` / `crypto_sign_rs256`)
|
||
- KV/R2/Service Binding 存取封裝
|
||
|
||
---
|
||
|
||
## 第三類:架構層級的禁令
|
||
|
||
### 3.1 禁止新增 Service Binding
|
||
**Cypher binding 不是 Cloudflare service binding**。它是 YAML/KV 裡的 URL 清單。
|
||
|
||
零件串接(workflow 層)一律走 HTTP URL,不走 `[[services]]`。
|
||
|
||
15 個現有的 `SVC_*` 綁定(`cypher-executor/wrangler.toml`)是歷史遺產(邏輯零件效能優化),**保留但不新增**。
|
||
|
||
**Hook 會擋**:bash 指令含 `wrangler tail` 以外、涉及 `[[services]]` 新增的 pattern;Edit wrangler.toml 新增 `[[services]]` 區塊時警告確認。
|
||
|
||
### 3.2 禁止以「從 R2 取 WASM」為設計
|
||
平台內建零件已 bundle 進各自 Worker,不從 R2 取。
|
||
R2 只在 Phase 5(用戶自製零件)啟用。
|
||
|
||
**Hook 會警告**:TS 中出現 `env.WASM_BUCKET.get(` 的新增 code(除非在明確標註的 Phase 5 user-submit 路徑中)。
|
||
|
||
### 3.3 禁止複製貼上 Worker 程式碼到新目錄
|
||
要改 `gmail` 零件 → 改 `registry/components/gmail/main.go`,重新編譯、部署。
|
||
**不准**新建 `gmail-v2/`、`new-gmail/`、`gmail-worker/` 等目錄。
|
||
|
||
**Hook 會擋**:`mkdir` 或 `Write` 到 `{component-name}-v2/`、`new-{component-name}/`、`{component-name}-worker/` 類路徑。
|
||
|
||
### 3.4 禁止在 SDK 內做 server 職責
|
||
- **禁止**:SDK 裡做 server 端解密、credential-injector 重實作、workflow executor、auth recipe 解析
|
||
- **允許**:SDK 做 HTTP thin wrapper + client 端加密(AES-GCM)
|
||
|
||
---
|
||
|
||
## 第四類:流程層級的禁令
|
||
|
||
### 4.1 禁止沒讀 SDD 就動 code
|
||
見 `00-sdd-protocol.md`。
|
||
|
||
### 4.2 禁止批次更新 tasks.md
|
||
每完成一個 task 就立刻 mark `- [x]`。不准「先全部做完再一次更新」。
|
||
|
||
### 4.3 禁止新建 SDD 而不事先與 richblack 確認
|
||
SDD 屬於架構決策,必須人確認。CC 不可以自行在 `.agents/specs/` 底下建新目錄。
|
||
例外:在現有 SDD 目錄內新增 `requirements.md` / `design.md` / `tasks.md` 的單檔補充(需在 CLAUDE.md 已註記的 SDD 範圍內)。
|
||
|
||
---
|
||
|
||
## Hook Block 訊息格式
|
||
|
||
當 hook 擋住一個操作時,訊息格式統一為:
|
||
|
||
```
|
||
❌ BLOCKED by arcrun CLAUDE rules
|
||
違反項:<禁令編號,例如 2.2>
|
||
原因:<簡短說明>
|
||
正確做法:<該改去哪裡、該用什麼方式>
|
||
參考:.claude/rules/<對應檔案>
|
||
```
|
||
|
||
這樣 CC 拿到錯誤訊息後有機會自行導正,不是被擋死就愣住。
|