space-data-module-sdk 0.9.8 → 0.9.10

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.
Files changed (65) hide show
  1. package/docs/_shell/consumer-assets.html +3 -3
  2. package/docs/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-callback.0f2dee485c8f0d7afe5f70b4b42093a382c92d32af551bd71b41733336091c7a.js +1 -0
  3. package/docs/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.9ab041131df957fcb6ef7e3d87bf9d19fe313bc5d7f1e53337752faf0ba354da.js +1 -0
  4. package/docs/assets/vendor/hd-wallet-ui/2.2.1/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css +32 -0
  5. package/docs/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.24eb3001afc5448a90cef87e53bb4e599c0ae4dc9e14bafb6d1236e0233c6008.js +283 -0
  6. package/docs/assets/vendor/sdn-stack-nav/1.0.1/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css +118 -0
  7. package/docs/browser-wasmedge-isomorphic.html +3 -3
  8. package/docs/byo-wasm-quickstart.html +3 -3
  9. package/docs/conformance.html +3 -3
  10. package/docs/events-abi.html +4 -4
  11. package/docs/events-abi.md +1 -1
  12. package/docs/families/analytics.html +3 -3
  13. package/docs/families/attitude.html +3 -3
  14. package/docs/families/behavior.html +3 -3
  15. package/docs/families/breakup.html +3 -3
  16. package/docs/families/conjunction.html +3 -3
  17. package/docs/families/data-source.html +3 -3
  18. package/docs/families/effects.html +3 -3
  19. package/docs/families/environment.html +3 -3
  20. package/docs/families/estimation.html +3 -3
  21. package/docs/families/gnc.html +3 -3
  22. package/docs/families/maneuver.html +3 -3
  23. package/docs/families/obstruction.html +3 -3
  24. package/docs/families/propagator.html +3 -3
  25. package/docs/families/propulsion.html +3 -3
  26. package/docs/families/reentry.html +3 -3
  27. package/docs/families/rf.html +3 -3
  28. package/docs/families/scheduler.html +3 -3
  29. package/docs/families/sensor.html +3 -3
  30. package/docs/families/signature.html +3 -3
  31. package/docs/flatsql-host-contract.html +3 -3
  32. package/docs/flatsql-streaming-standard.html +3 -3
  33. package/docs/gpu-module-abi.html +3 -3
  34. package/docs/index.html +3 -3
  35. package/docs/isomorphic-pthreads.html +3 -3
  36. package/docs/isomorphic-sdn-runtime-plan.html +3 -3
  37. package/docs/language-runtime-matrix.html +3 -3
  38. package/docs/module-bundle-runtime-plan.html +3 -3
  39. package/docs/module-publication-standard.html +3 -3
  40. package/docs/node-red-default-node-parity.html +3 -3
  41. package/docs/protect-and-sign.html +3 -3
  42. package/docs/protocol-installation.html +3 -3
  43. package/docs/publication-submission.html +3 -3
  44. package/docs/secrets-capability.html +3 -3
  45. package/docs/testing-harness.html +3 -3
  46. package/docs/tri-runtime-parity-gate.html +3 -3
  47. package/docs/tri-runtime-parity.html +3 -3
  48. package/docs/wallet-callback.html +1 -1
  49. package/package.json +1 -1
  50. package/schemas/orbpro/Propagator.fbs +4 -4
  51. package/schemas/orbpro/reference-frame-crosswalk.json +4 -4
  52. package/src/compiler/compileModule.js +51 -2
  53. package/src/flow/flowCompiler.js +1 -1
  54. package/src/flow/flowRuntimeHost.js +2 -2
  55. package/src/host/abi.js +2 -3
  56. package/src/host/hostWorkerBundleSources.js +3 -3
  57. package/src/host/hostcallWire.js +3 -2
  58. package/src/host/providerAccess.js +2 -3
  59. package/src/host/typedDispatch.js +2 -2
  60. package/src/host/wasiShim.js +5 -1
  61. package/src/runtime-host/flatsqlRuntimeStore.js +2 -2
  62. package/src/testing/headlessShell.js +80 -0
  63. package/src/testing/parityGate.js +17 -28
  64. package/src/testing/parityLanes.js +4 -22
  65. package/src/utils/guestText.js +12 -0
