退休 CREDENTIALS_KV:所有 auth 零件改讀新家(Workers Secrets),不再抓 KV #14

Open
opened 2026-07-06 15:41:20 +00:00 by Leo · 3 comments
Owner

開立者:arcrun 雲端維護 CC(受 InkStoneCo 總管交辦)。本 issue 是規格 + 盤點交棒,需在有 TinyGo 的機器上實作(雲端環境無 TinyGo,無法重編 WASM)。走正規 issue → PR,不在雲端硬改。

0. 原則(leo 定案,D19「擁有目錄,不擁有內容物」)

  • credential 的家 = CF Workers per-script Secrets(CF 加密託管、管理 API 唯寫讀不回值、CF 扛泄密責任)。
  • credential 目錄 = 使用者自己的 D1 credentials(只存 secret_ref 指標 + metadata,無密文)。
  • 任何固定零件都不該再讀 CREDENTIALS_KV 自管 ENCRYPTION_KEY 自加密路(AES-GCM 密文存 KV)要廢(D19)。
  • SDD:system-dev/docs/3-specs/arcrun/credential-primitives-wasm/credential-store-migration.md(T1.5–T9 已完成,T10 廢 ENCRYPTION_KEY 待此 PR)。本 issue 亦補齊 T6 對 oauth2 的漏網(T6 當時只改了 static_key / service_account)。rule 02 §2.1 本就列 credential-injector.ts 應刪。

1. 現況已完成(雲端這輪核實,不必重做)

  • leo21c 上 3 把 live static_key credentialtelegram_bot_token / notion_token / gitea_token)已在新家、namespace leo(D1 目錄 + Workers Secrets)。
  • ak_ 舊 KV 密文已刪(leo 名下 CREDENTIALS_KV{api_key}:cred:* 已清空)。
  • 已 live 實測:觸發 notify_leo 成功送出 Telegram(因 leo 的 credential 從沒進過 KV,能送出=auth_static_key 確實從新家 secret_get(Workers Secrets)解出、沒讀 KV)。static_key 鏈已證新家可用。
  • auth_static_key/main.goauth_service_account/main.go 已有 ResolvedSecrets(cypher 先從新家取值塞 payload,WASM 優先用它,kv_get(cred:) 僅 fallback)。

2. 完整消費者盤點(具體到檔案行號,實作照這張表清)

2a. cypher-executor TS(純 config/TS,不需 TinyGo,可先做)

檔案:行 現況 要做
cypher-executor/src/actions/credential-injector.ts(全檔;KV 讀 :82/:212、AES 解密 decryptCredentialBUILTIN_CREDENTIALS_MAPinterpolateTemplate 舊自加密 fallback(rule 02 §2.1 列應刪) 刪整檔
cypher-executor/src/graph-executor.ts:4(import)、:291/295/298injectCredentials fallback) 呼叫上檔 移除 import;把「tryAuthDispatch 未命中 → injectCredentials」的 fallback 拿掉(未命中的節點不需注入,context 原樣;local 模式無 apiKey 亦原樣)
cypher-executor/src/routes/auth.ts:243-248(Google refresh_token 寫 KV)、:322-327(GitHub access_token 寫 KV) OAuth 登入把 token 加密寫 CREDENTIALS_KV(供 auth_oauth2 讀) 移除這兩處 CREDENTIALS_KV.put;連帶清 aesEncrypt(移除後全檔無其他用途,generateApiKey 保留=api-key 身份用途)
cypher-executor/src/routes/credentials.ts:274(DELETE legacy-kv fallback)、:319-375POST /credentials/migrate-to-workers-secrets 端點,:336 KV.list、:348 KV.get)+ import { createArcrunHostFunctions }(僅此端點用) KV 退休後無意義(回填 T8 已一次性完成/失敗、DELETE 舊路已無資料) 移除 migrate 端點 + MigrateResult interface + createArcrunHostFunctions import;DELETE 改為「D1 有 secret_ref → 刪 Workers Secret + D1 row;無 → idempotent success(不再 fallback 刪 KV)」
cypher-executor/src/lib/wasi-shim.ts:16ArcrunHostEnv.CREDENTIALS_KV 型別 + :13 註解)、:666-679routedKvGetcred: 路由 → :676)、:685-693routedKvPutoauth2: 路由 → :689 平台 host 層 KV 路由 移除 CREDENTIALS_KV 型別;routedKvGet 只留 auth_recipe: → RECIPES保留,3 個 auth WASM 都靠它讀 recipe);routedKvPut 的 oauth2 快取路由移除(見 §3 快取新家待定)。crypto_decrypt/aesGcmDecrypt:699-710,用 ENCRYPTION_KEY)之去留見 §4
cypher-executor/src/types.ts:32CREDENTIALS_KV: KVNamespace Bindings 型別 移除
cypher-executor/src/routes/recipes.ts:439 只是註解提及 更新註解(非必須)

