Skip to content

Commit cba7c23

Browse files
committed
fix(intelligence): restore queued rebuilds and runtime progress
1 parent c95296f commit cba7c23

46 files changed

Lines changed: 4496 additions & 361 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,12 @@ jobs:
9292
- uses: oven-sh/setup-bun@v2
9393
- name: Install dependencies
9494
run: bun install --frozen-lockfile
95+
- name: Install Playwright Chromium
96+
run: bunx playwright install chromium
9597
- name: Run macOS platform-native checks
9698
run: bun run check:platform
99+
- name: Run desktop bridge truth gate
100+
run: bun run test:e2e:desktop-bridge:truth
97101

98102
platform-linux:
99103
runs-on: ubuntu-latest

docs/design/screens-and-nav.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
### 目前 export 已覆蓋
3232

33-
- shell chrome:sidebar 分區、brand / version、archive status footer、topbar 搜尋、共享 profile scope switcher 與主 CTA
33+
- shell chrome:sidebar 分區、brand / version、archive status footer、background-work footer strip、topbar 搜尋、共享 profile scope switcher 與主 CTA
3434
- Dashboard 視覺語言:stat cards、recent runs table、On This Day、storage breakdown、AI / queue summary 的資訊層級
3535
- Dashboard 導航語法:從首頁快速跳到 Explorer、Assistant、Insights、Audit 等核心入口
3636

@@ -46,16 +46,17 @@
4646

4747
- Onboarding、shared empty / error / loading、locked / no-data、permission-denied 等 production state,現在以本頁、[ux-principles.md](ux-principles.md) 與對應 feature / milestone docs 為 source of truth;prototype 沒畫到不再代表 UX 未定義。
4848
- long-running operation、generated artifact review、rollback confirmation、manual fallback 與 verify / rollback hint,全都遵循 PME grammar,而不是各頁自己發明流程。
49-
- `On This Day` 與其他 evidence surface 以使用者目前系統 timezone 的本地日曆日判斷,不再用 raw UTC slice 假裝是「今天」。
49+
- `On This Day` 與其他 evidence surface 以使用者目前系統 timezone 的本地日曆日判斷,不再用 raw UTC slice 假裝是「今天」`On This Day` 只回看過去幾年的同一天,不得把當前年份今天的紀錄混進去
5050
- keyboard-only walkthrough、reduced-motion fallback、locale-length wrapping 已是 trust-critical acceptance contract;剩餘的全站 accessibility review 與 release-level polish 留在 M4。
5151
- route metadata、sidebar section label、topbar title / subtitle、loading / skeleton label、empty / error / disabled state,以及 browser preview honesty copy 都屬於正式 i18n surface;不能因為 prototype 沒畫到文字細節就留下英文硬編碼。
5252
- Settings 的 remote backup 現在以 `Preview / Manual / Execute / Verify` tabs 呈現:Preview 顯示 bundle path / object key / upload URL,Manual 保留 curl command 與 retention guidance,Execute 顯示 upload result,Verify 則列出 checksum / required-entry / restore-readiness checks。
53-
- Settings 的 enrichment / derived-state panel 是正式 review surface,而不是 debug affordance。它必須顯示 plugin version、queue、freshness、derived tables、storage impact,以及 rebuild / clear controls。
53+
- Settings 的 enrichment / derived-state panel 是正式 review surface,而不是 debug affordance。它必須顯示 queue、freshness、derived tables、storage impact,以及 rebuild / clear controls;plugin / module 的內部版本標記只留在 diagnostics / runtime trace,不佔主產品 review chrome。
54+
- Jobs 頁是正式 shipping route:顯示 background queue summary、recent AI jobs、recent derived-data jobs、pause / resume control、plugin / module runtime status,以及 crash / restart recovery note;它不是 hidden diagnostics page。
5455
- Settings 的 general diagnostics 現在是 support / release 文檔依賴的正式入口:至少要顯示 app data root、archive DB path、audit repo path、app version、git short SHA,並提供直接打開對應路徑的動作。
5556
- Insights 現在除了既有 card / topic / thread surface 外,還要顯示 storage analytics 與 latest growth signal,並提供回到 Audit run 的 deep-link。
5657
- M5-B 起,Insights 也正式包含 `query groups``reference pages``source effectiveness``template summaries` 與 deterministic module registry status;這些都屬 shipping review surface,不是 debug-only affordance。
5758
- shared profile scope 是 production shell 的正式 viewer state:Topbar 可切換全域 viewing scope;Explorer 預設繼承、Assistant / Insights 直接沿用,Dashboard 則必須用 callout 清楚說明哪些區塊是 scoped、哪些 KPI 仍是 archive-wide。
58-
- Settings 的 derived-state panel 現在除了 enrichment runtime review,還要顯示 deterministic module registry:module enable / disable、dependency、derived tables、last built time、stale reason,以及需要 manual rebuild 的 honesty copy。
59+
- Settings 的 derived-state panel 現在除了 enrichment runtime review,還要顯示 deterministic module registry:module enable / disable、dependency、derived tables、last built time、stale reason,以及 auto rebuild job / manual override 的 honesty copy。
5960
- Assistant 的 empty / disabled state 要保留 seeded prompts、settings / queue 修復入口,以及 shared profile scope honesty;不能只剩「AI 尚未啟用」這種靜態段落。
6061
- Audit run detail 應以 `Summary / Artifacts / Warnings` 分頁控制資訊密度,同時保留 open / copy path 動作在單次 review 內可達。
6162
- Schedule 除了 Preview / Manual / Execute tabs 外,還要把 Verify 做成正式 surface:顯示 install state、detected files、warnings、latest audit artifact,並提供 PME quick-jump,而不是把驗證訊息藏在單一 badge。
@@ -71,15 +72,15 @@
7172

