@jungjaehoon/mama-core 1.8.1 → 2.0.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.
Files changed (136) hide show
  1. package/dist/agent-graph/alias-write.js +3 -0
  2. package/dist/agent-graph/entity-resolve.js +3 -7
  3. package/dist/agent-graph/graph-query.js +5 -4
  4. package/dist/agent-graph/types.d.ts +30 -0
  5. package/dist/cases/store.d.ts +0 -4
  6. package/dist/cases/store.js +0 -66
  7. package/dist/cases/wiki-page-index.d.ts +0 -13
  8. package/dist/cases/wiki-page-index.js +0 -153
  9. package/dist/connectors/event-index.d.ts +1 -22
  10. package/dist/connectors/event-index.js +0 -157
  11. package/dist/context-compile/channel-grant.d.ts +46 -0
  12. package/dist/context-compile/channel-grant.js +66 -0
  13. package/dist/context-compile/compiler.js +5 -2
  14. package/dist/context-compile/index.d.ts +1 -0
  15. package/dist/context-compile/index.js +1 -0
  16. package/dist/context-compile/packet-store.d.ts +0 -1
  17. package/dist/context-compile/packet-store.js +0 -16
  18. package/dist/context-compile/source-readers.d.ts +1 -0
  19. package/dist/context-compile/source-readers.js +156 -23
  20. package/dist/context-compile/types.d.ts +17 -0
  21. package/dist/context-compile/visibility.js +28 -4
  22. package/dist/db-adapter/node-sqlite-adapter.js +4 -0
  23. package/dist/db-manager.d.ts +0 -13
  24. package/dist/db-manager.js +0 -66
  25. package/dist/decision-formatter.d.ts +0 -11
  26. package/dist/decision-formatter.js +0 -122
  27. package/dist/decision-tracker.d.ts +0 -12
  28. package/dist/decision-tracker.js +0 -50
  29. package/dist/edges/ref-validation.d.ts +1 -2
  30. package/dist/edges/ref-validation.js +33 -13
  31. package/dist/edges/store.d.ts +1 -3
  32. package/dist/edges/store.js +0 -214
  33. package/dist/edges/types.d.ts +10 -0
  34. package/dist/embedding-client.d.ts +0 -17
  35. package/dist/embedding-client.js +0 -80
  36. package/dist/embedding-server/mobile/auth.d.ts +1 -10
  37. package/dist/embedding-server/mobile/auth.js +0 -15
  38. package/dist/embeddings.d.ts +0 -12
  39. package/dist/embeddings.js +0 -68
  40. package/dist/entities/audit-metrics.d.ts +0 -5
  41. package/dist/entities/audit-metrics.js +0 -4
  42. package/dist/entities/candidate-generator.d.ts +1 -2
  43. package/dist/entities/candidate-generator.js +0 -412
  44. package/dist/entities/entity-list.d.ts +0 -1
  45. package/dist/entities/entity-list.js +0 -96
  46. package/dist/entities/entity-orphan-list.d.ts +0 -9
  47. package/dist/entities/entity-orphan-list.js +0 -88
  48. package/dist/entities/entity-search.d.ts +0 -1
  49. package/dist/entities/entity-search.js +0 -147
  50. package/dist/entities/errors.d.ts +0 -10
  51. package/dist/entities/errors.js +1 -25
  52. package/dist/entities/lineage-store.d.ts +0 -23
  53. package/dist/entities/lineage-store.js +0 -104
  54. package/dist/entities/policy-store.d.ts +0 -9
  55. package/dist/entities/policy-store.js +0 -188
  56. package/dist/entities/provenance-query.d.ts +0 -1
  57. package/dist/entities/provenance-query.js +0 -164
  58. package/dist/entities/resolution-engine.d.ts +1 -8
  59. package/dist/entities/resolution-engine.js +0 -66
  60. package/dist/entities/rollback-preview.d.ts +0 -4
  61. package/dist/entities/rollback-preview.js +0 -232
  62. package/dist/entities/store.d.ts +1 -10
  63. package/dist/entities/store.js +0 -49
  64. package/dist/index.d.ts +15 -31
  65. package/dist/index.js +4 -46
  66. package/dist/mama-api.d.ts +19 -1
  67. package/dist/mama-api.js +97 -2
  68. package/dist/memory/api.d.ts +9 -0
  69. package/dist/memory/api.js +68 -4
  70. package/dist/memory/event-store.d.ts +0 -1
  71. package/dist/memory/event-store.js +0 -15
  72. package/dist/memory/finding-store.d.ts +0 -1
  73. package/dist/memory/finding-store.js +0 -12
  74. package/dist/memory/scope-backfill.d.ts +0 -3
  75. package/dist/memory/scope-backfill.js +0 -74
  76. package/dist/memory/scope-store.d.ts +0 -1
  77. package/dist/memory/scope-store.js +0 -4
  78. package/dist/memory/truth-store.d.ts +0 -3
  79. package/dist/memory/truth-store.js +0 -22
  80. package/dist/memory/types.d.ts +0 -1
  81. package/dist/memory/types.js +0 -13
  82. package/dist/memory-store.d.ts +0 -16
  83. package/dist/memory-store.js +0 -51
  84. package/dist/ollama-client.d.ts +0 -9
  85. package/dist/ollama-client.js +0 -125
  86. package/dist/outcome-tracker.d.ts +0 -14
  87. package/dist/outcome-tracker.js +0 -44
  88. package/dist/progress-indicator.d.ts +0 -4
  89. package/dist/progress-indicator.js +0 -7
  90. package/dist/provenance/source-ref.d.ts +0 -9
  91. package/dist/provenance/source-ref.js +0 -145
  92. package/dist/query-intent.d.ts +0 -4
  93. package/dist/query-intent.js +0 -30
  94. package/dist/relevance-scorer.d.ts +0 -9
  95. package/dist/relevance-scorer.js +0 -81
  96. package/dist/search/feedback-store.d.ts +0 -1
  97. package/dist/search/feedback-store.js +0 -4
  98. package/dist/search/ranker-rescore.d.ts +0 -3
  99. package/dist/search/ranker-rescore.js +0 -27
  100. package/dist/search/ranker-trainer.d.ts +0 -8
  101. package/dist/search/ranker-trainer.js +0 -376
  102. package/dist/tier-validator.d.ts +0 -12
  103. package/dist/tier-validator.js +0 -56
  104. package/package.json +1 -10
  105. package/dist/cases/case-links.d.ts +0 -116
  106. package/dist/cases/case-links.js +0 -794
  107. package/dist/cases/composition-overrides.d.ts +0 -90
  108. package/dist/cases/composition-overrides.js +0 -724
  109. package/dist/cases/corrections.d.ts +0 -156
  110. package/dist/cases/corrections.js +0 -1045
  111. package/dist/cases/freshness.d.ts +0 -57
  112. package/dist/cases/freshness.js +0 -283
  113. package/dist/cases/live-state.d.ts +0 -48
  114. package/dist/cases/live-state.js +0 -256
  115. package/dist/cases/membership-explain.d.ts +0 -56
  116. package/dist/cases/membership-explain.js +0 -140
  117. package/dist/cases/membership-matcher.d.ts +0 -23
  118. package/dist/cases/membership-matcher.js +0 -193
  119. package/dist/cases/merge-split.d.ts +0 -61
  120. package/dist/cases/merge-split.js +0 -368
  121. package/dist/cases/role-inference.d.ts +0 -10
  122. package/dist/cases/role-inference.js +0 -85
  123. package/dist/cases/sqlite-transaction.d.ts +0 -10
  124. package/dist/cases/sqlite-transaction.js +0 -62
  125. package/dist/cases/target-ref.d.ts +0 -25
  126. package/dist/cases/target-ref.js +0 -22
  127. package/dist/cases/tombstone-sweeper.d.ts +0 -13
  128. package/dist/cases/tombstone-sweeper.js +0 -128
  129. package/dist/entities/entity-impact.d.ts +0 -41
  130. package/dist/entities/entity-impact.js +0 -140
  131. package/dist/entities/exact-merge-backfill.d.ts +0 -11
  132. package/dist/entities/exact-merge-backfill.js +0 -161
  133. package/dist/entities/lineage-backfill.d.ts +0 -12
  134. package/dist/entities/lineage-backfill.js +0 -101
  135. package/dist/memory-inject.d.ts +0 -24
  136. package/dist/memory-inject.js +0 -116
