space-data-module-sdk 0.5.15 → 0.5.19

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 (45) hide show
  1. package/README.md +51 -0
  2. package/package.json +13 -4
  3. package/schemas/HostStorageAbi.fbs +53 -0
  4. package/src/browser.js +6 -0
  5. package/src/bundle/codec.js +1 -1
  6. package/src/compiler/compileModule.js +3 -0
  7. package/src/compliance/pluginCompliance.js +1 -2
  8. package/src/generated/orbpro/invoke/plugin-invoke-request.js +1 -1
  9. package/src/generated/orbpro/invoke/plugin-invoke-response.js +1 -1
  10. package/src/generated/orbpro/manifest/accepted-type-set.js +1 -1
  11. package/src/generated/orbpro/manifest/build-artifact.js +1 -1
  12. package/src/generated/orbpro/manifest/host-capability.js +1 -1
  13. package/src/generated/orbpro/manifest/method-manifest.js +1 -1
  14. package/src/generated/orbpro/manifest/plugin-manifest.js +1 -1
  15. package/src/generated/orbpro/manifest/port-manifest.js +1 -1
  16. package/src/generated/orbpro/manifest/protocol-spec.js +1 -1
  17. package/src/generated/orbpro/manifest/timer-spec.js +1 -1
  18. package/src/generated/orbpro/module/canonicalization-rule.js +1 -1
  19. package/src/generated/orbpro/module/module-bundle-entry.js +1 -1
  20. package/src/generated/orbpro/module/module-bundle.js +1 -1
  21. package/src/generated/orbpro/stream/flat-buffer-type-ref.js +1 -1
  22. package/src/generated/orbpro/stream/typed-arena-buffer.js +1 -1
  23. package/src/host/browserEdgeShims.js +355 -0
  24. package/src/host/browserHost.js +399 -0
  25. package/src/host/index.js +4 -0
  26. package/src/host/isomorphicLoader.js +101 -0
  27. package/src/host/wasiShim.js +275 -0
  28. package/src/index.d.ts +364 -0
  29. package/src/index.js +1 -0
  30. package/src/invoke/codec.js +1 -1
  31. package/src/manifest/codec.js +1 -1
  32. package/src/manifest/typeRefs.js +49 -12
  33. package/src/runtime-host/flatsqlRuntimeStore.js +217 -0
  34. package/src/runtime-host/index.js +21 -0
  35. package/src/runtime-host/moduleRegistry.js +92 -0
  36. package/src/runtime-host/runtimeRegionStore.js +245 -0
  37. package/src/testing/browserModuleHarness.js +275 -0
  38. package/src/testing/buildWasmEdgeRunner.js +41 -2
  39. package/src/testing/index.d.ts +173 -2
  40. package/src/testing/index.js +5 -0
  41. package/src/testing/moduleHarness.js +102 -1
  42. package/src/testing/native/wasmedge_emscripten_pthread_runner.c +2319 -209
  43. package/src/testing/processInvoke.js +250 -9
  44. package/src/testing/streamInvokeCodec.js +175 -0
  45. package/src/transport/records.js +19 -6
package/README.md CHANGED
@@ -14,6 +14,8 @@ This repository is the source of truth for module-level concerns:
14
14
  - the `sds.bundle` single-file container
15
15
  - deployment authorization plus SDS publication records (`REC`, `PNM`, `ENC`)
16
16
  - the first canonical module hostcall/import ABI surface
17
+ - the canonical runtime-host model for append-only standards rows, host-managed
18
+ runtime regions, and dynamic module installation/loading
17
19
  - shared module-level testing/runtime harnesses, including the WasmEdge
18
20
  process runner used by package-level validation suites
19
21
 
@@ -36,6 +38,28 @@ specific validation suites, including conjunction replay/V&V, are expected to
36
38
  sit on top of these shared harnesses instead of defining their own runtime
37
39
  process model.
38
40
 
