Solution for long term memory for agent coding CLIs and to facilitate handoff between different agent vendors
Rust
fix(store): renumber the Copilot CLI agent-kind migration to V73
AkitaOnRails279a4387e5f2
diff --git a/crates/ai-memory-core/src/ids.rs b/crates/ai-memory-core/src/ids.rsindex 7630159d..fca2a3e3 100644--- a/crates/ai-memory-core/src/ids.rs+++ b/crates/ai-memory-core/src/ids.rs@@ -295,7 +295,7 @@ impl AgentKind {/// CHECK constraint accepts every kind (the Zero integration shipped/// with the enum variant but without the V26 migration and only a/// live test caught it). Extend together with the enum.- pub const ALL: [Self; 22] = [+ pub const ALL: [Self; 23] = [Self::ClaudeCode,Self::Codex,Self::OpenCode,diff --git a/crates/ai-memory-store/migrations/V72__sessions_copilot_cli_agent_kind.sql b/crates/ai-memory-store/migrations/V73__sessions_copilot_cli_agent_kind.sqlsimilarity index 98%rename from crates/ai-memory-store/migrations/V72__sessions_copilot_cli_agent_kind.sqlrename to crates/ai-memory-store/migrations/V73__sessions_copilot_cli_agent_kind.sqlindex cc91c793..8ff68e58 100644--- a/crates/ai-memory-store/migrations/V72__sessions_copilot_cli_agent_kind.sql+++ b/crates/ai-memory-store/migrations/V73__sessions_copilot_cli_agent_kind.sql@@ -12,7 +12,7 @@ CREATE TABLE sessions_new (id BLOB PRIMARY KEY NOT NULL,workspace_id BLOB NOT NULL REFERENCES workspaces(id) ON DELETE CASCADE,project_id BLOB NOT NULL REFERENCES projects(id) ON DELETE CASCADE,- agent_kind TEXT NOT NULL CHECK (agent_kind IN ('claude-code','codex','open-code','cursor','gemini-cli','claude-desktop','openclaw','antigravity-cli','omp','pi','crush','grok','zero','devin','kimi-code','kiro-cli','command-code','hermes','pool','zcode','copilot-cli','other')),+ agent_kind TEXT NOT NULL CHECK (agent_kind IN ('claude-code','codex','open-code','cursor','gemini-cli','claude-desktop','openclaw','antigravity-cli','omp','pi','crush','grok','zero','devin','kimi-code','kiro-cli','command-code','hermes','pool','zcode','grizzybot','copilot-cli','other')),cwd TEXT,started_at INTEGER NOT NULL,ended_at INTEGER,diff --git a/crates/ai-memory-store/src/api_credentials.rs b/crates/ai-memory-store/src/api_credentials.rsindex dfc953c3..a59921ff 100644--- a/crates/ai-memory-store/src/api_credentials.rs+++ b/crates/ai-memory-store/src/api_credentials.rs@@ -411,7 +411,7 @@ mod tests {|row| row.get(0),).unwrap();- assert_eq!(version, 72, "update the pin when adding a migration");+ assert_eq!(version, 73, "update the pin when adding a migration");let cols: i64 = conn.query_row("SELECT COUNT(*) FROM pragma_table_info('users') WHERE name = 'token_hash'",diff --git a/crates/ai-memory-store/src/migrations.rs b/crates/ai-memory-store/src/migrations.rsindex ecfe95ab..c38c56f6 100644--- a/crates/ai-memory-store/src/migrations.rs+++ b/crates/ai-memory-store/src/migrations.rs@@ -998,6 +998,79 @@ mod tests {}}+ #[test]+ fn v72_to_v73_preserves_grizzybot_sessions_and_accepts_copilot_cli() {+ let mut conn = Connection::open_in_memory().unwrap();+ run_to(&mut conn, 72).unwrap();+ conn.pragma_update(None, "foreign_keys", "ON").unwrap();+ let workspace_id = crate::ops::get_or_create_workspace(&mut conn, "default").unwrap();+ let project_id =+ crate::ops::get_or_create_project(&mut conn, &workspace_id, "project", None).unwrap();+ let existing = SessionId::new();+ conn.execute(+ "INSERT INTO sessions \+ (id, workspace_id, project_id, agent_kind, cwd, started_at, ended_at, \+ ended_observation_count, actor_user) \+ VALUES (?1, ?2, ?3, 'grizzybot', '/repo', 1, 2, 7, 'user:alice')",+ params![+ existing.as_bytes(),+ workspace_id.as_bytes(),+ project_id.as_bytes(),+ ],+ )+ .unwrap();++ conn.pragma_update(None, "foreign_keys", "OFF").unwrap();+ run(&mut conn).unwrap();+ conn.pragma_update(None, "foreign_keys", "ON").unwrap();++ let preserved: (String, String, i64, Option<String>) = conn+ .query_row(+ "SELECT agent_kind, cwd, ended_observation_count, actor_user \+ FROM sessions WHERE id = ?1",+ params![existing.as_bytes()],+ |row| Ok((row.get(0)?, row.get(1)?, row.get(2)?, row.get(3)?)),+ )+ .unwrap();+ assert_eq!(+ preserved,+ (+ "grizzybot".into(),+ "/repo".into(),+ 7,+ Some("user:alice".into())+ )+ );++ crate::ops::begin_session(+ &mut conn,+ &NewSession {+ occurred_at: None,+ id: SessionId::new(),+ workspace_id,+ project_id,+ agent_kind: AgentKind::CopilotCli,+ cwd: Some("/repo".into()),+ actor_user: Some("user:alice".into()),+ },+ )+ .unwrap();++ for name in [+ "idx_sessions_open_owner",+ "sessions_ws_proj_pairing_ai",+ "auto_improve_scheduler_claims_session_pairing_ai",+ "session_consolidation_jobs_session_pairing_ai",+ ] {+ let kind = if name.starts_with("idx_") {+ "index"+ } else {+ "trigger"+ };+ assert_eq!(schema_object_count(&conn, kind, name), 1, "missing {name}");+ }+ }+/// V62 was reshaped in place (#776) from an in-migration backfill to/// DDL-only + a boot-path backfill, changing its checksum. A store that/// applied the ORIGINAL V62 recorded the old checksum; `run` must still