@signetai/connector-codex 0.216.7 → 0.217.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +601 -23
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -16154,6 +16154,241 @@ function up145(db) {
|
|
|
16154
16154
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
16155
16155
|
`);
|
|
16156
16156
|
}
|
|
16157
|
+
function up146(db) {
|
|
16158
|
+
db.exec(`
|
|
16159
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
16160
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
16161
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
16162
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
16163
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
16164
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
16165
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
16166
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16167
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
16168
|
+
);
|
|
16169
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
16170
|
+
|
|
16171
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
16172
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16173
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
16174
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
16175
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
16176
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
16177
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
16178
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16179
|
+
UNIQUE(job_id, ordinal)
|
|
16180
|
+
);
|
|
16181
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
16182
|
+
|
|
16183
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
16184
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16185
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
16186
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
16187
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
16188
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
16189
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16190
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
16191
|
+
);
|
|
16192
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
16193
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
16194
|
+
|
|
16195
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
16196
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
16197
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
16198
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
16199
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
16200
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16201
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
16202
|
+
);
|
|
16203
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
16204
|
+
|
|
16205
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
16206
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
16207
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
16208
|
+
);
|
|
16209
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
16210
|
+
`);
|
|
16211
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
16212
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
16213
|
+
if (exists == null)
|
|
16214
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
16215
|
+
}
|
|
16216
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
16217
|
+
}
|
|
16218
|
+
function up147(db) {
|
|
16219
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
16220
|
+
}
|
|
16221
|
+
function up148(db) {
|
|
16222
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
16223
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
16224
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
16225
|
+
}
|
|
16226
|
+
}
|
|
16227
|
+
function up149(db) {
|
|
16228
|
+
const addColumn = (table, column, definition) => {
|
|
16229
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
16230
|
+
if (exists == null)
|
|
16231
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16232
|
+
};
|
|
16233
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
16234
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
16235
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
16236
|
+
}
|
|
16237
|
+
function addColumnIfMissing28(db, table, column, definition) {
|
|
16238
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
16239
|
+
if (!columns.some((row) => row.name === column))
|
|
16240
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16241
|
+
}
|
|
16242
|
+
function up150(db) {
|
|
16243
|
+
addColumnIfMissing28(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
16244
|
+
addColumnIfMissing28(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
16245
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
16246
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
16247
|
+
db.exec(`
|
|
16248
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
16249
|
+
AFTER INSERT ON dreaming_passes
|
|
16250
|
+
WHEN NEW.mode = 'incremental-content'
|
|
16251
|
+
BEGIN
|
|
16252
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
16253
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
16254
|
+
UPDATE dreaming_passes
|
|
16255
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
16256
|
+
WHERE id = NEW.id;
|
|
16257
|
+
END;
|
|
16258
|
+
|
|
16259
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
16260
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
16261
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
16262
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
16263
|
+
OR OLD.agent_id IS NOT NEW.agent_id OR OLD.visibility IS NOT NEW.visibility OR OLD.scope IS NOT NEW.scope OR OLD.memory_kind IS NOT NEW.memory_kind
|
|
16264
|
+
BEGIN
|
|
16265
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16266
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
16267
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
16268
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16269
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16270
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
16271
|
+
END;
|
|
16272
|
+
|
|
16273
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
16274
|
+
AFTER DELETE ON memories
|
|
16275
|
+
BEGIN
|
|
16276
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16277
|
+
WHERE agent_id = OLD.agent_id
|
|
16278
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
16279
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16280
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16281
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
16282
|
+
END;
|
|
16283
|
+
|
|
16284
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
16285
|
+
AFTER DELETE ON agents
|
|
16286
|
+
BEGIN
|
|
16287
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16288
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
16289
|
+
END;
|
|
16290
|
+
|
|
16291
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
16292
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
16293
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
16294
|
+
BEGIN
|
|
16295
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16296
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
16297
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16298
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
16299
|
+
END;
|
|
16300
|
+
`);
|
|
16301
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
16302
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16303
|
+
if (!exists)
|
|
16304
|
+
continue;
|
|
16305
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
16306
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
16307
|
+
const contentChanged = table === "session_transcripts" ? "OLD.completed_at IS NOT NULL AND (OLD.content IS NOT NEW.content OR NEW.completed_at IS NULL)" : `OLD.content IS NOT NEW.content${hasIsDeleted ? " OR OLD.is_deleted IS NOT NEW.is_deleted" : ""}`;
|
|
16308
|
+
db.exec(`
|
|
16309
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16310
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16311
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
16312
|
+
BEGIN
|
|
16313
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16314
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16315
|
+
END;
|
|
16316
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16317
|
+
AFTER DELETE ON ${table}
|
|
16318
|
+
BEGIN
|
|
16319
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16320
|
+
END;
|
|
16321
|
+
`);
|
|
16322
|
+
}
|
|
16323
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
16324
|
+
db.exec(`
|
|
16325
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
16326
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
16327
|
+
WHEN OLD.depth = 0 AND (OLD.content IS NOT NEW.content OR OLD.source_ref IS NOT NEW.source_ref OR OLD.source_type IS NOT NEW.source_type OR OLD.depth IS NOT NEW.depth OR OLD.agent_id IS NOT NEW.agent_id)
|
|
16328
|
+
BEGIN
|
|
16329
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16330
|
+
END;
|
|
16331
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
16332
|
+
AFTER DELETE ON session_summaries
|
|
16333
|
+
WHEN OLD.depth = 0
|
|
16334
|
+
BEGIN
|
|
16335
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16336
|
+
END;
|
|
16337
|
+
`);
|
|
16338
|
+
}
|
|
16339
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
16340
|
+
if (safetyExists) {
|
|
16341
|
+
db.exec(`
|
|
16342
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
16343
|
+
AFTER INSERT ON memory_content_safety
|
|
16344
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
16345
|
+
BEGIN
|
|
16346
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16347
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
16348
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
16349
|
+
END;
|
|
16350
|
+
|
|
16351
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
16352
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
16353
|
+
WHEN (OLD.context_eligible IS NOT NEW.context_eligible OR OLD.agent_id IS NOT NEW.agent_id OR OLD.status IS NOT NEW.status)
|
|
16354
|
+
AND (OLD.status IS NOT 'clean' OR NEW.status IS NOT 'clean' OR OLD.context_eligible IS NOT 1 OR NEW.context_eligible IS NOT 1)
|
|
16355
|
+
BEGIN
|
|
16356
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16357
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
16358
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16359
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
16360
|
+
END;
|
|
16361
|
+
`);
|
|
16362
|
+
}
|
|
16363
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
16364
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16365
|
+
if (!exists)
|
|
16366
|
+
continue;
|
|
16367
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
16368
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
16369
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
16370
|
+
const lifecycleWhen = table === "imported_source_lifecycle" ? `(OLD.agent_id IS NOT NEW.agent_id OR OLD.status IS NOT NEW.status)${lifecycleUpdateClause}` : "OLD.agent_id IS NOT NEW.agent_id";
|
|
16371
|
+
db.exec(`
|
|
16372
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
16373
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
16374
|
+
BEGIN
|
|
16375
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
16376
|
+
END;
|
|
16377
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16378
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16379
|
+
WHEN ${lifecycleWhen}
|
|
16380
|
+
BEGIN
|
|
16381
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16382
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16383
|
+
END;
|
|
16384
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16385
|
+
AFTER DELETE ON ${table}
|
|
16386
|
+
BEGIN
|
|
16387
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16388
|
+
END;
|
|
16389
|
+
`);
|
|
16390
|
+
}
|
|
16391
|
+
}
|
|
16157
16392
|
var MIGRATIONS = [
|
|
16158
16393
|
{
|
|
16159
16394
|
version: 1,
|
|
@@ -17303,6 +17538,60 @@ var MIGRATIONS = [
|
|
|
17303
17538
|
name: "dreaming-evidence-reviews",
|
|
17304
17539
|
up: up145,
|
|
17305
17540
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
17541
|
+
},
|
|
17542
|
+
{
|
|
17543
|
+
version: 146,
|
|
17544
|
+
name: "source-transcript-import",
|
|
17545
|
+
up: up146,
|
|
17546
|
+
artifacts: {
|
|
17547
|
+
tables: [
|
|
17548
|
+
"source_import_jobs",
|
|
17549
|
+
"source_import_files",
|
|
17550
|
+
"source_import_records",
|
|
17551
|
+
"transcript_import_conversations",
|
|
17552
|
+
"source_import_record_attempts"
|
|
17553
|
+
],
|
|
17554
|
+
columns: [
|
|
17555
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
17556
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
17557
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
17558
|
+
]
|
|
17559
|
+
}
|
|
17560
|
+
},
|
|
17561
|
+
{
|
|
17562
|
+
version: 147,
|
|
17563
|
+
name: "source-import-replay-file-slots",
|
|
17564
|
+
up: up147,
|
|
17565
|
+
artifacts: { tables: ["source_import_files"] }
|
|
17566
|
+
},
|
|
17567
|
+
{
|
|
17568
|
+
version: 148,
|
|
17569
|
+
name: "source-import-attempt-provenance",
|
|
17570
|
+
up: up148,
|
|
17571
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
17572
|
+
},
|
|
17573
|
+
{
|
|
17574
|
+
version: 149,
|
|
17575
|
+
name: "transcript-import-state-machine",
|
|
17576
|
+
up: up149,
|
|
17577
|
+
artifacts: {
|
|
17578
|
+
columns: [
|
|
17579
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
17580
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
17581
|
+
{ table: "source_import_files", column: "error" }
|
|
17582
|
+
]
|
|
17583
|
+
}
|
|
17584
|
+
},
|
|
17585
|
+
{
|
|
17586
|
+
version: 150,
|
|
17587
|
+
name: "memory-head-freshness",
|
|
17588
|
+
up: up150,
|
|
17589
|
+
artifacts: {
|
|
17590
|
+
columns: [
|
|
17591
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
17592
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
17593
|
+
]
|
|
17594
|
+
}
|
|
17306
17595
|
}
|
|
17307
17596
|
];
|
|
17308
17597
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -29266,7 +29555,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
29266
29555
|
return true;
|
|
29267
29556
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
29268
29557
|
}
|
|
29269
|
-
function
|
|
29558
|
+
function up151(db) {
|
|
29270
29559
|
db.exec(`
|
|
29271
29560
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
29272
29561
|
version INTEGER PRIMARY KEY,
|
|
@@ -29359,27 +29648,27 @@ function hasColumn26(db, table, column) {
|
|
|
29359
29648
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29360
29649
|
return rows.some((r3) => r3.name === column);
|
|
29361
29650
|
}
|
|
29362
|
-
function
|
|
29651
|
+
function addColumnIfMissing29(db, table, column, definition) {
|
|
29363
29652
|
if (!hasColumn26(db, table, column)) {
|
|
29364
29653
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
29365
29654
|
}
|
|
29366
29655
|
}
|
|
29367
29656
|
function up210(db) {
|
|
29368
|
-
|
|
29369
|
-
|
|
29370
|
-
|
|
29371
|
-
|
|
29372
|
-
|
|
29373
|
-
|
|
29374
|
-
|
|
29375
|
-
|
|
29376
|
-
|
|
29377
|
-
|
|
29378
|
-
|
|
29379
|
-
|
|
29380
|
-
|
|
29381
|
-
|
|
29382
|
-
|
|
29657
|
+
addColumnIfMissing29(db, "memories", "content_hash", "TEXT");
|
|
29658
|
+
addColumnIfMissing29(db, "memories", "normalized_content", "TEXT");
|
|
29659
|
+
addColumnIfMissing29(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
29660
|
+
addColumnIfMissing29(db, "memories", "deleted_at", "TEXT");
|
|
29661
|
+
addColumnIfMissing29(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
29662
|
+
addColumnIfMissing29(db, "memories", "embedding_model", "TEXT");
|
|
29663
|
+
addColumnIfMissing29(db, "memories", "extraction_model", "TEXT");
|
|
29664
|
+
addColumnIfMissing29(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
29665
|
+
addColumnIfMissing29(db, "memories", "who", "TEXT");
|
|
29666
|
+
addColumnIfMissing29(db, "memories", "why", "TEXT");
|
|
29667
|
+
addColumnIfMissing29(db, "memories", "project", "TEXT");
|
|
29668
|
+
addColumnIfMissing29(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
29669
|
+
addColumnIfMissing29(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
29670
|
+
addColumnIfMissing29(db, "memories", "last_accessed", "TEXT");
|
|
29671
|
+
addColumnIfMissing29(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
29383
29672
|
db.exec(`
|
|
29384
29673
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
29385
29674
|
id TEXT PRIMARY KEY,
|
|
@@ -29475,7 +29764,7 @@ function up210(db) {
|
|
|
29475
29764
|
ON memory_entity_mentions(entity_id);
|
|
29476
29765
|
`);
|
|
29477
29766
|
}
|
|
29478
|
-
function
|
|
29767
|
+
function addColumnIfMissing210(db, table, column, definition) {
|
|
29479
29768
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29480
29769
|
if (rows.some((r3) => r3.name === column))
|
|
29481
29770
|
return false;
|
|
@@ -29483,8 +29772,8 @@ function addColumnIfMissing29(db, table, column, definition) {
|
|
|
29483
29772
|
return true;
|
|
29484
29773
|
}
|
|
29485
29774
|
function up310(db) {
|
|
29486
|
-
|
|
29487
|
-
|
|
29775
|
+
addColumnIfMissing210(db, "memories", "why", "TEXT");
|
|
29776
|
+
addColumnIfMissing210(db, "memories", "project", "TEXT");
|
|
29488
29777
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
29489
29778
|
db.exec(`
|
|
29490
29779
|
UPDATE memories
|
|
@@ -29776,7 +30065,7 @@ function up1310(db) {
|
|
|
29776
30065
|
addColumnIfMissing52(db, "memories", "source_path", "TEXT");
|
|
29777
30066
|
addColumnIfMissing52(db, "memories", "source_section", "TEXT");
|
|
29778
30067
|
}
|
|
29779
|
-
function
|
|
30068
|
+
function up1410(db) {
|
|
29780
30069
|
db.exec(`
|
|
29781
30070
|
CREATE TABLE IF NOT EXISTS telemetry_events (
|
|
29782
30071
|
id TEXT PRIMARY KEY,
|
|
@@ -34039,11 +34328,246 @@ function up1452(db) {
|
|
|
34039
34328
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
34040
34329
|
`);
|
|
34041
34330
|
}
|
|
34331
|
+
function up1462(db) {
|
|
34332
|
+
db.exec(`
|
|
34333
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
34334
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
34335
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
34336
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
34337
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
34338
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
34339
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
34340
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34341
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
34342
|
+
);
|
|
34343
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
34344
|
+
|
|
34345
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
34346
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
34347
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
34348
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
34349
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
34350
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
34351
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
34352
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34353
|
+
UNIQUE(job_id, ordinal)
|
|
34354
|
+
);
|
|
34355
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
34356
|
+
|
|
34357
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
34358
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
34359
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
34360
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
34361
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
34362
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
34363
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34364
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
34365
|
+
);
|
|
34366
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
34367
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
34368
|
+
|
|
34369
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
34370
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
34371
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
34372
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
34373
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
34374
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34375
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
34376
|
+
);
|
|
34377
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
34378
|
+
|
|
34379
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
34380
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
34381
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
34382
|
+
);
|
|
34383
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
34384
|
+
`);
|
|
34385
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
34386
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
34387
|
+
if (exists == null)
|
|
34388
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
34389
|
+
}
|
|
34390
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
34391
|
+
}
|
|
34392
|
+
function up1472(db) {
|
|
34393
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
34394
|
+
}
|
|
34395
|
+
function up1482(db) {
|
|
34396
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
34397
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
34398
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
34399
|
+
}
|
|
34400
|
+
}
|
|
34401
|
+
function up1492(db) {
|
|
34402
|
+
const addColumn = (table, column, definition) => {
|
|
34403
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
34404
|
+
if (exists == null)
|
|
34405
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
34406
|
+
};
|
|
34407
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
34408
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
34409
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
34410
|
+
}
|
|
34411
|
+
function addColumnIfMissing282(db, table, column, definition) {
|
|
34412
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
34413
|
+
if (!columns.some((row) => row.name === column))
|
|
34414
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
34415
|
+
}
|
|
34416
|
+
function up1502(db) {
|
|
34417
|
+
addColumnIfMissing282(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
34418
|
+
addColumnIfMissing282(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
34419
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
34420
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
34421
|
+
db.exec(`
|
|
34422
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
34423
|
+
AFTER INSERT ON dreaming_passes
|
|
34424
|
+
WHEN NEW.mode = 'incremental-content'
|
|
34425
|
+
BEGIN
|
|
34426
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
34427
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
34428
|
+
UPDATE dreaming_passes
|
|
34429
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
34430
|
+
WHERE id = NEW.id;
|
|
34431
|
+
END;
|
|
34432
|
+
|
|
34433
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
34434
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
34435
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
34436
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
34437
|
+
OR OLD.agent_id IS NOT NEW.agent_id OR OLD.visibility IS NOT NEW.visibility OR OLD.scope IS NOT NEW.scope OR OLD.memory_kind IS NOT NEW.memory_kind
|
|
34438
|
+
BEGIN
|
|
34439
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34440
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
34441
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
34442
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34443
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
34444
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
34445
|
+
END;
|
|
34446
|
+
|
|
34447
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
34448
|
+
AFTER DELETE ON memories
|
|
34449
|
+
BEGIN
|
|
34450
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34451
|
+
WHERE agent_id = OLD.agent_id
|
|
34452
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
34453
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34454
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
34455
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
34456
|
+
END;
|
|
34457
|
+
|
|
34458
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
34459
|
+
AFTER DELETE ON agents
|
|
34460
|
+
BEGIN
|
|
34461
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34462
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
34463
|
+
END;
|
|
34464
|
+
|
|
34465
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
34466
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
34467
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
34468
|
+
BEGIN
|
|
34469
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34470
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
34471
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34472
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
34473
|
+
END;
|
|
34474
|
+
`);
|
|
34475
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
34476
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
34477
|
+
if (!exists)
|
|
34478
|
+
continue;
|
|
34479
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
34480
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
34481
|
+
const contentChanged = table === "session_transcripts" ? "OLD.completed_at IS NOT NULL AND (OLD.content IS NOT NEW.content OR NEW.completed_at IS NULL)" : `OLD.content IS NOT NEW.content${hasIsDeleted ? " OR OLD.is_deleted IS NOT NEW.is_deleted" : ""}`;
|
|
34482
|
+
db.exec(`
|
|
34483
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
34484
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
34485
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
34486
|
+
BEGIN
|
|
34487
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34488
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34489
|
+
END;
|
|
34490
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
34491
|
+
AFTER DELETE ON ${table}
|
|
34492
|
+
BEGIN
|
|
34493
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34494
|
+
END;
|
|
34495
|
+
`);
|
|
34496
|
+
}
|
|
34497
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
34498
|
+
db.exec(`
|
|
34499
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
34500
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
34501
|
+
WHEN OLD.depth = 0 AND (OLD.content IS NOT NEW.content OR OLD.source_ref IS NOT NEW.source_ref OR OLD.source_type IS NOT NEW.source_type OR OLD.depth IS NOT NEW.depth OR OLD.agent_id IS NOT NEW.agent_id)
|
|
34502
|
+
BEGIN
|
|
34503
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34504
|
+
END;
|
|
34505
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
34506
|
+
AFTER DELETE ON session_summaries
|
|
34507
|
+
WHEN OLD.depth = 0
|
|
34508
|
+
BEGIN
|
|
34509
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34510
|
+
END;
|
|
34511
|
+
`);
|
|
34512
|
+
}
|
|
34513
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
34514
|
+
if (safetyExists) {
|
|
34515
|
+
db.exec(`
|
|
34516
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
34517
|
+
AFTER INSERT ON memory_content_safety
|
|
34518
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
34519
|
+
BEGIN
|
|
34520
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34521
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
34522
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
34523
|
+
END;
|
|
34524
|
+
|
|
34525
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
34526
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
34527
|
+
WHEN (OLD.context_eligible IS NOT NEW.context_eligible OR OLD.agent_id IS NOT NEW.agent_id OR OLD.status IS NOT NEW.status)
|
|
34528
|
+
AND (OLD.status IS NOT 'clean' OR NEW.status IS NOT 'clean' OR OLD.context_eligible IS NOT 1 OR NEW.context_eligible IS NOT 1)
|
|
34529
|
+
BEGIN
|
|
34530
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34531
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
34532
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34533
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
34534
|
+
END;
|
|
34535
|
+
`);
|
|
34536
|
+
}
|
|
34537
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
34538
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
34539
|
+
if (!exists)
|
|
34540
|
+
continue;
|
|
34541
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
34542
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
34543
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
34544
|
+
const lifecycleWhen = table === "imported_source_lifecycle" ? `(OLD.agent_id IS NOT NEW.agent_id OR OLD.status IS NOT NEW.status)${lifecycleUpdateClause}` : "OLD.agent_id IS NOT NEW.agent_id";
|
|
34545
|
+
db.exec(`
|
|
34546
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
34547
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
34548
|
+
BEGIN
|
|
34549
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
34550
|
+
END;
|
|
34551
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
34552
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
34553
|
+
WHEN ${lifecycleWhen}
|
|
34554
|
+
BEGIN
|
|
34555
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34556
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34557
|
+
END;
|
|
34558
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
34559
|
+
AFTER DELETE ON ${table}
|
|
34560
|
+
BEGIN
|
|
34561
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34562
|
+
END;
|
|
34563
|
+
`);
|
|
34564
|
+
}
|
|
34565
|
+
}
|
|
34042
34566
|
var MIGRATIONS2 = [
|
|
34043
34567
|
{
|
|
34044
34568
|
version: 1,
|
|
34045
34569
|
name: "baseline",
|
|
34046
|
-
up:
|
|
34570
|
+
up: up151,
|
|
34047
34571
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
34048
34572
|
},
|
|
34049
34573
|
{
|
|
@@ -34132,7 +34656,7 @@ var MIGRATIONS2 = [
|
|
|
34132
34656
|
{
|
|
34133
34657
|
version: 14,
|
|
34134
34658
|
name: "telemetry",
|
|
34135
|
-
up:
|
|
34659
|
+
up: up1410,
|
|
34136
34660
|
artifacts: { tables: ["telemetry_events"] }
|
|
34137
34661
|
},
|
|
34138
34662
|
{
|
|
@@ -35188,6 +35712,60 @@ var MIGRATIONS2 = [
|
|
|
35188
35712
|
name: "dreaming-evidence-reviews",
|
|
35189
35713
|
up: up1452,
|
|
35190
35714
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
35715
|
+
},
|
|
35716
|
+
{
|
|
35717
|
+
version: 146,
|
|
35718
|
+
name: "source-transcript-import",
|
|
35719
|
+
up: up1462,
|
|
35720
|
+
artifacts: {
|
|
35721
|
+
tables: [
|
|
35722
|
+
"source_import_jobs",
|
|
35723
|
+
"source_import_files",
|
|
35724
|
+
"source_import_records",
|
|
35725
|
+
"transcript_import_conversations",
|
|
35726
|
+
"source_import_record_attempts"
|
|
35727
|
+
],
|
|
35728
|
+
columns: [
|
|
35729
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
35730
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
35731
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
35732
|
+
]
|
|
35733
|
+
}
|
|
35734
|
+
},
|
|
35735
|
+
{
|
|
35736
|
+
version: 147,
|
|
35737
|
+
name: "source-import-replay-file-slots",
|
|
35738
|
+
up: up1472,
|
|
35739
|
+
artifacts: { tables: ["source_import_files"] }
|
|
35740
|
+
},
|
|
35741
|
+
{
|
|
35742
|
+
version: 148,
|
|
35743
|
+
name: "source-import-attempt-provenance",
|
|
35744
|
+
up: up1482,
|
|
35745
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
35746
|
+
},
|
|
35747
|
+
{
|
|
35748
|
+
version: 149,
|
|
35749
|
+
name: "transcript-import-state-machine",
|
|
35750
|
+
up: up1492,
|
|
35751
|
+
artifacts: {
|
|
35752
|
+
columns: [
|
|
35753
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
35754
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
35755
|
+
{ table: "source_import_files", column: "error" }
|
|
35756
|
+
]
|
|
35757
|
+
}
|
|
35758
|
+
},
|
|
35759
|
+
{
|
|
35760
|
+
version: 150,
|
|
35761
|
+
name: "memory-head-freshness",
|
|
35762
|
+
up: up1502,
|
|
35763
|
+
artifacts: {
|
|
35764
|
+
columns: [
|
|
35765
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
35766
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
35767
|
+
]
|
|
35768
|
+
}
|
|
35191
35769
|
}
|
|
35192
35770
|
];
|
|
35193
35771
|
var LATEST_SCHEMA_VERSION2 = MIGRATIONS2[MIGRATIONS2.length - 1]?.version ?? 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signetai/connector-codex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.217.3",
|
|
4
4
|
"description": "Signet connector for Codex CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"typecheck": "tsc --noEmit"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@signetai/connector-base": "0.
|
|
28
|
-
"@signetai/core": "0.
|
|
27
|
+
"@signetai/connector-base": "0.217.3",
|
|
28
|
+
"@signetai/core": "0.217.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.0.0",
|