41
+ ## Canonical Runtime Host
42
+
43
+ The SDK now owns the durable runtime identity model used by OrbPro, browser and
44
+ server SDN hosts, and the evolving WasmEdge harness:
45
+
46
+ - standards rows are addressed only by `($SCHEMA_FILE_ID, rowId)`
47
+ - `rowId` is append-only and never reused
48
+ - aligned-binary runtime state is addressed only by `(regionId, recordIndex)`
49
+ - raw pointers remain internal execution details and are not durable APIs
50
+
51
+ The minimal host surface lives under `src/runtime-host/` and covers three
52
+ responsibilities:
53
+
54
+ - `createFlatSqlRuntimeStore()` for append-only row handles and row resolution
55
+ - `createRuntimeRegionStore()` for host-allocated aligned-binary regions and
56
+ externally backed record-view descriptors
57
+ - `createModuleRegistry()` for dynamic install/load/unload/invoke
58
+
59
+ `createRuntimeHost()` composes those stores into the canonical SDK host model.
60
+ OrbPro layers entity/view helpers on top of that host instead of inventing a
61
+ separate durable identity model.
62
+
39
63
  ## Module Artifact Model
40
64
 
41
65
  A compliant module built with this SDK is always a valid `.wasm` artifact with:
@@ -165,6 +189,11 @@ the preferred server-side target when the guest needs network-oriented runtime
165
189
  features such as sockets or TLS. Plain `wasi` remains the strict portability
166
190
  baseline; `wasmedge` is the practical higher-capability target.
167
191
 
192
+ If a manifest declares `runtimeTargets: ["browser", "wasmedge"]`, this SDK
193
+ treats that as the explicit "one binary for both" profile. That pair now
194
+ defaults to a shared `single-thread` artifact so the compiled wasm can be loaded
195
+ unchanged by the browser harness and the WasmEdge harness.
196
+
168
197
  ## WasmEdge Pthreads
169
198
 
170
199
  `space-data-module-sdk` is also the source of truth for module thread-model
@@ -173,6 +202,7 @@ selection.
173
202
  - `compileModuleFromSource({ threadModel })` accepts an explicit thread model.
174
203
  - If `threadModel` is omitted, the SDK resolves it from `manifest.runtimeTargets`.
175
204
  - `runtimeTargets: ["wasmedge"]` defaults to `emscripten-pthreads`.
205
+ - `runtimeTargets: ["browser", "wasmedge"]` defaults to `single-thread`.
176
206
  - Other targets currently default to `single-thread`.
177
207
 
178
208
  WasmEdge-targeted pthread builds do not use the embedded `sdn-emception`
@@ -190,11 +220,32 @@ If a runtime cannot interoperate with the guest pthread contract directly,
190
220
  document that as a wrapper requirement instead of changing the guest artifact
191
221
  semantics.
192
222
 
223
+ ## Browser + WasmEdge Isomorphism
224
+
225
+ The supported isomorphic profile and browser edge shims are documented in
226
+ [`docs/browser-wasmedge-isomorphic.md`](./docs/browser-wasmedge-isomorphic.md).
227
+
228
+ The checked-in same-artifact demo lives in
229
+ [`examples/isomorphic-loader`](./examples/isomorphic-loader):
230
+
231
+ - [`build-demo.mjs`](./examples/isomorphic-loader/build-demo.mjs) compiles the
232
+ shared artifact
233
+ - [`browser-demo.html`](./examples/isomorphic-loader/browser-demo.html) and
234
+ [`browser-demo.mjs`](./examples/isomorphic-loader/browser-demo.mjs) load that
235
+ artifact in the browser harness with browser edge shims
236
+ - [`wasmedge-demo.mjs`](./examples/isomorphic-loader/wasmedge-demo.mjs) loads
237
+ that same artifact in WasmEdge
238
+
193
239
  ## Testing
194
240
 
195
241
  This repo now exposes a manifest-driven harness generator from
196
242
  `space-data-module-sdk/testing` and two complementary integration suites:
197
243
 
244
+ - browser/isomorphic helpers:
245
+ - `createBrowserModuleHarness(...)`
246
+ - `detectArtifactProfile(...)`
247
+ - `loadModule(...)`
248
+
198
249
  - shared process-level helpers for command-surface runtimes:
199
250
  - `createPluginInvokeProcessClient(...)`
200
251
  - `resolveWasmEdgePluginLaunchPlan(...)`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "space-data-module-sdk",
3
- "version": "0.5.15",
3
+ "version": "0.5.19",
4
4
  "description": "Module SDK for building, validating, signing, and deploying WebAssembly modules on the Space Data Network.",
5
5
  "type": "module",
6
6
  "types": "./src/index.d.ts",
@@ -31,6 +31,15 @@
31
31
  "./deployment": "./src/deployment/index.js",
32
32
  "./invoke": "./src/invoke/index.js",
33
33
  "./runtime": "./src/runtime/index.js",
