@signetai/connector-forge 0.216.7 → 0.217.1
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
|
@@ -16179,6 +16179,241 @@ function up145(db) {
|
|
|
16179
16179
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
16180
16180
|
`);
|
|
16181
16181
|
}
|
|
16182
|
+
function up146(db) {
|
|
16183
|
+
db.exec(`
|
|
16184
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
16185
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
16186
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
16187
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
16188
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
16189
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
16190
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
16191
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16192
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
16193
|
+
);
|
|
16194
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
16195
|
+
|
|
16196
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
16197
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16198
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
16199
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
16200
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
16201
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
16202
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
16203
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16204
|
+
UNIQUE(job_id, ordinal)
|
|
16205
|
+
);
|
|
16206
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
16207
|
+
|
|
16208
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
16209
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
16210
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
16211
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
16212
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
16213
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
16214
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16215
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
16216
|
+
);
|
|
16217
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
16218
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
16219
|
+
|
|
16220
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
16221
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
16222
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
16223
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
16224
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
16225
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
16226
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
16227
|
+
);
|
|
16228
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
16229
|
+
|
|
16230
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
16231
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
16232
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
16233
|
+
);
|
|
16234
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
16235
|
+
`);
|
|
16236
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
16237
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
16238
|
+
if (exists == null)
|
|
16239
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
16240
|
+
}
|
|
16241
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
16242
|
+
}
|
|
16243
|
+
function up147(db) {
|
|
16244
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
16245
|
+
}
|
|
16246
|
+
function up148(db) {
|
|
16247
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
16248
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
16249
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
16250
|
+
}
|
|
16251
|
+
}
|
|
16252
|
+
function up149(db) {
|
|
16253
|
+
const addColumn = (table, column, definition) => {
|
|
16254
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
16255
|
+
if (exists == null)
|
|
16256
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16257
|
+
};
|
|
16258
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
16259
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
16260
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
16261
|
+
}
|
|
16262
|
+
function addColumnIfMissing28(db, table, column, definition) {
|
|
16263
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
16264
|
+
if (!columns.some((row) => row.name === column))
|
|
16265
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
16266
|
+
}
|
|
16267
|
+
function up150(db) {
|
|
16268
|
+
addColumnIfMissing28(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
16269
|
+
addColumnIfMissing28(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
16270
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
16271
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
16272
|
+
db.exec(`
|
|
16273
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
16274
|
+
AFTER INSERT ON dreaming_passes
|
|
16275
|
+
WHEN NEW.mode = 'incremental-content'
|
|
16276
|
+
BEGIN
|
|
16277
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
16278
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
16279
|
+
UPDATE dreaming_passes
|
|
16280
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
16281
|
+
WHERE id = NEW.id;
|
|
16282
|
+
END;
|
|
16283
|
+
|
|
16284
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
16285
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
16286
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
16287
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
16288
|
+
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
|
|
16289
|
+
BEGIN
|
|
16290
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16291
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
16292
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
16293
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16294
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16295
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
16296
|
+
END;
|
|
16297
|
+
|
|
16298
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
16299
|
+
AFTER DELETE ON memories
|
|
16300
|
+
BEGIN
|
|
16301
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16302
|
+
WHERE agent_id = OLD.agent_id
|
|
16303
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
16304
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16305
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
16306
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
16307
|
+
END;
|
|
16308
|
+
|
|
16309
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
16310
|
+
AFTER DELETE ON agents
|
|
16311
|
+
BEGIN
|
|
16312
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16313
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
16314
|
+
END;
|
|
16315
|
+
|
|
16316
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
16317
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
16318
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
16319
|
+
BEGIN
|
|
16320
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16321
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
16322
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16323
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
16324
|
+
END;
|
|
16325
|
+
`);
|
|
16326
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
16327
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16328
|
+
if (!exists)
|
|
16329
|
+
continue;
|
|
16330
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
16331
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
16332
|
+
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" : ""}`;
|
|
16333
|
+
db.exec(`
|
|
16334
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16335
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16336
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
16337
|
+
BEGIN
|
|
16338
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16339
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16340
|
+
END;
|
|
16341
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16342
|
+
AFTER DELETE ON ${table}
|
|
16343
|
+
BEGIN
|
|
16344
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16345
|
+
END;
|
|
16346
|
+
`);
|
|
16347
|
+
}
|
|
16348
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
16349
|
+
db.exec(`
|
|
16350
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
16351
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
16352
|
+
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)
|
|
16353
|
+
BEGIN
|
|
16354
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16355
|
+
END;
|
|
16356
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
16357
|
+
AFTER DELETE ON session_summaries
|
|
16358
|
+
WHEN OLD.depth = 0
|
|
16359
|
+
BEGIN
|
|
16360
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16361
|
+
END;
|
|
16362
|
+
`);
|
|
16363
|
+
}
|
|
16364
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
16365
|
+
if (safetyExists) {
|
|
16366
|
+
db.exec(`
|
|
16367
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
16368
|
+
AFTER INSERT ON memory_content_safety
|
|
16369
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
16370
|
+
BEGIN
|
|
16371
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16372
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
16373
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
16374
|
+
END;
|
|
16375
|
+
|
|
16376
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
16377
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
16378
|
+
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)
|
|
16379
|
+
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)
|
|
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
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
16384
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
16385
|
+
END;
|
|
16386
|
+
`);
|
|
16387
|
+
}
|
|
16388
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
16389
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
16390
|
+
if (!exists)
|
|
16391
|
+
continue;
|
|
16392
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
16393
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
16394
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
16395
|
+
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";
|
|
16396
|
+
db.exec(`
|
|
16397
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
16398
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
16399
|
+
BEGIN
|
|
16400
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
16401
|
+
END;
|
|
16402
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
16403
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
16404
|
+
WHEN ${lifecycleWhen}
|
|
16405
|
+
BEGIN
|
|
16406
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
16407
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
16408
|
+
END;
|
|
16409
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
16410
|
+
AFTER DELETE ON ${table}
|
|
16411
|
+
BEGIN
|
|
16412
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
16413
|
+
END;
|
|
16414
|
+
`);
|
|
16415
|
+
}
|
|
16416
|
+
}
|
|
16182
16417
|
var MIGRATIONS = [
|
|
16183
16418
|
{
|
|
16184
16419
|
version: 1,
|
|
@@ -17328,6 +17563,60 @@ var MIGRATIONS = [
|
|
|
17328
17563
|
name: "dreaming-evidence-reviews",
|
|
17329
17564
|
up: up145,
|
|
17330
17565
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
17566
|
+
},
|
|
17567
|
+
{
|
|
17568
|
+
version: 146,
|
|
17569
|
+
name: "source-transcript-import",
|
|
17570
|
+
up: up146,
|
|
17571
|
+
artifacts: {
|
|
17572
|
+
tables: [
|
|
17573
|
+
"source_import_jobs",
|
|
17574
|
+
"source_import_files",
|
|
17575
|
+
"source_import_records",
|
|
17576
|
+
"transcript_import_conversations",
|
|
17577
|
+
"source_import_record_attempts"
|
|
17578
|
+
],
|
|
17579
|
+
columns: [
|
|
17580
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
17581
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
17582
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
17583
|
+
]
|
|
17584
|
+
}
|
|
17585
|
+
},
|
|
17586
|
+
{
|
|
17587
|
+
version: 147,
|
|
17588
|
+
name: "source-import-replay-file-slots",
|
|
17589
|
+
up: up147,
|
|
17590
|
+
artifacts: { tables: ["source_import_files"] }
|
|
17591
|
+
},
|
|
17592
|
+
{
|
|
17593
|
+
version: 148,
|
|
17594
|
+
name: "source-import-attempt-provenance",
|
|
17595
|
+
up: up148,
|
|
17596
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
17597
|
+
},
|
|
17598
|
+
{
|
|
17599
|
+
version: 149,
|
|
17600
|
+
name: "transcript-import-state-machine",
|
|
17601
|
+
up: up149,
|
|
17602
|
+
artifacts: {
|
|
17603
|
+
columns: [
|
|
17604
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
17605
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
17606
|
+
{ table: "source_import_files", column: "error" }
|
|
17607
|
+
]
|
|
17608
|
+
}
|
|
17609
|
+
},
|
|
17610
|
+
{
|
|
17611
|
+
version: 150,
|
|
17612
|
+
name: "memory-head-freshness",
|
|
17613
|
+
up: up150,
|
|
17614
|
+
artifacts: {
|
|
17615
|
+
columns: [
|
|
17616
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
17617
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
17618
|
+
]
|
|
17619
|
+
}
|
|
17331
17620
|
}
|
|
17332
17621
|
];
|
|
17333
17622
|
var LATEST_SCHEMA_VERSION = MIGRATIONS[MIGRATIONS.length - 1]?.version ?? 0;
|
|
@@ -29432,7 +29721,7 @@ function memoriesFtsNeedsTokenizerRepair2(sql) {
|
|
|
29432
29721
|
return true;
|
|
29433
29722
|
return !normalized.includes(`tokenize='${MEMORIES_FTS_TOKENIZER2}'`);
|
|
29434
29723
|
}
|
|
29435
|
-
function
|
|
29724
|
+
function up151(db) {
|
|
29436
29725
|
db.exec(`
|
|
29437
29726
|
CREATE TABLE IF NOT EXISTS schema_migrations (
|
|
29438
29727
|
version INTEGER PRIMARY KEY,
|
|
@@ -29525,27 +29814,27 @@ function hasColumn26(db, table, column) {
|
|
|
29525
29814
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29526
29815
|
return rows.some((r3) => r3.name === column);
|
|
29527
29816
|
}
|
|
29528
|
-
function
|
|
29817
|
+
function addColumnIfMissing29(db, table, column, definition) {
|
|
29529
29818
|
if (!hasColumn26(db, table, column)) {
|
|
29530
29819
|
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
29531
29820
|
}
|
|
29532
29821
|
}
|
|
29533
29822
|
function up210(db) {
|
|
29534
|
-
|
|
29535
|
-
|
|
29536
|
-
|
|
29537
|
-
|
|
29538
|
-
|
|
29539
|
-
|
|
29540
|
-
|
|
29541
|
-
|
|
29542
|
-
|
|
29543
|
-
|
|
29544
|
-
|
|
29545
|
-
|
|
29546
|
-
|
|
29547
|
-
|
|
29548
|
-
|
|
29823
|
+
addColumnIfMissing29(db, "memories", "content_hash", "TEXT");
|
|
29824
|
+
addColumnIfMissing29(db, "memories", "normalized_content", "TEXT");
|
|
29825
|
+
addColumnIfMissing29(db, "memories", "is_deleted", "INTEGER DEFAULT 0");
|
|
29826
|
+
addColumnIfMissing29(db, "memories", "deleted_at", "TEXT");
|
|
29827
|
+
addColumnIfMissing29(db, "memories", "extraction_status", "TEXT DEFAULT 'none'");
|
|
29828
|
+
addColumnIfMissing29(db, "memories", "embedding_model", "TEXT");
|
|
29829
|
+
addColumnIfMissing29(db, "memories", "extraction_model", "TEXT");
|
|
29830
|
+
addColumnIfMissing29(db, "memories", "update_count", "INTEGER DEFAULT 0");
|
|
29831
|
+
addColumnIfMissing29(db, "memories", "who", "TEXT");
|
|
29832
|
+
addColumnIfMissing29(db, "memories", "why", "TEXT");
|
|
29833
|
+
addColumnIfMissing29(db, "memories", "project", "TEXT");
|
|
29834
|
+
addColumnIfMissing29(db, "memories", "pinned", "INTEGER DEFAULT 0");
|
|
29835
|
+
addColumnIfMissing29(db, "memories", "importance", "REAL DEFAULT 0.5");
|
|
29836
|
+
addColumnIfMissing29(db, "memories", "last_accessed", "TEXT");
|
|
29837
|
+
addColumnIfMissing29(db, "memories", "access_count", "INTEGER DEFAULT 0");
|
|
29549
29838
|
db.exec(`
|
|
29550
29839
|
CREATE TABLE IF NOT EXISTS memory_history (
|
|
29551
29840
|
id TEXT PRIMARY KEY,
|
|
@@ -29641,7 +29930,7 @@ function up210(db) {
|
|
|
29641
29930
|
ON memory_entity_mentions(entity_id);
|
|
29642
29931
|
`);
|
|
29643
29932
|
}
|
|
29644
|
-
function
|
|
29933
|
+
function addColumnIfMissing210(db, table, column, definition) {
|
|
29645
29934
|
const rows = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
29646
29935
|
if (rows.some((r3) => r3.name === column))
|
|
29647
29936
|
return false;
|
|
@@ -29649,8 +29938,8 @@ function addColumnIfMissing29(db, table, column, definition) {
|
|
|
29649
29938
|
return true;
|
|
29650
29939
|
}
|
|
29651
29940
|
function up310(db) {
|
|
29652
|
-
|
|
29653
|
-
|
|
29941
|
+
addColumnIfMissing210(db, "memories", "why", "TEXT");
|
|
29942
|
+
addColumnIfMissing210(db, "memories", "project", "TEXT");
|
|
29654
29943
|
db.exec(`DROP INDEX IF EXISTS idx_memories_content_hash`);
|
|
29655
29944
|
db.exec(`
|
|
29656
29945
|
UPDATE memories
|
|
@@ -29942,7 +30231,7 @@ function up1310(db) {
|
|
|
29942
30231
|
addColumnIfMissing52(db, "memories", "source_path", "TEXT");
|
|
29943
30232
|
addColumnIfMissing52(db, "memories", "source_section", "TEXT");
|
|
29944
30233
|
}
|
|
29945
|
-
function
|
|
30234
|
+
function up1410(db) {
|
|
29946
30235
|
db.exec(`
|
|
29947
30236
|
CREATE TABLE IF NOT EXISTS telemetry_events (
|
|
29948
30237
|
id TEXT PRIMARY KEY,
|
|
@@ -34205,11 +34494,246 @@ function up1452(db) {
|
|
|
34205
34494
|
ON dreaming_evidence_reviews (agent_id, reviewed_at DESC);
|
|
34206
34495
|
`);
|
|
34207
34496
|
}
|
|
34497
|
+
function up1462(db) {
|
|
34498
|
+
db.exec(`
|
|
34499
|
+
CREATE TABLE IF NOT EXISTS source_import_jobs (
|
|
34500
|
+
id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind = 'import'), agent_id TEXT NOT NULL,
|
|
34501
|
+
schema_id TEXT NOT NULL, adapter_version INTEGER NOT NULL CHECK (adapter_version = 1),
|
|
34502
|
+
state TEXT NOT NULL CHECK (state IN ('staging','inventorying','queued','running','paused','completed','completed_with_rejections','cancelled','failed')),
|
|
34503
|
+
control_request TEXT CHECK (control_request IN ('pause','resume','retry','cancel') OR control_request IS NULL),
|
|
34504
|
+
generation INTEGER NOT NULL DEFAULT 0, total INTEGER NOT NULL DEFAULT 0, imported INTEGER NOT NULL DEFAULT 0,
|
|
34505
|
+
duplicate INTEGER NOT NULL DEFAULT 0, rejected INTEGER NOT NULL DEFAULT 0, pending INTEGER NOT NULL DEFAULT 0,
|
|
34506
|
+
lease_token TEXT, lease_expires_at TEXT, error TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34507
|
+
updated_at TEXT NOT NULL DEFAULT (datetime('now')), started_at TEXT, completed_at TEXT, reconciled_at TEXT
|
|
34508
|
+
);
|
|
34509
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_jobs_agent_state ON source_import_jobs(agent_id, state);
|
|
34510
|
+
|
|
34511
|
+
CREATE TABLE IF NOT EXISTS source_import_files (
|
|
34512
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
34513
|
+
source_id TEXT NOT NULL, agent_id TEXT NOT NULL, ordinal INTEGER NOT NULL, name TEXT NOT NULL,
|
|
34514
|
+
managed_path TEXT NOT NULL, size_bytes INTEGER NOT NULL DEFAULT 0, content_hash TEXT,
|
|
34515
|
+
state TEXT NOT NULL CHECK (state IN ('staging','ready','inventorying','completed','failed')),
|
|
34516
|
+
record_count INTEGER NOT NULL DEFAULT 0, blank_count INTEGER NOT NULL DEFAULT 0, malformed_count INTEGER NOT NULL DEFAULT 0,
|
|
34517
|
+
inventory_version INTEGER NOT NULL DEFAULT 1, checkpoint_ordinal INTEGER NOT NULL DEFAULT 0,
|
|
34518
|
+
checkpoint_byte_offset INTEGER NOT NULL DEFAULT 0, created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34519
|
+
UNIQUE(job_id, ordinal)
|
|
34520
|
+
);
|
|
34521
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state);
|
|
34522
|
+
|
|
34523
|
+
CREATE TABLE IF NOT EXISTS source_import_records (
|
|
34524
|
+
id TEXT PRIMARY KEY, job_id TEXT NOT NULL REFERENCES source_import_jobs(id) ON DELETE CASCADE,
|
|
34525
|
+
file_id TEXT NOT NULL REFERENCES source_import_files(id) ON DELETE CASCADE, source_id TEXT NOT NULL, agent_id TEXT NOT NULL,
|
|
34526
|
+
ordinal INTEGER NOT NULL, line_number INTEGER NOT NULL, byte_offset INTEGER NOT NULL, byte_length INTEGER NOT NULL,
|
|
34527
|
+
raw_hash TEXT NOT NULL, external_identity TEXT, conversation_fingerprint TEXT, status TEXT NOT NULL CHECK (status IN ('pending','imported','duplicate','rejected','cancelled')),
|
|
34528
|
+
canonical_id TEXT, canonical_key TEXT, rejection_code TEXT, attempt_count INTEGER NOT NULL DEFAULT 0,
|
|
34529
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34530
|
+
UNIQUE(file_id, ordinal), UNIQUE(file_id, byte_offset)
|
|
34531
|
+
);
|
|
34532
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_job_status ON source_import_records(job_id, status);
|
|
34533
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_records_source_status ON source_import_records(agent_id, source_id, status);
|
|
34534
|
+
|
|
34535
|
+
CREATE TABLE IF NOT EXISTS transcript_import_conversations (
|
|
34536
|
+
agent_id TEXT NOT NULL, external_identity TEXT NOT NULL, canonical_key TEXT NOT NULL,
|
|
34537
|
+
conversation_fingerprint TEXT NOT NULL, canonical_id TEXT NOT NULL, owner_source_id TEXT NOT NULL,
|
|
34538
|
+
owner_record_id TEXT NOT NULL, state TEXT NOT NULL CHECK (state IN ('committing','committed','removed')),
|
|
34539
|
+
content_hash TEXT NOT NULL, harness TEXT NOT NULL, timestamp TEXT NOT NULL,
|
|
34540
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now')), updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
34541
|
+
PRIMARY KEY (agent_id, external_identity), UNIQUE(agent_id, canonical_key)
|
|
34542
|
+
);
|
|
34543
|
+
CREATE INDEX IF NOT EXISTS idx_transcript_import_conversations_source ON transcript_import_conversations(agent_id, owner_source_id);
|
|
34544
|
+
|
|
34545
|
+
CREATE TABLE IF NOT EXISTS source_import_record_attempts (
|
|
34546
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT, agent_id TEXT NOT NULL, job_id TEXT NOT NULL, file_id TEXT NOT NULL,
|
|
34547
|
+
record_id TEXT NOT NULL, generation INTEGER NOT NULL, outcome TEXT NOT NULL, error_code TEXT, created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
34548
|
+
);
|
|
34549
|
+
CREATE INDEX IF NOT EXISTS idx_source_import_attempts_record ON source_import_record_attempts(agent_id, record_id, created_at);
|
|
34550
|
+
`);
|
|
34551
|
+
for (const column of ["source_id", "source_record_id", "source_meta_json"]) {
|
|
34552
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info('session_transcripts') WHERE name = ?").get(column);
|
|
34553
|
+
if (exists == null)
|
|
34554
|
+
db.exec(`ALTER TABLE session_transcripts ADD COLUMN ${column} TEXT`);
|
|
34555
|
+
}
|
|
34556
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_session_transcripts_agent_source ON session_transcripts(agent_id, source_id)");
|
|
34557
|
+
}
|
|
34558
|
+
function up1472(db) {
|
|
34559
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_source_import_files_job_state ON source_import_files(job_id, state)");
|
|
34560
|
+
}
|
|
34561
|
+
function up1482(db) {
|
|
34562
|
+
const columns = db.prepare("PRAGMA table_info(source_import_record_attempts)").all();
|
|
34563
|
+
if (!columns.some((column) => column.name === "source_id")) {
|
|
34564
|
+
db.exec("ALTER TABLE source_import_record_attempts ADD COLUMN source_id TEXT");
|
|
34565
|
+
}
|
|
34566
|
+
}
|
|
34567
|
+
function up1492(db) {
|
|
34568
|
+
const addColumn = (table, column, definition) => {
|
|
34569
|
+
const exists = db.prepare("SELECT 1 AS found FROM pragma_table_info(?) WHERE name = ?").get(table, column);
|
|
34570
|
+
if (exists == null)
|
|
34571
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
34572
|
+
};
|
|
34573
|
+
addColumn("source_import_jobs", "duplicate_mode", "TEXT NOT NULL DEFAULT 'skip' CHECK (duplicate_mode IN ('skip','replace','reimport'))");
|
|
34574
|
+
addColumn("source_import_jobs", "next_attempt_at", "TEXT");
|
|
34575
|
+
addColumn("source_import_files", "error", "TEXT");
|
|
34576
|
+
}
|
|
34577
|
+
function addColumnIfMissing282(db, table, column, definition) {
|
|
34578
|
+
const columns = db.prepare(`PRAGMA table_info(${table})`).all();
|
|
34579
|
+
if (!columns.some((row) => row.name === column))
|
|
34580
|
+
db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${definition}`);
|
|
34581
|
+
}
|
|
34582
|
+
function up1502(db) {
|
|
34583
|
+
addColumnIfMissing282(db, "memory_md_heads", "is_current", "INTEGER NOT NULL DEFAULT 0");
|
|
34584
|
+
addColumnIfMissing282(db, "dreaming_passes", "head_base_revision", "INTEGER");
|
|
34585
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_head_revisions_content_hash ON memory_head_revisions(content_hash)");
|
|
34586
|
+
db.exec("CREATE INDEX IF NOT EXISTS idx_memory_md_heads_content_hash ON memory_md_heads(content_hash)");
|
|
34587
|
+
db.exec(`
|
|
34588
|
+
CREATE TRIGGER IF NOT EXISTS dreaming_passes_head_fence_ai
|
|
34589
|
+
AFTER INSERT ON dreaming_passes
|
|
34590
|
+
WHEN NEW.mode = 'incremental-content'
|
|
34591
|
+
BEGIN
|
|
34592
|
+
INSERT OR IGNORE INTO memory_md_heads (agent_id, content, content_hash, revision, updated_at, is_current)
|
|
34593
|
+
VALUES (NEW.agent_id, '', '', 0, datetime('now'), 0);
|
|
34594
|
+
UPDATE dreaming_passes
|
|
34595
|
+
SET head_base_revision = (SELECT revision FROM memory_md_heads WHERE agent_id = NEW.agent_id)
|
|
34596
|
+
WHERE id = NEW.id;
|
|
34597
|
+
END;
|
|
34598
|
+
|
|
34599
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_au
|
|
34600
|
+
AFTER UPDATE OF content, superseded_by, stale_at, is_deleted, agent_id, visibility, scope, memory_kind ON memories
|
|
34601
|
+
WHEN OLD.content IS NOT NEW.content OR OLD.superseded_by IS NOT NEW.superseded_by
|
|
34602
|
+
OR OLD.stale_at IS NOT NEW.stale_at OR OLD.is_deleted IS NOT NEW.is_deleted
|
|
34603
|
+
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
|
|
34604
|
+
BEGIN
|
|
34605
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34606
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
34607
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global' OR COALESCE(NEW.visibility, 'global') = 'global')
|
|
34608
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34609
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
34610
|
+
(SELECT policy_group FROM agents WHERE id IN (OLD.agent_id, NEW.agent_id))));
|
|
34611
|
+
END;
|
|
34612
|
+
|
|
34613
|
+
CREATE TRIGGER IF NOT EXISTS memories_head_freshness_ad
|
|
34614
|
+
AFTER DELETE ON memories
|
|
34615
|
+
BEGIN
|
|
34616
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34617
|
+
WHERE agent_id = OLD.agent_id
|
|
34618
|
+
OR (COALESCE(OLD.visibility, 'global') = 'global'
|
|
34619
|
+
AND (agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34620
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN
|
|
34621
|
+
(SELECT policy_group FROM agents WHERE id = OLD.agent_id))));
|
|
34622
|
+
END;
|
|
34623
|
+
|
|
34624
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_ad
|
|
34625
|
+
AFTER DELETE ON agents
|
|
34626
|
+
BEGIN
|
|
34627
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34628
|
+
WHERE agent_id = OLD.id OR agent_id IN (SELECT id FROM agents WHERE read_policy='group' AND policy_group=OLD.policy_group);
|
|
34629
|
+
END;
|
|
34630
|
+
|
|
34631
|
+
CREATE TRIGGER IF NOT EXISTS agents_head_freshness_au
|
|
34632
|
+
AFTER UPDATE OF read_policy, policy_group ON agents
|
|
34633
|
+
WHEN OLD.read_policy IS NOT NEW.read_policy OR OLD.policy_group IS NOT NEW.policy_group
|
|
34634
|
+
BEGIN
|
|
34635
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34636
|
+
WHERE agent_id IN (OLD.id, NEW.id)
|
|
34637
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34638
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group' AND policy_group IN (OLD.policy_group, NEW.policy_group));
|
|
34639
|
+
END;
|
|
34640
|
+
`);
|
|
34641
|
+
for (const table of ["memory_artifacts", "session_transcripts"]) {
|
|
34642
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
34643
|
+
if (!exists)
|
|
34644
|
+
continue;
|
|
34645
|
+
const hasIsDeleted = db.prepare(`PRAGMA table_info(${table})`).all().some((row) => row.name === "is_deleted");
|
|
34646
|
+
const updateColumns = table === "session_transcripts" ? "content, agent_id, completed_at" : hasIsDeleted ? "content, agent_id, is_deleted" : "content, agent_id";
|
|
34647
|
+
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" : ""}`;
|
|
34648
|
+
db.exec(`
|
|
34649
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
34650
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
34651
|
+
WHEN OLD.agent_id IS NOT NEW.agent_id OR ${contentChanged}
|
|
34652
|
+
BEGIN
|
|
34653
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34654
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34655
|
+
END;
|
|
34656
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
34657
|
+
AFTER DELETE ON ${table}
|
|
34658
|
+
BEGIN
|
|
34659
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34660
|
+
END;
|
|
34661
|
+
`);
|
|
34662
|
+
}
|
|
34663
|
+
if (db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='session_summaries'").get()) {
|
|
34664
|
+
db.exec(`
|
|
34665
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_au
|
|
34666
|
+
AFTER UPDATE OF content, source_ref, source_type, depth, agent_id ON session_summaries
|
|
34667
|
+
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)
|
|
34668
|
+
BEGIN
|
|
34669
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34670
|
+
END;
|
|
34671
|
+
CREATE TRIGGER IF NOT EXISTS session_summaries_head_freshness_ad
|
|
34672
|
+
AFTER DELETE ON session_summaries
|
|
34673
|
+
WHEN OLD.depth = 0
|
|
34674
|
+
BEGIN
|
|
34675
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34676
|
+
END;
|
|
34677
|
+
`);
|
|
34678
|
+
}
|
|
34679
|
+
const safetyExists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='memory_content_safety'").get();
|
|
34680
|
+
if (safetyExists) {
|
|
34681
|
+
db.exec(`
|
|
34682
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_ai
|
|
34683
|
+
AFTER INSERT ON memory_content_safety
|
|
34684
|
+
WHEN NEW.status IS NOT 'clean' OR NEW.context_eligible IS NOT 1
|
|
34685
|
+
BEGIN
|
|
34686
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34687
|
+
WHERE agent_id IN (NEW.agent_id)
|
|
34688
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy IN ('shared', 'group'));
|
|
34689
|
+
END;
|
|
34690
|
+
|
|
34691
|
+
CREATE TRIGGER IF NOT EXISTS memory_content_safety_head_freshness_au
|
|
34692
|
+
AFTER UPDATE OF context_eligible, agent_id, status ON memory_content_safety
|
|
34693
|
+
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)
|
|
34694
|
+
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)
|
|
34695
|
+
BEGIN
|
|
34696
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34697
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id)
|
|
34698
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'shared')
|
|
34699
|
+
OR agent_id IN (SELECT id FROM agents WHERE read_policy = 'group');
|
|
34700
|
+
END;
|
|
34701
|
+
`);
|
|
34702
|
+
}
|
|
34703
|
+
for (const table of ["memory_artifact_tombstones", "imported_source_lifecycle"]) {
|
|
34704
|
+
const exists = db.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name=?").get(table);
|
|
34705
|
+
if (!exists)
|
|
34706
|
+
continue;
|
|
34707
|
+
const lifecycleClause = table === "imported_source_lifecycle" ? " WHEN NEW.status = 'unsupported'" : "";
|
|
34708
|
+
const updateColumns = table === "imported_source_lifecycle" ? "agent_id, status" : "agent_id";
|
|
34709
|
+
const lifecycleUpdateClause = table === "imported_source_lifecycle" ? " AND NEW.status = 'unsupported'" : "";
|
|
34710
|
+
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";
|
|
34711
|
+
db.exec(`
|
|
34712
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ai
|
|
34713
|
+
AFTER INSERT ON ${table}${lifecycleClause}
|
|
34714
|
+
BEGIN
|
|
34715
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = NEW.agent_id;
|
|
34716
|
+
END;
|
|
34717
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_au
|
|
34718
|
+
AFTER UPDATE OF ${updateColumns} ON ${table}
|
|
34719
|
+
WHEN ${lifecycleWhen}
|
|
34720
|
+
BEGIN
|
|
34721
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0
|
|
34722
|
+
WHERE agent_id IN (OLD.agent_id, NEW.agent_id);
|
|
34723
|
+
END;
|
|
34724
|
+
CREATE TRIGGER IF NOT EXISTS ${table}_head_freshness_ad
|
|
34725
|
+
AFTER DELETE ON ${table}
|
|
34726
|
+
BEGIN
|
|
34727
|
+
UPDATE memory_md_heads SET revision = revision + 1, is_current = 0 WHERE agent_id = OLD.agent_id;
|
|
34728
|
+
END;
|
|
34729
|
+
`);
|
|
34730
|
+
}
|
|
34731
|
+
}
|
|
34208
34732
|
var MIGRATIONS2 = [
|
|
34209
34733
|
{
|
|
34210
34734
|
version: 1,
|
|
34211
34735
|
name: "baseline",
|
|
34212
|
-
up:
|
|
34736
|
+
up: up151,
|
|
34213
34737
|
artifacts: { tables: ["memories", "conversations", "embeddings"] }
|
|
34214
34738
|
},
|
|
34215
34739
|
{
|
|
@@ -34298,7 +34822,7 @@ var MIGRATIONS2 = [
|
|
|
34298
34822
|
{
|
|
34299
34823
|
version: 14,
|
|
34300
34824
|
name: "telemetry",
|
|
34301
|
-
up:
|
|
34825
|
+
up: up1410,
|
|
34302
34826
|
artifacts: { tables: ["telemetry_events"] }
|
|
34303
34827
|
},
|
|
34304
34828
|
{
|
|
@@ -35354,6 +35878,60 @@ var MIGRATIONS2 = [
|
|
|
35354
35878
|
name: "dreaming-evidence-reviews",
|
|
35355
35879
|
up: up1452,
|
|
35356
35880
|
artifacts: { tables: ["dreaming_evidence_reviews"] }
|
|
35881
|
+
},
|
|
35882
|
+
{
|
|
35883
|
+
version: 146,
|
|
35884
|
+
name: "source-transcript-import",
|
|
35885
|
+
up: up1462,
|
|
35886
|
+
artifacts: {
|
|
35887
|
+
tables: [
|
|
35888
|
+
"source_import_jobs",
|
|
35889
|
+
"source_import_files",
|
|
35890
|
+
"source_import_records",
|
|
35891
|
+
"transcript_import_conversations",
|
|
35892
|
+
"source_import_record_attempts"
|
|
35893
|
+
],
|
|
35894
|
+
columns: [
|
|
35895
|
+
{ table: "session_transcripts", column: "source_id" },
|
|
35896
|
+
{ table: "session_transcripts", column: "source_record_id" },
|
|
35897
|
+
{ table: "session_transcripts", column: "source_meta_json" }
|
|
35898
|
+
]
|
|
35899
|
+
}
|
|
35900
|
+
},
|
|
35901
|
+
{
|
|
35902
|
+
version: 147,
|
|
35903
|
+
name: "source-import-replay-file-slots",
|
|
35904
|
+
up: up1472,
|
|
35905
|
+
artifacts: { tables: ["source_import_files"] }
|
|
35906
|
+
},
|
|
35907
|
+
{
|
|
35908
|
+
version: 148,
|
|
35909
|
+
name: "source-import-attempt-provenance",
|
|
35910
|
+
up: up1482,
|
|
35911
|
+
artifacts: { columns: [{ table: "source_import_record_attempts", column: "source_id" }] }
|
|
35912
|
+
},
|
|
35913
|
+
{
|
|
35914
|
+
version: 149,
|
|
35915
|
+
name: "transcript-import-state-machine",
|
|
35916
|
+
up: up1492,
|
|
35917
|
+
artifacts: {
|
|
35918
|
+
columns: [
|
|
35919
|
+
{ table: "source_import_jobs", column: "duplicate_mode" },
|
|
35920
|
+
{ table: "source_import_jobs", column: "next_attempt_at" },
|
|
35921
|
+
{ table: "source_import_files", column: "error" }
|
|
35922
|
+
]
|
|
35923
|
+
}
|
|
35924
|
+
},
|
|
35925
|
+
{
|
|
35926
|
+
version: 150,
|
|
35927
|
+
name: "memory-head-freshness",
|
|
35928
|
+
up: up1502,
|
|
35929
|
+
artifacts: {
|
|
35930
|
+
columns: [
|
|
35931
|
+
{ table: "memory_md_heads", column: "is_current" },
|
|
35932
|
+
{ table: "dreaming_passes", column: "head_base_revision" }
|
|
35933
|
+
]
|
|
35934
|
+
}
|
|
35357
35935
|
}
|
|
35358
35936
|
];
|
|
35359
35937
|
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-forge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.217.1",
|
|
4
4
|
"description": "Signet connector for ForgeCode - installs MCP, identity, and skills integration",
|
|
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.1",
|
|
28
|
+
"@signetai/core": "0.217.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.0.0",
|