7273
### M1 導航與 deep-link 規則
7374

74-
- Sidebar 依固定分區導航:`CORE`(Dashboard / Explorer / Insights / Assistant)、`OPERATIONS`(Import / Audit / Schedule)、`SYSTEM`(Security / Settings);Onboarding 是 utility route,不常駐 sidebar。
75+
- Sidebar 依固定分區導航:`CORE`(Dashboard / Explorer / Insights / Assistant)、`OPERATIONS`(Import / Audit / Jobs / Schedule)、`SYSTEM`(Security / Settings);Onboarding 是 utility route,不常駐 sidebar。
7576
- 頂部搜尋送到 `History Explorer`,直接寫入 `/explorer?q=...`,讓搜尋結果可以被複製、重整和重新打開。
7677
- Explorer 的 day-one filter deep-link 使用 query string:`q``profileId``browserKind``domain``start``end``sort``regex``page`
7778
- Audit Ledger 的 run detail deep-link 使用 `/audit?run=<id>`;Dashboard recent runs 直接跳進這個 URL。
7879
- Import recent batch review 允許 `/import?batch=<id>` deep-link;Audit / Dashboard 可以直接把使用者帶回指定 batch 的 review surface。
7980
- Dashboard zero-state、Security、Topbar 都可以回到 Onboarding,確保 first-backup flow 永遠有明確入口。
8081
- Onboarding shell header 必須有明確的 `Exit setup` 動作;離開後保留目前已選的 storage / profile / security 決策,避免把使用者困在 setup route。
8182
- Schedule / Security 在 M1 起就是 review surface;M2 之後 Import、Audit、Dashboard、Settings 也要能透過 callout / quick action 直接跳回這些修復頁,而不是把排障資訊藏在單一路由裡。
82-
- Sidebar 以視窗高度而不是頁面內容高度佈局;footer 的 archive 狀態與 theme toggle 在不捲動主內容區的情況下也要可見。
83+
- Sidebar 以視窗高度而不是頁面內容高度佈局;footer 的 archive 狀態、background-work strip 與 theme toggle 在不捲動主內容區的情況下也要可見。
8384
- Settings 擁有 day-one 語言切換與平台 troubleshooting;Schedule 擁有 platform-specific Preview / Manual / Execute / Verify story;Import 擁有 recent batch review、revert / restore 與 doctor repair 入口。
8485
- 共享 profile scope 存在於 shell chrome,而不是散落在各頁各自記憶;Explorer 若未指定 page-specific `profileId`,必須明講自己目前沿用 shared scope。
8586

