feat(daemon): direct 直送萃取同步模式(無 R2/Gitea,youlin live e2e 綠)
SDD ingest-hash-trigger task 11:daemon 跨平台核心 + 產品承諾核心實證
(丟檔進資料夾 → AI 查得到)。
- collector 新增 direct 子命令(direct.go):監看資料夾 → hash 差異偵測(沿用 Scan)
→ 讀檔內容 inline POST 進實例 rag_ingest_direct workflow;刪檔 → POST {page_name,path}
進 rag_takedown_direct。設定走 --config JSON(install/direct-config.sample.json)。
常駐輪詢=純 stdlib ticker,零 CGo,darwin/arm64 + windows/amd64 交叉編譯 OK。
- workflows/rag-ingest-direct:ask_llm(rag_extract_one)+ parse_card/post_block/post_triplet
(rag_ingest)拼成單一自足直鏈,繞開 R2 撈原稿與 Gitea 落卡。blocks/triplets 寫法與
rag_ingest 逐欄一致 → rag_chat 檢索得到。
- workflows/rag-takedown-direct:不含 __CARDS_PREFIX__ 閘的下架(rag_ingest removed 分支的
前綴閘會擋掉資料夾根的 direct 檔——2026-07-20 live e2e 實撞)。
dogfooding(D29 daemon 薄殼豁免)守住:daemon 只監看/讀檔/算 hash/HTTP POST,
萃取/切塊/RAG 全在 Arcrun workflow。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xabu4T28MmQEiYDwT2KnKW
This commit is contained in:
@@ -86,3 +86,42 @@ design 鐵律段明言保留;被刪掉的是「Gitea push 事件」這個來
|
||||
測試:`go test ./...` 19/19——掃描 7+上傳 7+sync/trigger 5(成功回寫+無變更輪不重發/
|
||||
失敗不回寫+修復後重試成功/防呆警告輪照送 warnings 零事件/上傳失敗事件擋下+renamed
|
||||
連坐不回寫/URL env 驗證),全部 httptest mock(**未實跑雲端 e2e**——等切換日與 leo 一起驗)。
|
||||
|
||||
## `direct`:daemon 直送萃取、無 R2 同步模式(SDD task 11)
|
||||
|
||||
`direct`=**產品承諾核心的最短路徑**:監看資料夾 → 偵測新增/改動檔(沿用 `Scan` 的 hash 差異
|
||||
偵測,與 `sync` 同一套)→ 讀檔內容 **inline POST** 進實例的 `rag_ingest_direct` workflow
|
||||
(LLM 萃卡 → 機械切塊 → 寫 kbdb,**全在 Arcrun workflow**)。刪檔 → POST `{page_name, path}`
|
||||
進 `rag_takedown_direct`(按 page_name 標 kbdb blocks/triplets `deprecated`)。
|
||||
|
||||
**繞開 R2/Gitea**:既有 `sync` 走 collector→R2→`rag_ingest`(要 R2 bucket=綁卡),`rag_extract_one`
|
||||
又要 Gitea repo 落卡。`direct` 兩者都不要——落地「丟檔進資料夾 → AI 查得到」的零綁卡版。
|
||||
|
||||
```
|
||||
collector direct --config <config.json> [--once] [--dry-run]
|
||||
```
|
||||
|
||||
- `--once`:掃一輪即退出(測試/cron);預設常駐輪詢(`poll_interval_sec`,純 stdlib ticker,跨平台)。
|
||||
- 設定檔(JSON,見 `install/direct-config.sample.json`):`watch_folder` / `manifest` /
|
||||
`cypher_url` / `namespace` / `api_key`(空=namespace)/ `library`(空=kb)/
|
||||
`poll_interval_sec`(空=5)/ `max_removed_ratio`(空=0.4)/ `ingest_workflow`
|
||||
(空=`rag_ingest_direct`)/ `removed_workflow`(空=`rag_takedown_direct`)。
|
||||
- **dogfooding(D29 daemon 薄殼豁免)**:本模式只「監看/讀檔/算 hash/HTTP POST」原生 Go——
|
||||
萃取/切塊/RAG 一律在實例 workflow,daemon 內零 LLM/切塊邏輯。
|
||||
- **回寫語意**:POST 回 2xx 才 `Manifest.MarkIngested`(下輪不重送);非 2xx 不回寫=下輪重試。
|
||||
- **大量刪除防呆**:沿用 `Scan` 的 `mass_delete_guard`(removed > manifest×`max_removed_ratio`
|
||||
→ 本輪不下架、只回報警告)。
|
||||
|
||||
**配套 workflow**(`workflows/rag-ingest-direct.local.yaml` / `rag-takedown-direct.local.yaml`;
|
||||
用 `install/push-demo-workflow.sh` 推,env 指向目標實例的 CYPHER/KBDB/HTTPREQ/CODE/LLM_MODEL/LIBRARY):
|
||||
blocks/triplets 寫法與 `rag_ingest` 逐欄一致 → `rag_chat` 一視同仁檢索得到。
|
||||
> ⚠️ 下架另立 `rag_takedown_direct` 而非重用 `rag_ingest` removed 分支:後者在 `collect_changed`
|
||||
> 有 `__CARDS_PREFIX__` 閘,direct 模式的檔在資料夾根會被擋掉零下架(2026-07-20 live e2e 實撞)。
|
||||
|
||||
**youlin live e2e 實證(2026-07-20,非 mock)**:
|
||||
- 丟 `請假規則.md`/`差旅政策.md` → daemon `ingested`(200) → `rag_chat` 帶出處正確作答。
|
||||
- 刪 `差旅政策.md` → daemon `removed`(200) → `rag_chat`「知識庫裡沒有這方面資料」(blocks 全 deprecated)。
|
||||
|
||||
**跨平台**:純 stdlib、零 CGo、輪詢式偵測(不依賴 fsnotify)→ `GOOS=darwin GOARCH=arm64` /
|
||||
`GOOS=windows GOARCH=amd64` 直接交叉編譯(各約 5.6M / 5.9M)。托盤殼(Wails)+Mac `.app`
|
||||
簽章/TCC 是下一刀,且 Mac 打包要在 Mac 上做。
|
||||
|
||||
Reference in New Issue
Block a user