Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/tangle-workspace-modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@tangle-network/agent-provider-tangle": patch
---

Separate workspace metadata encoding and durable recovery from operation handling.
Reuse the canonical attestation codec and shared identifier validation without changing the public provider contract.
4 changes: 4 additions & 0 deletions packages/agent-provider-tangle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
"dist/tangle-workspace-branching.js",
"dist/tangle-confidential-attestation.d.ts",
"dist/tangle-confidential-attestation.js",
"dist/tangle-workspace-markers.d.ts",
"dist/tangle-workspace-markers.js",
"dist/tangle-workspace-recovery.d.ts",
"dist/tangle-workspace-recovery.js",
"README.md",
"LICENSE"
],
Expand Down
38 changes: 29 additions & 9 deletions packages/agent-provider-tangle/src/tangle-contract-safety.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@ const IMMUTABLE_TANGLE_IMAGE =
/^(?:sha256:[a-f0-9]{64}|\S+@sha256:[a-f0-9]{64})$/i;

export function boundedIdentifier(value: unknown, label: string): string {
if (
typeof value !== "string" ||
value.length === 0 ||
value.length > MAX_IDENTIFIER_LENGTH ||
value.trim() !== value
) {
throw new Error(`${label} is invalid`);
}
return value;
const identifier = safeIdentifier(value);
if (identifier === undefined) throw new Error(`${label} is invalid`);
return identifier;
}

export function boundedString(value: unknown, label: string): string {
Expand Down Expand Up @@ -288,3 +282,29 @@ export async function awaitWithSignalAndCleanup<T>(
if (listener) signal.removeEventListener("abort", listener);
}
}

export function cloneJson<T>(value: T): T {
assertBoundedJson(value);
return structuredClone(value);
}

export function safeIdentifier(value: unknown): string | undefined {
if (
typeof value !== "string" ||
value.length === 0 ||
value.length > MAX_IDENTIFIER_LENGTH ||
value.trim() !== value
)
return undefined;
return value;
}

export function safeString(value: unknown): string | undefined {
if (
typeof value !== "string" ||
value.length === 0 ||
value.length > MAX_STRING_LENGTH
)
return undefined;
return value;
}
Loading