@byok-sdk/cloud-dataplane 0.8.1 → 0.9.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 +341 -7
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +338 -7
- package/dist/runtime.js.map +1 -1
- package/dist/sql/0014_agent_memory_projection.sql +134 -0
- package/dist/stores/agent-memory-projection.d.ts +34 -0
- package/dist/stores/index.d.ts +2 -0
- package/dist/tenant-erasure.d.ts +2 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { DEDUP_RING_CAPACITY, NONCE_TTL_MS, validateActivityAppend, projectTimel
|
|
|
3
3
|
import { contentHash, ByokCoreError, assertCanonicalTimestamp, isContentHash, tenantObjectKey, objectKeyPrefix, CoreConflictError, isLegalBoardTransition, checkSkillPackManifest, checkSkillPackEntry, SKILL_PACK_ENTRY_PATH, tenantId, SKILL_PACK_MANIFEST_SCHEMA_ID } from '@byok-sdk/core';
|
|
4
4
|
import { AwsClient } from 'aws4fetch';
|
|
5
5
|
import { XMLParser } from 'fast-xml-parser';
|
|
6
|
-
import { decodeEnvelope, isServerToDaemonType, EnvelopeSchema, encodeEnvelope, AgentEgressReliablePayloadSchema } from '@byok-sdk/protocol';
|
|
6
|
+
import { AgentMemoryProjectionMutationSchema, AgentMemoryProjectionReceiptSchema, AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE, AgentMemoryProjectionEraseResultSchema, AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES, decodeEnvelope, isServerToDaemonType, EnvelopeSchema, encodeEnvelope, AgentEgressReliablePayloadSchema } from '@byok-sdk/protocol';
|
|
7
7
|
import { createHash, randomUUID } from 'crypto';
|
|
8
8
|
import { readdir, readFile } from 'fs/promises';
|
|
9
9
|
import { join } from 'path';
|
|
@@ -1932,6 +1932,337 @@ var PostgresAgentEgressStore = class {
|
|
|
1932
1932
|
return row === void 0 ? void 0 : toRecord2(row);
|
|
1933
1933
|
}
|
|
1934
1934
|
};
|
|
1935
|
+
var RECEIPT_COLUMNS = [
|
|
1936
|
+
"tenant_id",
|
|
1937
|
+
"agent_id",
|
|
1938
|
+
"writer_epoch",
|
|
1939
|
+
"source_seq",
|
|
1940
|
+
"mutation_id",
|
|
1941
|
+
"device_id",
|
|
1942
|
+
"task_id",
|
|
1943
|
+
"agent_profile_revision",
|
|
1944
|
+
"session_ref",
|
|
1945
|
+
"runtime_id",
|
|
1946
|
+
"grant_ref",
|
|
1947
|
+
"policy_revision",
|
|
1948
|
+
"redacted_hash",
|
|
1949
|
+
"redacted_byte_count",
|
|
1950
|
+
"metering_receipt_id",
|
|
1951
|
+
"recorded_at"
|
|
1952
|
+
].join(", ");
|
|
1953
|
+
var PostgresAgentMemoryProjectionStore = class {
|
|
1954
|
+
#pool;
|
|
1955
|
+
#clock;
|
|
1956
|
+
#crypto;
|
|
1957
|
+
constructor(options) {
|
|
1958
|
+
this.#pool = options.pool;
|
|
1959
|
+
this.#clock = options.clock;
|
|
1960
|
+
this.#crypto = options.crypto;
|
|
1961
|
+
}
|
|
1962
|
+
async commit(input) {
|
|
1963
|
+
const mutation = AgentMemoryProjectionMutationSchema.parse(input.mutation);
|
|
1964
|
+
await this.#assertRedactedSnapshot(
|
|
1965
|
+
input.redactedBytes,
|
|
1966
|
+
mutation.snapshot.redactedBytes,
|
|
1967
|
+
mutation.snapshot.redactedByteCount,
|
|
1968
|
+
mutation.snapshot.redactedHash
|
|
1969
|
+
);
|
|
1970
|
+
const client = await this.#pool.connect();
|
|
1971
|
+
try {
|
|
1972
|
+
await client.query("BEGIN");
|
|
1973
|
+
await lockAgentMutation(client, input.tenantId, mutation.agentRef.agentId);
|
|
1974
|
+
const receipt = await this.#readReceipt(client, input.tenantId, mutation.agentRef.agentId, mutation.writerEpoch, mutation.sourceSeq);
|
|
1975
|
+
if (receipt !== void 0) {
|
|
1976
|
+
if (!sameReceiptBinding(receipt, input, mutation)) {
|
|
1977
|
+
throw replayMismatch();
|
|
1978
|
+
}
|
|
1979
|
+
await client.query("COMMIT");
|
|
1980
|
+
return toReceipt3(receipt, "idempotent");
|
|
1981
|
+
}
|
|
1982
|
+
const existingMutation = await this.#readReceiptByMutationId(
|
|
1983
|
+
client,
|
|
1984
|
+
input.tenantId,
|
|
1985
|
+
mutation.agentRef.agentId,
|
|
1986
|
+
mutation.writerEpoch,
|
|
1987
|
+
mutation.mutationId
|
|
1988
|
+
);
|
|
1989
|
+
if (existingMutation !== void 0) throw replayMismatch();
|
|
1990
|
+
const head = await this.#readHeadForUpdate(client, input.tenantId, mutation.agentRef.agentId);
|
|
1991
|
+
const fence = await this.#readEraseFenceForUpdate(client, input.tenantId, mutation.agentRef.agentId);
|
|
1992
|
+
assertNextMutation(head, fence, mutation.writerEpoch, mutation.sourceSeq);
|
|
1993
|
+
const now = this.#clock.now();
|
|
1994
|
+
const meteringReceiptId = this.#crypto.randomUuid();
|
|
1995
|
+
await client.query(
|
|
1996
|
+
`INSERT INTO agent_memory_projection_metering_receipt (${RECEIPT_COLUMNS})
|
|
1997
|
+
VALUES ($1, $2, $3, $4, $5::uuid, $6, $7, $8, $9, $10, $11, $12, $13, $14::integer, $15::uuid, $16)`,
|
|
1998
|
+
[
|
|
1999
|
+
input.tenantId,
|
|
2000
|
+
mutation.agentRef.agentId,
|
|
2001
|
+
mutation.writerEpoch,
|
|
2002
|
+
mutation.sourceSeq,
|
|
2003
|
+
mutation.mutationId,
|
|
2004
|
+
input.deviceId,
|
|
2005
|
+
mutation.taskId,
|
|
2006
|
+
mutation.agentRef.profileRevision,
|
|
2007
|
+
mutation.sessionRef,
|
|
2008
|
+
mutation.runtimeId,
|
|
2009
|
+
mutation.grantRef,
|
|
2010
|
+
mutation.policyRevision,
|
|
2011
|
+
mutation.snapshot.redactedHash,
|
|
2012
|
+
mutation.snapshot.redactedByteCount,
|
|
2013
|
+
meteringReceiptId,
|
|
2014
|
+
now
|
|
2015
|
+
]
|
|
2016
|
+
);
|
|
2017
|
+
await client.query(
|
|
2018
|
+
`INSERT INTO agent_memory_projection_head (
|
|
2019
|
+
tenant_id, agent_id, writer_epoch, source_seq, mutation_id,
|
|
2020
|
+
device_id, task_id, agent_profile_revision, session_ref, runtime_id,
|
|
2021
|
+
grant_ref, policy_revision, redacted_hash, redacted_snapshot,
|
|
2022
|
+
redacted_byte_count, committed_at
|
|
2023
|
+
) VALUES (
|
|
2024
|
+
$1, $2, $3, $4, $5::uuid,
|
|
2025
|
+
$6, $7, $8, $9, $10,
|
|
2026
|
+
$11, $12, $13, decode($14, 'base64'),
|
|
2027
|
+
$15::integer, $16
|
|
2028
|
+
)
|
|
2029
|
+
ON CONFLICT (tenant_id, agent_id) DO UPDATE SET
|
|
2030
|
+
writer_epoch = EXCLUDED.writer_epoch,
|
|
2031
|
+
source_seq = EXCLUDED.source_seq,
|
|
2032
|
+
mutation_id = EXCLUDED.mutation_id,
|
|
2033
|
+
device_id = EXCLUDED.device_id,
|
|
2034
|
+
task_id = EXCLUDED.task_id,
|
|
2035
|
+
agent_profile_revision = EXCLUDED.agent_profile_revision,
|
|
2036
|
+
session_ref = EXCLUDED.session_ref,
|
|
2037
|
+
runtime_id = EXCLUDED.runtime_id,
|
|
2038
|
+
grant_ref = EXCLUDED.grant_ref,
|
|
2039
|
+
policy_revision = EXCLUDED.policy_revision,
|
|
2040
|
+
redacted_hash = EXCLUDED.redacted_hash,
|
|
2041
|
+
redacted_snapshot = EXCLUDED.redacted_snapshot,
|
|
2042
|
+
redacted_byte_count = EXCLUDED.redacted_byte_count,
|
|
2043
|
+
committed_at = EXCLUDED.committed_at`,
|
|
2044
|
+
[
|
|
2045
|
+
input.tenantId,
|
|
2046
|
+
mutation.agentRef.agentId,
|
|
2047
|
+
mutation.writerEpoch,
|
|
2048
|
+
mutation.sourceSeq,
|
|
2049
|
+
mutation.mutationId,
|
|
2050
|
+
input.deviceId,
|
|
2051
|
+
mutation.taskId,
|
|
2052
|
+
mutation.agentRef.profileRevision,
|
|
2053
|
+
mutation.sessionRef,
|
|
2054
|
+
mutation.runtimeId,
|
|
2055
|
+
mutation.grantRef,
|
|
2056
|
+
mutation.policyRevision,
|
|
2057
|
+
mutation.snapshot.redactedHash,
|
|
2058
|
+
toBase64(input.redactedBytes),
|
|
2059
|
+
mutation.snapshot.redactedByteCount,
|
|
2060
|
+
now
|
|
2061
|
+
]
|
|
2062
|
+
);
|
|
2063
|
+
await client.query("COMMIT");
|
|
2064
|
+
return AgentMemoryProjectionReceiptSchema.parse({
|
|
2065
|
+
outcome: "accepted",
|
|
2066
|
+
tenantId: input.tenantId,
|
|
2067
|
+
deviceId: input.deviceId,
|
|
2068
|
+
taskId: mutation.taskId,
|
|
2069
|
+
agentRef: mutation.agentRef,
|
|
2070
|
+
sessionRef: mutation.sessionRef,
|
|
2071
|
+
runtimeId: mutation.runtimeId,
|
|
2072
|
+
grantRef: mutation.grantRef,
|
|
2073
|
+
writerEpoch: mutation.writerEpoch,
|
|
2074
|
+
sourceSeq: mutation.sourceSeq,
|
|
2075
|
+
mutationId: mutation.mutationId,
|
|
2076
|
+
policyRevision: mutation.policyRevision,
|
|
2077
|
+
redactedHash: mutation.snapshot.redactedHash,
|
|
2078
|
+
redactedByteCount: mutation.snapshot.redactedByteCount,
|
|
2079
|
+
metering: {
|
|
2080
|
+
meteringReceiptId,
|
|
2081
|
+
acceptedRedactedBytes: mutation.snapshot.redactedByteCount,
|
|
2082
|
+
recordedAt: now.toISOString()
|
|
2083
|
+
}
|
|
2084
|
+
});
|
|
2085
|
+
} catch (cause) {
|
|
2086
|
+
await rollback(client);
|
|
2087
|
+
throw cause;
|
|
2088
|
+
} finally {
|
|
2089
|
+
client.release();
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
/** Delete body/receipts but retain a body-free epoch fence under one source lock. */
|
|
2093
|
+
async erase(input) {
|
|
2094
|
+
const client = await this.#pool.connect();
|
|
2095
|
+
try {
|
|
2096
|
+
await client.query("BEGIN");
|
|
2097
|
+
await lockAgentMutation(client, input.tenantId, input.agentId);
|
|
2098
|
+
const head = await this.#readHeadForUpdate(client, input.tenantId, input.agentId);
|
|
2099
|
+
const fence = await this.#readEraseFenceForUpdate(client, input.tenantId, input.agentId);
|
|
2100
|
+
const nextWriterEpoch = Math.max(fence?.next_writer_epoch ?? 1, (head?.writer_epoch ?? 0) + 1);
|
|
2101
|
+
if (nextWriterEpoch > AGENT_MEMORY_PROJECTION_MAX_ORDERING_VALUE) {
|
|
2102
|
+
throw new ByokCloudError("agent_memory_projection_epoch_exhausted", "The memory projection writerEpoch cannot advance after erase.");
|
|
2103
|
+
}
|
|
2104
|
+
await client.query(
|
|
2105
|
+
"DELETE FROM agent_memory_projection_metering_receipt WHERE tenant_id = $1 AND agent_id = $2",
|
|
2106
|
+
[input.tenantId, input.agentId]
|
|
2107
|
+
);
|
|
2108
|
+
await client.query(
|
|
2109
|
+
"DELETE FROM agent_memory_projection_head WHERE tenant_id = $1 AND agent_id = $2",
|
|
2110
|
+
[input.tenantId, input.agentId]
|
|
2111
|
+
);
|
|
2112
|
+
await client.query(
|
|
2113
|
+
`INSERT INTO agent_memory_projection_erase_fence (tenant_id, agent_id, next_writer_epoch, erased_at)
|
|
2114
|
+
VALUES ($1, $2, $3::integer, $4)
|
|
2115
|
+
ON CONFLICT (tenant_id, agent_id) DO UPDATE SET
|
|
2116
|
+
next_writer_epoch = GREATEST(agent_memory_projection_erase_fence.next_writer_epoch, EXCLUDED.next_writer_epoch),
|
|
2117
|
+
erased_at = EXCLUDED.erased_at`,
|
|
2118
|
+
[input.tenantId, input.agentId, nextWriterEpoch, this.#clock.now()]
|
|
2119
|
+
);
|
|
2120
|
+
await client.query("COMMIT");
|
|
2121
|
+
return AgentMemoryProjectionEraseResultSchema.parse({ nextWriterEpoch });
|
|
2122
|
+
} catch (cause) {
|
|
2123
|
+
await rollback(client);
|
|
2124
|
+
throw cause;
|
|
2125
|
+
} finally {
|
|
2126
|
+
client.release();
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
async #assertRedactedSnapshot(bytes, portableBody, byteCount, expectedHash) {
|
|
2130
|
+
if (bytes.byteLength !== byteCount || bytes.byteLength > AGENT_MEMORY_PROJECTION_MAX_REDACTED_BYTES) {
|
|
2131
|
+
throw hashMismatch("Decoded redacted snapshot bytes do not match redactedByteCount.");
|
|
2132
|
+
}
|
|
2133
|
+
if (portableBody !== toBase64Url(bytes)) {
|
|
2134
|
+
throw hashMismatch("Decoded redacted snapshot bytes do not match the portable redactedBytes body.");
|
|
2135
|
+
}
|
|
2136
|
+
if (await this.#crypto.sha256(bytes) !== expectedHash) {
|
|
2137
|
+
throw hashMismatch("Decoded redacted snapshot bytes do not match redactedHash.");
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
async #readHeadForUpdate(client, tenant, agentId) {
|
|
2141
|
+
const result = await client.query(
|
|
2142
|
+
`SELECT tenant_id, agent_id, writer_epoch, source_seq
|
|
2143
|
+
FROM agent_memory_projection_head
|
|
2144
|
+
WHERE tenant_id = $1 AND agent_id = $2
|
|
2145
|
+
FOR UPDATE`,
|
|
2146
|
+
[tenant, agentId]
|
|
2147
|
+
);
|
|
2148
|
+
return result.rows[0];
|
|
2149
|
+
}
|
|
2150
|
+
async #readEraseFenceForUpdate(client, tenant, agentId) {
|
|
2151
|
+
const result = await client.query(
|
|
2152
|
+
`SELECT next_writer_epoch
|
|
2153
|
+
FROM agent_memory_projection_erase_fence
|
|
2154
|
+
WHERE tenant_id = $1 AND agent_id = $2
|
|
2155
|
+
FOR UPDATE`,
|
|
2156
|
+
[tenant, agentId]
|
|
2157
|
+
);
|
|
2158
|
+
return result.rows[0];
|
|
2159
|
+
}
|
|
2160
|
+
async #readReceipt(client, tenant, agentId, writerEpoch, sourceSeq) {
|
|
2161
|
+
const result = await client.query(
|
|
2162
|
+
`SELECT ${RECEIPT_COLUMNS}
|
|
2163
|
+
FROM agent_memory_projection_metering_receipt
|
|
2164
|
+
WHERE tenant_id = $1 AND agent_id = $2 AND writer_epoch = $3 AND source_seq = $4`,
|
|
2165
|
+
[tenant, agentId, writerEpoch, sourceSeq]
|
|
2166
|
+
);
|
|
2167
|
+
return result.rows[0];
|
|
2168
|
+
}
|
|
2169
|
+
async #readReceiptByMutationId(client, tenant, agentId, writerEpoch, mutationId) {
|
|
2170
|
+
const result = await client.query(
|
|
2171
|
+
`SELECT ${RECEIPT_COLUMNS}
|
|
2172
|
+
FROM agent_memory_projection_metering_receipt
|
|
2173
|
+
WHERE tenant_id = $1 AND agent_id = $2 AND writer_epoch = $3 AND mutation_id = $4::uuid`,
|
|
2174
|
+
[tenant, agentId, writerEpoch, mutationId]
|
|
2175
|
+
);
|
|
2176
|
+
return result.rows[0];
|
|
2177
|
+
}
|
|
2178
|
+
};
|
|
2179
|
+
function createPostgresAgentMemoryProjectionStore(options) {
|
|
2180
|
+
return new PostgresAgentMemoryProjectionStore(options);
|
|
2181
|
+
}
|
|
2182
|
+
function assertNextMutation(head, fence, writerEpoch, sourceSeq) {
|
|
2183
|
+
if (fence !== void 0 && writerEpoch < fence.next_writer_epoch) {
|
|
2184
|
+
throw erasedEpoch();
|
|
2185
|
+
}
|
|
2186
|
+
if (head === void 0) {
|
|
2187
|
+
if (sourceSeq !== 1) throw sequenceGap("The first memory projection mutation must use sourceSeq 1.");
|
|
2188
|
+
return;
|
|
2189
|
+
}
|
|
2190
|
+
if (writerEpoch < head.writer_epoch) {
|
|
2191
|
+
throw new ByokCloudError("agent_memory_projection_stale_epoch", "The memory projection writerEpoch is stale.");
|
|
2192
|
+
}
|
|
2193
|
+
if (writerEpoch > head.writer_epoch) {
|
|
2194
|
+
if (sourceSeq !== 1) throw sequenceGap("A new memory projection writerEpoch must start at sourceSeq 1.");
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2197
|
+
if (sourceSeq !== head.source_seq + 1) {
|
|
2198
|
+
throw sequenceGap("A memory projection mutation must advance sourceSeq exactly by one.");
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
function sameReceiptBinding(receipt, input, mutation) {
|
|
2202
|
+
return receipt.tenant_id === input.tenantId && receipt.agent_id === mutation.agentRef.agentId && receipt.device_id === input.deviceId && receipt.task_id === mutation.taskId && receipt.agent_profile_revision === mutation.agentRef.profileRevision && receipt.session_ref === mutation.sessionRef && receipt.runtime_id === mutation.runtimeId && receipt.grant_ref === mutation.grantRef && receipt.writer_epoch === mutation.writerEpoch && receipt.source_seq === mutation.sourceSeq && receipt.mutation_id === mutation.mutationId && receipt.policy_revision === mutation.policyRevision && receipt.redacted_hash === mutation.snapshot.redactedHash && receipt.redacted_byte_count === mutation.snapshot.redactedByteCount;
|
|
2203
|
+
}
|
|
2204
|
+
function toReceipt3(row, outcome) {
|
|
2205
|
+
return AgentMemoryProjectionReceiptSchema.parse({
|
|
2206
|
+
outcome,
|
|
2207
|
+
tenantId: row.tenant_id,
|
|
2208
|
+
deviceId: row.device_id,
|
|
2209
|
+
taskId: row.task_id,
|
|
2210
|
+
agentRef: { agentId: row.agent_id, profileRevision: row.agent_profile_revision },
|
|
2211
|
+
sessionRef: row.session_ref,
|
|
2212
|
+
runtimeId: row.runtime_id,
|
|
2213
|
+
grantRef: row.grant_ref,
|
|
2214
|
+
writerEpoch: row.writer_epoch,
|
|
2215
|
+
sourceSeq: row.source_seq,
|
|
2216
|
+
mutationId: row.mutation_id,
|
|
2217
|
+
policyRevision: row.policy_revision,
|
|
2218
|
+
redactedHash: row.redacted_hash,
|
|
2219
|
+
redactedByteCount: row.redacted_byte_count,
|
|
2220
|
+
metering: {
|
|
2221
|
+
meteringReceiptId: row.metering_receipt_id,
|
|
2222
|
+
acceptedRedactedBytes: row.redacted_byte_count,
|
|
2223
|
+
recordedAt: row.recorded_at.toISOString()
|
|
2224
|
+
}
|
|
2225
|
+
});
|
|
2226
|
+
}
|
|
2227
|
+
async function lockAgentMutation(client, tenant, agentId) {
|
|
2228
|
+
await client.query(
|
|
2229
|
+
`SELECT pg_advisory_xact_lock(
|
|
2230
|
+
hashtextextended(length($1)::text || ':' || $1 || length($2)::text || ':' || $2, 0)
|
|
2231
|
+
)`,
|
|
2232
|
+
[tenant, agentId]
|
|
2233
|
+
);
|
|
2234
|
+
}
|
|
2235
|
+
function hashMismatch(message) {
|
|
2236
|
+
return new ByokCloudError("agent_memory_projection_hash_mismatch", message);
|
|
2237
|
+
}
|
|
2238
|
+
function sequenceGap(message) {
|
|
2239
|
+
return new ByokCloudError("agent_memory_projection_sequence_gap", message);
|
|
2240
|
+
}
|
|
2241
|
+
function erasedEpoch() {
|
|
2242
|
+
return new ByokCloudError("agent_memory_projection_erased_epoch", "The memory projection writerEpoch was erased and cannot be replayed.");
|
|
2243
|
+
}
|
|
2244
|
+
function replayMismatch() {
|
|
2245
|
+
return new ByokCloudError(
|
|
2246
|
+
"agent_memory_projection_replay_mismatch",
|
|
2247
|
+
"A memory projection epoch and source sequence already names a different immutable mutation."
|
|
2248
|
+
);
|
|
2249
|
+
}
|
|
2250
|
+
function toBase64(bytes) {
|
|
2251
|
+
const chunks = [];
|
|
2252
|
+
for (let offset = 0; offset < bytes.length; offset += 32 * 1024) {
|
|
2253
|
+
chunks.push(String.fromCharCode(...bytes.subarray(offset, offset + 32 * 1024)));
|
|
2254
|
+
}
|
|
2255
|
+
return btoa(chunks.join(""));
|
|
2256
|
+
}
|
|
2257
|
+
function toBase64Url(bytes) {
|
|
2258
|
+
return toBase64(bytes).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
2259
|
+
}
|
|
2260
|
+
async function rollback(client) {
|
|
2261
|
+
try {
|
|
2262
|
+
await client.query("ROLLBACK");
|
|
2263
|
+
} catch {
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
1935
2266
|
|
|
1936
2267
|
// src/stores/device-assertion-replay.ts
|
|
1937
2268
|
var PostgresDeviceAssertionReplayAuthority = class {
|
|
@@ -3246,7 +3577,7 @@ function createPostgresCoreStores(options) {
|
|
|
3246
3577
|
};
|
|
3247
3578
|
}
|
|
3248
3579
|
var RECORD_COLUMNS2 = "tenant_id, kind, subject_id, rev, content_hash, byte_size, body_kind, body_inline, body_object_hash, label, request_id, written_at";
|
|
3249
|
-
var
|
|
3580
|
+
var RECEIPT_COLUMNS2 = "tenant_id, device_id, request_id, operation, resource, body_sha256, body_size, response_status, response_body, recorded_at";
|
|
3250
3581
|
function toBody2(row) {
|
|
3251
3582
|
return row.body_kind === "inline" ? { kind: "inline", body: row.body_inline ?? "" } : { kind: "object", hash: row.body_object_hash ?? "" };
|
|
3252
3583
|
}
|
|
@@ -3264,7 +3595,7 @@ function toRecord4(tenant, row) {
|
|
|
3264
3595
|
writtenAt: row.written_at
|
|
3265
3596
|
};
|
|
3266
3597
|
}
|
|
3267
|
-
function
|
|
3598
|
+
function toReceipt4(tenant, row) {
|
|
3268
3599
|
return {
|
|
3269
3600
|
tenantId: tenant,
|
|
3270
3601
|
deviceId: row.device_id,
|
|
@@ -3344,7 +3675,7 @@ var PostgresTruthCommitter = class {
|
|
|
3344
3675
|
snapshots: applied.slice(1).map((entry) => truthRecordMetadata(entry.record))
|
|
3345
3676
|
};
|
|
3346
3677
|
await client.query(
|
|
3347
|
-
`INSERT INTO proof_request_receipt (${
|
|
3678
|
+
`INSERT INTO proof_request_receipt (${RECEIPT_COLUMNS2})
|
|
3348
3679
|
VALUES ($1, $2, $3, $4, $5, $6, $7::bigint, 200, $8, $9)`,
|
|
3349
3680
|
[
|
|
3350
3681
|
tenant,
|
|
@@ -3403,12 +3734,12 @@ var PostgresTruthCommitter = class {
|
|
|
3403
3734
|
}
|
|
3404
3735
|
async #readReceipt(client, tenant, deviceId, requestId) {
|
|
3405
3736
|
const result = await client.query(
|
|
3406
|
-
`SELECT ${
|
|
3737
|
+
`SELECT ${RECEIPT_COLUMNS2} FROM proof_request_receipt
|
|
3407
3738
|
WHERE tenant_id = $1 AND device_id = $2 AND request_id = $3`,
|
|
3408
3739
|
[tenant, deviceId, requestId]
|
|
3409
3740
|
);
|
|
3410
3741
|
const row = result.rows[0];
|
|
3411
|
-
return row === void 0 ? void 0 :
|
|
3742
|
+
return row === void 0 ? void 0 : toReceipt4(tenant, row);
|
|
3412
3743
|
}
|
|
3413
3744
|
async #lockCurrentRecords(client, tenant, writes) {
|
|
3414
3745
|
const current = /* @__PURE__ */ new Map();
|
|
@@ -4904,6 +5235,9 @@ var TENANT_ERASURE_TABLES = [
|
|
|
4904
5235
|
"board_item",
|
|
4905
5236
|
"tenant_stream",
|
|
4906
5237
|
"outbox",
|
|
5238
|
+
"agent_memory_projection_metering_receipt",
|
|
5239
|
+
"agent_memory_projection_head",
|
|
5240
|
+
"agent_memory_projection_erase_fence",
|
|
4907
5241
|
"agent_egress_event",
|
|
4908
5242
|
"device_request_receipts",
|
|
4909
5243
|
"proof_request_receipt",
|
|
@@ -5360,6 +5694,6 @@ function databaseFailure(action, cause) {
|
|
|
5360
5694
|
);
|
|
5361
5695
|
}
|
|
5362
5696
|
|
|
5363
|
-
export { CLOUD_CLEANUP_ERROR_CODES, CloudCleanupError, DEFAULT_MAX_ATTEMPTS, DEFAULT_PRESIGN_TTL_SECONDS, DEFAULT_RETRY_DELAY_MS, MAX_PRESIGN_TTL_SECONDS, MIN_PRESIGN_TTL_SECONDS, MigrationChecksumMismatchError, MigrationFilenameError, MigrationStateMismatchError, ObjectStoreRequestError, PostgresActivityStore, PostgresApprovalTimelineStore, PostgresBoardStore, PostgresCloudCleanup, PostgresDeviceAssertionReplayAuthority, PostgresDeviceDirectory, PostgresInboundDedupStore, PostgresMailboxStore, PostgresNonceStore, PostgresObjectStore, PostgresPairingCodeStore, PostgresPresenceStore, PostgresProofRequestReceiptStore, PostgresQuotaStore, PostgresRequestReceiptStore, PostgresSkillPackStore, PostgresTaskAttemptStore, PostgresTaskCancellationStore, PostgresTenantErasure, PostgresTruthCommitter, PostgresTruthStore, R2BlobStoreError, R2CloudBlobStore, R2ObjectMaintenanceStore, R2_BLOB_ERROR_CODES, TENANT_ERASURE_ERROR_CODES, TENANT_ERASURE_TABLES, TenantErasureError, createByokPool, createPostgresCloudMaintenance, createPostgresCloudStores, createPostgresCoreStores, createPostgresTenantErasure, migrate, migrationsDir, readMigrationFiles, verifyMigrations };
|
|
5697
|
+
export { CLOUD_CLEANUP_ERROR_CODES, CloudCleanupError, DEFAULT_MAX_ATTEMPTS, DEFAULT_PRESIGN_TTL_SECONDS, DEFAULT_RETRY_DELAY_MS, MAX_PRESIGN_TTL_SECONDS, MIN_PRESIGN_TTL_SECONDS, MigrationChecksumMismatchError, MigrationFilenameError, MigrationStateMismatchError, ObjectStoreRequestError, PostgresActivityStore, PostgresAgentMemoryProjectionStore, PostgresApprovalTimelineStore, PostgresBoardStore, PostgresCloudCleanup, PostgresDeviceAssertionReplayAuthority, PostgresDeviceDirectory, PostgresInboundDedupStore, PostgresMailboxStore, PostgresNonceStore, PostgresObjectStore, PostgresPairingCodeStore, PostgresPresenceStore, PostgresProofRequestReceiptStore, PostgresQuotaStore, PostgresRequestReceiptStore, PostgresSkillPackStore, PostgresTaskAttemptStore, PostgresTaskCancellationStore, PostgresTenantErasure, PostgresTruthCommitter, PostgresTruthStore, R2BlobStoreError, R2CloudBlobStore, R2ObjectMaintenanceStore, R2_BLOB_ERROR_CODES, TENANT_ERASURE_ERROR_CODES, TENANT_ERASURE_TABLES, TenantErasureError, createByokPool, createPostgresAgentMemoryProjectionStore, createPostgresCloudMaintenance, createPostgresCloudStores, createPostgresCoreStores, createPostgresTenantErasure, migrate, migrationsDir, readMigrationFiles, verifyMigrations };
|
|
5364
5698
|
//# sourceMappingURL=index.js.map
|
|
5365
5699
|
//# sourceMappingURL=index.js.map
|