@sentropic/cluster-mesh 0.23.4 → 0.24.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/assets/storage/engram-memory/C6-FREEZE.md +63 -0
- package/assets/storage/engram-memory/contract-manifest.json +6 -4
- package/assets/storage/engram-memory/equivalence.json +1 -1
- package/assets/storage/engram-memory/neutral-asset-inventory.json +53 -0
- package/assets/storage/engram-memory/neutral-equivalence.json +44 -0
- package/assets/storage/postgres/007-consumed-counters.sql +17 -0
- package/assets/storage/postgres/008-instance-ownership.sql +35 -0
- package/assets/storage/postgres/engram-memory/001-projections.sql +14 -0
- package/assets/storage/postgres/engram-memory/002-host-ledger.sql +14 -0
- package/assets/storage/postgres/engram-memory/manifest.json +29 -0
- package/assets/storage/postgres/manifest.json +26 -0
- package/contracts/engram-memory-neutral-contract-v1.d.ts +367 -0
- package/dist/comments/postgres.d.ts +1 -0
- package/dist/comments/postgres.d.ts.map +1 -1
- package/dist/engram-memory/binding.d.ts +115 -0
- package/dist/engram-memory/binding.d.ts.map +1 -0
- package/dist/engram-memory/binding.js +239 -0
- package/dist/engram-memory/binding.js.map +1 -0
- package/dist/engram-memory/commit-result-recovery.d.ts +12 -0
- package/dist/engram-memory/commit-result-recovery.d.ts.map +1 -0
- package/dist/engram-memory/commit-result-recovery.js +14 -0
- package/dist/engram-memory/commit-result-recovery.js.map +1 -0
- package/dist/engram-memory/contract.d.ts +7 -1
- package/dist/engram-memory/contract.d.ts.map +1 -1
- package/dist/engram-memory/contract.js +7 -1
- package/dist/engram-memory/contract.js.map +1 -1
- package/dist/engram-memory/host-maintenance.d.ts +40 -0
- package/dist/engram-memory/host-maintenance.d.ts.map +1 -0
- package/dist/engram-memory/host-maintenance.js +44 -0
- package/dist/engram-memory/host-maintenance.js.map +1 -0
- package/dist/engram-memory/ledger.d.ts +75 -0
- package/dist/engram-memory/ledger.d.ts.map +1 -0
- package/dist/engram-memory/ledger.js +286 -0
- package/dist/engram-memory/ledger.js.map +1 -0
- package/dist/engram-memory/manifest.d.ts +1 -1
- package/dist/engram-memory/manifest.d.ts.map +1 -1
- package/dist/engram-memory/manifest.js +2 -1
- package/dist/engram-memory/manifest.js.map +1 -1
- package/dist/engram-memory/neutral-contract.d.ts +368 -0
- package/dist/engram-memory/neutral-contract.d.ts.map +1 -0
- package/dist/engram-memory/neutral-contract.js +39 -0
- package/dist/engram-memory/neutral-contract.js.map +1 -0
- package/dist/engram-memory/neutral-handle.d.ts +62 -0
- package/dist/engram-memory/neutral-handle.d.ts.map +1 -0
- package/dist/engram-memory/neutral-handle.js +131 -0
- package/dist/engram-memory/neutral-handle.js.map +1 -0
- package/dist/engram-memory/postgres-queries.d.ts +1 -1
- package/dist/engram-memory/postgres-queries.d.ts.map +1 -1
- package/dist/engram-memory/postgres-queries.js +111 -21
- package/dist/engram-memory/postgres-queries.js.map +1 -1
- package/dist/engram-memory/postgres.d.ts +51 -10
- package/dist/engram-memory/postgres.d.ts.map +1 -1
- package/dist/engram-memory/postgres.js +118 -17
- package/dist/engram-memory/postgres.js.map +1 -1
- package/dist/engram-memory/projection.d.ts +12 -0
- package/dist/engram-memory/projection.d.ts.map +1 -0
- package/dist/engram-memory/projection.js +123 -0
- package/dist/engram-memory/projection.js.map +1 -0
- package/dist/engram-memory/wire-adaptation.d.ts +61 -0
- package/dist/engram-memory/wire-adaptation.d.ts.map +1 -0
- package/dist/engram-memory/wire-adaptation.js +223 -0
- package/dist/engram-memory/wire-adaptation.js.map +1 -0
- package/dist/modules/catalog.d.ts +2 -2
- package/dist/modules/catalog.js +3 -3
- package/dist/storage/atomic.d.ts +66 -1
- package/dist/storage/atomic.d.ts.map +1 -1
- package/dist/storage/atomic.js +173 -1
- package/dist/storage/atomic.js.map +1 -1
- package/dist/storage/backend.d.ts +3 -0
- package/dist/storage/backend.d.ts.map +1 -1
- package/dist/storage/backend.js +8 -0
- package/dist/storage/backend.js.map +1 -1
- package/dist/storage/contracts.d.ts +13 -0
- package/dist/storage/contracts.d.ts.map +1 -1
- package/dist/storage/contracts.js +12 -0
- package/dist/storage/contracts.js.map +1 -1
- package/dist/storage/instance-ownership.d.ts.map +1 -1
- package/dist/storage/instance-ownership.js +25 -7
- package/dist/storage/instance-ownership.js.map +1 -1
- package/dist/storage/postgres/codec.d.ts +1 -0
- package/dist/storage/postgres/codec.d.ts.map +1 -1
- package/dist/storage/postgres/codec.js +19 -0
- package/dist/storage/postgres/codec.js.map +1 -1
- package/dist/storage/postgres/commit-results.d.ts +6 -0
- package/dist/storage/postgres/commit-results.d.ts.map +1 -0
- package/dist/storage/postgres/commit-results.js +28 -0
- package/dist/storage/postgres/commit-results.js.map +1 -0
- package/dist/storage/postgres/core.d.ts +3 -1
- package/dist/storage/postgres/core.d.ts.map +1 -1
- package/dist/storage/postgres/core.js +99 -36
- package/dist/storage/postgres/core.js.map +1 -1
- package/dist/storage/postgres/effects.d.ts +1 -1
- package/dist/storage/postgres/effects.d.ts.map +1 -1
- package/dist/storage/postgres/effects.js +31 -6
- package/dist/storage/postgres/effects.js.map +1 -1
- package/dist/storage/postgres/errors.d.ts.map +1 -1
- package/dist/storage/postgres/errors.js +13 -0
- package/dist/storage/postgres/errors.js.map +1 -1
- package/dist/storage/postgres/index.d.ts +1 -0
- package/dist/storage/postgres/index.d.ts.map +1 -1
- package/dist/storage/postgres/index.js +1 -0
- package/dist/storage/postgres/index.js.map +1 -1
- package/dist/storage/postgres/instance-guard.d.ts +48 -0
- package/dist/storage/postgres/instance-guard.d.ts.map +1 -0
- package/dist/storage/postgres/instance-guard.js +147 -0
- package/dist/storage/postgres/instance-guard.js.map +1 -0
- package/dist/storage/postgres/instance-ownership.d.ts +22 -0
- package/dist/storage/postgres/instance-ownership.d.ts.map +1 -0
- package/dist/storage/postgres/instance-ownership.js +165 -0
- package/dist/storage/postgres/instance-ownership.js.map +1 -0
- package/dist/storage/postgres/journal.d.ts +24 -8
- package/dist/storage/postgres/journal.d.ts.map +1 -1
- package/dist/storage/postgres/journal.js +43 -32
- package/dist/storage/postgres/journal.js.map +1 -1
- package/dist/storage/postgres/migrations.d.ts +2 -1
- package/dist/storage/postgres/migrations.d.ts.map +1 -1
- package/dist/storage/postgres/migrations.js +14 -4
- package/dist/storage/postgres/migrations.js.map +1 -1
- package/dist/storage/postgres/ordinary-transactions.d.ts.map +1 -1
- package/dist/storage/postgres/ordinary-transactions.js +3 -2
- package/dist/storage/postgres/ordinary-transactions.js.map +1 -1
- package/dist/storage/postgres/profiles.d.ts +15 -8
- package/dist/storage/postgres/profiles.d.ts.map +1 -1
- package/dist/storage/postgres/protocol.d.ts +14 -0
- package/dist/storage/postgres/protocol.d.ts.map +1 -1
- package/dist/storage/postgres/protocol.js.map +1 -1
- package/dist/storage/postgres/queries.js +5 -5
- package/dist/storage/postgres/queries.js.map +1 -1
- package/dist/storage/postgres/readers.js +2 -2
- package/dist/storage/postgres/readers.js.map +1 -1
- package/dist/storage/postgres/roots.d.ts.map +1 -1
- package/dist/storage/postgres/roots.js +10 -6
- package/dist/storage/postgres/roots.js.map +1 -1
- package/dist/storage/postgres/scope.d.ts +17 -8
- package/dist/storage/postgres/scope.d.ts.map +1 -1
- package/dist/storage/postgres/scope.js +4 -0
- package/dist/storage/postgres/scope.js.map +1 -1
- package/dist/storage/postgres/snapshots.d.ts +2 -2
- package/dist/storage/postgres/snapshots.d.ts.map +1 -1
- package/dist/storage/postgres/snapshots.js +7 -4
- package/dist/storage/postgres/snapshots.js.map +1 -1
- package/dist/storage/postgres/transactions.d.ts +11 -0
- package/dist/storage/postgres/transactions.d.ts.map +1 -1
- package/dist/storage/postgres/transactions.js +21 -0
- package/dist/storage/postgres/transactions.js.map +1 -1
- package/dist/storage/u64.d.ts +18 -0
- package/dist/storage/u64.d.ts.map +1 -0
- package/dist/storage/u64.js +54 -0
- package/dist/storage/u64.js.map +1 -0
- package/package.json +4 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-queries.d.ts","sourceRoot":"","sources":["../../src/engram-memory/postgres-queries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postgres-queries.d.ts","sourceRoot":"","sources":["../../src/engram-memory/postgres-queries.ts"],"names":[],"mappings":"AAMA,OAAO,EAAqB,KAAK,iBAAiB,EAAyC,MAAM,iCAAiC,CAAC;AAGnI,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGnD,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,eAAO,MAAM,iBAAiB,UAAW,OAAO,oBACwC,CAAC;AAEzF,iFAAiF;AACjF,eAAO,MAAM,uBAAuB,UAAW,OAAO,cAAc,MAAM,KAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAc5H,CAAC;AAEF,eAAO,MAAM,6BAA6B,UAAW,OAAO,KAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CASzF,CAAC;AAEF,eAAO,MAAM,2BAA2B,UAC/B,OAAO,iBACC,MAAM,KACpB;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;CAkB3F,CAAC;AAiDF,eAAO,MAAM,aAAa,SAAU,eAAe,KAAG,iBAmDrD,CAAC;AAiBF,eAAO,MAAM,iBAAiB;;;;;;EAM5B,CAAC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// engram-memory Postgres named queries (binding section 4.1): input
|
|
2
2
|
// validation and scope checks for the five registered queries. Query
|
|
3
|
-
// execution
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import {
|
|
3
|
+
// execution uses canonical membership at the captured root. Current
|
|
4
|
+
// availability and authority still apply to every retained page.
|
|
5
|
+
import { StorageCapacityExceededError, StorageInvalidCommandError, StorageUnavailableError } from '../storage/errors.js';
|
|
6
|
+
import { quotePgIdentifier } from '../storage/postgres/protocol.js';
|
|
7
|
+
import { decodePgJson, decodePgText, decodePgUtf8 } from '../storage/postgres/codec.js';
|
|
8
|
+
import { decodeMemoryValue, memoryPgMap, memoryPgSchema, memoryPgScope, readMemoryPgPayload } from './projection.js';
|
|
8
9
|
import { MEMORY_QUERY_NAMES } from './manifest.js';
|
|
9
10
|
import { isCanonicalU64 } from './codec.js';
|
|
10
11
|
export const isMemoryQueryName = (value) => typeof value === 'string' && MEMORY_QUERY_NAMES.includes(value);
|
|
@@ -53,6 +54,52 @@ export const validateMemorySnapshotInput = (input, maxCandidates) => {
|
|
|
53
54
|
}
|
|
54
55
|
return { systemAsOf, scopeRef: scopeRef, maxCandidates: max };
|
|
55
56
|
};
|
|
57
|
+
const requireAvailable = async (context, target, seen = new Set()) => {
|
|
58
|
+
if (seen.has(target) || seen.size >= 128)
|
|
59
|
+
throw new StorageUnavailableError('memory coverage is unavailable');
|
|
60
|
+
seen.add(target);
|
|
61
|
+
if (await memoryPgMap(context, context.currentRoot, 'barrier', target)
|
|
62
|
+
|| await memoryPgMap(context, context.currentRoot, 'disposed', target))
|
|
63
|
+
throw new StorageUnavailableError('memory selection is unavailable');
|
|
64
|
+
for (const parent of await memoryPgMap(context, context.currentRoot, 'parents', target) ?? [])
|
|
65
|
+
await requireAvailable(context, parent, new Set(seen));
|
|
66
|
+
};
|
|
67
|
+
const readProjectedRows = async (context, name, supplied) => {
|
|
68
|
+
const schema = memoryPgSchema(context);
|
|
69
|
+
const data = quotePgIdentifier(context.layout.dataSchema);
|
|
70
|
+
const member = `convert_from(${data}.map_get($1::bigint,'['||to_json(e.map_kind)::text||','||to_json(e.entry_key)::text||']'),'UTF8')::jsonb`;
|
|
71
|
+
if (name === 'memory-accepted-snapshot') {
|
|
72
|
+
const input = validateMemorySnapshotInput(supplied, context.limit);
|
|
73
|
+
return context.session.execute({
|
|
74
|
+
text: `WITH states AS (SELECT DISTINCT ON(e.entry_key) e.entry_key,e.state FROM ${schema}.memory_entries e
|
|
75
|
+
WHERE e.scope_key=$2 AND e.map_kind='aggregate' AND e.entry_key::jsonb->>0='memory-state-v1'
|
|
76
|
+
AND e.entry_key::jsonb->>1='record' AND e.ordinal<=$3::numeric
|
|
77
|
+
AND e.ordinal<=(${member}->>'version')::numeric ORDER BY e.entry_key,e.ordinal DESC)
|
|
78
|
+
SELECT r.payload_id,(s.entry_key::jsonb->>2) AS position,r.entry_key FROM states s
|
|
79
|
+
JOIN ${schema}.memory_entries r ON r.scope_key=$2 AND r.map_kind='record'
|
|
80
|
+
AND r.entry_key='["memory-record-v1",'||to_json(s.entry_key::jsonb->>2)::text||']'
|
|
81
|
+
WHERE s.state='accepted_current' AND ($4::text IS NULL OR r.scope_ref=$4)
|
|
82
|
+
AND ($5::text IS NULL OR (s.entry_key::jsonb->>2)>$5 COLLATE "C")
|
|
83
|
+
AND convert_from(${data}.map_get($1::bigint,'["record",'||to_json(r.entry_key)::text||']'),'UTF8')::jsonb->>'payload'=r.payload_id
|
|
84
|
+
ORDER BY (s.entry_key::jsonb->>2) COLLATE "C" LIMIT $6`,
|
|
85
|
+
values: [context.root, memoryPgScope(context), input.systemAsOf, input.scopeRef ?? null, context.cursor,
|
|
86
|
+
Math.min(context.limit, input.maxCandidates) + 1],
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const input = validateMemoryPageInput(supplied, context.limit);
|
|
90
|
+
const cursor = context.cursor === null ? [input.after, ''] : JSON.parse(String(context.cursor));
|
|
91
|
+
if (!Array.isArray(cursor) || cursor.length !== 2 || !isCanonicalU64(cursor[0]) || typeof cursor[1] !== 'string')
|
|
92
|
+
throw new StorageInvalidCommandError('invalid memory page continuation');
|
|
93
|
+
return context.session.execute({
|
|
94
|
+
text: `SELECT e.payload_id,e.ordinal::text,e.entry_key,e.map_kind FROM ${schema}.memory_entries e
|
|
95
|
+
WHERE e.scope_key=$2 AND e.map_kind=$3 AND e.ordinal>$4::numeric
|
|
96
|
+
AND (e.ordinal>$5::numeric OR (e.ordinal=$5::numeric AND e.entry_key>$6 COLLATE "C"))
|
|
97
|
+
AND (${member})->>'payload'=e.payload_id
|
|
98
|
+
ORDER BY e.ordinal,e.entry_key COLLATE "C" LIMIT $7`,
|
|
99
|
+
values: [context.root, memoryPgScope(context), name === 'memory-journal-page' ? 'chain-record' : 'record',
|
|
100
|
+
input.after, cursor[0], cursor[1], Math.min(context.limit, input.limit) + 1],
|
|
101
|
+
});
|
|
102
|
+
};
|
|
56
103
|
export const memoryPgQuery = (name) => {
|
|
57
104
|
if (!isMemoryQueryName(name)) {
|
|
58
105
|
throw new StorageInvalidCommandError(`unknown memory query: ${String(name)}`);
|
|
@@ -61,25 +108,68 @@ export const memoryPgQuery = (name) => {
|
|
|
61
108
|
if (context.cursor !== null && typeof context.cursor !== 'string') {
|
|
62
109
|
throw new StorageInvalidCommandError('invalid memory query continuation');
|
|
63
110
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
111
|
+
memoryPgSchema(context);
|
|
112
|
+
if (name === 'scope-chain-index') {
|
|
113
|
+
await requireAvailable(context, 'memory-journal');
|
|
114
|
+
const chain = await memoryPgMap(context, context.root, 'chain', 'memory-journal');
|
|
115
|
+
return { records: chain ? [{ chainId: 'memory-journal', headHash: chain.head, allocation: chain.allocation }] : [], nextCursor: null };
|
|
116
|
+
}
|
|
117
|
+
if (name === 'memory-record-by-id') {
|
|
118
|
+
const input = validateMemoryRecordByIdInput(supplied);
|
|
119
|
+
const key = JSON.stringify(['memory-record-v1', input.recordId]);
|
|
120
|
+
await requireAvailable(context, key);
|
|
121
|
+
const ref = await memoryPgMap(context, context.root, 'record', key);
|
|
122
|
+
return { records: ref ? [decodeMemoryValue(await readMemoryPgPayload(context, ref.payload))] : [], nextCursor: null };
|
|
123
|
+
}
|
|
124
|
+
if (name === 'memory-journal-page')
|
|
125
|
+
await requireAvailable(context, 'memory-journal');
|
|
126
|
+
const limit = Math.min(context.limit, name === 'memory-accepted-snapshot'
|
|
127
|
+
? validateMemorySnapshotInput(supplied, context.limit).maxCandidates
|
|
128
|
+
: validateMemoryPageInput(supplied, context.limit).limit);
|
|
129
|
+
const result = await readProjectedRows(context, name, supplied);
|
|
130
|
+
const records = [];
|
|
131
|
+
let position = null;
|
|
132
|
+
for (const row of result.rows.slice(0, limit)) {
|
|
133
|
+
const key = decodePgText(row.entry_key);
|
|
134
|
+
await requireAvailable(context, name === 'memory-journal-page' ? 'memory-journal' : key);
|
|
135
|
+
let value;
|
|
136
|
+
if (name === 'memory-journal-page') {
|
|
137
|
+
const data = quotePgIdentifier(context.layout.dataSchema);
|
|
138
|
+
const payload = (await context.session.execute({ text: `SELECT bytes,erased FROM ${data}.payloads WHERE scope_key=$1 AND id=$2`,
|
|
139
|
+
values: [memoryPgScope(context), decodePgText(row.payload_id)],
|
|
140
|
+
})).rows[0];
|
|
141
|
+
if (!payload || payload.erased === true || payload.bytes === null)
|
|
142
|
+
throw new StorageUnavailableError('memory journal payload is unavailable');
|
|
143
|
+
value = decodePgJson(decodePgUtf8(payload.bytes));
|
|
144
|
+
}
|
|
145
|
+
else
|
|
146
|
+
value = decodeMemoryValue(await readMemoryPgPayload(context, decodePgText(row.payload_id)));
|
|
147
|
+
const record = name === 'memory-accepted-snapshot' ? lexicalDocument(value) : value;
|
|
148
|
+
const next = name === 'memory-accepted-snapshot' ? decodePgText(row.position) : JSON.stringify([decodePgText(row.ordinal), key]);
|
|
149
|
+
if (Buffer.byteLength(JSON.stringify({ records: [...records, record], nextCursor: next }), 'utf8') > context.maxEncodedBytes) {
|
|
150
|
+
if (!records.length)
|
|
151
|
+
throw new StorageCapacityExceededError('memory record exceeds query byte budget');
|
|
152
|
+
return { records, nextCursor: position };
|
|
153
|
+
}
|
|
154
|
+
records.push(record);
|
|
155
|
+
position = next;
|
|
77
156
|
}
|
|
78
|
-
return
|
|
157
|
+
return { records, nextCursor: result.rows.length > limit ? position : null };
|
|
79
158
|
};
|
|
80
159
|
};
|
|
81
|
-
|
|
82
|
-
|
|
160
|
+
// Same accepted lexical document fields as Engram 0.21.1's derivation.
|
|
161
|
+
// Admission, eligibility, ranking and digest computation remain in Engram.
|
|
162
|
+
const lexicalDocument = (record) => {
|
|
163
|
+
const components = record.components;
|
|
164
|
+
const citations = record.citations;
|
|
165
|
+
const trust = record.trust;
|
|
166
|
+
if (!Array.isArray(components) || !Array.isArray(citations) || !trust)
|
|
167
|
+
throw new StorageUnavailableError('accepted memory record cannot be projected');
|
|
168
|
+
const text = (kind) => components.filter((component) => component.kind === kind).map((component) => component.text).join('\n');
|
|
169
|
+
return { record_id: record.record_id, record_digest: record.record_digest, valid_time: record.valid_time, trust_class: trust.class,
|
|
170
|
+
fields: { primary: components.find((component) => component.component_id === record.primary_component_id)?.text ?? '',
|
|
171
|
+
context: text('context'), decision: text('decision'), evidence: text('evidence'),
|
|
172
|
+
citations: citations.map((citation) => citation.source_ref).join('\n') } };
|
|
83
173
|
};
|
|
84
174
|
export const MEMORY_PG_QUERIES = Object.freeze({
|
|
85
175
|
'memory-journal-page': memoryPgQuery('memory-journal-page'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-queries.js","sourceRoot":"","sources":["../../src/engram-memory/postgres-queries.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,qEAAqE;AACrE,
|
|
1
|
+
{"version":3,"file":"postgres-queries.js","sourceRoot":"","sources":["../../src/engram-memory/postgres-queries.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,qEAAqE;AACrE,oEAAoE;AACpE,iEAAiE;AAEjE,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AACzH,O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ostgresStorageOptions } from '../storage/postgres/protocol.js';
|
|
1
|
+
import type { InjectedPgDriver, PostgresStorageOptions } from '../storage/postgres/protocol.js';
|
|
2
|
+
import { createPostgresKernel } from '../storage/postgres/index.js';
|
|
2
3
|
import { loadPgAssets } from '../storage/postgres/migrations.js';
|
|
3
4
|
import type { AtomicUnit } from '../storage/atomic.js';
|
|
4
5
|
import { MEMORY_DESCRIPTOR } from './manifest.js';
|
|
5
6
|
import { MEMORY_PG_QUERIES } from './postgres-queries.js';
|
|
6
7
|
import { MEMORY_STORAGE_LIMITS } from './limits.js';
|
|
8
|
+
import type { PgRegisteredProjection } from '../storage/postgres/protocol.js';
|
|
7
9
|
export interface MemoryPostgresRegistration {
|
|
8
10
|
readonly assets: Awaited<ReturnType<typeof loadPgAssets>>;
|
|
9
11
|
readonly descriptor: typeof MEMORY_DESCRIPTOR;
|
|
10
|
-
readonly validateEffects:
|
|
12
|
+
readonly validateEffects: PgRegisteredProjection;
|
|
13
|
+
readonly projection: PgRegisteredProjection;
|
|
11
14
|
readonly queries: typeof MEMORY_PG_QUERIES;
|
|
12
15
|
readonly limits: typeof MEMORY_STORAGE_LIMITS;
|
|
13
16
|
}
|
|
@@ -42,14 +45,52 @@ export declare const resolveMemoryCurrentFromAggregates: (readAggregate: (key: s
|
|
|
42
45
|
*/
|
|
43
46
|
export declare const validateMemoryEffects: (effects: AtomicUnit, resolveCurrent?: MemoryCurrentStateResolver) => Promise<void>;
|
|
44
47
|
export declare const createMemoryPostgresRegistration: () => Promise<MemoryPostgresRegistration>;
|
|
48
|
+
/** Host-owned PG driver identity: named versioned artifact, hex digest. */
|
|
49
|
+
export interface MemoryPostgresDriverIdentity {
|
|
50
|
+
readonly name: string;
|
|
51
|
+
readonly version: string;
|
|
52
|
+
readonly artifactDigest: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Qualified host-owned PG driver/pool provider. The host composition owns
|
|
56
|
+
* the pool lifecycle and passes the provider explicitly — including the
|
|
57
|
+
* live pool, so installed calls run through the exact pool the provider
|
|
58
|
+
* describes. Engram receives the neutral binding only, never the pool,
|
|
59
|
+
* raw SQL access or this provider.
|
|
60
|
+
*/
|
|
61
|
+
export interface MemoryPostgresDriverProvider {
|
|
62
|
+
readonly identity: MemoryPostgresDriverIdentity;
|
|
63
|
+
readonly serverFloor: string;
|
|
64
|
+
readonly pool: InjectedPgDriver;
|
|
65
|
+
}
|
|
66
|
+
/** Pinned server floor (the qualification stack runs postgres:17); kept literal. */
|
|
67
|
+
export declare const MEMORY_PG_SERVER_FLOOR: "17.0.0";
|
|
68
|
+
/** Object-level provider check: explicit host provider with a qualified identity, floor and live pool. */
|
|
69
|
+
export declare const checkMemoryPostgresDriver: (driver: unknown) => MemoryPostgresDriverProvider;
|
|
70
|
+
/**
|
|
71
|
+
* Live provider verification: run `SHOW server_version` through the
|
|
72
|
+
* provider's own pool and require it to meet the declared floor. This
|
|
73
|
+
* proves the pool is the installed one, not a metadata-only record.
|
|
74
|
+
*/
|
|
75
|
+
export declare const verifyMemoryPostgresProvider: (driver: unknown) => Promise<MemoryPostgresDriverProvider>;
|
|
45
76
|
/**
|
|
46
|
-
* Postgres storage composition
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
77
|
+
* Postgres storage composition, opened from the checked host provider
|
|
78
|
+
* (r2 P1-B). The factory checks the provider (identity, floor, live pool),
|
|
79
|
+
* fills the E6 stateful pieces (module assets, descriptor, effects
|
|
80
|
+
* validation, projection, queries, limits) from the memory registration and
|
|
81
|
+
* opens the kernel on the provider's own pool: installed calls run through
|
|
82
|
+
* the exact pool the provider describes, never a separately wired driver.
|
|
83
|
+
* The host applies migrations (E2 owns the migration writer); without the
|
|
84
|
+
* provider no backend is reachable and the factory refuses with
|
|
85
|
+
* `unavailable`. Engram never calls this factory: it receives the neutral
|
|
86
|
+
* grant only.
|
|
87
|
+
* Runtime pin (r2 P1-B'/r5): the caller owns exactly layout, history and
|
|
88
|
+
* cursorSecret. Factory-owned keys are dropped (the E6 registration always
|
|
89
|
+
* wins); any other key — notably an injected `operations` object, which the
|
|
90
|
+
* kernel would install as custom operations bypassing validateEffects — is
|
|
91
|
+
* refused with a denial, never ignored and never forwarded.
|
|
53
92
|
*/
|
|
54
|
-
export declare const createMemoryPostgresStorage: (options: Omit<PostgresStorageOptions, 'moduleId' | 'assets' | 'descriptor' | 'projection' | 'validateEffects' | 'queries' | 'operations'>
|
|
93
|
+
export declare const createMemoryPostgresStorage: (options: Omit<PostgresStorageOptions, 'moduleId' | 'driver' | 'assets' | 'descriptor' | 'projection' | 'validateEffects' | 'queries' | 'operations' | 'limits'> & {
|
|
94
|
+
readonly provider: MemoryPostgresDriverProvider;
|
|
95
|
+
}) => Promise<Awaited<ReturnType<typeof createPostgresKernel>>>;
|
|
55
96
|
//# sourceMappingURL=postgres.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/engram-memory/postgres.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../src/engram-memory/postgres.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAIjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,OAAO,KAAK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A4B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,4BAA4B,CAAC;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;CACjC;AAED,oFAAoF;AACpF,eAAO,MAAM,sBAAsB,UAAoB,CAAC;AAgBxD,0GAA0G;AAC1G,eAAO,MAAM,yBAAyB,WAAY,OAAO,KAAG,4BAgC3D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,WAC/B,OAAO,KACd,QAAQ,4BAA4B,CActC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,2BAA2B,YAC7B,KACP,sBAAsB,EACpB,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,YAAY,GACZ,YAAY,GACZ,iBAAiB,GACjB,SAAS,GACT,YAAY,GACZ,QAAQ,CACX,GAAG;IACF,QAAQ,CAAC,QAAQ,EAAE,4BAA4B,CAAC;CACjD,KACA,QAAQ,QAAQ,WAAW,2BAA2B,CAAC,CAAC,CAyC1D,CAAC"}
|
|
@@ -4,11 +4,15 @@
|
|
|
4
4
|
// then delegation to `createPostgresKernel`. No connection acquisition or
|
|
5
5
|
// migration execution in registration. A host cannot override mandatory
|
|
6
6
|
// validation, recovery or ownership through the storage factory.
|
|
7
|
+
import { createPostgresKernel } from '../storage/postgres/index.js';
|
|
7
8
|
import { loadPgAssets } from '../storage/postgres/migrations.js';
|
|
8
|
-
import {
|
|
9
|
+
import { decodePgText } from '../storage/postgres/codec.js';
|
|
10
|
+
import { StorageDeniedError, StorageInvalidCommandError, StorageUnavailableError } from '../storage/errors.js';
|
|
11
|
+
import { MemoryHostDriverRequiredError } from './sqlite.js';
|
|
9
12
|
import { MEMORY_DESCRIPTOR } from './manifest.js';
|
|
10
13
|
import { MEMORY_PG_QUERIES } from './postgres-queries.js';
|
|
11
14
|
import { MEMORY_STORAGE_LIMITS } from './limits.js';
|
|
15
|
+
import { projectMemoryPgEffects, validateMemoryPgEffects } from './projection.js';
|
|
12
16
|
import { isMemoryAdmissionOutcome, isMemoryCaptureProof, validateAdmissionTransition, validateCaptureTransition, } from './validation.js';
|
|
13
17
|
const decodeUpdateValue = (value) => {
|
|
14
18
|
const candidate = value;
|
|
@@ -54,17 +58,17 @@ export const resolveMemoryCurrentFromAggregates = (readAggregate) => async (key)
|
|
|
54
58
|
* refused before effects, and identical replay passes through.
|
|
55
59
|
*/
|
|
56
60
|
export const validateMemoryEffects = async (effects, resolveCurrent) => {
|
|
57
|
-
let
|
|
61
|
+
let completesCapture = false;
|
|
58
62
|
for (const update of effects.updates) {
|
|
59
63
|
const kind = updateKind(update.key);
|
|
60
64
|
if (kind === null)
|
|
61
65
|
throw new StorageInvalidCommandError('memory aggregate update requires a compound key');
|
|
62
66
|
const value = decodeUpdateValue(update.value);
|
|
63
67
|
if (kind === 'memory-capture-idempotency-v1') {
|
|
64
|
-
touchesCapture = true;
|
|
65
68
|
if (!isMemoryCaptureProof(value)) {
|
|
66
69
|
throw new StorageInvalidCommandError('memory capture update requires a capture proof value');
|
|
67
70
|
}
|
|
71
|
+
completesCapture ||= value.revision !== 1;
|
|
68
72
|
if (resolveCurrent !== undefined) {
|
|
69
73
|
const current = await resolveCurrent(update.key);
|
|
70
74
|
const transition = validateCaptureTransition(current ?? null, value);
|
|
@@ -86,30 +90,127 @@ export const validateMemoryEffects = async (effects, resolveCurrent) => {
|
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
|
-
if (
|
|
93
|
+
if (completesCapture && effects.appends.length !== 0) {
|
|
90
94
|
throw new StorageInvalidCommandError('memory capture completion carries strictly zero appends');
|
|
91
95
|
}
|
|
92
96
|
};
|
|
93
97
|
export const createMemoryPostgresRegistration = async () => Object.freeze({
|
|
94
|
-
assets: await loadPgAssets(),
|
|
98
|
+
assets: await loadPgAssets({ memory: true }),
|
|
95
99
|
descriptor: MEMORY_DESCRIPTOR,
|
|
96
|
-
validateEffects:
|
|
97
|
-
|
|
98
|
-
},
|
|
100
|
+
validateEffects: validateMemoryPgEffects,
|
|
101
|
+
projection: projectMemoryPgEffects,
|
|
99
102
|
queries: MEMORY_PG_QUERIES,
|
|
100
103
|
limits: MEMORY_STORAGE_LIMITS,
|
|
101
104
|
});
|
|
105
|
+
/** Pinned server floor (the qualification stack runs postgres:17); kept literal. */
|
|
106
|
+
export const MEMORY_PG_SERVER_FLOOR = '17.0.0';
|
|
107
|
+
const HEX64 = /^[a-f0-9]{64}$/;
|
|
108
|
+
const parseServer = (version) => {
|
|
109
|
+
const match = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?/.exec(version);
|
|
110
|
+
if (!match)
|
|
111
|
+
throw new StorageUnavailableError(`unreadable memory PG server version: ${version}`);
|
|
112
|
+
return [Number(match[1]), Number(match[2] ?? 0), Number(match[3] ?? 0)];
|
|
113
|
+
};
|
|
114
|
+
const serverAtLeast = (version, floor) => {
|
|
115
|
+
const [a, b, c] = parseServer(version);
|
|
116
|
+
const [x, y, z] = parseServer(floor);
|
|
117
|
+
return a !== x ? a > x : b !== y ? b > y : c >= z;
|
|
118
|
+
};
|
|
119
|
+
/** Object-level provider check: explicit host provider with a qualified identity, floor and live pool. */
|
|
120
|
+
export const checkMemoryPostgresDriver = (driver) => {
|
|
121
|
+
if (typeof driver !== 'object' || driver === null) {
|
|
122
|
+
throw new MemoryHostDriverRequiredError('memory Postgres storage requires an explicit host-injected driver provider');
|
|
123
|
+
}
|
|
124
|
+
const pool = driver.pool;
|
|
125
|
+
if (typeof pool !== 'object' ||
|
|
126
|
+
pool === null ||
|
|
127
|
+
typeof pool.transaction !== 'function') {
|
|
128
|
+
throw new MemoryHostDriverRequiredError('memory driver provider requires the live host pool');
|
|
129
|
+
}
|
|
130
|
+
const candidate = driver.identity;
|
|
131
|
+
const floor = driver.serverFloor;
|
|
132
|
+
if (typeof candidate !== 'object' ||
|
|
133
|
+
candidate === null ||
|
|
134
|
+
typeof candidate['name'] !== 'string' ||
|
|
135
|
+
candidate['name'].length === 0 ||
|
|
136
|
+
typeof candidate['version'] !== 'string' ||
|
|
137
|
+
candidate['version'].length === 0 ||
|
|
138
|
+
typeof candidate['artifactDigest'] !== 'string' ||
|
|
139
|
+
!HEX64.test(candidate['artifactDigest'])) {
|
|
140
|
+
throw new MemoryHostDriverRequiredError('memory driver provider requires a named versioned artifact identity');
|
|
141
|
+
}
|
|
142
|
+
if (typeof floor !== 'string' || !serverAtLeast(floor, MEMORY_PG_SERVER_FLOOR)) {
|
|
143
|
+
throw new StorageUnavailableError('memory PG server is below the qualified floor');
|
|
144
|
+
}
|
|
145
|
+
return driver;
|
|
146
|
+
};
|
|
102
147
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
148
|
+
* Live provider verification: run `SHOW server_version` through the
|
|
149
|
+
* provider's own pool and require it to meet the declared floor. This
|
|
150
|
+
* proves the pool is the installed one, not a metadata-only record.
|
|
151
|
+
*/
|
|
152
|
+
export const verifyMemoryPostgresProvider = async (driver) => {
|
|
153
|
+
const provider = checkMemoryPostgresDriver(driver);
|
|
154
|
+
const version = await provider.pool.transaction({ isolation: 'serializable', readOnly: true, deadlineMs: 5000 }, (session) => session.execute({ text: 'SHOW server_version', values: [] }).then((result) => {
|
|
155
|
+
const row = result.rows[0];
|
|
156
|
+
return decodePgText(row?.['server_version']);
|
|
157
|
+
}));
|
|
158
|
+
if (!serverAtLeast(version, provider.serverFloor)) {
|
|
159
|
+
throw new StorageUnavailableError('memory PG server is below the provider floor');
|
|
160
|
+
}
|
|
161
|
+
return provider;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Postgres storage composition, opened from the checked host provider
|
|
165
|
+
* (r2 P1-B). The factory checks the provider (identity, floor, live pool),
|
|
166
|
+
* fills the E6 stateful pieces (module assets, descriptor, effects
|
|
167
|
+
* validation, projection, queries, limits) from the memory registration and
|
|
168
|
+
* opens the kernel on the provider's own pool: installed calls run through
|
|
169
|
+
* the exact pool the provider describes, never a separately wired driver.
|
|
170
|
+
* The host applies migrations (E2 owns the migration writer); without the
|
|
171
|
+
* provider no backend is reachable and the factory refuses with
|
|
172
|
+
* `unavailable`. Engram never calls this factory: it receives the neutral
|
|
173
|
+
* grant only.
|
|
174
|
+
* Runtime pin (r2 P1-B'/r5): the caller owns exactly layout, history and
|
|
175
|
+
* cursorSecret. Factory-owned keys are dropped (the E6 registration always
|
|
176
|
+
* wins); any other key — notably an injected `operations` object, which the
|
|
177
|
+
* kernel would install as custom operations bypassing validateEffects — is
|
|
178
|
+
* refused with a denial, never ignored and never forwarded.
|
|
110
179
|
*/
|
|
111
180
|
export const createMemoryPostgresStorage = async (options) => {
|
|
112
|
-
|
|
113
|
-
|
|
181
|
+
const { provider, layout, history, cursorSecret, ...rest } = (options ?? {});
|
|
182
|
+
// Allowlist (r2 P1-B'' / r5): the caller owns exactly layout, history
|
|
183
|
+
// and cursorSecret. Factory-owned keys (moduleId, driver, assets,
|
|
184
|
+
// descriptor, projection, validateEffects, queries, limits) are dropped —
|
|
185
|
+
// the E6 registration below always wins. Anything else — notably an
|
|
186
|
+
// injected `operations` object, which the kernel would install as custom
|
|
187
|
+
// operations bypassing validateEffects — is refused, never ignored.
|
|
188
|
+
const dropped = new Set([
|
|
189
|
+
'moduleId', 'driver', 'assets', 'descriptor',
|
|
190
|
+
'projection', 'validateEffects', 'queries', 'limits',
|
|
191
|
+
]);
|
|
192
|
+
const smuggled = Object.keys(rest).filter((key) => !dropped.has(key));
|
|
193
|
+
if (smuggled.length > 0) {
|
|
194
|
+
throw new StorageDeniedError(`memory Postgres composition refuses caller-owned kernel keys: ${smuggled.sort().join(', ')}`);
|
|
195
|
+
}
|
|
196
|
+
if (typeof provider !== 'object' || provider === null) {
|
|
197
|
+
throw new StorageUnavailableError('memory Postgres composition requires the checked host provider for the G1b stateful projection: no backend reachable');
|
|
198
|
+
}
|
|
199
|
+
if (typeof layout !== 'object' || layout === null || typeof history !== 'object' || history === null) {
|
|
200
|
+
throw new StorageUnavailableError('memory Postgres composition requires the host layout and history');
|
|
201
|
+
}
|
|
202
|
+
if (typeof cursorSecret !== 'string' || cursorSecret.length === 0) {
|
|
203
|
+
throw new StorageUnavailableError('memory Postgres composition requires the host cursor secret');
|
|
204
|
+
}
|
|
205
|
+
const checked = checkMemoryPostgresDriver(provider);
|
|
206
|
+
const registration = await createMemoryPostgresRegistration();
|
|
207
|
+
return createPostgresKernel({
|
|
208
|
+
...registration,
|
|
209
|
+
moduleId: 'engram-memory',
|
|
210
|
+
driver: checked.pool,
|
|
211
|
+
layout,
|
|
212
|
+
history,
|
|
213
|
+
cursorSecret,
|
|
214
|
+
});
|
|
114
215
|
};
|
|
115
216
|
//# sourceMappingURL=postgres.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../src/engram-memory/postgres.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,qEAAqE;AACrE,yEAAyE;AACzE,0EAA0E;AAC1E,wEAAwE;AACxE,iEAAiE;AAGjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"postgres.js","sourceRoot":"","sources":["../../src/engram-memory/postgres.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,qEAAqE;AACrE,yEAAyE;AACzE,0EAA0E;AAC1E,wEAAwE;AACxE,iEAAiE;AAGjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AA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AAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACtE,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,kBAAkB,CAC1B,iEAAiE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC9F,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE,CAAC;QACtD,MAAM,IAAI,uBAAuB,CAC/B,sHAAsH,CACvH,CAAC;IACJ,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrG,MAAM,IAAI,uBAAuB,CAAC,kEAAkE,CAAC,CAAC;IACxG,CAAC;IACD,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClE,MAAM,IAAI,uBAAuB,CAAC,6DAA6D,CAAC,CAAC;IACnG,CAAC;IACD,MAAM,OAAO,GAAG,yBAAyB,CAAC,QAAQ,CAAC,CAAC;IACpD,MAAM,YAAY,GAAG,MAAM,gCAAgC,EAAE,CAAC;IAC9D,OAAO,oBAAoB,CAAC;QAC1B,GAAG,YAAY;QACf,QAAQ,EAAE,eAAe;QACzB,MAAM,EAAE,OAAO,CAAC,IAAI;QACpB,MAAM;QACN,OAAO;QACP,YAAY;KACb,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EncodedValue } from '../storage/contracts.js';
|
|
2
|
+
import type { PgProjectionContext, PgQueryContext, PgRegisteredProjection } from '../storage/postgres/protocol.js';
|
|
3
|
+
type Context = PgProjectionContext | PgQueryContext;
|
|
4
|
+
export declare const memoryPgScope: (context: Context) => string;
|
|
5
|
+
export declare const memoryPgSchema: (context: Context) => string;
|
|
6
|
+
export declare const decodeMemoryValue: (encoded: EncodedValue) => Record<string, unknown>;
|
|
7
|
+
export declare const memoryPgMap: <T>(context: Context, root: string | null, kind: string, key: string) => Promise<T | null>;
|
|
8
|
+
export declare const readMemoryPgPayload: (context: Context, payload: string) => Promise<EncodedValue>;
|
|
9
|
+
export declare const validateMemoryPgEffects: PgRegisteredProjection;
|
|
10
|
+
export declare const projectMemoryPgEffects: PgRegisteredProjection;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=projection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.d.ts","sourceRoot":"","sources":["../../src/engram-memory/projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAUnH,KAAK,OAAO,GAAG,mBAAmB,GAAG,cAAc,CAAC;AACpD,eAAO,MAAM,aAAa,YAAa,OAAO,KAAG,MAIhD,CAAC;AACF,eAAO,MAAM,cAAc,YAAa,OAAO,KAAG,MAKjD,CAAC;AACF,eAAO,MAAM,iBAAiB,YAAa,YAAY,KAAG,OAAO,MAAM,EAAE,OAAO,CAO/E,CAAC;AACF,eAAO,MAAM,WAAW,eAAuB,OAAO,QAAQ,MAAM,GAAG,IAAI,QAAQ,MAAM,OAAO,MAAM,KAAG,QAAQ,CAAC,GAAG,IAAI,CAMxH,CAAC;AACF,eAAO,MAAM,mBAAmB,YAAmB,OAAO,WAAW,MAAM,KAAG,QAAQ,YAAY,CAOjG,CAAC;AAIF,eAAO,MAAM,uBAAuB,EAAE,sBAiCrC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,sBA+BpC,CAAC"}
|