@sentry/junior-memory 0.132.0 → 0.133.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/dist/index.js +34 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/store.ts +41 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-memory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.133.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"commander": "^14.0.3",
|
|
28
28
|
"drizzle-orm": "^0.45.2",
|
|
29
29
|
"zod": "^4.4.3",
|
|
30
|
-
"@sentry/junior-plugin-api": "0.
|
|
30
|
+
"@sentry/junior-plugin-api": "0.133.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^25.9.1",
|
package/src/store.ts
CHANGED
|
@@ -52,6 +52,8 @@ const DEFAULT_EXPIRED_ARCHIVE_LIMIT = 100;
|
|
|
52
52
|
const PREFERENCE_ADJUDICATION_CANDIDATE_LIMIT = 10;
|
|
53
53
|
const PREFERENCE_ADJUDICATION_VECTOR_LIMIT = 5;
|
|
54
54
|
const VECTOR_SEARCH_OVERFETCH = 4;
|
|
55
|
+
const LEXICAL_RANK_OVERFETCH = 4;
|
|
56
|
+
const MAX_LEXICAL_RANK_CANDIDATES = 1_000;
|
|
55
57
|
const MAX_MEMORY_CONTENT_CHARS = 4_000;
|
|
56
58
|
const EMBEDDING_METRIC = "cosine";
|
|
57
59
|
|
|
@@ -947,7 +949,7 @@ async function listVisibleMemories(args: {
|
|
|
947
949
|
return rows.map(parseMemoryRow);
|
|
948
950
|
}
|
|
949
951
|
|
|
950
|
-
/** Search active
|
|
952
|
+
/** Search a bounded active candidate set with PostgreSQL full-text ranking. */
|
|
951
953
|
async function searchVisibleLexicalMemories(args: {
|
|
952
954
|
db: MemoryDb;
|
|
953
955
|
limit: number;
|
|
@@ -967,20 +969,49 @@ async function searchVisibleLexicalMemories(args: {
|
|
|
967
969
|
)
|
|
968
970
|
FROM unnest(tsvector_to_array(${queryVector})) AS query_terms(term)
|
|
969
971
|
)`;
|
|
970
|
-
const
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
})
|
|
972
|
+
const candidateLimit = Math.min(
|
|
973
|
+
MAX_LEXICAL_RANK_CANDIDATES,
|
|
974
|
+
args.limit * LEXICAL_RANK_OVERFETCH,
|
|
975
|
+
);
|
|
976
|
+
const candidates = args.db
|
|
977
|
+
.select()
|
|
977
978
|
.from(juniorMemoryMemories)
|
|
978
|
-
.where(
|
|
979
|
+
.where(
|
|
980
|
+
and(predicate, sql`${juniorMemoryMemories.searchVector} @@ ${tsquery}`),
|
|
981
|
+
)
|
|
979
982
|
.orderBy(
|
|
980
|
-
desc(textRank),
|
|
981
983
|
desc(juniorMemoryMemories.observedAtMs),
|
|
982
984
|
asc(juniorMemoryMemories.id),
|
|
983
985
|
)
|
|
986
|
+
.limit(candidateLimit)
|
|
987
|
+
.as("lexical_candidates");
|
|
988
|
+
const textRank = sql<number>`ts_rank_cd(${candidates.searchVector}, ${tsquery})`;
|
|
989
|
+
const rows = await args.db
|
|
990
|
+
.select({
|
|
991
|
+
memory: {
|
|
992
|
+
archiveReason: candidates.archiveReason,
|
|
993
|
+
archivedAtMs: candidates.archivedAtMs,
|
|
994
|
+
content: candidates.content,
|
|
995
|
+
createdAtMs: candidates.createdAtMs,
|
|
996
|
+
expiresAtMs: candidates.expiresAtMs,
|
|
997
|
+
id: candidates.id,
|
|
998
|
+
idempotencyKey: candidates.idempotencyKey,
|
|
999
|
+
kind: candidates.kind,
|
|
1000
|
+
observedAtMs: candidates.observedAtMs,
|
|
1001
|
+
scope: candidates.scope,
|
|
1002
|
+
scopeKey: candidates.scopeKey,
|
|
1003
|
+
searchVector: candidates.searchVector,
|
|
1004
|
+
sourceKey: candidates.sourceKey,
|
|
1005
|
+
sourcePlatform: candidates.sourcePlatform,
|
|
1006
|
+
subjectKey: candidates.subjectKey,
|
|
1007
|
+
subjectType: candidates.subjectType,
|
|
1008
|
+
supersededAtMs: candidates.supersededAtMs,
|
|
1009
|
+
supersededById: candidates.supersededById,
|
|
1010
|
+
},
|
|
1011
|
+
textRank,
|
|
1012
|
+
})
|
|
1013
|
+
.from(candidates)
|
|
1014
|
+
.orderBy(desc(textRank), desc(candidates.observedAtMs), asc(candidates.id))
|
|
984
1015
|
.limit(args.limit);
|
|
985
1016
|
const ranks = denseRanks(rows, (row) => Number(row.textRank));
|
|
986
1017
|
return rows.map((row, index) => ({
|