dsh-cross-memory 0.2.4 → 0.2.6

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/README.md CHANGED
@@ -108,9 +108,9 @@ dsh plugin --profile <profile> add /path/to/packages/dsh-cross-memory
108
108
  | `rotationEntries` | `16` | 每会话额外列出多少个未出现过的标题;`0` 关闭标题轮转 |
109
109
  | `rotationEveryTurns` | `8` | 同一个长会话里每隔多少个用户轮重新发一次标题轮转块;`0` 只发一次 |
110
110
  | `rawRecall` | `false` | 补注块是否附带来源会话的原文片段(默认关闭) |
111
- | `maxEntriesPerScope` | `1000` | 每作用域保留上限,超出后归档最久没有被读到或注入的条目(手写、`pinned`、`permanent` 条目除外) |
112
- | `maxUnusedDays` | `90` | 多久没用就归档(手写、`pinned`、`permanent` 条目除外);`0` 关闭 |
113
- | `snapshotMaxAgeDays` | `60` | `durability: snapshot` 条目的过期天数;`0` 关闭 |
111
+ | `maxEntriesPerScope` | `0`(不限制) | 每作用域保留上限;`0` 表示不设上限,条目一直保留,由召回排序决定用哪些。设了上限后超出部分归档最久没被读到或注入的条目(手写、`pinned`、`permanent` 除外) |
112
+ | `maxUnusedDays` | `0`(关闭) | 多久没用就归档(手写、`pinned`、`permanent` 除外);`0` 关闭。关闭时未读条目只是排序靠后,不会消失 |
113
+ | `snapshotMaxAgeDays` | `0`(关闭) | `durability: snapshot` 条目的过期天数;`0` 关闭 |
114
114
  | `dedupeSimilarity` | `0.7` | 标题与正文字词重合度超过多少时,新记忆取代旧记忆 |
115
115
  | `sweepIntervalHours` | `12` | 定期整理间隔;`0` 关闭 |
116
116
  | `autoExtract` | `true` | 是否启用空闲后台抽取 |
package/lib/config.js CHANGED
@@ -142,27 +142,36 @@ export const DEFAULT_SUMMARY_FRESH_SLOTS = 3;
142
142
  /**
143
143
  * Default cap on stored entries per scope before the least recently used are evicted.
144
144
  *
145
- * 1000 rather than 200 as of 2026-10-24, after the recall path got an inverted
146
- * index (`prefilterEntries`): measured on this machine, 1000 entries cost 63 ms
147
- * per turn scanning everything and 25 ms through the index, and the index falls
148
- * back to a full scan when it would leave too few candidates to be trusted.
149
- * `scripts/recall-bench.mjs` is the probe that decided it; re-run it before
150
- * raising this again.
151
- */
152
- export const DEFAULT_MAX_ENTRIES_PER_SCOPE = 1000;
145
+ * There is no cap by default (`0`). A cap is a storage decision, not a memory
146
+ * decision: the store is files on disk, the recall path reads an inverted index
147
+ * (`prefilterEntries`), and the summary already selects a bounded, ranked slice,
148
+ * so a large store costs index size rather than correctness. When a cap IS set,
149
+ * the least-attended entries are archived (never deleted) and `pinned`,
150
+ * `permanent` and `user`-written entries are exempt.
151
+ */
152
+ export const DEFAULT_MAX_ENTRIES_PER_SCOPE = 0;
153
153
  /** Default hours between periodic maintenance sweeps; `0` disables the sweep. */
154
154
  export const DEFAULT_SWEEP_INTERVAL_HOURS = 12;
