dsh-memu-memory 1.2.9 → 1.3.0
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/CHANGELOG.md +22 -0
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/docs/memory-semantics.md +3 -2
- package/lib/binding-diagnostics.js +1 -1
- package/lib/consolidation-ledger.js +41 -1
- package/lib/consolidation-receipt.js +41 -16
- package/lib/consolidation-worker.js +34 -10
- package/lib/private.js +237 -12
- package/lib/prompts/private-consolidation.md +2 -2
- package/lib/prompts/private-consolidation.rp.md +3 -2
- package/lib/tools.js +62 -62
- package/package.json +1 -1
- package/tests/consolidation-fork.test.mjs +61 -15
- package/tests/consolidation-ledger.test.mjs +64 -3
- package/tests/consolidation-snapshot.test.mjs +25 -9
- package/tests/injection-chain.test.mjs +2 -2
- package/tests/prompt-semantics.test.mjs +1 -1
- package/tests/prompts.test.mjs +1 -1
|
@@ -10,7 +10,7 @@ process.env.DSH_MEMU_HOME = home
|
|
|
10
10
|
const state = await import('../lib/state.js')
|
|
11
11
|
const activity = await import('../lib/activity-log.js')
|
|
12
12
|
const forkModel = await import('../lib/fork-model.js')
|
|
13
|
-
const { requestPrivateConsolidation, isConsolidating, consolidationWaitBudget, CONSOLIDATION_WAIT_POLICY, CONSOLIDATION_WINDOW_EVENTS, compactSeedEvents, selectConsolidationWindow, selectTailTurnWindow } = await import('../lib/private.js')
|
|
13
|
+
const { requestPrivateConsolidation, isConsolidating, consolidationWaitBudget, CONSOLIDATION_WAIT_POLICY, CONSOLIDATION_WINDOW_EVENTS, compactSeedEvents, selectConsolidationWindow, selectTailTurnWindow, mustCoverCandidates, mergeMustCover, candidateCovered } = await import('../lib/private.js')
|
|
14
14
|
|
|
15
15
|
test.after(() => {
|
|
16
16
|
forkModel.disposeConsolidationRoute()
|
|
@@ -431,7 +431,48 @@ test('a manual re-check starts at a complete turn instead of mid-step', () => {
|
|
|
431
431
|
assert.equal(window.throughSeq, 4, 'the window ends on a closed turn')
|
|
432
432
|
})
|
|
433
433
|
|
|
434
|
-
test('
|
|
434
|
+
test('must-cover candidates keep the high-signal turn and its seq range', () => {
|
|
435
|
+
const events = [
|
|
436
|
+
{ seq: 0, type: 'turn/start', data: {} },
|
|
437
|
+
{ seq: 1, type: 'user/message', data: { source: { kind: 'user' }, content: [{ type: 'text', text: '说好周末拿给阿兰换伞骨,记得带过去。' }] } },
|
|
438
|
+
{ seq: 2, type: 'turn/end', data: {} },
|
|
439
|
+
{ seq: 3, type: 'turn/start', data: {} },
|
|
440
|
+
{ seq: 4, type: 'user/message', data: { source: { kind: 'user' }, content: [{ type: 'text', text: '今天天气不错。' }] } },
|
|
441
|
+
{ seq: 5, type: 'turn/end', data: {} },
|
|
442
|
+
]
|
|
443
|
+
const rows = mustCoverCandidates(events, { max: 4 })
|
|
444
|
+
assert.equal(rows.length, 1, 'a low-signal turn is not a must-cover candidate')
|
|
445
|
+
assert.equal(rows[0].fromSeq, 0)
|
|
446
|
+
assert.equal(rows[0].throughSeq, 2)
|
|
447
|
+
assert.equal(rows[0].tag, '人物/关系')
|
|
448
|
+
assert.match(rows[0].text, /阿兰/)
|
|
449
|
+
})
|
|
450
|
+
|
|
451
|
+
test('mergeMustCover puts carried candidates first and reserves room for fresh ones', () => {
|
|
452
|
+
const carry = Array.from({ length: 6 }, (_, i) => ({ text: 'carry' + i, fromSeq: i, throughSeq: i, tag: '事实' }))
|
|
453
|
+
const fresh = Array.from({ length: 6 }, (_, i) => ({ text: 'fresh' + i, fromSeq: i, throughSeq: i, tag: '事实' }))
|
|
454
|
+
const merged = mergeMustCover(carry, fresh)
|
|
455
|
+
assert.equal(merged.length, 8)
|
|
456
|
+
assert.deepEqual(merged.slice(0, 4).map((row) => row.text), ['carry0', 'carry1', 'carry2', 'carry3'])
|
|
457
|
+
assert.deepEqual(merged.slice(4).map((row) => row.text), ['fresh0', 'fresh1', 'fresh2', 'fresh3'])
|
|
458
|
+
assert.ok(merged.slice(0, 4).every((row) => row.carried === true))
|
|
459
|
+
assert.equal(mergeMustCover([{ text: 'same' }], [{ text: 'same' }]).length, 1, 'duplicates are dropped')
|
|
460
|
+
})
|
|
461
|
+
|
|
462
|
+
test('a candidate is covered only when a written entry carries the fact', () => {
|
|
463
|
+
const index = {
|
|
464
|
+
entries: {
|
|
465
|
+
'mem-1': { title: '楼下修伞的阿兰', content: '说好周末拿折伞给她换伞骨,布不用动。' },
|
|
466
|
+
'mem-2': { title: '同事叶楠生日是八月十八号', content: '叶楠生日八月十八号。' },
|
|
467
|
+
},
|
|
468
|
+
}
|
|
469
|
+
assert.equal(candidateCovered({ text: '说好周末拿给阿兰换伞骨' }, ['mem-1'], index), true)
|
|
470
|
+
assert.equal(candidateCovered({ text: '叶楠生日八月十八号' }, ['mem-2'], index), true)
|
|
471
|
+
assert.equal(candidateCovered({ text: '父亲不吃芹菜' }, ['mem-1'], index), false)
|
|
472
|
+
assert.equal(candidateCovered({ text: '父亲不吃芹菜' }, [], index), false, 'no writes means no coverage')
|
|
473
|
+
})
|
|
474
|
+
|
|
475
|
+
test('the same failed snapshot stops automatic re-forking after the failure cap', async () => {
|
|
435
476
|
state.ensureSession('fork-failcap', { cwd: path.join(home, 'proj-failcap'), agentPreset: 'coding' })
|
|
436
477
|
const ctx = host({ live: true, turnReason: { kind: 'error', error: { message: 'provider refused' } } })
|
|
437
478
|
const first = await requestPrivateConsolidation(ctx, 'fork-failcap', { force: true })
|
|
@@ -439,10 +480,15 @@ test('the same failed snapshot stops re-forking after the failure cap', async ()
|
|
|
439
480
|
assert.equal(first.ok, false)
|
|
440
481
|
assert.equal(second.ok, false)
|
|
441
482
|
assert.equal(ctx.rec.created.length, 2, 'two real attempts happen')
|
|
442
|
-
|
|
483
|
+
// 自动路径仍然受上限约束:同一快照连续失败 2 次后不再付第三次 fork 成本。
|
|
484
|
+
const third = await requestPrivateConsolidation(ctx, 'fork-failcap')
|
|
443
485
|
assert.equal(third.ok, true)
|
|
444
486
|
assert.equal(third.skipped, 'snapshot-failed')
|
|
445
|
-
assert.equal(ctx.rec.created.length, 2, 'the
|
|
487
|
+
assert.equal(ctx.rec.created.length, 2, 'the automatic call does not pay for the same snapshot again')
|
|
488
|
+
// 手动整理是明确的一次再决定:force 不受上限约束(否则冻结回放/用户重试会被永久卡住)。
|
|
489
|
+
const forcedAgain = await requestPrivateConsolidation(ctx, 'fork-failcap', { force: true })
|
|
490
|
+
assert.equal(forcedAgain.ok, false)
|
|
491
|
+
assert.equal(ctx.rec.created.length, 3, 'a manual retry is allowed past the cap')
|
|
446
492
|
})
|
|
447
493
|
|
|
448
494
|
// ---------------------------------------------------------------- PTC 兼容
|
|
@@ -478,16 +524,16 @@ test('a PTC session (run_code only header) is consolidated and the worker gets w
|
|
|
478
524
|
assert.equal(result.ok, true, 'a run_code header must not block consolidation: ' + String(result.error || ''))
|
|
479
525
|
assert.equal(result.settled, true)
|
|
480
526
|
assert.equal(ctx.rec.created.length, 1, 'the fork is created for the PTC conversation')
|
|
481
|
-
// 只挂 worker
|
|
482
|
-
// archive/delete/unpin
|
|
483
|
-
assert.deepEqual([...registered].sort(), ['
|
|
527
|
+
// 只挂 worker 真正用到的读写面(remember/update/link_suggest/list/recall/status);
|
|
528
|
+
// lexicon、private_link、archive/delete/unpin 这些用不到或破坏性的工具不进 worker 面。
|
|
529
|
+
assert.deepEqual([...registered].sort(), ['memu_private_link_suggest', 'memu_private_list', 'memu_private_recall', 'memu_private_remember', 'memu_private_update', 'memu_status'])
|
|
484
530
|
// 整理结束(finally)必须卸载挂载,不能给这条一次性 worker 留常驻注册。
|
|
485
|
-
assert.deepEqual([...disposals].sort(), ['
|
|
531
|
+
assert.deepEqual([...disposals].sort(), ['memu_private_link_suggest', 'memu_private_list', 'memu_private_recall', 'memu_private_remember', 'memu_private_update', 'memu_status'])
|
|
486
532
|
// 全量挂载的活动元数据:attached=实际子集(此处=完整 wanted)、requested=完整 wanted、
|
|
487
533
|
// partial=false。三件一起钉住"成功路径不再含糊"。
|
|
488
534
|
const started = startedEntryFor(ctx, 'fork-ptc')
|
|
489
|
-
assert.deepEqual([...started.detail.workerToolsAttached].sort(), ['
|
|
490
|
-
assert.deepEqual([...started.detail.workerToolsRequested].sort(), ['
|
|
535
|
+
assert.deepEqual([...started.detail.workerToolsAttached].sort(), ['memu_private_link_suggest', 'memu_private_list', 'memu_private_recall', 'memu_private_remember', 'memu_private_update', 'memu_status'])
|
|
536
|
+
assert.deepEqual([...started.detail.workerToolsRequested].sort(), ['memu_private_link_suggest', 'memu_private_list', 'memu_private_recall', 'memu_private_remember', 'memu_private_update', 'memu_status'])
|
|
491
537
|
assert.equal(started.detail.workerToolsPartial, false, 'a full mount is not partial')
|
|
492
538
|
const followup = ctx.rec.forkFollowups[0]?.message
|
|
493
539
|
const brief = Array.isArray(followup?.content)
|
|
@@ -529,14 +575,14 @@ test('a host registry refusing one write tool leaves a structured partial mount
|
|
|
529
575
|
const result = await requestPrivateConsolidation(ctx, 'fork-ptc-partial')
|
|
530
576
|
assert.equal(result.ok, true, String(result.error || ''))
|
|
531
577
|
assert.equal(result.settled, true)
|
|
532
|
-
assert.deepEqual([...registered].sort(), ['
|
|
578
|
+
assert.deepEqual([...registered].sort(), ['memu_private_link_suggest', 'memu_private_list', 'memu_private_recall', 'memu_private_update', 'memu_status'],
|
|
533
579
|
'exactly the tools that actually registered are mounted')
|
|
534
|
-
assert.deepEqual([...disposals].sort(), ['
|
|
580
|
+
assert.deepEqual([...disposals].sort(), ['memu_private_link_suggest', 'memu_private_list', 'memu_private_recall', 'memu_private_update', 'memu_status'],
|
|
535
581
|
'dispose unmounts exactly what was mounted')
|
|
536
582
|
const started = startedEntryFor(ctx, 'fork-ptc-partial')
|
|
537
|
-
assert.deepEqual([...started.detail.workerToolsAttached].sort(), ['
|
|
583
|
+
assert.deepEqual([...started.detail.workerToolsAttached].sort(), ['memu_private_link_suggest', 'memu_private_list', 'memu_private_recall', 'memu_private_update', 'memu_status'],
|
|
538
584
|
'the log records the actual subset, not the full wanted list')
|
|
539
|
-
assert.deepEqual([...started.detail.workerToolsRequested].sort(), ['
|
|
585
|
+
assert.deepEqual([...started.detail.workerToolsRequested].sort(), ['memu_private_link_suggest', 'memu_private_list', 'memu_private_recall', 'memu_private_remember', 'memu_private_update', 'memu_status'])
|
|
540
586
|
assert.equal(started.detail.workerToolsPartial, true)
|
|
541
587
|
// 挂载为部分子集时任务书仍带 PTC 调用形态:worker 知道写记忆走 run_code 的 SDK 绑定。
|
|
542
588
|
const followup = ctx.rec.forkFollowups[0]?.message
|
|
@@ -557,7 +603,7 @@ test('a fork context without a tools service records a null mount, the request a
|
|
|
557
603
|
assert.equal(result.ok, true, String(result.error || ''))
|
|
558
604
|
const started = startedEntryFor(ctx, 'fork-ptc-notools')
|
|
559
605
|
assert.equal(started.detail.workerToolsAttached, null, 'no mount completed, so the log must not claim one')
|
|
560
|
-
assert.deepEqual([...started.detail.workerToolsRequested].sort(), ['
|
|
606
|
+
assert.deepEqual([...started.detail.workerToolsRequested].sort(), ['memu_private_link_suggest', 'memu_private_list', 'memu_private_recall', 'memu_private_remember', 'memu_private_update', 'memu_status'])
|
|
561
607
|
assert.equal(started.detail.workerToolsPartial, true)
|
|
562
608
|
})
|
|
563
609
|
|
|
@@ -260,12 +260,55 @@ test('an unchanged existing id cannot prove an update', () => {
|
|
|
260
260
|
assert.match(reconciled.problems.join(' '), /no verified post-worker change/)
|
|
261
261
|
})
|
|
262
262
|
|
|
263
|
-
test('a held
|
|
263
|
+
test('a held claim on an active entry is ignored, not fatal', () => {
|
|
264
264
|
const index = { entries: { 'mem-1': { status: 'active' } } }
|
|
265
265
|
const parsed = receipt.parseReceipt(fence({ status: 'completed', outcome: 'no_value', heldIds: ['mem-1'], checkedRange: { fromSeq: 0, throughSeq: 4 } }))
|
|
266
266
|
const reconciled = receipt.reconcileReceipt({ receipt: parsed.receipt, index })
|
|
267
|
-
|
|
268
|
-
assert.
|
|
267
|
+
// 库是权威:worker 说「暂扣」但条目正常落库时,不把整份回执退回。
|
|
268
|
+
assert.equal(reconciled.ok, true)
|
|
269
|
+
assert.deepEqual(reconciled.heldIds, [])
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
test('a held claim is accepted when the entry carries a conflict marker', () => {
|
|
273
|
+
const index = { entries: { 'mem-1': { status: 'active', conflictingWith: 'mem-2', reviewReason: '说法相反' } } }
|
|
274
|
+
const parsed = receipt.parseReceipt(fence({ status: 'completed', outcome: 'no_value', heldIds: ['mem-1'], checkedRange: { fromSeq: 0, throughSeq: 4 } }))
|
|
275
|
+
const reconciled = receipt.reconcileReceipt({ receipt: parsed.receipt, index })
|
|
276
|
+
assert.equal(reconciled.ok, true)
|
|
277
|
+
assert.deepEqual(reconciled.heldIds, ['mem-1'])
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
test('a memory created and updated in the same window is a create, not a failed update', () => {
|
|
281
|
+
const index = { entries: { 'mem-new': { status: 'active', content: 'final' }, 'mem-old': { status: 'active', content: 'same' } } }
|
|
282
|
+
const parsed = receipt.parseReceipt(fence({
|
|
283
|
+
status: 'completed', outcome: 'mixed', createdIds: ['mem-new'], updatedIds: ['mem-new', 'mem-old'], checkedRange: { fromSeq: 0, throughSeq: 4 },
|
|
284
|
+
}))
|
|
285
|
+
const reconciled = receipt.reconcileReceipt({
|
|
286
|
+
receipt: parsed.receipt,
|
|
287
|
+
index,
|
|
288
|
+
beforeIds: new Set(['mem-old']),
|
|
289
|
+
beforeEntries: { 'mem-old': receipt.entryFingerprint({ status: 'active', content: 'same' }) },
|
|
290
|
+
})
|
|
291
|
+
assert.equal(reconciled.ok, true)
|
|
292
|
+
assert.deepEqual(reconciled.createdIds, ['mem-new'])
|
|
293
|
+
assert.deepEqual(reconciled.updatedIds, [])
|
|
294
|
+
assert.equal(reconciled.outcome, 'created')
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
test('a retry may report a previous attempt write as created without failing', () => {
|
|
298
|
+
const index = { entries: { 'mem-prev': { status: 'active', content: 'v2' } } }
|
|
299
|
+
const parsed = receipt.parseReceipt(fence({
|
|
300
|
+
status: 'completed', outcome: 'created', createdIds: ['mem-prev'], checkedRange: { fromSeq: 0, throughSeq: 4 },
|
|
301
|
+
}))
|
|
302
|
+
const reconciled = receipt.reconcileReceipt({
|
|
303
|
+
receipt: parsed.receipt,
|
|
304
|
+
index,
|
|
305
|
+
beforeIds: new Set(['mem-prev']),
|
|
306
|
+
beforeEntries: { 'mem-prev': receipt.entryFingerprint({ status: 'active', content: 'v1' }) },
|
|
307
|
+
})
|
|
308
|
+
assert.equal(reconciled.ok, true)
|
|
309
|
+
assert.deepEqual(reconciled.duplicateIds, ['mem-prev'])
|
|
310
|
+
assert.deepEqual(reconciled.updatedIds, ['mem-prev'])
|
|
311
|
+
assert.equal(reconciled.outcome, 'updated')
|
|
269
312
|
})
|
|
270
313
|
|
|
271
314
|
test('decideCompletion: proof advances, guesswork does not', () => {
|
|
@@ -295,4 +338,22 @@ test('decideCompletion never settles a silent worker on its own', () => {
|
|
|
295
338
|
const unattributed = receipt.decideCompletion({ text: '', wrote: 2 })
|
|
296
339
|
assert.equal(unattributed.advance, false)
|
|
297
340
|
assert.match(unattributed.error, /receipt|cannot settle/i)
|
|
341
|
+
})
|
|
342
|
+
|
|
343
|
+
test('carry candidates survive the ledger round-trip and stay bounded', () => {
|
|
344
|
+
ledger.setCarryCandidates('carry-1', [
|
|
345
|
+
{ fromSeq: 1080, throughSeq: 1085, tag: '人物/关系', text: '说好周末拿给阿兰换伞骨', observedAt: '2026-05-17T12:00:00+08:00' },
|
|
346
|
+
{ fromSeq: 1152, throughSeq: 1163, tag: '人物/关系', text: '普法折页:小圆先登记,后换阿梁接手' },
|
|
347
|
+
])
|
|
348
|
+
const rows = ledger.readCarryCandidates('carry-1')
|
|
349
|
+
assert.equal(rows.length, 2)
|
|
350
|
+
assert.deepEqual(rows[0], {
|
|
351
|
+
fromSeq: 1080, throughSeq: 1085, score: 0, tag: '人物/关系',
|
|
352
|
+
text: '说好周末拿给阿兰换伞骨', observedAt: '2026-05-17T12:00:00+08:00',
|
|
353
|
+
})
|
|
354
|
+
const many = Array.from({ length: 12 }, (_, i) => ({ text: '候选 ' + i }))
|
|
355
|
+
ledger.setCarryCandidates('carry-1', many)
|
|
356
|
+
assert.equal(ledger.readCarryCandidates('carry-1').length, ledger.CARRY_LIMIT, 'the carry list is capped')
|
|
357
|
+
ledger.setCarryCandidates('carry-1', [])
|
|
358
|
+
assert.deepEqual(ledger.readCarryCandidates('carry-1'), [], 'a covered window clears the carry')
|
|
298
359
|
})
|
|
@@ -281,7 +281,7 @@ test('auxiliary link and lexicon tools alone do not prove the worker can write m
|
|
|
281
281
|
assert.equal(probe.hasWrite, false)
|
|
282
282
|
})
|
|
283
283
|
|
|
284
|
-
test('the brief teaches the suggest-then-adjudicate loop and
|
|
284
|
+
test('the brief teaches the suggest-then-adjudicate loop and the receipt buckets', () => {
|
|
285
285
|
const brief = buildWorkerBrief({
|
|
286
286
|
snapshot: { fromSeq: 0, throughSeq: 5, eventCount: 6, hash: 'brief01' },
|
|
287
287
|
probe: { tools: ['memu_private_remember', 'memu_private_update', 'memu_private_link_suggest', 'memu_lexicon_propose'] },
|
|
@@ -289,13 +289,10 @@ test('the brief teaches the suggest-then-adjudicate loop and lexicon extraction'
|
|
|
289
289
|
})
|
|
290
290
|
assert.match(brief, /memu_private_link_suggest\(\{ids:\[\.\.\.\]\}\)/, 'the call shape is spelled out')
|
|
291
291
|
assert.match(brief, /已经自动连好/, 'high-confidence links are applied before the worker sees candidates')
|
|
292
|
-
assert.match(brief,
|
|
293
|
-
assert.match(brief, /
|
|
294
|
-
|
|
295
|
-
assert.
|
|
296
|
-
assert.match(brief, /memu_lexicon_propose/)
|
|
297
|
-
assert.match(brief, /term 是索引键/)
|
|
298
|
-
assert.match(brief, /sensitive trigger/)
|
|
292
|
+
assert.match(brief, /每窗最多新增 8 条/)
|
|
293
|
+
assert.match(brief, /heldIds/)
|
|
294
|
+
// 整理 worker 只挂用得到的 6 个工具:词典/lexicon 不再出现在任务书里。
|
|
295
|
+
assert.doesNotMatch(brief, /memu_lexicon|term 是索引键|sensitive trigger/)
|
|
299
296
|
assert.match(brief, /tools-unavailable/, 'the tools-unavailable contract survives')
|
|
300
297
|
assert.match(brief, /没有回执视为本次整理失败/, 'the receipt requirement survives')
|
|
301
298
|
assert.match(brief, /BRIEF-CONTRACT/)
|
|
@@ -346,7 +343,7 @@ test('a mixed surface (run_code beside native memu_*) proves write ability and k
|
|
|
346
343
|
probe,
|
|
347
344
|
contract: 'MIXED-CONTRACT',
|
|
348
345
|
})
|
|
349
|
-
assert.match(brief, /
|
|
346
|
+
assert.match(brief, /memu_private_remember, memu_private_update/, 'the brief lists the allowed native names')
|
|
350
347
|
assert.match(brief, /await tools\.memu_private_remember/, 'the brief keeps the PTC SDK invocation shape on a mixed surface')
|
|
351
348
|
assert.match(brief, /MIXED-CONTRACT/)
|
|
352
349
|
})
|
|
@@ -396,4 +393,23 @@ test('the worker brief carries the range, the tools and the receipt contract', (
|
|
|
396
393
|
assert.match(brief, /RECEIPT-CONTRACT-MARKER/)
|
|
397
394
|
assert.match(brief, /手动/)
|
|
398
395
|
assert.match(brief, /tools-unavailable/)
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
test('the worker brief renders the must-cover checklist with seq ranges', () => {
|
|
399
|
+
const brief = buildWorkerBrief({
|
|
400
|
+
snapshot: { fromSeq: 998, throughSeq: 1211, eventCount: 214, hash: 'opt6' },
|
|
401
|
+
probe: { tools: ['memu_private_remember'] },
|
|
402
|
+
contract: '',
|
|
403
|
+
mustCover: [
|
|
404
|
+
{ fromSeq: 1080, throughSeq: 1085, tag: '人物/关系', text: '说好周末拿给阿兰换伞骨' },
|
|
405
|
+
{ fromSeq: 1152, throughSeq: 1157, tag: '人物/关系', text: '普法折页,小圆负责入口登记' },
|
|
406
|
+
{ fromSeq: 0, throughSeq: 0, tag: '事实', text: '父亲不吃芹菜', carried: true, observedAt: '2026-05-17T12:00:00+08:00' },
|
|
407
|
+
],
|
|
408
|
+
})
|
|
409
|
+
assert.match(brief, /本窗必写候选/)
|
|
410
|
+
assert.match(brief, /第 1080–1085 条 · 人物\/关系/)
|
|
411
|
+
assert.match(brief, /阿兰/)
|
|
412
|
+
assert.match(brief, /小圆负责入口登记/)
|
|
413
|
+
assert.match(brief, /顺延 · 事件时间 2026-05-17/)
|
|
414
|
+
assert.match(brief, /来自之前窗口/)
|
|
399
415
|
})
|
|
@@ -187,8 +187,8 @@ test('every consolidation prompt tells the model how to write the field', () =>
|
|
|
187
187
|
|
|
188
188
|
test('the remember tool tells the model to resolve a relative day', () => {
|
|
189
189
|
const source = fs.readFileSync(fileURLToPath(new URL('../lib/tools.js', import.meta.url)), 'utf8')
|
|
190
|
-
assert.ok(source.includes('
|
|
191
|
-
assert.ok(source.includes('
|
|
190
|
+
assert.ok(source.includes('Resolve 今天/明天/下周 to the absolute date'), 'the tool description must mention relative days')
|
|
191
|
+
assert.ok(source.includes('never send a bare MM-DD for a one-off'), 'and why it matters')
|
|
192
192
|
})
|
|
193
193
|
|
|
194
194
|
// ------------------------------------- D: freshness hint is conditional and bounded
|
|
@@ -45,7 +45,7 @@ test('the consolidation page and worker brief carry the same field contract', ()
|
|
|
45
45
|
snapshot: { fromSeq: 1, throughSeq: 2, eventCount: 2, hash: 'prompt-128' },
|
|
46
46
|
probe: { tools: ['memu_private_remember', 'memu_private_update'] },
|
|
47
47
|
})
|
|
48
|
-
for (const needle of ['speaker_id', 'source_kind', 'absolute_date', 'conflicts_with', 'supersedes', 'commitment', 'assistant_said', '每窗最多新增
|
|
48
|
+
for (const needle of ['speaker_id', 'source_kind', 'absolute_date', 'conflicts_with', 'supersedes', 'commitment', 'assistant_said', '每窗最多新增 8 条']) {
|
|
49
49
|
assert.ok(brief.includes(needle), `worker brief is missing ${needle}`)
|
|
50
50
|
}
|
|
51
51
|
})
|
package/tests/prompts.test.mjs
CHANGED
|
@@ -222,7 +222,7 @@ test('title guidance ships in every consolidation page; tool workflow lives in t
|
|
|
222
222
|
|
|
223
223
|
const { buildWorkerBrief } = await import('../lib/consolidation-worker.js')
|
|
224
224
|
const brief = buildWorkerBrief({ snapshot: { fromSeq: 1, throughSeq: 2, eventCount: 2, hash: 'prompt-test' }, probe: null, contract: '' })
|
|
225
|
-
for (const rule of [/
|
|
225
|
+
for (const rule of [/memu_private_remember/, /memu_private_update/, /memu_private_link_suggest/, /每窗最多新增 8 条/]) {
|
|
226
226
|
assert.match(brief, rule, 'the local worker brief owns the tool workflow')
|
|
227
227
|
}
|
|
228
228
|
assert.match(prompts.CONSOLIDATION_CONTRACTS.remote, /8-40字/, 'the remote JSON contract uses the same title length')
|