34
+ "./runtime-host": {
35
+ "types": "./src/index.d.ts",
36
+ "default": "./src/runtime-host/index.js"
37
+ },
38
+ "./host/browser": "./src/host/browserHost.js",
39
+ "./host/browser-edge-shims": "./src/host/browserEdgeShims.js",
40
+ "./host/wasi-shim": "./src/host/wasiShim.js",
41
+ "./host/isomorphic": "./src/host/isomorphicLoader.js",
42
+ "./testing/browser": "./src/testing/browserModuleHarness.js",
34
43
  "./testing": "./src/testing/index.js",
35
44
  "./standards": "./src/standards/index.js",
36
45
  "./schemas/*": "./schemas/*"
@@ -50,15 +59,15 @@
50
59
  "prepublishOnly": "npm test && npm run check:compliance"
51
60
  },
52
61
  "dependencies": {
53
- "flatc-wasm": "25.12.19-wasm.43",
54
62
  "flatbuffers": "^25.9.23",
63
+ "flatc-wasm": "25.12.19-wasm.43",
64
+ "flatsql": "^0.4.0",
55
65
  "hd-wallet-wasm": "1.6.0",
56
66
  "sdn-emception": "1.0.0",
57
67
  "spacedatastandards.org": "git+https://github.com/DigitalArsenal/spacedatastandards.org.git#09af351a1"
58
68
  },
59
69
  "devDependencies": {
60
- "express": "^4.21.2",
61
- "flatsql": "^0.4.0"
70
+ "express": "^4.21.2"
62
71
  },