155
- /** Default days an unused memory survives before it is archived; `0` disables archival. */
156
- export const DEFAULT_MAX_UNUSED_DAYS = 90;
155
+ /**
156
+ * Default days an unused memory survives before it is archived; `0` disables archival.
157
+ *
158
+ * Off by default for the same reason the cap is: an entry nobody has happened to
159
+ * read yet is not a stale entry, and archiving it removes it from recall without
160
+ * a person having decided anything. Retrieval already ranks by decay and use, so
161
+ * an unused memory sinks instead of being lost. Set a number to re-enable the
162
+ * age-based sweep.
163
+ */
164
+ export const DEFAULT_MAX_UNUSED_DAYS = 0;
157
165
  /**
158
166
  * Default days a `snapshot` memory survives before it is archived; `0` disables.
159
167
  *
160
168
  * A reading taken at one moment is wrong from the day after it was taken, and
161
169
  * reading it does not make it right, so it cannot be judged by the unused clock
162
- * that a convention is judged by. Sixty days is long enough to be useful as
163
- * history and short enough that a stale number stops being quoted.
170
+ * that a convention is judged by. Off by default: the decay ranking already
171
+ * pushes an old reading down, and archiving it outright is a loss nobody asked
172
+ * for. Set a number to re-enable snapshot expiry.
164
173
  */
165
- export const DEFAULT_SNAPSHOT_MAX_AGE_DAYS = 60;
174
+ export const DEFAULT_SNAPSHOT_MAX_AGE_DAYS = 0;
166
175
  /** Default share of title/body tokens two memories must have in common to be merged. */
167
176
  export const DEFAULT_DEDUPE_SIMILARITY = 0.7;
168
177
  /** Default recall mode: how much of a conversation pays for cross-session memory. */
@@ -270,8 +279,16 @@ export const DEFAULT_EXTRACT_INTERVAL_MINUTES = 30;
270
279
  export const DEFAULT_EXTRACT_MAX_OUTPUT_TOKENS = 8192;
271
280
  /** Default timeout for one extraction call. */
272
281
  export const DEFAULT_EXTRACT_TIMEOUT_MS = 120_000;
273
- /** Default max drafts one extraction may produce. */
274
- export const DEFAULT_EXTRACT_MAX_MEMORIES = 5;
282
+ /**
283
+ * Default max drafts one extraction may produce.
284
+ *
285
+ * 8 rather than 5: on a real production session, an audit of 50 Mubea
286
+ * Invoice-Insight conversations found 247 durable facts, and the cap of 5 was
287
+ * the single biggest cause of missed material on long sessions (one audit
288
+ * session held 16 facts and kept 5). Eight keeps a long session's findings
289
+ * without letting a short one pad itself.
290
+ */
291
+ export const DEFAULT_EXTRACT_MAX_MEMORIES = 8;
275
292
  /** Default idle hours a session must accumulate before it is mined. */
276
293
  export const DEFAULT_MIN_IDLE_HOURS = 6;
277
294
  /** Default age limit: sessions idle longer than this are never mined. */
