Merge branch 'feat/step6-success-rate' into feat/step3-missing-guidance

This commit is contained in:
uncle6me-web
2026-07-31 14:54:25 +08:00
10 changed files with 490 additions and 52 deletions
@@ -171,9 +171,13 @@
- [x] 28.3 `/webhooks/:token/trigger` 路由已補上 `waitUntil(writeExecutionVerdict(...))`
- _Requirements: 7.2_
- [ ] 29. registry Worker analytics 端點
- [ ] 29.1 新增 `POST /analytics/record` 路由,原子更新 `ANALYTICS_KV`
- [ ] 29.2 `GET /components` 回傳加入 `total_runs``success_rate``avg_duration_ms`
- [x] 29. registry Worker analytics 端點2026-07-31CP arcrun-usable 步驟 6
- [x] 29.1 新增 `POST /analytics/record` 路由,更新 `ANALYTICS_KV` 計數器(`stats:{hash_id}:{version}`
- 註:KV 無 CAS,「原子更新」在 KV 上做不到——read-modify-write,併發偶有丟計數,統計用途可接受(誠實限制)
- 衍生值(success_rate 0..1avg_duration_mscall_count)回填 `comp:` 記錄(查詢讀取端),計數器是唯一真相源
- [x] 29.2 `GET /components/:id``/components/search` 回傳的 `success_rate``avg_duration_ms``call_count` 隨執行更新(欄位既存,本次讓它有真資料)
- [x] 29.3 cypher-executor 執行收尾對用到的**每顆零件**回寫(`execution-evaluator.ts` 從 stub 改真實作;`/cypher/execute` 與 webhook 路徑都掛,waitUntil fire-and-forget;成敗判定=trace error 或 output.success===false
- 實測(本地 wrangler dev ×2registry 8788cypher 8787REGISTRY_BASE_URL 指本地):同一零件 http_request 跑 5 次(3 成功+2 失敗 404)→ `GET /components/http_request` success_rate 1→0.6、call_count 0→5`/cypher/search` 節點回 `success_rate: 0.6`
- _Requirements: 7.3, 7.6_
- [x] 30. `author` 欄位已加入 contract.yaml 規格