@tangle-network/agent-provider-tangle 5.0.19 → 5.0.20
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.
|
@@ -3,7 +3,7 @@ import { ConfidentialAttestationSchema, ConfidentialExecutionRequestSchema, Fork
|
|
|
3
3
|
import { awaitWithSignal, boundedIdentifier, boundedString, MAX_STRING_LENGTH, cloneJson, safeIdentifier, safeString, } from "./tangle-contract-safety.js";
|
|
4
4
|
import { encodeTangleConfidentialAttestationQuote } from "./tangle-confidential-attestation.js";
|
|
5
5
|
import { checkpointMarkerTags, forkMarkerMetadata, markerBelongsToSource, checkpointMarkerBelongsToSource, checkpointMarkerFromTags, forkMarkerFromMetadata, } from "./tangle-workspace-markers.js";
|
|
6
|
-
import { checkpointRecordFromSnapshot, validSnapshotResult, reconcileCheckpoint, findManagedCheckpoint, findForkByKey, findForkChildById, completeForkChild, lookupOutcomeFromSandbox, isoDate, } from "./tangle-workspace-recovery.js";
|
|
6
|
+
import { checkpointRecordFromSnapshot, validSnapshotResult, reconcileCheckpoint, findManagedCheckpoint, inspectCheckpointResource, findForkByKey, findForkChildById, completeForkChild, lookupOutcomeFromSandbox, isoDate, } from "./tangle-workspace-recovery.js";
|
|
7
7
|
const TANGLE_ATTESTATION_NONCE_PATTERN = /^(?:0x)?[0-9a-fA-F]{64}(?:[0-9a-fA-F]{64})?$/;
|
|
8
8
|
function confidentialForkRefusal(request) {
|
|
9
9
|
const confidential = request.confidential;
|
|
@@ -316,7 +316,7 @@ export function createTangleWorkspaceBranching(options) {
|
|
|
316
316
|
const checkpoint = [...checkpoints.values()].some((record) => canonicalCandidateDigest(record.checkpoint) ===
|
|
317
317
|
canonicalCandidateDigest(request.checkpoint))
|
|
318
318
|
? undefined
|
|
319
|
-
: await
|
|
319
|
+
: await inspectCheckpointResource(box, provider, request.checkpoint, operation?.signal);
|
|
320
320
|
if (checkpoint !== undefined && checkpoint.state !== "found") {
|
|
321
321
|
return forkUnknown(request, checkpoint.state === "absent"
|
|
322
322
|
? "Requested checkpoint is absent"
|
|
@@ -499,6 +499,7 @@ export function createTangleWorkspaceBranching(options) {
|
|
|
499
499
|
return {
|
|
500
500
|
checkpoint,
|
|
501
501
|
lookupCheckpoint,
|
|
502
|
+
inspectCheckpoint: async (reference, operation) => (await inspectCheckpointResource(box, provider, reference, operation?.signal)).state,
|
|
502
503
|
deleteCheckpoint,
|
|
503
504
|
fork,
|
|
504
505
|
lookupFork,
|
|
@@ -44,6 +44,8 @@ export type ManagedCheckpoint = {
|
|
|
44
44
|
state: "unknown";
|
|
45
45
|
reason: "inventory unavailable" | "ambiguous seal alias" | "invalid snapshot metadata" | "not marked by this source" | "operation not confirmed";
|
|
46
46
|
};
|
|
47
|
+
/** The public preflight and a fresh fork verify the same original reference. */
|
|
48
|
+
export declare function inspectCheckpointResource(box: SandboxInstanceLike, provider: string, input: WorkspaceCheckpointRef, signal?: AbortSignal): Promise<ManagedCheckpoint>;
|
|
47
49
|
/**
|
|
48
50
|
* Confirm that one checkpoint id is a settled checkpoint this provider created.
|
|
49
51
|
*
|
|
@@ -54,6 +56,9 @@ export type ManagedCheckpoint = {
|
|
|
54
56
|
* never absent. `expected` binds the answer to a specific checkpoint
|
|
55
57
|
* reference (fork): a reference that does not match its marker is absent, not
|
|
56
58
|
* unknown, because the caller supplied a checkpoint this source never produced.
|
|
59
|
+
* The retained reference can address a live physical capture after the operation
|
|
60
|
+
* expires: Sandbox reserves seal tags for storage, and the physical id commits to
|
|
61
|
+
* the native snapshot. This proof grants a read of those exact bytes only.
|
|
57
62
|
*/
|
|
58
63
|
export declare function findManagedCheckpoint(box: SandboxInstanceLike, provider: string, id: string, expected?: WorkspaceCheckpointRef, signal?: AbortSignal): Promise<ManagedCheckpoint>;
|
|
59
64
|
export declare function findForkByKey(client: SandboxClientLike, box: SandboxInstanceLike, provider: string, key: string, signal?: AbortSignal): Promise<(RecoveredForkChild & {
|
|
@@ -241,6 +241,11 @@ function snapshotFromOperationResult(snapshot, lookup, marker) {
|
|
|
241
241
|
}
|
|
242
242
|
return { ...snapshot, snapshotId: lookup.result.snapshotId, createdAt: lookup.result.createdAt };
|
|
243
243
|
}
|
|
244
|
+
/** The public preflight and a fresh fork verify the same original reference. */
|
|
245
|
+
export function inspectCheckpointResource(box, provider, input, signal) {
|
|
246
|
+
const reference = WorkspaceCheckpointRefSchema.parse(input);
|
|
247
|
+
return findManagedCheckpoint(box, provider, reference.checkpointId, reference, signal);
|
|
248
|
+
}
|
|
244
249
|
/**
|
|
245
250
|
* Confirm that one checkpoint id is a settled checkpoint this provider created.
|
|
246
251
|
*
|
|
@@ -251,6 +256,9 @@ function snapshotFromOperationResult(snapshot, lookup, marker) {
|
|
|
251
256
|
* never absent. `expected` binds the answer to a specific checkpoint
|
|
252
257
|
* reference (fork): a reference that does not match its marker is absent, not
|
|
253
258
|
* unknown, because the caller supplied a checkpoint this source never produced.
|
|
259
|
+
* The retained reference can address a live physical capture after the operation
|
|
260
|
+
* expires: Sandbox reserves seal tags for storage, and the physical id commits to
|
|
261
|
+
* the native snapshot. This proof grants a read of those exact bytes only.
|
|
254
262
|
*/
|
|
255
263
|
export async function findManagedCheckpoint(box, provider, id, expected, signal) {
|
|
256
264
|
const unknown = (reason) => ({ state: "unknown", reason });
|
|
@@ -273,7 +281,10 @@ export async function findManagedCheckpoint(box, provider, id, expected, signal)
|
|
|
273
281
|
return expected ? absent : unknown("not marked by this source");
|
|
274
282
|
}
|
|
275
283
|
if (expected &&
|
|
276
|
-
(
|
|
284
|
+
(expected.checkpointId !== id || expected.provider !== provider ||
|
|
285
|
+
marker.requestDigest !== expected.requestDigest ||
|
|
286
|
+
canonicalCandidateDigest(marker.request.metadata ?? null) !==
|
|
287
|
+
canonicalCandidateDigest(expected.metadata ?? null) ||
|
|
277
288
|
canonicalCandidateDigest(marker.request.source) !==
|
|
278
289
|
canonicalCandidateDigest(expected.source))) {
|
|
279
290
|
return absent;
|
|
@@ -286,9 +297,19 @@ export async function findManagedCheckpoint(box, provider, id, expected, signal)
|
|
|
286
297
|
signal?.throwIfAborted();
|
|
287
298
|
return unknown("operation not confirmed");
|
|
288
299
|
}
|
|
300
|
+
if (expected && lookup?.kind === "checkpoint" && lookup.outcome === "not_found") {
|
|
301
|
+
const seals = snapshot.tags.filter((tag) => tag.startsWith("seal."));
|
|
302
|
+
if (snapshot.snapshotId !== id || !/^[a-f0-9]{64}$/u.test(id) || seals.length !== 1 || seals[0] !== `seal.${id}`) {
|
|
303
|
+
return unknown("operation not confirmed");
|
|
304
|
+
}
|
|
305
|
+
const byKey = await checkpointOperationLookupByKey(box, marker.idempotencyKey, signal);
|
|
306
|
+
return byKey?.kind === "checkpoint" && byKey.outcome === "not_found"
|
|
307
|
+
? { state: "found", snapshotId: id }
|
|
308
|
+
: unknown("operation not confirmed");
|
|
309
|
+
}
|
|
289
310
|
if (lookup?.outcome !== "found" || lookup.kind !== "checkpoint" || lookup.state !== "succeeded")
|
|
290
311
|
return unknown("operation not confirmed");
|
|
291
|
-
return
|
|
312
|
+
return snapshotFromOperationResult(snapshot, lookup, marker)?.snapshotId === id
|
|
292
313
|
? { state: "found", snapshotId: snapshot.snapshotId }
|
|
293
314
|
: unknown("operation not confirmed");
|
|
294
315
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-provider-tangle",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.20",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"LICENSE"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tangle-network/agent-interface": "^5.10.
|
|
36
|
+
"@tangle-network/agent-interface": "^5.10.29"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@tangle-network/sandbox": ">=1.0.393 <2.0.0"
|