@opengeni/sdk 0.57.0 → 1.0.0
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 +1017 -26
- package/dist/accounts.d.ts +153 -0
- package/dist/accounts.js +307 -0
- package/dist/accounts.js.map +1 -0
- package/dist/adapters/express.d.ts +31 -0
- package/dist/adapters/express.js +87 -0
- package/dist/adapters/express.js.map +1 -0
- package/dist/adapters/hono.d.ts +16 -0
- package/dist/adapters/hono.js +8 -0
- package/dist/adapters/hono.js.map +1 -0
- package/dist/adapters/next.d.ts +29 -0
- package/dist/adapters/next.js +22 -0
- package/dist/adapters/next.js.map +1 -0
- package/dist/allowance-refusal.d.ts +2 -0
- package/dist/allowance-refusal.js +50 -0
- package/dist/allowance-refusal.js.map +1 -0
- package/dist/artifact-catalog.d.ts +31 -0
- package/dist/artifact-client.d.ts +23 -11
- package/dist/artifacts.d.ts +1 -1
- package/dist/artifacts.js +7 -5
- package/dist/automations-client.d.ts +17 -0
- package/dist/automations.d.ts +3 -0
- package/dist/automations.js +84 -0
- package/dist/automations.js.map +1 -0
- package/dist/browser.d.ts +11 -0
- package/dist/browser.js +47 -0
- package/dist/browser.js.map +1 -0
- package/dist/chat/fold.d.ts +75 -0
- package/dist/chat/handler.d.ts +41 -0
- package/dist/chat/http.d.ts +67 -0
- package/dist/chat/ids.d.ts +34 -0
- package/dist/chat/index.d.ts +9 -0
- package/dist/chat/index.js +1694 -0
- package/dist/chat/index.js.map +1 -0
- package/dist/chat/openai.d.ts +30 -0
- package/dist/chat/opengeni.d.ts +128 -0
- package/dist/chat/types.d.ts +207 -0
- package/dist/chat/vercel.d.ts +49 -0
- package/dist/chats.d.ts +8 -0
- package/dist/{chunk-JDLDDRNE.js → chunk-2UXZUCEZ.js} +291 -34
- package/dist/chunk-2UXZUCEZ.js.map +1 -0
- package/dist/chunk-4SMEOV3P.js +246 -0
- package/dist/chunk-4SMEOV3P.js.map +1 -0
- package/dist/{chunk-JRPFWI6T.js → chunk-AH5D5Q5V.js} +31 -35
- package/dist/chunk-AH5D5Q5V.js.map +1 -0
- package/dist/chunk-APXVSSSY.js +301 -0
- package/dist/chunk-APXVSSSY.js.map +1 -0
- package/dist/chunk-DUVIYER4.js +639 -0
- package/dist/chunk-DUVIYER4.js.map +1 -0
- package/dist/{chunk-PKQ377ED.js → chunk-FG3OO5LM.js} +2686 -611
- package/dist/chunk-FG3OO5LM.js.map +1 -0
- package/dist/chunk-GZYZT22T.js +260 -0
- package/dist/chunk-GZYZT22T.js.map +1 -0
- package/dist/chunk-HMGADJGZ.js +150 -0
- package/dist/chunk-HMGADJGZ.js.map +1 -0
- package/dist/{chunk-YKZME56C.js → chunk-KWADQ227.js} +3 -3
- package/dist/{chunk-YKZME56C.js.map → chunk-KWADQ227.js.map} +1 -1
- package/dist/chunk-LY2K6ELJ.js +126 -0
- package/dist/chunk-LY2K6ELJ.js.map +1 -0
- package/dist/chunk-MOTJYIYL.js +340 -0
- package/dist/chunk-MOTJYIYL.js.map +1 -0
- package/dist/{chunk-ST5DDKJP.js → chunk-NC57YMUO.js} +121 -3
- package/dist/chunk-NC57YMUO.js.map +1 -0
- package/dist/chunk-RWKB6YZG.js +1270 -0
- package/dist/chunk-RWKB6YZG.js.map +1 -0
- package/dist/chunk-U6CV2SXO.js +195 -0
- package/dist/chunk-U6CV2SXO.js.map +1 -0
- package/dist/chunk-UM4ZXXJR.js +9 -0
- package/dist/chunk-UM4ZXXJR.js.map +1 -0
- package/dist/chunk-V6GIY62B.js +229 -0
- package/dist/chunk-V6GIY62B.js.map +1 -0
- package/dist/chunk-WU6GQG25.js +268 -0
- package/dist/chunk-WU6GQG25.js.map +1 -0
- package/dist/{chunk-VWE2QIVO.js → chunk-XNG7YGR3.js} +23 -6
- package/dist/chunk-XNG7YGR3.js.map +1 -0
- package/dist/{chunk-HJ3HHUT5.js → chunk-YIKA2QT4.js} +33 -2
- package/dist/chunk-YIKA2QT4.js.map +1 -0
- package/dist/chunk-ZKPY6YAJ.js +135 -0
- package/dist/chunk-ZKPY6YAJ.js.map +1 -0
- package/dist/client.d.ts +740 -94
- package/dist/codex-realtime-controller.d.ts +3 -0
- package/dist/codex-realtime-controller.js +2 -2
- package/dist/codex-realtime-v3.d.ts +13 -2
- package/dist/company-brain.d.ts +22 -0
- package/dist/company-profile.d.ts +14 -1
- package/dist/core.d.ts +9 -3
- package/dist/core.js +25 -6
- package/dist/deprecation.d.ts +47 -0
- package/dist/document-authority-client.d.ts +51 -0
- package/dist/document-authority.d.ts +2 -0
- package/dist/document-authority.js +12 -0
- package/dist/document-authority.js.map +1 -0
- package/dist/editable-artifacts/browser-session.d.ts +7 -3
- package/dist/editable-artifacts/controller.d.ts +4 -1
- package/dist/editable-artifacts/errors.d.ts +1 -1
- package/dist/editable-artifacts/http-live-transport.d.ts +6 -2
- package/dist/editable-artifacts/index.d.ts +2 -0
- package/dist/editable-artifacts/open-failure.d.ts +9 -0
- package/dist/editable-artifacts/types.d.ts +6 -3
- package/dist/editable-artifacts/worker/kernel-adapter.d.ts +1 -1
- package/dist/editable-artifacts-worker.js +44 -17
- package/dist/editable-artifacts-worker.js.map +1 -1
- package/dist/editable-artifacts.js +240 -121
- package/dist/editable-artifacts.js.map +1 -1
- package/dist/embedding-client.d.ts +129 -0
- package/dist/errors.d.ts +36 -1
- package/dist/feedback.d.ts +23 -0
- package/dist/gateway-realtime-transport.js +1 -1
- package/dist/github-repositories.d.ts +10 -0
- package/dist/github-repositories.js +36 -0
- package/dist/github-repositories.js.map +1 -0
- package/dist/index.d.ts +56 -11
- package/dist/index.js +242 -125
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +84 -1
- package/dist/interaction.js +6 -1
- package/dist/knowledge.d.ts +7 -0
- package/dist/knowledge.js +20 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/message-links.d.ts +68 -0
- package/dist/model-context.d.ts +68 -0
- package/dist/model-display.d.ts +2 -0
- package/dist/model-display.js +15 -0
- package/dist/model-display.js.map +1 -0
- package/dist/model-picker-order.d.ts +1 -0
- package/dist/model-picker-order.js +10 -0
- package/dist/model-picker-order.js.map +1 -0
- package/dist/organization-integration-policy.d.ts +26 -0
- package/dist/organization-integration-policy.js +26 -0
- package/dist/organization-integration-policy.js.map +1 -0
- package/dist/organization-private-session-settings.d.ts +6 -0
- package/dist/organization-private-session-settings.js +22 -0
- package/dist/organization-private-session-settings.js.map +1 -0
- package/dist/organization-user-setup.d.ts +8 -0
- package/dist/organization-user-setup.js +16 -0
- package/dist/organization-user-setup.js.map +1 -0
- package/dist/pr-review-client.d.ts +16 -0
- package/dist/pr-review.d.ts +4 -0
- package/dist/pr-review.js +62 -0
- package/dist/pr-review.js.map +1 -0
- package/dist/preference-registry.d.ts +9 -1
- package/dist/proxy.d.ts +7 -5
- package/dist/realtime.d.ts +3 -1
- package/dist/realtime.js +6 -6
- package/dist/realtime.js.map +1 -1
- package/dist/retained-artifacts.d.ts +5 -1
- package/dist/session-history-import.d.ts +22 -0
- package/dist/session-history-import.js +36 -0
- package/dist/session-history-import.js.map +1 -0
- package/dist/session-list-entries.d.ts +1 -0
- package/dist/session-list-entries.js +7 -0
- package/dist/session-list-entries.js.map +1 -0
- package/dist/session-message-search.d.ts +53 -0
- package/dist/session-proxy-client.d.ts +24 -0
- package/dist/session-proxy.d.ts +245 -0
- package/dist/session-proxy.js +24 -0
- package/dist/session-proxy.js.map +1 -0
- package/dist/session-titles.d.ts +2 -0
- package/dist/site-browser-entry.d.ts +1 -0
- package/dist/site-browser-runtime.gen.d.ts +1 -0
- package/dist/site-document.d.ts +5 -0
- package/dist/site-document.js +20 -0
- package/dist/site-document.js.map +1 -0
- package/dist/site-document.test.d.ts +1 -0
- package/dist/site-http.d.ts +16 -0
- package/dist/site-tool-bridge.d.ts +44 -0
- package/dist/site.d.ts +101 -0
- package/dist/site.js +49 -0
- package/dist/site.js.map +1 -0
- package/dist/skills.d.ts +75 -0
- package/dist/stream.d.ts +2 -0
- package/dist/tenant-workspaces.d.ts +47 -0
- package/dist/tenant-workspaces.js +8 -0
- package/dist/tenant-workspaces.js.map +1 -0
- package/dist/tool-auth.d.ts +87 -0
- package/dist/tool-auth.js +23 -0
- package/dist/tool-auth.js.map +1 -0
- package/dist/tool-display-metadata.d.ts +3 -0
- package/dist/tools-FXBLUWAE.js +12 -0
- package/dist/tools-FXBLUWAE.js.map +1 -0
- package/dist/tools.d.ts +61 -0
- package/dist/types.d.ts +2863 -424
- package/dist/usage-allowances.d.ts +36 -0
- package/dist/usage-allowances.js +80 -0
- package/dist/usage-allowances.js.map +1 -0
- package/dist/workspace-artifacts.d.ts +33 -5
- package/dist/workspace-instruction-policies.d.ts +24 -2
- package/dist/workspace-integrations.d.ts +74 -0
- package/dist/workspace-integrations.js +65 -0
- package/dist/workspace-integrations.js.map +1 -0
- package/dist/workspace-learning.d.ts +124 -0
- package/dist/workspace-state.d.ts +8 -71
- package/package.json +108 -3
- package/src/accounts.ts +443 -0
- package/src/adapters/express.ts +136 -0
- package/src/adapters/hono.ts +18 -0
- package/src/adapters/next.ts +42 -0
- package/src/allowance-refusal.ts +5 -0
- package/src/artifact-catalog.ts +41 -0
- package/src/artifact-client.ts +43 -52
- package/src/artifacts.ts +7 -1
- package/src/automations-client.ts +124 -0
- package/src/automations.ts +15 -0
- package/src/browser.ts +54 -0
- package/src/chat/fold.ts +431 -0
- package/src/chat/handler.ts +240 -0
- package/src/chat/http.ts +257 -0
- package/src/chat/ids.ts +85 -0
- package/src/chat/index.ts +87 -0
- package/src/chat/openai.ts +439 -0
- package/src/chat/opengeni.ts +722 -0
- package/src/chat/types.ts +219 -0
- package/src/chat/vercel.ts +204 -0
- package/src/chats.ts +16 -0
- package/src/client.ts +4084 -515
- package/src/codex-realtime-controller.ts +235 -5
- package/src/codex-realtime-v3.ts +162 -31
- package/src/codex-realtime.ts +1 -1
- package/src/company-brain.ts +59 -0
- package/src/company-profile.ts +17 -1
- package/src/core.ts +23 -1
- package/src/deprecation.ts +149 -0
- package/src/document-authority-client.ts +219 -0
- package/src/document-authority.ts +17 -0
- package/src/editable-artifacts/browser-session.ts +36 -22
- package/src/editable-artifacts/controller.ts +102 -47
- package/src/editable-artifacts/errors.ts +2 -0
- package/src/editable-artifacts/http-live-transport.ts +62 -37
- package/src/editable-artifacts/index.ts +6 -0
- package/src/editable-artifacts/open-failure.ts +79 -0
- package/src/editable-artifacts/storage.ts +31 -40
- package/src/editable-artifacts/types.ts +6 -3
- package/src/editable-artifacts/worker/kernel-adapter.ts +23 -7
- package/src/editable-artifacts/worker/runtime.ts +26 -13
- package/src/editable-artifacts/worker/wire-codec.ts +23 -5
- package/src/embedding-client.ts +519 -0
- package/src/errors.ts +169 -2
- package/src/feedback.ts +20 -0
- package/src/gateway-realtime-transport.ts +3 -3
- package/src/github-repositories.ts +60 -0
- package/src/index.ts +561 -41
- package/src/interaction.ts +276 -4
- package/src/knowledge.ts +72 -0
- package/src/message-links.ts +178 -0
- package/src/model-context.ts +112 -0
- package/src/model-display.ts +10 -0
- package/src/model-picker-order.ts +6 -0
- package/src/organization-integration-policy.ts +54 -0
- package/src/organization-private-session-settings.ts +33 -0
- package/src/organization-user-setup.ts +31 -0
- package/src/pr-review-client.ts +92 -0
- package/src/pr-review.ts +17 -0
- package/src/preference-registry.ts +11 -0
- package/src/proxy.ts +17 -6
- package/src/realtime.ts +1 -0
- package/src/retained-artifacts.ts +101 -0
- package/src/session-history-import.ts +84 -0
- package/src/session-list-entries.ts +1 -0
- package/src/session-message-search.ts +47 -0
- package/src/session-proxy-client.ts +64 -0
- package/src/session-proxy.ts +1473 -0
- package/src/session-titles.ts +10 -0
- package/src/site-browser-entry.ts +6 -0
- package/src/site-browser-runtime.gen.ts +2 -0
- package/src/site-document.test.ts +64 -0
- package/src/site-document.ts +18 -0
- package/src/site-http.ts +162 -0
- package/src/site-tool-bridge.ts +146 -0
- package/src/site.ts +585 -0
- package/src/skills.ts +69 -0
- package/src/sse.ts +8 -2
- package/src/stream.ts +38 -4
- package/src/tenant-workspaces.ts +148 -0
- package/src/tool-auth.ts +301 -0
- package/src/tool-display-metadata.ts +19 -0
- package/src/tools.ts +396 -0
- package/src/types.ts +3346 -501
- package/src/usage-allowances.ts +189 -0
- package/src/workspace-artifacts.ts +40 -6
- package/src/workspace-instruction-policies.ts +26 -1
- package/src/workspace-integrations.ts +402 -0
- package/src/workspace-learning.ts +138 -0
- package/src/workspace-state.ts +8 -82
- package/dist/chunk-GU6JF75T.js +0 -119
- package/dist/chunk-GU6JF75T.js.map +0 -1
- package/dist/chunk-HJ3HHUT5.js.map +0 -1
- package/dist/chunk-JDLDDRNE.js.map +0 -1
- package/dist/chunk-JRPFWI6T.js.map +0 -1
- package/dist/chunk-PKQ377ED.js.map +0 -1
- package/dist/chunk-ST5DDKJP.js.map +0 -1
- package/dist/chunk-VWE2QIVO.js.map +0 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type EditableArtifactOpenFailureCategory =
|
|
2
|
+
| "unsupported_old_format"
|
|
3
|
+
| "byte_corruption"
|
|
4
|
+
| "authored_causal_mismatch"
|
|
5
|
+
| "runtime_package_mismatch"
|
|
6
|
+
| "projection_parity_ci_failure";
|
|
7
|
+
|
|
8
|
+
/** Content-free, bounded telemetry safe to emit for workbook-open failures. */
|
|
9
|
+
export type EditableArtifactOpenFailureEvent = Readonly<{
|
|
10
|
+
category: EditableArtifactOpenFailureCategory;
|
|
11
|
+
code: string;
|
|
12
|
+
}>;
|
|
13
|
+
|
|
14
|
+
export type EditableArtifactOpenFailureReporter = (event: EditableArtifactOpenFailureEvent) => void;
|
|
15
|
+
|
|
16
|
+
const BYTE_CORRUPTION_CODES = new Set([
|
|
17
|
+
"byte_corruption",
|
|
18
|
+
"artifact_bad_magic",
|
|
19
|
+
"artifact_checksum_mismatch",
|
|
20
|
+
"artifact_invalid_collaboration_snapshot",
|
|
21
|
+
"artifact_invalid_snapshot",
|
|
22
|
+
"artifact_invalid_tag",
|
|
23
|
+
"artifact_invalid_utf8",
|
|
24
|
+
"artifact_non_canonical",
|
|
25
|
+
"artifact_trailing_bytes",
|
|
26
|
+
"artifact_truncated",
|
|
27
|
+
]);
|
|
28
|
+
const AUTHORED_CAUSAL_CODES = new Set([
|
|
29
|
+
"artifact_state_mismatch",
|
|
30
|
+
"authored_causal_mismatch",
|
|
31
|
+
"committed_metadata_mismatch",
|
|
32
|
+
"invalid_frontier",
|
|
33
|
+
"kernel_diverged",
|
|
34
|
+
]);
|
|
35
|
+
const RUNTIME_PACKAGE_CODES = new Set([
|
|
36
|
+
"artifact_runtime_incompatible",
|
|
37
|
+
"artifact_runtime_integrity",
|
|
38
|
+
"artifact_runtime_manifest_invalid",
|
|
39
|
+
"artifact_runtime_unavailable",
|
|
40
|
+
"artifact_runtime_unsupported_target",
|
|
41
|
+
"incompatible_wasm_build",
|
|
42
|
+
"runtime_identity_mismatch",
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
/** Maps only stable error codes; messages and workbook/formula content are ignored. */
|
|
46
|
+
export function classifyEditableArtifactOpenFailure(
|
|
47
|
+
error: unknown,
|
|
48
|
+
): EditableArtifactOpenFailureEvent | null {
|
|
49
|
+
const code = normalizedErrorCode(error);
|
|
50
|
+
if (code === null) return null;
|
|
51
|
+
let category: EditableArtifactOpenFailureCategory | null = null;
|
|
52
|
+
if (code === "unsupported_protocol" || code === "artifact_unsupported_version") {
|
|
53
|
+
category = "unsupported_old_format";
|
|
54
|
+
} else if (BYTE_CORRUPTION_CODES.has(code)) {
|
|
55
|
+
category = "byte_corruption";
|
|
56
|
+
} else if (AUTHORED_CAUSAL_CODES.has(code)) {
|
|
57
|
+
category = "authored_causal_mismatch";
|
|
58
|
+
} else if (RUNTIME_PACKAGE_CODES.has(code)) {
|
|
59
|
+
category = "runtime_package_mismatch";
|
|
60
|
+
} else if (code === "artifact_runtime_projection_parity") {
|
|
61
|
+
category = "projection_parity_ci_failure";
|
|
62
|
+
}
|
|
63
|
+
return category === null ? null : Object.freeze({ category, code });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function normalizedErrorCode(error: unknown): string | null {
|
|
67
|
+
if (typeof error !== "object" || error === null) return null;
|
|
68
|
+
let descriptor: PropertyDescriptor | undefined;
|
|
69
|
+
try {
|
|
70
|
+
descriptor = Object.getOwnPropertyDescriptor(error, "code");
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
if (!descriptor || !("value" in descriptor)) return null;
|
|
75
|
+
const value = descriptor.value;
|
|
76
|
+
if (typeof value !== "string") return null;
|
|
77
|
+
const code = value.toLowerCase();
|
|
78
|
+
return /^[a-z][a-z0-9_]{0,127}$/u.test(code) ? code : null;
|
|
79
|
+
}
|
|
@@ -135,7 +135,7 @@ export class MemoryEditableArtifactStorage implements EditableArtifactStoragePor
|
|
|
135
135
|
stateHash: replica.head.stateHash,
|
|
136
136
|
modality: replica.head.modality,
|
|
137
137
|
...(replica.head.snapshot.modality === "spreadsheet"
|
|
138
|
-
? {
|
|
138
|
+
? { operationProtocolVersion: replica.head.snapshot.operationProtocolVersion }
|
|
139
139
|
: {}),
|
|
140
140
|
},
|
|
141
141
|
input,
|
|
@@ -227,10 +227,9 @@ type MemoryStoredReplica = {
|
|
|
227
227
|
|
|
228
228
|
type IndexedDbStoredReplicaHead = Omit<StoredReplicaHead, "snapshot"> & {
|
|
229
229
|
namespace: string;
|
|
230
|
-
|
|
231
|
-
modality?: EditableArtifactModality;
|
|
230
|
+
modality: EditableArtifactModality;
|
|
232
231
|
/** Spreadsheet-only; absent for serialized modalities. */
|
|
233
|
-
|
|
232
|
+
operationProtocolVersion?: number;
|
|
234
233
|
tailCount: number;
|
|
235
234
|
tailBytes: number;
|
|
236
235
|
};
|
|
@@ -240,10 +239,10 @@ type IndexedDbCommittedTransaction = EditableArtifactCommittedTransaction & {
|
|
|
240
239
|
};
|
|
241
240
|
type IndexedDbPendingTransaction = EditableArtifactPendingTransaction & {
|
|
242
241
|
namespace: string;
|
|
243
|
-
/**
|
|
242
|
+
/** IndexedDB key-path alias; always exactly clientTransactionId. */
|
|
244
243
|
transactionId: string;
|
|
245
244
|
};
|
|
246
|
-
const DATABASE_VERSION =
|
|
245
|
+
const DATABASE_VERSION = 4;
|
|
247
246
|
const REPLICA_HEAD_STORE = "replicas";
|
|
248
247
|
const SNAPSHOT_STORE = "snapshots";
|
|
249
248
|
const COMMITTED_STORE = "committedTransactions";
|
|
@@ -352,7 +351,7 @@ export class IndexedDbEditableArtifactStorage implements EditableArtifactStorage
|
|
|
352
351
|
assertStoredHeadAccounting(head, tail.length, retainedTailBytes);
|
|
353
352
|
const {
|
|
354
353
|
namespace: _headNamespace,
|
|
355
|
-
|
|
354
|
+
operationProtocolVersion: retainedOperationProtocolVersion,
|
|
356
355
|
tailCount: _tailCount,
|
|
357
356
|
tailBytes: _tailBytes,
|
|
358
357
|
...storedHead
|
|
@@ -364,13 +363,12 @@ export class IndexedDbEditableArtifactStorage implements EditableArtifactStorage
|
|
|
364
363
|
normalizeStoredCommitted(value, ownedScope.modality),
|
|
365
364
|
)
|
|
366
365
|
.sort(compareCommittedTransactions);
|
|
367
|
-
|
|
368
|
-
if (headModality !== ownedScope.modality) {
|
|
366
|
+
if (head.modality !== ownedScope.modality) {
|
|
369
367
|
throw new TypeError("retained head modality does not match its storage scope");
|
|
370
368
|
}
|
|
371
369
|
if (
|
|
372
370
|
storedSnapshot.modality === "spreadsheet" &&
|
|
373
|
-
|
|
371
|
+
retainedOperationProtocolVersion !== storedSnapshot.operationProtocolVersion
|
|
374
372
|
)
|
|
375
373
|
throw new TypeError("retained head protocol does not match its snapshot");
|
|
376
374
|
const replica: EditableArtifactStoredReplica = {
|
|
@@ -643,7 +641,11 @@ function assertStoredReplica(replica: EditableArtifactStoredReplica): void {
|
|
|
643
641
|
assertSha256(replica.snapshot.digest, "snapshot.digest");
|
|
644
642
|
if (replica.snapshot.modality === "spreadsheet") {
|
|
645
643
|
assertFrontier(replica.snapshot.causalFrontier, "snapshot.causalFrontier");
|
|
646
|
-
assertPositiveInteger(
|
|
644
|
+
assertPositiveInteger(
|
|
645
|
+
replica.snapshot.operationProtocolVersion,
|
|
646
|
+
"snapshot.operationProtocolVersion",
|
|
647
|
+
);
|
|
648
|
+
assertPositiveInteger(replica.snapshot.snapshotVersion, "snapshot.snapshotVersion");
|
|
647
649
|
} else {
|
|
648
650
|
assertSequence(replica.snapshot.nativeRevision, "snapshot.nativeRevision");
|
|
649
651
|
}
|
|
@@ -676,7 +678,7 @@ function assertStoredReplica(replica: EditableArtifactStoredReplica): void {
|
|
|
676
678
|
if (
|
|
677
679
|
transaction.modality === "spreadsheet" &&
|
|
678
680
|
replica.snapshot.modality === "spreadsheet" &&
|
|
679
|
-
transaction.
|
|
681
|
+
transaction.operationProtocolVersion !== replica.snapshot.operationProtocolVersion
|
|
680
682
|
)
|
|
681
683
|
throw new TypeError("stored committed tail protocol does not match its snapshot");
|
|
682
684
|
if (transaction.modality !== "spreadsheet") {
|
|
@@ -805,11 +807,11 @@ function assertCommittedTransaction(
|
|
|
805
807
|
}
|
|
806
808
|
if (transaction.modality === "spreadsheet") {
|
|
807
809
|
assertFrontier(transaction.causalFrontier, "causalFrontier");
|
|
808
|
-
assertPositiveInteger(transaction.
|
|
810
|
+
assertPositiveInteger(transaction.operationProtocolVersion, "operationProtocolVersion");
|
|
809
811
|
const summary = decodeCommittedTransactionSummary(transaction.committedTransactionBytes);
|
|
810
812
|
if (
|
|
811
813
|
summary.transactionId !== transaction.transactionId ||
|
|
812
|
-
summary.operationProtocolVersion !== transaction.
|
|
814
|
+
summary.operationProtocolVersion !== transaction.operationProtocolVersion ||
|
|
813
815
|
summary.priorStateHash !== transaction.priorStateHash ||
|
|
814
816
|
summary.stateHash !== transaction.stateHash ||
|
|
815
817
|
!frontiersEqual(summary.resultingCausalFrontier, transaction.causalFrontier)
|
|
@@ -907,8 +909,8 @@ function assertPendingTransaction(transaction: EditableArtifactPendingTransactio
|
|
|
907
909
|
|
|
908
910
|
function assertAppendCanApply(
|
|
909
911
|
head: Pick<StoredReplicaHead, "cursor" | "stateHash"> & {
|
|
910
|
-
modality
|
|
911
|
-
|
|
912
|
+
modality: EditableArtifactModality;
|
|
913
|
+
operationProtocolVersion?: number;
|
|
912
914
|
},
|
|
913
915
|
input: EditableArtifactAppendCommittedInput,
|
|
914
916
|
): void {
|
|
@@ -917,15 +919,14 @@ function assertAppendCanApply(
|
|
|
917
919
|
`artifact ${input.artifactId} retained head no longer matches append expectation`,
|
|
918
920
|
);
|
|
919
921
|
}
|
|
920
|
-
|
|
921
|
-
if (input.transaction.modality !== headModality) {
|
|
922
|
+
if (input.transaction.modality !== head.modality) {
|
|
922
923
|
throw new EditableArtifactStorageConflictError(
|
|
923
924
|
`artifact ${input.artifactId} append modality does not match retained snapshot`,
|
|
924
925
|
);
|
|
925
926
|
}
|
|
926
927
|
if (
|
|
927
928
|
input.transaction.modality === "spreadsheet" &&
|
|
928
|
-
input.transaction.
|
|
929
|
+
input.transaction.operationProtocolVersion !== head.operationProtocolVersion
|
|
929
930
|
) {
|
|
930
931
|
throw new EditableArtifactStorageConflictError(
|
|
931
932
|
`artifact ${input.artifactId} append protocol does not match retained snapshot`,
|
|
@@ -936,7 +937,7 @@ function assertAppendCanApply(
|
|
|
936
937
|
function assertReplacementCanApply(
|
|
937
938
|
head:
|
|
938
939
|
| (Pick<StoredReplicaHead, "cursor" | "stateHash"> & {
|
|
939
|
-
|
|
940
|
+
operationProtocolVersion?: number;
|
|
940
941
|
})
|
|
941
942
|
| undefined,
|
|
942
943
|
expectedHead: EditableArtifactExpectedStoredHead,
|
|
@@ -1028,7 +1029,7 @@ function committedTransactionsEqual(
|
|
|
1028
1029
|
left.priorStateHash === right.priorStateHash &&
|
|
1029
1030
|
left.stateHash === right.stateHash &&
|
|
1030
1031
|
(left.modality === "spreadsheet" && right.modality === "spreadsheet"
|
|
1031
|
-
? left.
|
|
1032
|
+
? left.operationProtocolVersion === right.operationProtocolVersion &&
|
|
1032
1033
|
frontiersEqual(left.causalFrontier, right.causalFrontier)
|
|
1033
1034
|
: left.modality !== "spreadsheet" &&
|
|
1034
1035
|
right.modality !== "spreadsheet" &&
|
|
@@ -1107,9 +1108,7 @@ function normalizeStoredSnapshot(
|
|
|
1107
1108
|
snapshot: Omit<IndexedDbStoredSnapshot, "namespace">,
|
|
1108
1109
|
modality: EditableArtifactModality,
|
|
1109
1110
|
): EditableArtifactSnapshot {
|
|
1110
|
-
|
|
1111
|
-
(snapshot as { modality?: EditableArtifactModality }).modality ?? "spreadsheet";
|
|
1112
|
-
if (retainedModality !== modality) {
|
|
1111
|
+
if (snapshot.modality !== modality) {
|
|
1113
1112
|
throw new TypeError("retained snapshot modality does not match its storage scope");
|
|
1114
1113
|
}
|
|
1115
1114
|
return { ...snapshot, modality } as EditableArtifactSnapshot;
|
|
@@ -1119,9 +1118,7 @@ function normalizeStoredCommitted(
|
|
|
1119
1118
|
transaction: Omit<IndexedDbCommittedTransaction, "namespace">,
|
|
1120
1119
|
modality: EditableArtifactModality,
|
|
1121
1120
|
): EditableArtifactCommittedTransaction {
|
|
1122
|
-
|
|
1123
|
-
(transaction as { modality?: EditableArtifactModality }).modality ?? "spreadsheet";
|
|
1124
|
-
if (retainedModality !== modality) {
|
|
1121
|
+
if (transaction.modality !== modality) {
|
|
1125
1122
|
throw new TypeError("retained transaction modality does not match its storage scope");
|
|
1126
1123
|
}
|
|
1127
1124
|
return { ...transaction, modality } as EditableArtifactCommittedTransaction;
|
|
@@ -1131,9 +1128,7 @@ function normalizeStoredPending(
|
|
|
1131
1128
|
transaction: Omit<IndexedDbPendingTransaction, "namespace" | "transactionId">,
|
|
1132
1129
|
modality: EditableArtifactModality,
|
|
1133
1130
|
): EditableArtifactPendingTransaction {
|
|
1134
|
-
|
|
1135
|
-
(transaction as { modality?: EditableArtifactModality }).modality ?? "spreadsheet";
|
|
1136
|
-
if (retainedModality !== modality) {
|
|
1131
|
+
if (transaction.modality !== modality) {
|
|
1137
1132
|
throw new TypeError("retained pending modality does not match its storage scope");
|
|
1138
1133
|
}
|
|
1139
1134
|
return { ...transaction, modality } as EditableArtifactPendingTransaction;
|
|
@@ -1269,18 +1264,12 @@ function openDatabase(factory: IDBFactory, databaseName: string): Promise<IDBDat
|
|
|
1269
1264
|
};
|
|
1270
1265
|
request.onupgradeneeded = (event) => {
|
|
1271
1266
|
const database = request.result;
|
|
1272
|
-
if (event.oldVersion <
|
|
1273
|
-
//
|
|
1274
|
-
//
|
|
1267
|
+
if (event.oldVersion < DATABASE_VERSION) {
|
|
1268
|
+
// All local artifact state is reconstructible. A format hard cut drops
|
|
1269
|
+
// confirmed state and pending commands instead of interpreting old bytes.
|
|
1275
1270
|
for (const name of [REPLICA_HEAD_STORE, SNAPSHOT_STORE, PENDING_STORE, COMMITTED_STORE]) {
|
|
1276
1271
|
if (database.objectStoreNames.contains(name)) database.deleteObjectStore(name);
|
|
1277
1272
|
}
|
|
1278
|
-
} else if (event.oldVersion < 3) {
|
|
1279
|
-
// V2 heads did not retain constant-time journal accounting. Confirmed
|
|
1280
|
-
// state is reconstructible, so rebuild it while preserving the pending WAL.
|
|
1281
|
-
for (const name of [REPLICA_HEAD_STORE, SNAPSHOT_STORE, COMMITTED_STORE]) {
|
|
1282
|
-
if (database.objectStoreNames.contains(name)) database.deleteObjectStore(name);
|
|
1283
|
-
}
|
|
1284
1273
|
}
|
|
1285
1274
|
if (!database.objectStoreNames.contains(REPLICA_HEAD_STORE)) {
|
|
1286
1275
|
database.createObjectStore(REPLICA_HEAD_STORE, {
|
|
@@ -1373,7 +1362,9 @@ function replaceIndexedDbReplica(
|
|
|
1373
1362
|
updatedAt: replica.updatedAt,
|
|
1374
1363
|
modality: replica.modality,
|
|
1375
1364
|
...(replica.snapshot.modality === "spreadsheet"
|
|
1376
|
-
? {
|
|
1365
|
+
? {
|
|
1366
|
+
operationProtocolVersion: replica.snapshot.operationProtocolVersion,
|
|
1367
|
+
}
|
|
1377
1368
|
: {}),
|
|
1378
1369
|
tailCount: replica.tail.length,
|
|
1379
1370
|
tailBytes: committedTailBytes(replica.tail),
|
|
@@ -39,7 +39,8 @@ type EditableArtifactSnapshotCommon = {
|
|
|
39
39
|
export type EditableArtifactSpreadsheetSnapshot = EditableArtifactSnapshotCommon & {
|
|
40
40
|
modality: "spreadsheet";
|
|
41
41
|
causalFrontier: EditableArtifactCausalFrontier;
|
|
42
|
-
|
|
42
|
+
operationProtocolVersion: number;
|
|
43
|
+
snapshotVersion: number;
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
export type EditableArtifactSerializedSnapshot = EditableArtifactSnapshotCommon & {
|
|
@@ -67,7 +68,7 @@ export type EditableArtifactSpreadsheetCommittedTransaction =
|
|
|
67
68
|
EditableArtifactCommittedTransactionCommon & {
|
|
68
69
|
modality: "spreadsheet";
|
|
69
70
|
causalFrontier: EditableArtifactCausalFrontier;
|
|
70
|
-
|
|
71
|
+
operationProtocolVersion: number;
|
|
71
72
|
/** Exact whole canonical OGACO committed-transaction envelope. */
|
|
72
73
|
committedTransactionBytes: Uint8Array;
|
|
73
74
|
};
|
|
@@ -236,7 +237,7 @@ export type EditableArtifactStoredReplica = {
|
|
|
236
237
|
|
|
237
238
|
type EditableArtifactBootstrapCommon = {
|
|
238
239
|
artifactId: EditableArtifactId;
|
|
239
|
-
|
|
240
|
+
liveProtocolVersion: number;
|
|
240
241
|
headSequence: number;
|
|
241
242
|
headStateHash: string;
|
|
242
243
|
kernelVersion: string;
|
|
@@ -478,6 +479,8 @@ export type EditableArtifactSyncView = {
|
|
|
478
479
|
writable: boolean;
|
|
479
480
|
pendingTransactions: number;
|
|
480
481
|
blockedPending: readonly EditableArtifactBlockedPending[];
|
|
482
|
+
/** A command barrier independent of the artifact's edit permission. */
|
|
483
|
+
authoringBlockedReason?: "pending_conflict" | "prior_writer" | undefined;
|
|
481
484
|
queuedMessages: number;
|
|
482
485
|
reconnectAttempt: number;
|
|
483
486
|
lastError: Error | null;
|
|
@@ -4,15 +4,24 @@ import {
|
|
|
4
4
|
EDITABLE_ARTIFACT_INTENT_VERSION,
|
|
5
5
|
EDITABLE_ARTIFACT_PRODUCT_MAX_SNAPSHOT_BYTES,
|
|
6
6
|
SPREADSHEET_ARTIFACT_COMMAND_VERSION,
|
|
7
|
+
SPREADSHEET_ARTIFACT_MODEL_SCHEMA_VERSION,
|
|
7
8
|
} from "@opengeni/contracts/editable-artifacts";
|
|
8
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION,
|
|
11
|
+
SPREADSHEET_KERNEL_COMMAND_VERSION,
|
|
12
|
+
SPREADSHEET_KERNEL_SNAPSHOT_VERSION,
|
|
13
|
+
} from "@opengeni/contracts/editable-artifact-versions";
|
|
14
|
+
import {
|
|
15
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
16
|
+
MAX_COMMITTED_TRANSACTION_BYTES,
|
|
17
|
+
} from "@opengeni/contracts/editable-artifact-committed-transaction";
|
|
9
18
|
import type { ArtifactWorkerInitializeInput } from "./wire-codec";
|
|
10
19
|
import type { EditableArtifactModality } from "../types";
|
|
11
20
|
import { ArtifactWorkerProtocolError } from "./rpc-protocol";
|
|
12
21
|
|
|
13
22
|
export type ArtifactWorkerKernelSession = {
|
|
14
23
|
readonly modality: EditableArtifactModality;
|
|
15
|
-
/** Replays one exact whole canonical
|
|
24
|
+
/** Replays one exact whole canonical OGACO002 transaction. */
|
|
16
25
|
applyCommitted: (committedTransactionBytes: Uint8Array) => void;
|
|
17
26
|
/** Authors and applies one exact OGATX001 intent over the current frontier. */
|
|
18
27
|
applyPending: (intentBytes: Uint8Array) => void;
|
|
@@ -129,6 +138,7 @@ type WasmCapabilities = Readonly<{
|
|
|
129
138
|
editableArtifactIntentVersion: number;
|
|
130
139
|
kernelSnapshotVersion: number;
|
|
131
140
|
spreadsheetCommandVersion: number;
|
|
141
|
+
spreadsheetModelSchemaVersion: number;
|
|
132
142
|
maxCellsPerBatch: number;
|
|
133
143
|
maxCommandBytes: number;
|
|
134
144
|
maxCommands: number;
|
|
@@ -579,6 +589,7 @@ function decodeCapabilities(bytes: Uint8Array): WasmCapabilities {
|
|
|
579
589
|
"safeRust",
|
|
580
590
|
"sessionForks",
|
|
581
591
|
"spreadsheetCommandVersion",
|
|
592
|
+
"spreadsheetModelSchemaVersion",
|
|
582
593
|
"statefulSessions",
|
|
583
594
|
"textLayout",
|
|
584
595
|
"textLayoutFontBundleVersion",
|
|
@@ -637,6 +648,10 @@ function decodeCapabilities(bytes: Uint8Array): WasmCapabilities {
|
|
|
637
648
|
value.spreadsheetCommandVersion,
|
|
638
649
|
"spreadsheetCommandVersion",
|
|
639
650
|
),
|
|
651
|
+
spreadsheetModelSchemaVersion: positiveInteger(
|
|
652
|
+
value.spreadsheetModelSchemaVersion,
|
|
653
|
+
"spreadsheetModelSchemaVersion",
|
|
654
|
+
),
|
|
640
655
|
maxCellsPerBatch: positiveInteger(value.maxCellsPerBatch, "maxCellsPerBatch"),
|
|
641
656
|
maxCommands: positiveInteger(value.maxCommands, "maxCommands"),
|
|
642
657
|
maxSnapshotBytes: positiveInteger(value.maxSnapshotBytes, "maxSnapshotBytes"),
|
|
@@ -765,16 +780,17 @@ function decodeCapabilities(bytes: Uint8Array): WasmCapabilities {
|
|
|
765
780
|
normalized.canonicalStateHash !== "sha256:canonical-snapshot" ||
|
|
766
781
|
normalized.editableArtifactIntentVersion !== EDITABLE_ARTIFACT_INTENT_VERSION ||
|
|
767
782
|
normalized.spreadsheetCommandVersion !== SPREADSHEET_ARTIFACT_COMMAND_VERSION ||
|
|
768
|
-
normalized.
|
|
769
|
-
normalized.
|
|
770
|
-
normalized.
|
|
783
|
+
normalized.spreadsheetModelSchemaVersion !== SPREADSHEET_ARTIFACT_MODEL_SCHEMA_VERSION ||
|
|
784
|
+
normalized.collaborationSnapshotVersion !== SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION ||
|
|
785
|
+
normalized.commandSchemaVersion !== SPREADSHEET_KERNEL_COMMAND_VERSION ||
|
|
786
|
+
normalized.committedTransactionVersion !== COMMITTED_TRANSACTION_PROTOCOL_VERSION ||
|
|
771
787
|
normalized.documentCommandVersion !== 1 ||
|
|
772
788
|
normalized.documentQueryResponseVersion !== 1 ||
|
|
773
789
|
normalized.documentQueryVersion !== 1 ||
|
|
774
790
|
normalized.documentReceiptVersion !== 1 ||
|
|
775
791
|
normalized.documentSnapshotVersion !== 1 ||
|
|
776
792
|
normalized.documentStatefulSessions !== normalized.document ||
|
|
777
|
-
normalized.kernelSnapshotVersion !==
|
|
793
|
+
normalized.kernelSnapshotVersion !== SPREADSHEET_KERNEL_SNAPSHOT_VERSION ||
|
|
778
794
|
normalized.maxCellsPerBatch !== WASM_MAX_CELLS_PER_BATCH ||
|
|
779
795
|
normalized.maxCommandBytes !== WASM_MAX_COMMAND_BYTES ||
|
|
780
796
|
normalized.maxSpreadsheetCommandBytes !== EDITABLE_ARTIFACT_COMMAND_MAX_BYTES ||
|
|
@@ -868,7 +884,7 @@ function capabilityProfile(modality: EditableArtifactModality, capabilities: Was
|
|
|
868
884
|
);
|
|
869
885
|
}
|
|
870
886
|
return {
|
|
871
|
-
modelSchemaVersion: capabilities.
|
|
887
|
+
modelSchemaVersion: capabilities.spreadsheetModelSchemaVersion,
|
|
872
888
|
commandVersion: capabilities.spreadsheetCommandVersion,
|
|
873
889
|
maximumSnapshotBytes: capabilities.maxSnapshotBytes,
|
|
874
890
|
maximumCommandBytes: capabilities.maxSpreadsheetCommandBytes,
|
|
@@ -5,9 +5,13 @@ import {
|
|
|
5
5
|
decodeEditableArtifactMutationIntent,
|
|
6
6
|
hashEditableArtifactMutationIntent,
|
|
7
7
|
} from "@opengeni/contracts/editable-artifacts";
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
COMMITTED_TRANSACTION_PROTOCOL_VERSION,
|
|
10
|
+
decodeCommittedTransactionSummary,
|
|
11
|
+
} from "@opengeni/contracts/editable-artifact-committed-transaction";
|
|
9
12
|
import { editableArtifactCodecFor } from "@opengeni/contracts/editable-artifact-codec-registry";
|
|
10
13
|
import { decodeEditableArtifactSerializedCommit } from "@opengeni/contracts/editable-artifact-serialized-commit";
|
|
14
|
+
import { SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION } from "@opengeni/contracts/editable-artifact-versions";
|
|
11
15
|
import type {
|
|
12
16
|
EditableArtifactBlockedPending,
|
|
13
17
|
EditableArtifactCausalFrontier,
|
|
@@ -269,18 +273,20 @@ export class ArtifactWorkerRuntime {
|
|
|
269
273
|
snapshot.modality !== initialization.modality ||
|
|
270
274
|
snapshot.modality !== adapter.modality ||
|
|
271
275
|
(snapshot.modality === "spreadsheet" &&
|
|
272
|
-
snapshot.
|
|
273
|
-
|
|
276
|
+
(snapshot.operationProtocolVersion !== COMMITTED_TRANSACTION_PROTOCOL_VERSION ||
|
|
277
|
+
snapshot.snapshotVersion !== SPREADSHEET_COLLABORATION_SNAPSHOT_VERSION)) ||
|
|
274
278
|
snapshot.modelSchemaVersion !== adapter.modelSchemaVersion
|
|
275
279
|
) {
|
|
276
280
|
throw runtimeError(
|
|
277
281
|
"unsupported_protocol",
|
|
278
|
-
"snapshot protocol/
|
|
282
|
+
"snapshot protocol/schema is incompatible with the loaded collaboration kernel",
|
|
279
283
|
);
|
|
280
284
|
}
|
|
281
285
|
const digest = await sha256Hex(ownedBytes);
|
|
282
286
|
this.throwIfCancelled(frame.requestId);
|
|
283
|
-
|
|
287
|
+
if (digest !== snapshot.digest) {
|
|
288
|
+
throw runtimeError("byte_corruption", "snapshot digest does not match its bytes");
|
|
289
|
+
}
|
|
284
290
|
const canonical = requireBytesWithin(
|
|
285
291
|
adapter.canonicalizeSnapshot(ownedBytes),
|
|
286
292
|
initialization.maximumSnapshotBytes,
|
|
@@ -298,7 +304,12 @@ export class ArtifactWorkerRuntime {
|
|
|
298
304
|
try {
|
|
299
305
|
stateHash = await nextConfirmed.stateHash();
|
|
300
306
|
this.throwIfCancelled(frame.requestId);
|
|
301
|
-
|
|
307
|
+
if (stateHash !== snapshot.stateHash) {
|
|
308
|
+
throw runtimeError(
|
|
309
|
+
"authored_causal_mismatch",
|
|
310
|
+
"snapshot authored state does not match its state hash",
|
|
311
|
+
);
|
|
312
|
+
}
|
|
302
313
|
if (
|
|
303
314
|
snapshot.modality !== "spreadsheet" &&
|
|
304
315
|
nextConfirmed.nativeRevision() !== snapshot.nativeRevision
|
|
@@ -324,7 +335,7 @@ export class ArtifactWorkerRuntime {
|
|
|
324
335
|
artifactId: snapshot.artifactId,
|
|
325
336
|
modality: "spreadsheet",
|
|
326
337
|
sequence: snapshot.sequence,
|
|
327
|
-
protocolVersion:
|
|
338
|
+
protocolVersion: adapter.protocolVersion,
|
|
328
339
|
kernelVersion: snapshot.kernelVersion,
|
|
329
340
|
modelSchemaVersion: snapshot.modelSchemaVersion,
|
|
330
341
|
stateHash,
|
|
@@ -566,7 +577,7 @@ export class ArtifactWorkerRuntime {
|
|
|
566
577
|
}
|
|
567
578
|
if (
|
|
568
579
|
transaction.modality === "spreadsheet" &&
|
|
569
|
-
transaction.
|
|
580
|
+
transaction.operationProtocolVersion !== COMMITTED_TRANSACTION_PROTOCOL_VERSION
|
|
570
581
|
)
|
|
571
582
|
throw runtimeError("unsupported_protocol", "committed transaction protocol is incompatible");
|
|
572
583
|
if (transaction.startSequence !== installed.sequence + 1) {
|
|
@@ -1046,12 +1057,12 @@ function assertCommittedEnvelopeMatchesOuter(
|
|
|
1046
1057
|
} catch (error) {
|
|
1047
1058
|
throw new ArtifactWorkerProtocolError(
|
|
1048
1059
|
"invalid_committed_transaction",
|
|
1049
|
-
"committed transaction is not canonical
|
|
1060
|
+
"committed transaction is not canonical OGACO002",
|
|
1050
1061
|
{ cause: error },
|
|
1051
1062
|
);
|
|
1052
1063
|
}
|
|
1053
1064
|
if (
|
|
1054
|
-
summary.operationProtocolVersion !== transaction.
|
|
1065
|
+
summary.operationProtocolVersion !== transaction.operationProtocolVersion ||
|
|
1055
1066
|
summary.transactionId !== transaction.transactionId ||
|
|
1056
1067
|
summary.priorStateHash !== transaction.priorStateHash ||
|
|
1057
1068
|
summary.stateHash !== transaction.stateHash ||
|
|
@@ -1059,7 +1070,7 @@ function assertCommittedEnvelopeMatchesOuter(
|
|
|
1059
1070
|
) {
|
|
1060
1071
|
throw runtimeError(
|
|
1061
1072
|
"committed_metadata_mismatch",
|
|
1062
|
-
"outer committed metadata disagrees with its exact
|
|
1073
|
+
"outer committed metadata disagrees with its exact OGACO002 envelope",
|
|
1063
1074
|
);
|
|
1064
1075
|
}
|
|
1065
1076
|
}
|
|
@@ -1156,8 +1167,9 @@ function asWorkerFailure(error: unknown): WorkerFailure {
|
|
|
1156
1167
|
};
|
|
1157
1168
|
}
|
|
1158
1169
|
if (error instanceof Error) {
|
|
1170
|
+
const rawCode = (error as Error & { code?: unknown }).code;
|
|
1159
1171
|
return {
|
|
1160
|
-
code: "kernel_failed",
|
|
1172
|
+
code: typeof rawCode === "string" ? normalizeErrorCode(rawCode) : "kernel_failed",
|
|
1161
1173
|
message: sanitizeErrorMessage(error.message || "artifact kernel failed"),
|
|
1162
1174
|
retryable: false,
|
|
1163
1175
|
};
|
|
@@ -1175,7 +1187,8 @@ function asProtocolError(error: unknown): ArtifactWorkerProtocolError {
|
|
|
1175
1187
|
}
|
|
1176
1188
|
|
|
1177
1189
|
function normalizeErrorCode(value: string): string {
|
|
1178
|
-
|
|
1190
|
+
const normalized = value.toLowerCase();
|
|
1191
|
+
return /^[a-z][a-z0-9_]{0,127}$/.test(normalized) ? normalized : "kernel_failed";
|
|
1179
1192
|
}
|
|
1180
1193
|
|
|
1181
1194
|
function sanitizeErrorMessage(value: string): string {
|
|
@@ -126,7 +126,10 @@ export function encodeSnapshotMetadata(snapshot: EditableArtifactSnapshot): Uint
|
|
|
126
126
|
if (snapshot.modality === "spreadsheet") {
|
|
127
127
|
writer
|
|
128
128
|
.frontier(snapshot.causalFrontier)
|
|
129
|
-
.u32(
|
|
129
|
+
.u32(
|
|
130
|
+
positiveSafeInteger(snapshot.operationProtocolVersion, "snapshot.operationProtocolVersion"),
|
|
131
|
+
)
|
|
132
|
+
.u32(positiveSafeInteger(snapshot.snapshotVersion, "snapshot.snapshotVersion"));
|
|
130
133
|
} else {
|
|
131
134
|
writer.safeUint(nonNegativeSafeInteger(snapshot.nativeRevision, "snapshot.nativeRevision"));
|
|
132
135
|
}
|
|
@@ -154,7 +157,11 @@ export function decodeSnapshotMetadata(
|
|
|
154
157
|
...common,
|
|
155
158
|
modality,
|
|
156
159
|
causalFrontier: reader.frontier(),
|
|
157
|
-
|
|
160
|
+
operationProtocolVersion: positiveSafeInteger(
|
|
161
|
+
reader.u32(),
|
|
162
|
+
"snapshot.operationProtocolVersion",
|
|
163
|
+
),
|
|
164
|
+
snapshotVersion: positiveSafeInteger(reader.u32(), "snapshot.snapshotVersion"),
|
|
158
165
|
}
|
|
159
166
|
: {
|
|
160
167
|
...common,
|
|
@@ -195,7 +202,10 @@ export function decodeCommittedMetadata(
|
|
|
195
202
|
...common,
|
|
196
203
|
modality,
|
|
197
204
|
causalFrontier: reader.frontier(),
|
|
198
|
-
|
|
205
|
+
operationProtocolVersion: positiveSafeInteger(
|
|
206
|
+
reader.u32(),
|
|
207
|
+
"transaction.operationProtocolVersion",
|
|
208
|
+
),
|
|
199
209
|
}
|
|
200
210
|
: {
|
|
201
211
|
...common,
|
|
@@ -427,7 +437,12 @@ function encodeCommittedFields(
|
|
|
427
437
|
if (transaction.modality === "spreadsheet") {
|
|
428
438
|
writer
|
|
429
439
|
.frontier(transaction.causalFrontier)
|
|
430
|
-
.u32(
|
|
440
|
+
.u32(
|
|
441
|
+
positiveSafeInteger(
|
|
442
|
+
transaction.operationProtocolVersion,
|
|
443
|
+
"transaction.operationProtocolVersion",
|
|
444
|
+
),
|
|
445
|
+
);
|
|
431
446
|
} else {
|
|
432
447
|
writer
|
|
433
448
|
.safeUint(
|
|
@@ -461,7 +476,10 @@ function decodeCommittedFields(
|
|
|
461
476
|
...common,
|
|
462
477
|
modality,
|
|
463
478
|
causalFrontier: reader.frontier(),
|
|
464
|
-
|
|
479
|
+
operationProtocolVersion: positiveSafeInteger(
|
|
480
|
+
reader.u32(),
|
|
481
|
+
"transaction.operationProtocolVersion",
|
|
482
|
+
),
|
|
465
483
|
}
|
|
466
484
|
: {
|
|
467
485
|
...common,
|