@@ -89,6 +90,8 @@
8990
- semantic result、assistant citation、insight evidence 都要能 deep-link 回 `/explorer`,至少可帶 `q``profileId``domain` 等 canonical filters 讓使用者回看原始記錄。
9091
- Assistant 的 seeded follow-up 使用 `/assistant?question=...`;Explorer、Insights、Dashboard 都可以透過這個 deep-link 把 scoped 問題帶進 assistant composer。
9192
- Dashboard 的 intelligence quick actions 必須直接通往 Explorer、Assistant、Insights;錯誤或 disabled 狀態下還要能跳到 Settings / queue controls,而不是只剩靜態說明。
93+
- shell footer 與 Jobs 頁要形成同一套 queue grammar:footer 負責小型摘要與入口,Jobs 頁負責完整 progress / log / recovery;不能讓兩處各自發明不同的狀態名稱。
94+
- 對長時間 deterministic rebuild,footer 與 Jobs 頁都必須優先顯示 phase / heartbeat / coarse percent,而不是永遠只給一條無信息的 indeterminate bar;使用者需要知道工作仍在前進,還是停在某個 phase 沒有 heartbeat。
9295
- Explorer 的 `semantic` / `hybrid` surface,以及 Assistant、Insights 的 AI status panel,都必須顯示 provider / model、queue counts、index state,並提供 test provider、refresh queue、rebuild / clear index、open settings 這類 controls;keyword-first Explorer 不應被 optional AI 面板壓過主工作流。
9396
- Settings 是 M4-A 起的 remote backup 與 derived-state 控制塔:從這裡可以完成 remote upload 的 PME、credential review、bundle verification、plugin enable / disable、derived rebuild / clear,並回鏈到 Audit run 驗證最新 growth signal。
9497

docs/features/deterministic-intelligence.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ Optional helpers:
475475

476476
2026-04-10 implementation note:
477477

478-
- `clear_derived_intelligence_state` 與 archive visibility repair 現在都會清掉 M5-B derived tables,並把 deterministic module registry 明確標成 `stale`,保留 `manual rebuild required` honesty,而不是讓舊 surface 假裝仍然新鮮。
478+
- `clear_derived_intelligence_state` 與 archive visibility repair 現在都會清掉 M5-B derived tables,並把 deterministic module registry 明確標成 `stale`。backup / import 成功後必須自動排入新的 deterministic rebuild job;若是 manual clear / repair 導致的 stale state,UI 也必須明講目前狀態與下一步,而不是讓舊 surface 假裝仍然新鮮。
479479

480480
---
481481

docs/features/intelligence.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120

121121
- 拉出歷年同一天(±1 天容差)的歷史紀錄,按年份分組展示。
122122
- 同一天的比對以使用者目前系統 timezone 的本地日曆日為準,不用 raw UTC 日期切片假裝對齊「今天」。
123+
- 當前年份今天的紀錄不屬於 `On This Day`;這張卡只用來回看過去幾年的同一天,不能把今天剛產生的瀏覽紀錄混進歷史回顧。
123124
- 如果有足夠數據,用 LLM 生成一句話摘要。
124125
- 適合放在 Dashboard 上作為每日亮點。
125126
- **實現**:純數據庫查詢,不需要 embedding。有 LLM 時可生成摘要,沒有也能用。
@@ -199,14 +200,17 @@
199200

