Skip to content

Commit cd30fa7

Browse files
test(memory): verify long suggestions preserve cited facts
Exercise short, boundary-length, over-limit, and whitespace-wrapped long queries against stored project knowledge. Require the cited result without retrieval or receipt side effects.
1 parent 869c47e commit cd30fa7

1 file changed

Lines changed: 21 additions & 29 deletions

File tree

‎apps/server/src/project/knowledge/ProjectKnowledge.test.ts‎

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
ProviderThreadId,
1818
RunAttemptId,
1919
RunId,
20+
THREAD_SEARCH_QUERY_MAX_LENGTH,
2021
ThreadId,
2122
TurnItemId,
2223
type OrchestrationV2DomainEvent,
@@ -1716,22 +1717,6 @@ it.effect.each(["rolled", "edited", "deleted", "project-deleted", "archive"] as
17161717
}).pipe(Effect.provide(receiptTestLayer)),
17171718
);
17181719

1719-
it.effect("accepts long delegated prompts for optional memory suggestions", () =>
1720-
Effect.gen(function* () {
1721-
const knowledge = yield* ProjectKnowledge.ProjectKnowledge;
1722-
const projectId = ProjectId.make("long-delegated-prompt");
1723-
yield* createProject(projectId);
1724-
assert.deepEqual(
1725-
yield* knowledge.suggest({
1726-
projectId,
1727-
requestId: CommandId.make("suggest-long-delegated-prompt"),
1728-
query: "Review SQLite migrations for project memory. ".repeat(100),
1729-
}),
1730-
[],
1731-
);
1732-
}).pipe(Effect.provide(layerTest)),
1733-
);
1734-
17351720
it.effect("browsing searches can opt out of reinforcing retrieval counts", () =>
17361721
Effect.gen(function* () {
17371722
const knowledge = yield* ProjectKnowledge.ProjectKnowledge;
@@ -1764,20 +1749,27 @@ it.effect("browsing searches can opt out of reinforcing retrieval counts", () =>
17641749
}),
17651750
[],
17661751
);
1767-
const suggestions = yield* knowledge.suggest({
1768-
projectId,
1769-
requestId: CommandId.make("suggest-relevant"),
1770-
query: "cache keys tenant",
1771-
});
1772-
assert.equal(suggestions.length, 1);
1773-
assert.equal(suggestions[0]?.fact.id, ProjectFactId.make("fact-one"));
1774-
assert.equal(suggestions[0]?.fact.sources[0]?.kind, "user");
17751752
const sql = yield* SqlClient.SqlClient;
1776-
assert.equal(
1777-
(yield* sql`SELECT command_id FROM project_knowledge_commands WHERE command_id = ${"suggest-relevant"}`)
1778-
.length,
1779-
0,
1780-
);
1753+
const longQuery = "cache keys tenant ".repeat(100);
1754+
for (const [name, query] of [
1755+
["short", "cache keys tenant"],
1756+
["limit", longQuery.slice(0, THREAD_SEARCH_QUERY_MAX_LENGTH)],
1757+
["over-limit", longQuery.slice(0, THREAD_SEARCH_QUERY_MAX_LENGTH + 1)],
1758+
["long-with-whitespace", ` \n\t${longQuery}\n\t `],
1759+
] as const) {
1760+
const requestId = CommandId.make(`suggest-relevant-${name}`);
1761+
const suggestions = yield* knowledge.suggest({ projectId, requestId, query });
1762+
assert.equal(suggestions.length, 1);
1763+
assert.equal(suggestions[0]?.fact.id, ProjectFactId.make("fact-one"));
1764+
assert.equal(suggestions[0]?.fact.sources[0]?.kind, "user");
1765+
assert.equal(suggestions[0]?.fact.retrievalCount, 0);
1766+
assert.equal(yield* storedCount, 0);
1767+
assert.equal(
1768+
(yield* sql`SELECT command_id FROM project_knowledge_commands WHERE command_id = ${requestId}`)
1769+
.length,
1770+
0,
1771+
);
1772+
}
17811773

17821774
assert.deepEqual(
17831775
yield* knowledge.suggest({

0 commit comments

Comments
 (0)