feat: 新增 diag_refs — source_ref↔manifest 對帳診斷

lint 的「source_ref 不在 manifest」只報對不上、不辨成因。diag_refs 把每個
對不上的 source_ref 分成五類(hash 不符/路徑字串岔開/檔名 hash 後綴岔開/
檔在磁碟未登記/完全無對應),各附修法,讓「補帳本(§14.3)」與「修規則
(§12)」的相反處置不再混為一談。純唯讀、結束碼 0/1,可當搬機或改 manifest
後的閘門。附 selfcheck 驗五型別分類、結束碼與零寫檔。README §3.3/§6/§7/§8 同步。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
LittleYellow
2026-07-23 23:44:34 +08:00
parent d41cb49a45
commit 04f4fd5ead
3 changed files with 261 additions and 1 deletions

View File

@@ -126,6 +126,16 @@ ollama list # 對照 tasks.ingest.model / tasks.lint.model / tasks.fallba
- **結束碼**`0` = 無發現;`1` = 有待人工核准項目(供 CI 判斷 / 標紅通知)。
- 排程:[.gitea/workflows/lint.yaml](.gitea/workflows/lint.yaml)(每週一台北時間 05:00草稿部署 Gitea 時啟用)。
> **`source_ref 不在 manifest` 的成因分類**lint 只報「對不上」,不分辨成因。跑
> [tools/diag_refs.py](tools/diag_refs.py) 把每個對不上的 source_ref 分成五類hash 不符 /
> 路徑字串岔開 / 檔名 hash 後綴岔開 / 檔在磁碟未登記 / 完全無對應),各附修法——
> 「補帳本」§14.3與「修規則」§12的處置相反先分類再動手。純唯讀不改任何檔
> 結束碼同 lint`0` 全部解得開 / `1` 有對不上),可當搬機或改 manifest 後的閘門。
>
> ```powershell
> .venv\Scripts\python tools\diag_refs.py
> ```
### 3.4 查詢 `search` — BM25 檢索
```powershell
@@ -180,7 +190,7 @@ wiki/entities/ # 實體頁(系統/模組/API/法規/專案)
wiki/concepts/ # 概念頁(跨來源綜合)
index.md # 目錄式導航(由 ingest 自動重建)
log.md # append-only 操作日誌
tools/ # convert/ ingest.py lint.py search.py kb.py共用模組
tools/ # convert/ ingest.py lint.py diag_refs.py search.py kb.py共用模組
mcp/server.py # MCP 薄殼
```
@@ -197,6 +207,7 @@ mcp/server.py # MCP 薄殼
| `須在 main 分支執行` | 攝入前先切回 `main`。 |
| `工作區有 raw/ 以外的未提交變更` | 先 commit / stash 非 `raw/` 的變更再攝入。 |
| `... 不在 manifest 的 converted 條目中` | 該來源尚未轉換;先跑 `convert.py`。 |
| lint 報 `source_ref 不在 manifest` | 跑 `tools/diag_refs.py` 分類成因:帳本掉條目→補登走 PR§14.3路徑字串岔開→修規則§12別逐頁改。 |
| `LLM 輸出驗證失敗(含 fallback` | 本地模型連主模型 + fallback 都無法產出合規 JSON檢查 Ollama 是否在線、模型是否拉好。 |
| `push 失敗(無 remote 或離線)` | 正常;分支已保留本地,手動 push 後開 PR。 |
@@ -210,5 +221,6 @@ mcp/server.py # MCP 薄殼
.venv\Scripts\python tools\convert\selfcheck.py
.venv\Scripts\python tools\selfcheck_ingest.py
.venv\Scripts\python tools\selfcheck_lint.py
.venv\Scripts\python tools\selfcheck_diag_refs.py
.venv\Scripts\python tools\selfcheck_search.py
```