200201
- Insights 頁現在還必須顯示 storage analytics:tracked storage、reclaimable bytes、dominant slice,以及 latest growth signal。這個 growth signal 必須能 deep-link 回對應的 Audit run,而不是只停在摘要數字。
201202
- storage analytics 目前用四個 slice 呈現磁碟分佈:`core``audit``exports``rebuildable``rebuildable` 代表 staging / quarantine 一類可重建或可清理資產,不能和 canonical archive facts 混為一談。
202-
- Settings 頁必須提供 enrichment / derived-state panel,顯示 built-in plugin registry、live queue / recent job review、network boundary、freshness、derived tables、storage impact、enable / disable control,以及 rebuild / clear controls。
203+
- Settings 頁必須提供 enrichment / derived-state panel,顯示 built-in plugin registry、live queue / recent job review、network boundary、freshness、derived tables、storage impact、enable / disable control,以及 rebuild / clear controls。plugin / module 的內部版本標記屬 diagnostics / runtime trace,不應佔據主產品 review chrome。
204+
- shell chrome 左下角必須常駐一個小型 background-work status strip,顯示 queued / running / failed 概況並 deep-link 到 dedicated Jobs 頁;使用者不應該只能靠 Settings / Insights 才知道 background queue 還在跑什麼。
205+
- long-running derived-data job 不能只顯示抽象的 `running`。deterministic rebuild 至少要持續更新 phase、heartbeat 與 coarse progress(例如目前在哪個 phase、已處理幾筆 / 總筆數),讓 Jobs 頁和 shell footer 都能分辨「仍在前進」與「疑似卡死」。
203206
- M5-A 起正式 shipping 的 built-in enrichment plugin 有兩個:`title-normalization`(local-only,版本 `m5-v1`)與 `readable-content-refetch`(network-backed,版本 `m4-v1`)。兩者都屬 derived-state runtime,不可改寫 canonical archive facts。
204207
- `title-normalization` 預設啟用,負責把 noisy browser title、redirect suffix 與 URL fallback 收斂成更穩定的 evidence label。停用後,deterministic insights 仍可用,但必須誠實回退到 raw title / URL structural signals。
205208
- `readable-content-refetch` 預設啟用、freshness window 7 天,也承載第一批 built-in site adapters:影片頁面(YouTube / Vimeo)可優先提取 title、channel / author、duration、publish date 與 description,避免把 noisy page chrome 誤當成主要 evidence。
206209
- built-in enrichment runtime 目前仍是 first-party only:Settings / Insights 可以 review、retry、cancel 內建 job,但 third-party plugin execution 仍 deferred,直到獨立 sandbox / permission ADR 存在。
207-
- derived intelligence refresh 仍是 explicit action;manual backup / import 完成後不應同步綁住 UI 等待 insights rebuild。若使用者要最新 derived state,從 Insights / Settings 主動觸發 rebuild,並在 UI 上看到明確 progress / notes
210+
- derived intelligence refresh backup / import 成功後必須自動排入 runtime job 並留下可 review 的 queue / recent-job trace;Insights / Settings 仍保留手動 rebuild 作為 override,但不能再把最新 derived state 完全變成使用者自己記得去按的 follow-up
208211
- clear derived state 必須回傳清除數量報告,至少涵蓋 enrichment rows、feature rows、topics、threads、cards、runs,並明講 canonical archive、manifests、rollback state 完全未被動到。
209212
- full rebuild 會先清空既有 derived enrichment / insight tables,再重算 insight cards;derived clear / rebuild 與 deterministic module runtime 狀態更新必須以同一個 archive transaction 落地,避免只清掉一半或留下不一致的 stale trace。這一輪 rebuild 仍必須留下 run-linked report 和 notes,避免 advanced intelligence 變成不可追蹤的黑盒。
213+
- queue / progress persistence 也屬 recoverability contract:如果使用者突然關閉 app、程序崩潰或主機斷電,重新開啟後 Jobs 頁必須能誠實呈現上次停在哪個 job、是否已被 recover/requeue,以及最後一次 heartbeat / progress update;不可把 interrupted long-running work 假裝成從未發生。
210214
- source-effectiveness / reference-page 類 surface 的 domain key 必須跟 canonical visit evidence 使用同一套 registrable-domain normalization;不能因為 `docs.example.com` / `www.example.com` 分裂而把同一來源錯拆成多個 source role。
211215
- Dashboard 的 aggregate archive KPIs 仍以 archive-wide read model 為準;共享 profile scope 目前只保證影響 insight fetch、assistant retrieval 與 Explorer 預設 filter,不能誤寫成所有 dashboard 指標都已 profile-partitioned。
212216
- 2026-04-09 truth closeout:目前的 intelligence 支援邊界與未完成項,見 [../plan/m4-full-polish/intelligence-60-year-envelope.md](../plan/m4-full-polish/intelligence-60-year-envelope.md)。在該文件有真實 large-archive artifact 之前,不可把 PathKeep 寫成已完成「60 年資料量、所有 AI 開啟、仍可流暢使用全部功能」的最終性能背書。
@@ -310,4 +314,6 @@
310314
- semantic index 必須支援三種明確操作:incremental catch-up、full rebuild、clear-only;這三者都要留下 run / queue trace,且不能影響 canonical archive facts。
311315
- v1 invalidation contract 先以 honest stale detection + manual rebuild 落地:import / rollback / visibility change / approved enrichment freshness 改變時,UI 必須把 index state 標成 stale。是否自動 re-enqueue rebuild 屬後續 work,不可假裝 day-one 已完成。
312316
- queue payload 必須凍結 enqueue 當下的 provider / model 選擇,避免使用者之後改設定時,同一個 queued job 漂移成不同的執行語義。
313-
- M5-A 現在已把 enrichment queue 收斂成 SQLite-backed `intelligence_jobs` family,並在 Settings / Insights 提供 recent job review、retry / cancel controls 與 first-party-only boundary copy;execution 仍是 manual-first,不假裝已有 autonomous background plugin worker。
317+
- M5-A 起的 queue/runtime surface 現在必須在 archive 解鎖且 queue 未暫停時自動背景執行:AI index job、retry/replay 後的 AI queue,以及 deterministic / enrichment runtime job 都不能再卡住前台 UI。Settings / Insights 仍保留 review / retry / cancel controls,而 dedicated Jobs 頁則作為 always-on log / progress / recovery surface。
318+
- deterministic rebuild 屬於 baseline intelligence,可選 enrichment 只是在後面補更多證據。兩者同時排隊時,deterministic rebuild 必須先跑,避免使用者看到 queue 很忙,但無 AI 的 Insights 仍然完全不可用。
319+
- automatic post-backup/import deterministic refresh 仍不得重新把 network enrichment 塞回 inline backup critical path;backup 只負責 enqueue 與啟動 background rebuild,後續 readable-content 類工作必須留在 queue 裡獨立處理。