@@ -406,7 +423,7 @@ export const Config = z.object({
406
423
  */
407
424
  rotationEveryTurns: z.number().default(DEFAULT_ROTATION_EVERY_TURNS).description('Inside one conversation, emit a fresh rotation block every this many user turns (0 keeps the old once-per-conversation behaviour).').volatile(),
408
425
  /** Max stored entries per scope; the least-recently-updated are evicted. */
409
- maxEntriesPerScope: z.number().default(DEFAULT_MAX_ENTRIES_PER_SCOPE).description('Stored memories per scope; past this cap the least recently used are deleted.').volatile(),
426
+ maxEntriesPerScope: z.number().default(DEFAULT_MAX_ENTRIES_PER_SCOPE).description('Stored memories per scope; past this cap the least-attended are archived (pinned, permanent and user-written entries are exempt). 0 (the default) means no cap: the store grows and retrieval ranks it.').volatile(),
410
427
  /** Days an unused memory survives before it is archived. `0` disables archival. */
411
428
  maxUnusedDays: z.number().default(DEFAULT_MAX_UNUSED_DAYS).description('Days an unused memory survives before it is archived. Archived entries are recoverable with /memories restore. 0 disables archival.').volatile(),
412
429
  /** Days a snapshot memory survives regardless of use. `0` disables. */
@@ -624,7 +641,7 @@ export function normalizeSettings(input) {
624
641
  deltaMaxBytes: positive(value.deltaMaxBytes, DEFAULT_DELTA_MAX_BYTES, 0),
625
642
  rotationEntries: positive(value.rotationEntries, DEFAULT_ROTATION_ENTRIES, 0),
626
643
  rotationEveryTurns: positive(value.rotationEveryTurns, DEFAULT_ROTATION_EVERY_TURNS, 0),
627
- maxEntriesPerScope: positive(value.maxEntriesPerScope, DEFAULT_MAX_ENTRIES_PER_SCOPE),
644
+ maxEntriesPerScope: positive(value.maxEntriesPerScope, DEFAULT_MAX_ENTRIES_PER_SCOPE, 0),
628
645
  maxUnusedDays: positive(value.maxUnusedDays, DEFAULT_MAX_UNUSED_DAYS, 0),
629
646
  snapshotMaxAgeDays: positive(value.snapshotMaxAgeDays, DEFAULT_SNAPSHOT_MAX_AGE_DAYS, 0),
630
647
  dedupeSimilarity: clampUnit(value.dedupeSimilarity, DEFAULT_DEDUPE_SIMILARITY),
package/lib/extract.js CHANGED
@@ -75,6 +75,8 @@ export const EXTRACT_SYSTEM = [
75
75
  '',
76
76
  'Record: stable user preferences and working style; project architecture and conventions; build/test/deploy commands; environment and tooling facts; non-obvious gotchas; decisions and their reasons; the user\'s personal background and relationships (family, colleagues, friends, neighbours); personal habits, routines and plans; creative collaborations and shared stories; commitments and promises with their deadlines.',
77
77
  'Do NOT record: transient task state, one-off debugging output, secrets, API keys, tokens, credentials, sensitive personal data (ID numbers, medical records, financial account details), restatements of the code the assistant just wrote, or anything already stated in the transcript as a question rather than a fact.',
78
+ 'Do NOT record what the repository already answers: a config key and its value, an i18n key that is there to be read, the list of entry files, a script\'s CLI flags, a bug that is already fixed (name the fix only when the failure mode is non-obvious). If a later session can get it by opening the file, it is not memory.',
79
+ 'REPORTS: when the transcript is an implementation/audit/review report (often a subagent\'s), record what the report LEARNED — the mechanism, the interface trap, the root cause, the measured result, the open gap — and skip what it was ASKED to do: the task boundary ("只改这 5 个文件", "不要 git commit"), the verification commands, the review verdict, the commit hash. Those expire with the task; the finding does not.',
78
80
  '',
79
81
  'Write every title and body in Simplified Chinese. Keep paths, commands, identifiers, product names and error strings exactly as they are.',
80
82
  'The injected summary shows only the title and roughly the first 100 characters of the body (the budget forces short previews), so lead with the trigger and the decision; put the detail after.',
@@ -85,6 +87,7 @@ export const EXTRACT_SYSTEM = [
85
87
  'TIME: a fact carrying a relative time (明天/上周五/前天/下周三/上个月) MUST also carry its absolute date in the body, resolved against the today\'s date given below ("前天(2026-05-25)"). A later turn may ask exactly "那次是几号", and the relative word alone cannot answer it.',
86
88
  'UPDATES: when the transcript CHANGES an existing fact — a correction, a changed plan, a new version, a story retcon — do NOT overwrite the old state. Keep the timeline in the body: "旧:<old>;新:<new>(<date> 改)". A later turn may ask what was true BEFORE the change (改口/纠错/真实变化), and only the timeline answers it.',
87
89
  'CONFLICTS: when the user says two things about the same subject that do not agree and the transcript does not explain why, record BOTH ("两种说法:<A>;<B>;原因未明"). Never pick one side and drop the other.',
90
+ 'CONDITIONS: a rule or preference is usually BOUNDED — "下雨才喝", "当周有早班或盘点就不碰", "只在雨夜、最多两指", "戒到 5 月 10 日". The condition is the memory: a later turn asks "今晚那瓶能开不" and only the bounded rule answers it. Copy the condition and any deadline into the body exactly as the user set it ("条件:当周有早班或盘点则不喝;雨夜才喝,最多两指;戒到 2026-05-10"), and never record the bare preference without its bounds.',
88
91
  '',
89
92
  'Choose the scope of each memory:',
90
93
  '- "global": true across the developer\'s machines and projects — how they like to work, general preferences, tooling, machine and path facts, network and proxy setup, how to move work between machines, and the user\'s personal background and relationships.',
@@ -114,7 +117,7 @@ export const EXTRACT_SYSTEM = [
114
117
  '- One short sentence each, in the user\'s framing, naming the object ("把报价单发出去", not "邮件相关").',
115
118
  '- NEVER drop the time word: if the user said 明天/周五/下周三, the loop text must start with it ("明天把登录页的截图补齐"), because a later question may be exactly "我明天要做什么"; resolve "dueAt" to the absolute ISO date computed from today\'s date given above, and omit it when no deadline was said.',
116
119
  '- "dueAt" only when a deadline was actually said, as ISO date or date-time. Never invent one: a loop without a deadline is a note, and nagging somebody about a note turns help into supervision.',
117
- '- PROGRESS: when the user reports that part of an existing obligation is done ("先还一件,还剩两件"), return a loop whose text KEEPS the original promise\'s wording and adds the remaining part ("还剩两件夜班见闻(原欠三件)"), so the ledger recognises it as the same promise and updates it. Do not keep the original full amount as still owed.',
120
+ '- PROGRESS: when the user reports that part of an existing obligation is done ("先还一件,还剩两件"), the loop text MUST be the REMAINING part with the original promise\'s wording kept ("还剩两件夜班见闻(原欠三件)"), because the ledger recognises it as the same promise and replaces the old amount. A loop that still states the full original amount ("三天内讲完欠的三件") is WRONG after a progress report: it leaves the ledger owing what is already done. Skip the obligation entirely only when nothing is left.',
118
121
  '- Skip what the session shows as already done, and skip the assistant\'s own to-dos. An empty array is the normal result.',
119
122
  'Prefer few high-value memories over many trivial ones. Return at most the requested number.',
120
123
  'Reply with JSON only, no prose and no code fence: {"memories":[{"scope":"global"|"project","kind":string,"title":string,"body":string,"tags":string[],"keys":string[],"entities":string[],"appliesTo":string,"quote":string,"voice":"user"|"assistant"}],"loops":[{"text":string,"dueAt":string?}],"summary":string}',
package/lib/sync.js CHANGED
@@ -377,6 +377,28 @@ async function tryGit(dir, args, timeout) {
377
377
  return undefined;
378
378
  }
379
379
  }
380
+ /** Run git and keep the failure text, for callers that must read git's wording. */
381
+ async function tryGitResult(dir, args, timeout) {
382
+ try {
383
+ return { ok: true, stdout: await git(dir, args, timeout), stderr: '' };
384
+ }
385
+ catch (error) {
386
+ const failure = error;
387
+ return {
388
+ ok: false,
389
+ stdout: String(failure.stdout ?? ''),
390
+ stderr: String(failure.stderr ?? failure.message ?? ''),
391
+ };
392
+ }
393
+ }
394
+ /**
395
+ * Whether `git rebase --continue` stopped because the replayed commit is now
396
+ * empty (its change is already upstream). Git tells the operator to use
397
+ * `--skip`; the plugin must do the same, otherwise the loop spins to its cap.
398
+ */
399
+ export function isEmptyCommitFailure(text) {
400
+ return /previous cherry-pick is now empty|nothing to commit|no changes added to commit|no changes did you forget|no changes - did you forget/iu.test(text);
401
+ }
380
402
  /** The memory store's git transport. */
381
403
  export class MemorySync {
382
404
  options;
@@ -569,6 +591,17 @@ export class MemorySync {
569
591
  const rebase = await tryGit(this.dir, ['rebase', '--quiet', 'origin/main'], this.options.networkTimeoutMs);
570
592
  if (rebase !== undefined)
571
593
  return { ...nothing, pulled: count };
594
+ // A concurrent store write can leave the tree dirty, so git refuses to even
595
+ // start the rebase. Entering the resolver in that state is a trap: with no
596
+ // rebase in progress every --continue/--skip fails and the loop burns its
597
+ // whole round budget (2026-11-13: seven such warnings in two days). Skip the
598
+ // cycle cheaply and let the next timer retry once the writes settle; the
599
+ // --autostash shortcut is not used because a concurrent edit to a file the
600
+ // upstream commit also rewrites would resurface as conflict markers.
601
+ if (!this.rebaseInProgress()) {
602
+ this.options.log.warn('dsh-cross-memory: 记忆库 rebase 没能启动(工作区仍有未提交改动),本轮跳过同步');
603
+ return { ...nothing, pulled: 0, stoppedBy: 'rebase-not-started' };
604
+ }
572
605
  const resolution = await this.resolveRebase();
573
606
  return { pulled: count, ...resolution };
574
607
  }
@@ -587,14 +620,37 @@ export class MemorySync {
587
620
  let resolvedByTime = 0;
588
621
  let mergedByStructure = 0;
589
622
  for (let round = 0; round < 200; round += 1) {
623
+ // Without a live rebase every --continue/--skip fails, so a resolver that
624
+ // was entered in that state can never make progress; bail out instead of
625
+ // spending the whole round budget.
626
+ if (!this.rebaseInProgress()) {
627
+ this.options.log.warn('dsh-cross-memory: 记忆库 rebase 已不在进行中,结束本轮冲突处理');
628
+ return { conflicts, resolvedByResolver, resolvedByTime, mergedByStructure, stoppedBy: 'rebase-gone' };
629
+ }
590
630
  const unmerged = await tryGit(this.dir, ['diff', '--name-only', '--diff-filter=U'], this.options.gitTimeoutMs);
591
631
  const paths = (unmerged ?? '').split('\n').filter((line) => line.length > 0);
592
632
  if (paths.length === 0) {
593
- const cont = await tryGit(this.dir, ['rebase', '--continue'], this.options.networkTimeoutMs);
594
- if (cont !== undefined)
633
+ const cont = await tryGitResult(this.dir, ['rebase', '--continue'], this.options.networkTimeoutMs);
634
+ if (cont.ok)
595
635
  return { conflicts, resolvedByResolver, resolvedByTime, mergedByStructure };
636
+ if (!this.rebaseInProgress()) {
637
+ this.options.log.warn('dsh-cross-memory: 记忆库 rebase 已结束,停止冲突处理');
638
+ return { conflicts, resolvedByResolver, resolvedByTime, mergedByStructure, stoppedBy: 'rebase-gone' };
639
+ }
596
640
  // An empty commit (its change is already upstream) makes --continue
597
- // refuse forever; with a clean index/tree the only way forward is --skip.
641
+ // refuse forever; --skip is the documented way forward. Do not gate this
642
+ // on a clean worktree: the memory plugin writes the store concurrently,
643
+ // so `git status` is routinely dirty during a sync and the old gate made
644
+ // the loop spin until the round cap (observed 2026-11-11 on the host).
645
+ if (isEmptyCommitFailure(`${cont.stdout}\n${cont.stderr}`)) {
646
+ const skipped = await tryGit(this.dir, ['rebase', '--skip'], this.options.gitTimeoutMs);
647
+ if (skipped !== undefined) {
648
+ mergedByStructure += 1;
649
+ continue;
650
+ }
651
+ }
652
+ // Fallback for git builds with different wording: only when the tree is
653
+ // clean is skipping safe without an explicit empty-commit signal.
598
654
  const dirty = await tryGit(this.dir, ['status', '--porcelain'], this.options.gitTimeoutMs);
599
655
  if ((dirty ?? '').trim() === '') {
600
656
  const skipped = await tryGit(this.dir, ['rebase', '--skip'], this.options.gitTimeoutMs);
@@ -40,7 +40,9 @@ function stubSession(cwd) {
40
40
  /** A runtime over a temp store. */
41
41
  async function fixture(t, settings = {}) {
42
42
  const dir = await mkdtemp(join(tmpdir(), 'dsh-cross-memory-sweep-'));
43
- const runtime = new MemoriesRuntime(stubContext, { memoriesDir: dir, autoExtract: false, ...settings });
43
+ // Retention is off by default now (the store keeps everything and retrieval
44
+ // ranks it), so a test about the age sweep says the window it means.
45
+ const runtime = new MemoriesRuntime(stubContext, { memoriesDir: dir, autoExtract: false, maxUnusedDays: 90, ...settings });
44
46
  t.after(() => {
45
47
  runtime.dispose();
46
48
  return rm(dir, { recursive: true, force: true });
@@ -9,11 +9,12 @@
9
9
  */
10
10
  import assert from 'node:assert/strict';
11
11
  import { execFileSync } from 'node:child_process';
12
+ import { existsSync } from 'node:fs';
12
13
  import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
13
14
  import { hostname, tmpdir } from 'node:os';
14
15
  import { join } from 'node:path';
15
16
  import test from 'node:test';
16
- import { MemorySync, STORE_GITIGNORE, entryStamp, isEntryPath, isHostDescriptorPath, isPersonaPath, isSessionNotePath, mergeLoopLedgers, mergePersona, newerEntry, newerHostDescriptor, newerSessionNote, nextClockDelay } from '../sync.js';
17
+ import { MemorySync, STORE_GITIGNORE, entryStamp, isEmptyCommitFailure, isEntryPath, isHostDescriptorPath, isPersonaPath, isSessionNotePath, mergeLoopLedgers, mergePersona, newerEntry, newerHostDescriptor, newerSessionNote, nextClockDelay } from '../sync.js';
17
18
  import { applyConflictPlan, isArchivedEntryPath, projectRootOf } from '../sync-runtime.js';
18
19
  import { slugify } from '../storage.js';
19
20
  /** A logger that swallows everything; tests assert on git state, not log text. */
@@ -222,6 +223,53 @@ test('a conflicting host descriptor keeps the newer reading', () => {
222
223
  assert.equal(isHostDescriptorPath('projects/a/project.json'), false);
223
224
  assert.equal(isHostDescriptorPath('entries/hosts/note.md'), false);
224
225
  });
226
+ test('git empty-commit wording is recognised, ordinary failures are not', () => {
227
+ // real messages from git 2.5x
228
+ assert.equal(isEmptyCommitFailure('The previous cherry-pick is now empty, possibly due to conflict resolution.'), true);
229
+ assert.equal(isEmptyCommitFailure('nothing to commit, working tree clean'), true);
230
+ assert.equal(isEmptyCommitFailure('CONFLICT (content): Merge conflict in entries/a.md'), false);
231
+ assert.equal(isEmptyCommitFailure('fatal: could not read from remote repository'), false);
232
+ });
233
+ test('a pull that cannot start the rebase bails out instead of spinning', { timeout: 20_000 }, async () => {
234
+ const { left, right } = await twoWayFixture();
235
+ await writeFile(join(left.dir, 'entries', 'shared.md'), entryText('shared', 'left fact v2', '2026-03-01T00:00:00.000Z'));
236
+ await left.sync.run('test');
237
+ // A concurrent store write leaves the right tree dirty; git refuses to start a
238
+ // rebase over it. Before the guard this spun the resolver to its 200-round cap.
239
+ await writeFile(join(right.dir, 'entries', 'shared.md'), entryText('shared', 'uncommitted local edit', '2026-04-01T00:00:00.000Z'));
240
+ const started = Date.now();
241
+ const outcome = await right.sync.pull();
242
+ const elapsed = Date.now() - started;
243
+ assert.ok(elapsed < 10_000, `pull took ${elapsed}ms, the guard should bail out immediately`);
244
+ assert.equal(outcome.stoppedBy, 'rebase-not-started');
245
+ assert.equal(existsSync(join(right.dir, '.git', 'rebase-merge')), false, 'no rebase left behind');
246
+ assert.match(await readFile(join(right.dir, 'entries', 'shared.md'), 'utf8'), /uncommitted local edit/u, 'the local edit is untouched');
247
+ });
248
+ test('a resolver entered without a live rebase gives up immediately', async () => {
249
+ const { right } = await twoWayFixture();
250
+ const started = Date.now();
251
+ const outcome = await right.sync.resolveRebase();
252
+ const elapsed = Date.now() - started;
253
+ assert.ok(elapsed < 5_000, `resolveRebase took ${elapsed}ms without a rebase in progress`);
254
+ assert.equal(outcome.stoppedBy, 'rebase-gone');
255
+ });
256
+ test('an identical change on both machines becomes an empty commit and the sync still finishes', async () => {
257
+ const { remote, left, right } = await twoWayFixture();
258
+ // right records the row locally first (no sync), then left lands the very same
259
+ // content upstream: replaying right's commit onto it produces an empty commit.
260
+ await mkdir(join(right.dir, 'entries'), { recursive: true });
261
+ const text = entryText('same-row', 'the very same fact', '2026-04-01T00:00:00.000Z');
262
+ await writeFile(join(right.dir, 'entries', 'same-row.md'), text);
263
+ git(right.dir, 'add', '-A');
264
+ git(right.dir, 'commit', '-q', '-m', 'memory(right): same row');
265
+ await mkdir(join(left.dir, 'entries'), { recursive: true });
266
+ await writeFile(join(left.dir, 'entries', 'same-row.md'), text);
267
+ await left.sync.run('test');
268
+ const outcome = await right.sync.run('test');
269
+ assert.equal(outcome.stoppedBy, undefined, 'the empty commit no longer aborts the sync');
270
+ assert.equal(git(right.dir, 'status', '--porcelain').trim(), '', 'no half-finished rebase left behind');
271
+ assert.match(execFileSync('git', ['-C', remote, 'show', 'main:entries/same-row.md'], { encoding: 'utf8' }), /the very same fact/u);
272
+ });
225
273
  test('a persona file merges as a bullet union, section by section', () => {
226
274
  const ours = ['## 他怎么工作', '- 中文交流', '- 改完自己验', '', '## 他的标准', '- 讨厌假动作', ''].join('\n');
227
275
  const theirs = ['## 他怎么工作', '- 中文交流', '- 一条只有 PC 记下的工作方式', '', '## 他的标准', '- 讨厌假动作', '- 一条只有 PC 记下的标准', ''].join('\n');
@@ -138,27 +138,36 @@ export declare const DEFAULT_SUMMARY_FRESH_SLOTS = 3;
138
138
  /**
139
139
  * Default cap on stored entries per scope before the least recently used are evicted.
140
140
  *
141
- * 1000 rather than 200 as of 2026-10-24, after the recall path got an inverted
142
- * index (`prefilterEntries`): measured on this machine, 1000 entries cost 63 ms
143
- * per turn scanning everything and 25 ms through the index, and the index falls
144
- * back to a full scan when it would leave too few candidates to be trusted.
145
- * `scripts/recall-bench.mjs` is the probe that decided it; re-run it before
146
- * raising this again.
147
- */
148
- export declare const DEFAULT_MAX_ENTRIES_PER_SCOPE = 1000;
141
+ * There is no cap by default (`0`). A cap is a storage decision, not a memory
142
+ * decision: the store is files on disk, the recall path reads an inverted index
143
+ * (`prefilterEntries`), and the summary already selects a bounded, ranked slice,
144
+ * so a large store costs index size rather than correctness. When a cap IS set,
145
+ * the least-attended entries are archived (never deleted) and `pinned`,
146
+ * `permanent` and `user`-written entries are exempt.
147
+ */
148
+ export declare const DEFAULT_MAX_ENTRIES_PER_SCOPE = 0;
149
149
  /** Default hours between periodic maintenance sweeps; `0` disables the sweep. */
150
150
  export declare const DEFAULT_SWEEP_INTERVAL_HOURS = 12;
151
- /** Default days an unused memory survives before it is archived; `0` disables archival. */
152
- export declare const DEFAULT_MAX_UNUSED_DAYS = 90;
151
+ /**
152
+ * Default days an unused memory survives before it is archived; `0` disables archival.
153
+ *
154
+ * Off by default for the same reason the cap is: an entry nobody has happened to
155
+ * read yet is not a stale entry, and archiving it removes it from recall without
156
+ * a person having decided anything. Retrieval already ranks by decay and use, so
157
+ * an unused memory sinks instead of being lost. Set a number to re-enable the
158
+ * age-based sweep.
159
+ */
160
+ export declare const DEFAULT_MAX_UNUSED_DAYS = 0;
153
161
  /**
154
162
  * Default days a `snapshot` memory survives before it is archived; `0` disables.
155
163
  *
156
164
  * A reading taken at one moment is wrong from the day after it was taken, and
157
165
  * reading it does not make it right, so it cannot be judged by the unused clock
158
- * that a convention is judged by. Sixty days is long enough to be useful as
159
- * history and short enough that a stale number stops being quoted.
166
+ * that a convention is judged by. Off by default: the decay ranking already
167
+ * pushes an old reading down, and archiving it outright is a loss nobody asked
168
+ * for. Set a number to re-enable snapshot expiry.
160
169
  */
161
- export declare const DEFAULT_SNAPSHOT_MAX_AGE_DAYS = 60;
170
+ export declare const DEFAULT_SNAPSHOT_MAX_AGE_DAYS = 0;
162
171
  /** Default share of title/body tokens two memories must have in common to be merged. */
163
172
  export declare const DEFAULT_DEDUPE_SIMILARITY = 0.7;
164
173
  /** Default recall mode: how much of a conversation pays for cross-session memory. */
@@ -264,8 +273,16 @@ export declare const DEFAULT_EXTRACT_INTERVAL_MINUTES = 30;
264
273
  export declare const DEFAULT_EXTRACT_MAX_OUTPUT_TOKENS = 8192;
265
274
  /** Default timeout for one extraction call. */
266
275
  export declare const DEFAULT_EXTRACT_TIMEOUT_MS = 120000;
267
- /** Default max drafts one extraction may produce. */
268
- export declare const DEFAULT_EXTRACT_MAX_MEMORIES = 5;
276
+ /**
277
+ * Default max drafts one extraction may produce.
278
+ *
279
+ * 8 rather than 5: on a real production session, an audit of 50 Mubea
280
+ * Invoice-Insight conversations found 247 durable facts, and the cap of 5 was
281
+ * the single biggest cause of missed material on long sessions (one audit
282
+ * session held 16 facts and kept 5). Eight keeps a long session's findings
283
+ * without letting a short one pad itself.
284
+ */
285
+ export declare const DEFAULT_EXTRACT_MAX_MEMORIES = 8;
269
286
  /** Default idle hours a session must accumulate before it is mined. */
270
287
  export declare const DEFAULT_MIN_IDLE_HOURS = 6;
271
288
  /** Default age limit: sessions idle longer than this are never mined. */
@@ -159,6 +159,12 @@ export declare function parseClockTime(value: string): number | undefined;
159
159
  * @returns the delay, or undefined when no entry parses.
160
160
  */
161
161
  export declare function nextClockDelay(clock: readonly string[], now: number): number | undefined;
162
+ /**
163
+ * Whether `git rebase --continue` stopped because the replayed commit is now
164
+ * empty (its change is already upstream). Git tells the operator to use
165
+ * `--skip`; the plugin must do the same, otherwise the loop spins to its cap.
166
+ */
167
+ export declare function isEmptyCommitFailure(text: string): boolean;
162
168
  /** The memory store's git transport. */
163
169
  export declare class MemorySync {
164
170
  private readonly options;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-cross-memory",
3
3
  "description": "Cross-session memory for the DeepSeek Harness: project-scoped and global memories with an explicit memory tool, idle-time background extraction, consolidation, and layered summary injection",
4
- "version": "0.2.4",
4
+ "version": "0.2.6",
5
5
  "private": false,
6
6
  "publishConfig": {
7
7
  "access": "public"