@tangle-network/agent-provider-tangle 3.1.0 → 3.1.1
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/README.md +10 -0
- package/dist/tangle-evidence.d.ts +7 -1
- package/dist/tangle-evidence.js +32 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -593,3 +593,13 @@ The caller's attempt projection includes only its known execution IDs.
|
|
|
593
593
|
The capture records the running sidecar image digest and the served Sidecar bundle revision.
|
|
594
594
|
The image digest can be compared with the pre-create proof only when that proof identifies the actual placement image.
|
|
595
595
|
An incomplete inventory, missing stream, unrelated backend, or mismatched digest does not produce complete evidence.
|
|
596
|
+
|
|
597
|
+
## Exact retained workspace capture
|
|
598
|
+
|
|
599
|
+
Pass the admitted `controlRef` to `captureTangleEnvironmentEvidence`.
|
|
600
|
+
Keep `executionId` as the Runtime artifact identity.
|
|
601
|
+
The control reference supplies the exact native environment, session, and execution identifiers.
|
|
602
|
+
Capture validates those coordinates before reading files.
|
|
603
|
+
A reconstructed environment does not need the original in-memory session cache.
|
|
604
|
+
The returned provenance retains both identities and reports incomplete native coverage explicitly.
|
|
605
|
+
Missing native session evidence preserves the source under Runtime's complete-provenance policy.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentExactRunControlRef, type AgentProfile } from "@tangle-network/agent-interface";
|
|
2
2
|
import type { AgentEnvironment } from "@tangle-network/agent-interface/environment-provider";
|
|
3
3
|
import type { NativeCaptureProofLike, SandboxInstanceLike, TangleEvidenceAttemptLike, TangleEvidenceSourceLike } from "./tangle-types.js";
|
|
4
4
|
interface WorkspaceEntryMetadata {
|
|
@@ -14,7 +14,10 @@ interface WorkspaceEntryMetadata {
|
|
|
14
14
|
symlinkTarget: null;
|
|
15
15
|
}
|
|
16
16
|
export interface TangleEnvironmentEvidenceOptions {
|
|
17
|
+
/** Runtime artifact identity when controlRef is supplied; otherwise the native execution id. */
|
|
17
18
|
executionId: string;
|
|
19
|
+
/** Durable admitted coordinates, including when a reconstructed environment has no session cache. */
|
|
20
|
+
controlRef?: AgentExactRunControlRef;
|
|
18
21
|
harness: NonNullable<AgentProfile["harness"]>;
|
|
19
22
|
/** Optional local image ID to compare with the running sidecar image. */
|
|
20
23
|
expectedSidecarImageDigest?: string;
|
|
@@ -26,6 +29,8 @@ export interface TangleEnvironmentEvidenceOptions {
|
|
|
26
29
|
signal?: AbortSignal;
|
|
27
30
|
}
|
|
28
31
|
export interface TangleSandboxEvidenceOptions extends Omit<TangleEnvironmentEvidenceOptions, "sandboxSessionId"> {
|
|
32
|
+
/** Runtime artifact identity; native executionId remains subject to path-safe validation. */
|
|
33
|
+
runtimeExecutionId?: string;
|
|
29
34
|
sandboxSessionIds: readonly string[];
|
|
30
35
|
/** Every observed execution on each retained Sandbox session. */
|
|
31
36
|
sessionExecutionIds?: Readonly<Record<string, readonly string[]>>;
|
|
@@ -42,6 +47,7 @@ export interface TangleEnvironmentEvidence {
|
|
|
42
47
|
provider: string;
|
|
43
48
|
environmentId: string;
|
|
44
49
|
executionId: string;
|
|
50
|
+
controlRef?: AgentExactRunControlRef;
|
|
45
51
|
captureProof?: NativeCaptureProofLike;
|
|
46
52
|
workspaceScope: "environment";
|
|
47
53
|
workspaceRoot: string;
|
package/dist/tangle-evidence.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
+
import { AgentExactRunControlRefSchema } from "@tangle-network/agent-interface";
|
|
2
3
|
import { requireNativeCaptureProof } from "./tangle-native-capture-proof.js";
|
|
3
4
|
const handles = new WeakMap();
|
|
4
5
|
const blockedNames = new Set([".ssh", ".config", ".claude", ".codex", ".opencode", ".env", ".env.local", ".npmrc", ".sidecar"]);
|
|
@@ -20,19 +21,31 @@ export async function captureTangleEnvironmentEvidence(environment, options) {
|
|
|
20
21
|
const state = handles.get(environment);
|
|
21
22
|
if (!state || state.box.id !== environment.id)
|
|
22
23
|
throw new Error("Tangle evidence requires a live provider environment handle");
|
|
23
|
-
const
|
|
24
|
-
|
|
24
|
+
const controlRef = options.controlRef === undefined ? undefined : AgentExactRunControlRefSchema.parse(options.controlRef);
|
|
25
|
+
if (controlRef && (controlRef.environmentId !== environment.id || controlRef.provider !== environment.provider ||
|
|
26
|
+
(options.sandboxSessionId != null && options.sandboxSessionId !== controlRef.sessionId))) {
|
|
27
|
+
throw new Error("Tangle evidence control reference names another environment or session");
|
|
28
|
+
}
|
|
29
|
+
const executionId = controlRef?.executionId ?? options.executionId;
|
|
30
|
+
const sessionIds = controlRef ? new Set([controlRef.sessionId]) : new Set([...state.sessions.entries()]
|
|
31
|
+
.filter(([, executions]) => executions.has(executionId))
|
|
25
32
|
.map(([id]) => id));
|
|
26
33
|
if (options.sandboxSessionId != null)
|
|
27
34
|
sessionIds.add(options.sandboxSessionId);
|
|
35
|
+
const sessionExecutionIds = Object.fromEntries([...sessionIds].filter((id) => state.sessions.has(id))
|
|
36
|
+
.map((id) => [id, [...state.sessions.get(id)]]));
|
|
37
|
+
if (controlRef)
|
|
38
|
+
sessionExecutionIds[controlRef.sessionId] = [...new Set([
|
|
39
|
+
...(sessionExecutionIds[controlRef.sessionId] ?? []), controlRef.executionId,
|
|
40
|
+
])];
|
|
28
41
|
return captureTangleSandboxEvidence(state.box, {
|
|
29
|
-
executionId
|
|
42
|
+
executionId,
|
|
43
|
+
...(controlRef === undefined ? {} : { runtimeExecutionId: options.executionId, controlRef }),
|
|
30
44
|
harness: options.harness,
|
|
31
45
|
expectedSidecarImageDigest: options.expectedSidecarImageDigest,
|
|
32
46
|
requireNativeSessionCapture: options.requireNativeSessionCapture,
|
|
33
47
|
sandboxSessionIds: [...sessionIds],
|
|
34
|
-
sessionExecutionIds
|
|
35
|
-
.map((id) => [id, [...state.sessions.get(id)]])),
|
|
48
|
+
sessionExecutionIds,
|
|
36
49
|
maxBytes: options.maxBytes,
|
|
37
50
|
signal: options.signal,
|
|
38
51
|
});
|
|
@@ -41,6 +54,16 @@ export async function captureTangleEnvironmentEvidence(environment, options) {
|
|
|
41
54
|
export async function captureTangleSandboxEvidence(box, options) {
|
|
42
55
|
if (!safeIdentifier(box.id) || !safeIdentifier(options.executionId))
|
|
43
56
|
throw new Error("Tangle evidence requires exact box and execution ids");
|
|
57
|
+
const controlRef = options.controlRef === undefined ? undefined : AgentExactRunControlRefSchema.parse(options.controlRef);
|
|
58
|
+
if (controlRef && (controlRef.environmentId !== box.id ||
|
|
59
|
+
controlRef.executionId !== options.executionId || !options.sandboxSessionIds?.includes(controlRef.sessionId))) {
|
|
60
|
+
throw new Error("Tangle evidence control reference does not bind the exact native capture");
|
|
61
|
+
}
|
|
62
|
+
if (options.runtimeExecutionId !== undefined && (!controlRef || typeof options.runtimeExecutionId !== "string" ||
|
|
63
|
+
!options.runtimeExecutionId.length || options.runtimeExecutionId.length > 2048 || /[\u0000-\u001f\u007f]/.test(options.runtimeExecutionId))) {
|
|
64
|
+
throw new Error("Tangle evidence Runtime artifact identity requires an exact admitted control reference");
|
|
65
|
+
}
|
|
66
|
+
const artifactExecutionId = options.runtimeExecutionId ?? options.executionId;
|
|
44
67
|
if (!safeIdentifier(options.harness))
|
|
45
68
|
throw new Error("Tangle evidence requires an exact profile harness");
|
|
46
69
|
if (options.expectedSidecarImageDigest !== undefined &&
|
|
@@ -603,7 +626,7 @@ export async function captureTangleSandboxEvidence(box, options) {
|
|
|
603
626
|
capturedBytes += manifest.byteLength;
|
|
604
627
|
}
|
|
605
628
|
sessions.push({
|
|
606
|
-
id, executionId:
|
|
629
|
+
id, executionId: artifactExecutionId, executionIds: [...executionIds], eventCountsByExecutionId,
|
|
607
630
|
backendType: options.harness, sidecarImageDigest, sidecarBundleRevision,
|
|
608
631
|
transportEvents: executionIds.every((executionId) => eventCountsByExecutionId[executionId] > 0) ? "complete" : "unavailable",
|
|
609
632
|
eventCount: events.length, messageCount: messages.length, messageScope: "session",
|
|
@@ -620,9 +643,10 @@ export async function captureTangleSandboxEvidence(box, options) {
|
|
|
620
643
|
}
|
|
621
644
|
}
|
|
622
645
|
const provenance = {
|
|
623
|
-
provider: "tangle-sandbox",
|
|
646
|
+
provider: controlRef?.provider ?? "tangle-sandbox",
|
|
624
647
|
environmentId: box.id,
|
|
625
|
-
executionId:
|
|
648
|
+
executionId: artifactExecutionId,
|
|
649
|
+
...(controlRef === undefined ? {} : { controlRef }),
|
|
626
650
|
...(captureProof ? { captureProof } : {}),
|
|
627
651
|
workspaceScope: "environment",
|
|
628
652
|
workspaceRoot,
|