dsh-cross-memory 0.2.5 → 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/lib/sync.js +22 -0
- package/lib/test/sync.test.js +24 -0
- package/package.json +1 -1
package/lib/sync.js
CHANGED
|
@@ -591,6 +591,17 @@ export class MemorySync {
|
|
|
591
591
|
const rebase = await tryGit(this.dir, ['rebase', '--quiet', 'origin/main'], this.options.networkTimeoutMs);
|
|
592
592
|
if (rebase !== undefined)
|
|
593
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
|
+
}
|
|
594
605
|
const resolution = await this.resolveRebase();
|
|
595
606
|
return { pulled: count, ...resolution };
|
|
596
607
|
}
|
|
@@ -609,12 +620,23 @@ export class MemorySync {
|
|
|
609
620
|
let resolvedByTime = 0;
|
|
610
621
|
let mergedByStructure = 0;
|
|
611
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
|
+
}
|
|
612
630
|
const unmerged = await tryGit(this.dir, ['diff', '--name-only', '--diff-filter=U'], this.options.gitTimeoutMs);
|
|
613
631
|
const paths = (unmerged ?? '').split('\n').filter((line) => line.length > 0);
|
|
614
632
|
if (paths.length === 0) {
|
|
615
633
|
const cont = await tryGitResult(this.dir, ['rebase', '--continue'], this.options.networkTimeoutMs);
|
|
616
634
|
if (cont.ok)
|
|
617
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
|
+
}
|
|
618
640
|
// An empty commit (its change is already upstream) makes --continue
|
|
619
641
|
// refuse forever; --skip is the documented way forward. Do not gate this
|
|
620
642
|
// on a clean worktree: the memory plugin writes the store concurrently,
|
package/lib/test/sync.test.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
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';
|
|
@@ -229,6 +230,29 @@ test('git empty-commit wording is recognised, ordinary failures are not', () =>
|
|
|
229
230
|
assert.equal(isEmptyCommitFailure('CONFLICT (content): Merge conflict in entries/a.md'), false);
|
|
230
231
|
assert.equal(isEmptyCommitFailure('fatal: could not read from remote repository'), false);
|
|
231
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
|
+
});
|
|
232
256
|
test('an identical change on both machines becomes an empty commit and the sync still finishes', async () => {
|
|
233
257
|
const { remote, left, right } = await twoWayFixture();
|
|
234
258
|
// right records the row locally first (no sync), then left lands the very same
|
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
|
+
"version": "0.2.6",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|