Files
Arcrun/cypher-executor
Leo 4e7880c1cb fix(cypher-executor): /executions/paused 走 per-user index (強 consistent)
對應 LI SDD M2.1 修補。

問題:原 /executions/paused 走 EXEC_CONTEXT.list({prefix:'paused_run:'})。
CF KV list 是強 eventual consistent (30-60s 延遲),剛 paused 的 workflow
list 不會立刻看到。本機 wrangler kv list 也回 [],但 KV.get 同 task_id
能即時拿到 — 證實 list vs get 一致性層級不同。

修補:persistPausedRun 額外維護 per-user index `paused_idx:{api_key}`
(JSON Array),是單一 KV.get 拿全列表,**強 consistent 無延遲**。
consumePausedRun 同步從 index 移除。

新 helper:
- listPausedRunsByApiKey(kv, apiKey, limit) — 走 index
- PausedIndexEntry type — task_id / run_id / paused_node_id / workflow_name /
  expires_at / persisted_at

實測:trigger 後立刻 list 即時看到 paused (commit 前是 0)

副作用:index 寫入 + delete 都是 fire-and-forget 在 consume path,失敗
不擋主流程。Index entries 上限 100 防無限長。每次 read 過濾 expired。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 17:15:16 +08:00
..