@@ -1,13 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LEGACY_SOURCE_REF_KINDS = exports.STRICT_SOURCE_REF_KINDS = void 0;
4
- exports.fromContextRef = fromContextRef;
5
- exports.toContextRef = toContextRef;
6
- exports.fromVerifyArtifact = fromVerifyArtifact;
7
- exports.parseSourceRefString = parseSourceRefString;
8
4
  exports.serializeSourceRef = serializeSourceRef;
9
- exports.assertNonEmptySourceRefs = assertNonEmptySourceRefs;
10
- const types_js_1 = require("../context-compile/types.js");
11
5
  exports.STRICT_SOURCE_REF_KINDS = [
12
6
  'memory',
13
7
  'raw',
@@ -25,17 +19,7 @@ exports.STRICT_SOURCE_REF_KINDS = [
25
19
  ];
26
20
  exports.LEGACY_SOURCE_REF_KINDS = ['message', 'conversation', 'raw_memory'];
27
21
  const STRICT_SOURCE_REF_KIND_SET = new Set(exports.STRICT_SOURCE_REF_KINDS);
28
- const CONTEXT_REF_KIND_SET = new Set(types_js_1.CONTEXT_REF_KINDS);
29
22
  const LEGACY_SOURCE_REF_KIND_SET = new Set(exports.LEGACY_SOURCE_REF_KINDS);
30
- const VERIFY_ARTIFACT_KIND_SET = new Set([
31
- 'decision',
32
- 'os_task',
33
- 'agent_situation_packet',
34
- 'report_slot',
35
- 'context_packet',
36
- 'model_run',
37
- 'tool_trace',
38
- ]);
39
23
  function requiredString(value, field) {
40
24
  if (typeof value !== 'string') {
41
25
  throw new Error(`Source ref ${field} must be a string`);
@@ -46,18 +30,6 @@ function requiredString(value, field) {
46
30
  }
47
31
  return trimmed;
48
32
  }
49
- function optionalString(value, field) {
50
- if (value === undefined) {
51
- return undefined;
52
- }
53
- return requiredString(value, field);
54
- }
55
- function optionalNullableString(value, field) {
56
- if (value === null) {
57
- return null;
58
- }
59
- return optionalString(value, field);
60
- }
61
33
  function assertStrictSourceRefKind(kind) {
62
34
  if (!STRICT_SOURCE_REF_KIND_SET.has(kind)) {
63
35
  throw new Error(`Unsupported source ref kind: ${kind}`);
@@ -68,115 +40,6 @@ function assertLegacySourceRefKind(kind) {
68
40
  throw new Error(`Unsupported legacy source ref kind: ${kind}`);
69
41
  }
70
42
  }
71
- function assertContextSourceRefKind(kind) {
72
- if (kind === 'raw' || !CONTEXT_REF_KIND_SET.has(kind)) {
73
- throw new Error(`Unsupported context source ref kind: ${kind}`);
74
- }
75
- }
76
- function fromContextRef(ref) {
77
- if (ref === null || ref === undefined) {
78
- throw new Error('Context ref must not be null or undefined');
79
- }
80
- const input = ref;
81
- const kind = requiredString(input.kind, 'kind');
82
- if (kind === 'raw') {
83
- const normalized = {
84
- kind: 'raw',
85
- id: requiredString(input.raw_id, 'raw_id'),
86
- connector: requiredString(input.connector, 'connector'),
87
- };
88
- const sourceId = optionalString(input.source_id, 'source_id');
89
- const channelId = optionalNullableString(input.channel_id, 'channel_id');
90
- if (sourceId !== undefined) {
91
- normalized.source_id = sourceId;
92
- }
93
- if (channelId !== undefined) {
94
- normalized.channel_id = channelId;
95
- }
96
- return normalized;
97
- }
98
- assertContextSourceRefKind(kind);
99
- return {
100
- kind,
101
- id: requiredString(input.id, 'id'),
102
- };
103
- }
104
- function toContextRef(ref) {
105
- if (ref === null || ref === undefined) {
106
- return null;
107
- }
108
- switch (ref.kind) {
109
- case 'memory':
110
- case 'entity':
111
- case 'case':
112
- return {
113
- kind: ref.kind,
114
- id: requiredString(ref.id, 'id'),
115
- };
116
- case 'raw': {
117
- const normalized = {
118
- kind: 'raw',
119
- raw_id: requiredString(ref.id, 'id'),
120
- connector: requiredString(ref.connector, 'connector'),
121
- };
122
- const sourceId = optionalString(ref.source_id, 'source_id');
123
- const channelId = optionalNullableString(ref.channel_id, 'channel_id');
124
- if (sourceId !== undefined) {
125
- normalized.source_id = sourceId;
126
- }
127
- if (channelId !== undefined) {
128
- normalized.channel_id = channelId;
129
- }
130
- return normalized;
131
- }
132
- default:
133
- return null;
134
- }
135
- }
136
- function fromVerifyArtifact(artifact) {
137
- if (artifact === null || artifact === undefined) {
138
- throw new Error('Artifact must not be null or undefined');
139
- }
140
- const kind = requiredString(artifact.type, 'type');
141
- if (!VERIFY_ARTIFACT_KIND_SET.has(kind)) {
142
- throw new Error(`Unsupported verify artifact source ref kind: ${kind}`);
143
- }
144
- assertStrictSourceRefKind(kind);
145
- if (kind === 'raw') {
146
- throw new Error('Verify artifact source refs cannot use raw kind');
147
- }
148
- return {
149
- kind,
150
- id: requiredString(artifact.id, 'id'),
151
- };
152
- }
153
- function parseSourceRefString(value) {
154
- const rawValue = requiredString(value, 'value');
155
- const parts = rawValue.split(':');
156
- const kind = requiredString(parts[0], 'kind');
157
- if (kind === 'raw') {
158
- const connector = requiredString(parts[1], 'connector');
159
- const id = requiredString(parts.slice(2).join(':'), 'id');
160
- return { kind: 'raw', connector, id };
161
- }
162
- if (LEGACY_SOURCE_REF_KIND_SET.has(kind)) {
163
- assertLegacySourceRefKind(kind);
164
- return {
165
- kind: 'legacy',
166
- legacy_kind: kind,
167
- id: requiredString(parts.slice(1).join(':'), 'id'),
168
- };
169
- }
170
- assertStrictSourceRefKind(kind);
171
- if (kind === 'raw') {
172
- throw new Error('Raw source refs must include connector and id');
173
- }
174
- const sourceKind = kind;
175
- return {
176
- kind: sourceKind,
177
- id: requiredString(parts.slice(1).join(':'), 'id'),
178
- };
179
- }
180
43
  function serializeSourceRef(ref) {
181
44
  if (ref === null || ref === undefined) {
182
45
  throw new Error('Source ref must not be null or undefined');
@@ -193,12 +56,4 @@ function serializeSourceRef(ref) {
193
56
  }
194
57
  }
195
58
  }
196
- function assertNonEmptySourceRefs(refs) {
197
- if (!Array.isArray(refs) || refs.length === 0) {
198
- throw new Error('Source refs must not be empty');
199
- }
200
- for (const ref of refs) {
201
- serializeSourceRef(ref);
202
- }
203
- }
204
59
  //# sourceMappingURL=source-ref.js.map
@@ -20,8 +20,4 @@ export interface AnalyzeOptions {
20
20
  * Analyze user message for decision-related intent
21
21
  */
22
22
  export declare function analyzeIntent(userMessage: string, options?: AnalyzeOptions): Promise<IntentResult>;
23
- /**
24
- * Extract topic keywords from user message (fallback method)
25
- */
26
- export declare function extractTopicKeywords(userMessage: string): IntentResult;
27
23
  //# sourceMappingURL=query-intent.d.ts.map
@@ -9,7 +9,6 @@
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
11
  exports.analyzeIntent = analyzeIntent;
12
- exports.extractTopicKeywords = extractTopicKeywords;
13
12
  const debug_logger_js_1 = require("./debug-logger.js");
14
13
  const ollama_client_js_1 = require("./ollama-client.js");
15
14
  /**
@@ -112,33 +111,4 @@ async function generateWithFallback(prompt, options = {}) {
112
111
  // Unreachable: loop always returns or throws
113
112
  throw new Error('Unexpected: all LLM tiers exhausted without result');
114
113
  }
115
- /**
116
- * Extract topic keywords from user message (fallback method)
117
- */
118
- function extractTopicKeywords(userMessage) {
119
- const topicPatterns = {
120
- workflow_storage: /workflow|save|persist/i,
121
- mesh_structure: /mesh|structure/i,
122
- authentication: /auth|jwt|oauth|login/i,
123
- testing: /test|jest|spec/i,
124
- architecture: /architecture|design/i,
125
- coding_style: /style|format|coding/i,
126
- };
127
- for (const [topic, pattern] of Object.entries(topicPatterns)) {
128
- if (pattern.test(userMessage)) {
129
- return {
130
- involves_decision: true,
131
- topic,
132
- confidence: 0.5, // Lower confidence for keyword matching
133
- reasoning: 'Keyword-based detection (LLM fallback)',
134
- };
135
- }
136
- }
137
- return {
138
- involves_decision: false,
139
- topic: null,
140
- confidence: 0.0,
141
- reasoning: 'No topic keywords found',
142
- };
143
- }
144
114
  //# sourceMappingURL=query-intent.js.map
@@ -112,13 +112,4 @@ export interface TestResult {
112
112
  calculated: string;
113
113
  pass: boolean;
114
114
  }
115
- /**
116
- * Test relevance scoring with sample decisions
117
- *
118
- * Task 1.4: Test relevance scoring with sample decisions
119
- * AC #1, #4: Verify scoring formula and failure priority
120
- *
121
- * @returns Test results
122
- */
123
- export declare function testRelevanceScoring(): TestResult[];
124
115
  //# sourceMappingURL=relevance-scorer.d.ts.map
@@ -14,7 +14,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.calculateRelevance = calculateRelevance;
15
15
  exports.selectTopDecisions = selectTopDecisions;
16
16
  exports.formatTopNContext = formatTopNContext;
17
- exports.testRelevanceScoring = testRelevanceScoring;
18
17
  const embeddings_js_1 = require("./embeddings.js");
19
18
  /**
20
19
  * Outcome weights for importance scoring
@@ -160,84 +159,4 @@ function formatTopNContext(decisions, topN = 3) {
160
159
  }
161
160
  return { full, summary };
162
161
  }
163
- /**
164
- * Test relevance scoring with sample decisions
165
- *
166
- * Task 1.4: Test relevance scoring with sample decisions
167
- * AC #1, #4: Verify scoring formula and failure priority
168
- *
169
- * @returns Test results
170
- */
171
- function testRelevanceScoring() {
172
- const now = Date.now();
173
- // Mock embeddings (dummy for testing)
174
- const queryEmbedding = new Float32Array(384).fill(0.5);
175
- const decisionEmbedding1 = new Float32Array(384).fill(0.5); // Identical (similarity = 1.0)
176
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
177
- const _decisionEmbedding2 = new Float32Array(384).fill(0.3); // Different (similarity < 1.0)
178
- const scenarios = [
179
- // Scenario 1: Recent FAILED decision (should have highest relevance)
180
- {
181
- name: 'Recent FAILED decision',
182
- decision: {
183
- created_at: now - 5 * 24 * 60 * 60 * 1000, // 5 days ago
184
- outcome: 'FAILED',
185
- embedding: decisionEmbedding1,
186
- decision: 'test decision',
187
- },
188
- queryContext: { embedding: queryEmbedding },
189
- expected: {
190
- recency: 0.85, // exp(-5/30) ≈ 0.85
191
- importance: 1.0, // FAILED = 1.0 (AC #4)
192
- semantic: 1.0, // Identical embeddings
193
- relevance: 0.87, // (0.85×0.2) + (1.0×0.5) + (1.0×0.3)
194
- },
195
- },
196
- // Scenario 2: Recent SUCCESS decision (lower importance)
197
- {
198
- name: 'Recent SUCCESS decision',
199
- decision: {
200
- created_at: now - 5 * 24 * 60 * 60 * 1000, // 5 days ago
201
- outcome: 'SUCCESS',
202
- embedding: decisionEmbedding1,
203
- decision: 'test decision',
204
- },
205
- queryContext: { embedding: queryEmbedding },
206
- expected: {
207
- recency: 0.85,
208
- importance: 0.5, // SUCCESS = 0.5
209
- semantic: 1.0,
210
- relevance: 0.62, // (0.85×0.2) + (0.5×0.5) + (1.0×0.3)
211
- },
212
- },
213
- // Scenario 3: Old FAILED decision (recency decay)
214
- {
215
- name: 'Old FAILED decision',
216
- decision: {
217
- created_at: now - 60 * 24 * 60 * 60 * 1000, // 60 days ago
218
- outcome: 'FAILED',
219
- embedding: decisionEmbedding1,
220
- decision: 'test decision',
221
- },
222
- queryContext: { embedding: queryEmbedding },
223
- expected: {
224
- recency: 0.25, // exp(-60/30) ≈ 0.25
225
- importance: 1.0,
226
- semantic: 1.0,
227
- relevance: 0.85, // (0.25×0.2) + (1.0×0.5) + (1.0×0.3)
228
- },
229
- },
230
- ];
231
- const results = scenarios.map((scenario) => {
232
- const calculated = calculateRelevance(scenario.decision, scenario.queryContext);
233
- const pass = Math.abs(calculated - scenario.expected.relevance) < 0.05;
234
- return {
235
- name: scenario.name,
236
- expected: scenario.expected.relevance.toFixed(2),
237
- calculated: calculated.toFixed(2),
238
- pass,
239
- };
240
- });
241
- return results;
242
- }
243
162
  //# sourceMappingURL=relevance-scorer.js.map
@@ -51,7 +51,6 @@ export interface FeedbackStoreAdapter {
51
51
  };
52
52
  transaction?<T>(fn: () => T): T | (() => T);
53
53
  }
54
- export declare function hashQuery(query: string): string;
55
54
  export declare function getFeedbackRetentionDays(adapter: FeedbackStoreAdapter): number;
56
55
  export declare function compactShownSearchFeedback(adapter: FeedbackStoreAdapter, retentionDays?: number): number;
57
56
  export declare function recordSearchFeedback(adapter: FeedbackStoreAdapter, input: SearchFeedbackInput): RecordSearchFeedbackResult;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hashQuery = hashQuery;
4
3
  exports.getFeedbackRetentionDays = getFeedbackRetentionDays;
5
4
  exports.compactShownSearchFeedback = compactShownSearchFeedback;
6
5
  exports.recordSearchFeedback = recordSearchFeedback;
@@ -18,9 +17,6 @@ function fullQueryHashHex(query) {
18
17
  function fullQueryHashBuffer(query) {
19
18
  return Buffer.from(fullQueryHashHex(query), 'hex');
20
19
  }
21
- function hashQuery(query) {
22
- return fullQueryHashHex(query).slice(0, 16);
23
- }
24
20
  function assertNonEmpty(value, field) {
25
21
  if (!value || value.trim().length === 0) {
26
22
  throw new Error(`${field} is required`);
@@ -1,5 +1,4 @@
1
1
  import type { RunResult } from '../db-adapter/statement.js';
2
- import { type SearchRankerModel } from './ranker-trainer.js';
3
2
  export type SearchRankerSkippedReason = 'feature_disabled' | 'no_active_model' | 'feature_set_mismatch' | 'quality_gate_failed' | 'insufficient_result_count' | 'llm_reranking_requested';
4
3
  export interface RankerRescoreAdapter {
5
4
  prepare(sql: string): {
@@ -24,8 +23,6 @@ export interface RescoreSearchResultsResult<T> {
24
23
  model_id: string | null;
25
24
  skipped_reason?: SearchRankerSkippedReason;
26
25
  }
27
- export declare function loadActiveSearchRankerModel(adapter: RankerRescoreAdapter): SearchRankerModel | null;
28
26
  export declare function isSearchRankerEnabled(adapter: RankerRescoreAdapter): boolean;
29
27
  export declare function rescoreSearchResults<T extends Record<string, unknown>>(adapter: RankerRescoreAdapter, options: RescoreSearchResultsOptions<T>): RescoreSearchResultsResult<T>;
30
- export declare function logisticScoreForRow(model: SearchRankerModel, row: Record<string, unknown>, query: string): number;
31
28
  //# sourceMappingURL=ranker-rescore.d.ts.map
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadActiveSearchRankerModel = loadActiveSearchRankerModel;
4
3
  exports.isSearchRankerEnabled = isSearchRankerEnabled;
5
4
  exports.rescoreSearchResults = rescoreSearchResults;
6
- exports.logisticScoreForRow = logisticScoreForRow;
7
5
  const ranker_features_js_1 = require("./ranker-features.js");
8
6
  const ranker_trainer_js_1 = require("./ranker-trainer.js");
9
7
  const question_type_js_1 = require("./question-type.js");
@@ -78,17 +76,6 @@ function logSkipped(reason, modelId) {
78
76
  feature_set_version: ranker_features_js_1.SEARCH_RANKER_FEATURE_SET_VERSION,
79
77
  }));
80
78
  }
81
- function loadActiveSearchRankerModel(adapter) {
82
- const row = loadActiveRow(adapter);
83
- if (!row) {
84
- return null;
85
- }
86
- if (row.feature_set_version !== ranker_features_js_1.SEARCH_RANKER_FEATURE_SET_VERSION) {
87
- logSkipped('feature_set_mismatch', row.model_id);
88
- return null;
89
- }
90
- return modelFromRow(row);
91
- }
92
79
  function isSearchRankerEnabled(adapter) {
93
80
  const row = adapter
94
81
  .prepare(`
@@ -209,18 +196,4 @@ function rescoreSearchResults(adapter, options) {
209
196
  model_id: model.model_id,
210
197
  };
211
198
  }
212
- function logisticScoreForRow(model, row, query) {
213
- const questionType = (0, question_type_js_1.classifyQuestionType)(query);
214
- const features = (0, ranker_features_js_1.serializeFeatures)((0, ranker_features_js_1.extractFeatures)(row, query, { question_type: questionType }));
215
- const coefficients = model.question_type_weights[questionType] ?? model.coefficients;
216
- let score = model.intercept;
217
- for (let index = 0; index < Math.min(coefficients.length, features.length); index += 1) {
218
- score += coefficients[index] * features[index];
219
- }
220
- if (score >= 35)
221
- return 1;
222
- if (score <= -35)
223
- return 0;
224
- return 1 / (1 + Math.exp(-score));
225
- }
226
199
  //# sourceMappingURL=ranker-rescore.js.map
@@ -75,20 +75,12 @@ interface QualityFixture {
75
75
  candidates: QualityCandidate[];
76
76
  }
77
77
  export declare const RANKER_QUALITY_FIXTURES: readonly QualityFixture[];
78
- export declare function trainOfflineRanker(input: RankerTrainerInput): Promise<TrainOfflineRankerResult>;
79
78
  export declare function scoreWithRankerModel(model: SearchRankerModel, row: Record<string, unknown>, query: string, questionType: QuestionType): number;
80
- export declare function evaluateAgainstBaselines(_input: RankerTrainerInput, model: SearchRankerModel): Promise<RankerEvaluation>;
81
- export declare function insertRankerModelVersion(adapter: RankerTrainerAdapter, model: SearchRankerModel, evaluation: RankerEvaluation): Promise<{
82
- model_id: string;
83
- active: boolean;
84
- }>;
85
- export declare function activateRankerModel(adapter: RankerTrainerAdapter, model_id: string): Promise<'activated' | 'quality_gate_failed' | 'feature_set_mismatch' | 'not_found'>;
86
79
  export declare function ndcgAtK<T extends {
87
80
  id: string;
88
81
  }>(results: readonly T[], relevanceMap: Map<string, number>, k: number): number;
89
82
  export declare function mrr<T extends {
90
83
  id: string;
91
84
  }>(results: readonly T[], relevantSet: Set<string>): number;
92
- export declare function seedQualityFixtureFeedback(adapter: RankerTrainerAdapter, createdAt?: string): void;
93
85
  export { SEARCH_RANKER_FEATURE_SET_VERSION, currentFeatureSetVersion as featureSetVersion };
94
86
  //# sourceMappingURL=ranker-trainer.d.ts.map