Skip to content

Commit 023589a

Browse files
committed
test: add memory quality eval fixtures
Wave 2 of memory quality optimization plan. - 5 accepted cases: durable facts that should be kept - 7 rejected cases: noise that should be filtered - Parser-level regression guard (zero API call) - All cases pass against current extractors.ts
1 parent 24f807f commit 023589a

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

tests/memory-quality-eval.test.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import test from "node:test";
2+
import assert from "node:assert/strict";
3+
import { parseWorkspaceMemoryCandidates } from "../src/extractors.ts";
4+
5+
const acceptedCases = [
6+
{
7+
name: "durable user language preference",
8+
line: "- [feedback] User prefers architecture reviews in Traditional Chinese",
9+
expectedType: "feedback",
10+
expectedText: /Traditional Chinese/,
11+
},
12+
{
13+
name: "stable cache architecture decision",
14+
line: "- [decision] Use frozen workspace memory snapshots plus ephemeral hot state for cache stability",
15+
expectedType: "decision",
16+
expectedText: /frozen workspace memory/,
17+
},
18+
{
19+
name: "stable zero API call constraint",
20+
line: "- [project] The plugin piggybacks memory extraction on OpenCode compaction and should not add extra LLM calls",
21+
expectedType: "project",
22+
expectedText: /extra LLM calls/,
23+
},
24+
{
25+
name: "hard to rediscover reference",
26+
line: "- [reference] Workspace memory uses a frozen system[1] snapshot and pending memories remain in hot session state until compaction",
27+
expectedType: "reference",
28+
expectedText: /system\[1\]/,
29+
},
30+
{
31+
name: "short stable config reference",
32+
line: "- [reference] Config parser supports bracketless format",
33+
expectedType: "reference",
34+
expectedText: /bracketless/,
35+
},
36+
] as const;
37+
38+
const rejectedCases = [
39+
{
40+
name: "test count snapshot",
41+
line: "- [project] 42 tests passed after the latest implementation",
42+
},
43+
{
44+
name: "suite count snapshot",
45+
line: "- [project] 3 suites pass and 0 suites fail right now",
46+
},
47+
{
48+
name: "phase progress snapshot",
49+
line: "- [project] Wave 2 completed successfully",
50+
},
51+
{
52+
name: "commit hash",
53+
line: "- [reference] Commit 4309cb8 contains the promotion accounting fix",
54+
},
55+
{
56+
name: "raw transient error",
57+
line: "- [feedback] TypeError: Cannot read properties of undefined",
58+
},
59+
{
60+
name: "path heavy rediscoverable fact",
61+
line: "- [project] Important files are /src/plugin.ts /src/workspace-memory.ts /src/session-state.ts",
62+
},
63+
{
64+
name: "temporary pending task",
65+
line: "- [decision] currently: run npm test before the next reply",
66+
},
67+
] as const;
68+
69+
for (const item of acceptedCases) {
70+
test(`memory quality accepts ${item.name}`, () => {
71+
const summary = `
72+
Memory candidates:
73+
${item.line}
74+
`;
75+
const entries = parseWorkspaceMemoryCandidates(summary);
76+
77+
assert.equal(entries.length, 1);
78+
assert.equal(entries[0].type, item.expectedType);
79+
assert.match(entries[0].text, item.expectedText);
80+
});
81+
}
82+
83+
for (const item of rejectedCases) {
84+
test(`memory quality rejects ${item.name}`, () => {
85+
const summary = `
86+
Memory candidates:
87+
${item.line}
88+
`;
89+
const entries = parseWorkspaceMemoryCandidates(summary);
90+
91+
assert.equal(entries.length, 0);
92+
});
93+
}

0 commit comments

Comments
 (0)