@cortexkit/pi-magic-context 0.42.1 → 0.42.2
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-pknkkpnp.js → index-6zjn0r2z.js} +827 -27
- package/dist/index.js +417 -142
- package/dist/subagent-entry.js +1 -1
- package/package.json +2 -2
|
@@ -10169,6 +10169,7 @@ function logSlowWriteTransaction(site, startedAt, thresholdMs = SLOW_WRITE_TRANS
|
|
|
10169
10169
|
|
|
10170
10170
|
// ../plugin/src/features/magic-context/context-authority.ts
|
|
10171
10171
|
import { createHash as createHash3, randomUUID } from "node:crypto";
|
|
10172
|
+
var AUTHORITY_DOMAINS = ["memories", "notes"];
|
|
10172
10173
|
var observedAuthorityRoutingByProject = new Map;
|
|
10173
10174
|
var moduleNoteEvaluationBridges = new Map;
|
|
10174
10175
|
function getModuleNoteEvaluationBridge(projectPath) {
|
|
@@ -10190,7 +10191,788 @@ function ensureContextStoreUuid(db) {
|
|
|
10190
10191
|
});
|
|
10191
10192
|
return getContextStoreUuid(db) ?? minted;
|
|
10192
10193
|
}
|
|
10194
|
+
function bumpDomainMutationEpoch(db, projectPath, domain) {
|
|
10195
|
+
db.prepare(`INSERT INTO domain_mutation_epoch(project_path, domain, epoch) VALUES (?, ?, 1)
|
|
10196
|
+
ON CONFLICT(project_path, domain) DO UPDATE SET epoch = epoch + 1`).run(projectPath, domain);
|
|
10197
|
+
}
|
|
10193
10198
|
var MAX_AUTHORITY_SEED_FRAME_BYTES = 900 * 1024;
|
|
10199
|
+
function getMirrorCursor(db, domain) {
|
|
10200
|
+
const row = db.prepare("SELECT cursor FROM mirror_cursors WHERE domain = ?").get(domain);
|
|
10201
|
+
return typeof row?.cursor === "number" ? row.cursor : 0;
|
|
10202
|
+
}
|
|
10203
|
+
function rowNumber(row, key, fallback = 0) {
|
|
10204
|
+
const value = row[key];
|
|
10205
|
+
return typeof value === "number" && Number.isFinite(value) ? value : fallback;
|
|
10206
|
+
}
|
|
10207
|
+
function rowString(row, key, fallback = "") {
|
|
10208
|
+
const value = row[key];
|
|
10209
|
+
return typeof value === "string" ? value : fallback;
|
|
10210
|
+
}
|
|
10211
|
+
function rowNullableString(row, key) {
|
|
10212
|
+
const value = row[key];
|
|
10213
|
+
return typeof value === "string" ? value : null;
|
|
10214
|
+
}
|
|
10215
|
+
var MEMORY_SNAPSHOT_COLUMNS = [
|
|
10216
|
+
"id",
|
|
10217
|
+
"project_path",
|
|
10218
|
+
"category",
|
|
10219
|
+
"content",
|
|
10220
|
+
"normalized_hash",
|
|
10221
|
+
"importance",
|
|
10222
|
+
"scope",
|
|
10223
|
+
"shareable",
|
|
10224
|
+
"source_session_id",
|
|
10225
|
+
"source_type",
|
|
10226
|
+
"seen_count",
|
|
10227
|
+
"retrieval_count",
|
|
10228
|
+
"first_seen_at",
|
|
10229
|
+
"created_at",
|
|
10230
|
+
"updated_at",
|
|
10231
|
+
"last_seen_at",
|
|
10232
|
+
"last_retrieved_at",
|
|
10233
|
+
"status",
|
|
10234
|
+
"expires_at",
|
|
10235
|
+
"verification_status",
|
|
10236
|
+
"verified_at",
|
|
10237
|
+
"classified_at",
|
|
10238
|
+
"superseded_by_memory_id",
|
|
10239
|
+
"merged_from",
|
|
10240
|
+
"metadata_json",
|
|
10241
|
+
"context_store_uuid",
|
|
10242
|
+
"context_row_id",
|
|
10243
|
+
"mural_cue",
|
|
10244
|
+
"mural_cue_hash",
|
|
10245
|
+
"mural_cue_at",
|
|
10246
|
+
"mural_cue_rejection_count"
|
|
10247
|
+
];
|
|
10248
|
+
var IMMUTABLE_MEMORY_SNAPSHOT_COLUMNS = ["project_path", "first_seen_at", "created_at"];
|
|
10249
|
+
var CLASSIFICATION_MEMORY_SNAPSHOT_COLUMNS = [
|
|
10250
|
+
"importance",
|
|
10251
|
+
"scope",
|
|
10252
|
+
"shareable",
|
|
10253
|
+
"source_type",
|
|
10254
|
+
"classified_at"
|
|
10255
|
+
];
|
|
10256
|
+
var VERIFICATION_MEMORY_SNAPSHOT_COLUMNS = [
|
|
10257
|
+
"verification_status",
|
|
10258
|
+
"verified_at",
|
|
10259
|
+
"mapping",
|
|
10260
|
+
"mapping_origin"
|
|
10261
|
+
];
|
|
10262
|
+
var MURAL_MEMORY_SNAPSHOT_COLUMNS = [
|
|
10263
|
+
"mural_cue",
|
|
10264
|
+
"mural_cue_hash",
|
|
10265
|
+
"mural_cue_at",
|
|
10266
|
+
"mural_cue_rejection_count"
|
|
10267
|
+
];
|
|
10268
|
+
var UPDATED_MEMORY_SNAPSHOT_COLUMNS = [
|
|
10269
|
+
"category",
|
|
10270
|
+
"content",
|
|
10271
|
+
"normalized_hash",
|
|
10272
|
+
"source_session_id",
|
|
10273
|
+
"seen_count",
|
|
10274
|
+
"retrieval_count",
|
|
10275
|
+
"updated_at",
|
|
10276
|
+
"last_seen_at",
|
|
10277
|
+
"last_retrieved_at",
|
|
10278
|
+
"status",
|
|
10279
|
+
"expires_at",
|
|
10280
|
+
"superseded_by_memory_id",
|
|
10281
|
+
"merged_from",
|
|
10282
|
+
"metadata_json"
|
|
10283
|
+
];
|
|
10284
|
+
function memorySnapshotTimestamp(row, key) {
|
|
10285
|
+
const value = row[key];
|
|
10286
|
+
return typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
10287
|
+
}
|
|
10288
|
+
function parsedMemorySnapshot(snapshotJson, fallback) {
|
|
10289
|
+
try {
|
|
10290
|
+
const parsed = JSON.parse(snapshotJson);
|
|
10291
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : fallback;
|
|
10292
|
+
} catch {
|
|
10293
|
+
return fallback;
|
|
10294
|
+
}
|
|
10295
|
+
}
|
|
10296
|
+
function guardMemorySnapshotByRecency(args) {
|
|
10297
|
+
const effectiveRow = { ...args.row };
|
|
10298
|
+
if (!args.existing) {
|
|
10299
|
+
return { effectiveRow, hostUpdatedNewer: false, hostVerificationNewer: false };
|
|
10300
|
+
}
|
|
10301
|
+
const existing = args.existing;
|
|
10302
|
+
const preserve = (columns) => {
|
|
10303
|
+
for (const column of columns) {
|
|
10304
|
+
if (Object.hasOwn(existing, column)) {
|
|
10305
|
+
effectiveRow[column] = existing[column];
|
|
10306
|
+
}
|
|
10307
|
+
}
|
|
10308
|
+
};
|
|
10309
|
+
preserve(IMMUTABLE_MEMORY_SNAPSHOT_COLUMNS);
|
|
10310
|
+
const hostUpdatedNewer = memorySnapshotTimestamp(existing, "updated_at") > memorySnapshotTimestamp(args.snapshot, "updated_at");
|
|
10311
|
+
const hostClassificationNewer = hostUpdatedNewer || memorySnapshotTimestamp(existing, "classified_at") > memorySnapshotTimestamp(args.snapshot, "classified_at");
|
|
10312
|
+
const snapshotCarriesUpdatedAt = hasSnapshotField(args.snapshot, "updated_at");
|
|
10313
|
+
const hostVerificationNewer = hostUpdatedNewer && snapshotCarriesUpdatedAt;
|
|
10314
|
+
const hostMuralNewer = hostUpdatedNewer && snapshotCarriesUpdatedAt;
|
|
10315
|
+
if (hostUpdatedNewer)
|
|
10316
|
+
preserve(UPDATED_MEMORY_SNAPSHOT_COLUMNS);
|
|
10317
|
+
if (hostClassificationNewer)
|
|
10318
|
+
preserve(CLASSIFICATION_MEMORY_SNAPSHOT_COLUMNS);
|
|
10319
|
+
if (hostVerificationNewer)
|
|
10320
|
+
preserve(VERIFICATION_MEMORY_SNAPSHOT_COLUMNS);
|
|
10321
|
+
if (hostMuralNewer)
|
|
10322
|
+
preserve(MURAL_MEMORY_SNAPSHOT_COLUMNS);
|
|
10323
|
+
return { effectiveRow, hostUpdatedNewer, hostVerificationNewer };
|
|
10324
|
+
}
|
|
10325
|
+
function hasSnapshotField(row, key) {
|
|
10326
|
+
return Object.prototype.hasOwnProperty.call(row, key);
|
|
10327
|
+
}
|
|
10328
|
+
function isCompleteMemorySnapshot(row) {
|
|
10329
|
+
return MEMORY_SNAPSHOT_COLUMNS.every((column) => hasSnapshotField(row, column));
|
|
10330
|
+
}
|
|
10331
|
+
function memoryResnapshotState(db) {
|
|
10332
|
+
const row = db.prepare("SELECT status, generation, updated_at FROM mirror_resnapshot_state WHERE domain = 'memories'").get();
|
|
10333
|
+
return row ?? null;
|
|
10334
|
+
}
|
|
10335
|
+
function casMemoryResnapshotState(db, observed, status, generation) {
|
|
10336
|
+
const result = db.prepare(`UPDATE mirror_resnapshot_state
|
|
10337
|
+
SET status = ?, generation = ?, updated_at = ?
|
|
10338
|
+
WHERE domain = 'memories'
|
|
10339
|
+
AND status = ?
|
|
10340
|
+
AND generation IS ?`).run(status, generation, Date.now(), observed.status, observed.generation);
|
|
10341
|
+
return result.changes === 1;
|
|
10342
|
+
}
|
|
10343
|
+
function upgradeMemoryMirrorNeedsResnapshot(db) {
|
|
10344
|
+
const missingLive = db.prepare(`SELECT 1
|
|
10345
|
+
FROM mirror_identity identity
|
|
10346
|
+
WHERE identity.domain = 'memories'
|
|
10347
|
+
AND NOT EXISTS (
|
|
10348
|
+
SELECT 1
|
|
10349
|
+
FROM mirror_live_memory_rows live
|
|
10350
|
+
WHERE live.module_project = identity.module_project
|
|
10351
|
+
AND live.module_row_id = identity.module_row_id
|
|
10352
|
+
)
|
|
10353
|
+
LIMIT 1`).get();
|
|
10354
|
+
if (missingLive)
|
|
10355
|
+
return true;
|
|
10356
|
+
const orphanedLive = db.prepare(`SELECT 1
|
|
10357
|
+
FROM mirror_live_memory_rows live
|
|
10358
|
+
WHERE NOT EXISTS (
|
|
10359
|
+
SELECT 1
|
|
10360
|
+
FROM mirror_identity identity
|
|
10361
|
+
WHERE identity.domain = 'memories'
|
|
10362
|
+
AND identity.module_project = live.module_project
|
|
10363
|
+
AND identity.module_row_id = live.module_row_id
|
|
10364
|
+
)
|
|
10365
|
+
LIMIT 1`).get();
|
|
10366
|
+
return Boolean(orphanedLive);
|
|
10367
|
+
}
|
|
10368
|
+
function stageLiveMemorySnapshotPage(db, generation, rows) {
|
|
10369
|
+
const owned = db.prepare(`SELECT 1
|
|
10370
|
+
FROM mirror_resnapshot_state
|
|
10371
|
+
WHERE domain = 'memories'
|
|
10372
|
+
AND status = 'resnapshotting'
|
|
10373
|
+
AND generation = ?`).get(generation);
|
|
10374
|
+
if (!owned)
|
|
10375
|
+
return false;
|
|
10376
|
+
const insert = db.prepare(`INSERT OR IGNORE INTO mirror_live_staging(
|
|
10377
|
+
generation, module_project, module_row_id, category, normalized_hash, full_row_snapshot
|
|
10378
|
+
) VALUES (?, ?, ?, ?, ?, ?)`);
|
|
10379
|
+
for (const feed of rows) {
|
|
10380
|
+
const row = feed.full_row_snapshot;
|
|
10381
|
+
const moduleProject = rowString(row, "project_path");
|
|
10382
|
+
const normalizedHash = rowString(row, "normalized_hash");
|
|
10383
|
+
if (!moduleProject || !normalizedHash) {
|
|
10384
|
+
throw new Error("live memory snapshot omitted project_path or normalized_hash");
|
|
10385
|
+
}
|
|
10386
|
+
insert.run(generation, moduleProject, feed.module_row_id, rowString(row, "category", "CONSTRAINTS"), normalizedHash, JSON.stringify(row));
|
|
10387
|
+
}
|
|
10388
|
+
return true;
|
|
10389
|
+
}
|
|
10390
|
+
function installStagedLiveMemorySnapshot(db, generation) {
|
|
10391
|
+
const owned = db.prepare(`SELECT 1
|
|
10392
|
+
FROM mirror_resnapshot_state
|
|
10393
|
+
WHERE domain = 'memories'
|
|
10394
|
+
AND status = 'resnapshotting'
|
|
10395
|
+
AND generation = ?`).get(generation);
|
|
10396
|
+
if (!owned)
|
|
10397
|
+
return false;
|
|
10398
|
+
db.prepare("DELETE FROM mirror_live_memory_rows").run();
|
|
10399
|
+
db.prepare(`INSERT INTO mirror_live_memory_rows(
|
|
10400
|
+
module_project, module_row_id, category, normalized_hash, full_row_snapshot
|
|
10401
|
+
)
|
|
10402
|
+
SELECT module_project, module_row_id, category, normalized_hash, full_row_snapshot
|
|
10403
|
+
FROM mirror_live_staging
|
|
10404
|
+
WHERE generation = ?`).run(generation);
|
|
10405
|
+
const completed = db.prepare(`UPDATE mirror_resnapshot_state
|
|
10406
|
+
SET status = 'complete', updated_at = ?
|
|
10407
|
+
WHERE domain = 'memories'
|
|
10408
|
+
AND status = 'resnapshotting'
|
|
10409
|
+
AND generation = ?`).run(Date.now(), generation);
|
|
10410
|
+
if (completed.changes !== 1) {
|
|
10411
|
+
throw new Error("live memory resnapshot ownership changed inside its install transaction");
|
|
10412
|
+
}
|
|
10413
|
+
db.prepare("DELETE FROM mirror_live_staging WHERE generation = ?").run(generation);
|
|
10414
|
+
return true;
|
|
10415
|
+
}
|
|
10416
|
+
function ensureMemoryRepairState(db) {
|
|
10417
|
+
db.exec(`
|
|
10418
|
+
CREATE TABLE IF NOT EXISTS mirror_memory_repair_state (
|
|
10419
|
+
id INTEGER PRIMARY KEY CHECK(id = 1),
|
|
10420
|
+
dirty INTEGER NOT NULL DEFAULT 0 CHECK(dirty IN (0, 1)),
|
|
10421
|
+
updated_at INTEGER NOT NULL DEFAULT 0
|
|
10422
|
+
);
|
|
10423
|
+
`);
|
|
10424
|
+
db.prepare("INSERT OR IGNORE INTO mirror_memory_repair_state(id, dirty, updated_at) VALUES (1, 0, 0)").run();
|
|
10425
|
+
}
|
|
10426
|
+
function markMemoryRepairPending(db) {
|
|
10427
|
+
ensureMemoryRepairState(db);
|
|
10428
|
+
db.prepare("UPDATE mirror_memory_repair_state SET dirty = 1, updated_at = ? WHERE id = 1").run(Date.now());
|
|
10429
|
+
}
|
|
10430
|
+
function prepareMirrorPageStatements(db) {
|
|
10431
|
+
return {
|
|
10432
|
+
identityByModule: db.prepare("SELECT context_row_id FROM mirror_identity WHERE domain = ? AND module_project = ? AND module_row_id = ?"),
|
|
10433
|
+
insertIdentity: db.prepare("INSERT OR IGNORE INTO mirror_identity(domain, module_project, module_row_id, context_row_id) VALUES (?, ?, ?, ?)"),
|
|
10434
|
+
deleteIdentityByContext: db.prepare("DELETE FROM mirror_identity WHERE domain = ? AND context_row_id = ?"),
|
|
10435
|
+
deleteLiveMemory: db.prepare("DELETE FROM mirror_live_memory_rows WHERE module_project = ? AND module_row_id = ?"),
|
|
10436
|
+
deletePendingReferencesForMemory: db.prepare("DELETE FROM mirror_pending_references WHERE domain = ? AND module_project = ? AND (module_row_id = ? OR target_module_row_id = ?)"),
|
|
10437
|
+
deleteIdentity: db.prepare("DELETE FROM mirror_identity WHERE domain = ? AND module_project = ? AND module_row_id = ?"),
|
|
10438
|
+
sharedIdentity: db.prepare("SELECT 1 FROM mirror_identity WHERE domain = ? AND context_row_id = ? LIMIT 1"),
|
|
10439
|
+
memoryById: db.prepare(`SELECT project_path, category, content, normalized_hash, importance, scope, shareable,
|
|
10440
|
+
source_session_id, source_type, seen_count, retrieval_count, first_seen_at,
|
|
10441
|
+
created_at, updated_at, last_seen_at, last_retrieved_at, status, expires_at,
|
|
10442
|
+
verification_status, verified_at, classified_at, superseded_by_memory_id,
|
|
10443
|
+
merged_from, metadata_json, mural_cue, mural_cue_hash, mural_cue_at,
|
|
10444
|
+
mural_cue_rejection_count
|
|
10445
|
+
FROM memories WHERE id = ?`),
|
|
10446
|
+
memoryIdByStoreId: db.prepare("SELECT id FROM memories WHERE id = ? AND project_path = ?"),
|
|
10447
|
+
memoryCandidates: db.prepare("SELECT id FROM memories WHERE project_path = ? AND category = ? AND normalized_hash = ? ORDER BY id"),
|
|
10448
|
+
insertMemory: db.prepare("INSERT INTO memories (project_path, category, content, normalized_hash, first_seen_at, created_at, updated_at, last_seen_at) VALUES (?, ?, '', '', 0, 0, 0, 0)"),
|
|
10449
|
+
liveMemoryMatches: db.prepare(`SELECT module_project, module_row_id FROM mirror_live_memory_rows
|
|
10450
|
+
WHERE module_project = ? AND category = ? AND normalized_hash = ?
|
|
10451
|
+
ORDER BY module_row_id LIMIT 2`),
|
|
10452
|
+
deleteMemoryEmbeddings: db.prepare("DELETE FROM memory_embeddings WHERE memory_id = ?"),
|
|
10453
|
+
deleteMemory: db.prepare("DELETE FROM memories WHERE id = ?"),
|
|
10454
|
+
liveMemorySnapshot: db.prepare("SELECT full_row_snapshot FROM mirror_live_memory_rows WHERE module_project = ? AND module_row_id = ?"),
|
|
10455
|
+
upsertLiveMemory: db.prepare(`INSERT INTO mirror_live_memory_rows(
|
|
10456
|
+
module_project, module_row_id, category, normalized_hash, full_row_snapshot
|
|
10457
|
+
) VALUES (?, ?, ?, ?, ?)
|
|
10458
|
+
ON CONFLICT(module_project, module_row_id) DO UPDATE SET
|
|
10459
|
+
category = excluded.category,
|
|
10460
|
+
normalized_hash = excluded.normalized_hash,
|
|
10461
|
+
full_row_snapshot = excluded.full_row_snapshot`),
|
|
10462
|
+
updateMemory: db.prepare(`UPDATE memories SET project_path = ?, category = ?, content = ?, normalized_hash = ?,
|
|
10463
|
+
importance = ?, scope = ?, shareable = ?, source_session_id = ?, source_type = ?,
|
|
10464
|
+
seen_count = ?, retrieval_count = ?, first_seen_at = ?, created_at = ?, updated_at = ?,
|
|
10465
|
+
last_seen_at = ?, last_retrieved_at = ?, status = ?, expires_at = ?,
|
|
10466
|
+
verification_status = ?, verified_at = ?, classified_at = ?, superseded_by_memory_id = ?,
|
|
10467
|
+
merged_from = ?, metadata_json = ?, mural_cue = ?, mural_cue_hash = ?, mural_cue_at = ?,
|
|
10468
|
+
mural_cue_rejection_count = ? WHERE id = ?`),
|
|
10469
|
+
updateSuperseded: db.prepare("UPDATE memories SET superseded_by_memory_id = ?, updated_at = ? WHERE id = ?"),
|
|
10470
|
+
deletePendingReference: db.prepare("DELETE FROM mirror_pending_references WHERE domain = 'memories' AND module_project = ? AND module_row_id = ?"),
|
|
10471
|
+
upsertPendingReference: db.prepare("INSERT INTO mirror_pending_references(domain, module_project, module_row_id, target_module_row_id) VALUES ('memories', ?, ?, ?) ON CONFLICT(domain, module_project, module_row_id) DO UPDATE SET target_module_row_id = excluded.target_module_row_id"),
|
|
10472
|
+
deleteMemoryVerifications: db.prepare("DELETE FROM memory_verifications WHERE memory_id = ?"),
|
|
10473
|
+
insertMemoryVerification: db.prepare("INSERT INTO memory_verifications(memory_id, file_path, verified_at, mapped_at, mapping_origin) VALUES (?, ?, ?, ?, ?)"),
|
|
10474
|
+
noteById: db.prepare("SELECT * FROM notes WHERE id = ?"),
|
|
10475
|
+
noteIdByStoreId: db.prepare("SELECT id FROM notes WHERE id = ? AND type = 'smart' AND project_path = ?"),
|
|
10476
|
+
insertNote: db.prepare("INSERT INTO notes (type, status, content, project_path, session_id, created_at, updated_at) VALUES ('smart', 'active', '', ?, ?, 0, 0)"),
|
|
10477
|
+
deleteNote: db.prepare("DELETE FROM notes WHERE id = ?"),
|
|
10478
|
+
deleteNoteRevisions: db.prepare("DELETE FROM mirror_note_revisions WHERE module_project = ? AND module_row_id = ?"),
|
|
10479
|
+
updateNote: db.prepare(`UPDATE notes SET type = ?, status = ?, project_path = ?, session_id = ?, content = ?,
|
|
10480
|
+
surface_condition = ?, compiled_provider = ?, compiled_config = ?, compiled_at = ?, compile_status = ?,
|
|
10481
|
+
ready_at = ?, ready_reason = ?, manifest_json = ?, compiled_check = ?,
|
|
10482
|
+
check_hash = ?, check_cron = ?, check_failure_count = ?, check_network_failure_count = ?,
|
|
10483
|
+
check_quarantined_until = ?, check_next_due_at = ?, check_compiled_at = ?, check_false_since_at = ?,
|
|
10484
|
+
check_last_liveness_at = ?, last_checked_at = ?, check_status = ?, check_version = ?,
|
|
10485
|
+
policy_version = ?, anchor_block_id = ?, anchor_ordinal = ?, created_at = ?, updated_at = ? WHERE id = ?`),
|
|
10486
|
+
upsertNoteRevision: db.prepare("INSERT OR REPLACE INTO mirror_note_revisions(module_project, module_row_id, context_row_id, status_version) VALUES (?, ?, ?, ?)"),
|
|
10487
|
+
translateMemoryReferences: db.prepare(`UPDATE memories
|
|
10488
|
+
SET superseded_by_memory_id = (
|
|
10489
|
+
SELECT target.context_row_id
|
|
10490
|
+
FROM mirror_pending_references pending
|
|
10491
|
+
JOIN mirror_identity source
|
|
10492
|
+
ON source.domain = pending.domain
|
|
10493
|
+
AND source.module_project = pending.module_project
|
|
10494
|
+
AND source.module_row_id = pending.module_row_id
|
|
10495
|
+
JOIN mirror_identity target
|
|
10496
|
+
ON target.domain = pending.domain
|
|
10497
|
+
AND target.module_project = pending.module_project
|
|
10498
|
+
AND target.module_row_id = pending.target_module_row_id
|
|
10499
|
+
WHERE pending.domain = 'memories'
|
|
10500
|
+
AND source.context_row_id = memories.id
|
|
10501
|
+
),
|
|
10502
|
+
updated_at = ?
|
|
10503
|
+
WHERE id IN (
|
|
10504
|
+
SELECT source.context_row_id
|
|
10505
|
+
FROM mirror_pending_references pending
|
|
10506
|
+
JOIN mirror_identity source
|
|
10507
|
+
ON source.domain = pending.domain
|
|
10508
|
+
AND source.module_project = pending.module_project
|
|
10509
|
+
AND source.module_row_id = pending.module_row_id
|
|
10510
|
+
JOIN mirror_identity target
|
|
10511
|
+
ON target.domain = pending.domain
|
|
10512
|
+
AND target.module_project = pending.module_project
|
|
10513
|
+
AND target.module_row_id = pending.target_module_row_id
|
|
10514
|
+
WHERE pending.domain = 'memories'
|
|
10515
|
+
)`),
|
|
10516
|
+
clearTranslatedReferences: db.prepare(`DELETE FROM mirror_pending_references
|
|
10517
|
+
WHERE domain = 'memories'
|
|
10518
|
+
AND EXISTS (
|
|
10519
|
+
SELECT 1
|
|
10520
|
+
FROM mirror_identity source
|
|
10521
|
+
JOIN mirror_identity target
|
|
10522
|
+
ON target.domain = source.domain
|
|
10523
|
+
AND target.module_project = source.module_project
|
|
10524
|
+
AND target.module_row_id = mirror_pending_references.target_module_row_id
|
|
10525
|
+
WHERE source.domain = mirror_pending_references.domain
|
|
10526
|
+
AND source.module_project = mirror_pending_references.module_project
|
|
10527
|
+
AND source.module_row_id = mirror_pending_references.module_row_id
|
|
10528
|
+
)`),
|
|
10529
|
+
repairPending: db.prepare("SELECT dirty FROM mirror_memory_repair_state WHERE id = 1"),
|
|
10530
|
+
markRepairPending: db.prepare("UPDATE mirror_memory_repair_state SET dirty = 1, updated_at = ? WHERE id = 1"),
|
|
10531
|
+
clearRepairPending: db.prepare("UPDATE mirror_memory_repair_state SET dirty = 0, updated_at = ? WHERE id = 1"),
|
|
10532
|
+
repairCandidates: db.prepare(`SELECT memory.id, memory.updated_at, memory.classified_at, live.full_row_snapshot
|
|
10533
|
+
FROM memories memory
|
|
10534
|
+
JOIN mirror_identity identity
|
|
10535
|
+
ON identity.domain = 'memories'
|
|
10536
|
+
AND identity.context_row_id = memory.id
|
|
10537
|
+
JOIN mirror_live_memory_rows live
|
|
10538
|
+
ON live.module_project = identity.module_project
|
|
10539
|
+
AND live.module_row_id = identity.module_row_id
|
|
10540
|
+
JOIN authority_managed managed
|
|
10541
|
+
ON managed.project_path = memory.project_path
|
|
10542
|
+
OR managed.project_path = identity.module_project
|
|
10543
|
+
WHERE (memory.source_type IS NULL OR memory.importance IS NULL)
|
|
10544
|
+
AND live.full_row_snapshot IS NOT NULL`),
|
|
10545
|
+
repairMemory: db.prepare(`UPDATE memories
|
|
10546
|
+
SET source_type = COALESCE(source_type, ?),
|
|
10547
|
+
importance = COALESCE(importance, ?),
|
|
10548
|
+
updated_at = ?
|
|
10549
|
+
WHERE id = ?
|
|
10550
|
+
AND COALESCE(updated_at, 0) <= ?
|
|
10551
|
+
AND COALESCE(classified_at, 0) <= ?
|
|
10552
|
+
AND ((source_type IS NULL AND ? IS NOT NULL)
|
|
10553
|
+
OR (importance IS NULL AND ? IS NOT NULL))`),
|
|
10554
|
+
updateCursor: db.prepare("INSERT INTO mirror_cursors(domain, cursor, updated_at) VALUES (?, ?, ?) ON CONFLICT(domain) DO UPDATE SET cursor = excluded.cursor, updated_at = excluded.updated_at"),
|
|
10555
|
+
contextStoreUuid: getContextStoreUuid(db)
|
|
10556
|
+
};
|
|
10557
|
+
}
|
|
10558
|
+
function mirrorIdentity(db, domain, moduleProject, moduleRowId, statements) {
|
|
10559
|
+
return (statements?.identityByModule ?? db.prepare("SELECT context_row_id FROM mirror_identity WHERE domain = ? AND module_project = ? AND module_row_id = ?")).get(domain, moduleProject, moduleRowId) ?? null;
|
|
10560
|
+
}
|
|
10561
|
+
function rememberIdentity(db, domain, moduleProject, moduleRowId, contextRowId, statements, replaceContextIdentity = domain === "notes") {
|
|
10562
|
+
const existing = mirrorIdentity(db, domain, moduleProject, moduleRowId, statements);
|
|
10563
|
+
if (existing?.context_row_id === contextRowId)
|
|
10564
|
+
return;
|
|
10565
|
+
if (existing) {
|
|
10566
|
+
if (!replaceContextIdentity)
|
|
10567
|
+
return;
|
|
10568
|
+
(statements?.deleteIdentity ?? db.prepare("DELETE FROM mirror_identity WHERE domain = ? AND module_project = ? AND module_row_id = ?")).run(domain, moduleProject, moduleRowId);
|
|
10569
|
+
}
|
|
10570
|
+
if (replaceContextIdentity) {
|
|
10571
|
+
(statements?.deleteIdentityByContext ?? db.prepare("DELETE FROM mirror_identity WHERE domain = ? AND context_row_id = ?")).run(domain, contextRowId);
|
|
10572
|
+
}
|
|
10573
|
+
(statements?.insertIdentity ?? db.prepare("INSERT OR IGNORE INTO mirror_identity(domain, module_project, module_row_id, context_row_id) VALUES (?, ?, ?, ?)")).run(domain, moduleProject, moduleRowId, contextRowId);
|
|
10574
|
+
}
|
|
10575
|
+
function contextMemoryId(db, domain, moduleProject, row, moduleRowId, statements) {
|
|
10576
|
+
const mapped = mirrorIdentity(db, domain, moduleProject, moduleRowId, statements);
|
|
10577
|
+
if (mapped)
|
|
10578
|
+
return { contextId: mapped.context_row_id, inserted: false };
|
|
10579
|
+
const sourceUuid = rowNullableString(row, "context_store_uuid");
|
|
10580
|
+
const sourceId = rowNumber(row, "context_row_id", -1);
|
|
10581
|
+
const localStoreUuid = statements?.contextStoreUuid ?? getContextStoreUuid(db);
|
|
10582
|
+
if (sourceUuid && sourceUuid === localStoreUuid && sourceId >= 0) {
|
|
10583
|
+
const existing = (statements?.memoryIdByStoreId ?? db.prepare("SELECT id FROM memories WHERE id = ? AND project_path = ?")).get(sourceId, moduleProject);
|
|
10584
|
+
if (existing?.id !== undefined) {
|
|
10585
|
+
rememberIdentity(db, domain, moduleProject, moduleRowId, existing.id, statements, true);
|
|
10586
|
+
return { contextId: existing.id, inserted: false };
|
|
10587
|
+
}
|
|
10588
|
+
}
|
|
10589
|
+
const normalizedHash = rowString(row, "normalized_hash");
|
|
10590
|
+
const category = rowString(row, "category", "CONSTRAINTS");
|
|
10591
|
+
if (normalizedHash) {
|
|
10592
|
+
const candidates = (statements?.memoryCandidates ?? db.prepare("SELECT id FROM memories WHERE project_path = ? AND category = ? AND normalized_hash = ? ORDER BY id")).all(moduleProject, category, normalizedHash);
|
|
10593
|
+
if (candidates.length === 1 && candidates[0]?.id !== undefined) {
|
|
10594
|
+
rememberIdentity(db, domain, moduleProject, moduleRowId, candidates[0].id, statements);
|
|
10595
|
+
return { contextId: candidates[0].id, inserted: false };
|
|
10596
|
+
}
|
|
10597
|
+
}
|
|
10598
|
+
const result = (statements?.insertMemory ?? db.prepare("INSERT INTO memories (project_path, category, content, normalized_hash, first_seen_at, created_at, updated_at, last_seen_at) VALUES (?, ?, '', '', 0, 0, 0, 0)")).run(moduleProject, rowString(row, "category", "CONSTRAINTS"));
|
|
10599
|
+
const contextId = Number(result.lastInsertRowid);
|
|
10600
|
+
rememberIdentity(db, domain, moduleProject, moduleRowId, contextId, statements);
|
|
10601
|
+
return { contextId, inserted: true };
|
|
10602
|
+
}
|
|
10603
|
+
function applyMemoryRow(db, feed, statements) {
|
|
10604
|
+
const row = feed.full_row_snapshot;
|
|
10605
|
+
const moduleProject = rowString(row, "project_path");
|
|
10606
|
+
if (!moduleProject)
|
|
10607
|
+
throw new Error("memory feed snapshot has no project_path");
|
|
10608
|
+
if (feed.op === "tombstone") {
|
|
10609
|
+
statements.deleteLiveMemory.run(moduleProject, feed.module_row_id);
|
|
10610
|
+
statements.deletePendingReferencesForMemory.run(feed.domain, moduleProject, feed.module_row_id, feed.module_row_id);
|
|
10611
|
+
const mapped = mirrorIdentity(db, feed.domain, moduleProject, feed.module_row_id, statements);
|
|
10612
|
+
if (!mapped)
|
|
10613
|
+
return;
|
|
10614
|
+
statements.deleteIdentity.run(feed.domain, moduleProject, feed.module_row_id);
|
|
10615
|
+
const shared = statements.sharedIdentity.get(feed.domain, mapped.context_row_id);
|
|
10616
|
+
if (shared)
|
|
10617
|
+
return;
|
|
10618
|
+
const contextRow = statements.memoryById.get(mapped.context_row_id);
|
|
10619
|
+
if (contextRow?.project_path && contextRow.category && contextRow.normalized_hash) {
|
|
10620
|
+
const liveMatches = statements.liveMemoryMatches.all(contextRow.project_path, contextRow.category, contextRow.normalized_hash);
|
|
10621
|
+
if (liveMatches.length === 1 && liveMatches[0]) {
|
|
10622
|
+
rememberIdentity(db, feed.domain, liveMatches[0].module_project, liveMatches[0].module_row_id, mapped.context_row_id, statements);
|
|
10623
|
+
return;
|
|
10624
|
+
}
|
|
10625
|
+
}
|
|
10626
|
+
statements.deleteMemoryEmbeddings.run(mapped.context_row_id);
|
|
10627
|
+
statements.deleteMemory.run(mapped.context_row_id);
|
|
10628
|
+
return;
|
|
10629
|
+
}
|
|
10630
|
+
const storedLive = statements.liveMemorySnapshot.get(moduleProject, feed.module_row_id);
|
|
10631
|
+
const snapshotJson = !isCompleteMemorySnapshot(row) && storedLive?.full_row_snapshot ? storedLive.full_row_snapshot : JSON.stringify(row);
|
|
10632
|
+
statements.upsertLiveMemory.run(moduleProject, feed.module_row_id, rowString(row, "category", "CONSTRAINTS"), rowString(row, "normalized_hash"), snapshotJson);
|
|
10633
|
+
const metadataClobberRisk = hasSnapshotField(row, "source_type") && rowNullableString(row, "source_type") === null || hasSnapshotField(row, "importance") && !(typeof row.importance === "number" && Number.isFinite(row.importance));
|
|
10634
|
+
if (metadataClobberRisk)
|
|
10635
|
+
statements.markRepairPending.run(Date.now());
|
|
10636
|
+
const { contextId, inserted } = contextMemoryId(db, feed.domain, moduleProject, row, feed.module_row_id, statements);
|
|
10637
|
+
const existing = statements.memoryById.get(contextId);
|
|
10638
|
+
if (existing && existing.project_path !== moduleProject) {
|
|
10639
|
+
log(`[magic-context] skipping memory mirror update for module ${moduleProject}/${feed.module_row_id}: context row ${contextId} belongs to ${existing.project_path}`);
|
|
10640
|
+
return;
|
|
10641
|
+
}
|
|
10642
|
+
const retainedRecencySnapshot = parsedMemorySnapshot(snapshotJson, row);
|
|
10643
|
+
const recencySnapshot = hasSnapshotField(row, "updated_at") ? row : hasSnapshotField(row, "classified_at") ? { ...retainedRecencySnapshot, classified_at: row.classified_at } : retainedRecencySnapshot;
|
|
10644
|
+
const recencyGuard = guardMemorySnapshotByRecency({
|
|
10645
|
+
row,
|
|
10646
|
+
snapshot: recencySnapshot,
|
|
10647
|
+
existing: inserted ? undefined : existing
|
|
10648
|
+
});
|
|
10649
|
+
const projectedRow = recencyGuard.effectiveRow;
|
|
10650
|
+
const has = (key) => hasSnapshotField(row, key);
|
|
10651
|
+
const nullableNumber = (key, previous) => has(key) ? typeof projectedRow[key] === "number" && Number.isFinite(projectedRow[key]) ? projectedRow[key] : null : previous ?? null;
|
|
10652
|
+
const nullableString = (key, previous) => has(key) ? rowNullableString(projectedRow, key) : previous ?? null;
|
|
10653
|
+
const hasSuperseded = has("superseded_by_memory_id") && !recencyGuard.hostUpdatedNewer;
|
|
10654
|
+
const previousHash = existing?.normalized_hash;
|
|
10655
|
+
statements.updateMemory.run(has("project_path") ? rowString(projectedRow, "project_path") : existing?.project_path ?? moduleProject, has("category") ? rowString(projectedRow, "category", "CONSTRAINTS") : existing?.category ?? "CONSTRAINTS", has("content") ? rowString(projectedRow, "content") : existing?.content ?? "", has("normalized_hash") ? rowString(projectedRow, "normalized_hash") : existing?.normalized_hash ?? "", has("importance") ? typeof projectedRow.importance === "number" && Number.isFinite(projectedRow.importance) ? projectedRow.importance : null : existing?.importance ?? null, has("scope") ? rowString(projectedRow, "scope", "project") : existing?.scope ?? "project", has("shareable") ? rowNumber(projectedRow, "shareable") : existing?.shareable ?? 0, nullableString("source_session_id", existing?.source_session_id), nullableString("source_type", existing?.source_type), has("seen_count") ? rowNumber(projectedRow, "seen_count", 1) : existing?.seen_count ?? 1, has("retrieval_count") ? rowNumber(projectedRow, "retrieval_count") : existing?.retrieval_count ?? 0, has("first_seen_at") ? rowNumber(projectedRow, "first_seen_at") : existing?.first_seen_at ?? 0, has("created_at") ? rowNumber(projectedRow, "created_at") : existing?.created_at ?? 0, has("updated_at") ? rowNumber(projectedRow, "updated_at") : existing?.updated_at ?? 0, has("last_seen_at") ? rowNumber(projectedRow, "last_seen_at") : existing?.last_seen_at ?? 0, nullableNumber("last_retrieved_at", existing?.last_retrieved_at), has("status") ? rowString(projectedRow, "status", "active") : existing?.status ?? "active", nullableNumber("expires_at", existing?.expires_at), has("verification_status") ? rowString(projectedRow, "verification_status", "unverified") : existing?.verification_status ?? "unverified", nullableNumber("verified_at", existing?.verified_at), nullableNumber("classified_at", existing?.classified_at), hasSuperseded ? null : existing?.superseded_by_memory_id ?? null, nullableString("merged_from", existing?.merged_from), nullableString("metadata_json", existing?.metadata_json), nullableString("mural_cue", existing?.mural_cue), nullableString("mural_cue_hash", existing?.mural_cue_hash), nullableNumber("mural_cue_at", existing?.mural_cue_at), has("mural_cue_rejection_count") ? rowNumber(projectedRow, "mural_cue_rejection_count") : existing?.mural_cue_rejection_count ?? 0, contextId);
|
|
10656
|
+
if (hasSuperseded && typeof projectedRow.superseded_by_memory_id === "number") {
|
|
10657
|
+
const translated = mirrorIdentity(db, "memories", moduleProject, projectedRow.superseded_by_memory_id, statements);
|
|
10658
|
+
if (translated) {
|
|
10659
|
+
statements.updateSuperseded.run(translated.context_row_id, Date.now(), contextId);
|
|
10660
|
+
statements.deletePendingReference.run(moduleProject, feed.module_row_id);
|
|
10661
|
+
} else {
|
|
10662
|
+
statements.upsertPendingReference.run(moduleProject, feed.module_row_id, projectedRow.superseded_by_memory_id);
|
|
10663
|
+
}
|
|
10664
|
+
} else if (hasSuperseded) {
|
|
10665
|
+
statements.deletePendingReference.run(moduleProject, feed.module_row_id);
|
|
10666
|
+
}
|
|
10667
|
+
const appliedHash = has("normalized_hash") ? rowString(projectedRow, "normalized_hash") : previousHash;
|
|
10668
|
+
if (previousHash !== appliedHash && appliedHash !== undefined) {
|
|
10669
|
+
statements.deleteMemoryEmbeddings.run(contextId);
|
|
10670
|
+
}
|
|
10671
|
+
if (has("mapping") && !recencyGuard.hostVerificationNewer) {
|
|
10672
|
+
statements.deleteMemoryVerifications.run(contextId);
|
|
10673
|
+
if (Array.isArray(projectedRow.mapping)) {
|
|
10674
|
+
const files = [
|
|
10675
|
+
...new Set(projectedRow.mapping.filter((file) => typeof file === "string").sort())
|
|
10676
|
+
];
|
|
10677
|
+
const verifiedAt = rowNumber(projectedRow, "verified_at");
|
|
10678
|
+
const mappedAt = rowNumber(projectedRow, "updated_at", Date.now());
|
|
10679
|
+
const mappingOrigin = projectedRow.mapping_origin === "host_rejected_fallback" ? "host_rejected_fallback" : "mapper";
|
|
10680
|
+
for (const file of files.length > 0 ? files : [""]) {
|
|
10681
|
+
statements.insertMemoryVerification.run(contextId, file, verifiedAt, mappedAt, mappingOrigin);
|
|
10682
|
+
}
|
|
10683
|
+
}
|
|
10684
|
+
}
|
|
10685
|
+
}
|
|
10686
|
+
function repairNullClobberedMemoryRows(statements) {
|
|
10687
|
+
const pending = statements.repairPending.get();
|
|
10688
|
+
if (pending?.dirty !== 1)
|
|
10689
|
+
return;
|
|
10690
|
+
const candidates = statements.repairCandidates.all();
|
|
10691
|
+
for (const candidate of candidates) {
|
|
10692
|
+
if (!candidate.full_row_snapshot)
|
|
10693
|
+
continue;
|
|
10694
|
+
let snapshot;
|
|
10695
|
+
try {
|
|
10696
|
+
const parsed = JSON.parse(candidate.full_row_snapshot);
|
|
10697
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
10698
|
+
continue;
|
|
10699
|
+
snapshot = parsed;
|
|
10700
|
+
} catch {
|
|
10701
|
+
continue;
|
|
10702
|
+
}
|
|
10703
|
+
const sourceType = hasSnapshotField(snapshot, "source_type") && typeof snapshot.source_type === "string" ? snapshot.source_type : null;
|
|
10704
|
+
const importance = hasSnapshotField(snapshot, "importance") && typeof snapshot.importance === "number" && Number.isFinite(snapshot.importance) ? snapshot.importance : null;
|
|
10705
|
+
if (sourceType === null && importance === null)
|
|
10706
|
+
continue;
|
|
10707
|
+
const snapshotVintage = Math.max(memorySnapshotTimestamp(snapshot, "updated_at"), memorySnapshotTimestamp(snapshot, "classified_at"));
|
|
10708
|
+
const hostVintage = Math.max(candidate.updated_at ?? 0, candidate.classified_at ?? 0);
|
|
10709
|
+
if (hostVintage > snapshotVintage)
|
|
10710
|
+
continue;
|
|
10711
|
+
statements.repairMemory.run(sourceType, importance, Date.now(), candidate.id, snapshotVintage, snapshotVintage, sourceType, importance);
|
|
10712
|
+
}
|
|
10713
|
+
statements.clearRepairPending.run(Date.now());
|
|
10714
|
+
}
|
|
10715
|
+
function contextNoteId(db, feed, moduleProject, statements) {
|
|
10716
|
+
const mapped = mirrorIdentity(db, feed.domain, moduleProject, feed.module_row_id, statements);
|
|
10717
|
+
if (mapped)
|
|
10718
|
+
return mapped.context_row_id;
|
|
10719
|
+
const row = feed.full_row_snapshot;
|
|
10720
|
+
const sourceId = rowNumber(row, "context_row_id", -1);
|
|
10721
|
+
const sourceUuid = rowNullableString(row, "context_store_uuid");
|
|
10722
|
+
const localStoreUuid = statements?.contextStoreUuid ?? getContextStoreUuid(db);
|
|
10723
|
+
if (sourceUuid && sourceUuid === localStoreUuid && sourceId >= 0) {
|
|
10724
|
+
const existing = (statements?.noteIdByStoreId ?? db.prepare("SELECT id FROM notes WHERE id = ? AND type = 'smart' AND project_path = ?")).get(sourceId, moduleProject);
|
|
10725
|
+
if (existing?.id !== undefined) {
|
|
10726
|
+
rememberIdentity(db, feed.domain, moduleProject, feed.module_row_id, existing.id, statements);
|
|
10727
|
+
return existing.id;
|
|
10728
|
+
}
|
|
10729
|
+
}
|
|
10730
|
+
const result = (statements?.insertNote ?? db.prepare("INSERT INTO notes (type, status, content, project_path, session_id, created_at, updated_at) VALUES ('smart', 'active', '', ?, ?, 0, 0)")).run(moduleProject, rowNullableString(row, "session_id"));
|
|
10731
|
+
const contextId = Number(result.lastInsertRowid);
|
|
10732
|
+
rememberIdentity(db, feed.domain, moduleProject, feed.module_row_id, contextId, statements);
|
|
10733
|
+
return contextId;
|
|
10734
|
+
}
|
|
10735
|
+
function translateMemoryReferences(statements) {
|
|
10736
|
+
statements.translateMemoryReferences.run(Date.now());
|
|
10737
|
+
statements.clearTranslatedReferences.run();
|
|
10738
|
+
}
|
|
10739
|
+
function applyNoteRow(db, feed, statements) {
|
|
10740
|
+
const row = feed.full_row_snapshot;
|
|
10741
|
+
const moduleProject = rowString(row, "project_path");
|
|
10742
|
+
if (!moduleProject)
|
|
10743
|
+
throw new Error("note feed snapshot has no project_path");
|
|
10744
|
+
if (feed.op === "tombstone") {
|
|
10745
|
+
const mapped = mirrorIdentity(db, feed.domain, moduleProject, feed.module_row_id, statements);
|
|
10746
|
+
if (!mapped)
|
|
10747
|
+
return;
|
|
10748
|
+
statements.deleteNote.run(mapped.context_row_id);
|
|
10749
|
+
statements.deleteIdentity.run(feed.domain, moduleProject, feed.module_row_id);
|
|
10750
|
+
statements.deleteNoteRevisions.run(moduleProject, feed.module_row_id);
|
|
10751
|
+
return;
|
|
10752
|
+
}
|
|
10753
|
+
const contextId = contextNoteId(db, feed, moduleProject, statements);
|
|
10754
|
+
const existing = statements.noteById.get(contextId);
|
|
10755
|
+
const effectiveRow = { ...existing ?? {}, ...row };
|
|
10756
|
+
if (!hasSnapshotField(row, "created_at_ms") && existing?.created_at !== undefined) {
|
|
10757
|
+
effectiveRow.created_at_ms = existing.created_at;
|
|
10758
|
+
}
|
|
10759
|
+
if (!hasSnapshotField(row, "updated_at_ms") && existing?.updated_at !== undefined) {
|
|
10760
|
+
effectiveRow.updated_at_ms = existing.updated_at;
|
|
10761
|
+
}
|
|
10762
|
+
const moduleStatus = rowString(effectiveRow, "status", "active");
|
|
10763
|
+
const contextStatus = moduleStatus === "surfaced" || moduleStatus === "surfacing" ? "ready" : moduleStatus;
|
|
10764
|
+
statements.updateNote.run(rowString(effectiveRow, "type", "smart"), contextStatus, moduleProject, rowNullableString(effectiveRow, "session_id"), rowString(effectiveRow, "content"), rowNullableString(effectiveRow, "surface_condition"), rowNullableString(effectiveRow, "compiled_provider"), rowNullableString(effectiveRow, "compiled_config"), typeof effectiveRow.compiled_at === "number" ? effectiveRow.compiled_at : null, rowNullableString(effectiveRow, "compile_status"), typeof effectiveRow.ready_at === "number" ? effectiveRow.ready_at : null, rowNullableString(effectiveRow, "ready_reason"), rowNullableString(effectiveRow, "manifest_json"), rowNullableString(effectiveRow, "compiled_check"), rowNullableString(effectiveRow, "check_hash"), rowNullableString(effectiveRow, "check_cron"), rowNumber(effectiveRow, "check_failure_count"), rowNumber(effectiveRow, "check_network_failure_count"), typeof effectiveRow.check_quarantined_until === "number" ? effectiveRow.check_quarantined_until : null, typeof effectiveRow.check_next_due_at === "number" ? effectiveRow.check_next_due_at : null, typeof effectiveRow.check_compiled_at === "number" ? effectiveRow.check_compiled_at : null, typeof effectiveRow.check_false_since_at === "number" ? effectiveRow.check_false_since_at : null, typeof effectiveRow.check_last_liveness_at === "number" ? effectiveRow.check_last_liveness_at : null, typeof effectiveRow.last_checked_at === "number" ? effectiveRow.last_checked_at : null, rowString(effectiveRow, "check_status", "uncompiled"), rowNumber(effectiveRow, "check_version"), rowNumber(effectiveRow, "policy_version", 1), rowNullableString(effectiveRow, "anchor_block_id"), typeof effectiveRow.anchor_ordinal === "number" ? effectiveRow.anchor_ordinal : null, rowNumber(effectiveRow, "created_at_ms"), rowNumber(effectiveRow, "updated_at_ms"), contextId);
|
|
10765
|
+
statements.upsertNoteRevision.run(moduleProject, feed.module_row_id, contextId, rowNumber(effectiveRow, "status_version"));
|
|
10766
|
+
}
|
|
10767
|
+
function applyMirrorPage(args) {
|
|
10768
|
+
const { db, page } = args;
|
|
10769
|
+
if (!AUTHORITY_DOMAINS.includes(page.domain))
|
|
10770
|
+
throw new Error("unknown mirror domain");
|
|
10771
|
+
const durableCursor = getMirrorCursor(db, page.domain);
|
|
10772
|
+
if (page.cursor !== durableCursor) {
|
|
10773
|
+
throw new Error(`mirror cursor mismatch for ${page.domain}: expected ${durableCursor}, got ${page.cursor}`);
|
|
10774
|
+
}
|
|
10775
|
+
if (page.next_cursor < durableCursor) {
|
|
10776
|
+
throw new Error("mirror page moved its cursor backwards");
|
|
10777
|
+
}
|
|
10778
|
+
const resnapshotState = page.domain === "memories" ? memoryResnapshotState(db) : null;
|
|
10779
|
+
const hasNewRows = page.rows.some((feed) => feed.domain === page.domain && feed.feed_seq > durableCursor);
|
|
10780
|
+
const replayMustRun = page.domain === "memories" && resnapshotState !== null && resnapshotState.status !== "complete" && (durableCursor === 0 || page.rows.some((feed) => feed.op === "tombstone"));
|
|
10781
|
+
if (!hasNewRows && !replayMustRun) {
|
|
10782
|
+
if (page.next_cursor <= durableCursor)
|
|
10783
|
+
return durableCursor;
|
|
10784
|
+
withPrivilegedWriter(db, () => {
|
|
10785
|
+
db.prepare("INSERT INTO mirror_cursors(domain, cursor, updated_at) VALUES (?, ?, ?) ON CONFLICT(domain) DO UPDATE SET cursor = excluded.cursor, updated_at = excluded.updated_at").run(page.domain, page.next_cursor, Date.now());
|
|
10786
|
+
});
|
|
10787
|
+
return page.next_cursor;
|
|
10788
|
+
}
|
|
10789
|
+
let nextCursor = durableCursor;
|
|
10790
|
+
withPrivilegedWriter(db, () => {
|
|
10791
|
+
db.transaction(() => {
|
|
10792
|
+
ensureMemoryRepairState(db);
|
|
10793
|
+
const statements = prepareMirrorPageStatements(db);
|
|
10794
|
+
const currentResnapshotState = page.domain === "memories" ? memoryResnapshotState(db) : null;
|
|
10795
|
+
let resnapshotStatus = page.domain === "memories" ? currentResnapshotState?.status ?? null : "complete";
|
|
10796
|
+
if (page.domain === "memories" && durableCursor === 0 && currentResnapshotState && resnapshotStatus !== "complete") {
|
|
10797
|
+
statements.markRepairPending.run(Date.now());
|
|
10798
|
+
if (!casMemoryResnapshotState(db, currentResnapshotState, "complete", currentResnapshotState.generation)) {
|
|
10799
|
+
throw new Error("memory mirror resnapshot ownership changed during replay");
|
|
10800
|
+
}
|
|
10801
|
+
resnapshotStatus = "complete";
|
|
10802
|
+
}
|
|
10803
|
+
if (page.domain === "memories" && resnapshotStatus !== "complete" && page.rows.some((feed) => feed.op === "tombstone")) {
|
|
10804
|
+
throw new Error("memory mirror resnapshot must complete before tombstones");
|
|
10805
|
+
}
|
|
10806
|
+
if (page.domain === "memories") {
|
|
10807
|
+
for (const feed of page.rows) {
|
|
10808
|
+
if (feed.domain !== "memories" || feed.op === "tombstone" || feed.feed_seq <= durableCursor) {
|
|
10809
|
+
continue;
|
|
10810
|
+
}
|
|
10811
|
+
const row = feed.full_row_snapshot;
|
|
10812
|
+
const moduleProject = rowString(row, "project_path");
|
|
10813
|
+
const sourceUuid = rowNullableString(row, "context_store_uuid");
|
|
10814
|
+
const sourceId = rowNumber(row, "context_row_id", -1);
|
|
10815
|
+
if (!moduleProject || !sourceUuid || sourceUuid !== statements.contextStoreUuid || sourceId < 0) {
|
|
10816
|
+
continue;
|
|
10817
|
+
}
|
|
10818
|
+
const existing = statements.memoryIdByStoreId.get(sourceId, moduleProject);
|
|
10819
|
+
if (existing?.id === undefined)
|
|
10820
|
+
continue;
|
|
10821
|
+
rememberIdentity(db, "memories", moduleProject, feed.module_row_id, existing.id, statements, true);
|
|
10822
|
+
}
|
|
10823
|
+
}
|
|
10824
|
+
const touchedProjects = new Set;
|
|
10825
|
+
for (const feed of page.rows) {
|
|
10826
|
+
if (feed.domain !== page.domain || feed.feed_seq <= nextCursor)
|
|
10827
|
+
continue;
|
|
10828
|
+
const projectPath = rowString(feed.full_row_snapshot, "project_path");
|
|
10829
|
+
if (projectPath)
|
|
10830
|
+
touchedProjects.add(projectPath);
|
|
10831
|
+
if (feed.domain === "memories")
|
|
10832
|
+
applyMemoryRow(db, feed, statements);
|
|
10833
|
+
else
|
|
10834
|
+
applyNoteRow(db, feed, statements);
|
|
10835
|
+
nextCursor = feed.feed_seq;
|
|
10836
|
+
}
|
|
10837
|
+
if (page.domain === "memories") {
|
|
10838
|
+
translateMemoryReferences(statements);
|
|
10839
|
+
repairNullClobberedMemoryRows(statements);
|
|
10840
|
+
}
|
|
10841
|
+
for (const projectPath of touchedProjects) {
|
|
10842
|
+
bumpDomainMutationEpoch(db, projectPath, page.domain);
|
|
10843
|
+
}
|
|
10844
|
+
if (page.next_cursor < nextCursor) {
|
|
10845
|
+
throw new Error("mirror page moved its cursor backwards");
|
|
10846
|
+
}
|
|
10847
|
+
nextCursor = Math.max(nextCursor, page.next_cursor);
|
|
10848
|
+
statements.updateCursor.run(page.domain, nextCursor, Date.now());
|
|
10849
|
+
}).immediate();
|
|
10850
|
+
});
|
|
10851
|
+
return nextCursor;
|
|
10852
|
+
}
|
|
10853
|
+
async function ensureLiveMemoryResnapshot(args) {
|
|
10854
|
+
let adoptedWinner = false;
|
|
10855
|
+
let generation;
|
|
10856
|
+
while (true) {
|
|
10857
|
+
const observed = memoryResnapshotState(args.db);
|
|
10858
|
+
if (!observed || observed.status === "complete")
|
|
10859
|
+
return;
|
|
10860
|
+
if (observed.status === "resnapshotting") {
|
|
10861
|
+
withPrivilegedWriter(args.db, () => markMemoryRepairPending(args.db));
|
|
10862
|
+
}
|
|
10863
|
+
if (observed.status === "pending_check" && !upgradeMemoryMirrorNeedsResnapshot(args.db)) {
|
|
10864
|
+
let completed = false;
|
|
10865
|
+
withPrivilegedWriter(args.db, () => {
|
|
10866
|
+
args.db.transaction(() => {
|
|
10867
|
+
markMemoryRepairPending(args.db);
|
|
10868
|
+
completed = casMemoryResnapshotState(args.db, observed, "complete", observed.generation);
|
|
10869
|
+
if (completed) {
|
|
10870
|
+
args.db.prepare("DELETE FROM mirror_live_staging WHERE generation IS NOT ?").run(observed.generation);
|
|
10871
|
+
}
|
|
10872
|
+
}).immediate();
|
|
10873
|
+
});
|
|
10874
|
+
if (completed)
|
|
10875
|
+
return;
|
|
10876
|
+
continue;
|
|
10877
|
+
}
|
|
10878
|
+
if (!args.module.mirrorPull) {
|
|
10879
|
+
throw new Error("memory mirror resnapshot requires the mirror.pull module route");
|
|
10880
|
+
}
|
|
10881
|
+
const now = Date.now();
|
|
10882
|
+
generation = `${now.toString(36)}:${crypto.randomUUID()}`;
|
|
10883
|
+
let claimed = false;
|
|
10884
|
+
withPrivilegedWriter(args.db, () => {
|
|
10885
|
+
args.db.transaction(() => {
|
|
10886
|
+
claimed = casMemoryResnapshotState(args.db, observed, "resnapshotting", generation);
|
|
10887
|
+
if (claimed) {
|
|
10888
|
+
markMemoryRepairPending(args.db);
|
|
10889
|
+
args.db.prepare("DELETE FROM mirror_live_staging WHERE generation != ?").run(generation);
|
|
10890
|
+
}
|
|
10891
|
+
}).immediate();
|
|
10892
|
+
});
|
|
10893
|
+
if (claimed)
|
|
10894
|
+
break;
|
|
10895
|
+
const winner = memoryResnapshotState(args.db);
|
|
10896
|
+
if (!adoptedWinner && winner?.status === "resnapshotting" && typeof winner.generation === "string" && winner.generation.length > 0) {
|
|
10897
|
+
generation = winner.generation;
|
|
10898
|
+
adoptedWinner = true;
|
|
10899
|
+
break;
|
|
10900
|
+
}
|
|
10901
|
+
}
|
|
10902
|
+
let cursor = 0;
|
|
10903
|
+
while (true) {
|
|
10904
|
+
const response = await args.module.mirrorPull({
|
|
10905
|
+
domain: "memories",
|
|
10906
|
+
cursor,
|
|
10907
|
+
limit: args.limit,
|
|
10908
|
+
live_only: true
|
|
10909
|
+
});
|
|
10910
|
+
const page = response.page;
|
|
10911
|
+
if (page.domain !== "memories" || page.cursor !== cursor) {
|
|
10912
|
+
throw new Error("live memory resnapshot returned a mismatched page");
|
|
10913
|
+
}
|
|
10914
|
+
let staged = false;
|
|
10915
|
+
withPrivilegedWriter(args.db, () => {
|
|
10916
|
+
args.db.transaction(() => {
|
|
10917
|
+
staged = stageLiveMemorySnapshotPage(args.db, generation, page.rows);
|
|
10918
|
+
}).immediate();
|
|
10919
|
+
});
|
|
10920
|
+
if (!staged)
|
|
10921
|
+
return;
|
|
10922
|
+
if (!page.has_more)
|
|
10923
|
+
break;
|
|
10924
|
+
if (page.next_cursor <= cursor) {
|
|
10925
|
+
throw new Error("live memory resnapshot did not advance its cursor");
|
|
10926
|
+
}
|
|
10927
|
+
cursor = page.next_cursor;
|
|
10928
|
+
}
|
|
10929
|
+
withPrivilegedWriter(args.db, () => {
|
|
10930
|
+
args.db.transaction(() => {
|
|
10931
|
+
installStagedLiveMemorySnapshot(args.db, generation);
|
|
10932
|
+
}).immediate();
|
|
10933
|
+
});
|
|
10934
|
+
}
|
|
10935
|
+
async function pullAndApplyMirrorPageWithStatus(args) {
|
|
10936
|
+
if (!args.module.mirrorPull) {
|
|
10937
|
+
throw new Error("memory mirror consumer requires the mirror.pull module route");
|
|
10938
|
+
}
|
|
10939
|
+
const limit = Math.max(1, Math.min(args.limit ?? 100, 1000));
|
|
10940
|
+
if (args.domain === "memories") {
|
|
10941
|
+
await ensureLiveMemoryResnapshot({ db: args.db, module: args.module, limit });
|
|
10942
|
+
}
|
|
10943
|
+
const cursor = getMirrorCursor(args.db, args.domain);
|
|
10944
|
+
const response = await args.module.mirrorPull({
|
|
10945
|
+
domain: args.domain,
|
|
10946
|
+
cursor,
|
|
10947
|
+
limit
|
|
10948
|
+
});
|
|
10949
|
+
const nextCursor = applyMirrorPage({ db: args.db, page: response.page });
|
|
10950
|
+
return {
|
|
10951
|
+
cursor: nextCursor,
|
|
10952
|
+
hasMore: response.page.has_more,
|
|
10953
|
+
rowsApplied: response.page.rows.filter((row) => row.domain === args.domain && row.feed_seq > cursor).length
|
|
10954
|
+
};
|
|
10955
|
+
}
|
|
10956
|
+
async function drainMirrorPages(args) {
|
|
10957
|
+
const pageBudget = args.pageBudget === undefined ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.floor(args.pageBudget));
|
|
10958
|
+
let pagesPulled = 0;
|
|
10959
|
+
let rowsApplied = 0;
|
|
10960
|
+
let cursor = getMirrorCursor(args.db, args.domain);
|
|
10961
|
+
while (pagesPulled < pageBudget) {
|
|
10962
|
+
const priorCursor = cursor;
|
|
10963
|
+
const page = await pullAndApplyMirrorPageWithStatus(args);
|
|
10964
|
+
pagesPulled += 1;
|
|
10965
|
+
rowsApplied += page.rowsApplied;
|
|
10966
|
+
cursor = page.cursor;
|
|
10967
|
+
if (!page.hasMore) {
|
|
10968
|
+
return { cursor, pagesPulled, rowsApplied, complete: true, budgetExhausted: false };
|
|
10969
|
+
}
|
|
10970
|
+
if (cursor === priorCursor) {
|
|
10971
|
+
return { cursor, pagesPulled, rowsApplied, complete: false, budgetExhausted: false };
|
|
10972
|
+
}
|
|
10973
|
+
}
|
|
10974
|
+
return { cursor, pagesPulled, rowsApplied, complete: false, budgetExhausted: true };
|
|
10975
|
+
}
|
|
10194
10976
|
var mirrorFlights = new WeakMap;
|
|
10195
10977
|
|
|
10196
10978
|
// ../plugin/src/features/magic-context/message-fts-rowid-map.ts
|
|
@@ -18473,9 +19255,21 @@ function getPersistedCompactionMarkerState(db, sessionId) {
|
|
|
18473
19255
|
return parsePersistedCompactionMarkerState(row?.compaction_marker_state, row?.compaction_marker_target_end_message_id);
|
|
18474
19256
|
}
|
|
18475
19257
|
function setPersistedCompactionMarkerState(db, sessionId, state) {
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
19258
|
+
db.transaction(() => {
|
|
19259
|
+
ensureSessionMetaRow(db, sessionId);
|
|
19260
|
+
const previous = state === null ? getPersistedCompactionMarkerState(db, sessionId) ?? getDeferredClearedCompactionMarkerState(db, sessionId) : null;
|
|
19261
|
+
const json = state ? JSON.stringify(state) : previous ? JSON.stringify({ deferredClear: previous }) : "";
|
|
19262
|
+
db.prepare("UPDATE session_meta SET compaction_marker_state = ?, compaction_marker_target_end_message_id = ? WHERE session_id = ?").run(json, state?.targetEndMessageId ?? null, sessionId);
|
|
19263
|
+
})();
|
|
19264
|
+
}
|
|
19265
|
+
function getDeferredClearedCompactionMarkerState(db, sessionId) {
|
|
19266
|
+
const row = db.prepare("SELECT compaction_marker_state FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
19267
|
+
try {
|
|
19268
|
+
const parsed = JSON.parse(row?.compaction_marker_state || "null");
|
|
19269
|
+
return parsePersistedCompactionMarkerState(JSON.stringify(parsed?.deferredClear));
|
|
19270
|
+
} catch {
|
|
19271
|
+
return null;
|
|
19272
|
+
}
|
|
18479
19273
|
}
|
|
18480
19274
|
var MAX_STRIPPED_PLACEHOLDER_IDS = 4096;
|
|
18481
19275
|
function parseStrippedPlaceholderState(raw) {
|
|
@@ -21231,29 +22025,35 @@ function getPiContentDecisions(db, sessionId) {
|
|
|
21231
22025
|
return new Set(readEntries(row?.decisions ?? null).filter((value) => decodePiContentDecision(value) !== null));
|
|
21232
22026
|
}
|
|
21233
22027
|
function freezePiContentDecision(db, sessionId, kind, messageId) {
|
|
21234
|
-
|
|
21235
|
-
|
|
21236
|
-
|
|
21237
|
-
|
|
21238
|
-
|
|
21239
|
-
|
|
21240
|
-
|
|
21241
|
-
|
|
21242
|
-
|
|
21243
|
-
|
|
21244
|
-
|
|
21245
|
-
const
|
|
21246
|
-
|
|
21247
|
-
|
|
21248
|
-
|
|
21249
|
-
|
|
21250
|
-
|
|
21251
|
-
|
|
21252
|
-
|
|
21253
|
-
|
|
21254
|
-
|
|
21255
|
-
|
|
21256
|
-
|
|
22028
|
+
try {
|
|
22029
|
+
ensureSessionMetaRow(db, sessionId);
|
|
22030
|
+
const entry = encodePiContentDecision(kind, messageId);
|
|
22031
|
+
return db.transaction(() => {
|
|
22032
|
+
for (let attempt = 0;attempt < 5; attempt++) {
|
|
22033
|
+
const row = db.prepare("SELECT merged_reasoning_stripped_ids AS decisions FROM session_meta WHERE session_id = ?").get(sessionId);
|
|
22034
|
+
const current = readEntries(row.decisions);
|
|
22035
|
+
if (current.includes(entry))
|
|
22036
|
+
return true;
|
|
22037
|
+
const ownsTag = db.prepare("SELECT 1 FROM tags WHERE session_id = ? AND message_id = ? LIMIT 1");
|
|
22038
|
+
const ownsMessage = db.prepare("SELECT 1 FROM tags WHERE session_id = ? AND message_id >= ? AND message_id < ? LIMIT 1");
|
|
22039
|
+
const kept = current.filter((value) => {
|
|
22040
|
+
const decision = decodePiContentDecision(value);
|
|
22041
|
+
return !decision || !!(decision[0] === "seam-temporal-strip" ? ownsMessage.get(sessionId, `${decision[1]}:p`, `${decision[1]}:q`) : ownsTag.get(sessionId, decision[1]));
|
|
22042
|
+
});
|
|
22043
|
+
if (kept.filter((value) => decodePiContentDecision(value) !== null).length >= PI_CONTENT_DECISION_LIMIT)
|
|
22044
|
+
return false;
|
|
22045
|
+
kept.push(entry);
|
|
22046
|
+
const result = db.prepare("UPDATE session_meta SET merged_reasoning_stripped_ids = ? WHERE session_id = ? AND merged_reasoning_stripped_ids IS ?").run(JSON.stringify(kept), sessionId, row.decisions);
|
|
22047
|
+
if (result.changes > 0)
|
|
22048
|
+
return true;
|
|
22049
|
+
}
|
|
22050
|
+
return false;
|
|
22051
|
+
}).immediate();
|
|
22052
|
+
} catch (error) {
|
|
22053
|
+
if (/database (?:table )?is locked|sqlite_(busy|locked)/i.test(String(error)))
|
|
22054
|
+
return false;
|
|
22055
|
+
throw error;
|
|
22056
|
+
}
|
|
21257
22057
|
}
|
|
21258
22058
|
|
|
21259
22059
|
// ../plugin/src/features/magic-context/storage-native-replay.ts
|
|
@@ -39663,4 +40463,4 @@ function registerMagicContextTools(pi, opts) {
|
|
|
39663
40463
|
}
|
|
39664
40464
|
}
|
|
39665
40465
|
|
|
39666
|
-
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, migrateMagicContextConfigLocations, withContentLanguageDirective, withMigrationLanguageDirective, buildPrimaryLanguageDirective, parseCron, nextOccurrence, nextDueAtMs, canonicalModelIdentity, piModelRefToCanonical, resolveModelRefForPi, modelRefLookupOrder, ompModelRefToCanonical, resolveModelRefForOmp, resolveModelConfigValue, resolveModelConfigOrDefault, DEFAULT_HISTORIAN_TIMEOUT_MS, getProtectedTokensTierOverrides, sanitizeDiagnosticText, hasShareabilitySensitiveText, FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, createFailClosedController, setHarness, getHarness, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageResolution, getMagicContextStorageDir, log, sessionLog, flushLogger, ProjectIdentityError, resolveProjectIdentityStrict, resolveProjectIdentity, resolveProjectIdentityForSession, beginBootQuietPeriod, scheduleAfterBootQuiet, CTX_REDUCE_KEEP, newestCtxReduceTagNumbers, textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, preloadTokenizer, estimateTokens, normalizeText, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isRecord, estimateImageTokensFromDataUrl, normalizeTodoStateJson, buildSyntheticTodoPart, stripChannel1ReminderSpans, effectiveTailHygiene, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, decideChannel1, evaluateChannel2, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, planEmergencyDrop, updateTagByteSize, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, updateTagInputByteSize, updateTagTokenCount, getPersistedToolTagAccounting, getAllStatusTagTokenTotalsFlat, updateTagInputTokenCount, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, updateTagDropMode, updateCavemanDepth, hasPiFallbackMessageTags, findAdoptableFallbackTags, hasPiFallbackToolOwnerTags, findPiFallbackToolOwnerTags, adoptPiFallbackToolOwnerTag, adoptPiFallbackMessageTag, getMaxTagNumberBySession, getAssignableTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getTagsForPendingOperations, getTagsByNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, resolveOpenCodeDbPath, openCodeDbPathExists, recordOpenCodeDbReadFailure, clearOpenCodeDbReadFailure, claimOpenCodeDbDiagnosticOnce, Database, closeQuietly, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, invalidateTrueRawTokenCache, DROPPED_INPUT_MESSAGE, droppedInputMarker, containsDroppedInputPlaceholder, isEditTool, applyEditMarkerToInput, setRawMessageProvider, withRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, getCachedAbsoluteMessageCount, primeInMemoryTailRawMessageCache, getRawSessionMessageCount, getRawSessionTagKeysThrough, getLegacyProtectedTailStartOrdinal, readSessionChunk, logSlowWriteTransaction, clearCompressionDepth, clearCompressionDepthRange, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordSessionProjectIdentity, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, persistCachedM0, clearCachedM0M1, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getModuleNoteEvaluationBridge, getContextStoreUuid, parseCompartmentOutput, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, sourceNameForMemory, computeWorkspaceEpochFingerprint, bumpEpochsForWorkspaceMembers, readProjectDocsCanonical, encodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, getErrorMessage, describeError, piHarnessKindFromExecutable, setStoragePrivatePermissionEnforcement, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, applySqliteTuningPragmas, runSqliteOptimize, openDatabase, openDatabaseAsync, queueM0Mutation, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, computeProtectionWindow, readEpochFloorSnapshot, getProtectionWindowForSession, isProviderOverflowFailClosedProven, describeProtectedTailDrainBudgetSkip, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, NEWEST_REASONING_BEARING_ASSISTANT, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, thinkingBindingRecoveryFrozenId, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, getSessionsWithPendingPiMarker, setSessionWorkMetrics, getSessionWorkMetrics, resolveEpochFloorForPass, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, getNotes, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, BoundedSessionMap, MIN_PLAUSIBLE_CONTEXT_LIMIT, reloadWindowOverlay, getWindowOverlay, resolveWindowOverlayFacts, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, isSaneLimit, resolveOutputReserve, getSdkContextLimit, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findLastModelKeyFromBranch, convertEntriesToRawMessages, convertEntriesToRawMessagePage, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, invalidateMemory, computeNormalizedHash, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, insertMemory, getMemoryByHash, getMemoriesByProject, getMemoriesByProjects, getMaxMemoryIdForProjects, getAllActiveMemoriesForMigration, getMemoryById, setMemoryClassification, archiveMemory, deleteMemory, getMemoryCount, getMemoryCountsByStatus, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, formatSynapseLaneDescriptor, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, cosineSimilarity, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, describeShadowBackfillWriteRefusal, contentSha256, sweepStaleEmbeddingIdentitiesForProject, enqueueShadowEmbeddingItems, getProjectEmbeddingSnapshot, getProjectChunkEmbeddingModelId, getProjectEmbeddingMaxInputTokens, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, indexCommitsForProject, embedUnembeddedCommits, loadPiConfig, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, temporalMarkerPrefix, clearInjectionCache, getVisibleMemoryIds, renderMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, unifiedSearch, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|
|
40466
|
+
export { COMPACTION_ENABLED_PATH, isDreamerRunnable, isCompactionEnabled, migrateMagicContextConfigLocations, withContentLanguageDirective, withMigrationLanguageDirective, buildPrimaryLanguageDirective, parseCron, nextOccurrence, nextDueAtMs, canonicalModelIdentity, piModelRefToCanonical, resolveModelRefForPi, modelRefLookupOrder, ompModelRefToCanonical, resolveModelRefForOmp, resolveModelConfigValue, resolveModelConfigOrDefault, DEFAULT_HISTORIAN_TIMEOUT_MS, getProtectedTokensTierOverrides, sanitizeDiagnosticText, hasShareabilitySensitiveText, FAIL_CLOSED_DOCTOR_COMMAND, formatFailClosedBlockingMessage, createFailClosedBlockingError, isFailClosedBlockingError, shouldBypassFailClosedBlock, createFailClosedController, setHarness, getHarness, ensureCortexKitArtifactGitignore, getProjectMagicContextHistorianDir, getMagicContextStorageResolution, getMagicContextStorageDir, log, sessionLog, flushLogger, ProjectIdentityError, resolveProjectIdentityStrict, resolveProjectIdentity, resolveProjectIdentityForSession, beginBootQuietPeriod, scheduleAfterBootQuiet, CTX_REDUCE_KEEP, newestCtxReduceTagNumbers, textMentionsRecentCommit, hasMeaningfulUserText, extractTexts, extractToolCallSummaries, preloadTokenizer, estimateTokens, normalizeText, stripWellFormedLeadingTagPrefix, stripPersistedAssistantText, byteSize, stripTagPrefix, peelLeadingMcTagNotation, prependTag, isRecord, estimateImageTokensFromDataUrl, normalizeTodoStateJson, buildSyntheticTodoPart, stripChannel1ReminderSpans, effectiveTailHygiene, CHANNEL1_SENTINEL, CHANNEL1_FLOOR_TOKENS, decideChannel1, evaluateChannel2, reclaimableToolOutputCount, buildChannel2Reminder, buildChannel1Reminder, planEmergencyDrop, updateTagByteSize, getRecentTagOwnerMessageIds, AGE_RECLAIM_MIN_TOKENS, getOldestActiveUnprotectedToolTags, getActiveToolTagsForAgeReclaim, getTriggerTagTokenUpperBound, updateTagInputByteSize, updateTagTokenCount, getPersistedToolTagAccounting, getAllStatusTagTokenTotalsFlat, updateTagInputTokenCount, tagTokenCountIsNull, backfillTagTokenCounts, insertTag, updateTagStatus, updateTagDropMode, updateCavemanDepth, hasPiFallbackMessageTags, findAdoptableFallbackTags, hasPiFallbackToolOwnerTags, findPiFallbackToolOwnerTags, adoptPiFallbackToolOwnerTag, adoptPiFallbackMessageTag, getMaxTagNumberBySession, getAssignableTagNumberByMessageId, deriveTagLoadFloor, getTagsBySession, getActiveTagsBySession, getTagsForPendingOperations, getTagsByNumbers, getDroppedTagsByNumbers, getMaxDroppedTagNumber, getToolTagNumberByOwner, getNullOwnerToolTag, adoptNullOwnerToolTag, resolveOpenCodeDbPath, openCodeDbPathExists, recordOpenCodeDbReadFailure, clearOpenCodeDbReadFailure, claimOpenCodeDbDiagnosticOnce, Database, closeQuietly, completedToolArcCrossesBoundary, estimateTrueRawMessageTokens, buildToolArcs, fenceBoundaryForCompletedToolArcs, fenceBoundaryForToolArcs, buildTrueRawTokenIndex, computeRawRangeFingerprint, invalidateTrueRawTokenCache, DROPPED_INPUT_MESSAGE, droppedInputMarker, containsDroppedInputPlaceholder, isEditTool, applyEditMarkerToInput, setRawMessageProvider, withRawMessageProvider, cleanUserText, withRawSessionMessageCache, readRawSessionMessages, primeTailRawMessageCache, getCachedAbsoluteMessageCount, primeInMemoryTailRawMessageCache, getRawSessionMessageCount, getRawSessionTagKeysThrough, getLegacyProtectedTailStartOrdinal, readSessionChunk, logSlowWriteTransaction, clearCompressionDepth, clearCompressionDepthRange, getMessageIndexSourceIdentity, isMessageIndexSourceCurrent, getLastIndexedOrdinal, getMessageIndexReconciliationStartOrdinal, isMessageIndexReconciledThrough, indexSingleMessage, indexMessagesAfterOrdinal, sweepOrphanedOpenCodeMessageIndexes, recordSessionProjectIdentity, COMPARTMENT_LEASE_RENEWAL_MS, acquireCompartmentLease, renewCompartmentLease, releaseCompartmentLease, releaseCompartmentLeaseBestEffort, isCompartmentLeaseHeld, isNoContentCompartment, HAS_COMPARTMENT_CONTENT_SQL, persistCachedM0, clearCachedM0M1, getCompartments, getLastCompartmentEndMessage, getLastCompartmentEndMessageId, getCompartmentsByEndMessageId, appendCompartments, saveRecompStagingPass, getRecompStaging, clearRecompStaging, getRecompPartialRange, setRecompPartialRange, escapeXmlAttr, escapeXmlContent, getModuleNoteEvaluationBridge, getContextStoreUuid, drainMirrorPages, parseCompartmentOutput, resolveWorkspaceShareCategories, resolveWorkspaceIdentitySet, expandWorkspaceIdentitySetWithAliases, sourceNameForMemory, computeWorkspaceEpochFingerprint, bumpEpochsForWorkspaceMembers, readProjectDocsCanonical, encodePiContentDecision, getPiContentDecisions, freezePiContentDecision, getNativeReplayState, saveNativeToolInputs, addNativeReasoningIds, copySessionStateForClone, getErrorMessage, describeError, piHarnessKindFromExecutable, setStoragePrivatePermissionEnforcement, getSchemaFenceRejection, getMigrationOnOpenRefusal, LATEST_SUPPORTED_VERSION, getDatabasePath, getPersistedSchemaVersion, setSqlitePragmaConfig, applySqliteTuningPragmas, runSqliteOptimize, openDatabase, openDatabaseAsync, queueM0Mutation, getMaxM0MutationId, queueMemoryMutation, getMemoryMutationsForRender, getMemoryMutationsForRenderByProjects, getMaxMemoryMutationId, getMaxMemoryMutationIdForProjects, MAX_EXECUTE_THRESHOLD, escalationBands, computeProtectionWindow, readEpochFloorSnapshot, getProtectionWindowForSession, isProviderOverflowFailClosedProven, describeProtectedTailDrainBudgetSkip, loadProtectedTailMeta, markProtectedTailPolicyV3Seeded, recordProtectedTailPublicationFloor, recordProtectedTailNoEligibleHead, getWrapupInProgressState, isWrapupInProgress, acquireWrapupInProgress, updateWrapupInProgress, releaseWrapupInProgress, resolveCompactionModeRecord, getCompactionModeRecord, setCompactionModeRecord, reserveProtectedTailDrainTokens, clearEmergencyDrainLatch, recordHistorianDrainFailure, clearHistorianDrainFailure, rollbackProtectedTailDrainReservation, clearPersistedReasoningWatermark, getEmergencyInputSample, setEmergencyDropSample, clearEmergencyDropSample, getLastNudgeUndropped, setLastNudgeUndropped, getChannel1NudgeState, setChannel1NudgeState, markChannel1PostReduceGracePending, captureChannel1PostReduceGraceBaseline, getChannel2NudgeState, getChannel2NudgeClaim, setChannel2NudgeState, casChannel2NudgeState, claimChannel2NudgeState, casChannel2NudgeClaim, getPersistedNoteNudge, setPersistedNoteNudgeTrigger, setPersistedNoteNudgeTriggerMessageId, getNoteNudgeAnchors, getAutoSearchHintDecisions, deliverNoteNudgeAtomic, appendAutoSearchHintDecision, pruneNoteNudgeAnchors, pruneAutoSearchHintDecisions, getPersistedTodoSyntheticAnchor, setPersistedTodoSyntheticAnchor, clearPersistedTodoSyntheticAnchor, getNoteLastReadAt, incrementHistorianFailure, clearHistorianFailureState, getOverflowState, recordOverflowDetected, clearEmergencyRecovery, clearDetectedContextLimit, getStrippedPlaceholderIds, applyStrippedPlaceholderDelta, NEWEST_REASONING_BEARING_ASSISTANT, THINKING_BINDING_RECOVERY_FROZEN_PREFIX, thinkingBindingRecoveryFrozenId, getThinkingBindingRecoveryTarget, armThinkingBindingRecovery, clearThinkingBindingRecoveryIf, getMergedReasoningStrippedIds, addMergedReasoningStrippedIds, getProcessedImageStrippedIds, addProcessedImageStrippedIds, getPendingCompactionMarkerState, clearPendingCompactionMarkerStateIf, getPendingPiCompactionMarkerState, setPendingPiCompactionMarkerState, clearPendingPiCompactionMarkerStateIf, getSessionsWithPendingPiMarker, setSessionWorkMetrics, getSessionWorkMetrics, resolveEpochFloorForPass, getOrCreateSessionMeta, updateSessionMeta, advanceToolReclaimWatermark, retryPendingSessionCleanups, retryPendingRustSessionCleanupsForProject, getNotes, getSessionNotes, getPendingSmartNotes, getReadySmartNotes, markNoteReady, markNoteChecked, queuePendingOp, getPendingOps, getPendingOpsCount, clearPendingOps, removePendingOp, PRIMER_CANDIDATE_TTL_MS, PRIMER_CANDIDATE_MAX_AGE_MS, primerOccurrenceKey, primerOccurrenceUtcDay, insertPrimerCandidates, updatePrimerCandidateEmbedding, getPrimerCandidatesByIds, getPrimerCandidatesForPromotion, countPrimerCandidatesForProject, getActivePrimers, createPrimer, updatePrimerSupport, updatePrimerAnswer, GLOBAL_USER_PROFILE_PROJECT_PATH, getProjectState, bumpProjectUserProfileVersion, saveSourceContent, getSourceContents, recordSubagentInvocation, getLatestHistorianInvocationId, BoundedSessionMap, MIN_PLAUSIBLE_CONTEXT_LIMIT, reloadWindowOverlay, getWindowOverlay, resolveWindowOverlayFacts, deriveWindowGeometry, hasTrustedAbsoluteWall, applyProvenInputFloor, formatWindowDerivationLine, isSaneLimit, resolveOutputReserve, getSdkContextLimit, formatConfigParseStatusLine, formatConfigParseNotice, claimConfigParseFailuresOnce, promptSurfaceHashMaterial, createPromptSurfaceRuntime, createPromptSurfaceGuidanceEpochCache, SYNTH_USER_ID_PREFIX, resolvePiStableId, readPiSessionSnapshot, readPiSessionMessages, readPiSessionMessagePage, findLastModelKeyFromBranch, convertEntriesToRawMessages, convertEntriesToRawMessagePage, computeCueContentHash, hasMuralCueColumns, getMuralCueState, memoryNeedsCue, setMuralCue, recordMuralCueRejection, invalidateMemory, computeNormalizedHash, hasMemoryShareableColumn, hasMemoryClassifiedAtColumn, getUnclassifiedMemoryIds, insertMemory, getMemoryByHash, getMemoriesByProject, getMemoriesByProjects, getMaxMemoryIdForProjects, getAllActiveMemoriesForMigration, getMemoryById, setMemoryClassification, archiveMemory, deleteMemory, getMemoryCount, getMemoryCountsByStatus, USER_MEMORY_CANDIDATE_TTL_MS, insertUserMemoryCandidates, getUserMemoryCandidates, deleteUserMemoryCandidates, pruneExpiredUserMemoryCandidates, insertUserMemory, getActiveUserMemories, updateUserMemoryContent, dismissUserMemory, formatSynapseLaneDescriptor, buildCanonicalChunkTextFromFts, buildCompartmentSummaryFallbackText, canonicalizeInMemoryChunkTextForEmbedding, chunkCanonicalText, chunkEmbeddingWindowsAreCurrent, replaceCompartmentChunkEmbeddings, cosineSimilarity, GIT_SWEEP_LEASE_RENEWAL_MS, acquireGitSweepLease, renewGitSweepLease, markGitSweepSuccessAndRelease, parkGitSweepNonIndexable, releaseGitSweepLease, describeShadowBackfillWriteRefusal, contentSha256, sweepStaleEmbeddingIdentitiesForProject, enqueueShadowEmbeddingItems, getProjectEmbeddingSnapshot, getProjectChunkEmbeddingModelId, getProjectEmbeddingMaxInputTokens, embedTextForProject, embedBatchForProject, embedItemsForProject, embedUnembeddedMemoriesForProject, drainCommitBacklogForProject, embedSessionCompartmentChunks, getEmbeddingCoverageStatus, promoteSessionFactsDurable, embedPromotedFacts, recordMemoryMapping, recordMemoryVerifications, getUnmappedMemoryIds, clearMemoryVerifications, getMemoryVerifications, resolveGitTopLevel, readGitHead, readGitChangedFilesSince, readGitFileChangeTimesSince, verificationFileExists, normalizeVerificationFiles, isDirectiveShapedProjectRule, takeCurateSafetyRefusalCount, wakePlaneStatus, indexCommitsForProject, embedUnembeddedCommits, loadPiConfig, ensureProjectRegisteredFromPiDirectory, resolvePiHarnessDetection, resolvePiHarnessKind, resolveMuralWire, updateCompactionMarkerAfterPublication, COMPARTMENT_RENDER_EPOCH, encodeCachedM0UpgradeIdentity, decodeCachedM0UpgradeIdentity, DEFAULT_HISTORY_BUDGET_TOKENS, renderCompartmentAtTier, renderDecayedCompartments, extractM0Block, TEMPORAL_MARKER_PATTERN, temporalMarkerPrefix, clearInjectionCache, getVisibleMemoryIds, renderMemoryBlock, DEFAULT_MEMORY_BUDGET_TOKENS, DEFAULT_USER_PROFILE_BUDGET_TOKENS, trimMemoriesToBudgetV2, trimWorkspaceMemoriesToBudgetV2, trimUserMemoriesToBudget, renderMemoryBlockV2, stripMemoryMuralBlock, unifiedSearch, rememberTodowriteToolCallTodos, parseTodos, setTodoSnapshot, registerTodoOverlay, registerTodoStateLifecycle, syncCtxMemoryToolEnabled, registerMagicContextTools };
|