@cleocode/core 2026.4.44 → 2026.4.45

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.
@@ -1 +1 @@
1
- {"version":3,"file":"migration-manager.d.ts","sourceRoot":"","sources":["../../src/store/migration-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIlE,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,GAAG,EAAE,MAAM,CAAC;CACb;AAOD;;GAEG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAK9E;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIlD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CASvD;AAiCD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,MAAM,EACxB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,GACnB,IAAI,CAkIN;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAG5D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAE9B,EAAE,EAAE,kBAAkB,CAAC,GAAG,CAAC,EAC3B,gBAAgB,EAAE,MAAM,EACxB,QAAQ,CAAC,EAAE,YAAY,EACvB,cAAc,CAAC,EAAE,MAAM,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,IAAI,CAkCN;AAED;;;;;;;;;;;GAWG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AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,YAAY,EACtB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,cAAc,EAAE,EACjC,YAAY,EAAE,MAAM,GACnB,IAAI,CAmBN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleocode/core",
3
- "version": "2026.4.44",
3
+ "version": "2026.4.45",
4
4
  "description": "CLEO core business logic kernel — tasks, sessions, memory, orchestration, lifecycle, with bundled SQLite store",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -53,13 +53,13 @@
53
53
  "write-file-atomic": "^7.0.1",
54
54
  "yaml": "^2.8.3",
55
55
  "zod": "^4.3.6",
56
- "@cleocode/adapters": "2026.4.44",
57
- "@cleocode/agents": "2026.4.44",
58
- "@cleocode/caamp": "2026.4.44",
59
- "@cleocode/contracts": "2026.4.44",
60
- "@cleocode/lafs": "2026.4.44",
61
- "@cleocode/nexus": "2026.4.44",
62
- "@cleocode/skills": "2026.4.44"
56
+ "@cleocode/adapters": "2026.4.45",
57
+ "@cleocode/agents": "2026.4.45",
58
+ "@cleocode/caamp": "2026.4.45",
59
+ "@cleocode/lafs": "2026.4.45",
60
+ "@cleocode/contracts": "2026.4.45",
61
+ "@cleocode/nexus": "2026.4.45",
62
+ "@cleocode/skills": "2026.4.45"
63
63
  },
64
64
  "engines": {
65
65
  "node": ">=24.0.0"
@@ -144,23 +144,55 @@ export function reconcileJournal(
144
144
  }
145
145
 
146
146
  // Scenario 2: Journal has orphaned entries from a previous CLEO version
147
+ //
148
+ // Two distinct sub-cases require different handling:
149
+ //
150
+ // A) DB is AHEAD of this install (forward-compatibility): all local hashes
151
+ // are present in the DB, but the DB also has additional entries for
152
+ // migrations this install does not know about. This happens when a user
153
+ // runs a globally-installed (older) cleo binary against a DB that was
154
+ // last written by a newer cleo version. Deleting those entries would
155
+ // cause an infinite reconciliation cycle: Drizzle re-runs the "missing"
156
+ // migrations, hits duplicate-column errors (Scenario 3 recovers), writes
157
+ // them back — only for this install to delete them again on the next run.
158
+ // ACTION: skip reconciliation, log at debug only.
159
+ //
160
+ // B) DB has stale hashes from a genuinely old CLEO version whose checksum
161
+ // algorithm produced different hashes for the same migration files (i.e.,
162
+ // at least one local hash is MISSING from the DB while other DB entries
163
+ // are unrecognised). ACTION: delete and re-seed as before, log at warn.
147
164
  if (tableExists(nativeDb, '__drizzle_migrations') && tableExists(nativeDb, existenceTable)) {
148
165
  const localMigrations = readMigrationFiles({ migrationsFolder });
149
166
  const localHashes = new Set(localMigrations.map((m) => m.hash));
150
167
  const dbEntries = nativeDb.prepare('SELECT hash FROM "__drizzle_migrations"').all() as Array<{
151
168
  hash: string;
152
169
  }>;
153
- const hasOrphanedEntries = dbEntries.some((e) => !localHashes.has(e.hash));
170
+ const orphanedEntries = dbEntries.filter((e) => !localHashes.has(e.hash));
171
+ const hasOrphanedEntries = orphanedEntries.length > 0;
154
172
 
155
173
  if (hasOrphanedEntries) {
156
- const log = getLogger(logSubsystem);
157
- log.warn(
158
- { orphaned: dbEntries.filter((e) => !localHashes.has(e.hash)).length },
159
- `Detected stale migration journal entries from a previous CLEO version. Reconciling.`,
160
- );
161
- nativeDb.exec('DELETE FROM "__drizzle_migrations"');
162
- for (const m of localMigrations) {
163
- insertJournalEntry(nativeDb, m.hash, m.folderMillis, m.name ?? '');
174
+ const dbHashes = new Set(dbEntries.map((e) => e.hash));
175
+ const allLocalHashesPresentInDb = localMigrations.every((m) => dbHashes.has(m.hash));
176
+
177
+ if (allLocalHashesPresentInDb) {
178
+ // Sub-case A: DB is ahead — this install is older than the DB.
179
+ // Do NOT modify the journal; log at debug so we can trace if needed.
180
+ const log = getLogger(logSubsystem);
181
+ log.debug(
182
+ { extra: orphanedEntries.length },
183
+ `Migration journal has ${orphanedEntries.length} entries for migrations not known to this install (DB is ahead). Skipping reconciliation.`,
184
+ );
185
+ } else {
186
+ // Sub-case B: Genuine stale hashes from an older CLEO version.
187
+ const log = getLogger(logSubsystem);
188
+ log.warn(
189
+ { orphaned: orphanedEntries.length },
190
+ `Detected stale migration journal entries from a previous CLEO version. Reconciling.`,
191
+ );
192
+ nativeDb.exec('DELETE FROM "__drizzle_migrations"');
193
+ for (const m of localMigrations) {
194
+ insertJournalEntry(nativeDb, m.hash, m.folderMillis, m.name ?? '');
195
+ }
164
196
  }
165
197
  }
166
198
  }