@tangle-network/agent-provider-tangle 5.0.19 → 5.0.21

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.
@@ -225,6 +225,12 @@ export interface SandboxSnapshotInfoLike {
225
225
  export interface SandboxSnapshotDeleteAcknowledgementLike {
226
226
  snapshotId: string;
227
227
  outcome: "deleted" | "already_absent" | "unknown";
228
+ /** What the 2xx body itself said; `outcome` folds a missing field and an explicit `unknown`. */
229
+ response?: {
230
+ attestation?: {
231
+ outcome?: "deleted" | "already_absent" | "unknown" | "missing" | "unrecognized";
232
+ };
233
+ };
228
234
  }
229
235
  /** Result returned by the SDK's durable operation lookup route. */
230
236
  export interface SandboxWorkspaceOperationLookupLike {
@@ -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;
@@ -265,11 +265,7 @@ export function createTangleWorkspaceBranching(options) {
265
265
  operation?.signal?.throwIfAborted();
266
266
  return cleanupTransportFailure(request, `Sandbox checkpoint deletion failed: ${safeError(error)}`, true);
267
267
  }
268
- const outcome = result &&
269
- result.snapshotId === known.snapshotId &&
270
- (result.outcome === "deleted" || result.outcome === "already_absent")
271
- ? result.outcome
272
- : "unknown";
268
+ const outcome = snapshotDeleteOutcome(result, known.snapshotId);
273
269
  if (outcome !== "deleted" && outcome !== "already_absent") {
274
270
  return cleanupUnknown(request, "Sandbox delete answered unknown (deletion not attested)", true);
275
271
  }
@@ -316,7 +312,7 @@ export function createTangleWorkspaceBranching(options) {
316
312
  const checkpoint = [...checkpoints.values()].some((record) => canonicalCandidateDigest(record.checkpoint) ===
317
313
  canonicalCandidateDigest(request.checkpoint))
318
314
  ? undefined
319
- : await findManagedCheckpoint(box, provider, request.checkpoint.checkpointId, request.checkpoint, operation?.signal);
315
+ : await inspectCheckpointResource(box, provider, request.checkpoint, operation?.signal);
320
316
  if (checkpoint !== undefined && checkpoint.state !== "found") {
321
317
  return forkUnknown(request, checkpoint.state === "absent"
322
318
  ? "Requested checkpoint is absent"
@@ -499,6 +495,7 @@ export function createTangleWorkspaceBranching(options) {
499
495
  return {
500
496
  checkpoint,
501
497
  lookupCheckpoint,
498
+ inspectCheckpoint: async (reference, operation) => (await inspectCheckpointResource(box, provider, reference, operation?.signal)).state,
502
499
  deleteCheckpoint,
503
500
  fork,
504
501
  lookupFork,
@@ -859,6 +856,22 @@ function forkLookupUnknown(request, message, retryable) {
859
856
  retryable,
860
857
  });
861
858
  }
859
+ /**
860
+ * What a Sandbox snapshot delete of a snapshot this handle just listed did. Sandbox answers 200 for
861
+ * "deleted, or already absent" and says which only when its controller can attest it; an explicit
862
+ * `unknown` declines to say which and never means the snapshot remains, since the controller
863
+ * tombstones it and refuses every later restore. The listing is the witness the controller lacked,
864
+ * so the delete removed it. Read as `unknown` on real-work-benchmark-20261129b, such a delete left
865
+ * Runtime naming the removed checkpoint as its restore point, and a reopen's create from it was
866
+ * refused "Snapshot not found". A body that names no outcome stays unknown.
867
+ */
868
+ function snapshotDeleteOutcome(result, snapshotId) {
869
+ if (!result || result.snapshotId !== snapshotId)
870
+ return "unknown";
871
+ if (result.outcome === "deleted" || result.outcome === "already_absent")
872
+ return result.outcome;
873
+ return result.response?.attestation?.outcome === "unknown" ? "deleted" : "unknown";
874
+ }
862
875
  function cleanupDeleted(request) {
863
876
  return WorkspaceCleanupAcknowledgementSchema.parse({
864
877
  ...request,
@@ -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
- (marker.requestDigest !== expected.requestDigest ||
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 snapshot.snapshotId === id || snapshotFromOperationResult(snapshot, lookup, marker)?.snapshotId === id
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.19",
3
+ "version": "5.0.21",
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.28"
36
+ "@tangle-network/agent-interface": "^5.10.29"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@tangle-network/sandbox": ">=1.0.393 <2.0.0"