@cleocode/cleo 2026.4.45 → 2026.4.47
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/cli/index.js +226 -141
- package/dist/cli/index.js.map +4 -4
- package/package.json +8 -8
package/dist/cli/index.js
CHANGED
|
@@ -11473,14 +11473,14 @@ function reconcileJournal(nativeDb, migrationsFolder, existenceTable, logSubsyst
|
|
|
11473
11473
|
const dbHashes = new Set(dbEntries.map((e) => e.hash));
|
|
11474
11474
|
const allLocalHashesPresentInDb = localMigrations.every((m2) => dbHashes.has(m2.hash));
|
|
11475
11475
|
if (allLocalHashesPresentInDb) {
|
|
11476
|
-
const
|
|
11477
|
-
|
|
11476
|
+
const log13 = getLogger(logSubsystem);
|
|
11477
|
+
log13.debug(
|
|
11478
11478
|
{ extra: orphanedEntries.length },
|
|
11479
11479
|
`Migration journal has ${orphanedEntries.length} entries for migrations not known to this install (DB is ahead). Skipping reconciliation.`
|
|
11480
11480
|
);
|
|
11481
11481
|
} else {
|
|
11482
|
-
const
|
|
11483
|
-
|
|
11482
|
+
const log13 = getLogger(logSubsystem);
|
|
11483
|
+
log13.warn(
|
|
11484
11484
|
{ orphaned: orphanedEntries.length },
|
|
11485
11485
|
`Detected stale migration journal entries from a previous CLEO version. Reconciling.`
|
|
11486
11486
|
);
|
|
@@ -11511,8 +11511,8 @@ function reconcileJournal(nativeDb, migrationsFolder, existenceTable, logSubsyst
|
|
|
11511
11511
|
return cols.some((c) => c.name === column);
|
|
11512
11512
|
});
|
|
11513
11513
|
if (allColumnsExist) {
|
|
11514
|
-
const
|
|
11515
|
-
|
|
11514
|
+
const log13 = getLogger(logSubsystem);
|
|
11515
|
+
log13.warn(
|
|
11516
11516
|
{ migration: migration.name, columns: alterMatches },
|
|
11517
11517
|
`Detected partially-applied migration ${migration.name} \u2014 columns exist but journal entry missing. Auto-reconciling.`
|
|
11518
11518
|
);
|
|
@@ -11530,8 +11530,8 @@ function reconcileJournal(nativeDb, migrationsFolder, existenceTable, logSubsyst
|
|
|
11530
11530
|
for (const entry of unnamedEntries) {
|
|
11531
11531
|
const migrationName = hashToName.get(entry.hash);
|
|
11532
11532
|
if (!migrationName) continue;
|
|
11533
|
-
const
|
|
11534
|
-
|
|
11533
|
+
const log13 = getLogger(logSubsystem);
|
|
11534
|
+
log13.warn(
|
|
11535
11535
|
{ id: entry.id, hash: entry.hash, name: migrationName },
|
|
11536
11536
|
`Backfilling missing name on journal entry id=${entry.id} \u2014 Drizzle v1 beta requires name for applied-migration detection.`
|
|
11537
11537
|
);
|
|
@@ -11575,8 +11575,8 @@ function ensureColumns(nativeDb, tableName, requiredColumns, logSubsystem) {
|
|
|
11575
11575
|
const existingCols = new Set(columns.map((c) => c.name));
|
|
11576
11576
|
for (const req of requiredColumns) {
|
|
11577
11577
|
if (!existingCols.has(req.name)) {
|
|
11578
|
-
const
|
|
11579
|
-
|
|
11578
|
+
const log13 = getLogger(logSubsystem);
|
|
11579
|
+
log13.warn(
|
|
11580
11580
|
{ column: req.name },
|
|
11581
11581
|
`Adding missing column ${tableName}.${req.name} via ALTER TABLE`
|
|
11582
11582
|
);
|
|
@@ -13974,7 +13974,7 @@ function getDbPath(cwd) {
|
|
|
13974
13974
|
return join10(getCleoDirAbsolute(cwd), DB_FILENAME2);
|
|
13975
13975
|
}
|
|
13976
13976
|
async function autoRecoverFromBackup(nativeDb, dbPath, cwd) {
|
|
13977
|
-
const
|
|
13977
|
+
const log13 = getLogger("sqlite");
|
|
13978
13978
|
try {
|
|
13979
13979
|
const countResult = nativeDb.prepare("SELECT COUNT(*) as cnt FROM tasks").get();
|
|
13980
13980
|
const taskCount = countResult?.cnt ?? 0;
|
|
@@ -13995,7 +13995,7 @@ async function autoRecoverFromBackup(nativeDb, dbPath, cwd) {
|
|
|
13995
13995
|
if (backupTaskCount < MIN_BACKUP_TASK_COUNT) {
|
|
13996
13996
|
return;
|
|
13997
13997
|
}
|
|
13998
|
-
|
|
13998
|
+
log13.warn(
|
|
13999
13999
|
{ dbPath, backupPath: newestBackup.path, backupTasks: backupTaskCount },
|
|
14000
14000
|
`Empty database detected with ${backupTaskCount}-task backup available. Auto-recovering from backup. This likely happened because git-tracked WAL/SHM files were overwritten during a branch switch (T5188).`
|
|
14001
14001
|
);
|
|
@@ -14013,7 +14013,7 @@ async function autoRecoverFromBackup(nativeDb, dbPath, cwd) {
|
|
|
14013
14013
|
const tempPath = dbPath + ".recovery-tmp";
|
|
14014
14014
|
copyFileSync4(newestBackup.path, tempPath);
|
|
14015
14015
|
renameSync(tempPath, dbPath);
|
|
14016
|
-
|
|
14016
|
+
log13.info(
|
|
14017
14017
|
{ dbPath, backupPath: newestBackup.path, restoredTasks: backupTaskCount },
|
|
14018
14018
|
"Database auto-recovered from backup successfully."
|
|
14019
14019
|
);
|
|
@@ -14023,7 +14023,7 @@ async function autoRecoverFromBackup(nativeDb, dbPath, cwd) {
|
|
|
14023
14023
|
runMigrations(restoredNativeDb, restoredDb);
|
|
14024
14024
|
_db = restoredDb;
|
|
14025
14025
|
} catch (err) {
|
|
14026
|
-
|
|
14026
|
+
log13.error({ err, dbPath }, "Auto-recovery from backup failed. Continuing with empty database.");
|
|
14027
14027
|
}
|
|
14028
14028
|
}
|
|
14029
14029
|
async function getDb(cwd) {
|
|
@@ -14057,7 +14057,7 @@ async function getDb(cwd) {
|
|
|
14057
14057
|
const { execFileSync: execFileSync19 } = await import("node:child_process");
|
|
14058
14058
|
const gitCwd = resolve3(dbPath, "..", "..");
|
|
14059
14059
|
const filesToCheck = [dbPath, dbPath + "-wal", dbPath + "-shm"];
|
|
14060
|
-
const
|
|
14060
|
+
const log13 = getLogger("sqlite");
|
|
14061
14061
|
for (const fileToCheck of filesToCheck) {
|
|
14062
14062
|
try {
|
|
14063
14063
|
execFileSync19("git", ["ls-files", "--error-unmatch", fileToCheck], {
|
|
@@ -14066,7 +14066,7 @@ async function getDb(cwd) {
|
|
|
14066
14066
|
});
|
|
14067
14067
|
const basename19 = fileToCheck.split(/[\\/]/).pop();
|
|
14068
14068
|
const relPath = fileToCheck.replace(gitCwd + sep, "");
|
|
14069
|
-
|
|
14069
|
+
log13.warn(
|
|
14070
14070
|
{ path: fileToCheck },
|
|
14071
14071
|
`${basename19} is tracked by project git \u2014 this risks data loss on branch switch. Resolution (ADR-013 \xA79): \`git rm --cached ${relPath}\` and rely on \`.cleo/backups/sqlite/\` snapshots + \`cleo backup add\` for recovery.`
|
|
14072
14072
|
);
|
|
@@ -15260,11 +15260,18 @@ var init_cross_db_cleanup = __esm({
|
|
|
15260
15260
|
|
|
15261
15261
|
// packages/core/src/store/db-helpers.ts
|
|
15262
15262
|
import { eq as eq4, inArray as inArray2 } from "drizzle-orm";
|
|
15263
|
-
async function upsertTask(db, row, archiveFields) {
|
|
15263
|
+
async function upsertTask(db, row, archiveFields, allowOrphanParent = false) {
|
|
15264
15264
|
if (row.parentId) {
|
|
15265
15265
|
const parent = await db.select({ id: tasks.id }).from(tasks).where(eq4(tasks.id, row.parentId)).limit(1).all();
|
|
15266
15266
|
if (parent.length === 0) {
|
|
15267
|
-
|
|
15267
|
+
if (allowOrphanParent) {
|
|
15268
|
+
row = { ...row, parentId: null };
|
|
15269
|
+
} else {
|
|
15270
|
+
log2.warn(
|
|
15271
|
+
{ taskId: row.id, parentId: row.parentId },
|
|
15272
|
+
"upsertTask: parentId references a non-existent task \u2014 parent relationship may be lost"
|
|
15273
|
+
);
|
|
15274
|
+
}
|
|
15268
15275
|
}
|
|
15269
15276
|
}
|
|
15270
15277
|
const values = archiveFields ? { ...row, ...archiveFields, status: "archived" } : row;
|
|
@@ -15408,10 +15415,13 @@ async function loadRelationsForTasks(db, tasks2) {
|
|
|
15408
15415
|
}
|
|
15409
15416
|
}
|
|
15410
15417
|
}
|
|
15418
|
+
var log2;
|
|
15411
15419
|
var init_db_helpers = __esm({
|
|
15412
15420
|
"packages/core/src/store/db-helpers.ts"() {
|
|
15413
15421
|
"use strict";
|
|
15422
|
+
init_logger();
|
|
15414
15423
|
init_tasks_schema();
|
|
15424
|
+
log2 = getLogger("db-helpers");
|
|
15415
15425
|
}
|
|
15416
15426
|
});
|
|
15417
15427
|
|
|
@@ -15745,7 +15755,7 @@ async function createSqliteDataAccessor(cwd) {
|
|
|
15745
15755
|
archiveReason: taskAny.archiveReason ?? "completed",
|
|
15746
15756
|
cycleTimeDays: taskAny.cycleTimeDays ?? null
|
|
15747
15757
|
};
|
|
15748
|
-
await upsertTask(db, row, archiveFields);
|
|
15758
|
+
await upsertTask(db, row, archiveFields, true);
|
|
15749
15759
|
depBatch.push({ taskId: task.id, deps: task.depends ?? [] });
|
|
15750
15760
|
}
|
|
15751
15761
|
await batchUpdateDependencies(db, depBatch, validDepIds);
|
|
@@ -16758,7 +16768,7 @@ async function ensureSequenceValid(cwd, options) {
|
|
|
16758
16768
|
if (!options?.validateSequence) return;
|
|
16759
16769
|
const check2 = await checkSequence(cwd);
|
|
16760
16770
|
if (!check2.valid) {
|
|
16761
|
-
|
|
16771
|
+
log3.warn({ counter: check2.counter, maxId: check2.maxIdInData }, "Sequence behind, repairing");
|
|
16762
16772
|
const repair = await repairSequence(cwd);
|
|
16763
16773
|
if (!repair.repaired && options.strict) {
|
|
16764
16774
|
throw new DataSafetyError(`Sequence repair failed: ${repair.message}`, "SEQUENCE_INVALID", {
|
|
@@ -16775,7 +16785,7 @@ async function checkpoint(context, cwd, options) {
|
|
|
16775
16785
|
stats.checkpoints++;
|
|
16776
16786
|
stats.lastCheckpoint = /* @__PURE__ */ new Date();
|
|
16777
16787
|
} catch (err) {
|
|
16778
|
-
|
|
16788
|
+
log3.warn({ err }, "Checkpoint failed (non-fatal)");
|
|
16779
16789
|
}
|
|
16780
16790
|
vacuumIntoBackup({ cwd }).catch(() => {
|
|
16781
16791
|
});
|
|
@@ -16837,7 +16847,7 @@ async function safeAppendLog(accessor, entry, cwd, options) {
|
|
|
16837
16847
|
stats.writes++;
|
|
16838
16848
|
await checkpoint("log entry", cwd, opts);
|
|
16839
16849
|
}
|
|
16840
|
-
var
|
|
16850
|
+
var log3, DataSafetyError, DEFAULT_SAFETY, stats;
|
|
16841
16851
|
var init_data_safety_central = __esm({
|
|
16842
16852
|
"packages/core/src/store/data-safety-central.ts"() {
|
|
16843
16853
|
"use strict";
|
|
@@ -16845,7 +16855,7 @@ var init_data_safety_central = __esm({
|
|
|
16845
16855
|
init_sequence();
|
|
16846
16856
|
init_git_checkpoint();
|
|
16847
16857
|
init_sqlite_backup();
|
|
16848
|
-
|
|
16858
|
+
log3 = getLogger("data-safety");
|
|
16849
16859
|
DataSafetyError = class extends Error {
|
|
16850
16860
|
constructor(message, code, context) {
|
|
16851
16861
|
super(message);
|
|
@@ -16885,7 +16895,7 @@ function isSafetyDisabled() {
|
|
|
16885
16895
|
}
|
|
16886
16896
|
function wrapWithSafety(accessor, cwd) {
|
|
16887
16897
|
if (isSafetyDisabled()) {
|
|
16888
|
-
|
|
16898
|
+
log4.warn(
|
|
16889
16899
|
"Safety disabled - emergency mode (CLEO_DISABLE_SAFETY=true). Data integrity checks bypassed."
|
|
16890
16900
|
);
|
|
16891
16901
|
return accessor;
|
|
@@ -16906,13 +16916,13 @@ function getSafetyStatus() {
|
|
|
16906
16916
|
enabled: true
|
|
16907
16917
|
};
|
|
16908
16918
|
}
|
|
16909
|
-
var
|
|
16919
|
+
var log4, SafetyDataAccessor;
|
|
16910
16920
|
var init_safety_data_accessor = __esm({
|
|
16911
16921
|
"packages/core/src/store/safety-data-accessor.ts"() {
|
|
16912
16922
|
"use strict";
|
|
16913
16923
|
init_logger();
|
|
16914
16924
|
init_data_safety_central();
|
|
16915
|
-
|
|
16925
|
+
log4 = getLogger("data-safety");
|
|
16916
16926
|
SafetyDataAccessor = class {
|
|
16917
16927
|
/** The underlying accessor being wrapped. */
|
|
16918
16928
|
inner;
|
|
@@ -16936,7 +16946,7 @@ var init_safety_data_accessor = __esm({
|
|
|
16936
16946
|
...config2
|
|
16937
16947
|
};
|
|
16938
16948
|
if (this.config.verbose) {
|
|
16939
|
-
|
|
16949
|
+
log4.debug({ engine: inner.engine }, "SafetyDataAccessor initialized");
|
|
16940
16950
|
}
|
|
16941
16951
|
}
|
|
16942
16952
|
/** The storage engine backing this accessor. */
|
|
@@ -16948,7 +16958,7 @@ var init_safety_data_accessor = __esm({
|
|
|
16948
16958
|
*/
|
|
16949
16959
|
logVerbose(message) {
|
|
16950
16960
|
if (this.config.verbose) {
|
|
16951
|
-
|
|
16961
|
+
log4.debug(message);
|
|
16952
16962
|
}
|
|
16953
16963
|
}
|
|
16954
16964
|
/**
|
|
@@ -20579,6 +20589,27 @@ var init_intelligence = __esm({
|
|
|
20579
20589
|
}
|
|
20580
20590
|
});
|
|
20581
20591
|
|
|
20592
|
+
// packages/nexus/src/pipeline/suffix-index.ts
|
|
20593
|
+
var EMPTY_SUFFIX_INDEX;
|
|
20594
|
+
var init_suffix_index = __esm({
|
|
20595
|
+
"packages/nexus/src/pipeline/suffix-index.ts"() {
|
|
20596
|
+
"use strict";
|
|
20597
|
+
EMPTY_SUFFIX_INDEX = Object.freeze({
|
|
20598
|
+
get: () => void 0,
|
|
20599
|
+
getInsensitive: () => void 0,
|
|
20600
|
+
getFilesInDir: () => []
|
|
20601
|
+
});
|
|
20602
|
+
}
|
|
20603
|
+
});
|
|
20604
|
+
|
|
20605
|
+
// packages/nexus/src/pipeline/import-processor.ts
|
|
20606
|
+
var init_import_processor = __esm({
|
|
20607
|
+
"packages/nexus/src/pipeline/import-processor.ts"() {
|
|
20608
|
+
"use strict";
|
|
20609
|
+
init_suffix_index();
|
|
20610
|
+
}
|
|
20611
|
+
});
|
|
20612
|
+
|
|
20582
20613
|
// packages/nexus/src/pipeline/symbol-table.ts
|
|
20583
20614
|
var init_symbol_table = __esm({
|
|
20584
20615
|
"packages/nexus/src/pipeline/symbol-table.ts"() {
|
|
@@ -20598,6 +20629,7 @@ var init_resolution_context = __esm({
|
|
|
20598
20629
|
var init_call_processor = __esm({
|
|
20599
20630
|
"packages/nexus/src/pipeline/call-processor.ts"() {
|
|
20600
20631
|
"use strict";
|
|
20632
|
+
init_import_processor();
|
|
20601
20633
|
init_resolution_context();
|
|
20602
20634
|
}
|
|
20603
20635
|
});
|
|
@@ -20653,27 +20685,6 @@ var init_heritage_processor = __esm({
|
|
|
20653
20685
|
}
|
|
20654
20686
|
});
|
|
20655
20687
|
|
|
20656
|
-
// packages/nexus/src/pipeline/suffix-index.ts
|
|
20657
|
-
var EMPTY_SUFFIX_INDEX;
|
|
20658
|
-
var init_suffix_index = __esm({
|
|
20659
|
-
"packages/nexus/src/pipeline/suffix-index.ts"() {
|
|
20660
|
-
"use strict";
|
|
20661
|
-
EMPTY_SUFFIX_INDEX = Object.freeze({
|
|
20662
|
-
get: () => void 0,
|
|
20663
|
-
getInsensitive: () => void 0,
|
|
20664
|
-
getFilesInDir: () => []
|
|
20665
|
-
});
|
|
20666
|
-
}
|
|
20667
|
-
});
|
|
20668
|
-
|
|
20669
|
-
// packages/nexus/src/pipeline/import-processor.ts
|
|
20670
|
-
var init_import_processor = __esm({
|
|
20671
|
-
"packages/nexus/src/pipeline/import-processor.ts"() {
|
|
20672
|
-
"use strict";
|
|
20673
|
-
init_suffix_index();
|
|
20674
|
-
}
|
|
20675
|
-
});
|
|
20676
|
-
|
|
20677
20688
|
// packages/nexus/src/pipeline/knowledge-graph.ts
|
|
20678
20689
|
var init_knowledge_graph = __esm({
|
|
20679
20690
|
"packages/nexus/src/pipeline/knowledge-graph.ts"() {
|
|
@@ -24069,16 +24080,16 @@ async function queryAudit(options) {
|
|
|
24069
24080
|
error: row.errorMessage ?? void 0
|
|
24070
24081
|
}));
|
|
24071
24082
|
} catch (err) {
|
|
24072
|
-
|
|
24083
|
+
log5.warn({ err }, "Failed to query audit entries from SQLite");
|
|
24073
24084
|
return [];
|
|
24074
24085
|
}
|
|
24075
24086
|
}
|
|
24076
|
-
var
|
|
24087
|
+
var log5;
|
|
24077
24088
|
var init_audit = __esm({
|
|
24078
24089
|
"packages/core/src/audit.ts"() {
|
|
24079
24090
|
"use strict";
|
|
24080
24091
|
init_logger();
|
|
24081
|
-
|
|
24092
|
+
log5 = getLogger("audit");
|
|
24082
24093
|
}
|
|
24083
24094
|
});
|
|
24084
24095
|
|
|
@@ -46423,13 +46434,16 @@ async function runTierPromotion(projectRoot) {
|
|
|
46423
46434
|
try {
|
|
46424
46435
|
shortToMedium = typedAll(
|
|
46425
46436
|
nativeDb.prepare(`
|
|
46426
|
-
SELECT id, citation_count, quality_score
|
|
46437
|
+
SELECT id, citation_count, quality_score, verified
|
|
46427
46438
|
FROM ${table}
|
|
46428
46439
|
WHERE memory_tier = 'short'
|
|
46429
46440
|
AND invalid_at IS NULL
|
|
46430
46441
|
AND ${dateCol} < ?
|
|
46431
|
-
AND
|
|
46432
|
-
|
|
46442
|
+
AND (
|
|
46443
|
+
citation_count >= 3
|
|
46444
|
+
OR quality_score >= 0.7
|
|
46445
|
+
OR verified = 1
|
|
46446
|
+
)
|
|
46433
46447
|
`),
|
|
46434
46448
|
age24h
|
|
46435
46449
|
);
|
|
@@ -46439,13 +46453,15 @@ async function runTierPromotion(projectRoot) {
|
|
|
46439
46453
|
for (const row of shortToMedium) {
|
|
46440
46454
|
try {
|
|
46441
46455
|
nativeDb.prepare(`UPDATE ${table} SET memory_tier = 'medium', updated_at = ? WHERE id = ?`).run(now2, row.id);
|
|
46442
|
-
|
|
46443
|
-
|
|
46444
|
-
|
|
46445
|
-
|
|
46446
|
-
|
|
46447
|
-
|
|
46448
|
-
|
|
46456
|
+
let reason;
|
|
46457
|
+
if (row.citation_count >= 3) {
|
|
46458
|
+
reason = `citationCount=${row.citation_count} >= 3, age > 24h`;
|
|
46459
|
+
} else if ((row.quality_score ?? 0) >= 0.7) {
|
|
46460
|
+
reason = `qualityScore=${row.quality_score?.toFixed(2)} >= 0.70, age > 24h`;
|
|
46461
|
+
} else {
|
|
46462
|
+
reason = `verified=true, age > 24h`;
|
|
46463
|
+
}
|
|
46464
|
+
promoted.push({ id: row.id, table, fromTier: "short", toTier: "medium", reason });
|
|
46449
46465
|
} catch {
|
|
46450
46466
|
}
|
|
46451
46467
|
}
|
|
@@ -46453,13 +46469,12 @@ async function runTierPromotion(projectRoot) {
|
|
|
46453
46469
|
try {
|
|
46454
46470
|
mediumToLong = typedAll(
|
|
46455
46471
|
nativeDb.prepare(`
|
|
46456
|
-
SELECT id, citation_count, quality_score
|
|
46472
|
+
SELECT id, citation_count, quality_score, verified
|
|
46457
46473
|
FROM ${table}
|
|
46458
46474
|
WHERE memory_tier = 'medium'
|
|
46459
46475
|
AND invalid_at IS NULL
|
|
46460
46476
|
AND ${dateCol} < ?
|
|
46461
|
-
AND verified = 1
|
|
46462
|
-
AND citation_count >= 5
|
|
46477
|
+
AND (citation_count >= 5 OR verified = 1)
|
|
46463
46478
|
`),
|
|
46464
46479
|
age7d
|
|
46465
46480
|
);
|
|
@@ -46469,13 +46484,8 @@ async function runTierPromotion(projectRoot) {
|
|
|
46469
46484
|
for (const row of mediumToLong) {
|
|
46470
46485
|
try {
|
|
46471
46486
|
nativeDb.prepare(`UPDATE ${table} SET memory_tier = 'long', updated_at = ? WHERE id = ?`).run(now2, row.id);
|
|
46472
|
-
|
|
46473
|
-
|
|
46474
|
-
table,
|
|
46475
|
-
fromTier: "medium",
|
|
46476
|
-
toTier: "long",
|
|
46477
|
-
reason: `citationCount=${row.citation_count} >= 5, verified, age > 7d`
|
|
46478
|
-
});
|
|
46487
|
+
const reason = row.citation_count >= 5 ? `citationCount=${row.citation_count} >= 5, age > 7d` : `verified=true, age > 7d`;
|
|
46488
|
+
promoted.push({ id: row.id, table, fromTier: "medium", toTier: "long", reason });
|
|
46479
46489
|
} catch {
|
|
46480
46490
|
}
|
|
46481
46491
|
}
|
|
@@ -57107,7 +57117,7 @@ async function recordEvidence(epicId, stage, uri, type, options) {
|
|
|
57107
57117
|
description: options?.description ?? null
|
|
57108
57118
|
}).run();
|
|
57109
57119
|
} catch (err) {
|
|
57110
|
-
|
|
57120
|
+
log6.warn({ err }, "Failed to write evidence to SQLite");
|
|
57111
57121
|
}
|
|
57112
57122
|
return record2;
|
|
57113
57123
|
}
|
|
@@ -57120,14 +57130,14 @@ async function linkProvenance(epicId, stage, filePath, cwd) {
|
|
|
57120
57130
|
cwd
|
|
57121
57131
|
});
|
|
57122
57132
|
}
|
|
57123
|
-
var
|
|
57133
|
+
var log6;
|
|
57124
57134
|
var init_evidence = __esm({
|
|
57125
57135
|
"packages/core/src/lifecycle/evidence.ts"() {
|
|
57126
57136
|
"use strict";
|
|
57127
57137
|
init_logger();
|
|
57128
57138
|
init_paths();
|
|
57129
57139
|
init_tasks_schema();
|
|
57130
|
-
|
|
57140
|
+
log6 = getLogger("lifecycle:evidence");
|
|
57131
57141
|
}
|
|
57132
57142
|
});
|
|
57133
57143
|
|
|
@@ -65581,7 +65591,7 @@ async function ensureExternalTaskLinksTable(cwd) {
|
|
|
65581
65591
|
)
|
|
65582
65592
|
);
|
|
65583
65593
|
} catch (err) {
|
|
65584
|
-
|
|
65594
|
+
log7.warn({ err }, "Failed to ensure external_task_links table exists");
|
|
65585
65595
|
throw err;
|
|
65586
65596
|
}
|
|
65587
65597
|
}
|
|
@@ -65649,14 +65659,14 @@ function rowToLink(row) {
|
|
|
65649
65659
|
lastSyncAt: row.lastSyncAt
|
|
65650
65660
|
};
|
|
65651
65661
|
}
|
|
65652
|
-
var
|
|
65662
|
+
var log7;
|
|
65653
65663
|
var init_link_store = __esm({
|
|
65654
65664
|
"packages/core/src/reconciliation/link-store.ts"() {
|
|
65655
65665
|
"use strict";
|
|
65656
65666
|
init_logger();
|
|
65657
65667
|
init_sqlite2();
|
|
65658
65668
|
init_tasks_schema();
|
|
65659
|
-
|
|
65669
|
+
log7 = getLogger("link-store");
|
|
65660
65670
|
}
|
|
65661
65671
|
});
|
|
65662
65672
|
|
|
@@ -65802,7 +65812,7 @@ async function executeTransferInternal(params) {
|
|
|
65802
65812
|
}
|
|
65803
65813
|
}
|
|
65804
65814
|
} catch (err) {
|
|
65805
|
-
|
|
65815
|
+
log8.warn(
|
|
65806
65816
|
{ err, linksCreated },
|
|
65807
65817
|
"Failed to create external_task_links during transfer \u2014 tasks were transferred successfully but provenance links could not be written"
|
|
65808
65818
|
);
|
|
@@ -65830,7 +65840,7 @@ async function executeTransferInternal(params) {
|
|
|
65830
65840
|
})
|
|
65831
65841
|
});
|
|
65832
65842
|
} catch (err) {
|
|
65833
|
-
|
|
65843
|
+
log8.warn({ err }, "nexus transfer audit write failed");
|
|
65834
65844
|
}
|
|
65835
65845
|
if (mode === "move") {
|
|
65836
65846
|
let archived = 0;
|
|
@@ -65843,7 +65853,7 @@ async function executeTransferInternal(params) {
|
|
|
65843
65853
|
});
|
|
65844
65854
|
archived++;
|
|
65845
65855
|
} catch (err) {
|
|
65846
|
-
|
|
65856
|
+
log8.warn({ err, taskId: entry.sourceId }, "failed to archive source task after transfer");
|
|
65847
65857
|
}
|
|
65848
65858
|
}
|
|
65849
65859
|
}
|
|
@@ -65881,14 +65891,14 @@ async function executeTransferInternal(params) {
|
|
|
65881
65891
|
}
|
|
65882
65892
|
}
|
|
65883
65893
|
} catch (err) {
|
|
65884
|
-
|
|
65894
|
+
log8.warn({ err }, "brain observation transfer failed");
|
|
65885
65895
|
}
|
|
65886
65896
|
result.brainObservationsTransferred = brainTransferred;
|
|
65887
65897
|
result.manifest.brainObservationsTransferred = brainTransferred;
|
|
65888
65898
|
}
|
|
65889
65899
|
return result;
|
|
65890
65900
|
}
|
|
65891
|
-
var
|
|
65901
|
+
var log8;
|
|
65892
65902
|
var init_transfer = __esm({
|
|
65893
65903
|
"packages/core/src/nexus/transfer.ts"() {
|
|
65894
65904
|
"use strict";
|
|
@@ -65901,7 +65911,7 @@ var init_transfer = __esm({
|
|
|
65901
65911
|
init_export2();
|
|
65902
65912
|
init_permissions();
|
|
65903
65913
|
init_registry3();
|
|
65904
|
-
|
|
65914
|
+
log8 = getLogger("nexus:transfer");
|
|
65905
65915
|
}
|
|
65906
65916
|
});
|
|
65907
65917
|
|
|
@@ -66182,9 +66192,7 @@ async function completeTask(options, cwd, accessor) {
|
|
|
66182
66192
|
const parent = await acc.loadSingleTask(task.parentId);
|
|
66183
66193
|
if (parent && parent.type === "epic" && !parent.noAutoComplete) {
|
|
66184
66194
|
const siblings = await acc.getChildren(parent.id);
|
|
66185
|
-
const allDone = siblings.every(
|
|
66186
|
-
(c) => c.id === task.id || c.status === "done" || c.status === "cancelled"
|
|
66187
|
-
);
|
|
66195
|
+
const allDone = siblings.length > 0 && siblings.every((c) => c.id === task.id || c.status === "done" || c.status === "cancelled");
|
|
66188
66196
|
if (allDone) {
|
|
66189
66197
|
parent.status = "done";
|
|
66190
66198
|
parent.completedAt = now2;
|
|
@@ -66843,8 +66851,8 @@ async function loadProjectACL(projectPath) {
|
|
|
66843
66851
|
async function logAclFailure(projectPath) {
|
|
66844
66852
|
try {
|
|
66845
66853
|
const { getLogger: getLogger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
|
|
66846
|
-
const
|
|
66847
|
-
|
|
66854
|
+
const log13 = getLogger2("nexus.acl");
|
|
66855
|
+
log13.warn({ projectPath }, "Failed to load ACL configuration, defaulting to deny-all");
|
|
66848
66856
|
} catch {
|
|
66849
66857
|
}
|
|
66850
66858
|
}
|
|
@@ -66989,9 +66997,9 @@ async function executeOperation(operation, taskId, projectPath, accessor, direct
|
|
|
66989
66997
|
async function logRouteAudit(directive, projectName, taskId, operation, success2, error48) {
|
|
66990
66998
|
try {
|
|
66991
66999
|
const { getLogger: getLogger2 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
|
|
66992
|
-
const
|
|
67000
|
+
const log13 = getLogger2("nexus.route");
|
|
66993
67001
|
const level = success2 ? "info" : "warn";
|
|
66994
|
-
|
|
67002
|
+
log13[level](
|
|
66995
67003
|
{
|
|
66996
67004
|
directive: directive.verb,
|
|
66997
67005
|
agentId: directive.agentId,
|
|
@@ -76084,7 +76092,7 @@ async function queryTasks(cwd, since) {
|
|
|
76084
76092
|
}).from(tasks2).where(conditions.length > 0 ? and14(...conditions) : void 0).all();
|
|
76085
76093
|
return rows;
|
|
76086
76094
|
} catch (err) {
|
|
76087
|
-
|
|
76095
|
+
log9.warn({ err }, "Failed to query tasks for workflow telemetry");
|
|
76088
76096
|
return [];
|
|
76089
76097
|
}
|
|
76090
76098
|
}
|
|
@@ -76118,7 +76126,7 @@ async function queryCompletionAuditRows(cwd, since) {
|
|
|
76118
76126
|
return isComplete;
|
|
76119
76127
|
});
|
|
76120
76128
|
} catch (err) {
|
|
76121
|
-
|
|
76129
|
+
log9.warn({ err }, "Failed to query audit log for workflow telemetry");
|
|
76122
76130
|
return [];
|
|
76123
76131
|
}
|
|
76124
76132
|
}
|
|
@@ -76343,12 +76351,12 @@ async function getWorkflowComplianceReport(opts) {
|
|
|
76343
76351
|
}
|
|
76344
76352
|
};
|
|
76345
76353
|
}
|
|
76346
|
-
var
|
|
76354
|
+
var log9;
|
|
76347
76355
|
var init_workflow_telemetry = __esm({
|
|
76348
76356
|
"packages/core/src/stats/workflow-telemetry.ts"() {
|
|
76349
76357
|
"use strict";
|
|
76350
76358
|
init_logger();
|
|
76351
|
-
|
|
76359
|
+
log9 = getLogger("workflow-telemetry");
|
|
76352
76360
|
}
|
|
76353
76361
|
});
|
|
76354
76362
|
|
|
@@ -77665,7 +77673,7 @@ import { createGzip } from "node:zlib";
|
|
|
77665
77673
|
async function pruneAuditLog(cleoDir, config2) {
|
|
77666
77674
|
try {
|
|
77667
77675
|
if (!config2.auditRetentionDays || config2.auditRetentionDays <= 0) {
|
|
77668
|
-
|
|
77676
|
+
log10.debug("auditRetentionDays is 0 or unset; skipping audit prune");
|
|
77669
77677
|
return { rowsArchived: 0, rowsDeleted: 0 };
|
|
77670
77678
|
}
|
|
77671
77679
|
const cutoff = new Date(Date.now() - config2.auditRetentionDays * 864e5).toISOString();
|
|
@@ -77676,7 +77684,7 @@ async function pruneAuditLog(cleoDir, config2) {
|
|
|
77676
77684
|
const db = await getDb4(projectRoot);
|
|
77677
77685
|
const oldRows = await db.select().from(auditLog2).where(lt4(auditLog2.timestamp, cutoff));
|
|
77678
77686
|
if (oldRows.length === 0) {
|
|
77679
|
-
|
|
77687
|
+
log10.debug("No audit_log rows older than cutoff; nothing to prune");
|
|
77680
77688
|
return { rowsArchived: 0, rowsDeleted: 0 };
|
|
77681
77689
|
}
|
|
77682
77690
|
let archivePath;
|
|
@@ -77694,17 +77702,17 @@ async function pruneAuditLog(cleoDir, config2) {
|
|
|
77694
77702
|
const inStream = Readable.from([jsonlContent]);
|
|
77695
77703
|
await pipeline(inStream, gzip, outStream);
|
|
77696
77704
|
rowsArchived = oldRows.length;
|
|
77697
|
-
|
|
77705
|
+
log10.info(
|
|
77698
77706
|
{ archivePath, rowsArchived },
|
|
77699
77707
|
`Archived ${rowsArchived} audit rows to ${archivePath}`
|
|
77700
77708
|
);
|
|
77701
77709
|
} catch (archiveErr) {
|
|
77702
|
-
|
|
77710
|
+
log10.warn({ err: archiveErr }, "Failed to archive audit rows; continuing with deletion");
|
|
77703
77711
|
archivePath = void 0;
|
|
77704
77712
|
}
|
|
77705
77713
|
}
|
|
77706
77714
|
await db.delete(auditLog2).where(lt4(auditLog2.timestamp, cutoff)).run();
|
|
77707
|
-
|
|
77715
|
+
log10.info(
|
|
77708
77716
|
{ rowsDeleted: oldRows.length, cutoff },
|
|
77709
77717
|
`Pruned ${oldRows.length} audit_log rows older than ${cutoff}`
|
|
77710
77718
|
);
|
|
@@ -77714,16 +77722,16 @@ async function pruneAuditLog(cleoDir, config2) {
|
|
|
77714
77722
|
archivePath
|
|
77715
77723
|
};
|
|
77716
77724
|
} catch (err) {
|
|
77717
|
-
|
|
77725
|
+
log10.warn({ err }, "audit log pruning failed");
|
|
77718
77726
|
return { rowsArchived: 0, rowsDeleted: 0 };
|
|
77719
77727
|
}
|
|
77720
77728
|
}
|
|
77721
|
-
var
|
|
77729
|
+
var log10;
|
|
77722
77730
|
var init_audit_prune = __esm({
|
|
77723
77731
|
"packages/core/src/audit-prune.ts"() {
|
|
77724
77732
|
"use strict";
|
|
77725
77733
|
init_logger();
|
|
77726
|
-
|
|
77734
|
+
log10 = getLogger("prune");
|
|
77727
77735
|
}
|
|
77728
77736
|
});
|
|
77729
77737
|
|
|
@@ -90085,6 +90093,7 @@ async function runBrainMaintenance(projectRoot, options) {
|
|
|
90085
90093
|
skipDecay = false,
|
|
90086
90094
|
skipConsolidation = false,
|
|
90087
90095
|
skipReconciliation = false,
|
|
90096
|
+
skipTierPromotion = false,
|
|
90088
90097
|
skipEmbeddings = false,
|
|
90089
90098
|
onProgress
|
|
90090
90099
|
} = options ?? {};
|
|
@@ -90096,6 +90105,7 @@ async function runBrainMaintenance(projectRoot, options) {
|
|
|
90096
90105
|
observationsFixed: 0,
|
|
90097
90106
|
linksRemoved: 0
|
|
90098
90107
|
};
|
|
90108
|
+
const tierPromotionResult = { promoted: 0, evicted: 0 };
|
|
90099
90109
|
const embeddingsResult = {
|
|
90100
90110
|
processed: 0,
|
|
90101
90111
|
skipped: 0,
|
|
@@ -90122,6 +90132,13 @@ async function runBrainMaintenance(projectRoot, options) {
|
|
|
90122
90132
|
reconciliationResult.linksRemoved = raw.linksRemoved;
|
|
90123
90133
|
onProgress?.("reconciliation", 1, 1);
|
|
90124
90134
|
}
|
|
90135
|
+
if (!skipTierPromotion) {
|
|
90136
|
+
onProgress?.("tier-promotion", 0, 1);
|
|
90137
|
+
const raw = await runTierPromotion(projectRoot);
|
|
90138
|
+
tierPromotionResult.promoted = raw.promoted.length;
|
|
90139
|
+
tierPromotionResult.evicted = raw.evicted.length;
|
|
90140
|
+
onProgress?.("tier-promotion", 1, 1);
|
|
90141
|
+
}
|
|
90125
90142
|
if (!skipEmbeddings) {
|
|
90126
90143
|
const raw = await populateEmbeddings(projectRoot, {
|
|
90127
90144
|
onProgress: (current, total) => {
|
|
@@ -90136,6 +90153,7 @@ async function runBrainMaintenance(projectRoot, options) {
|
|
|
90136
90153
|
decay: decayResult,
|
|
90137
90154
|
consolidation: consolidationResult,
|
|
90138
90155
|
reconciliation: reconciliationResult,
|
|
90156
|
+
tierPromotion: tierPromotionResult,
|
|
90139
90157
|
embeddings: embeddingsResult,
|
|
90140
90158
|
duration: Date.now() - startTime
|
|
90141
90159
|
};
|
|
@@ -96752,7 +96770,7 @@ var init_backup_pack = __esm({
|
|
|
96752
96770
|
import fs5 from "node:fs";
|
|
96753
96771
|
import path5 from "node:path";
|
|
96754
96772
|
function detectAndRemoveLegacyGlobalFiles(cleoHomeOverride) {
|
|
96755
|
-
const
|
|
96773
|
+
const log13 = getLogger("cleanup-legacy");
|
|
96756
96774
|
const cleoHome = cleoHomeOverride ?? getCleoHome();
|
|
96757
96775
|
const removed = [];
|
|
96758
96776
|
const errors = [];
|
|
@@ -96762,30 +96780,30 @@ function detectAndRemoveLegacyGlobalFiles(cleoHomeOverride) {
|
|
|
96762
96780
|
if (fs5.existsSync(fullPath)) {
|
|
96763
96781
|
fs5.unlinkSync(fullPath);
|
|
96764
96782
|
removed.push(fileName);
|
|
96765
|
-
|
|
96783
|
+
log13.info({ file: fullPath }, "Removed legacy global file");
|
|
96766
96784
|
}
|
|
96767
96785
|
} catch (err) {
|
|
96768
96786
|
const message = err instanceof Error ? err.message : String(err);
|
|
96769
96787
|
errors.push({ file: fileName, error: message });
|
|
96770
|
-
|
|
96788
|
+
log13.warn({ file: fullPath, error: message }, "Failed to remove legacy global file");
|
|
96771
96789
|
}
|
|
96772
96790
|
}
|
|
96773
96791
|
return { removed, errors };
|
|
96774
96792
|
}
|
|
96775
96793
|
function detectAndRemoveStrayProjectNexus(projectRoot) {
|
|
96776
|
-
const
|
|
96794
|
+
const log13 = getLogger("cleanup-legacy");
|
|
96777
96795
|
const strayPath = path5.join(projectRoot, ".cleo", "nexus.db");
|
|
96778
96796
|
if (fs5.existsSync(strayPath)) {
|
|
96779
96797
|
try {
|
|
96780
96798
|
fs5.unlinkSync(strayPath);
|
|
96781
|
-
|
|
96799
|
+
log13.warn(
|
|
96782
96800
|
{ path: strayPath },
|
|
96783
96801
|
"Removed stray project-tier nexus.db (violates ADR-036 global-only contract)"
|
|
96784
96802
|
);
|
|
96785
96803
|
return { removed: true, path: strayPath };
|
|
96786
96804
|
} catch (err) {
|
|
96787
96805
|
const message = err instanceof Error ? err.message : String(err);
|
|
96788
|
-
|
|
96806
|
+
log13.warn(
|
|
96789
96807
|
{ path: strayPath, error: message },
|
|
96790
96808
|
"Failed to remove stray project-tier nexus.db \u2014 manual deletion may be required"
|
|
96791
96809
|
);
|
|
@@ -96856,7 +96874,7 @@ function brokenTimestamp() {
|
|
|
96856
96874
|
return `${now2.getFullYear()}${pad2(now2.getMonth() + 1)}${pad2(now2.getDate())}-${pad2(now2.getHours())}${pad2(now2.getMinutes())}${pad2(now2.getSeconds())}-${pad3(now2.getMilliseconds())}`;
|
|
96857
96875
|
}
|
|
96858
96876
|
function migrateSignaldockToConduit(projectRoot) {
|
|
96859
|
-
const
|
|
96877
|
+
const log13 = getLogger("migrate-signaldock-to-conduit");
|
|
96860
96878
|
const legacyPath = join113(projectRoot, ".cleo", "signaldock.db");
|
|
96861
96879
|
const conduitPath = join113(projectRoot, ".cleo", "conduit.db");
|
|
96862
96880
|
const globalSignaldockPath = join113(getCleoHome(), "signaldock.db");
|
|
@@ -96873,13 +96891,13 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
96873
96891
|
if (!needsSignaldockToConduitMigration(projectRoot)) {
|
|
96874
96892
|
return result;
|
|
96875
96893
|
}
|
|
96876
|
-
|
|
96894
|
+
log13.info({ projectRoot, legacyPath }, "T310 migration: starting signaldock.db \u2192 conduit.db");
|
|
96877
96895
|
let legacy = null;
|
|
96878
96896
|
try {
|
|
96879
96897
|
legacy = new DatabaseSync7(legacyPath, { readOnly: true });
|
|
96880
96898
|
} catch (err) {
|
|
96881
96899
|
const message = err instanceof Error ? err.message : String(err);
|
|
96882
|
-
|
|
96900
|
+
log13.error({ legacyPath, error: message }, "T310 migration: cannot open legacy signaldock.db");
|
|
96883
96901
|
result.errors.push({ step: "step-2-open-legacy", error: message });
|
|
96884
96902
|
result.status = "failed";
|
|
96885
96903
|
return result;
|
|
@@ -96887,7 +96905,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
96887
96905
|
try {
|
|
96888
96906
|
if (!integrityCheckPasses(legacy)) {
|
|
96889
96907
|
const msg = "Legacy signaldock.db failed PRAGMA integrity_check. Migration aborted \u2014 no changes written. Recovery: inspect the database with sqlite3 and attempt manual repair before re-running.";
|
|
96890
|
-
|
|
96908
|
+
log13.error({ legacyPath }, msg);
|
|
96891
96909
|
result.errors.push({ step: "step-3-legacy-integrity", error: msg });
|
|
96892
96910
|
result.status = "failed";
|
|
96893
96911
|
legacy.close();
|
|
@@ -96895,7 +96913,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
96895
96913
|
}
|
|
96896
96914
|
} catch (err) {
|
|
96897
96915
|
const message = err instanceof Error ? err.message : String(err);
|
|
96898
|
-
|
|
96916
|
+
log13.error({ legacyPath, error: message }, "T310 migration: integrity_check threw on legacy DB");
|
|
96899
96917
|
result.errors.push({ step: "step-3-legacy-integrity", error: message });
|
|
96900
96918
|
result.status = "failed";
|
|
96901
96919
|
legacy.close();
|
|
@@ -96913,7 +96931,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
96913
96931
|
getGlobalSalt();
|
|
96914
96932
|
} catch (err) {
|
|
96915
96933
|
const message = err instanceof Error ? err.message : String(err);
|
|
96916
|
-
|
|
96934
|
+
log13.error({ error: message }, "T310 migration: getGlobalSalt failed \u2014 migration aborted");
|
|
96917
96935
|
result.errors.push({ step: "step-6-global-salt", error: message });
|
|
96918
96936
|
result.status = "failed";
|
|
96919
96937
|
legacy.close();
|
|
@@ -96927,7 +96945,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
96927
96945
|
conduit.exec("PRAGMA foreign_keys = OFF");
|
|
96928
96946
|
} catch (err) {
|
|
96929
96947
|
const message = err instanceof Error ? err.message : String(err);
|
|
96930
|
-
|
|
96948
|
+
log13.error({ conduitPath, error: message }, "T310 migration: failed to create conduit.db");
|
|
96931
96949
|
result.errors.push({ step: "step-7-create-conduit", error: message });
|
|
96932
96950
|
result.status = "failed";
|
|
96933
96951
|
legacy.close();
|
|
@@ -96973,7 +96991,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
96973
96991
|
result.agentsCopied = agentsCountForConduit;
|
|
96974
96992
|
} catch (err) {
|
|
96975
96993
|
const message = err instanceof Error ? err.message : String(err);
|
|
96976
|
-
|
|
96994
|
+
log13.error({ error: message }, "T310 migration: conduit.db write failed \u2014 rolling back");
|
|
96977
96995
|
result.errors.push({ step: "step-8-conduit-write", error: message });
|
|
96978
96996
|
result.status = "failed";
|
|
96979
96997
|
try {
|
|
@@ -96994,7 +97012,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
96994
97012
|
try {
|
|
96995
97013
|
if (!integrityCheckPasses(conduit)) {
|
|
96996
97014
|
const msg = "conduit.db failed PRAGMA integrity_check after write";
|
|
96997
|
-
|
|
97015
|
+
log13.error({ conduitPath }, msg);
|
|
96998
97016
|
result.errors.push({ step: "step-10-conduit-integrity", error: msg });
|
|
96999
97017
|
result.status = "failed";
|
|
97000
97018
|
conduit.close();
|
|
@@ -97009,7 +97027,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
97009
97027
|
}
|
|
97010
97028
|
} catch (err) {
|
|
97011
97029
|
const message = err instanceof Error ? err.message : String(err);
|
|
97012
|
-
|
|
97030
|
+
log13.error({ error: message }, "T310 migration: conduit.db integrity_check threw");
|
|
97013
97031
|
result.errors.push({ step: "step-10-conduit-integrity", error: message });
|
|
97014
97032
|
result.status = "failed";
|
|
97015
97033
|
if (conduit) {
|
|
@@ -97031,7 +97049,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
97031
97049
|
globalDb.exec("PRAGMA foreign_keys = OFF");
|
|
97032
97050
|
} catch (err) {
|
|
97033
97051
|
const message = err instanceof Error ? err.message : String(err);
|
|
97034
|
-
|
|
97052
|
+
log13.error(
|
|
97035
97053
|
{ globalSignaldockPath, error: message },
|
|
97036
97054
|
"T310 migration: cannot open global signaldock.db"
|
|
97037
97055
|
);
|
|
@@ -97070,7 +97088,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
97070
97088
|
result.agentsCopied = agentsCopiedToGlobal;
|
|
97071
97089
|
} catch (err) {
|
|
97072
97090
|
const message = err instanceof Error ? err.message : String(err);
|
|
97073
|
-
|
|
97091
|
+
log13.error(
|
|
97074
97092
|
{ error: message },
|
|
97075
97093
|
"T310 migration: global signaldock.db write failed \u2014 rolling back"
|
|
97076
97094
|
);
|
|
@@ -97088,7 +97106,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
97088
97106
|
try {
|
|
97089
97107
|
if (!integrityCheckPasses(globalDb)) {
|
|
97090
97108
|
const msg = "Global signaldock.db failed PRAGMA integrity_check after write";
|
|
97091
|
-
|
|
97109
|
+
log13.error({ globalSignaldockPath }, msg);
|
|
97092
97110
|
result.errors.push({ step: "step-14-global-integrity", error: msg });
|
|
97093
97111
|
result.status = "failed";
|
|
97094
97112
|
globalDb.close();
|
|
@@ -97103,7 +97121,7 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
97103
97121
|
}
|
|
97104
97122
|
} catch (err) {
|
|
97105
97123
|
const message = err instanceof Error ? err.message : String(err);
|
|
97106
|
-
|
|
97124
|
+
log13.error({ error: message }, "T310 migration: global signaldock.db integrity_check threw");
|
|
97107
97125
|
result.errors.push({ step: "step-14-global-integrity", error: message });
|
|
97108
97126
|
result.status = "failed";
|
|
97109
97127
|
if (globalDb) {
|
|
@@ -97122,21 +97140,21 @@ function migrateSignaldockToConduit(projectRoot) {
|
|
|
97122
97140
|
result.bakPath = bakPath;
|
|
97123
97141
|
} catch (err) {
|
|
97124
97142
|
const message = err instanceof Error ? err.message : String(err);
|
|
97125
|
-
|
|
97143
|
+
log13.error(
|
|
97126
97144
|
{ legacyPath, bakPath, error: message },
|
|
97127
97145
|
"T310 migration: rename to .pre-t310.bak failed \u2014 legacy file left in place (harmless)"
|
|
97128
97146
|
);
|
|
97129
97147
|
result.errors.push({ step: "step-16-rename-bak", error: message });
|
|
97130
97148
|
}
|
|
97131
|
-
|
|
97149
|
+
log13.info(
|
|
97132
97150
|
{ projectRoot, agentsCopied: result.agentsCopied, conduitPath, bakPath: result.bakPath },
|
|
97133
97151
|
`T310 migration complete: ${result.agentsCopied} agents migrated to global, conduit.db created`
|
|
97134
97152
|
);
|
|
97135
|
-
|
|
97153
|
+
log13.warn(
|
|
97136
97154
|
{},
|
|
97137
97155
|
"T310 migration: API keys have been re-keyed. External systems holding old API keys (CI env vars, remote agent configs) must be updated."
|
|
97138
97156
|
);
|
|
97139
|
-
|
|
97157
|
+
log13.info(
|
|
97140
97158
|
{ legacyPath, bakPath: result.bakPath, conduitPath },
|
|
97141
97159
|
"T310 migration recovery: if problems occur, rename .pre-t310.bak to signaldock.db and delete conduit.db to re-run migration."
|
|
97142
97160
|
);
|
|
@@ -97370,7 +97388,7 @@ async function validateAndRepairSequence(cwd, config2 = {}) {
|
|
|
97370
97388
|
}
|
|
97371
97389
|
const repair = await repairSequence(cwd);
|
|
97372
97390
|
if (repair.repaired) {
|
|
97373
|
-
|
|
97391
|
+
log11.warn(
|
|
97374
97392
|
{ oldCounter: repair.oldCounter, newCounter: repair.newCounter },
|
|
97375
97393
|
"Sequence repaired"
|
|
97376
97394
|
);
|
|
@@ -97399,7 +97417,7 @@ async function triggerCheckpoint(context, cwd, config2 = {}) {
|
|
|
97399
97417
|
try {
|
|
97400
97418
|
await gitCheckpoint("auto", context, cwd);
|
|
97401
97419
|
} catch (err) {
|
|
97402
|
-
|
|
97420
|
+
log11.warn({ err }, "Checkpoint failed (non-fatal)");
|
|
97403
97421
|
}
|
|
97404
97422
|
vacuumIntoBackup({ cwd }).catch(() => {
|
|
97405
97423
|
});
|
|
@@ -97437,16 +97455,16 @@ async function safeDeleteTask(deleteFn, taskId, cwd, config2 = {}) {
|
|
|
97437
97455
|
return result;
|
|
97438
97456
|
}
|
|
97439
97457
|
async function forceCheckpointBeforeOperation(operation, cwd) {
|
|
97440
|
-
|
|
97458
|
+
log11.info({ operation }, "Forcing checkpoint before operation");
|
|
97441
97459
|
try {
|
|
97442
97460
|
await gitCheckpoint("manual", `pre-${operation}`, cwd);
|
|
97443
97461
|
} catch (err) {
|
|
97444
|
-
|
|
97462
|
+
log11.error({ err }, "Failed to create pre-operation checkpoint");
|
|
97445
97463
|
}
|
|
97446
97464
|
vacuumIntoBackup({ cwd, force: true }).catch(() => {
|
|
97447
97465
|
});
|
|
97448
97466
|
}
|
|
97449
|
-
var
|
|
97467
|
+
var log11, DEFAULT_CONFIG2, SafetyError;
|
|
97450
97468
|
var init_data_safety = __esm({
|
|
97451
97469
|
"packages/core/src/store/data-safety.ts"() {
|
|
97452
97470
|
"use strict";
|
|
@@ -97456,7 +97474,7 @@ var init_data_safety = __esm({
|
|
|
97456
97474
|
init_sqlite2();
|
|
97457
97475
|
init_sqlite_backup();
|
|
97458
97476
|
init_tasks_schema();
|
|
97459
|
-
|
|
97477
|
+
log11 = getLogger("data-safety");
|
|
97460
97478
|
DEFAULT_CONFIG2 = {
|
|
97461
97479
|
verifyWrites: true,
|
|
97462
97480
|
detectCollisions: true,
|
|
@@ -107330,11 +107348,11 @@ var require_core = __commonJS({
|
|
|
107330
107348
|
Ajv4.ValidationError = validation_error_1.default;
|
|
107331
107349
|
Ajv4.MissingRefError = ref_error_1.default;
|
|
107332
107350
|
exports.default = Ajv4;
|
|
107333
|
-
function checkOptions(checkOpts, options, msg,
|
|
107351
|
+
function checkOptions(checkOpts, options, msg, log13 = "error") {
|
|
107334
107352
|
for (const key in checkOpts) {
|
|
107335
107353
|
const opt = key;
|
|
107336
107354
|
if (opt in options)
|
|
107337
|
-
this.logger[
|
|
107355
|
+
this.logger[log13](`${msg}: option ${key}. ${checkOpts[opt]}`);
|
|
107338
107356
|
}
|
|
107339
107357
|
}
|
|
107340
107358
|
function getSchEnv(keyRef) {
|
|
@@ -112989,9 +113007,11 @@ __export(internal_exports, {
|
|
|
112989
113007
|
routing: () => routing_exports,
|
|
112990
113008
|
runAllMigrations: () => runAllMigrations,
|
|
112991
113009
|
runBrainMaintenance: () => runBrainMaintenance,
|
|
113010
|
+
runConsolidation: () => runConsolidation,
|
|
112992
113011
|
runDoctorFixes: () => runDoctorFixes,
|
|
112993
113012
|
runMigration: () => runMigration,
|
|
112994
113013
|
runReleaseGates: () => runReleaseGates,
|
|
113014
|
+
runTierPromotion: () => runTierPromotion,
|
|
112995
113015
|
runUpgrade: () => runUpgrade,
|
|
112996
113016
|
safestop: () => safestop,
|
|
112997
113017
|
sanitizeContent: () => sanitizeContent,
|
|
@@ -130134,7 +130154,7 @@ async function writeToSqlite(entry, requestId) {
|
|
|
130134
130154
|
};
|
|
130135
130155
|
const parsed = AuditLogInsertSchema2.safeParse(payload);
|
|
130136
130156
|
if (!parsed.success) {
|
|
130137
|
-
|
|
130157
|
+
log12.warn(
|
|
130138
130158
|
{ issues: parsed.error.issues },
|
|
130139
130159
|
"Audit payload failed Zod validation; skipping insert"
|
|
130140
130160
|
);
|
|
@@ -130143,7 +130163,7 @@ async function writeToSqlite(entry, requestId) {
|
|
|
130143
130163
|
const db = await getDb4(process.cwd());
|
|
130144
130164
|
await db.insert(auditLog2).values(parsed.data).run();
|
|
130145
130165
|
} catch (err) {
|
|
130146
|
-
|
|
130166
|
+
log12.warn({ err }, "Failed to write audit entry to SQLite");
|
|
130147
130167
|
}
|
|
130148
130168
|
}
|
|
130149
130169
|
function createAudit() {
|
|
@@ -130174,7 +130194,7 @@ function createAudit() {
|
|
|
130174
130194
|
},
|
|
130175
130195
|
error: response.error?.message
|
|
130176
130196
|
};
|
|
130177
|
-
|
|
130197
|
+
log12.info(
|
|
130178
130198
|
{
|
|
130179
130199
|
domain: entry.domain,
|
|
130180
130200
|
operation: entry.operation,
|
|
@@ -130191,20 +130211,20 @@ function createAudit() {
|
|
|
130191
130211
|
await writeToSqlite(entry, req.requestId);
|
|
130192
130212
|
} else {
|
|
130193
130213
|
writeToSqlite(entry, req.requestId).catch((err) => {
|
|
130194
|
-
|
|
130214
|
+
log12.error({ err }, "Failed to persist audit entry to SQLite");
|
|
130195
130215
|
});
|
|
130196
130216
|
}
|
|
130197
130217
|
return response;
|
|
130198
130218
|
};
|
|
130199
130219
|
}
|
|
130200
|
-
var
|
|
130220
|
+
var log12, cachedProjectHash;
|
|
130201
130221
|
var init_audit3 = __esm({
|
|
130202
130222
|
"packages/cleo/src/dispatch/middleware/audit.ts"() {
|
|
130203
130223
|
"use strict";
|
|
130204
130224
|
init_internal();
|
|
130205
130225
|
init_config3();
|
|
130206
130226
|
init_internal();
|
|
130207
|
-
|
|
130227
|
+
log12 = getLogger("audit");
|
|
130208
130228
|
}
|
|
130209
130229
|
});
|
|
130210
130230
|
|
|
@@ -134875,6 +134895,9 @@ function registerBrainCommand(program) {
|
|
|
134875
134895
|
"--skip-decay",
|
|
134876
134896
|
"Skip the temporal decay step (confidence reduction on stale learnings)"
|
|
134877
134897
|
).option("--skip-consolidation", "Skip the memory consolidation step (merging old observations)").option("--skip-reconciliation", "Skip the cross-DB orphaned reference reconciliation step").option(
|
|
134898
|
+
"--skip-tier-promotion",
|
|
134899
|
+
"Skip the tier promotion step (short\u2192medium, medium\u2192long promotion)"
|
|
134900
|
+
).option(
|
|
134878
134901
|
"--skip-embeddings",
|
|
134879
134902
|
"Skip the embedding backfill step (vector generation for observations)"
|
|
134880
134903
|
).option("--json", "Output results as JSON").action(
|
|
@@ -134889,6 +134912,7 @@ function registerBrainCommand(program) {
|
|
|
134889
134912
|
skipDecay: !!opts.skipDecay,
|
|
134890
134913
|
skipConsolidation: !!opts.skipConsolidation,
|
|
134891
134914
|
skipReconciliation: !!opts.skipReconciliation,
|
|
134915
|
+
skipTierPromotion: !!opts.skipTierPromotion,
|
|
134892
134916
|
skipEmbeddings: !!opts.skipEmbeddings,
|
|
134893
134917
|
onProgress: isJson ? void 0 : (step, current, total) => {
|
|
134894
134918
|
if (step === "embeddings" && total > 0) {
|
|
@@ -134923,6 +134947,11 @@ function registerBrainCommand(program) {
|
|
|
134923
134947
|
` Consolidation: ${result.consolidation.merged} merged, ${result.consolidation.removed} archived`
|
|
134924
134948
|
);
|
|
134925
134949
|
}
|
|
134950
|
+
if (!opts.skipTierPromotion) {
|
|
134951
|
+
console.log(
|
|
134952
|
+
` Tier promotion: ${result.tierPromotion.promoted} promoted, ${result.tierPromotion.evicted} evicted`
|
|
134953
|
+
);
|
|
134954
|
+
}
|
|
134926
134955
|
if (!opts.skipReconciliation) {
|
|
134927
134956
|
console.log(
|
|
134928
134957
|
` Reconcile: ${result.reconciliation.decisionsFixed} decisions, ${result.reconciliation.observationsFixed} observations, ${result.reconciliation.linksRemoved} links`
|
|
@@ -137846,6 +137875,7 @@ function registerMapCommand(program) {
|
|
|
137846
137875
|
}
|
|
137847
137876
|
|
|
137848
137877
|
// packages/cleo/src/cli/commands/memory-brain.ts
|
|
137878
|
+
init_internal();
|
|
137849
137879
|
init_cli();
|
|
137850
137880
|
init_renderers();
|
|
137851
137881
|
function registerMemoryBrainCommand(program) {
|
|
@@ -138208,6 +138238,61 @@ function registerMemoryBrainCommand(program) {
|
|
|
138208
138238
|
{ command: "memory", operation: "memory.code.for-memory" }
|
|
138209
138239
|
);
|
|
138210
138240
|
});
|
|
138241
|
+
memory.command("consolidate").description(
|
|
138242
|
+
"Run the full brain consolidation pipeline: dedup, quality recompute, tier promotion, contradiction detection, soft eviction, graph strengthening, summary generation. Equivalent to the session-end sleep-time consolidation but triggered on demand."
|
|
138243
|
+
).option("--json", "Output results as JSON").action(async (opts) => {
|
|
138244
|
+
const root = getProjectRoot();
|
|
138245
|
+
const isJson = !!opts.json;
|
|
138246
|
+
if (!isJson) {
|
|
138247
|
+
console.log("Running memory consolidation (including tier promotion)...");
|
|
138248
|
+
}
|
|
138249
|
+
try {
|
|
138250
|
+
const result = await runConsolidation(root);
|
|
138251
|
+
if (isJson) {
|
|
138252
|
+
console.log(
|
|
138253
|
+
JSON.stringify(
|
|
138254
|
+
{
|
|
138255
|
+
success: true,
|
|
138256
|
+
data: result,
|
|
138257
|
+
meta: {
|
|
138258
|
+
operation: "memory.consolidate",
|
|
138259
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
138260
|
+
}
|
|
138261
|
+
},
|
|
138262
|
+
null,
|
|
138263
|
+
2
|
|
138264
|
+
)
|
|
138265
|
+
);
|
|
138266
|
+
return;
|
|
138267
|
+
}
|
|
138268
|
+
console.log("\nConsolidation complete.");
|
|
138269
|
+
console.log(` Deduplicated: ${result.deduplicated}`);
|
|
138270
|
+
console.log(` Quality recomp: ${result.qualityRecomputed}`);
|
|
138271
|
+
console.log(` Tier promoted: ${result.tierPromotions.promoted.length} entries promoted`);
|
|
138272
|
+
console.log(` Tier evicted: ${result.tierPromotions.evicted.length} entries evicted`);
|
|
138273
|
+
console.log(` Contradictions: ${result.contradictions}`);
|
|
138274
|
+
console.log(` Soft evicted: ${result.softEvicted}`);
|
|
138275
|
+
console.log(` Edges strength: ${result.edgesStrengthened}`);
|
|
138276
|
+
console.log(` Summaries gen: ${result.summariesGenerated}`);
|
|
138277
|
+
if (result.graphLinksCreated !== void 0) {
|
|
138278
|
+
console.log(` Graph links: ${result.graphLinksCreated}`);
|
|
138279
|
+
}
|
|
138280
|
+
if (result.tierPromotions.promoted.length > 0) {
|
|
138281
|
+
console.log("\nTier promotions:");
|
|
138282
|
+
for (const p2 of result.tierPromotions.promoted) {
|
|
138283
|
+
console.log(` [${p2.table}] ${p2.id}: ${p2.fromTier} \u2192 ${p2.toTier} (${p2.reason})`);
|
|
138284
|
+
}
|
|
138285
|
+
}
|
|
138286
|
+
} catch (err) {
|
|
138287
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
138288
|
+
if (isJson) {
|
|
138289
|
+
console.log(JSON.stringify({ success: false, error: message }));
|
|
138290
|
+
} else {
|
|
138291
|
+
console.error(`Memory consolidation failed: ${message}`);
|
|
138292
|
+
}
|
|
138293
|
+
process.exit(1);
|
|
138294
|
+
}
|
|
138295
|
+
});
|
|
138211
138296
|
}
|
|
138212
138297
|
|
|
138213
138298
|
// packages/cleo/src/cli/commands/migrate-claude-mem.ts
|