@@ -18,7 +18,8 @@
18
18
  * responses (meta = { ok, result } | { ok, error }).
19
19
  */
20
20
 
21
- const textDecoder = new TextDecoder();
21
+ import { decodeGuestText } from "../utils/guestText.js";
22
+
22
23
  const textEncoder = new TextEncoder();
23
24
 
24
25
  export const HOSTCALL_BINARY_REF_KEY = "$bin";
@@ -143,7 +144,7 @@ export function decodeHostcallEnvelope(bytes) {
143
144
  throw new RangeError("Hostcall envelope meta exceeds envelope bounds.");
144
145
  }
145
146
  const meta = JSON.parse(
146
- textDecoder.decode(bytes.subarray(offset, offset + metaLength)),
147
+ decodeGuestText(bytes.subarray(offset, offset + metaLength)),
147
148
  );
148
149
  offset += metaLength;
149
150
  const segmentCount = view.getUint32(offset, true);
@@ -29,8 +29,7 @@ import {
29
29
  providerErrorName,
30
30
  providerSourceId,
31
31
  } from "./providerAccessAbi.js";
32
-
33
- const textDecoder = new TextDecoder();
32
+ import { decodeGuestText } from "../utils/guestText.js";
34
33
 
35
34
  function isThenable(value) {
36
35
  return value !== null && typeof value?.then === "function";
@@ -588,7 +587,7 @@ export function createProviderAccessBridge(options = {}) {
588
587
  function acquire(reqPtr, reqLen, descPtr) {
589
588
  try {
590
589
  const request = JSON.parse(
591
- textDecoder.decode(guestView(getMemory, reqPtr, reqLen)),
590
+ decodeGuestText(guestView(getMemory, reqPtr, reqLen)),
592
591
  );
593
592
  // RASTER IN. A coverage field is 512x512 = 262,144 positions; encoding
594
593
  // those as JSON would be a multi-megabyte request string parsed per
@@ -13,10 +13,10 @@ import {
13
13
  import * as hostOps from "../generated/runtime/aligned/HostOps_aligned.js";
14
14
  import { cryptoAlgorithm, deliverMode, reconcileKind, sandboxWant } from "../generated/runtime/aligned/HostOps_enums.js";
15
15
  import { base64ToBytes, bytesToBase64 } from "../utils/encoding.js";
16
+ import { decodeGuestText } from "../utils/guestText.js";
16
17
 
17
- const textDecoder = new TextDecoder();
18
18
  const textEncoder = new TextEncoder();
19
- const text = (bytes) => (bytes === undefined ? undefined : textDecoder.decode(bytes));
19
+ const text = (bytes) => (bytes === undefined ? undefined : decodeGuestText(bytes));
20
20
  const bytesOf = (value) => (value === undefined || value === null ? undefined : value instanceof Uint8Array ? value : typeof value === "string" ? textEncoder.encode(value) : new Uint8Array(value));
21
21
  const items = (values) => (values || []).map((v) => ({ VALUE: String(v) }));
22
22
  const unix = (value) => BigInt(Math.round(value instanceof Date ? value.getTime() : Number(value)));
@@ -278,7 +278,11 @@ export function createBrowserWasiShim(options = {}) {
278
278
  if (!cryptoApi?.getRandomValues) {
279
279
  return ERRNO_NOSYS;
280
280
  }
281
- cryptoApi.getRandomValues(mem8().subarray(bufPtr, bufPtr + bufLen));
281
+ // A browser refuses crypto.getRandomValues on a view of shared memory (a threads guest): fill a private
282
+ // buffer, then copy it into the guest.
283
+ const random = new Uint8Array(bufLen);
284
+ cryptoApi.getRandomValues(random);
285
+ mem8().set(random, bufPtr);
282
286
  return ERRNO_SUCCESS;
283
287
  }
284
288
 
@@ -1,4 +1,5 @@
1
1
  import { DirectAccessor, FlatSQLDatabase } from "flatsql";
2
+ import { decodeGuestText } from "../utils/guestText.js";
2
3
 
3
4
  const RUNTIME_ROW_TABLE = "RuntimeHostRow";
4
5
  const RUNTIME_ROW_SCHEMA = `
@@ -9,7 +10,6 @@ table RuntimeHostRow {
9
10
  `;
10
11
 
11
12
  const encoder = new TextEncoder();
12
- const decoder = new TextDecoder();
13
13
 
14
14
  function clonePayload(payload) {
15
15
  if (payload === null || payload === undefined) {
@@ -151,7 +151,7 @@ function decodeRuntimeRowMetadata(data) {
151
151
  throw new Error("Invalid runtime row metadata layout.");
152
152
  }
153
153
  return {
154
- schemaFileId: decoder.decode(bytes.subarray(schemaStart, schemaEnd)),
154
+ schemaFileId: decodeGuestText(bytes.subarray(schemaStart, schemaEnd)),
155
155
  rowId: Number(view.getBigUint64(rowIdOffset, true)),
156
156
  };
157
157
  }
@@ -0,0 +1,80 @@
1
+ // The only browser the parity lanes launch: Chromium's headless shell from
2
+ // the Playwright cache (owner rule 2026-10-16). Never Google Chrome.app, Chrome
3
+ // for Testing, Chromium.app or a `channel` browser: a full browser started
4
+ // from a background process registers with the window server, aborts in
5
+ // HIServices on macOS and throws crash dialogs on the operator's screen. The
6
+ // headless shell has no window-server registration and runs with an isolated
7
+ // user-data-dir, which is what a parity lane needs.
8
+ //
9
+ // Resolution order: `context.chromeBinary`, SDM_CHROME_BINARY, CHROME_BINARY
10
+ // (each must itself be a headless shell), then the newest installed shell
11
+ // under PLAYWRIGHT_BROWSERS_PATH (default ~/Library/Caches/ms-playwright, or
12
+ // ~/.cache/ms-playwright on Linux).
13
+ import { constants as fsConstants, existsSync, readdirSync } from "node:fs";
14
+ import { access } from "node:fs/promises";
15
+ import os from "node:os";
16
+ import path from "node:path";
17
+ import process from "node:process";
18
+
19
+ const FORBIDDEN = /Google Chrome|Chrome for Testing|Chromium\.app|google-chrome|chromium-browser/;
20
+ const SHELL = /chrome-headless-shell|headless_shell/;
21
+
22
+ function cacheRoots() {
23
+ if (process.env.PLAYWRIGHT_BROWSERS_PATH) return [process.env.PLAYWRIGHT_BROWSERS_PATH];
24
+ return [
25
+ path.join(os.homedir(), "Library", "Caches", "ms-playwright"),
26
+ path.join(os.homedir(), ".cache", "ms-playwright"),
27
+ ];
28
+ }
29
+
30
+ /** Installed headless shells, newest first. */
31
+ export function installedHeadlessShells() {
32
+ const found = [];
33
+ for (const cache of cacheRoots()) {
34
+ if (!existsSync(cache)) continue;
35
+ const dirs = readdirSync(cache).filter((d) => /^chromium_headless_shell-\d+$/.test(d));
36
+ dirs.sort((a, b) => Number(b.split("-")[1]) - Number(a.split("-")[1]));
37
+ for (const dir of dirs) {
38
+ for (const sub of readdirSync(path.join(cache, dir))) {
39
+ if (!sub.startsWith("chrome-headless-shell")) continue;
40
+ for (const name of ["chrome-headless-shell", "chrome-headless-shell.exe"]) {
41
+ const bin = path.join(cache, dir, sub, name);
42
+ if (existsSync(bin)) found.push(bin);
43
+ }
44
+ }
45
+ }
46
+ }
47
+ return found;
48
+ }
49
+
50
+ /**
51
+ * The headless-shell binary the browser lanes spawn. An explicit choice is
52
+ * honoured only when it is a headless shell; a full browser is refused.
53
+ */
54
+ export async function resolveHeadlessShell(context = {}) {
55
+ const explicit =
56
+ context.chromeBinary ?? process.env.SDM_CHROME_BINARY ?? process.env.CHROME_BINARY;
57
+ if (explicit) {
58
+ const candidate = String(explicit);
59
+ if (FORBIDDEN.test(candidate) || !SHELL.test(candidate)) {
60
+ throw new Error(
61
+ `browser lane: ${candidate} is not a Chromium headless shell. Only the Playwright ` +
62
+ "chromium_headless_shell may be launched (never Google Chrome.app, Chrome for Testing or Chromium.app).",
63
+ );
64
+ }
65
+ return candidate;
66
+ }
67
+ for (const candidate of installedHeadlessShells()) {
68
+ try {
69
+ await access(candidate, fsConstants.X_OK);
70
+ return candidate;
71
+ } catch {
72
+ // not executable here; try the next install
73
+ }
74
+ }
75
+ throw new Error(
76
+ "browser lane: no Chromium headless shell found under the Playwright cache " +
77
+ "(npx playwright install chromium-headless-shell), and SDM_CHROME_BINARY is unset. " +
78
+ "The browser lane requires a REAL browser context — jsdom masks SAB/threading realities.",
79
+ );
80
+ }
@@ -55,6 +55,7 @@ import path from "node:path";
55
55
  import process from "node:process";
56
56
  import { createRequire } from "node:module";
57
57
  import { fileURLToPath } from "node:url";
58
+ import { resolveHeadlessShell } from "./headlessShell.js";
58
59
  import { promisify } from "node:util";
59
60
 
60
61
  import { toLoadableWasmBytes } from "../bundle/artifactBytes.js";
@@ -529,26 +530,9 @@ async function ensureDockerLane(context) {
529
530
 
530
531
  // --- Browser probe lane ---------------------------------------------------------
531
532
 
532
- const CHROME_CANDIDATES = [
533
- "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
534
- "/Applications/Chromium.app/Contents/MacOS/Chromium",
535
- "/usr/bin/google-chrome-stable",
536
- "/usr/bin/google-chrome",
537
- "/usr/bin/chromium",
538
- "/usr/bin/chromium-browser",
539
- ];
540
-
533
+ // Only the Playwright chromium headless shell is launched (headlessShell.js).
541
534
  export async function resolveChromeBinary(context = {}) {
542
- const explicit =
543
- context.chromeBinary ?? process.env.SDM_CHROME_BINARY ?? process.env.CHROME_BINARY;
544
- if (explicit) return String(explicit);
545
- for (const candidate of CHROME_CANDIDATES) {
546
- if (await binaryExists(candidate)) return candidate;
547
- }
548
- throw new Error(
549
- "browser lane: no Chrome/Chromium binary found (set SDM_CHROME_BINARY). " +
550
- "The browser lane requires a REAL browser context — jsdom masks SAB/threading realities.",
551
- );
535
+ return resolveHeadlessShell(context);
552
536
  }
553
537
 
554
538
  const PROBE_HTML = `<!doctype html>
@@ -1232,15 +1216,20 @@ export async function runParityGate(options = {}) {
1232
1216
  const behavioral = [];
1233
1217
  for (const artifact of artifacts) {
1234
1218
  if (!artifact.fixture) continue;
1235
- // Behavioral lanes are scoped by the artifact's OWN declaration too: a
1236
- // WasmEdge-only artifact has no browser behaviour to compare, and running
1237
- // it there would score the harness's (correct) refusal as a divergence.
1238
- // The scoping is RECORDED — a skipped lane is evidence, never silence.
1239
- const harnessLanes = [
1240
- "browser",
1219
+ // Behavioral lanes are the gate's active lanes: a lane the caller did not
1220
+ // request is never compared (the Docker lane is optional; owner
1221
+ // 2026-10-22: "we don't need it for any of these tasks"), and a requested
1222
+ // lane that is not up already failed above as lane-unavailable. They are
1223
+ // scoped by the artifact's OWN declaration too: a WasmEdge-only artifact
1224
+ // has no browser behaviour to compare, and running it there would score
1225
+ // the harness's (correct) refusal as a divergence. The scoping is
1226
+ // RECORDED — a skipped lane is evidence, never silence.
1227
+ const requestedHarnessLanes = [
1228
+ ...(activeLanes.includes("browser") ? ["browser"] : []),
1241
1229
  ...(wasmedgeLanes.includes("wasmedge-native") ? ["wasmedge"] : []),
1242
- "docker-wasmedge",
1243
- ].filter((laneName) =>
1230
+ ...(wasmedgeLanes.includes("wasmedge-docker") ? ["docker-wasmedge"] : []),
1231
+ ];
1232
+ const harnessLanes = requestedHarnessLanes.filter((laneName) =>
1244
1233
  laneIsInDeclaredScope(
1245
1234
  laneName === "wasmedge"
1246
1235
  ? "wasmedge-native"
@@ -1251,7 +1240,7 @@ export async function runParityGate(options = {}) {
1251
1240
  artifact.declaredCapabilities,
1252
1241
  ),
1253
1242
  );
1254
- const outOfScopeLanes = ["browser", "wasmedge", "docker-wasmedge"].filter(
1243
+ const outOfScopeLanes = requestedHarnessLanes.filter(
1255
1244
  (laneName) => !harnessLanes.includes(laneName),
1256
1245
  );
1257
1246
  if (harnessLanes.length < 2) {
@@ -27,6 +27,7 @@ import path from "node:path";
27
27
  import process from "node:process";
28
28
  import { fileURLToPath } from "node:url";
29
29
  import { promisify } from "node:util";
30
+ import { resolveHeadlessShell } from "./headlessShell.js";
30
31
 
31
32
  import { ExitClass, assertWasmEdgeVersionMatchesPin } from "./parityHarness.js";
32
33
  import { normalizeWasmEdgeOutcome } from "./wasmedgeOutput.js";
@@ -379,30 +380,11 @@ export async function runDockerWasmEdgeLane(context) {
379
380
  return runs;
380
381
  }
381
382
 
382
- // --- Browser lane (real headless Chrome; never jsdom) --------------------------
383
-
384
- const CHROME_CANDIDATES = [
385
- "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
386
- "/Applications/Chromium.app/Contents/MacOS/Chromium",
387
- "/usr/bin/google-chrome-stable",
388
- "/usr/bin/google-chrome",
389
- "/usr/bin/chromium",
390
- "/usr/bin/chromium-browser",
391
- ];
383
+ // --- Browser lane (Chromium headless shell; never jsdom, never Chrome.app) ----
392
384
 
385
+ // Only the Playwright chromium headless shell is launched (headlessShell.js).
393
386
  export async function resolveChromeBinary(context = {}) {
394
- const explicit =
395
- context.chromeBinary ??
396
- process.env.SDM_CHROME_BINARY ??
397
- process.env.CHROME_BINARY;
398
- if (explicit) return String(explicit);
399
- for (const candidate of CHROME_CANDIDATES) {
400
- if (await binaryExists(candidate)) return candidate;
401
- }
402
- throw new Error(
403
- "browser lane: no Chrome/Chromium binary found. Set SDM_CHROME_BINARY. " +
404
- "(The browser lane requires a REAL browser context — jsdom masks SAB/threading realities.)",
405
- );
387
+ return resolveHeadlessShell(context);
406
388
  }
407
389
 
408
390
  async function buildBrowserRunnerBundle() {
@@ -0,0 +1,12 @@
1
+ // The one place a JavaScript host turns bytes read out of a WebAssembly guest into text.
2
+ //
3
+ // A guest built for wasm32-wasip1-threads (the wasi-sequential modules too) owns a SharedArrayBuffer memory, so the
4
+ // views a host takes over it are shared. Chromium's TextDecoder refuses them ("The provided ArrayBufferView value
5
+ // must not be shared"); Node and WasmEdge accept them, so the browser alone failed. A shared view can also change
6
+ // under the decoder. Decode an owned copy, so every host reads the same bytes in every runtime.
7
+ const decoder = new TextDecoder();
8
+
9
+ /** The UTF-8 text of `bytes`, a Uint8Array that may be a view of shared guest memory. */
10
+ export function decodeGuestText(bytes) {
11
+ return decoder.decode(bytes.slice());
12
+ }