memorix icon indicating copy to clipboard operation
memorix copied to clipboard

v1.10.3: unrelated Korean consolidation and queued lifecycle jobs with auto_cleanup=false

Open xz0831 opened this issue 3 weeks ago • 1 comments

v1.10.3 consolidation falsely merges unrelated Korean observations; queued maintenance ignores auto_cleanup=false

Tested upstream v1.10.3 (4721e9bb05dd699e0dca10cd0cf1b3cccd27b103) using synthetic Git projects, separate temporary HOME/data directories, formation="shadow", no LLM keys. No actual memories are needed.

Korean consolidation

Save the script below as reproduce.mjs and run it with Node and the v1.10.3 CLI installed (node reproduce.mjs), or pass the CLI JavaScript entry as the first argument. The script exits nonzero on stock v1.10.3 because it asserts that the independent records survive.

The fixture stores two decision observations with the same entity and distinct topic keys:

  • apple: 사과 구매 — 사용자는 매주 월요일에 사과를 구매한다.
  • mountain: 등산 계획 — 사용자는 매달 토요일에 산을 오른다.

Expected: preview has no cluster and execute retains both original IDs, titles, topic keys and content.

Actual: preview reports similarity 1; execute leaves one row. Both sentences survive in the merged narrative, but the older row's independent identity/title/topic key disappear. Real stdio MCP store/consolidate and default-enabled automatic maintenance reproduce the same behavior.

src/memory/consolidation.ts discards Hangul tokens and treats two empty token sets as similarity 1. Korean text sharing a surviving common ASCII token also falsely clusters. Unrelated English and Korean text with distinct ASCII anchors stay separate. Punctuation-only pairs expose the empty-set case independently.

A local test of retaining Hangul script tokens and treating empty/empty similarity as 0 preserves these unrelated pairs while still consolidating exact Korean and English duplicates. No patch or internal evidence directory is attached here.

Cleanup-disabled durable jobs

A separate lifecycle issue remains after disabling automatic startup cleanup:

  1. In a synthetic temporary HOME, set [memory] auto_cleanup = false.
  2. Start real MCP, call memorix_session_start with joinTeam=true, then store a synthetic observation with longTerm: {kind:"semantic", scope:"user"}.
  3. The promotion path queues long-term-maintenance anyway.
  4. Stop the test server. In this synthetic fixture only, set the long-term row's updatedAt and lastAccessedAt to 31 days ago and mark that maintenance job pending/due.
  5. Reconnect to the same synthetic project and let the real maintenance worker run.

Expected: the automatic job completes without lifecycle mutation or daily rescheduling while cleanup is disabled. Actual: the 31-day fact is archived and the job reschedules. Jobs queued before the setting changed can likewise still consolidate/archive observations.

An execution-time auto_cleanup check for the three automatic lifecycle job kinds fixes the disabled cases locally. Explicit archive/supersede remain functional; with default-enabled cleanup, the 31-day fact still archives and the job still reschedules. The live execution boundary control for 30 days uses a one-minute guard against wall-clock drift.

Runnable synthetic consolidation reproduction

The script below covers consolidation. The cleanup-disabled maintenance reproduction is described separately above. It uses only synthetic content and does not read an existing memory store.

// Run: node reproduce.mjs [path-to-memorix-cli.js]
// Uses synthetic repositories and temporary HOME/data only. Retains the temporary evidence.
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import {spawnSync} from 'node:child_process';
import assert from 'node:assert/strict';
const root=fs.mkdtempSync(path.join(os.tmpdir(),'memorix-consolidation-repro-'));
const home=path.join(root,'home'),repo=path.join(root,'repo');
fs.mkdirSync(path.join(home,'.memorix'),{recursive:true});fs.mkdirSync(repo);
fs.writeFileSync(path.join(home,'.memorix/config.toml'),'[memory]\nauto_cleanup = false\nformation = "shadow"\n');
const env={HOME:home,PATH:process.env.PATH,LANG:'en_US.UTF-8',MEMORIX_DATA_DIR:path.join(home,'.memorix/data')};
function command(bin,args){const p=spawnSync(bin,args,{cwd:repo,env,encoding:'utf8',timeout:30000});assert.equal(p.status,0,p.stderr);return p.stdout;}
command('git',['init','-q']);command('git',['remote','add','origin','https://example.invalid/synthetic/consolidation.git']);
function cli(args){return JSON.parse(command(process.argv[2]?process.execPath:'memorix', [...(process.argv[2]?[path.resolve(process.argv[2])]:[]),'memory',...args,'--json']));}
for(const [key,title,text] of [['apple','사과 구매','사용자는 매주 월요일에 사과를 구매한다.'],['mountain','등산 계획','사용자는 매달 토요일에 산을 오른다.']])cli(['store','--entity=한국어기억','--type=decision','--topicKey='+key,'--title='+title,'--text='+text,'--facts='+text]);
const before=cli(['recent','--limit=20']);const preview=cli(['consolidate','--action=preview']);const execute=cli(['consolidate','--action=execute']);const after=cli(['recent','--limit=20']);
const select=r=>r.observations.map(({id,title,topicKey,narrative})=>({id,title,topicKey,narrative}));
console.log(JSON.stringify({before:select(before),similarities:preview.clusters.map(x=>x.similarity),execute:{clustersFound:execute.clustersFound,observationsMerged:execute.observationsMerged},after:select(after)},null,2));
assert.equal(before.observations.length,2);
assert.equal(after.observations.length,2,'Unrelated independently keyed observations must retain both rows');

xz0831 avatar Nov 08 '26 13:11 xz0831

Fixed and merged in PR #386 (merge commit faf6ce5). The consolidation bug came from dropping Hangul during tokenization and treating two empty fingerprints as similarity 1; the cleanup bug came from maintenance execution never re-checking memory.autoCleanup. The fix keeps Unicode letters/numbers, treats empty fingerprints as unrelated, preserves exact Korean duplicate consolidation, and makes retention/consolidation/long-term jobs complete without mutation when cleanup is disabled.

Local verification: full suite 3321 passed, 5 skipped; 356 files passed, 3 skipped; lint and build passed. GitHub CI did not start because the repository account is locked due to billing.

AVIDS2 avatar Nov 08 '26 14:11 AVIDS2