docs/plan/BACKLOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@
77

88
## 工作塊佇列(按順序)
99

10-
- 目前沒有待排的 work block。`WORK-QC-F` 已於 2026-04-10 完成 closeout;default desktop shipping surface 維持內建 optional AI / MCP / semantic runtime。
10+
- [ ] **WORK-QC-M** — Large-Archive Performance Envelope And Chunked Deterministic Runtime
11+
- 讀先:
12+
`docs/features/intelligence.md`
13+
`docs/features/deterministic-intelligence.md`
14+
`docs/plan/program/research-and-decisions.md`
15+
`docs/plan/m4-full-polish/intelligence-60-year-envelope.md`
16+
`docs/architecture/data-model.md`
17+
- 目標:把 deterministic intelligence 在大資料量下的時間 / 記憶體 / I/O 邊界做成可重跑 artifact,而不是只靠主觀體感;必要時把 full rebuild 拆成 chunked / resumable / amortized pipeline。
18+
- 契約:以 4 核 3GHz CPU / 8GB RAM、60 年高強度瀏覽資料、無 LLM / 無 embedding 為 baseline,對 backup 後 auto rebuild、Explorer/Insights deterministic surfaces、Jobs recovery / resume 做真實 benchmark 與 complexity audit;如現行複雜度或記憶體模型不滿足基線,需提出並實作 chunking / checkpoint / resume 策略與對應驗收。
19+
- 驗收:留下 benchmark artifact、source doc 更新、targeted regression / perf guard,以及至少一條能在 large-archive sample 上重跑的 honest automation / manual recipe。
1120

1221
---
1322

0 commit comments

Comments
 (0)