@inupedia/spotlight-memory 0.2.14 → 0.2.15

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.
@@ -1 +1 @@
1
- {"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../src/node/gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,yBAAyB,EAE9B,KAAK,0BAA0B,EAC/B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAChC,MAAM,8BAA8B,CAAC;AAKtC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,8BAA8B,EAAE,oBAAoB,GAAG,IAAI,CAAC,CAAC;IACxG,YAAY,CACV,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,gBAAgB,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GACpE,OAAO,CACR,KAAK,CAAC;QACJ,KAAK,EAAE,OAAO,8BAA8B,EAAE,oBAAoB,CAAC;QACnE,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CACH,CAAC;IACF,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,8BAA8B,EAAE,oBAAoB,GACjE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,WAAW,CACT,KAAK,EAAE,OAAO,8BAA8B,EAAE,oBAAoB,GACjE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC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f,CAAC,CACH,CAAC;IACF,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,8BAA8B,EAAE,oBAAoB,GACjE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,WAAW,CACT,KAAK,EAAE,OAAO,8BAA8B,EAAE,oBAAoB,GACjE,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC9E,KAAK,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;CAC9E;AA4DD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,iBAAiB,EACzB,MAAM,GAAE,gBAAqB,GAC5B,UAAU,CAwKZ"}
package/dist/node/gate.js CHANGED
@@ -21,10 +21,14 @@ function resolveLookupScopes(input) {
21
21
  function pickViableSemanticHit(candidates, params) {
22
22
  const viable = candidates
23
23
  .filter((candidate) => candidate.score >= params.threshold)
24
+ .filter((candidate) => isMemoryEntryActive(candidate.entry))
24
25
  .filter((candidate) => !isMemoryEntryStale(candidate.entry, params.invalidation))
25
26
  .filter((candidate) => isMemoryKindAllowedForRead(candidate.entry.kind));
26
27
  return viable[0] ?? null;
27
28
  }
29
+ function isMemoryEntryActive(entry) {
30
+ return entry.schemaVersion !== 2 || (entry.status ?? "active") === "active";
31
+ }
28
32
  export function createMemoryGate(reader, writer, config = {}) {
29
33
  const enabled = config.enabled ?? true;
30
34
  const semanticThreshold = config.semanticThreshold ?? 0.92;
@@ -52,6 +56,8 @@ export function createMemoryGate(reader, writer, config = {}) {
52
56
  });
53
57
  const exact = await reader.getExact(cacheKey);
54
58
  if (exact) {
59
+ if (!isMemoryEntryActive(exact))
60
+ continue;
55
61
  if (isMemoryEntryStale(exact, input.invalidation)) {
56
62
  continue;
57
63
  }
@@ -63,6 +69,8 @@ export function createMemoryGate(reader, writer, config = {}) {
63
69
  hit: true,
64
70
  result: {
65
71
  source: scope.scope === "session" ? "session" : "exact",
72
+ matchKind: "exact",
73
+ scope: scope.scope,
66
74
  entry: exact,
67
75
  confidence: 1,
68
76
  lookupLatencyMs: performance.now() - started,
@@ -85,6 +93,8 @@ export function createMemoryGate(reader, writer, config = {}) {
85
93
  hit: true,
86
94
  result: {
87
95
  source: "semantic",
96
+ matchKind: "semantic",
97
+ scope: top.entry.scope ?? scope.scope,
88
98
  entry: top.entry,
89
99
  confidence: top.score,
90
100
  lookupLatencyMs: performance.now() - started,
@@ -139,9 +149,12 @@ export function createMemoryGate(reader, writer, config = {}) {
139
149
  }
140
150
  const entry = {
141
151
  id: createMemoryEntryId(),
152
+ schemaVersion: input.schemaVersion,
142
153
  projectId: input.projectId,
143
154
  scope: scope.scope,
144
155
  sessionId: scope.sessionId,
156
+ recordType: input.recordType,
157
+ status: input.status,
145
158
  questionNorm,
146
159
  questionRaw: input.question,
147
160
  kind,
@@ -153,6 +166,10 @@ export function createMemoryGate(reader, writer, config = {}) {
153
166
  hitCount: 0,
154
167
  confidence: input.confidence,
155
168
  sourceRunId: input.sourceRunId,
169
+ evidence: input.evidence,
170
+ sourceVersion: input.sourceVersion,
171
+ verifiedAt: input.verifiedAt,
172
+ supersedes: input.supersedes,
156
173
  };
157
174
  await writer.putExact(cacheKey, entry);
158
175
  await writer.putSemantic(entry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inupedia/spotlight-memory",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "Memory Gate, exact/semantic cache stores for Inupedia Spotlight",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@zilliz/milvus2-sdk-node": "^2.5.5",
28
28
  "ioredis": "^5.6.1",
29
- "@inupedia/spotlight-protocol": "0.2.14"
29
+ "@inupedia/spotlight-protocol": "0.2.15"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^22.10.0",