@tangle-network/agent-provider-tangle 5.0.14 → 5.0.15
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.
|
@@ -6,7 +6,8 @@ export function tangleProfileValidator(supplied, resolver) {
|
|
|
6
6
|
if (result && !result.ok)
|
|
7
7
|
return result;
|
|
8
8
|
const candidate = result?.normalizedProfile ?? profile;
|
|
9
|
-
|
|
9
|
+
// Without a harness the SDK still runs create's inline-mount and size checks; it skips only materialization.
|
|
10
|
+
const verdict = typeof candidate !== "string" ? validateProfileForCreate(candidate, candidate.harness) : undefined;
|
|
10
11
|
const issues = verdict && !verdict.ok ? [{ level: "error", code: verdict.error.code, message: verdict.error.message }] : [];
|
|
11
12
|
if (issues.length)
|
|
12
13
|
return { ok: false, issues };
|
|
@@ -80,12 +80,6 @@ async function checkpointOperationLookupByKey(box, idempotencyKey, signal) {
|
|
|
80
80
|
signal?.throwIfAborted();
|
|
81
81
|
return await awaitWithSignal(box.getSnapshotOperation?.(idempotencyKey), signal);
|
|
82
82
|
}
|
|
83
|
-
async function checkpointOperationSucceeded(box, marker, signal) {
|
|
84
|
-
const lookup = await checkpointOperationLookup(box, marker, signal);
|
|
85
|
-
return (lookup?.outcome === "found" &&
|
|
86
|
-
lookup.kind === "checkpoint" &&
|
|
87
|
-
lookup.state === "succeeded");
|
|
88
|
-
}
|
|
89
83
|
/** Confirm a fork child through its marker or the legacy fork ledger. */
|
|
90
84
|
async function forkOperationLookup(box, marker, signal) {
|
|
91
85
|
if (marker.materialization === "snapshot") {
|
|
@@ -143,8 +137,8 @@ async function findCheckpointByKey(box, provider, key, signal) {
|
|
|
143
137
|
if (lookup?.outcome === "found" &&
|
|
144
138
|
lookup.kind === "checkpoint" &&
|
|
145
139
|
lookup.state === "succeeded") {
|
|
146
|
-
const authoritative = snapshotFromOperationResult(snapshot, lookup);
|
|
147
|
-
if (authoritative === undefined)
|
|
140
|
+
const authoritative = snapshotFromOperationResult(snapshot, lookup, marker);
|
|
141
|
+
if (authoritative === undefined || snapshots.filter((candidate) => snapshotHasId(candidate, authoritative.snapshotId) !== false).length !== 1)
|
|
148
142
|
return undefined;
|
|
149
143
|
if (found !== undefined)
|
|
150
144
|
return undefined;
|
|
@@ -186,17 +180,18 @@ async function findCheckpointByKey(box, provider, key, signal) {
|
|
|
186
180
|
return { state: "retired" };
|
|
187
181
|
if (!validTaggedSnapshotOperationResult(lookup.result))
|
|
188
182
|
return undefined;
|
|
189
|
-
const
|
|
183
|
+
const result = lookup.result;
|
|
184
|
+
const live = snapshots.filter((snapshot) => snapshotHasId(snapshot, result.snapshotId) !== false);
|
|
190
185
|
if (live.length === 0)
|
|
191
186
|
return { state: "retired" };
|
|
192
|
-
if (live.length !== 1)
|
|
187
|
+
if (live.length !== 1 || snapshotHasId(live[0], lookup.result.snapshotId) !== true)
|
|
193
188
|
return undefined;
|
|
194
189
|
const marker = checkpointMarkerFromTags(lookup.result.tags, key);
|
|
195
190
|
if (!marker ||
|
|
196
191
|
!checkpointMarkerBelongsToSource(marker, provider, box.id)) {
|
|
197
192
|
return undefined;
|
|
198
193
|
}
|
|
199
|
-
const authoritative = snapshotFromOperationResult(live[0], lookup);
|
|
194
|
+
const authoritative = snapshotFromOperationResult(live[0], lookup, marker);
|
|
200
195
|
return authoritative === undefined
|
|
201
196
|
? undefined
|
|
202
197
|
: { state: "found", snapshot: authoritative, marker };
|
|
@@ -222,22 +217,29 @@ export async function reconcileCheckpoint(box, provider, request, signal) {
|
|
|
222
217
|
? { state: "undecided", reason: "metadata_invalid" }
|
|
223
218
|
: { state: "found", record };
|
|
224
219
|
}
|
|
225
|
-
/**
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
220
|
+
/** Sandbox lists a sealed capture by its physical id, retaining the acknowledged id in its native seal tag. */
|
|
221
|
+
function snapshotHasId(snapshot, id) {
|
|
222
|
+
if (snapshot.snapshotId === id)
|
|
223
|
+
return true;
|
|
224
|
+
const seals = snapshot.tags.filter((tag) => tag.startsWith("seal."));
|
|
225
|
+
if (!seals.includes(`seal.${id}`))
|
|
226
|
+
return false;
|
|
227
|
+
return seals.length === 1 ? true : "unknown";
|
|
228
|
+
}
|
|
229
|
+
/** Recover the exact acknowledged id/time, with a marked live inventory witness. */
|
|
230
|
+
function snapshotFromOperationResult(snapshot, lookup, marker) {
|
|
234
231
|
if (lookup.result === undefined)
|
|
235
232
|
return snapshot;
|
|
236
|
-
if (!validSnapshotOperationResult(lookup.result) ||
|
|
237
|
-
lookup.result.snapshotId !== snapshot.snapshotId) {
|
|
233
|
+
if (!validSnapshotOperationResult(lookup.result) || snapshotHasId(snapshot, lookup.result.snapshotId) !== true)
|
|
238
234
|
return undefined;
|
|
235
|
+
if (lookup.result.snapshotId !== snapshot.snapshotId) {
|
|
236
|
+
if (!validTaggedSnapshotOperationResult(lookup.result))
|
|
237
|
+
return undefined;
|
|
238
|
+
const operationMarker = checkpointMarkerFromTags(lookup.result.tags, marker.idempotencyKey);
|
|
239
|
+
if (!operationMarker || canonicalCandidateDigest(operationMarker.request) !== canonicalCandidateDigest(marker.request))
|
|
240
|
+
return undefined;
|
|
239
241
|
}
|
|
240
|
-
return { ...snapshot, createdAt: lookup.result.createdAt };
|
|
242
|
+
return { ...snapshot, snapshotId: lookup.result.snapshotId, createdAt: lookup.result.createdAt };
|
|
241
243
|
}
|
|
242
244
|
/**
|
|
243
245
|
* Confirm that one snapshot id is a settled checkpoint this provider created.
|
|
@@ -252,10 +254,16 @@ export async function findManagedCheckpoint(box, provider, id, expected, signal)
|
|
|
252
254
|
if (!Array.isArray(snapshots) || snapshots.length > MAX_LIST_RESULTS) {
|
|
253
255
|
return "unknown";
|
|
254
256
|
}
|
|
255
|
-
const
|
|
256
|
-
if (
|
|
257
|
+
const candidates = snapshots.filter((candidate) => snapshotHasId(candidate, id) !== false);
|
|
258
|
+
if (candidates.length === 0)
|
|
257
259
|
return false;
|
|
258
|
-
if (
|
|
260
|
+
if (candidates.length !== 1)
|
|
261
|
+
return "unknown";
|
|
262
|
+
const snapshot = candidates[0];
|
|
263
|
+
if (!validSnapshotInfo(snapshot, box.id) || snapshotHasId(snapshot, id) !== true)
|
|
264
|
+
return "unknown";
|
|
265
|
+
// An expected reference can prove a fork source; an alias alone never authorizes cleanup.
|
|
266
|
+
if (snapshot.snapshotId !== id && expected === undefined)
|
|
259
267
|
return "unknown";
|
|
260
268
|
const marker = checkpointMarkerFromTags(snapshot.tags, expected?.idempotencyKey);
|
|
261
269
|
if (!marker)
|
|
@@ -270,9 +278,10 @@ export async function findManagedCheckpoint(box, provider, id, expected, signal)
|
|
|
270
278
|
canonicalCandidateDigest(expected.source))) {
|
|
271
279
|
return false;
|
|
272
280
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
281
|
+
const lookup = await checkpointOperationLookup(box, marker, signal);
|
|
282
|
+
if (lookup?.outcome !== "found" || lookup.kind !== "checkpoint" || lookup.state !== "succeeded")
|
|
283
|
+
return "unknown";
|
|
284
|
+
return snapshot.snapshotId === id || snapshotFromOperationResult(snapshot, lookup, marker)?.snapshotId === id ? true : "unknown";
|
|
276
285
|
}
|
|
277
286
|
catch {
|
|
278
287
|
signal?.throwIfAborted();
|
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.15",
|
|
4
4
|
"description": "AgentEnvironmentProvider adapter for Tangle sandboxes",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tangle-network/agent-provider-testkit": "0.12.
|
|
47
|
+
"@tangle-network/agent-provider-testkit": "0.12.5",
|
|
48
48
|
"@tangle-network/agent-runtime": "0.349.0",
|
|
49
49
|
"@tangle-network/sandbox": "^1.0.242",
|
|
50
50
|
"@types/node": "26.6.5",
|