@jungjaehoon/mama-core 2.2.2 → 2.2.3
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.d.ts +1 -0
- package/dist/index.js +5 -3
- package/dist/memory/api.js +1 -37
- package/dist/memory/bootstrap-builder.js +3 -3
- package/dist/memory/provenance.d.ts +0 -1
- package/dist/memory/provenance.js +0 -1
- package/dist/memory/truth-store.d.ts +0 -1
- package/dist/memory/truth-store.js +42 -56
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { mama };
|
|
|
18
18
|
export { MEMORY_SCOPE_KINDS, MEMORY_KINDS, MEMORY_STATUSES, MEMORY_EDGE_TYPES, createEmptyRecallBundle, type MemoryScopeKind, type MemoryKind, type MemoryStatus, type MemoryEdgeType, type MemoryScopeRef, type MemorySourceRef, type MemoryRecord, type MemoryWriteProvenance, type MemoryProvenanceRecord, type PublicSaveMemoryInput, type PublicIngestMemoryInput, type PublicIngestConversationInput, type MemorySearchResultHit, type MemoryEdge, type ProfileSnapshot, type RecallBundle, type ConversationMessage, type IngestConversationInput, type ExtractedMemoryUnit, type IngestConversationResult, type AuditFindingRecord, } from './memory/types.js';
|
|
19
19
|
export { saveMemory, saveMemoryWithTrustedProvenance, promoteMemoryStatus, recallMemory, buildProfile, ingestMemory, ingestWithTrustedProvenance, evolveMemory, buildMemoryBootstrap, createAuditAck, recordMemoryAudit, ingestConversation, ingestConversationWithTrustedProvenance, setExtractionFn, upsertChannelSummary, getChannelSummary, } from './memory/api.js';
|
|
20
20
|
export { buildExtractionPrompt, parseExtractionResponse } from './memory/extraction-prompt.js';
|
|
21
|
+
export { queryRelevantTruth } from './memory/truth-store.js';
|
|
21
22
|
export { createAuditFinding, listOpenAuditFindings } from './memory/finding-store.js';
|
|
22
23
|
export { appendMemoryEvent, insertMemoryEventInTransaction, listMemoryEventsForMemory, listRecentMemoryEvents, } from './memory/event-store.js';
|
|
23
24
|
export { createTrustedProvenanceCapability, assertTrustedProvenanceCapability, type TrustedProvenanceCapability, type TrustedMemoryWriteOptions, } from './memory/provenance.js';
|
package/dist/index.js
CHANGED
|
@@ -27,9 +27,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.createAuditAck = exports.buildMemoryBootstrap = exports.evolveMemory = exports.ingestWithTrustedProvenance = exports.ingestMemory = exports.buildProfile = exports.recallMemory = exports.promoteMemoryStatus = exports.saveMemoryWithTrustedProvenance = exports.saveMemory = exports.createEmptyRecallBundle = exports.MEMORY_EDGE_TYPES = exports.MEMORY_STATUSES = exports.MEMORY_KINDS = exports.MEMORY_SCOPE_KINDS = exports.mama = exports.DEFAULT_DB_PATH = exports.LEGACY_DB_PATH = exports.DB_DIR = exports.DB_PATH = exports.traverseDecisionChain = exports.SQLiteAdapter = exports.DatabaseAdapter = exports.createAdapter = exports.fts5Search = exports.getDbPath = exports.getPreparedStmt = exports.updateDecisionOutcome = exports.querySemanticEdges = exports.queryDecisionGraph = exports.insertDecisionWithEmbedding = exports.queryVectorSearch = exports.vectorSearch = exports.insertEmbedding = exports.closeDB = exports.getAdapter = exports.getDB = exports.initDB = exports.TIMEOUT_MS = exports.HOST = exports.DEFAULT_PORT = exports.getServerPort = exports.EmbeddingCache = exports.EMBEDDING_PREFIX_SCHEME = exports.MODEL_NAME = exports.EMBEDDING_DIM = exports.embeddingCache = exports.cosineSimilarity = exports.generateEnhancedEmbedding = exports.generateEmbedding = void 0;
|
|
30
|
-
exports.
|
|
31
|
-
exports.
|
|
32
|
-
exports.notifyInsight = exports.FALLBACK_MODEL = exports.DEFAULT_MODEL = exports.listModels = exports.isAvailable = exports.generate = exports.analyzeIntent = exports.RECENT_WINDOW_MS = exports.PARTIAL_INDICATORS = exports.SUCCESS_INDICATORS = exports.FAILURE_INDICATORS = exports.markOutcome = exports.getEvidenceImpact = exports.calculateDurationDays = exports.getRecentDecision = exports.extractFailureReason = exports.matchesPartialIndicators = exports.matchesSuccessIndicators = exports.matchesFailureIndicators = exports.analyzeOutcome = exports.extractCodeExample = exports.extractQuickAnswer = exports.estimateTokens = void 0;
|
|
30
|
+
exports.getConfigPath = exports.updateConfig = exports.getCacheDir = exports.getEmbeddingDim = exports.getModelName = exports.loadConfig = exports.CanonicalizeError = exports.targetRefHash = exports.canonicalizeJSON = exports.listVisibleTwinEdgesForRefs = exports.mapTwinEdgeRow = exports.listTwinEdgesForRefs = exports.getTwinEdge = exports.TWIN_REF_KINDS = exports.TWIN_EDGE_TYPES = exports.TWIN_EDGE_SOURCES = exports.listToolTracesForRun = exports.appendToolTrace = exports.getModelRunInAdapter = exports.getModelRun = exports.failModelRunInAdapter = exports.failModelRun = exports.commitModelRunInAdapter = exports.commitModelRun = exports.beginModelRunInAdapter = exports.beginModelRun = exports.MODEL_RUN_STATUSES = exports.listMemoryProvenanceAudit = exports.getMemoryProvenanceAudit = exports.listMemoriesByModelRunId = exports.listMemoriesByGatewayCallId = exports.listMemoriesByEnvelopeHash = exports.getMemoryProvenance = exports.assertTrustedProvenanceCapability = exports.createTrustedProvenanceCapability = exports.listRecentMemoryEvents = exports.listMemoryEventsForMemory = exports.insertMemoryEventInTransaction = exports.appendMemoryEvent = exports.listOpenAuditFindings = exports.createAuditFinding = exports.queryRelevantTruth = exports.parseExtractionResponse = exports.buildExtractionPrompt = exports.getChannelSummary = exports.upsertChannelSummary = exports.setExtractionFn = exports.ingestConversationWithTrustedProvenance = exports.ingestConversation = exports.recordMemoryAudit = void 0;
|
|
31
|
+
exports.formatTrustContext = exports.formatList = exports.formatRecall = exports.formatLegacyContext = exports.formatContext = exports.isMAMAError = exports.wrapError = exports.ErrorCodes = exports.TimeoutError = exports.RateLimitError = exports.LinkError = exports.ConfigurationError = exports.EmbeddingError = exports.DatabaseError = exports.ValidationError = exports.NotFoundError = exports.MAMAError = exports.formatTimeAgo = exports.DebugLogger = exports.error = exports.warn = exports.info = exports.debug = exports.logSearching = exports.logLoading = exports.logError = exports.logFailed = exports.logComplete = exports.logProgress = exports.getTierDescription = exports.checkDatabase = exports.checkEmbeddings = exports.checkSQLite = exports.checkNodeVersion = exports.VALID_EDGE_TYPES = exports.updateConfidence = exports.createEdgesFromReasoning = exports.parseReasoningForRelationships = exports.detectRefinement = exports.calculateCombinedConfidence = exports.markSuperseded = exports.createSupersedesEdge = exports.createEdge = exports.getPreviousDecision = exports.generateDecisionId = exports.learnDecision = exports.formatTopNContext = exports.selectTopDecisions = exports.calculateRelevance = exports.DEFAULT_CONFIG = void 0;
|
|
32
|
+
exports.notifyInsight = exports.FALLBACK_MODEL = exports.DEFAULT_MODEL = exports.listModels = exports.isAvailable = exports.generate = exports.analyzeIntent = exports.RECENT_WINDOW_MS = exports.PARTIAL_INDICATORS = exports.SUCCESS_INDICATORS = exports.FAILURE_INDICATORS = exports.markOutcome = exports.getEvidenceImpact = exports.calculateDurationDays = exports.getRecentDecision = exports.extractFailureReason = exports.matchesPartialIndicators = exports.matchesSuccessIndicators = exports.matchesFailureIndicators = exports.analyzeOutcome = exports.extractCodeExample = exports.extractQuickAnswer = exports.estimateTokens = exports.ensureTokenBudget = void 0;
|
|
33
33
|
var embeddings_js_1 = require("./embeddings.js");
|
|
34
34
|
Object.defineProperty(exports, "generateEmbedding", { enumerable: true, get: function () { return embeddings_js_1.generateEmbedding; } });
|
|
35
35
|
Object.defineProperty(exports, "generateEnhancedEmbedding", { enumerable: true, get: function () { return embeddings_js_1.generateEnhancedEmbedding; } });
|
|
@@ -98,6 +98,8 @@ Object.defineProperty(exports, "getChannelSummary", { enumerable: true, get: fun
|
|
|
98
98
|
var extraction_prompt_js_1 = require("./memory/extraction-prompt.js");
|
|
99
99
|
Object.defineProperty(exports, "buildExtractionPrompt", { enumerable: true, get: function () { return extraction_prompt_js_1.buildExtractionPrompt; } });
|
|
100
100
|
Object.defineProperty(exports, "parseExtractionResponse", { enumerable: true, get: function () { return extraction_prompt_js_1.parseExtractionResponse; } });
|
|
101
|
+
var truth_store_js_1 = require("./memory/truth-store.js");
|
|
102
|
+
Object.defineProperty(exports, "queryRelevantTruth", { enumerable: true, get: function () { return truth_store_js_1.queryRelevantTruth; } });
|
|
101
103
|
var finding_store_js_1 = require("./memory/finding-store.js");
|
|
102
104
|
Object.defineProperty(exports, "createAuditFinding", { enumerable: true, get: function () { return finding_store_js_1.createAuditFinding; } });
|
|
103
105
|
Object.defineProperty(exports, "listOpenAuditFindings", { enumerable: true, get: function () { return finding_store_js_1.listOpenAuditFindings; } });
|
package/dist/memory/api.js
CHANGED
|
@@ -31,7 +31,6 @@ const bootstrap_builder_js_1 = require("./bootstrap-builder.js");
|
|
|
31
31
|
const evolution_engine_js_1 = require("./evolution-engine.js");
|
|
32
32
|
const channel_summary_state_store_js_1 = require("./channel-summary-state-store.js");
|
|
33
33
|
const debug_logger_js_1 = require("../debug-logger.js");
|
|
34
|
-
const truth_store_js_1 = require("./truth-store.js");
|
|
35
34
|
const extraction_prompt_js_1 = require("./extraction-prompt.js");
|
|
36
35
|
const types_js_1 = require("./types.js");
|
|
37
36
|
const channel_summary_store_js_1 = require("./channel-summary-store.js");
|
|
@@ -647,9 +646,6 @@ async function saveMemoryInternal(input, options) {
|
|
|
647
646
|
adapter
|
|
648
647
|
.prepare(`UPDATE decisions SET superseded_by = ?, status = 'superseded', updated_at = ? WHERE id = ?`)
|
|
649
648
|
.run(id, now, edge.to_id);
|
|
650
|
-
adapter
|
|
651
|
-
.prepare(`UPDATE memory_truth SET truth_status = 'superseded', superseded_by = ?, updated_at = ? WHERE memory_id = ?`)
|
|
652
|
-
.run(id, now, edge.to_id);
|
|
653
649
|
}
|
|
654
650
|
adapter
|
|
655
651
|
.prepare(`
|
|
@@ -683,25 +679,6 @@ async function saveMemoryInternal(input, options) {
|
|
|
683
679
|
}
|
|
684
680
|
}
|
|
685
681
|
}
|
|
686
|
-
if (options?.projectTruth !== false) {
|
|
687
|
-
// Project to memory_truth table (best-effort; failure should not break save)
|
|
688
|
-
try {
|
|
689
|
-
await (0, truth_store_js_1.projectMemoryTruth)({
|
|
690
|
-
memory_id: id,
|
|
691
|
-
topic: input.topic,
|
|
692
|
-
truth_status: targetStatus,
|
|
693
|
-
effective_summary: input.summary,
|
|
694
|
-
effective_details: input.details,
|
|
695
|
-
trust_score: input.confidence ?? 0.5,
|
|
696
|
-
scope_refs: input.scopes,
|
|
697
|
-
supporting_event_ids: [],
|
|
698
|
-
superseded_by: undefined,
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
catch {
|
|
702
|
-
// Truth projection is best-effort; do not fail the save
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
682
|
return {
|
|
706
683
|
success: true,
|
|
707
684
|
id,
|
|
@@ -724,7 +701,7 @@ async function promoteMemoryStatus(input) {
|
|
|
724
701
|
const targetStatus = input.status;
|
|
725
702
|
const row = adapter
|
|
726
703
|
.prepare(`
|
|
727
|
-
SELECT id, topic, decision,
|
|
704
|
+
SELECT id, topic, decision, confidence, kind, summary, supersedes
|
|
728
705
|
FROM decisions
|
|
729
706
|
WHERE id = ?
|
|
730
707
|
`)
|
|
@@ -734,7 +711,6 @@ async function promoteMemoryStatus(input) {
|
|
|
734
711
|
}
|
|
735
712
|
const topic = String(row.topic);
|
|
736
713
|
const summary = String(row.summary ?? row.decision ?? '');
|
|
737
|
-
const details = String(row.reasoning ?? row.decision ?? '');
|
|
738
714
|
const kind = (row.kind ?? 'fact') || 'fact';
|
|
739
715
|
const scopes = batchLoadScopes(adapter, [memoryId]).get(memoryId) ?? [];
|
|
740
716
|
let evolution = { edges: [] };
|
|
@@ -823,23 +799,11 @@ async function promoteMemoryStatus(input) {
|
|
|
823
799
|
if (updated.changes !== 1) {
|
|
824
800
|
throw new Error(`Cannot promote missing memory ${memoryId}`);
|
|
825
801
|
}
|
|
826
|
-
adapter
|
|
827
|
-
.prepare(`
|
|
828
|
-
INSERT OR REPLACE INTO memory_truth (
|
|
829
|
-
memory_id, topic, truth_status, effective_summary, effective_details, trust_score,
|
|
830
|
-
scope_refs, supporting_event_ids, superseded_by, contradicted_by, created_at, updated_at
|
|
831
|
-
)
|
|
832
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, COALESCE((SELECT supporting_event_ids FROM memory_truth WHERE memory_id = ?), '[]'), NULL, NULL, COALESCE((SELECT created_at FROM memory_truth WHERE memory_id = ?), ?), ?)
|
|
833
|
-
`)
|
|
834
|
-
.run(memoryId, topic, targetStatus, summary, details, row.confidence ?? 0.5, JSON.stringify(scopes), memoryId, memoryId, now, now);
|
|
835
802
|
for (const edge of evolution.edges) {
|
|
836
803
|
if (edge.type === 'supersedes') {
|
|
837
804
|
adapter
|
|
838
805
|
.prepare(`UPDATE decisions SET superseded_by = ?, status = 'superseded', updated_at = ? WHERE id = ?`)
|
|
839
806
|
.run(memoryId, now, edge.to_id);
|
|
840
|
-
adapter
|
|
841
|
-
.prepare(`UPDATE memory_truth SET truth_status = 'superseded', superseded_by = ?, updated_at = ? WHERE memory_id = ?`)
|
|
842
|
-
.run(memoryId, now, edge.to_id);
|
|
843
807
|
}
|
|
844
808
|
adapter
|
|
845
809
|
.prepare(`
|
|
@@ -11,7 +11,7 @@ async function buildMemoryAgentBootstrap(params) {
|
|
|
11
11
|
(0, truth_store_js_1.queryRelevantTruth)({
|
|
12
12
|
query: '',
|
|
13
13
|
scopes: params.scopes,
|
|
14
|
-
includeHistory:
|
|
14
|
+
includeHistory: false,
|
|
15
15
|
}),
|
|
16
16
|
(0, finding_store_js_1.listOpenAuditFindings)(),
|
|
17
17
|
(0, event_store_js_1.listRecentMemoryEvents)(10),
|
|
@@ -25,11 +25,11 @@ async function buildMemoryAgentBootstrap(params) {
|
|
|
25
25
|
summary: row.effective_summary,
|
|
26
26
|
details: row.effective_details,
|
|
27
27
|
confidence: row.trust_score,
|
|
28
|
-
status: row.truth_status
|
|
28
|
+
status: row.truth_status,
|
|
29
29
|
scopes: row.scope_refs,
|
|
30
30
|
source: {
|
|
31
31
|
package: 'mama-core',
|
|
32
|
-
source_type: '
|
|
32
|
+
source_type: 'decisions_current',
|
|
33
33
|
},
|
|
34
34
|
created_at: 0,
|
|
35
35
|
updated_at: 0,
|
|
@@ -5,7 +5,6 @@ export interface TrustedProvenanceCapability {
|
|
|
5
5
|
export interface TrustedMemoryWriteOptions {
|
|
6
6
|
provenance: MemoryWriteProvenance;
|
|
7
7
|
capability: TrustedProvenanceCapability;
|
|
8
|
-
projectTruth?: boolean;
|
|
9
8
|
}
|
|
10
9
|
export interface NormalizedMemoryProvenance {
|
|
11
10
|
actor: MemoryEventRecord['actor'];
|
|
@@ -92,7 +92,6 @@ function appendProvenanceSourceRefs(options, refs) {
|
|
|
92
92
|
assertTrustedProvenanceCapability(options.capability);
|
|
93
93
|
return {
|
|
94
94
|
capability: options.capability,
|
|
95
|
-
projectTruth: options.projectTruth,
|
|
96
95
|
provenance: {
|
|
97
96
|
...options.provenance,
|
|
98
97
|
source_refs: [...(options.provenance.source_refs ?? []), ...refs],
|
|
@@ -1,33 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.projectMemoryTruth = projectMemoryTruth;
|
|
4
3
|
exports.queryRelevantTruth = queryRelevantTruth;
|
|
5
4
|
const db_manager_js_1 = require("../db-manager.js");
|
|
6
|
-
function
|
|
5
|
+
function decisionToTruthRow(row) {
|
|
7
6
|
return {
|
|
8
|
-
memory_id:
|
|
9
|
-
topic:
|
|
10
|
-
truth_status: row.
|
|
11
|
-
effective_summary:
|
|
12
|
-
effective_details:
|
|
13
|
-
trust_score:
|
|
14
|
-
scope_refs: JSON.parse(
|
|
15
|
-
supporting_event_ids:
|
|
16
|
-
superseded_by:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
created_at: typeof row.created_at === 'number' ? row.created_at : undefined,
|
|
21
|
-
updated_at: typeof row.updated_at === 'number' ? row.updated_at : undefined,
|
|
22
|
-
kind: typeof row.kind === 'string' ? row.kind : undefined,
|
|
7
|
+
memory_id: row.id,
|
|
8
|
+
topic: row.topic,
|
|
9
|
+
truth_status: row.status,
|
|
10
|
+
effective_summary: row.summary ?? row.decision,
|
|
11
|
+
effective_details: row.reasoning ?? '',
|
|
12
|
+
trust_score: row.confidence,
|
|
13
|
+
scope_refs: JSON.parse(row.scope_refs),
|
|
14
|
+
supporting_event_ids: [],
|
|
15
|
+
superseded_by: row.superseded_by ?? undefined,
|
|
16
|
+
created_at: row.created_at,
|
|
17
|
+
updated_at: row.updated_at ?? undefined,
|
|
18
|
+
kind: row.kind ?? undefined,
|
|
23
19
|
};
|
|
24
20
|
}
|
|
25
|
-
function matchesScopes(row, scopes) {
|
|
26
|
-
if (scopes.length === 0) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
return row.scope_refs.some((scopeRef) => scopes.some((scope) => scope.kind === scopeRef.kind && scope.id === scopeRef.id));
|
|
30
|
-
}
|
|
31
21
|
function matchesQuery(row, query) {
|
|
32
22
|
const tokens = query
|
|
33
23
|
.toLowerCase()
|
|
@@ -40,47 +30,43 @@ function matchesQuery(row, query) {
|
|
|
40
30
|
? haystack.includes(query.toLowerCase())
|
|
41
31
|
: tokens.some((token) => haystack.includes(token));
|
|
42
32
|
}
|
|
43
|
-
async function projectMemoryTruth(row) {
|
|
44
|
-
await (0, db_manager_js_1.initDB)();
|
|
45
|
-
const adapter = (0, db_manager_js_1.getAdapter)();
|
|
46
|
-
const now = Date.now();
|
|
47
|
-
adapter
|
|
48
|
-
.prepare(`
|
|
49
|
-
INSERT OR REPLACE INTO memory_truth (
|
|
50
|
-
memory_id, topic, truth_status, effective_summary, effective_details, trust_score,
|
|
51
|
-
scope_refs, supporting_event_ids, superseded_by, contradicted_by, created_at, updated_at
|
|
52
|
-
)
|
|
53
|
-
VALUES (
|
|
54
|
-
?, ?,
|
|
55
|
-
COALESCE((SELECT status FROM decisions WHERE id = ?), ?),
|
|
56
|
-
?, ?, ?, ?, ?,
|
|
57
|
-
COALESCE((SELECT superseded_by FROM decisions WHERE id = ?), ?),
|
|
58
|
-
?, COALESCE((SELECT created_at FROM memory_truth WHERE memory_id = ?), ?), ?
|
|
59
|
-
)
|
|
60
|
-
`)
|
|
61
|
-
.run(row.memory_id, row.topic, row.memory_id, row.truth_status, row.effective_summary, row.effective_details, row.trust_score, JSON.stringify(row.scope_refs), JSON.stringify(row.supporting_event_ids), row.memory_id, row.superseded_by ?? null, row.contradicted_by ? JSON.stringify(row.contradicted_by) : null, row.memory_id, now, now);
|
|
62
|
-
}
|
|
63
33
|
async function queryRelevantTruth(params) {
|
|
64
34
|
await (0, db_manager_js_1.initDB)();
|
|
65
35
|
const adapter = (0, db_manager_js_1.getAdapter)();
|
|
36
|
+
const scopeMatch = params.scopes
|
|
37
|
+
.map(() => '(scope_filter.kind = ? AND scope_filter.external_id = ?)')
|
|
38
|
+
.join(' OR ');
|
|
39
|
+
const scopeFilter = params.scopes.length > 0
|
|
40
|
+
? `
|
|
41
|
+
AND EXISTS (
|
|
42
|
+
SELECT 1
|
|
43
|
+
FROM memory_scope_bindings binding_filter
|
|
44
|
+
JOIN memory_scopes scope_filter ON scope_filter.id = binding_filter.scope_id
|
|
45
|
+
WHERE binding_filter.memory_id = d.id
|
|
46
|
+
AND (${scopeMatch})
|
|
47
|
+
)
|
|
48
|
+
`
|
|
49
|
+
: 'AND 1 = 0';
|
|
50
|
+
const currentFilter = params.includeHistory === true ? '' : "AND d.status = 'active'";
|
|
51
|
+
const scopeParams = params.scopes.flatMap((scope) => [scope.kind, scope.id]);
|
|
66
52
|
const rows = adapter
|
|
67
53
|
.prepare(`
|
|
68
|
-
SELECT
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
FROM
|
|
72
|
-
|
|
73
|
-
|
|
54
|
+
SELECT d.id, d.topic, d.status, d.summary, d.decision, d.reasoning, d.confidence,
|
|
55
|
+
d.superseded_by, d.created_at, d.updated_at, d.kind,
|
|
56
|
+
json_group_array(json_object('kind', scope.kind, 'id', scope.external_id)) AS scope_refs
|
|
57
|
+
FROM decisions d
|
|
58
|
+
JOIN memory_scope_bindings binding ON binding.memory_id = d.id
|
|
59
|
+
JOIN memory_scopes scope ON scope.id = binding.scope_id
|
|
60
|
+
WHERE 1 = 1
|
|
61
|
+
${currentFilter}
|
|
62
|
+
${scopeFilter}
|
|
63
|
+
GROUP BY d.id
|
|
64
|
+
ORDER BY d.updated_at DESC, d.created_at DESC
|
|
74
65
|
`)
|
|
75
|
-
.all();
|
|
66
|
+
.all(...scopeParams);
|
|
76
67
|
return rows
|
|
77
|
-
.map(
|
|
78
|
-
.filter((row) => matchesScopes(row, params.scopes))
|
|
68
|
+
.map(decisionToTruthRow)
|
|
79
69
|
.filter((row) => matchesQuery(row, params.query))
|
|
80
|
-
.filter((row) => params.includeHistory === true ||
|
|
81
|
-
(row.truth_status !== 'quarantined' &&
|
|
82
|
-
row.truth_status !== 'superseded' &&
|
|
83
|
-
row.truth_status !== 'contradicted'))
|
|
84
70
|
.sort((left, right) => right.trust_score - left.trust_score);
|
|
85
71
|
}
|
|
86
72
|
//# sourceMappingURL=truth-store.js.map
|