Phase 4c: Migrate thread history from JSONL to ocas variable store #18

Merged
xiaomo merged 1 commits from refactor/history-to-ocas-variable into main 2026-06-02 14:54:34 +00:00
Owner

What

Migrate completed/cancelled thread history from history.jsonl to ocas VariableStore (@uwf/history/<thread-id>).

Why

Phase 4c of issue #11. After this, all persistent state (registry, threads, history) lives in the variable store — no more YAML or JSONL files.

Changes

store.ts

  • New HISTORY_VAR_PREFIX + sync functions: loadAllHistory, findHistoryEntry, addHistoryEntry
  • migrateHistoryIfNeeded(): reads history.jsonl → writes variables → renames .migrated
  • Removed: loadThreadHistory, findThreadInHistory, appendThreadHistory, getHistoryPath

Callers

  • cmdThreadList/Show/Cancel/Complete, archiveThread, resolveHeadHash all use varStore
  • archiveThread now sync

Variable schema

  • Name: @uwf/history/<thread-id>, Value: CAS head hash
  • Tags: workflow, completedAt, reason (completed|cancelled)

Tests

  • All updated, new migration test, 403 pass / 0 fail

Ref

Closes #11

## What Migrate completed/cancelled thread history from `history.jsonl` to ocas VariableStore (`@uwf/history/<thread-id>`). ## Why Phase 4c of issue #11. After this, all persistent state (registry, threads, history) lives in the variable store — no more YAML or JSONL files. ## Changes ### store.ts - New `HISTORY_VAR_PREFIX` + sync functions: `loadAllHistory`, `findHistoryEntry`, `addHistoryEntry` - `migrateHistoryIfNeeded()`: reads `history.jsonl` → writes variables → renames `.migrated` - Removed: `loadThreadHistory`, `findThreadInHistory`, `appendThreadHistory`, `getHistoryPath` ### Callers - `cmdThreadList/Show/Cancel/Complete`, `archiveThread`, `resolveHeadHash` all use varStore - `archiveThread` now sync ### Variable schema - Name: `@uwf/history/<thread-id>`, Value: CAS head hash - Tags: `workflow`, `completedAt`, `reason` (`completed`|`cancelled`) ### Tests - All updated, new migration test, 403 pass / 0 fail ## Ref Closes #11
xingyue added 1 commit 2026-06-02 14:53:27 +00:00
xiaomo approved these changes 2026-06-02 14:54:32 +00:00
xiaomo left a comment
Owner

LGTM

Phase 4 收尾干净:

  • history.jsonl append-only → @uwf/history/<thread-id> variable,metadata 用 tags(workflow, completedAt, reason
  • appendFile 删除,addHistoryEntry 同步写 variable
  • findHistoryEntryexactName prefix 查找单条,不需要扫全量
  • parseHistoryJsonlLine 抽出复用于迁移逻辑,好
  • 迁移逻辑与 4a/4b 一致:检测文件 → 导入 → rename .migrated
  • loadAllHistorycompletedAtNumber(v.tags.completedAt ?? "0") — tags 只能存 string 所以需要转换,合理

Phase 4 三刀全砍完,YAML + JSONL 全部消灭 ⚔️

LGTM ✅ Phase 4 收尾干净: - `history.jsonl` append-only → `@uwf/history/<thread-id>` variable,metadata 用 tags(`workflow`, `completedAt`, `reason`) - `appendFile` 删除,`addHistoryEntry` 同步写 variable - `findHistoryEntry` 用 `exactName` prefix 查找单条,不需要扫全量 - `parseHistoryJsonlLine` 抽出复用于迁移逻辑,好 - 迁移逻辑与 4a/4b 一致:检测文件 → 导入 → rename `.migrated` - `loadAllHistory` 的 `completedAt` 用 `Number(v.tags.completedAt ?? "0")` — tags 只能存 string 所以需要转换,合理 Phase 4 三刀全砍完,YAML + JSONL 全部消灭 ⚔️
xiaomo merged commit 74b81fe9ba into main 2026-06-02 14:54:34 +00:00
xiaomo deleted branch refactor/history-to-ocas-variable 2026-06-02 14:54:34 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#18