Skip to content

feat(daemon): arc migrate v2-to-v3 CLI — ingest v2 state into SQLite#31

Open
Codename-11 wants to merge 1 commit into
feature/v3-foundationfrom
feature/migrate-v2-to-v3
Open

feat(daemon): arc migrate v2-to-v3 CLI — ingest v2 state into SQLite#31
Codename-11 wants to merge 1 commit into
feature/v3-foundationfrom
feature/migrate-v2-to-v3

Conversation

@Codename-11
Copy link
Copy Markdown
Owner

Summary

  • Adds arc migrate v2-to-v3 CLI command (offline, does not require the daemon) that ingests v2 state into the v3 SQLite store at ~/.arc/arc.db.
  • New migrateV2ToV3() function in packages/daemon/src/migrations/v2-to-v3.ts — reads history.json, per-profile chat-sessions/*.json, and activity.log (or logs/events.ndjson); writes rows into agents, agent_events, and meta.
  • Idempotence is guarded by a meta row (migration_v2_to_v3_completed_at). A second invocation reports "already migrated, nothing to do".
  • Non-destructive: v2 files are preserved, never deleted or modified.
  • Supports --dry-run (counts only, no DB writes) and --json.
  • Fixture-based vitest covering: ingestion, idempotence, dry-run, non-destructiveness, and missing-history graceful path.

Mapping

  • Each history.json launch entry becomes one agents row (status=completed, launch_mode=native, deterministic v2-<sha1> id, metadata JSON preserves tool/outcome/exitCode).
  • Chat session messages land as agent_events with epoch=1: assistant/user/system → stdout, toolCalls[]tool_call (+ tool_result if result/error present), role=tooltool_result.
  • Activity log lines land as agent_events with kind=status, correlated to an agent via timestamp window (+/- 10 min, same profile). Unmatched lines are counted as skipped.

Test plan

  • npx tsc --noEmit passes
  • npx vitest run tests/migrate-v2-to-v3.test.ts — 5/5 pass
  • CLI smoke (dry-run emits JSON counts, no db written; real run creates arc.db; second run reports "already migrated")
  • Reviewer spot-check DB schema and event kinds

Offline, idempotent migration that reads ~/.arc/history.json, per-profile
chat-sessions, and activity.log (or logs/events.ndjson) and writes rows to
agents / agent_events / meta tables in the v3 SQLite store. v2 files are
preserved. Supports --dry-run and --json.

Idempotence is guarded by a meta row (migration_v2_to_v3_completed_at).
A second run short-circuits as "already migrated, nothing to do".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant