recallnest 2.3.0 → 2.6.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 +187 -0
- package/README.md +49 -38
- package/README_CN.md +46 -31
- package/assets/ui/app.js +1031 -0
- package/assets/ui/index.html +224 -0
- package/assets/ui/styles.css +781 -0
- package/config.json.example +4 -1
- package/docs/api-reference.md +1291 -0
- package/docs/architecture.md +168 -0
- package/docs/connector-spec.md +126 -0
- package/eval/cases-canary.json +58 -0
- package/eval/cases-scope-robustness.json +278 -0
- package/eval/cases.json +117 -20
- package/package.json +25 -4
- package/src/__tests__/access-tracker-novelty.test.ts +304 -0
- package/src/__tests__/activity-counter.test.ts +125 -0
- package/src/__tests__/adaptive-fidelity.test.ts +102 -0
- package/src/__tests__/admission-control.test.ts +206 -0
- package/src/__tests__/anchor-generator.test.ts +67 -0
- package/src/__tests__/api-server-security.test.ts +102 -0
- package/src/__tests__/auto-consolidation.test.ts +168 -0
- package/src/__tests__/auto-recall.test.ts +131 -0
- package/src/__tests__/babel-integration.test.ts +144 -0
- package/src/__tests__/batch-dedup.test.ts +65 -0
- package/src/__tests__/belief-history.test.ts +220 -0
- package/src/__tests__/canary-eval.test.ts +114 -0
- package/src/__tests__/capture-engine.test.ts +1328 -0
- package/src/__tests__/capture-heuristic.test.ts +171 -0
- package/src/__tests__/cascade-forget.test.ts +210 -0
- package/src/__tests__/category-min-scores.test.ts +116 -0
- package/src/__tests__/cc8-cc1-essential-context.test.ts +298 -0
- package/src/__tests__/circuit-breaker.test.ts +99 -0
- package/src/__tests__/cluster-consolidation.test.ts +945 -0
- package/src/__tests__/confidence-metadata.test.ts +125 -0
- package/src/__tests__/confidence-tracker.test.ts +261 -0
- package/src/__tests__/conflict-advisor.test.ts +206 -0
- package/src/__tests__/conflict-escalation.test.ts +149 -0
- package/src/__tests__/conflict-lifecycle.test.ts +83 -0
- package/src/__tests__/conflict-output.test.ts +85 -0
- package/src/__tests__/conflict-store.test.ts +418 -0
- package/src/__tests__/connector-v1.test.ts +181 -0
- package/src/__tests__/consolidation-engine.test.ts +430 -0
- package/src/__tests__/constructive-retrieval.test.ts +509 -0
- package/src/__tests__/context-collapse-renderer.test.ts +214 -0
- package/src/__tests__/context-composer-pins.test.ts +64 -0
- package/src/__tests__/context-composer-task-selection.test.ts +24 -0
- package/src/__tests__/context-reconstructor.test.ts +65 -0
- package/src/__tests__/context-renderer.test.ts +91 -0
- package/src/__tests__/continuity-eval.test.ts +275 -0
- package/src/__tests__/continuity-schema.test.ts +97 -0
- package/src/__tests__/contracts.test.ts +262 -0
- package/src/__tests__/conversation-importer.test.ts +692 -0
- package/src/__tests__/core-recall-eval.test.ts +235 -0
- package/src/__tests__/core-summary.test.ts +109 -0
- package/src/__tests__/data-checkup.test.ts +276 -0
- package/src/__tests__/decay-exemption.test.ts +129 -0
- package/src/__tests__/dedup-actions.test.ts +58 -0
- package/src/__tests__/dedup-guard.test.ts +39 -0
- package/src/__tests__/deterministic-id.test.ts +39 -0
- package/src/__tests__/distill-lock.test.ts +305 -0
- package/src/__tests__/distill-session-argshape.test.ts +79 -0
- package/src/__tests__/doctor.test.ts +319 -0
- package/src/__tests__/dream-pipeline.test.ts +780 -0
- package/src/__tests__/drill-down.test.ts +108 -0
- package/src/__tests__/embedder.test.ts +122 -0
- package/src/__tests__/emotion-decay.test.ts +46 -0
- package/src/__tests__/emotion-detector.test.ts +56 -0
- package/src/__tests__/emotion-phase1-integration.test.ts +153 -0
- package/src/__tests__/emotion-retrieval.test.ts +56 -0
- package/src/__tests__/entity-resolver.test.ts +58 -0
- package/src/__tests__/env-config.test.ts +151 -0
- package/src/__tests__/error-signature-boost.test.ts +87 -0
- package/src/__tests__/error-signature.test.ts +95 -0
- package/src/__tests__/error-taxonomy.test.ts +129 -0
- package/src/__tests__/ethics-layer.test.ts +476 -0
- package/src/__tests__/event-segmenter.test.ts +153 -0
- package/src/__tests__/feature-flags-integration.test.ts +54 -0
- package/src/__tests__/frequency-tracker.test.ts +113 -0
- package/src/__tests__/freshness.test.ts +186 -0
- package/src/__tests__/graph-export.test.ts +489 -0
- package/src/__tests__/hotness-blend.test.ts +283 -0
- package/src/__tests__/ingest-chunking.test.ts +44 -0
- package/src/__tests__/ingest.test.ts +360 -0
- package/src/__tests__/interference-detector.test.ts +203 -0
- package/src/__tests__/kg-extractor.test.ts +192 -0
- package/src/__tests__/kg-store.test.ts +300 -0
- package/src/__tests__/llm-client-pivot.test.ts +628 -0
- package/src/__tests__/llm-consolidation.test.ts +226 -0
- package/src/__tests__/maintenance-locks.test.ts +189 -0
- package/src/__tests__/mcp-efficiency.test.ts +288 -0
- package/src/__tests__/mcp-related-scopes.test.ts +151 -0
- package/src/__tests__/memory-boundaries.test.ts +282 -0
- package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +345 -0
- package/src/__tests__/memory-evolution.test.ts +271 -0
- package/src/__tests__/memory-health-rebalance.test.ts +144 -0
- package/src/__tests__/memory-lint.test.ts +421 -0
- package/src/__tests__/memory-output.test.ts +215 -0
- package/src/__tests__/memory-promotion.test.ts +315 -0
- package/src/__tests__/migrate-dedup-ids.test.ts +65 -0
- package/src/__tests__/multi-vector.test.ts +242 -0
- package/src/__tests__/narrative-architecture.test.ts +456 -0
- package/src/__tests__/noise-filter.test.ts +205 -0
- package/src/__tests__/noise-prototype-bank.test.ts +280 -0
- package/src/__tests__/obsidian-connector.test.ts +363 -0
- package/src/__tests__/omitted-reporting.test.ts +98 -0
- package/src/__tests__/pending-review.test.ts +77 -0
- package/src/__tests__/pii-redact.test.ts +333 -0
- package/src/__tests__/pivot-apply.test.ts +373 -0
- package/src/__tests__/pivot-distill-supervisor.test.ts +457 -0
- package/src/__tests__/pivot-distill.test.ts +1178 -0
- package/src/__tests__/post-retrieval-filter.test.ts +178 -0
- package/src/__tests__/ppr-traversal.test.ts +256 -0
- package/src/__tests__/prediction-engine.test.ts +349 -0
- package/src/__tests__/predictive-prospective-memory.test.ts +416 -0
- package/src/__tests__/preference-guard-smoke.test.ts +211 -0
- package/src/__tests__/preference-matcher.test.ts +282 -0
- package/src/__tests__/preference-slots.test.ts +205 -0
- package/src/__tests__/prospective-memory.test.ts +283 -0
- package/src/__tests__/pull-from-macbook-sync-only.test.ts +679 -0
- package/src/__tests__/query-entity-detector.test.ts +171 -0
- package/src/__tests__/query-expander-alias.test.ts +146 -0
- package/src/__tests__/query-expander.test.ts +34 -0
- package/src/__tests__/recall-gate.test.ts +266 -0
- package/src/__tests__/recall-governor.test.ts +227 -0
- package/src/__tests__/recall-mode.test.ts +64 -0
- package/src/__tests__/resolve-db-path.test.ts +130 -0
- package/src/__tests__/resolve-tier.test.ts +64 -0
- package/src/__tests__/result-synthesizer.test.ts +198 -0
- package/src/__tests__/resume-context.test.ts +4898 -0
- package/src/__tests__/retrieval-eval.test.ts +163 -0
- package/src/__tests__/retrieval-trace.test.ts +213 -0
- package/src/__tests__/retriever-boundary-weight.test.ts +136 -0
- package/src/__tests__/retriever-lazy-init-dispatch.test.ts +123 -0
- package/src/__tests__/retroactive-boost.test.ts +223 -0
- package/src/__tests__/salience-scoring.test.ts +106 -0
- package/src/__tests__/scope-inventory.test.ts +200 -0
- package/src/__tests__/scope-policy.test.ts +69 -0
- package/src/__tests__/scope-suggester.test.ts +80 -0
- package/src/__tests__/session-checkpoint.test.ts +291 -0
- package/src/__tests__/session-distiller.test.ts +640 -0
- package/src/__tests__/session-gc.test.ts +215 -0
- package/src/__tests__/skill-engine.test.ts +552 -0
- package/src/__tests__/skill-promotion.test.ts +654 -0
- package/src/__tests__/skill-verifier.test.ts +122 -0
- package/src/__tests__/source-heartbeat.test.ts +250 -0
- package/src/__tests__/stable-context-length-contract.test.ts +62 -0
- package/src/__tests__/store-patch-metadata.test.ts +205 -0
- package/src/__tests__/store-read-consistency.test.ts +122 -0
- package/src/__tests__/store-schema-migration.test.ts +87 -0
- package/src/__tests__/store-scope-audit.test.ts +81 -0
- package/src/__tests__/store-upsert.test.ts +201 -0
- package/src/__tests__/supersede-chain.test.ts +154 -0
- package/src/__tests__/temporal-parser.test.ts +241 -0
- package/src/__tests__/temporal-validity.test.ts +160 -0
- package/src/__tests__/term-registry-terminal-roster.test.ts +127 -0
- package/src/__tests__/term-registry.test.ts +121 -0
- package/src/__tests__/tool-error-surfacing.test.ts +98 -0
- package/src/__tests__/tool-output-compressor.test.ts +160 -0
- package/src/__tests__/topic-tag.test.ts +113 -0
- package/src/__tests__/trusted-memory.test.ts +839 -0
- package/src/__tests__/ui-server-security.test.ts +93 -0
- package/src/__tests__/usage-tracker.test.ts +287 -0
- package/src/__tests__/version-manager.test.ts +213 -0
- package/src/__tests__/workflow-observation-skill-outcome.test.ts +352 -0
- package/src/__tests__/workflow-observation.test.ts +433 -0
- package/src/__tests__/write-verifier.test.ts +122 -0
- package/src/access-tracker.ts +90 -34
- package/src/activity-counter.ts +46 -18
- package/src/adaptive-retrieval.ts +11 -0
- package/src/aliases.ts +133 -0
- package/src/api-server.ts +36 -9
- package/src/audit-log.ts +4 -2
- package/src/auto-consolidation.ts +8 -3
- package/src/auto-gc.ts +85 -21
- package/src/auto-recall.ts +61 -1
- package/src/belief-history.ts +164 -0
- package/src/capture-engine.ts +142 -32
- package/src/cli.ts +268 -41
- package/src/confidence-tracker.ts +36 -18
- package/src/conflict-engine.ts +24 -3
- package/src/consolidation-engine.ts +255 -23
- package/src/context-composer-stable-selection.ts +7 -1
- package/src/context-composer.ts +8 -1
- package/src/data-checkup.ts +96 -7
- package/src/decay-engine.ts +59 -7
- package/src/distill-lock.ts +194 -15
- package/src/doctor.ts +13 -4
- package/src/dream-pipeline.ts +473 -41
- package/src/env-config.ts +118 -0
- package/src/error-signature.ts +153 -0
- package/src/error-taxonomy.ts +115 -0
- package/src/eval.ts +402 -14
- package/src/freshness.ts +192 -0
- package/src/http-request-policy.ts +148 -0
- package/src/idempotency.ts +8 -0
- package/src/ingest.ts +308 -12
- package/src/kg-extractor.ts +13 -3
- package/src/kg-store.ts +236 -44
- package/src/llm-client.ts +106 -11
- package/src/llm-consolidation.ts +2 -1
- package/src/mcp-server.ts +87 -1800
- package/src/mcp-tool-deps.ts +48 -0
- package/src/mcp-tools-advanced.ts +954 -0
- package/src/mcp-tools-core.ts +637 -0
- package/src/mcp-tools-governance.ts +475 -0
- package/src/memory-boundaries.ts +26 -3
- package/src/memory-evolution.ts +73 -1
- package/src/memory-health-rebalance.ts +4 -0
- package/src/memory-lint.ts +183 -10
- package/src/memory-output.ts +129 -4
- package/src/memory-promotion.ts +246 -0
- package/src/memory-schema.ts +25 -2
- package/src/memory-store-port.ts +46 -0
- package/src/multi-vector.ts +2 -1
- package/src/narrative-schema.ts +2 -1
- package/src/noise-filter.ts +57 -6
- package/src/noise-prototype-bank.ts +408 -0
- package/src/pii-detector.ts +207 -5
- package/src/pivot-apply.ts +399 -0
- package/src/preference-matcher.ts +37 -3
- package/src/query-expander.ts +90 -9
- package/src/recall-gate.ts +305 -0
- package/src/result-synthesizer.ts +2 -1
- package/src/retention-policy.ts +2 -1
- package/src/retrieval-profiles.ts +46 -4
- package/src/retriever.ts +354 -157
- package/src/retroactive-boost.ts +6 -2
- package/src/runtime-config.ts +78 -6
- package/src/scope-suggester.ts +113 -0
- package/src/session-distiller.ts +23 -2
- package/src/session-engine.ts +2 -1
- package/src/session-schema.ts +1 -0
- package/src/session-store.ts +5 -0
- package/src/skill-engine.ts +78 -0
- package/src/skill-promotion.ts +304 -48
- package/src/skill-schema.ts +16 -3
- package/src/skill-verifier.ts +152 -0
- package/src/store.ts +321 -57
- package/src/term-registry.ts +35 -0
- package/src/tool-output-compressor.ts +3 -1
- package/src/ui-server.ts +9 -1
- package/src/usage-tracker.ts +242 -0
- package/src/version-manager.ts +3 -2
- package/src/version.ts +19 -0
- package/src/workflow-observation-engine.ts +2 -1
- package/src/workflow-observation-schema.ts +2 -1
- package/src/workflow-observation-store.ts +6 -2
- package/.env +0 -4
- package/CLAUDE.md +0 -46
- package/config.json +0 -55
- package/daily-recall.sh +0 -110
- package/logs/daily-recall.error.log +0 -0
- package/logs/daily-recall.log +0 -60
- package/logs/ingest-2026-04-11.log +0 -110
- package/logs/ingest-2026-04-12.log +0 -90
- package/logs/ingest-2026-04-13.log +0 -87
- package/logs/launchagent-stderr.log +0 -0
- package/logs/launchagent-stdout.log +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { describe, expect, it } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
buildStructuredMemoryBoundary,
|
|
5
|
+
buildDefaultCanonicalKey,
|
|
6
|
+
extractBoundaryMetadata,
|
|
7
|
+
extractMemoryProvenance,
|
|
8
|
+
extractPromotedFrom,
|
|
9
|
+
extractProvenanceHistory,
|
|
10
|
+
extractProvenanceHistoryCount,
|
|
11
|
+
resolveIngestBoundary,
|
|
12
|
+
shouldUseStableMemoryResult,
|
|
13
|
+
} from "../memory-boundaries.js";
|
|
14
|
+
|
|
15
|
+
describe("memory boundaries", () => {
|
|
16
|
+
it("downgrades transcript-derived profile facts into evidence events", () => {
|
|
17
|
+
const resolved = resolveIngestBoundary({
|
|
18
|
+
source: "cc",
|
|
19
|
+
scope: "cc:abc123",
|
|
20
|
+
category: "profile",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
expect(resolved.category).toBe("events");
|
|
24
|
+
expect(resolved.boundary.layer).toBe("evidence");
|
|
25
|
+
expect(resolved.boundary.authority).toBe("transcript-ingest");
|
|
26
|
+
expect(resolved.boundary.downgradedFrom).toBe("profile");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// 端清单回归:memory-boundaries.ts 的 TRANSCRIPT_SOURCES / TRANSCRIPT_SCOPE_PREFIXES
|
|
30
|
+
// 历史上漏过两次(kimi 2026-07-19 进栈、antigravity 07-29 进栈,都到 08-01 才发现)。
|
|
31
|
+
// 根因不是"忘了改",是**没有断言**——纯判断步骤没有测试撑着就会被跳过。
|
|
32
|
+
// ⚠️ 接入新端时:先在下面的清单里加一行让测试变红,再去改常量把它变绿。
|
|
33
|
+
it.each([
|
|
34
|
+
["cc", "cc:abc123"],
|
|
35
|
+
["codex", "codex:abc123"],
|
|
36
|
+
["gemini", "gemini:abc123"],
|
|
37
|
+
["kimi", "kimi:abc123"],
|
|
38
|
+
["antigravity", "antigravity:abc123"],
|
|
39
|
+
["minis", "minis:abc123"],
|
|
40
|
+
])("downgrades transcript profile facts for end %s", (source, scope) => {
|
|
41
|
+
const resolved = resolveIngestBoundary({ source, scope, category: "profile" });
|
|
42
|
+
|
|
43
|
+
expect(resolved.boundary.layer).toBe("evidence");
|
|
44
|
+
expect(resolved.boundary.authority).toBe("transcript-ingest");
|
|
45
|
+
expect(resolved.category).toBe("events");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// 反向断言:确认上面那组不是同义反复(如果任何 source 都被降权,那组测试就永远绿、
|
|
49
|
+
// 等于没测)。一个不在清单里的来源必须**不**被当成 transcript。
|
|
50
|
+
it("does not downgrade sources outside the transcript end list", () => {
|
|
51
|
+
const resolved = resolveIngestBoundary({
|
|
52
|
+
source: "manual",
|
|
53
|
+
scope: "memory:pivot",
|
|
54
|
+
category: "profile",
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
expect(resolved.boundary.layer).not.toBe("evidence");
|
|
58
|
+
expect(resolved.category).toBe("profile");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("keeps transcript cases searchable but marks them as evidence", () => {
|
|
62
|
+
const resolved = resolveIngestBoundary({
|
|
63
|
+
source: "codex",
|
|
64
|
+
scope: "codex:session1",
|
|
65
|
+
category: "cases",
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
expect(resolved.category).toBe("cases");
|
|
69
|
+
expect(resolved.boundary.layer).toBe("evidence");
|
|
70
|
+
expect(resolved.boundary.authority).toBe("transcript-ingest");
|
|
71
|
+
expect(resolved.boundary.originalCategory).toBe("cases");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("marks structured memory as durable authority", () => {
|
|
75
|
+
const boundary = buildStructuredMemoryBoundary("preferences");
|
|
76
|
+
|
|
77
|
+
expect(boundary).toEqual({
|
|
78
|
+
layer: "durable",
|
|
79
|
+
authority: "structured-memory",
|
|
80
|
+
conflictPolicy: "latest-wins",
|
|
81
|
+
originalCategory: "preferences",
|
|
82
|
+
note: "Structured memory writes are the durable source inside RecallNest.",
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("builds slot-aware canonical keys for atomic brand-item preferences", () => {
|
|
87
|
+
expect(buildDefaultCanonicalKey({
|
|
88
|
+
category: "preferences",
|
|
89
|
+
text: "我喜欢吃麦当劳的麦辣鸡翅",
|
|
90
|
+
})).toBe("preferences:brand-item:麦当劳:麦辣鸡翅");
|
|
91
|
+
|
|
92
|
+
expect(buildDefaultCanonicalKey({
|
|
93
|
+
category: "preferences",
|
|
94
|
+
text: "User prefers concise, direct replies.",
|
|
95
|
+
})).toBe("preferences:reply-style:concise:direct");
|
|
96
|
+
|
|
97
|
+
expect(buildDefaultCanonicalKey({
|
|
98
|
+
category: "preferences",
|
|
99
|
+
text: "Uses Bun over Node.",
|
|
100
|
+
})).toBe("preferences:tool-choice:bun:over:node");
|
|
101
|
+
|
|
102
|
+
expect(buildDefaultCanonicalKey({
|
|
103
|
+
category: "preferences",
|
|
104
|
+
text: "我喜欢吃麦当劳的麦旋风、板烧鸡腿堡和麦辣鸡翅",
|
|
105
|
+
})).toBe("preferences:我喜欢吃麦当劳的麦旋风-板烧鸡腿堡和麦辣鸡翅");
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it("builds distinct canonical keys for different implicit-usage preferences (#6 regression)", () => {
|
|
109
|
+
// 修复前 implicit-usage slot 无专属分支,落到 tool-choice 三元支、preferredTool/avoidedTool
|
|
110
|
+
// 均 undefined → 全部坍缩成 'preferences:implicit-usage:over',不同隐式偏好在 latest-wins
|
|
111
|
+
// 下互相覆盖丢数据。现在用 slot.subject 区分。
|
|
112
|
+
const figma = buildDefaultCanonicalKey({ category: "preferences", text: "I use Figma for design" });
|
|
113
|
+
const python = buildDefaultCanonicalKey({ category: "preferences", text: "I use Python for scripting" });
|
|
114
|
+
const sony = buildDefaultCanonicalKey({ category: "preferences", text: "我有一台索尼相机" });
|
|
115
|
+
|
|
116
|
+
expect(figma).toBe("preferences:implicit-usage:figma");
|
|
117
|
+
expect(python).toBe("preferences:implicit-usage:python");
|
|
118
|
+
expect(new Set([figma, python, sony]).size).toBe(3);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("rejects transcript/evidence stable recall and keeps durable stable recall", () => {
|
|
122
|
+
expect(shouldUseStableMemoryResult({
|
|
123
|
+
category: "preferences",
|
|
124
|
+
scope: "cc:session",
|
|
125
|
+
metadata: JSON.stringify({
|
|
126
|
+
boundary: {
|
|
127
|
+
layer: "evidence",
|
|
128
|
+
authority: "transcript-ingest",
|
|
129
|
+
conflictPolicy: "append-only",
|
|
130
|
+
},
|
|
131
|
+
}),
|
|
132
|
+
})).toBe(false);
|
|
133
|
+
|
|
134
|
+
expect(shouldUseStableMemoryResult({
|
|
135
|
+
category: "preferences",
|
|
136
|
+
scope: "memory:agent",
|
|
137
|
+
metadata: JSON.stringify({
|
|
138
|
+
boundary: buildStructuredMemoryBoundary("preferences"),
|
|
139
|
+
}),
|
|
140
|
+
})).toBe(true);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it("parses valid boundary metadata and ignores malformed payloads", () => {
|
|
144
|
+
expect(extractBoundaryMetadata(JSON.stringify({
|
|
145
|
+
boundary: buildStructuredMemoryBoundary("patterns"),
|
|
146
|
+
}))).toEqual(buildStructuredMemoryBoundary("patterns"));
|
|
147
|
+
|
|
148
|
+
expect(extractBoundaryMetadata("{not-json")).toBeNull();
|
|
149
|
+
expect(extractBoundaryMetadata(JSON.stringify({
|
|
150
|
+
boundary: { layer: "durable", authority: "oops" },
|
|
151
|
+
}))).toBeNull();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("extracts promotedFrom provenance and canonical keys", () => {
|
|
155
|
+
const metadata = JSON.stringify({
|
|
156
|
+
canonicalKey: "user-reply-style",
|
|
157
|
+
boundary: buildStructuredMemoryBoundary("preferences"),
|
|
158
|
+
promotedFrom: {
|
|
159
|
+
memoryId: "12345678-1234-1234-1234-123456789abc",
|
|
160
|
+
scope: "cc:session1",
|
|
161
|
+
category: "events",
|
|
162
|
+
source: "cc",
|
|
163
|
+
boundary: {
|
|
164
|
+
layer: "evidence",
|
|
165
|
+
authority: "transcript-ingest",
|
|
166
|
+
conflictPolicy: "append-only",
|
|
167
|
+
originalCategory: "preferences",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
expect(extractPromotedFrom(metadata)).toEqual({
|
|
173
|
+
memoryId: "12345678-1234-1234-1234-123456789abc",
|
|
174
|
+
scope: "cc:session1",
|
|
175
|
+
category: "events",
|
|
176
|
+
source: "cc",
|
|
177
|
+
boundary: {
|
|
178
|
+
layer: "evidence",
|
|
179
|
+
authority: "transcript-ingest",
|
|
180
|
+
conflictPolicy: "append-only",
|
|
181
|
+
originalCategory: "preferences",
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
expect(extractProvenanceHistory(metadata)).toEqual([{
|
|
186
|
+
memoryId: "12345678-1234-1234-1234-123456789abc",
|
|
187
|
+
scope: "cc:session1",
|
|
188
|
+
category: "events",
|
|
189
|
+
source: "cc",
|
|
190
|
+
boundary: {
|
|
191
|
+
layer: "evidence",
|
|
192
|
+
authority: "transcript-ingest",
|
|
193
|
+
conflictPolicy: "append-only",
|
|
194
|
+
originalCategory: "preferences",
|
|
195
|
+
},
|
|
196
|
+
}]);
|
|
197
|
+
expect(extractProvenanceHistoryCount(metadata)).toBe(1);
|
|
198
|
+
|
|
199
|
+
expect(extractMemoryProvenance({
|
|
200
|
+
scope: "memory:agent",
|
|
201
|
+
metadata,
|
|
202
|
+
})).toEqual({
|
|
203
|
+
boundary: buildStructuredMemoryBoundary("preferences"),
|
|
204
|
+
canonicalKey: "user-reply-style",
|
|
205
|
+
promotedFrom: {
|
|
206
|
+
memoryId: "12345678-1234-1234-1234-123456789abc",
|
|
207
|
+
scope: "cc:session1",
|
|
208
|
+
category: "events",
|
|
209
|
+
source: "cc",
|
|
210
|
+
boundary: {
|
|
211
|
+
layer: "evidence",
|
|
212
|
+
authority: "transcript-ingest",
|
|
213
|
+
conflictPolicy: "append-only",
|
|
214
|
+
originalCategory: "preferences",
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
provenanceHistory: [{
|
|
218
|
+
memoryId: "12345678-1234-1234-1234-123456789abc",
|
|
219
|
+
scope: "cc:session1",
|
|
220
|
+
category: "events",
|
|
221
|
+
source: "cc",
|
|
222
|
+
boundary: {
|
|
223
|
+
layer: "evidence",
|
|
224
|
+
authority: "transcript-ingest",
|
|
225
|
+
conflictPolicy: "append-only",
|
|
226
|
+
originalCategory: "preferences",
|
|
227
|
+
},
|
|
228
|
+
}],
|
|
229
|
+
provenanceHistoryCount: 1,
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("prefers explicit provenance history over fallback promotedFrom metadata", () => {
|
|
234
|
+
const metadata = JSON.stringify({
|
|
235
|
+
canonicalKey: "preferences:brand-item:麦当劳:麦辣鸡翅",
|
|
236
|
+
boundary: buildStructuredMemoryBoundary("preferences"),
|
|
237
|
+
promotedFrom: {
|
|
238
|
+
memoryId: "12345678-1234-1234-1234-123456789abc",
|
|
239
|
+
scope: "cc:session1",
|
|
240
|
+
category: "events",
|
|
241
|
+
source: "cc",
|
|
242
|
+
},
|
|
243
|
+
provenanceHistory: [
|
|
244
|
+
{
|
|
245
|
+
memoryId: "aaaaaaaa-1234-1234-1234-123456789abc",
|
|
246
|
+
scope: "cc:session-food-1",
|
|
247
|
+
category: "events",
|
|
248
|
+
source: "cc",
|
|
249
|
+
observedAt: "2026-03-17T04:00:00.000Z",
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
memoryId: "bbbbbbbb-1234-1234-1234-123456789abc",
|
|
253
|
+
scope: "cc:session-food-2",
|
|
254
|
+
category: "events",
|
|
255
|
+
source: "codex",
|
|
256
|
+
observedAt: "2026-03-17T05:00:00.000Z",
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
provenanceHistoryCount: 2,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
expect(extractProvenanceHistory(metadata)).toEqual([
|
|
263
|
+
{
|
|
264
|
+
memoryId: "aaaaaaaa-1234-1234-1234-123456789abc",
|
|
265
|
+
scope: "cc:session-food-1",
|
|
266
|
+
category: "events",
|
|
267
|
+
source: "cc",
|
|
268
|
+
observedAt: "2026-03-17T04:00:00.000Z",
|
|
269
|
+
boundary: null,
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
memoryId: "bbbbbbbb-1234-1234-1234-123456789abc",
|
|
273
|
+
scope: "cc:session-food-2",
|
|
274
|
+
category: "events",
|
|
275
|
+
source: "codex",
|
|
276
|
+
observedAt: "2026-03-17T05:00:00.000Z",
|
|
277
|
+
boundary: null,
|
|
278
|
+
},
|
|
279
|
+
]);
|
|
280
|
+
expect(extractProvenanceHistoryCount(metadata)).toBe(2);
|
|
281
|
+
});
|
|
282
|
+
});
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for Memory Evolution Phase B-2 (Archive Strategy),
|
|
3
|
+
* B-3 (LLM Importance Assessment), and E-1 (Multi-factor Retrieval Scoring).
|
|
4
|
+
*/
|
|
5
|
+
import { describe, expect, test } from "bun:test";
|
|
6
|
+
import {
|
|
7
|
+
parseEvolution,
|
|
8
|
+
computeDecayScore,
|
|
9
|
+
computeUsageAdjustedDecayScore,
|
|
10
|
+
buildArchivedMetadata,
|
|
11
|
+
isActiveMemory,
|
|
12
|
+
patchEvolution,
|
|
13
|
+
type EvolutionMetadata,
|
|
14
|
+
} from "../memory-evolution.js";
|
|
15
|
+
import {
|
|
16
|
+
maybeRunGc,
|
|
17
|
+
resetGcTimestamp,
|
|
18
|
+
DEFAULT_AUTO_GC_CONFIG,
|
|
19
|
+
type AutoGcConfig,
|
|
20
|
+
} from "../auto-gc.js";
|
|
21
|
+
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// B-2: Archive Strategy Tests
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
describe("B-2: Archive Strategy", () => {
|
|
27
|
+
test("buildArchivedMetadata sets status to archived", () => {
|
|
28
|
+
const meta = JSON.stringify({ evolution: { status: "active", version: 1 } });
|
|
29
|
+
const archived = buildArchivedMetadata(meta);
|
|
30
|
+
const evo = parseEvolution(archived);
|
|
31
|
+
expect(evo.status).toBe("archived");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("archived memory is not active", () => {
|
|
35
|
+
const meta = JSON.stringify({ evolution: { status: "archived", version: 1 } });
|
|
36
|
+
expect(isActiveMemory(meta)).toBe(false);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("active memory is active", () => {
|
|
40
|
+
const meta = JSON.stringify({ evolution: { status: "active", version: 1 } });
|
|
41
|
+
expect(isActiveMemory(meta)).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe("auto-gc with evolution system", () => {
|
|
45
|
+
function makeStore(entries: Array<{
|
|
46
|
+
id: string;
|
|
47
|
+
importance: number;
|
|
48
|
+
timestamp: number;
|
|
49
|
+
metadata: string;
|
|
50
|
+
}>) {
|
|
51
|
+
const data = new Map(entries.map(e => [e.id, {
|
|
52
|
+
...e,
|
|
53
|
+
text: "test",
|
|
54
|
+
vector: [1, 0, 0],
|
|
55
|
+
category: "events",
|
|
56
|
+
scope: "project:test",
|
|
57
|
+
}]));
|
|
58
|
+
const updates: Array<{ id: string; metadata: string }> = [];
|
|
59
|
+
return {
|
|
60
|
+
store: {
|
|
61
|
+
stats: async () => ({ totalCount: data.size, scopeCounts: {}, categoryCounts: {} }),
|
|
62
|
+
list: async () => Array.from(data.values()),
|
|
63
|
+
listPage: async (opts: { limit?: number; offset?: number } = {}) => {
|
|
64
|
+
const { limit = 1000, offset = 0 } = opts;
|
|
65
|
+
return Array.from(data.values()).slice(offset, offset + limit);
|
|
66
|
+
},
|
|
67
|
+
update: async (id: string, patch: { metadata: string }) => {
|
|
68
|
+
updates.push({ id, metadata: patch.metadata });
|
|
69
|
+
const entry = data.get(id);
|
|
70
|
+
if (!entry) return null;
|
|
71
|
+
entry.metadata = patch.metadata;
|
|
72
|
+
return entry;
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
updates,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
test("archives low-decay-score memories", async () => {
|
|
80
|
+
resetGcTimestamp();
|
|
81
|
+
const now = Date.now();
|
|
82
|
+
const oldTimestamp = now - 120 * 86_400_000; // 120 days ago
|
|
83
|
+
const activeMeta = JSON.stringify({
|
|
84
|
+
evolution: {
|
|
85
|
+
status: "active",
|
|
86
|
+
version: 1,
|
|
87
|
+
accessCount: 0,
|
|
88
|
+
lastAccessedAt: null,
|
|
89
|
+
validFrom: oldTimestamp,
|
|
90
|
+
validUntil: null,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const { store, updates } = makeStore([
|
|
95
|
+
{ id: "old-low", importance: 0.1, timestamp: oldTimestamp, metadata: activeMeta },
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
const config: AutoGcConfig = {
|
|
99
|
+
...DEFAULT_AUTO_GC_CONFIG,
|
|
100
|
+
minMemoryCount: 1,
|
|
101
|
+
minHoursSinceLastGc: 0,
|
|
102
|
+
decayScoreThreshold: 0.2,
|
|
103
|
+
minAgeDays: 30,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const result = await maybeRunGc(store as any, config);
|
|
107
|
+
expect(result.triggered).toBe(true);
|
|
108
|
+
expect(result.archivedCount).toBe(1);
|
|
109
|
+
expect(updates.length).toBe(1);
|
|
110
|
+
|
|
111
|
+
const archivedEvo = parseEvolution(updates[0].metadata);
|
|
112
|
+
expect(archivedEvo.status).toBe("archived");
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
test("skips pinned memories (importance >= 0.95)", async () => {
|
|
116
|
+
resetGcTimestamp();
|
|
117
|
+
const now = Date.now();
|
|
118
|
+
const oldTimestamp = now - 120 * 86_400_000;
|
|
119
|
+
const activeMeta = JSON.stringify({
|
|
120
|
+
evolution: {
|
|
121
|
+
status: "active",
|
|
122
|
+
version: 1,
|
|
123
|
+
accessCount: 0,
|
|
124
|
+
lastAccessedAt: null,
|
|
125
|
+
validFrom: oldTimestamp,
|
|
126
|
+
validUntil: null,
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const { store, updates } = makeStore([
|
|
131
|
+
{ id: "pinned", importance: 0.95, timestamp: oldTimestamp, metadata: activeMeta },
|
|
132
|
+
]);
|
|
133
|
+
|
|
134
|
+
const config: AutoGcConfig = {
|
|
135
|
+
...DEFAULT_AUTO_GC_CONFIG,
|
|
136
|
+
minMemoryCount: 1,
|
|
137
|
+
minHoursSinceLastGc: 0,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const result = await maybeRunGc(store as any, config);
|
|
141
|
+
expect(result.triggered).toBe(true);
|
|
142
|
+
expect(result.archivedCount).toBe(0);
|
|
143
|
+
expect(updates.length).toBe(0);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
test("usage-adjusted GC is gated and can archive cold high-frequency memories", async () => {
|
|
147
|
+
const savedUsageDecay = process.env.RECALLNEST_USAGE_DECAY;
|
|
148
|
+
const savedConstructive = process.env.RECALLNEST_CONSTRUCTIVE_RETRIEVAL;
|
|
149
|
+
try {
|
|
150
|
+
const now = Date.now();
|
|
151
|
+
const oldTimestamp = now - 180 * 86_400_000;
|
|
152
|
+
const coldMeta = JSON.stringify({
|
|
153
|
+
accessCount: 10,
|
|
154
|
+
evolution: {
|
|
155
|
+
status: "active",
|
|
156
|
+
version: 1,
|
|
157
|
+
accessCount: 10,
|
|
158
|
+
lastAccessedAt: now,
|
|
159
|
+
validFrom: oldTimestamp,
|
|
160
|
+
validUntil: null,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
const config: AutoGcConfig = {
|
|
164
|
+
...DEFAULT_AUTO_GC_CONFIG,
|
|
165
|
+
minMemoryCount: 1,
|
|
166
|
+
minHoursSinceLastGc: 0,
|
|
167
|
+
decayScoreThreshold: 0.15,
|
|
168
|
+
minAgeDays: 30,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
delete process.env.RECALLNEST_USAGE_DECAY;
|
|
172
|
+
delete process.env.RECALLNEST_CONSTRUCTIVE_RETRIEVAL;
|
|
173
|
+
resetGcTimestamp();
|
|
174
|
+
const withoutFlag = makeStore([
|
|
175
|
+
{ id: "cold-no-flag", importance: 0.05, timestamp: oldTimestamp, metadata: coldMeta },
|
|
176
|
+
]);
|
|
177
|
+
const baseline = await maybeRunGc(withoutFlag.store as any, config);
|
|
178
|
+
expect(baseline.archivedCount).toBe(0);
|
|
179
|
+
expect(withoutFlag.updates).toHaveLength(0);
|
|
180
|
+
|
|
181
|
+
process.env.RECALLNEST_USAGE_DECAY = "true";
|
|
182
|
+
process.env.RECALLNEST_CONSTRUCTIVE_RETRIEVAL = "true";
|
|
183
|
+
resetGcTimestamp();
|
|
184
|
+
const withFlag = makeStore([
|
|
185
|
+
{ id: "cold-with-flag", importance: 0.05, timestamp: oldTimestamp, metadata: coldMeta },
|
|
186
|
+
]);
|
|
187
|
+
const adjusted = await maybeRunGc(withFlag.store as any, config);
|
|
188
|
+
expect(adjusted.archivedCount).toBe(1);
|
|
189
|
+
expect(withFlag.updates).toHaveLength(1);
|
|
190
|
+
} finally {
|
|
191
|
+
if (savedUsageDecay === undefined) delete process.env.RECALLNEST_USAGE_DECAY;
|
|
192
|
+
else process.env.RECALLNEST_USAGE_DECAY = savedUsageDecay;
|
|
193
|
+
if (savedConstructive === undefined) delete process.env.RECALLNEST_CONSTRUCTIVE_RETRIEVAL;
|
|
194
|
+
else process.env.RECALLNEST_CONSTRUCTIVE_RETRIEVAL = savedConstructive;
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
test("skips recently created memories", async () => {
|
|
199
|
+
resetGcTimestamp();
|
|
200
|
+
const recentMeta = JSON.stringify({
|
|
201
|
+
evolution: {
|
|
202
|
+
status: "active",
|
|
203
|
+
version: 1,
|
|
204
|
+
accessCount: 0,
|
|
205
|
+
lastAccessedAt: null,
|
|
206
|
+
validFrom: Date.now(),
|
|
207
|
+
validUntil: null,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const { store, updates } = makeStore([
|
|
212
|
+
{ id: "recent", importance: 0.1, timestamp: Date.now(), metadata: recentMeta },
|
|
213
|
+
]);
|
|
214
|
+
|
|
215
|
+
const config: AutoGcConfig = {
|
|
216
|
+
...DEFAULT_AUTO_GC_CONFIG,
|
|
217
|
+
minMemoryCount: 1,
|
|
218
|
+
minHoursSinceLastGc: 0,
|
|
219
|
+
minAgeDays: 30,
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const result = await maybeRunGc(store as any, config);
|
|
223
|
+
expect(result.triggered).toBe(true);
|
|
224
|
+
expect(result.archivedCount).toBe(0);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
test("does not trigger when below memory threshold", async () => {
|
|
228
|
+
resetGcTimestamp();
|
|
229
|
+
const { store } = makeStore([
|
|
230
|
+
{ id: "one", importance: 0.1, timestamp: Date.now() - 90 * 86_400_000, metadata: "{}" },
|
|
231
|
+
]);
|
|
232
|
+
|
|
233
|
+
const result = await maybeRunGc(store as any, {
|
|
234
|
+
...DEFAULT_AUTO_GC_CONFIG,
|
|
235
|
+
minMemoryCount: 1000,
|
|
236
|
+
});
|
|
237
|
+
expect(result.triggered).toBe(false);
|
|
238
|
+
expect(result.reason).toBe("below_memory_threshold");
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
// ---------------------------------------------------------------------------
|
|
244
|
+
// E-1: Access Count Boost Tests (via computeDecayScore)
|
|
245
|
+
// ---------------------------------------------------------------------------
|
|
246
|
+
|
|
247
|
+
describe("E-1: Multi-factor Retrieval Scoring", () => {
|
|
248
|
+
test("higher accessCount produces higher decay score", () => {
|
|
249
|
+
const base: EvolutionMetadata = {
|
|
250
|
+
status: "active",
|
|
251
|
+
version: 1,
|
|
252
|
+
accessCount: 0,
|
|
253
|
+
lastAccessedAt: null,
|
|
254
|
+
supersededBy: null,
|
|
255
|
+
consolidatedInto: null,
|
|
256
|
+
sourceMemories: [],
|
|
257
|
+
validFrom: Date.now() - 30 * 86_400_000,
|
|
258
|
+
validUntil: null,
|
|
259
|
+
};
|
|
260
|
+
const lowAccess = computeDecayScore(base, 0.5);
|
|
261
|
+
const highAccess = computeDecayScore({ ...base, accessCount: 10, lastAccessedAt: Date.now() }, 0.5);
|
|
262
|
+
expect(highAccess).toBeGreaterThan(lowAccess);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
test("higher importance produces higher decay score", () => {
|
|
266
|
+
const base: EvolutionMetadata = {
|
|
267
|
+
status: "active",
|
|
268
|
+
version: 1,
|
|
269
|
+
accessCount: 2,
|
|
270
|
+
lastAccessedAt: Date.now() - 86_400_000,
|
|
271
|
+
supersededBy: null,
|
|
272
|
+
consolidatedInto: null,
|
|
273
|
+
sourceMemories: [],
|
|
274
|
+
validFrom: Date.now() - 30 * 86_400_000,
|
|
275
|
+
validUntil: null,
|
|
276
|
+
};
|
|
277
|
+
const lowImportance = computeDecayScore(base, 0.3);
|
|
278
|
+
const highImportance = computeDecayScore(base, 0.9);
|
|
279
|
+
expect(highImportance).toBeGreaterThan(lowImportance);
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test("older memories without access have lower decay scores", () => {
|
|
283
|
+
const recent: EvolutionMetadata = {
|
|
284
|
+
status: "active",
|
|
285
|
+
version: 1,
|
|
286
|
+
accessCount: 0,
|
|
287
|
+
lastAccessedAt: null,
|
|
288
|
+
supersededBy: null,
|
|
289
|
+
consolidatedInto: null,
|
|
290
|
+
sourceMemories: [],
|
|
291
|
+
validFrom: Date.now() - 7 * 86_400_000,
|
|
292
|
+
validUntil: null,
|
|
293
|
+
};
|
|
294
|
+
const old: EvolutionMetadata = {
|
|
295
|
+
...recent,
|
|
296
|
+
validFrom: Date.now() - 180 * 86_400_000,
|
|
297
|
+
};
|
|
298
|
+
expect(computeDecayScore(recent, 0.5)).toBeGreaterThan(computeDecayScore(old, 0.5));
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
describe("P0 B-2: usage-adjusted GC scoring", () => {
|
|
303
|
+
const now = Date.now();
|
|
304
|
+
const oldColdEvo: EvolutionMetadata = {
|
|
305
|
+
status: "active",
|
|
306
|
+
version: 1,
|
|
307
|
+
accessCount: 10,
|
|
308
|
+
lastAccessedAt: now,
|
|
309
|
+
supersededBy: null,
|
|
310
|
+
supersedes: null,
|
|
311
|
+
evolutionNote: null,
|
|
312
|
+
consolidatedInto: null,
|
|
313
|
+
contributedToPattern: null,
|
|
314
|
+
sourceMemories: [],
|
|
315
|
+
validFrom: now - 180 * 86_400_000,
|
|
316
|
+
validUntil: null,
|
|
317
|
+
eventTime: null,
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
test("discounts frequency only for cold memories in GC scoring", () => {
|
|
321
|
+
const metadata = JSON.stringify({ accessCount: 10 });
|
|
322
|
+
const base = computeDecayScore(oldColdEvo, 0.05, now, metadata);
|
|
323
|
+
const adjusted = computeUsageAdjustedDecayScore(oldColdEvo, 0.05, now, metadata);
|
|
324
|
+
|
|
325
|
+
expect(base).toBeGreaterThan(0.15);
|
|
326
|
+
expect(adjusted).toBeLessThan(base);
|
|
327
|
+
expect(adjusted).toBeLessThan(0.15);
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
test("does not discount pending reminders or promoted memories", () => {
|
|
331
|
+
const pendingReminder = JSON.stringify({
|
|
332
|
+
accessCount: 10,
|
|
333
|
+
prospective: { status: "pending" },
|
|
334
|
+
});
|
|
335
|
+
const promoted = JSON.stringify({
|
|
336
|
+
accessCount: 10,
|
|
337
|
+
promotedTo: "memory:durable-target",
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
expect(computeUsageAdjustedDecayScore(oldColdEvo, 0.05, now, pendingReminder))
|
|
341
|
+
.toBe(computeDecayScore(oldColdEvo, 0.05, now, pendingReminder));
|
|
342
|
+
expect(computeUsageAdjustedDecayScore(oldColdEvo, 0.05, now, promoted))
|
|
343
|
+
.toBe(computeDecayScore(oldColdEvo, 0.05, now, promoted));
|
|
344
|
+
});
|
|
345
|
+
});
|