recallnest 2.2.0 → 2.2.1
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/.env +4 -0
- package/config.json +55 -0
- package/logs/daily-recall.error.log +0 -0
- package/logs/daily-recall.log +30 -0
- package/logs/ingest-2026-04-11.log +110 -0
- package/logs/ingest-2026-04-12.log +90 -0
- package/logs/launchagent-stderr.log +0 -0
- package/logs/launchagent-stdout.log +0 -0
- package/package.json +1 -1
- package/.claude-plugin/CLAUDE.md +0 -29
- package/.claude-plugin/marketplace.json +0 -18
- package/.dockerignore +0 -11
- package/.github/workflows/ci.yml +0 -28
- package/.mcp.json +0 -9
- package/CHANGELOG.md +0 -51
- package/DEMO.md +0 -94
- package/Dockerfile +0 -20
- package/EVAL.md +0 -89
- package/FAILURES.md +0 -75
- package/OPERATIONS.md +0 -59
- package/ROADMAP.md +0 -245
- package/SKILL.md +0 -250
- package/assets/dashboard.png +0 -0
- package/assets/knowledge-graph.png +0 -0
- package/assets/recallnest-workbench.png +0 -0
- package/assets/screenshots/ui-full.png +0 -0
- package/assets/screenshots/ui-overview.png +0 -0
- package/assets/screenshots/ui-search.png +0 -0
- package/assets/ui/app.js +0 -1031
- package/assets/ui/index.html +0 -224
- package/assets/ui/styles.css +0 -781
- package/assets/wechat-qr.jpg +0 -0
- package/bun.lock +0 -337
- package/daily-reflections/2026-03-05.md +0 -15
- package/daily-reflections/2026-03-06.md +0 -15
- package/daily-reflections/2026-03-07.md +0 -7
- package/daily-reflections/2026-03-08.md +0 -34
- package/daily-reflections/2026-03-09.md +0 -35
- package/daily-reflections/2026-03-10.md +0 -36
- package/daily-reflections/2026-03-11.md +0 -35
- package/daily-reflections/2026-03-12.md +0 -36
- package/daily-reflections/2026-03-13.md +0 -35
- package/daily-reflections/2026-03-14.md +0 -35
- package/daily-reflections/2026-03-15.md +0 -35
- package/daily-reflections/2026-03-16.md +0 -41
- package/daily-reflections/2026-03-17.md +0 -10
- package/daily-reflections/2026-03-18.md +0 -10
- package/daily-reflections/2026-03-19.md +0 -10
- package/daily-reflections/2026-03-20.md +0 -10
- package/daily-reflections/2026-03-21.md +0 -10
- package/daily-reflections/2026-03-22.md +0 -10
- package/daily-reflections/2026-03-23.md +0 -10
- package/daily-reflections/2026-03-24.md +0 -10
- package/daily-reflections/2026-03-25.md +0 -32
- package/daily-reflections/2026-03-26.md +0 -37
- package/daily-reflections/2026-03-27.md +0 -35
- package/daily-reflections/2026-03-28.md +0 -35
- package/daily-reflections/2026-03-29.md +0 -35
- package/daily-reflections/2026-03-30.md +0 -36
- package/daily-reflections/2026-03-31.md +0 -35
- package/daily-reflections/2026-04-01.md +0 -35
- package/daily-reflections/2026-04-02.md +0 -35
- package/daily-reflections/2026-04-03.md +0 -37
- package/daily-reflections/2026-04-04.md +0 -37
- package/daily-reflections/2026-04-05.md +0 -35
- package/daily-reflections/2026-04-06.md +0 -36
- package/daily-reflections/2026-04-07.md +0 -35
- package/daily-reflections/2026-04-08.md +0 -35
- package/daily-reflections/2026-04-12.md +0 -35
- package/data/alias-map.example.json +0 -22
- package/docs/api-reference.md +0 -1291
- package/docs/architecture.md +0 -168
- package/docs/memory-boundary-contract.md +0 -226
- package/docs/memory-categories.md +0 -119
- package/docs/pipeline-audit-ultramemory.md +0 -177
- package/docs/plans/2026-03-08-query-expansion.md +0 -270
- package/docs/plans/2026-03-16-continuity-layer.md +0 -196
- package/docs/plans/2026-04-01-recall-boost.md +0 -100
- package/docs/plans/mcp-tiering-plan.md +0 -126
- package/docs/research/recall-quality-audit-2026-03-22.md +0 -153
- package/docs/self-evolution.md +0 -198
- package/docs/superpowers/plans/2026-03-19-ingest-pipeline-upgrade.md +0 -782
- package/docs/superpowers/plans/2026-04-11-constructive-retrieval-emotion.md +0 -1195
- package/docs/superpowers/specs/2026-03-19-ingest-pipeline-upgrade-design.md +0 -77
- package/docs/superpowers/specs/2026-03-23-pull-claude-desktop-design.md +0 -95
- package/docs/superpowers/specs/2026-04-11-constructive-retrieval-emotion-design.md +0 -398
- package/eval/continuity/results-2026-03-16.md +0 -117
- package/eval/continuity/results-2026-03-19.md +0 -453
- package/eval/continuity/runbook.md +0 -110
- package/eval/continuity/seed-cases.md +0 -54
- package/eval/reports/2026-03-06-abstract-query-baseline.md +0 -96
- package/eval/reports/2026-03-06-aws-ssh-baseline.md +0 -82
- package/eval/reports/2026-03-06-baseline.md +0 -82
- package/eval/reports/query-expansion.md +0 -138
- package/glama.json +0 -6
- package/lm +0 -19
- package/plan-philosophy-upgrades.md +0 -363
- package/plan-product-upgrades.md +0 -155
- package/plan-v1.2-distributable.md +0 -105
- package/plan.md +0 -140
- package/research-memory-evolution.md +0 -440
- package/research-rl-agent-memory.md +0 -330
- package/scripts/archive-distilled-junk.ts +0 -116
- package/scripts/backfill-anchors.ts +0 -130
- package/scripts/backfill-l0l1l2.ts +0 -98
- package/scripts/blind-scan.ts +0 -588
- package/scripts/cleanup-step1-exact-dups.ts +0 -117
- package/scripts/cleanup-step2-template-dups.ts +0 -113
- package/scripts/cleanup-step3-stale-content.ts +0 -149
- package/scripts/cleanup-step4-orphan-scopes.ts +0 -131
- package/scripts/delete-distilled-junk.ts +0 -88
- package/scripts/diagnose-vector-search.ts +0 -132
- package/scripts/distill-facts.ts +0 -305
- package/scripts/health-check.ts +0 -343
- package/scripts/incremental-ingest.sh +0 -71
- package/scripts/migrate-language.ts +0 -75
- package/scripts/mlp-health-check.ts +0 -382
- package/scripts/pull-claude-desktop.ts +0 -515
- package/scripts/re-ingest-cc.sh +0 -66
- package/scripts/rebalance-memory-health.ts +0 -181
- package/scripts/run-desktop-ingest.sh +0 -11
- package/scripts/start-server.sh +0 -12
- package/scripts/verify-emotion-decay.ts +0 -148
- package/scripts/viz-dashboard.html +0 -423
- package/scripts/viz-export.ts +0 -703
- package/src/__tests__/access-tracker-novelty.test.ts +0 -228
- package/src/__tests__/activity-counter.test.ts +0 -96
- package/src/__tests__/admission-control.test.ts +0 -206
- package/src/__tests__/anchor-generator.test.ts +0 -67
- package/src/__tests__/auto-consolidation.test.ts +0 -168
- package/src/__tests__/auto-recall.test.ts +0 -131
- package/src/__tests__/babel-integration.test.ts +0 -139
- package/src/__tests__/batch-dedup.test.ts +0 -65
- package/src/__tests__/capture-engine.test.ts +0 -1144
- package/src/__tests__/capture-heuristic.test.ts +0 -171
- package/src/__tests__/cascade-forget.test.ts +0 -210
- package/src/__tests__/category-min-scores.test.ts +0 -33
- package/src/__tests__/cc8-cc1-essential-context.test.ts +0 -298
- package/src/__tests__/circuit-breaker.test.ts +0 -99
- package/src/__tests__/cluster-consolidation.test.ts +0 -712
- package/src/__tests__/confidence-metadata.test.ts +0 -125
- package/src/__tests__/confidence-tracker.test.ts +0 -249
- package/src/__tests__/conflict-advisor.test.ts +0 -206
- package/src/__tests__/conflict-escalation.test.ts +0 -149
- package/src/__tests__/conflict-lifecycle.test.ts +0 -83
- package/src/__tests__/conflict-output.test.ts +0 -85
- package/src/__tests__/conflict-store.test.ts +0 -374
- package/src/__tests__/consolidation-engine.test.ts +0 -181
- package/src/__tests__/constructive-retrieval.test.ts +0 -509
- package/src/__tests__/context-collapse-renderer.test.ts +0 -214
- package/src/__tests__/context-composer-pins.test.ts +0 -64
- package/src/__tests__/context-composer-task-selection.test.ts +0 -24
- package/src/__tests__/context-reconstructor.test.ts +0 -65
- package/src/__tests__/context-renderer.test.ts +0 -91
- package/src/__tests__/continuity-eval.test.ts +0 -275
- package/src/__tests__/continuity-schema.test.ts +0 -97
- package/src/__tests__/conversation-importer.test.ts +0 -692
- package/src/__tests__/core-recall-eval.test.ts +0 -235
- package/src/__tests__/core-summary.test.ts +0 -109
- package/src/__tests__/data-checkup.test.ts +0 -225
- package/src/__tests__/decay-exemption.test.ts +0 -84
- package/src/__tests__/dedup-actions.test.ts +0 -58
- package/src/__tests__/dedup-guard.test.ts +0 -39
- package/src/__tests__/deterministic-id.test.ts +0 -39
- package/src/__tests__/distill-lock.test.ts +0 -176
- package/src/__tests__/doctor.test.ts +0 -303
- package/src/__tests__/dream-pipeline.test.ts +0 -232
- package/src/__tests__/drill-down.test.ts +0 -108
- package/src/__tests__/embedder.test.ts +0 -122
- package/src/__tests__/emotion-decay.test.ts +0 -46
- package/src/__tests__/emotion-detector.test.ts +0 -56
- package/src/__tests__/emotion-phase1-integration.test.ts +0 -153
- package/src/__tests__/emotion-retrieval.test.ts +0 -56
- package/src/__tests__/entity-resolver.test.ts +0 -58
- package/src/__tests__/ethics-layer.test.ts +0 -476
- package/src/__tests__/event-segmenter.test.ts +0 -153
- package/src/__tests__/feature-flags-integration.test.ts +0 -54
- package/src/__tests__/frequency-tracker.test.ts +0 -113
- package/src/__tests__/graph-export.test.ts +0 -489
- package/src/__tests__/hotness-blend.test.ts +0 -76
- package/src/__tests__/ingest.test.ts +0 -360
- package/src/__tests__/interference-detector.test.ts +0 -203
- package/src/__tests__/kg-extractor.test.ts +0 -184
- package/src/__tests__/kg-store.test.ts +0 -198
- package/src/__tests__/llm-consolidation.test.ts +0 -226
- package/src/__tests__/mcp-efficiency.test.ts +0 -288
- package/src/__tests__/memory-boundaries.test.ts +0 -237
- package/src/__tests__/memory-evolution-b2-b3-e1.test.ts +0 -243
- package/src/__tests__/memory-evolution.test.ts +0 -271
- package/src/__tests__/memory-health-rebalance.test.ts +0 -144
- package/src/__tests__/memory-lint.test.ts +0 -271
- package/src/__tests__/memory-output.test.ts +0 -215
- package/src/__tests__/multi-vector.test.ts +0 -242
- package/src/__tests__/narrative-architecture.test.ts +0 -456
- package/src/__tests__/pending-review.test.ts +0 -77
- package/src/__tests__/post-retrieval-filter.test.ts +0 -178
- package/src/__tests__/ppr-traversal.test.ts +0 -256
- package/src/__tests__/prediction-engine.test.ts +0 -349
- package/src/__tests__/predictive-prospective-memory.test.ts +0 -416
- package/src/__tests__/preference-guard-smoke.test.ts +0 -211
- package/src/__tests__/preference-matcher.test.ts +0 -230
- package/src/__tests__/preference-slots.test.ts +0 -205
- package/src/__tests__/prospective-memory.test.ts +0 -283
- package/src/__tests__/query-entity-detector.test.ts +0 -171
- package/src/__tests__/query-expander-alias.test.ts +0 -89
- package/src/__tests__/query-expander.test.ts +0 -34
- package/src/__tests__/recall-governor.test.ts +0 -227
- package/src/__tests__/recall-mode.test.ts +0 -64
- package/src/__tests__/result-synthesizer.test.ts +0 -198
- package/src/__tests__/resume-context.test.ts +0 -4898
- package/src/__tests__/retrieval-trace.test.ts +0 -213
- package/src/__tests__/retriever-boundary-weight.test.ts +0 -136
- package/src/__tests__/retroactive-boost.test.ts +0 -223
- package/src/__tests__/salience-scoring.test.ts +0 -106
- package/src/__tests__/scope-inventory.test.ts +0 -200
- package/src/__tests__/scope-policy.test.ts +0 -69
- package/src/__tests__/session-checkpoint.test.ts +0 -259
- package/src/__tests__/session-distiller.test.ts +0 -611
- package/src/__tests__/session-gc.test.ts +0 -215
- package/src/__tests__/skill-engine.test.ts +0 -546
- package/src/__tests__/skill-promotion.test.ts +0 -349
- package/src/__tests__/store-scope-audit.test.ts +0 -81
- package/src/__tests__/supersede-chain.test.ts +0 -154
- package/src/__tests__/temporal-parser.test.ts +0 -241
- package/src/__tests__/temporal-validity.test.ts +0 -160
- package/src/__tests__/term-registry.test.ts +0 -121
- package/src/__tests__/tool-output-compressor.test.ts +0 -133
- package/src/__tests__/topic-tag.test.ts +0 -113
- package/src/__tests__/trusted-memory.test.ts +0 -828
- package/src/__tests__/version-manager.test.ts +0 -213
- package/src/__tests__/workflow-observation.test.ts +0 -400
- package/src/__tests__/write-verifier.test.ts +0 -122
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phase 1 integration tests: Emotional Valence in Decay pipeline.
|
|
3
|
-
*
|
|
4
|
-
* Validates the full wiring:
|
|
5
|
-
* 1. detectEmotion → salience + source fields
|
|
6
|
-
* 2. computeDecayScore → emotion-aware weights (0.15/0.25/0.45/0.15)
|
|
7
|
-
* 3. Backward compatibility when emotion flag is off or metadata absent
|
|
8
|
-
*/
|
|
9
|
-
import { describe, test, expect } from "bun:test";
|
|
10
|
-
import { detectEmotion } from "../emotion-detector.js";
|
|
11
|
-
import { computeDecayScore, type EvolutionMetadata } from "../memory-evolution.js";
|
|
12
|
-
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
// 1. detectEmotion: salience + source fields
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
describe("detectEmotion salience & source", () => {
|
|
18
|
-
test("returns salience field as (|valence| + arousal) / 2", () => {
|
|
19
|
-
const result = detectEmotion("Finally fixed that horrible production bug after 3 days!");
|
|
20
|
-
expect(result.salience).toBeDefined();
|
|
21
|
-
expect(typeof result.salience).toBe("number");
|
|
22
|
-
// salience = (|valence| + arousal) / 2
|
|
23
|
-
const expected = (Math.abs(result.valence) + result.arousal) / 2;
|
|
24
|
-
expect(result.salience).toBeCloseTo(expected, 5);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("returns source: keyword", () => {
|
|
28
|
-
const result = detectEmotion("This is a great success!");
|
|
29
|
-
expect(result.source).toBe("keyword");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test("neutral text returns salience 0", () => {
|
|
33
|
-
const result = detectEmotion("The meeting is at 3pm tomorrow.");
|
|
34
|
-
expect(result.salience).toBe(0);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test("empty text returns salience 0 and source keyword", () => {
|
|
38
|
-
const result = detectEmotion("");
|
|
39
|
-
expect(result.salience).toBe(0);
|
|
40
|
-
expect(result.source).toBe("keyword");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("high emotion + high arousal gives high salience", () => {
|
|
44
|
-
const result = detectEmotion("CRITICAL BUG! Everything is broken! Urgent fix needed!");
|
|
45
|
-
expect(result.salience).toBeGreaterThan(0.2);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("salience is clamped to [0, 1]", () => {
|
|
49
|
-
const result = detectEmotion("fail fail fail broken broken crash crash urgent urgent critical critical !!!");
|
|
50
|
-
expect(result.salience).toBeGreaterThanOrEqual(0);
|
|
51
|
-
expect(result.salience).toBeLessThanOrEqual(1);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
56
|
-
// 2. computeDecayScore: emotion-aware weights
|
|
57
|
-
// ---------------------------------------------------------------------------
|
|
58
|
-
|
|
59
|
-
describe("computeDecayScore with emotion", () => {
|
|
60
|
-
const now = Date.now();
|
|
61
|
-
const baseEvo: EvolutionMetadata = {
|
|
62
|
-
status: "active",
|
|
63
|
-
version: 1,
|
|
64
|
-
accessCount: 3,
|
|
65
|
-
lastAccessedAt: now - 7 * 86_400_000, // 7 days ago
|
|
66
|
-
supersededBy: null,
|
|
67
|
-
supersedes: null,
|
|
68
|
-
evolutionNote: null,
|
|
69
|
-
consolidatedInto: null,
|
|
70
|
-
contributedToPattern: null,
|
|
71
|
-
sourceMemories: [],
|
|
72
|
-
validFrom: now - 30 * 86_400_000, // 30 days old
|
|
73
|
-
validUntil: null,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// Save and restore env
|
|
77
|
-
const origFlag = process.env.RECALLNEST_EMOTION_SCORING;
|
|
78
|
-
|
|
79
|
-
test("with emotion flag ON and metadata, emotional memory scores higher", () => {
|
|
80
|
-
process.env.RECALLNEST_EMOTION_SCORING = "true";
|
|
81
|
-
try {
|
|
82
|
-
const emotionalMeta = JSON.stringify({
|
|
83
|
-
emotion: { valence: -0.9, arousal: 0.8, label: "frustration", salience: 0.85, source: "keyword" },
|
|
84
|
-
});
|
|
85
|
-
const neutralMeta = JSON.stringify({
|
|
86
|
-
emotion: { valence: 0, arousal: 0, label: "neutral", salience: 0, source: "keyword" },
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const emotionalScore = computeDecayScore(baseEvo, 0.5, now, emotionalMeta);
|
|
90
|
-
const neutralScore = computeDecayScore(baseEvo, 0.5, now, neutralMeta);
|
|
91
|
-
|
|
92
|
-
expect(emotionalScore).toBeGreaterThan(neutralScore);
|
|
93
|
-
} finally {
|
|
94
|
-
process.env.RECALLNEST_EMOTION_SCORING = origFlag;
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test("with emotion flag ON, weights sum close to 1.0", () => {
|
|
99
|
-
process.env.RECALLNEST_EMOTION_SCORING = "true";
|
|
100
|
-
try {
|
|
101
|
-
// At max values: time=1, freq=1, importance=1, salience=1
|
|
102
|
-
// Score should be 0.15 + 0.25 + 0.45 + 0.15 = 1.0
|
|
103
|
-
const freshEvo: EvolutionMetadata = {
|
|
104
|
-
...baseEvo,
|
|
105
|
-
accessCount: 100,
|
|
106
|
-
lastAccessedAt: now,
|
|
107
|
-
validFrom: now, // just created
|
|
108
|
-
};
|
|
109
|
-
const maxMeta = JSON.stringify({
|
|
110
|
-
emotion: { valence: 1, arousal: 1, label: "positive", salience: 1, source: "keyword" },
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const score = computeDecayScore(freshEvo, 1.0, now, maxMeta);
|
|
114
|
-
expect(score).toBeCloseTo(1.0, 1);
|
|
115
|
-
} finally {
|
|
116
|
-
process.env.RECALLNEST_EMOTION_SCORING = origFlag;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
test("backward compat: no metadata param still works", () => {
|
|
121
|
-
const score = computeDecayScore(baseEvo, 0.5, now);
|
|
122
|
-
expect(score).toBeGreaterThan(0);
|
|
123
|
-
expect(score).toBeLessThanOrEqual(1);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test("backward compat: metadata without emotion still works", () => {
|
|
127
|
-
process.env.RECALLNEST_EMOTION_SCORING = "true";
|
|
128
|
-
try {
|
|
129
|
-
const noEmotionMeta = JSON.stringify({ tier: "working" });
|
|
130
|
-
const score = computeDecayScore(baseEvo, 0.5, now, noEmotionMeta);
|
|
131
|
-
expect(score).toBeGreaterThan(0);
|
|
132
|
-
expect(score).toBeLessThanOrEqual(1);
|
|
133
|
-
} finally {
|
|
134
|
-
process.env.RECALLNEST_EMOTION_SCORING = origFlag;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
test("with emotion flag OFF, metadata is ignored (base weights)", () => {
|
|
139
|
-
process.env.RECALLNEST_EMOTION_SCORING = "";
|
|
140
|
-
try {
|
|
141
|
-
const emotionalMeta = JSON.stringify({
|
|
142
|
-
emotion: { valence: -0.9, arousal: 0.8, label: "frustration", salience: 0.85, source: "keyword" },
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
const withMeta = computeDecayScore(baseEvo, 0.5, now, emotionalMeta);
|
|
146
|
-
const withoutMeta = computeDecayScore(baseEvo, 0.5, now);
|
|
147
|
-
|
|
148
|
-
expect(withMeta).toBeCloseTo(withoutMeta, 5);
|
|
149
|
-
} finally {
|
|
150
|
-
process.env.RECALLNEST_EMOTION_SCORING = origFlag;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { describe, test, expect } from "bun:test";
|
|
2
|
-
import { applyEmotionWeight } from "../retriever.js";
|
|
3
|
-
|
|
4
|
-
describe("applyEmotionWeight", () => {
|
|
5
|
-
const makeResult = (id: string, score: number, emotionJson?: object) => ({
|
|
6
|
-
id,
|
|
7
|
-
text: "test",
|
|
8
|
-
vector: [],
|
|
9
|
-
category: "events" as const,
|
|
10
|
-
scope: "test",
|
|
11
|
-
importance: 0.5,
|
|
12
|
-
timestamp: Date.now(),
|
|
13
|
-
metadata: emotionJson ? JSON.stringify({ emotion: emotionJson }) : "{}",
|
|
14
|
-
score,
|
|
15
|
-
sources: {},
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("null query emotion returns unchanged", () => {
|
|
19
|
-
const results = [makeResult("a", 0.8, { valence: 0.9, arousal: 0.5 })];
|
|
20
|
-
const output = applyEmotionWeight(results, null);
|
|
21
|
-
expect(output[0].score).toBe(0.8);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("low-valence query returns unchanged", () => {
|
|
25
|
-
const queryEmotion = { valence: 0.1, arousal: 0, label: "neutral" };
|
|
26
|
-
const results = [makeResult("a", 0.8, { valence: 0.9, arousal: 0.5 })];
|
|
27
|
-
const output = applyEmotionWeight(results, queryEmotion);
|
|
28
|
-
expect(output[0].score).toBe(0.8);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test("negative query boosts negative memories", () => {
|
|
32
|
-
const queryEmotion = { valence: -0.8, arousal: 0.5, label: "frustration" };
|
|
33
|
-
const results = [
|
|
34
|
-
makeResult("neg", 0.7, { valence: -0.7, arousal: 0.5 }),
|
|
35
|
-
makeResult("pos", 0.7, { valence: 0.8, arousal: 0.3 }),
|
|
36
|
-
];
|
|
37
|
-
const output = applyEmotionWeight(results, queryEmotion);
|
|
38
|
-
expect(output.find(r => r.id === "neg")!.score).toBeGreaterThan(
|
|
39
|
-
output.find(r => r.id === "pos")!.score
|
|
40
|
-
);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("no emotion data leaves score unchanged", () => {
|
|
44
|
-
const queryEmotion = { valence: -0.8, arousal: 0.5, label: "negative" };
|
|
45
|
-
const results = [makeResult("no-emo", 0.7)];
|
|
46
|
-
const output = applyEmotionWeight(results, queryEmotion);
|
|
47
|
-
expect(output[0].score).toBe(0.7);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("max boost is 15%", () => {
|
|
51
|
-
const queryEmotion = { valence: 1.0, arousal: 1.0, label: "positive" };
|
|
52
|
-
const results = [makeResult("a", 1.0, { valence: 1.0, arousal: 1.0 })];
|
|
53
|
-
const output = applyEmotionWeight(results, queryEmotion);
|
|
54
|
-
expect(output[0].score).toBeCloseTo(1.15, 2);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
|
|
3
|
-
import { EntityResolver, BUILTIN_ALIASES, defaultResolver, resolveQueryEntities } from "../entity-resolver.js";
|
|
4
|
-
|
|
5
|
-
describe("EntityResolver", () => {
|
|
6
|
-
it("resolves known aliases", () => {
|
|
7
|
-
expect(defaultResolver.resolve("ts")).toBe("typescript");
|
|
8
|
-
expect(defaultResolver.resolve("TS")).toBe("typescript");
|
|
9
|
-
expect(defaultResolver.resolve("k8s")).toBe("kubernetes");
|
|
10
|
-
expect(defaultResolver.resolve("pg")).toBe("postgresql");
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("returns term as-is for unknown aliases", () => {
|
|
14
|
-
expect(defaultResolver.resolve("unknownThing")).toBe("unknownThing");
|
|
15
|
-
expect(defaultResolver.resolve("")).toBe("");
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("supports user aliases that override builtins", () => {
|
|
19
|
-
const resolver = new EntityResolver(BUILTIN_ALIASES, { "ts": "my-custom-ts" });
|
|
20
|
-
expect(resolver.resolve("ts")).toBe("my-custom-ts");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it("resolveText replaces aliases in context", () => {
|
|
24
|
-
const text = "I'm using TS with k8s and pg for the backend";
|
|
25
|
-
const resolved = defaultResolver.resolveText(text);
|
|
26
|
-
expect(resolved).toContain("typescript");
|
|
27
|
-
expect(resolved).toContain("kubernetes");
|
|
28
|
-
expect(resolved).toContain("postgresql");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("resolveText handles longer aliases first", () => {
|
|
32
|
-
const text = "Using docker-compose for local dev";
|
|
33
|
-
const resolved = defaultResolver.resolveText(text);
|
|
34
|
-
expect(resolved).toContain("docker compose");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("hasAlias returns true for known aliases", () => {
|
|
38
|
-
expect(defaultResolver.hasAlias("ts")).toBe(true);
|
|
39
|
-
expect(defaultResolver.hasAlias("unknown")).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("size returns the number of aliases", () => {
|
|
43
|
-
expect(defaultResolver.size).toBeGreaterThan(40);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe("resolveQueryEntities", () => {
|
|
48
|
-
it("normalizes entities in a search query", () => {
|
|
49
|
-
const result = resolveQueryEntities("search for ts config in k8s");
|
|
50
|
-
expect(result).toContain("typescript");
|
|
51
|
-
expect(result).toContain("kubernetes");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("passes through queries with no aliases", () => {
|
|
55
|
-
const result = resolveQueryEntities("how to deploy a web app");
|
|
56
|
-
expect(result).toBe("how to deploy a web app");
|
|
57
|
-
});
|
|
58
|
-
});
|