fix(examples): graph_neighbors 去寫死官方 KBDB URL(審查 🔴)+敏感輸入註記

審查發現:workflow.yaml 寫死 kbdb.finally.click = KBDB_BASE_URL fallback 同家族坑
(self-hosted 用戶照抄示範,查詢與資料流向直接打進官方庫)。

改法:
- fetch_triplets base URL 參數化為 {{input.kbdb_base}}(每次呼叫帶),yaml 檔頂加醒目
  警示「先改成你自己的 KBDB URL」;grep 證兩檔零 finally.click 殘留。
- 1042 註解保留並補一句:self-hosted 有 global_fetch_strictly_public flag
  (credential-primitives-wasm Phase 7),開了 workers.dev URL 亦可帶。
- description.md 參數表加 kbdb_base(必填)+觸發範例改自有域名佔位+補
  「敏感輸入請用 POST /query(GET /q/ 的 query string 會進各層 log)」。

tsc 乾淨、全套 50 passed(1 失敗為 main 既有 executor.test.ts 斷言漂移,無關)。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015d5jDbuqT5Htwv3Q88XXKk
This commit is contained in:
2026-07-07 09:01:20 +00:00
parent 06ff0e21ce
commit 39d6fdfaff
2 changed files with 35 additions and 15 deletions
@@ -5,17 +5,28 @@ description: >
POST /webhooks/named/:name/query),把 workflow 最終節點輸出直接當 HTTP response 拿回,
取代 graph plugin 內建的 GET /graph/neighbors。對照 kbdb-graph-plugin graph-traverse.ts 的記憶體 BFS。
# ── 為什麼走 base custom domainkbdb.finally.click)而非 workers.dev ──
# cypher-executor 執行 http_request 節點時對 kbdb 發 fetch。若打 *.uncle6-me.workers.dev 同 zone
# 會踩 CF 1042same-zone self-fetch)。打 base 的對外 custom domain kbdb.finally.click 屬跨 zone
# 前門公網進出,避開 1042(同 credential-primitives-wasm Phase 7 的 global_fetch_strictly_public 精神)。
# ══════════════════════════════════════════════════════════════════════════════
# ⚠️ 先改成你自己的 KBDB URLself-hosted 必看)
# fetch_triplets 的 base URL 走 {{input.kbdb_base}} 參數(每次呼叫帶),**沒有寫死官方庫**。
# 照抄本示範時,把觸發參數 kbdb_base 換成你自己部署的 KBDB 對外 URL——
# 抄了別人的值=你的查詢與資料流向直接打進別人的庫(KBDB_BASE_URL fallback 同家族坑)。
# ══════════════════════════════════════════════════════════════════════════════
# ── 1042 與 kbdb_base 該帶哪種 URL ──
# cypher-executor 執行 http_request 節點時對 kbdb 發 fetch。若打同 zone URL 會踩 CF 1042
# same-zone self-fetch)。兩條路皆可:
# a) 帶 KBDB 的 custom domain(跨 zone、走公網前門,天然避開 1042);
# b) self-hosted 有 `global_fetch_strictly_public` compatibility flag
# credential-primitives-wasm Phase 7cypher wrangler.toml),開了之後
# workers.dev URL 亦可直接帶。
# ── 觸發(同步查詢 trigger,非 202)──
# GET https://cypher.arcrun.dev/q/{namespace}/graph_neighbors?node=Arcrun&depth=2&template=graph_triplet&namespace={namespace}
# POST https://cypher.arcrun.dev/webhooks/named/graph_neighbors/query
# GET https://{你的-cypher-domain}/q/{namespace}/graph_neighbors?node=Arcrun&depth=2&template=graph_triplet&namespace={namespace}&kbdb_base=https://{你的-kbdb-domain}
# POST https://{你的-cypher-domain}/webhooks/named/graph_neighbors/query
# -H "X-Arcrun-API-Key: {namespace}"
# -d '{"node":"Arcrun","depth":2,"template":"graph_triplet","namespace":"{namespace}"}'
# -d '{"node":"Arcrun","depth":2,"template":"graph_triplet","namespace":"{namespace}","kbdb_base":"https://{你的-kbdb-domain}"}'
# → 直接回 { success, start, depth, directed, neighbors:[...], count }(最終節點輸出本身)。
# (敏感輸入用 POST /queryGET /q/ 的 query string 會進各層 log,見 description.md。)
flow:
- "input >> ON_SUCCESS >> fetch_triplets"
@@ -27,10 +38,11 @@ config:
# 回 { success, records:[{ record_id, values:{subject,predicate,object} }], count }。
# ⚠️ template 名(此處 {{input.template}},預設由呼叫者帶 graph_triplet)以實際部署的
# kbdb-graph-plugin triplet template id 為準——上線前對一次。
# ⚠️ base URL 由呼叫者帶({{input.kbdb_base}})——不寫死任何一家的庫(見檔頂警示)。
fetch_triplets:
component: http_request
method: GET
url: "https://kbdb.finally.click/records/by-template/{{input.template}}?owner_id={{input.namespace}}"
url: "{{input.kbdb_base}}/records/by-template/{{input.template}}?owner_id={{input.namespace}}"
headers:
Accept: "application/json"