Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions packages/plugin/src/features/magic-context/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export const MIGRATIONS: Migration[] = [
session_id TEXT,
project_path TEXT,
surface_condition TEXT,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL,
last_checked_at INTEGER,
ready_at INTEGER,
Expand Down Expand Up @@ -320,7 +320,7 @@ export const MIGRATIONS: Migration[] = [
type TEXT NOT NULL,
payload TEXT NOT NULL DEFAULT '{}',
session_id TEXT,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
consumed_at INTEGER
);
CREATE INDEX IF NOT EXISTS idx_plugin_messages_direction_consumed
Expand All @@ -341,7 +341,7 @@ export const MIGRATIONS: Migration[] = [
session_id TEXT NOT NULL,
source_compartment_start INTEGER,
source_compartment_end INTEGER,
created_at INTEGER NOT NULL
created_at INTEGER NOT NULL -- epoch ms (Date.now())
);
CREATE INDEX IF NOT EXISTS idx_umc_created ON user_memory_candidates(created_at);

Expand All @@ -352,7 +352,7 @@ export const MIGRATIONS: Migration[] = [
promoted_at INTEGER NOT NULL,
source_candidate_ids TEXT DEFAULT '[]',
source_candidate_provenance TEXT,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_um_status ON user_memories(status);
Expand Down Expand Up @@ -380,7 +380,7 @@ export const MIGRATIONS: Migration[] = [
sha TEXT PRIMARY KEY,
embedding BLOB NOT NULL,
model_id TEXT NOT NULL,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
-- FK-cascade audit (v12): git_commit_embeddings.sha -> git_commits.sha
-- uses ON DELETE CASCADE, so SQLite PRAGMA foreign_keys must be ON on
-- every connection and v12 cleans historical orphan rows.
Expand Down Expand Up @@ -1061,7 +1061,7 @@ export const MIGRATIONS: Migration[] = [
kind TEXT NOT NULL,
at_compartment INTEGER,
fields_json TEXT NOT NULL DEFAULT '{}',
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
harness TEXT NOT NULL DEFAULT 'opencode'
);
CREATE INDEX IF NOT EXISTS idx_compartment_events_session
Expand Down Expand Up @@ -1101,7 +1101,7 @@ export const MIGRATIONS: Migration[] = [
importance_avg REAL,
discarded_last INTEGER NOT NULL DEFAULT 0,
legacy INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL
created_at INTEGER NOT NULL -- epoch ms (Date.now())
);
CREATE INDEX IF NOT EXISTS idx_historian_runs_session
ON historian_runs(session_id, created_at DESC);
Expand Down Expand Up @@ -1452,7 +1452,7 @@ export const MIGRATIONS: Migration[] = [
model_id TEXT NOT NULL,
dims INTEGER NOT NULL,
vector BLOB NOT NULL,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
UNIQUE(compartment_id, window_index)
);
CREATE INDEX IF NOT EXISTS idx_cce_session
Expand All @@ -1471,7 +1471,7 @@ export const MIGRATIONS: Migration[] = [
CREATE TABLE IF NOT EXISTS workspaces (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL
);
CREATE TABLE IF NOT EXISTS workspace_members (
Expand Down Expand Up @@ -1544,7 +1544,7 @@ export const MIGRATIONS: Migration[] = [
CREATE TABLE IF NOT EXISTS workspaces (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL,
share_categories TEXT NOT NULL DEFAULT '["CONSTRAINTS"]'
);
Expand Down Expand Up @@ -1829,7 +1829,7 @@ export const MIGRATIONS: Migration[] = [
source_message_time INTEGER NOT NULL,
question_embedding BLOB,
question_embedding_model_id TEXT,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
UNIQUE(project_path, harness, session_id, source_start_message_id, source_end_message_id)
);
CREATE INDEX IF NOT EXISTS idx_primer_candidates_project_time
Expand All @@ -1852,7 +1852,7 @@ export const MIGRATIONS: Migration[] = [
answer_refreshed_at INTEGER,
source_candidate_ids TEXT NOT NULL DEFAULT '[]',
source_candidate_provenance TEXT,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_primers_project_status_observed
Expand Down Expand Up @@ -1985,7 +1985,7 @@ export const MIGRATIONS: Migration[] = [
sha TEXT NOT NULL,
embedding BLOB NOT NULL,
model_id TEXT NOT NULL,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
PRIMARY KEY(sha, model_id),
FOREIGN KEY(sha) REFERENCES git_commits(sha) ON DELETE CASCADE
);
Expand Down Expand Up @@ -2022,7 +2022,7 @@ export const MIGRATIONS: Migration[] = [
model_id TEXT NOT NULL,
dims INTEGER NOT NULL,
vector BLOB NOT NULL,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
UNIQUE(compartment_id, model_id, window_index)
);
INSERT INTO compartment_chunk_embeddings_v49_new (
Expand Down Expand Up @@ -2117,7 +2117,7 @@ export const MIGRATIONS: Migration[] = [
job_id TEXT,
cursor TEXT,
status TEXT NOT NULL DEFAULT 'pending',
created_at INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL DEFAULT 0, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL DEFAULT 0,
UNIQUE(session_id, request_key)
);
Expand Down Expand Up @@ -2156,7 +2156,7 @@ export const MIGRATIONS: Migration[] = [
shadow_epoch INTEGER NOT NULL DEFAULT 0,
corpus_hash TEXT NOT NULL DEFAULT '',
coverage_json TEXT NOT NULL DEFAULT '{}',
created_at INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL DEFAULT 0, -- epoch ms (Date.now())
UNIQUE(dedup_key, cohort_key)
);
CREATE INDEX IF NOT EXISTS idx_embedding_measurement_session
Expand Down Expand Up @@ -2814,7 +2814,7 @@ export const MIGRATIONS: Migration[] = [
stage_path TEXT NOT NULL,
content_sha256 TEXT NOT NULL,
phase TEXT NOT NULL CHECK (phase IN ('staged', 'db_committed')),
created_at INTEGER NOT NULL
created_at INTEGER NOT NULL -- epoch ms (Date.now())
);
`);
},
Expand Down
28 changes: 14 additions & 14 deletions packages/plugin/src/features/magic-context/storage-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ export function initializeDatabase(
p1_embedding BLOB,
p1_embedding_model_id TEXT,
legacy INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
harness TEXT NOT NULL DEFAULT 'opencode',
UNIQUE(session_id, sequence)
);
Expand All @@ -982,7 +982,7 @@ export function initializeDatabase(
model_id TEXT NOT NULL,
dims INTEGER NOT NULL,
vector BLOB NOT NULL,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
UNIQUE(compartment_id, model_id, window_index)
);
CREATE INDEX IF NOT EXISTS idx_cce_session ON compartment_chunk_embeddings(session_id);
Expand All @@ -1005,7 +1005,7 @@ export function initializeDatabase(
kind TEXT NOT NULL,
at_compartment INTEGER,
fields_json TEXT NOT NULL DEFAULT '{}',
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
harness TEXT NOT NULL DEFAULT 'opencode'
);
CREATE INDEX IF NOT EXISTS idx_compartment_events_session
Expand Down Expand Up @@ -1034,7 +1034,7 @@ export function initializeDatabase(
session_id TEXT NOT NULL,
category TEXT NOT NULL,
content TEXT NOT NULL,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL,
harness TEXT NOT NULL DEFAULT 'opencode'
);
Expand All @@ -1053,7 +1053,7 @@ export function initializeDatabase(
source_message_time INTEGER NOT NULL,
question_embedding BLOB,
question_embedding_model_id TEXT,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
UNIQUE(project_path, harness, session_id, source_start_message_id, source_end_message_id)
);
CREATE INDEX IF NOT EXISTS idx_primer_candidates_project_time
Expand All @@ -1076,7 +1076,7 @@ export function initializeDatabase(
answer_refreshed_at INTEGER,
source_candidate_ids TEXT NOT NULL DEFAULT '[]',
source_candidate_provenance TEXT,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL
);
CREATE INDEX IF NOT EXISTS idx_primers_project_status_observed
Expand Down Expand Up @@ -1129,7 +1129,7 @@ export function initializeDatabase(
seen_count INTEGER DEFAULT 1,
retrieval_count INTEGER DEFAULT 0,
first_seen_at INTEGER NOT NULL,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL,
last_seen_at INTEGER NOT NULL,
last_retrieved_at INTEGER,
Expand Down Expand Up @@ -1189,7 +1189,7 @@ export function initializeDatabase(
job_id TEXT,
cursor TEXT,
status TEXT NOT NULL DEFAULT 'pending',
created_at INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL DEFAULT 0, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL DEFAULT 0,
UNIQUE(session_id, request_key)
);
Expand Down Expand Up @@ -1230,7 +1230,7 @@ export function initializeDatabase(
shadow_epoch INTEGER NOT NULL DEFAULT 0,
corpus_hash TEXT NOT NULL DEFAULT '',
coverage_json TEXT NOT NULL DEFAULT '{}',
created_at INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL DEFAULT 0, -- epoch ms (Date.now())
UNIQUE(dedup_key, cohort_key)
);
CREATE INDEX IF NOT EXISTS idx_embedding_measurement_session
Expand Down Expand Up @@ -1384,7 +1384,7 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
CREATE TABLE IF NOT EXISTS workspaces (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL,
share_categories TEXT NOT NULL DEFAULT '["CONSTRAINTS"]'
);
Expand Down Expand Up @@ -1655,7 +1655,7 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
importance_avg REAL,
discarded_last INTEGER NOT NULL DEFAULT 0,
legacy INTEGER NOT NULL DEFAULT 0,
created_at INTEGER NOT NULL
created_at INTEGER NOT NULL -- epoch ms (Date.now())
);
CREATE INDEX IF NOT EXISTS idx_historian_runs_session
ON historian_runs(session_id, created_at DESC);
Expand Down Expand Up @@ -1708,7 +1708,7 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
importance INTEGER NOT NULL DEFAULT 50,
episode_type TEXT,
pass_number INTEGER NOT NULL,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
harness TEXT NOT NULL DEFAULT 'opencode',
UNIQUE(session_id, sequence)
);
Expand All @@ -1719,7 +1719,7 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
category TEXT NOT NULL,
content TEXT NOT NULL,
pass_number INTEGER NOT NULL,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
harness TEXT NOT NULL DEFAULT 'opencode'
);

Expand Down Expand Up @@ -2100,7 +2100,7 @@ CREATE INDEX IF NOT EXISTS idx_dream_queue_pending ON dream_queue(started_at, en
CREATE TABLE IF NOT EXISTS workspaces (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL UNIQUE,
created_at INTEGER NOT NULL,
created_at INTEGER NOT NULL, -- epoch ms (Date.now())
updated_at INTEGER NOT NULL,
share_categories TEXT NOT NULL DEFAULT '["CONSTRAINTS"]'
);
Expand Down