⚠️ typecheck 連動(別漏)cypher-executor/tsconfig.json includetests/**。移除 CREDENTIALS_KV 後這些測試會編不過,需同步改:tests/credentials.test.ts(migrate + DELETE-legacy 兩個 describe 整段刪/改)、tests/wasi-shim.test.ts:232makeFakeEnvCREDENTIALS_KV: fakeKv 移除)、tests/env.d.ts:4(註解)、cypher-executor/wrangler.test.toml:19-21(測試 binding 移除)。

2b. WASM 零件 main.go(需 TinyGo 重編,本 PR 核心)

3 個 auth 零件的 .component-builds/auth_*/src/index.ts:18import '../../../cypher-executor/src/lib/wasi-shim'共用同一份 shim)→ 動 shim 就一起動,故必須整包協調。

零件 現況(行號) 要做 重編
registry/components/auth_oauth2/main.go 完全沒有 ResolvedSecrets(T6 漏網)。硬靠 kvGet(apiKey+":cred:"+refresh_token)+cryptoDecrypt 讀 refresh_token(:290-307);且 oauth2: 前綴 KV 做 access_token 快取:讀 :184-185/:236-240、寫 kvPut :366-371 ResolvedSecrets 消費(比照 static_key)讓 refresh_token 走新家;access_token 快取改用不抓 CREDENTIALS_KV的新家(架構待定,見 §3
registry/components/auth_static_key/main.go ResolvedSecrets 已有(:53-57,:154,:239);kv_get(cred:)+cryptoDecrypt fallback 仍在(:160-161,:245-246,解密 :177,:262 移除 kv_get(cred:) 自解密 fallback(新家已是唯一真相源,ak_ KV 已刪,不再需要雙讀錨點)
registry/components/auth_service_account/main.go ResolvedSecrets 已有(:65-69,:190);kv_get(cred:)+cryptoDecrypt fallback 仍在(:194-195,解密 :210 同上,移除 fallback

2c. 4 顆 wrangler.toml 移除 binding = "CREDENTIALS_KV"(純 config,讓 namespace 可刪的關鍵)

  • cypher-executor/wrangler.toml:22-24(id e7f4320f88d343f187e35e3543dd74c9
  • .component-builds/auth_static_key/wrangler.toml:15-17
  • .component-builds/auth_service_account/wrangler.toml:15-17
  • .component-builds/auth_oauth2/wrangler.toml:14-16
  • (測試:cypher-executor/wrangler.test.toml:19-21 一併)

3. 待定架構點(實作前需 leo/總管拍板):oauth2 access_token 快取放哪?

現況 auth_oauth2 用 CREDENTIALS_KVoauth2:{service}:access_token / :expires_at(帶 TTL)快取換來的短效 token。這不是自加密 credential,是 runtime 快取,但寄生在同一顆 KV。退休 KV 後選項:

  • (a) 另開一顆專用短效快取 KV(新 namespace,非 credential store)——最小改動、語意乾淨。
  • (b) 放 D1(多一張表,SQL 對短效 KV-class 負載較重)。
  • (c) 不快取,每次重新 token exchange(最簡單,代價是多打 token endpoint)。

建議 (a) 或 (c)。此點定案前 auth_oauth2 的 main.go 改動無法收尾。

4. ENCRYPTION_KEY 去留(誠實結論,別誤刪)

  • credential 面用途credential-injector.tsdecryptCredential(隨刪檔消失)、auth.tsaesEncrypt(隨移除消失)、wasi-shim.tscrypto_decrypt/aesGcmDecrypt(3 auth WASM 移除 kv_get(cred:) fallback 後即無來源餵密文 → 該 host function 變 dormant;若同時移除 auth WASM 的 //go:wasmimport u6u crypto_decrypt 就可連 host fn 一起拿掉)。
  • 非-credential 用途(不可廢)wasi-shim.ts:764-788 createPlatformCryptoHostFunctions 的 HMAC/AES(api-key 產生用)、auth.ts:52 generateApiKey。→ ENCRYPTION_KEY secret 本身不可刪(api-key 身份還在用)。只能說「credential 面用途已清零」。
  • 結論寫進 PR:credential 面對 ENCRYPTION_KEY 的相依清零可達成;但該 secret 因 api-key 身份用途仍需保留——與「廢自加密路」不衝突(廢的是「用 ENCRYPTION_KEY 解 credential 密文」這條,不是整把 key)。

5. 驗收(誠實禁假綠,mindset §7)

  • grep -rn CREDENTIALS_KV 全 repo 零命中(含 registry WASM 源、cypher src、4+1 wrangler.toml、tests)。
  • cd cypher-executor && npx tsc --noEmit 過(含 tests,共用 shim 的 auth workers build 亦過)。
  • 3 個 auth 零件 tinygo build -target=wasi 過 + copy 進 .component-builds/*/component.wasm
  • 部署後對真端點 curl(禁 miniflare 假綠):
    • static_key(telegram)仍能從新家解出、送出訊息(比照 notify_leo live 實測)。
    • 若恢復 oauth2:google_user/github_user 能從新家取 refresh_token、換 access_token、快取走新家(不碰 KV)。
  • 全綠後:CREDENTIALS_KV namespace 可由 leo 刪;ENCRYPTION_KEY credential 用途清零(見 §4,secret 本身保留)。

6. 邊界 / 不要做

  • 不新增 service binding(rule 03 §3.1;auth 走 HTTP URL)。不動 KBDB 平台本身。
  • 密文本體永不進 D1(D1 只存 secret_ref + metadata)。
  • 部署繞開 GitHub Actions(wrangler 直推,見 mistakes #23 acr update codeload 陷阱)。
> 開立者:arcrun 雲端維護 CC(受 InkStoneCo 總管交辦)。本 issue 是**規格 + 盤點交棒**,需在**有 TinyGo 的機器**上實作(雲端環境無 TinyGo,無法重編 WASM)。走正規 issue → PR,不在雲端硬改。 ## 0. 原則(leo 定案,D19「擁有目錄,不擁有內容物」) - credential **值**的家 = **CF Workers per-script Secrets**(CF 加密託管、管理 API 唯寫讀不回值、CF 扛泄密責任)。 - credential **目錄** = 使用者自己的 **D1 `credentials` 表**(只存 `secret_ref` 指標 + metadata,**無密文**)。 - **任何固定零件都不該再讀 `CREDENTIALS_KV`。** 自管 `ENCRYPTION_KEY` 自加密路(AES-GCM 密文存 KV)要廢(D19)。 - SDD:`system-dev/docs/3-specs/arcrun/credential-primitives-wasm/credential-store-migration.md`(T1.5–T9 已完成,T10 廢 ENCRYPTION_KEY 待此 PR)。本 issue 亦補齊 T6 對 **oauth2** 的漏網(T6 當時只改了 static_key / service_account)。rule 02 §2.1 本就列 `credential-injector.ts` 應刪。 ## 1. 現況已完成(雲端這輪核實,不必重做) - leo21c 上 **3 把 live static_key credential**(`telegram_bot_token` / `notion_token` / `gitea_token`)已在新家、namespace `leo`(D1 目錄 + Workers Secrets)。 - `ak_` 舊 KV 密文已刪(leo 名下 `CREDENTIALS_KV` 的 `{api_key}:cred:*` 已清空)。 - **已 live 實測**:觸發 `notify_leo` 成功送出 Telegram(因 leo 的 credential 從沒進過 KV,能送出=`auth_static_key` 確實從新家 `secret_get`(Workers Secrets)解出、沒讀 KV)。static_key 鏈已證新家可用。 - `auth_static_key/main.go`、`auth_service_account/main.go` 已有 `ResolvedSecrets`(cypher 先從新家取值塞 payload,WASM 優先用它,`kv_get(cred:)` 僅 fallback)。 ## 2. 完整消費者盤點(具體到檔案行號,實作照這張表清) ### 2a. cypher-executor TS(純 config/TS,不需 TinyGo,可先做) | 檔案:行 | 現況 | 要做 | |---|---|---| | `cypher-executor/src/actions/credential-injector.ts`(全檔;KV 讀 `:82`/`:212`、AES 解密 `decryptCredential`、`BUILTIN_CREDENTIALS_MAP`、`interpolateTemplate`) | 舊自加密 fallback(rule 02 §2.1 列應刪) | **刪整檔** | | `cypher-executor/src/graph-executor.ts:4`(import)、`:291/295/298`(`injectCredentials` fallback) | 呼叫上檔 | 移除 import;把「tryAuthDispatch 未命中 → injectCredentials」的 fallback 拿掉(未命中的節點不需注入,context 原樣;local 模式無 apiKey 亦原樣) | | `cypher-executor/src/routes/auth.ts:243-248`(Google `refresh_token` 寫 KV)、`:322-327`(GitHub `access_token` 寫 KV) | OAuth 登入把 token 加密寫 `CREDENTIALS_KV`(供 auth_oauth2 讀) | 移除這兩處 `CREDENTIALS_KV.put`;連帶清 `aesEncrypt`(移除後全檔無其他用途,`generateApiKey` 保留=api-key 身份用途) | | `cypher-executor/src/routes/credentials.ts:274`(DELETE `legacy-kv` fallback)、`:319-375`(`POST /credentials/migrate-to-workers-secrets` 端點,`:336` KV.list、`:348` KV.get)+ `import { createArcrunHostFunctions }`(僅此端點用) | KV 退休後無意義(回填 T8 已一次性完成/失敗、DELETE 舊路已無資料) | 移除 migrate 端點 + `MigrateResult` interface + `createArcrunHostFunctions` import;DELETE 改為「D1 有 `secret_ref` → 刪 Workers Secret + D1 row;無 → idempotent success(不再 fallback 刪 KV)」 | | `cypher-executor/src/lib/wasi-shim.ts:16`(`ArcrunHostEnv.CREDENTIALS_KV` 型別 + `:13` 註解)、`:666-679`(`routedKvGet` 的 `cred:` 路由 → `:676`)、`:685-693`(`routedKvPut` 的 `oauth2:` 路由 → `:689`) | 平台 host 層 KV 路由 | 移除 `CREDENTIALS_KV` 型別;`routedKvGet` 只留 `auth_recipe: → RECIPES`(**保留**,3 個 auth WASM 都靠它讀 recipe);`routedKvPut` 的 oauth2 快取路由移除(見 §3 快取新家待定)。`crypto_decrypt`/`aesGcmDecrypt`(`:699-710`,用 ENCRYPTION_KEY)之去留見 §4 | | `cypher-executor/src/types.ts:32`(`CREDENTIALS_KV: KVNamespace`) | Bindings 型別 | 移除 | | `cypher-executor/src/routes/recipes.ts:439` | 只是註解提及 | 更新註解(非必須) | > ⚠️ **typecheck 連動(別漏)**:`cypher-executor/tsconfig.json` `include` 含 `tests/**`。移除 `CREDENTIALS_KV` 後這些測試會編不過,需同步改:`tests/credentials.test.ts`(migrate + DELETE-legacy 兩個 describe 整段刪/改)、`tests/wasi-shim.test.ts:232`(`makeFakeEnv` 的 `CREDENTIALS_KV: fakeKv` 移除)、`tests/env.d.ts:4`(註解)、`cypher-executor/wrangler.test.toml:19-21`(測試 binding 移除)。 ### 2b. WASM 零件 main.go(**需 TinyGo 重編**,本 PR 核心) 3 個 auth 零件的 `.component-builds/auth_*/src/index.ts:18` 都 `import '../../../cypher-executor/src/lib/wasi-shim'`(**共用同一份 shim**)→ 動 shim 就一起動,故必須整包協調。 | 零件 | 現況(行號) | 要做 | 重編 | |---|---|---|---| | `registry/components/auth_oauth2/main.go` | **完全沒有 `ResolvedSecrets`**(T6 漏網)。硬靠 `kvGet(apiKey+":cred:"+refresh_token)`+`cryptoDecrypt` 讀 refresh_token(`:290-307`);且 `oauth2:` 前綴 KV 做 access_token 快取:讀 `:184-185`/`:236-240`、寫 `kvPut` `:366-371` | 加 `ResolvedSecrets` 消費(比照 static_key)讓 refresh_token 走新家;access_token 快取改用**不抓 CREDENTIALS_KV**的新家(**架構待定,見 §3**) | ✅ | | `registry/components/auth_static_key/main.go` | `ResolvedSecrets` 已有(`:53-57`,`:154`,`:239`);`kv_get(cred:)`+`cryptoDecrypt` fallback 仍在(`:160-161`,`:245-246`,解密 `:177`,`:262`) | 移除 `kv_get(cred:)` 自解密 fallback(新家已是唯一真相源,`ak_` KV 已刪,不再需要雙讀錨點) | ✅ | | `registry/components/auth_service_account/main.go` | `ResolvedSecrets` 已有(`:65-69`,`:190`);`kv_get(cred:)`+`cryptoDecrypt` fallback 仍在(`:194-195`,解密 `:210`) | 同上,移除 fallback | ✅ | ### 2c. 4 顆 wrangler.toml 移除 `binding = "CREDENTIALS_KV"`(純 config,讓 namespace 可刪的關鍵) - `cypher-executor/wrangler.toml:22-24`(id `e7f4320f88d343f187e35e3543dd74c9`) - `.component-builds/auth_static_key/wrangler.toml:15-17` - `.component-builds/auth_service_account/wrangler.toml:15-17` - `.component-builds/auth_oauth2/wrangler.toml:14-16` - (測試:`cypher-executor/wrangler.test.toml:19-21` 一併) ## 3. 待定架構點(實作前需 leo/總管拍板):oauth2 access_token 快取放哪? 現況 auth_oauth2 用 `CREDENTIALS_KV` 的 `oauth2:{service}:access_token` / `:expires_at`(帶 TTL)快取換來的短效 token。**這不是自加密 credential,是 runtime 快取**,但寄生在同一顆 KV。退休 KV 後選項: - (a) 另開一顆**專用短效快取 KV**(新 namespace,非 credential store)——最小改動、語意乾淨。 - (b) 放 D1(多一張表,SQL 對短效 KV-class 負載較重)。 - (c) 不快取,每次重新 token exchange(最簡單,代價是多打 token endpoint)。 建議 (a) 或 (c)。**此點定案前 auth_oauth2 的 main.go 改動無法收尾。** ## 4. ENCRYPTION_KEY 去留(誠實結論,別誤刪) - **credential 面用途**:`credential-injector.ts` 的 `decryptCredential`(隨刪檔消失)、`auth.ts` 的 `aesEncrypt`(隨移除消失)、`wasi-shim.ts` 的 `crypto_decrypt`/`aesGcmDecrypt`(3 auth WASM 移除 `kv_get(cred:)` fallback 後即無來源餵密文 → 該 host function 變 dormant;若同時移除 auth WASM 的 `//go:wasmimport u6u crypto_decrypt` 就可連 host fn 一起拿掉)。 - **非-credential 用途(不可廢)**:`wasi-shim.ts:764-788` `createPlatformCryptoHostFunctions` 的 HMAC/AES(**api-key 產生**用)、`auth.ts:52` `generateApiKey`。→ **ENCRYPTION_KEY secret 本身不可刪**(api-key 身份還在用)。只能說「credential 面用途已清零」。 - 結論寫進 PR:**credential 面對 ENCRYPTION_KEY 的相依清零可達成;但該 secret 因 api-key 身份用途仍需保留**——與「廢自加密路」不衝突(廢的是「用 ENCRYPTION_KEY 解 credential 密文」這條,不是整把 key)。 ## 5. 驗收(誠實禁假綠,mindset §7) - `grep -rn CREDENTIALS_KV` **全 repo 零命中**(含 registry WASM 源、cypher src、4+1 wrangler.toml、tests)。 - `cd cypher-executor && npx tsc --noEmit` 過(含 tests,共用 shim 的 auth workers build 亦過)。 - 3 個 auth 零件 `tinygo build -target=wasi` 過 + copy 進 `.component-builds/*/component.wasm`。 - **部署後對真端點 curl**(禁 miniflare 假綠): - static_key(telegram)仍能從新家解出、送出訊息(比照 `notify_leo` live 實測)。 - 若恢復 oauth2:google_user/github_user 能從新家取 refresh_token、換 access_token、快取走新家(不碰 KV)。 - 全綠後:**CREDENTIALS_KV namespace 可由 leo 刪**;ENCRYPTION_KEY credential 用途清零(見 §4,secret 本身保留)。 ## 6. 邊界 / 不要做 - **不新增 service binding**(rule 03 §3.1;auth 走 HTTP URL)。不動 KBDB 平台本身。 - 密文本體永不進 D1(D1 只存 `secret_ref` + metadata)。 - 部署繞開 GitHub Actions(wrangler 直推,見 mistakes #23 `acr update` codeload 陷阱)。
Author
Owner

總管訂正(leo 定案,取代 issue 內 ENCRYPTION_KEY 段)

1. ENCRYPTION_KEY 可整把刪,不是「因 api-key 身份不可刪」。

  • 本專案只做 self-hosted、沒有 SaaS(認證=namespace 明碼,無 ak_ key)。因此 generateApiKey(HMAC-of-email) / /register / api-key 發放全是死 SaaS 碼——ENCRYPTION_KEY 的「api-key 身份」用途不存在
  • 這些死 SaaS 碼(auth.tsgenerateApiKeyregister router、/register 路徑、OAuth 用 generateApiKey 組 KV key 的 3 處)一併刪除
  • ENCRYPTION_KEY 移除 credential AES 自解密 + 上述死碼後,無殘留用途 → 整把 secret 由 leo 廢除。原則:有零件靠它、刪了會死=那零件是待改/待刪的死碼,不是保留 key 的理由。

2. auth_oauth2 的 access_token 快取(leo 定):放短效快取即可。

  • 它本來就會過期、失效即消失,不需要長效儲存。用 KV 帶 TTL 的短效快取(KV 的正當暫存用途)或乾脆不快取皆可——不搬 D1/KBDB(長效資料才進 KBDB;短效快取留 KV 是對的)。
  • 憑證本體(refresh_token)仍須走新家(ResolvedSecrets / Workers Secrets),不得留在 CREDENTIALS_KV。

3. 大原則(leo):長效資料(credential 目錄、recipe、triplet)一律 KBDB/新家,不得為閃避 KBDB 而塞 KV;KV 只留短效/暫存。

## 總管訂正(leo 定案,取代 issue 內 ENCRYPTION_KEY 段) **1. ENCRYPTION_KEY 可整把刪,不是「因 api-key 身份不可刪」。** - 本專案**只做 self-hosted、沒有 SaaS**(認證=namespace 明碼,無 ak_ key)。因此 `generateApiKey`(HMAC-of-email) / `/register` / api-key 發放**全是死 SaaS 碼**——ENCRYPTION_KEY 的「api-key 身份」用途**不存在**。 - 這些死 SaaS 碼(`auth.ts` 的 `generateApiKey`、`register` router、`/register` 路徑、OAuth 用 `generateApiKey` 組 KV key 的 3 處)**一併刪除**。 - ENCRYPTION_KEY 移除 credential AES 自解密 + 上述死碼後,**無殘留用途 → 整把 secret 由 leo 廢除**。原則:有零件靠它、刪了會死=那零件是待改/待刪的死碼,不是保留 key 的理由。 **2. auth_oauth2 的 access_token 快取(leo 定):放短效快取即可。** - 它本來就會過期、失效即消失,**不需要長效儲存**。用 KV 帶 TTL 的短效快取(KV 的正當暫存用途)或乾脆不快取皆可——**不搬 D1/KBDB**(長效資料才進 KBDB;短效快取留 KV 是對的)。 - 但**憑證本體(refresh_token)仍須走新家**(ResolvedSecrets / Workers Secrets),不得留在 CREDENTIALS_KV。 **3. 大原則(leo)**:長效資料(credential 目錄、recipe、triplet)一律 KBDB/新家,不得為閃避 KBDB 而塞 KV;KV 只留短效/暫存。
Author
Owner

08-01 複核:◐ 半通——自管加密已廢、injector 已刪,但 CREDENTIALS_KV binding 未退休,保留

已完成(main 源碼實查)

  • cypher-executor/src/actions/credential-injector.ts 已整檔刪除git ls-tree gitea/main cypher-executor/src/actions/ 已無此檔)=盤點表 2a 第一列完成
  • commit 20c7610「移除已廢棄的自管加密金鑰機制(credential 全面託管 CF Workers Secrets)」=D19 核心已落地
  • commit 8d8b01d「credential-primitives-wasm 封存進 archive(T10 完成,卷已結案)」⇒ SDD 側 T10(廢 ENCRYPTION_KEY)已銷帳

仍殘留(本 issue 保留的理由)——CREDENTIALS_KV 在 main 仍有 9 處引用:

cypher-executor/src/types.ts:32            CREDENTIALS_KV: KVNamespace;   ← binding 型別
cypher-executor/src/lib/wasi-shim.ts:16,605,618,625,631   ← kv_get/kv_put host fn 仍讀寫它
cypher-executor/src/routes/credentials.ts:286              ← DELETE 仍 fallback 刪 KV
cypher-executor/src/routes/recipes.ts:439                  ← 註解引用

⇒ 本 issue 標題「所有 auth 零件改讀新家,不再抓 KV」尚未達成:wasi-shimkv_get(cred:) fallback 路徑還在,binding 也還掛著。

建議收尾範圍(縮小後的剩餘工):拆 wasi-shimcred:/oauth2: KV 路徑 → 清 credentials.ts:286 的 legacy fallback → 移 types.ts 與各 wrangler.toml 的 binding → 重部署 → leo dashboard 刪 namespace(人閘)。與 #16/#17 同屬 KV 退休戰,建議三張一起排。

## 08-01 複核:◐ 半通——自管加密已廢、injector 已刪,**但 CREDENTIALS_KV binding 未退休**,保留 **已完成(main 源碼實查)**: - `cypher-executor/src/actions/credential-injector.ts` **已整檔刪除**(`git ls-tree gitea/main cypher-executor/src/actions/` 已無此檔)=盤點表 2a 第一列完成 - commit `20c7610`「移除已廢棄的自管加密金鑰機制(credential 全面託管 CF Workers Secrets)」=D19 核心已落地 - commit `8d8b01d`「credential-primitives-wasm 封存進 archive(T10 完成,卷已結案)」⇒ **SDD 側 T10(廢 ENCRYPTION_KEY)已銷帳** **仍殘留(本 issue 保留的理由)**——`CREDENTIALS_KV` 在 main 仍有 9 處引用: ``` cypher-executor/src/types.ts:32 CREDENTIALS_KV: KVNamespace; ← binding 型別 cypher-executor/src/lib/wasi-shim.ts:16,605,618,625,631 ← kv_get/kv_put host fn 仍讀寫它 cypher-executor/src/routes/credentials.ts:286 ← DELETE 仍 fallback 刪 KV cypher-executor/src/routes/recipes.ts:439 ← 註解引用 ``` ⇒ 本 issue 標題「**所有 auth 零件改讀新家,不再抓 KV**」尚未達成:`wasi-shim` 的 `kv_get(cred:)` fallback 路徑還在,binding 也還掛著。 **建議收尾範圍**(縮小後的剩餘工):拆 `wasi-shim` 的 `cred:`/`oauth2:` KV 路徑 → 清 `credentials.ts:286` 的 legacy fallback → 移 `types.ts` 與各 wrangler.toml 的 binding → 重部署 → leo dashboard 刪 namespace(人閘)。與 #16/#17 同屬 KV 退休戰,建議三張一起排。
Leo added the
s
backlog
label 2026-08-09 13:09:48 +00:00
Author
Owner

[總管·票務複驗 2026-08-09 晚] 仍然成立——用今天真的出貨到用戶手上的那顆 worker 反證,不是讀原始碼推測。

2026-08-09 出貨的 arcrun-rag 1.4.29(bundle manifest,source: Arcrun@19c82df),
裡面 arcrun-cypher-executor 這顆 worker 宣告它必須綁這些 KV 才跑得起來:

arcrun-cypher-executor -> requires.kv = [
  EXEC_CONTEXT, WEBHOOKS, CREDENTIALS_KV, ANALYTICS_KV, RECIPES, USERS_KV, SESSIONS_KV
]

對照這四張票要退休的東西:

  • #14 退休 CREDENTIALS_KV還在 requires 裡
  • #16 RECIPES KV → KBDB → 還在
  • #17 WEBHOOKS KV 退休 → 還在
  • #2 credential KV → D1 + Secrets Store → KV 那頭沒拆

⇒ 四張全部仍存在,而且不是「程式碼裡還有殘跡」這種軟證據——
  是今天新裝的用戶會被要求綁這些 KV,它們活在出貨路徑上。

📌 我把狀態標成 s/backlog(已驗過、確定要做、還沒排進任何 sprint)。
  這是保守的預設值,不是我對優先序的判斷——這個 repo 的 37 張票原本一張標籤都沒有,
  等於在看板上不存在。要往上排的請直接改標,不必回頭問我。

[總管·票務複驗 2026-08-09 晚] **仍然成立**——用今天真的出貨到用戶手上的那顆 worker 反證,不是讀原始碼推測。 2026-08-09 出貨的 `arcrun-rag` 1.4.29(bundle manifest,`source: Arcrun@19c82df`), 裡面 `arcrun-cypher-executor` 這顆 worker 宣告它**必須**綁這些 KV 才跑得起來: ``` arcrun-cypher-executor -> requires.kv = [ EXEC_CONTEXT, WEBHOOKS, CREDENTIALS_KV, ANALYTICS_KV, RECIPES, USERS_KV, SESSIONS_KV ] ``` 對照這四張票要退休的東西: - `#14` 退休 `CREDENTIALS_KV` → **還在 requires 裡** - `#16` `RECIPES` KV → KBDB → **還在** - `#17` `WEBHOOKS` KV 退休 → **還在** - `#2` credential KV → D1 + Secrets Store → **KV 那頭沒拆** ⇒ 四張全部**仍存在**,而且不是「程式碼裡還有殘跡」這種軟證據——   是**今天新裝的用戶會被要求綁這些 KV**,它們活在出貨路徑上。 📌 我把狀態標成 `s/backlog`(已驗過、確定要做、還沒排進任何 sprint)。   這是**保守的預設值,不是我對優先序的判斷**——這個 repo 的 37 張票原本一張標籤都沒有,   等於在看板上不存在。要往上排的請直接改標,不必回頭問我。
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Leo/Arcrun#14