63
72
  "engines": {
64
73
  "node": ">=20.0.0"
@@ -0,0 +1,53 @@
1
+ namespace orbpro.hoststorage;
2
+
3
+ table RowHandle {
4
+ schema_file_id: string (required);
5
+ row_id: uint64;
6
+ }
7
+
8
+ table RuntimeRegionRecord {
9
+ region_id: uint64;
10
+ record_index: uint32;
11
+ layout_id: string (required);
12
+ record_byte_length: uint32;
13
+ byte_length: uint32;
14
+ alignment: uint16 = 1;
15
+ bytes: [ubyte];
16
+ }
17
+
18
+ table ResolveRowViewRequest {
19
+ handle: RowHandle;
20
+ }
21
+
22
+ table ResolveRowViewResult {
23
+ handle: RowHandle;
24
+ found: bool = false;
25
+ }
26
+
27
+ table ResolveRegionRecordRequest {
28
+ region_id: uint64;
29
+ record_index: uint32;
30
+ }
31
+
32
+ table ResolveRegionRecordResult {
33
+ record: RuntimeRegionRecord;
34
+ found: bool = false;
35
+ }
36
+
37
+ table AllocateRuntimeRegionRequest {
38
+ layout_id: string (required);
39
+ record_byte_length: uint32;
40
+ alignment: uint16 = 1;
41
+ initial_record_count: uint32;
42
+ }
43
+
44
+ table AllocateRuntimeRegionResult {
45
+ region_id: uint64;
46
+ layout_id: string (required);
47
+ record_byte_length: uint32;
48
+ alignment: uint16 = 1;
49
+ record_count: uint32;
50
+ }
51
+
52
+ root_type ResolveRowViewRequest;
53
+ file_identifier "HSTR";
package/src/browser.js CHANGED
@@ -6,3 +6,9 @@ export * from "./capabilities.js";
6
6
  export * from "./deployment/index.js";
7
7
  export * from "./invoke/index.js";
8
8
  export * from "./runtime/index.js";
9
+ export * from "./host/browserHost.js";
10
+ export * from "./host/browserEdgeShims.js";
11
+ export * from "./host/wasiShim.js";
12
+ export * from "./host/abi.js";
13
+ export * from "./host/isomorphicLoader.js";
14
+ export { createBrowserModuleHarness, detectArtifactProfile } from "./testing/browserModuleHarness.js";
@@ -1,4 +1,4 @@
1
- import * as flatbuffers from "flatbuffers";
1
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
2
2
 
3
3
  import {
4
4
  CanonicalizationRuleT,
@@ -142,6 +142,9 @@ function resolveThreadModel({ manifest, threadModel } = {}) {
142
142
  .map((target) => String(target ?? "").trim().toLowerCase())
143
143
  .filter(Boolean)
144
144
  : [];
145
+ if (runtimeTargets.includes(RuntimeTarget.BROWSER)) {
146
+ return ModuleThreadModel.SINGLE_THREAD;
147
+ }
145
148
  if (runtimeTargets.includes(RuntimeTarget.WASMEDGE)) {
146
149
  return ModuleThreadModel.EMSCRIPTEN_PTHREADS;
147
150
  }
@@ -30,7 +30,6 @@ const ExternalInterfaceKindSet = new Set(Object.values(ExternalInterfaceKind));
30
30
  const ProtocolRoleSet = new Set(Object.values(ProtocolRole));
31
31
  const ProtocolTransportKindSet = new Set(Object.values(ProtocolTransportKind));
32
32
  const BrowserIncompatibleCapabilitySet = new Set([
33
- "filesystem",
34
33
  "pipe",
35
34
  "network",
36
35
  "tcp",
@@ -366,7 +365,7 @@ function validateAllowedType(type, issues, location) {
366
365
  "Allowed type fixedStringLength",
367
366
  { min: 0 },
368
367
  );
369
- validateIntegerField(
368
+ validateOptionalIntegerField(
370
369
  issues,
371
370
  type.byteLength,
372
371
  `${location}.byteLength`,
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from 'flatbuffers';
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { TypedArenaBuffer } from '../../orbpro/stream/typed-arena-buffer.js';
5
5
  /**
6
6
  * Canonical invoke envelope consumed by direct ABI and command-mode execution.
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from 'flatbuffers';
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { TypedArenaBuffer } from '../../orbpro/stream/typed-arena-buffer.js';
5
5
  /**
6
6
  * Canonical invoke result emitted by direct ABI and command-mode execution.
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from "flatbuffers";
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { FlatBufferTypeRef, } from "../../orbpro/stream/flat-buffer-type-ref.js";
5
5
  /**
6
6
  * Accepted schema family for a port.
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from "flatbuffers";
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  /**
5
5
  * Build artifact emitted by the plugin toolchain.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from "flatbuffers";
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { CapabilityKind } from "../../orbpro/manifest/capability-kind.js";
5
5
  /**
6
6
  * One host capability dependency.
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from "flatbuffers";
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { DrainPolicy } from "../../orbpro/manifest/drain-policy.js";
5
5
  import { PortManifest, } from "../../orbpro/manifest/port-manifest.js";
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from 'flatbuffers';
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { BuildArtifact } from '../../orbpro/manifest/build-artifact.js';
5
5
  import { HostCapability } from '../../orbpro/manifest/host-capability.js';
6
6
  import { MethodManifest } from '../../orbpro/manifest/method-manifest.js';
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from "flatbuffers";
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { AcceptedTypeSet, } from "../../orbpro/manifest/accepted-type-set.js";
5
5
  /**
6
6
  * One input or output port on a method.
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from "flatbuffers";
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  /**
5
5
  * Protocol handler declared by a plugin.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from "flatbuffers";
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  /**
5
5
  * Timer entry declared by a plugin.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from 'flatbuffers';
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  /**
5
5
  * Canonicalization rule applied before hashing or signature verification.
6
6
  */
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from 'flatbuffers';
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { ModuleBundleEntryRole } from '../../orbpro/module/module-bundle-entry-role.js';
5
5
  import { ModulePayloadEncoding } from '../../orbpro/module/module-payload-encoding.js';
6
6
  import { FlatBufferTypeRef } from '../../orbpro/stream/flat-buffer-type-ref.js';
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from 'flatbuffers';
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { CanonicalizationRule } from '../../orbpro/module/canonicalization-rule.js';
5
5
  import { ModuleBundleEntry } from '../../orbpro/module/module-bundle-entry.js';
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from "flatbuffers";
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { PayloadWireFormat } from "../../orbpro/stream/payload-wire-format.js";
5
5
  function normalizePayloadWireFormat(value) {
6
6
  if (value === PayloadWireFormat.ALIGNED_BINARY) {
@@ -1,6 +1,6 @@
1
1
  // automatically generated by the FlatBuffers compiler, do not modify
2
2
  /* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
3
- import * as flatbuffers from "flatbuffers";
3
+ import * as flatbuffers from "flatbuffers/mjs/flatbuffers.js";
4
4
  import { BufferMutability } from "../../orbpro/stream/buffer-mutability.js";
5
5
  import { BufferOwnership } from "../../orbpro/stream/buffer-ownership.js";
6
6
  import { FlatBufferTypeRef, } from "../../orbpro/stream/flat-buffer-type-ref.js";