space-data-module-sdk 0.8.3 → 0.8.5

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 (354) hide show
  1. package/README.md +117 -20
  2. package/bin/space-data-module.js +263 -0
  3. package/docs/.nojekyll +1 -0
  4. package/docs/AGENTS.md +34 -0
  5. package/docs/architecture.svg +141 -0
  6. package/docs/browser-wasmedge-isomorphic.md +179 -0
  7. package/docs/flatsql-streaming-standard.md +341 -0
  8. package/docs/gpu-module-abi.md +193 -0
  9. package/docs/index.html +125 -0
  10. package/docs/isomorphic-pthreads.md +188 -0
  11. package/docs/isomorphic-sdn-runtime-plan.md +167 -0
  12. package/docs/language-runtime-matrix.md +82 -0
  13. package/docs/manifest-structure.svg +114 -0
  14. package/docs/module-bundle-runtime-plan.md +19 -0
  15. package/docs/module-lifecycle.svg +70 -0
  16. package/docs/module-publication-standard.md +540 -0
  17. package/docs/node-red-default-node-parity.md +88 -0
  18. package/docs/protocol-installation.md +196 -0
  19. package/docs/secrets-capability.md +152 -0
  20. package/docs/styles.css +288 -0
  21. package/docs/testing-harness.md +408 -0
  22. package/docs/tri-runtime-parity.md +132 -0
  23. package/docs/wallet-callback.html +2 -0
  24. package/package.json +26 -6
  25. package/schemas/HttpRequestAbi.fbs +41 -0
  26. package/schemas/HttpResponseAbi.fbs +36 -0
  27. package/schemas/PluginManifest.fbs +2 -1
  28. package/src/AGENTS.md +1 -1
  29. package/src/app/codec.js +548 -0
  30. package/src/app/index.js +6 -0
  31. package/src/browser.js +5 -0
  32. package/src/bundle/constants.js +1 -0
  33. package/src/bundle/index.js +15 -0
  34. package/src/bundle/sigdomain.js +179 -0
  35. package/src/bundle/signing.js +767 -0
  36. package/src/bundle/wasm.js +3 -2
  37. package/src/capabilities.js +3 -0
  38. package/src/compat/index.js +7 -0
  39. package/src/compat/sdnLegacy.js +449 -0
  40. package/src/compiler/compileModule.js +556 -55
  41. package/src/compiler/flatcSupport.js +41 -27
  42. package/src/compiler/index.d.ts +2 -0
  43. package/src/compiler/index.js +18 -0
  44. package/src/compiler/invokeGlue.js +1212 -183
  45. package/src/compiler/pthreadArtifactGuard.js +910 -0
  46. package/src/compiler/sdnShimGenerator.js +323 -0
  47. package/src/compiler/wasiThreadsToolchain.js +150 -0
  48. package/src/compliance/index.js +11 -1
  49. package/src/compliance/legacyWildcardPorts.js +228 -0
  50. package/src/compliance/pluginCompliance.js +1000 -96
  51. package/src/field-stream/index.d.ts +31 -0
  52. package/src/field-stream/index.js +119 -0
  53. package/src/flow/dependencyStreamBridge.js +234 -0
  54. package/src/flow/flatsqlLinkShim.js +304 -0
  55. package/src/flow/flowCodec.js +107 -0
  56. package/src/flow/flowCompiler.js +2900 -0
  57. package/src/flow/flowRuntimeHost.js +877 -0
  58. package/src/flow/index.d.ts +117 -0
  59. package/src/flow/index.js +31 -0
  60. package/src/flow/isomorphicFlowHost.js +384 -0
  61. package/src/flow/jsFlowRuntime.js +275 -0
  62. package/src/flow/normalize.js +294 -0
  63. package/src/flow/runtime-src/flow_runtime.cpp +1699 -0
  64. package/src/flow/vendor/sdn-flow/MethodRegistry.js +400 -0
  65. package/src/flow/vendor/sdn-flow/constants.js +39 -0
  66. package/src/flow/vendor/sdn-flow/index.js +29 -0
  67. package/src/flow/vendor/sdn-flow/normalize.js +506 -0
  68. package/src/flow/vendor/sdn-flow/wasmCompatibility.js +189 -0
  69. package/src/generated/http/cpp/HttpRequestAbi_generated.h +285 -0
  70. package/src/generated/http/cpp/HttpResponseAbi_generated.h +192 -0
  71. package/src/generated/http/sdn/http/http-header.js +53 -0
  72. package/src/generated/http/sdn/http/http-header.ts +67 -0
  73. package/src/generated/http/sdn/http/http-request.js +132 -0
  74. package/src/generated/http/sdn/http/http-request.ts +179 -0
  75. package/src/generated/http/sdn/http/http-response.js +144 -0
  76. package/src/generated/http/sdn/http/http-response.ts +168 -0
  77. package/src/generated/http/sdn/http.js +11 -0
  78. package/src/generated/http/sdn/http.ts +4 -0
  79. package/src/generated/orbpro/flow/backpressure-policy.d.ts +12 -0
  80. package/src/generated/orbpro/flow/backpressure-policy.d.ts.map +1 -0
  81. package/src/generated/orbpro/flow/backpressure-policy.js +17 -0
  82. package/src/generated/orbpro/flow/backpressure-policy.js.map +1 -0
  83. package/src/generated/orbpro/flow/backpressure-policy.ts +15 -0
  84. package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts +142 -0
  85. package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts.map +1 -0
  86. package/src/generated/orbpro/flow/flow-bundle-manifest.js +304 -0
  87. package/src/generated/orbpro/flow/flow-bundle-manifest.js.map +1 -0
  88. package/src/generated/orbpro/flow/flow-bundle-manifest.ts +399 -0
  89. package/src/generated/orbpro/flow/flow-edge.d.ts +113 -0
  90. package/src/generated/orbpro/flow/flow-edge.d.ts.map +1 -0
  91. package/src/generated/orbpro/flow/flow-edge.js +221 -0
  92. package/src/generated/orbpro/flow/flow-edge.js.map +1 -0
  93. package/src/generated/orbpro/flow/flow-edge.ts +292 -0
  94. package/src/generated/orbpro/flow/flow-node.d.ts +80 -0
  95. package/src/generated/orbpro/flow/flow-node.d.ts.map +1 -0
  96. package/src/generated/orbpro/flow/flow-node.js +158 -0
  97. package/src/generated/orbpro/flow/flow-node.js.map +1 -0
  98. package/src/generated/orbpro/flow/flow-node.ts +202 -0
  99. package/src/generated/orbpro/flow/flow-program.d.ts +164 -0
  100. package/src/generated/orbpro/flow/flow-program.d.ts.map +1 -0
  101. package/src/generated/orbpro/flow/flow-program.js +350 -0
  102. package/src/generated/orbpro/flow/flow-program.js.map +1 -0
  103. package/src/generated/orbpro/flow/flow-program.ts +477 -0
  104. package/src/generated/orbpro/flow/flow-trigger.d.ts +108 -0
  105. package/src/generated/orbpro/flow/flow-trigger.d.ts.map +1 -0
  106. package/src/generated/orbpro/flow/flow-trigger.js +207 -0
  107. package/src/generated/orbpro/flow/flow-trigger.js.map +1 -0
  108. package/src/generated/orbpro/flow/flow-trigger.ts +276 -0
  109. package/src/generated/orbpro/flow/node-kind.d.ts +13 -0
  110. package/src/generated/orbpro/flow/node-kind.d.ts.map +1 -0
  111. package/src/generated/orbpro/flow/node-kind.js +16 -0
  112. package/src/generated/orbpro/flow/node-kind.js.map +1 -0
  113. package/src/generated/orbpro/{invoke.ts → flow/node-kind.ts} +12 -2
  114. package/src/generated/orbpro/flow/plugin-version-binding.d.ts +52 -0
  115. package/src/generated/orbpro/flow/plugin-version-binding.d.ts.map +1 -0
  116. package/src/generated/orbpro/flow/plugin-version-binding.js +85 -0
  117. package/src/generated/orbpro/flow/plugin-version-binding.js.map +1 -0
  118. package/src/generated/orbpro/flow/plugin-version-binding.ts +121 -0
  119. package/src/generated/orbpro/flow/schema-hash-binding.d.ts +70 -0
  120. package/src/generated/orbpro/flow/schema-hash-binding.d.ts.map +1 -0
  121. package/src/generated/orbpro/flow/schema-hash-binding.js +143 -0
  122. package/src/generated/orbpro/flow/schema-hash-binding.js.map +1 -0
  123. package/src/generated/orbpro/flow/schema-hash-binding.ts +189 -0
  124. package/src/generated/orbpro/flow/trigger-binding.d.ts +71 -0
  125. package/src/generated/orbpro/flow/trigger-binding.d.ts.map +1 -0
  126. package/src/generated/orbpro/flow/trigger-binding.js +142 -0
  127. package/src/generated/orbpro/flow/trigger-binding.js.map +1 -0
  128. package/src/generated/orbpro/flow/trigger-binding.ts +181 -0
  129. package/src/generated/orbpro/flow/trigger-kind.d.ts +14 -0
  130. package/src/generated/orbpro/flow/trigger-kind.d.ts.map +1 -0
  131. package/src/generated/orbpro/flow/trigger-kind.js +17 -0
  132. package/src/generated/orbpro/flow/trigger-kind.js.map +1 -0
  133. package/src/generated/orbpro/flow/trigger-kind.ts +17 -0
  134. package/src/generated/orbpro/flow.d.ts +21 -0
  135. package/src/generated/orbpro/flow.d.ts.map +1 -0
  136. package/src/generated/orbpro/flow.js +23 -0
  137. package/src/generated/orbpro/flow.js.map +1 -0
  138. package/src/generated/orbpro/flow.ts +24 -0
  139. package/src/generated/orbpro/manifest/capability-kind.d.ts +2 -1
  140. package/src/generated/orbpro/manifest/capability-kind.js +1 -0
  141. package/src/generated/orbpro/manifest/capability-kind.ts +1 -0
  142. package/src/generated/orbpro/plugin/stream-invoke-request.d.ts +93 -0
  143. package/src/generated/orbpro/plugin/stream-invoke-request.js +160 -0
  144. package/src/generated/orbpro/plugin/stream-invoke-request.ts +211 -0
  145. package/src/generated/orbpro/plugin/stream-invoke-response.d.ts +99 -0
  146. package/src/generated/orbpro/plugin/stream-invoke-response.js +175 -0
  147. package/src/generated/orbpro/plugin/stream-invoke-response.ts +226 -0
  148. package/src/generated/orbpro/plugin.js +8 -0
  149. package/src/generated/orbpro/stream.d.ts +12 -0
  150. package/src/generated/orbpro/stream.js +14 -0
  151. package/src/generated/orbpro/stream.ts +15 -0
  152. package/src/generated/spacedatastandards/plg/EntryFunction.d.ts +52 -0
  153. package/src/generated/spacedatastandards/plg/EntryFunction.d.ts.map +1 -0
  154. package/src/generated/spacedatastandards/plg/EntryFunction.js +106 -0
  155. package/src/generated/spacedatastandards/plg/EntryFunction.ts +162 -0
  156. package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts +90 -0
  157. package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts.map +1 -0
  158. package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.js +189 -0
  159. package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.ts +270 -0
  160. package/src/generated/spacedatastandards/plg/PLG.d.ts +492 -0
  161. package/src/generated/spacedatastandards/plg/PLG.d.ts.map +1 -0
  162. package/src/generated/spacedatastandards/plg/PLG.js +1139 -0
  163. package/src/generated/spacedatastandards/plg/PLG.ts +1600 -0
  164. package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts +63 -0
  165. package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts.map +1 -0
  166. package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.js +138 -0
  167. package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.ts +189 -0
  168. package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts +41 -0
  169. package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts.map +1 -0
  170. package/src/generated/spacedatastandards/plg/PLGBuildArtifact.js +104 -0
  171. package/src/generated/spacedatastandards/plg/PLGBuildArtifact.ts +151 -0
  172. package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts +68 -0
  173. package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts.map +1 -0
  174. package/src/generated/spacedatastandards/plg/PLGFlowEdge.js +124 -0
  175. package/src/generated/spacedatastandards/plg/PLGFlowEdge.ts +184 -0
  176. package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts +58 -0
  177. package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts.map +1 -0
  178. package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.js +126 -0
  179. package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.ts +161 -0
  180. package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts +82 -0
  181. package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts.map +1 -0
  182. package/src/generated/spacedatastandards/plg/PLGFlowNode.js +164 -0
  183. package/src/generated/spacedatastandards/plg/PLGFlowNode.ts +244 -0
  184. package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts +55 -0
  185. package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts.map +1 -0
  186. package/src/generated/spacedatastandards/plg/PLGFlowTrigger.js +105 -0
  187. package/src/generated/spacedatastandards/plg/PLGFlowTrigger.ts +162 -0
  188. package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts +42 -0
  189. package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts.map +1 -0
  190. package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.js +83 -0
  191. package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.ts +127 -0
  192. package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts +36 -0
  193. package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts.map +1 -0
  194. package/src/generated/spacedatastandards/plg/PLGHostCapability.js +90 -0
  195. package/src/generated/spacedatastandards/plg/PLGHostCapability.ts +127 -0
  196. package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts +53 -0
  197. package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts.map +1 -0
  198. package/src/generated/spacedatastandards/plg/PLGMethodManifest.js +153 -0
  199. package/src/generated/spacedatastandards/plg/PLGMethodManifest.ts +210 -0
  200. package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts +70 -0
  201. package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts.map +1 -0
  202. package/src/generated/spacedatastandards/plg/PLGPortManifest.js +149 -0
  203. package/src/generated/spacedatastandards/plg/PLGPortManifest.ts +212 -0
  204. package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts +73 -0
  205. package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts.map +1 -0
  206. package/src/generated/spacedatastandards/plg/PLGProtocolSpec.js +199 -0
  207. package/src/generated/spacedatastandards/plg/PLGProtocolSpec.ts +292 -0
  208. package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts +40 -0
  209. package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts.map +1 -0
  210. package/src/generated/spacedatastandards/plg/PLGTimerSpec.js +103 -0
  211. package/src/generated/spacedatastandards/plg/PLGTimerSpec.ts +148 -0
  212. package/src/generated/spacedatastandards/plg/PluginCapability.d.ts +41 -0
  213. package/src/generated/spacedatastandards/plg/PluginCapability.d.ts.map +1 -0
  214. package/src/generated/spacedatastandards/plg/PluginCapability.js +82 -0
  215. package/src/generated/spacedatastandards/plg/{plugin-capability.ts → PluginCapability.ts} +55 -18
  216. package/src/generated/spacedatastandards/plg/PluginDependency.d.ts +42 -0
  217. package/src/generated/spacedatastandards/plg/PluginDependency.d.ts.map +1 -0
  218. package/src/generated/spacedatastandards/plg/PluginDependency.js +80 -0
  219. package/src/generated/spacedatastandards/plg/PluginDependency.ts +124 -0
  220. package/src/generated/spacedatastandards/plg/TAB.d.ts +85 -0
  221. package/src/generated/spacedatastandards/plg/TAB.d.ts.map +1 -0
  222. package/src/generated/spacedatastandards/plg/TAB.js +173 -0
  223. package/src/generated/spacedatastandards/plg/TAB.ts +228 -0
  224. package/src/generated/spacedatastandards/plg/bufferMutability.d.ts +18 -0
  225. package/src/generated/spacedatastandards/plg/bufferMutability.d.ts.map +1 -0
  226. package/src/generated/spacedatastandards/plg/bufferMutability.js +20 -0
  227. package/src/generated/spacedatastandards/plg/bufferMutability.ts +23 -0
  228. package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts +18 -0
  229. package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts.map +1 -0
  230. package/src/generated/spacedatastandards/plg/bufferOwnership.js +20 -0
  231. package/src/generated/spacedatastandards/plg/bufferOwnership.ts +23 -0
  232. package/src/generated/spacedatastandards/plg/drainBehavior.d.ts +20 -0
  233. package/src/generated/spacedatastandards/plg/drainBehavior.d.ts.map +1 -0
  234. package/src/generated/spacedatastandards/plg/drainBehavior.js +22 -0
  235. package/src/generated/spacedatastandards/plg/drainBehavior.ts +25 -0
  236. package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts +10 -0
  237. package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts.map +1 -0
  238. package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.js +12 -0
  239. package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.ts +13 -0
  240. package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts +51 -0
  241. package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts.map +1 -0
  242. package/src/generated/spacedatastandards/plg/hostCapabilityKind.js +53 -0
  243. package/src/generated/spacedatastandards/plg/hostCapabilityKind.ts +55 -0
  244. package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts +15 -0
  245. package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts.map +1 -0
  246. package/src/generated/spacedatastandards/plg/invokeSurfaceKind.js +17 -0
  247. package/src/generated/spacedatastandards/plg/invokeSurfaceKind.ts +19 -0
  248. package/src/generated/spacedatastandards/plg/main.d.ts +29 -0
  249. package/src/generated/spacedatastandards/plg/main.d.ts.map +1 -0
  250. package/src/generated/spacedatastandards/plg/main.js +30 -0
  251. package/src/generated/spacedatastandards/plg/main.ts +32 -0
  252. package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts +17 -0
  253. package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts.map +1 -0
  254. package/src/generated/spacedatastandards/plg/payloadWireFormat.js +19 -0
  255. package/src/generated/spacedatastandards/plg/payloadWireFormat.ts +21 -0
  256. package/src/generated/spacedatastandards/plg/pluginCategory.d.ts +82 -0
  257. package/src/generated/spacedatastandards/plg/pluginCategory.d.ts.map +1 -0
  258. package/src/generated/spacedatastandards/plg/pluginCategory.js +84 -0
  259. package/src/generated/spacedatastandards/plg/pluginCategory.ts +103 -0
  260. package/src/generated/spacedatastandards/plg/publicationState.d.ts +18 -0
  261. package/src/generated/spacedatastandards/plg/publicationState.d.ts.map +1 -0
  262. package/src/generated/spacedatastandards/plg/publicationState.js +20 -0
  263. package/src/generated/spacedatastandards/plg/purchaseTier.d.ts +18 -0
  264. package/src/generated/spacedatastandards/plg/purchaseTier.d.ts.map +1 -0
  265. package/src/generated/spacedatastandards/plg/purchaseTier.js +20 -0
  266. package/src/host/AGENTS.md +2 -2
  267. package/src/host/abi.js +53 -66
  268. package/src/host/browserHost.js +355 -8
  269. package/src/host/cpp/keyslotClient.hpp +231 -0
  270. package/src/host/cpp/secretsClient.hpp +583 -0
  271. package/src/host/hostcallWire.js +183 -0
  272. package/src/host/index.js +2 -0
  273. package/src/host/isomorphicLoader.js +44 -7
  274. package/src/host/nodeHost.js +227 -8
  275. package/src/host/sabHostcallChannel.js +206 -0
  276. package/src/host/timerDriver.js +203 -0
  277. package/src/host/wasiShim.js +41 -1
  278. package/src/host/wasiThreadBrowserWorker.mjs +48 -0
  279. package/src/host/wasiThreadHost.js +393 -0
  280. package/src/host/wasiThreadWorker.mjs +32 -0
  281. package/src/host/wasiThreadWorkerRuntime.js +93 -0
  282. package/src/http/index.js +339 -0
  283. package/src/index.d.ts +716 -10
  284. package/src/index.js +4 -0
  285. package/src/invoke/codec.js +1202 -128
  286. package/src/invoke/index.js +5 -1
  287. package/src/licensing/index.d.ts +2 -0
  288. package/src/licensing/index.js +2 -0
  289. package/src/licensing/records.js +287 -8
  290. package/src/manifest/codec.js +62 -14
  291. package/src/manifest/index.js +2 -0
  292. package/src/manifest/legacyToPlg.js +164 -25
  293. package/src/manifest/normalize.js +1 -0
  294. package/src/manifest/plgCodec.js +1303 -62
  295. package/src/manifest/typeRefs.js +162 -24
  296. package/src/runtime/compiledRuntimeAbi.js +47 -0
  297. package/src/runtime/compiledRuntimeAbi.json +33 -0
  298. package/src/runtime/index.d.ts +32 -0
  299. package/src/runtime/index.js +1 -0
  300. package/src/runtime-host/index.js +3 -0
  301. package/src/runtime-host/methodRegistry.js +55 -0
  302. package/src/standards/index.js +200 -56
  303. package/src/standards/sharedCatalog.js +16 -0
  304. package/src/testing/browserModuleHarness.js +604 -31
  305. package/src/testing/docker/wasmedge-parity.Dockerfile +39 -0
  306. package/src/testing/index.d.ts +151 -0
  307. package/src/testing/index.js +21 -0
  308. package/src/testing/native/wasmedge_emscripten_pthread_runner.c +25 -1
  309. package/src/testing/parityBrowserRunner.js +138 -0
  310. package/src/testing/parityHarness.js +616 -0
  311. package/src/testing/parityLanes.js +537 -0
  312. package/src/testing/processInvoke.js +29 -21
  313. package/src/testing/streamInvokeCodec.js +10 -175
  314. package/src/testing/wasmedgePin.json +6 -0
  315. package/src/testing/workerModuleHarness.js +242 -0
  316. package/src/testing/workerModuleHarnessWorker.js +176 -0
  317. package/src/transport/index.js +3 -0
  318. package/src/transport/pki.js +299 -11
  319. package/src/transport/records.js +16 -7
  320. package/src/utils/ecdsaDer.js +106 -0
  321. package/src/utils/wasmCrypto.js +0 -43
  322. package/templates/gpu-module/README.md +48 -0
  323. package/templates/gpu-module/include/space_data_gpu_abi.h +122 -0
  324. package/templates/gpu-module/manifest.json +84 -0
  325. package/schemas/PluginInvokeRequest.fbs +0 -18
  326. package/schemas/PluginInvokeResponse.fbs +0 -30
  327. package/schemas/spacedatastandards/PLG.fbs +0 -191
  328. package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts +0 -51
  329. package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts.map +0 -1
  330. package/src/generated/orbpro/invoke/plugin-invoke-request.js +0 -131
  331. package/src/generated/orbpro/invoke/plugin-invoke-request.js.map +0 -1
  332. package/src/generated/orbpro/invoke/plugin-invoke-request.ts +0 -173
  333. package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts +0 -76
  334. package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts.map +0 -1
  335. package/src/generated/orbpro/invoke/plugin-invoke-response.js +0 -184
  336. package/src/generated/orbpro/invoke/plugin-invoke-response.js.map +0 -1
  337. package/src/generated/orbpro/invoke/plugin-invoke-response.ts +0 -243
  338. package/src/generated/orbpro/invoke.d.ts +0 -3
  339. package/src/generated/orbpro/invoke.js +0 -5
  340. package/src/generated/spacedatastandards/plg/entry-function.js +0 -86
  341. package/src/generated/spacedatastandards/plg/entry-function.ts +0 -119
  342. package/src/generated/spacedatastandards/plg/index.js +0 -16
  343. package/src/generated/spacedatastandards/plg/index.ts +0 -11
  344. package/src/generated/spacedatastandards/plg/plg.js +0 -657
  345. package/src/generated/spacedatastandards/plg/plg.ts +0 -924
  346. package/src/generated/spacedatastandards/plg/plugin-capability.js +0 -66
  347. package/src/generated/spacedatastandards/plg/plugin-category.js +0 -15
  348. package/src/generated/spacedatastandards/plg/plugin-category.ts +0 -53
  349. package/src/generated/spacedatastandards/plg/plugin-dependency.js +0 -63
  350. package/src/generated/spacedatastandards/plg/plugin-dependency.ts +0 -86
  351. package/src/generated/spacedatastandards/plg/publication-state.js +0 -9
  352. package/src/generated/spacedatastandards/plg/purchase-tier.js +0 -9
  353. /package/src/generated/spacedatastandards/plg/{publication-state.ts → publicationState.ts} +0 -0
  354. /package/src/generated/spacedatastandards/plg/{purchase-tier.ts → purchaseTier.ts} +0 -0
@@ -0,0 +1,193 @@
1
+ # GPU Module ABI
2
+
3
+ This document defines the SDK-level standard for modules that can use GPU
4
+ compute acceleration while remaining portable across browser and WasmEdge
5
+ module runtimes.
6
+
7
+ ## Scope
8
+
9
+ The standard covers:
10
+
11
+ - the manifest capability used by module authors
12
+ - the host-owned async dispatch boundary used by browsers and native hosts
13
+ - the C/C++ layout header shared by module code, browser adapters, and native
14
+ Dawn-backed hosts
15
+ - the artifact layout for portable CPU fallback plus optional GPU adapters
16
+
17
+ It does not add a new SDS FlatBuffer schema or a new `space_data_module_host`
18
+ sync import. GPU dispatch is asynchronous in browser WebGPU and must stay
19
+ outside the current sync guest hostcall bridge.
20
+
21
+ ## Capability
22
+
23
+ GPU-capable modules declare the coarse capability id:
24
+
25
+ ```json
26
+ {
27
+ "capability": "gpu_compute",
28
+ "scope": "webgpu.v1",
29
+ "required": false,
30
+ "description": "Optional WebGPU/Dawn compute acceleration."
31
+ }
32
+ ```
33
+
34
+ Use `required: false` unless the module has no correct CPU path. A missing GPU
35
+ adapter must degrade to the module's CPU implementation, not to an incomplete
36
+ result.
37
+
38
+ The `gpu_compute` id is part of the SDK recommended capability vocabulary. The
39
+ typed PLG `HOST_CAPABILITIES` enum cannot carry a dedicated GPU enum value
40
+ until the canonical standards schema adds one. Until that SDS change lands,
41
+ module manifests should use the string/object capability form above and avoid
42
+ claiming a typed PLG host capability enum for GPU.
43
+
44
+ ## Artifact Layout
45
+
46
+ The canonical portable artifact remains:
47
+
48
+ ```text
49
+ dist/isomorphic/module.wasm
50
+ ```
51
+
52
+ That artifact must be valid without GPU access. Optional GPU adapters belong
53
+ outside the shared guest binary:
54
+
55
+ ```text
56
+ dist/browser/module.js
57
+ dist/browser/module.wasm
58
+ dist/wasmedge/gpu-host.{so,dylib,dll}
59
+ ```
60
+
61
+ The browser adapter owns the browser `GPUDevice`. The WasmEdge host extension
62
+ owns the native Dawn instance/device. The guest module owns correctness,
63
+ fallback, exact refinement, and final result validation.
64
+
65
+ ## ABI Layers
66
+
67
+ ### 1. Data Layout ABI
68
+
69
+ The reusable C/C++ header is:
70
+
71
+ ```text
72
+ templates/gpu-module/include/space_data_gpu_abi.h
73
+ ```
74
+
75
+ It defines:
76
+
77
+ - `SDN_GPU_ABI_VERSION`
78
+ - the `gpu_compute` capability id and `webgpu.v1` scope
79
+ - status codes
80
+ - backend and buffer role enums
81
+ - split `f64` helpers using high/low `f32`
82
+ - packed dispatch/result descriptors
83
+
84
+ All multi-byte fields are little-endian in serialized buffers. Structs in the
85
+ header are fixed-width and intentionally avoid owning pointers. Pointers are
86
+ runtime-local implementation details and must not appear in durable manifests,
87
+ publication metadata, or cross-process descriptors.
88
+
89
+ ### 2. Host Dispatch ABI
90
+
91
+ The canonical operation is:
92
+
93
+ ```text
94
+ gpu_compute.dispatch.v1
95
+ ```
96
+
97
+ The host adapter receives:
98
+
99
+ - an ABI version
100
+ - a stable kernel id
101
+ - storage/uniform buffer descriptors
102
+ - little-endian input bytes
103
+ - requested workgroup counts
104
+ - declared output buffer sizes
105
+
106
+ The host adapter returns:
107
+
108
+ - a status code
109
+ - backend metadata (`browser-webgpu`, `dawn-native`, or `cpu-fallback`)
110
+ - output buffer bytes
111
+ - optional counters such as candidates emitted, overflow count, and elapsed
112
+ device time
113
+
114
+ Browser and native hosts may expose this through their existing async
115
+ capability adapter registries. A shared browser/WasmEdge guest must not depend
116
+ on raw asynchronous wasm imports for this operation.
117
+
118
+ ### 3. Module-Level API
119
+
120
+ Module methods should keep the public invoke contract domain-specific. For
121
+ example, a conjunction assessment module should expose conjunction assessment
122
+ request/response ports, not generic WebGPU command buffers.
123
+
124
+ The GPU dispatch boundary is an implementation detail between the host runtime
125
+ and the module/adapter pair. Hosts may precompute a GPU broadphase and pass
126
+ coarse hits into the guest, or they may let a browser-specific adapter call the
127
+ guest's exact refinement entry points after dispatch.
128
+
129
+ ## Browser Backend
130
+
131
+ Browser adapters use WebGPU through browser APIs or Emscripten's WebGPU/Dawn
132
+ surface. They must:
133
+
134
+ - request and cache the `GPUAdapter` and `GPUDevice`
135
+ - validate device limits before accepting a dispatch
136
+ - compile WGSL from a module-owned or SDK-owned source string
137
+ - copy results back through mapped buffers or equivalent browser APIs
138
+ - return a CPU fallback status when WebGPU is unavailable
139
+
140
+ Browser WebGPU setup and buffer mapping are asynchronous. Do not model them as
141
+ sync `space_data_module_host` calls.
142
+
143
+ ## WasmEdge Backend
144
+
145
+ WasmEdge deployments that need GPU acceleration should use a native host
146
+ extension linked against Dawn. The native host implements the same
147
+ `gpu_compute.dispatch.v1` operation and uses the same C/C++ layout header.
148
+
149
+ The shared module artifact should still be loadable without that extension. A
150
+ pure `["wasmedge"]` artifact may choose a higher-capability native host profile,
151
+ but a `["browser", "wasmedge"]` artifact must retain the portable fallback
152
+ contract documented in `docs/browser-wasmedge-isomorphic.md`.
153
+
154
+ ## Numerical Rules
155
+
156
+ GPU kernels that need double-like position precision should use split high/low
157
+ `f32` values:
158
+
159
+ ```c
160
+ SdnGpuSplitF64 x = sdn_gpu_split_f64(x_km);
161
+ ```
162
+
163
+ For orbital screening, store position components in kilometers unless a module
164
+ contract states otherwise. The high component is the nearest `f32`; the low
165
+ component is the residual:
166
+
167
+ ```text
168
+ hi = f32(value)
169
+ lo = f32(value - f64(hi))
170
+ ```
171
+
172
+ GPU broadphase kernels must be conservative. They may emit extra candidates,
173
+ but they must not drop candidates that the CPU exact path would refine. Exact
174
+ TCA, probability, and final acceptance logic remain in the CPU double-precision
175
+ module path unless a module ships a separately validated exact GPU algorithm.
176
+
177
+ ## Template
178
+
179
+ Start new GPU-capable modules from:
180
+
181
+ ```text
182
+ templates/gpu-module/
183
+ ```
184
+
185
+ The template contains:
186
+
187
+ - `include/space_data_gpu_abi.h`: reusable C/C++ ABI layout header
188
+ - `manifest.json`: manifest fragment showing `gpu_compute`
189
+ - `README.md`: integration notes for browser WebGPU and WasmEdge/Dawn hosts
190
+
191
+ Use the template as a layout and ABI starting point. Real module repos should
192
+ still define domain-specific FlatBuffer request/response schemas and must keep
193
+ their canonical compiled artifact at `dist/isomorphic/module.wasm`.
@@ -0,0 +1,125 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <meta name="description" content="Space Data Module SDK documentation for building, validating, signing, and deploying WebAssembly modules on the Space Data Network." />
7
+ <title>Space Data Module SDK</title>
8
+ <link rel="stylesheet" href="./styles.css" />
9
+ <!-- SDN_CONSUMER_ASSETS_START -->
10
+ <link rel="stylesheet" href="https://static.spacedatanetwork.org/assets/hd-wallet-ui/2.0.28/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" crossorigin="anonymous">
11
+ <script defer src="https://static.spacedatanetwork.org/assets/hd-wallet-ui/2.0.28/sdn-wallet-public-client.f611e7e151a3b5c38384272f8894a4c6634f0a29bf925b0e02e0e27f8db0bfff.js" integrity="sha384-R+QqsKoWJIS7iWrtPmgJ49DVnb1hSGjZokupbLInJd1PLp8RwQhtF/hnaerc33ci" crossorigin="anonymous" data-sdn-wallet-public-client="v1"></script>
12
+ <script defer src="https://static.spacedatanetwork.org/assets/sdn-stack-nav/1.0.0/sdn-stack-nav.52fde607eee38ffa116188201f50258ed50bd18c9f06c1af9678f763147a8fe5.js" integrity="sha384-dgeojhJ8vTszHXIbv7O7nZcEzqD10oUYYJjBmPrV7+kLQEUlXLQD4ek5Q7HOFiO5" crossorigin="anonymous" data-nav-style-url="https://static.spacedatanetwork.org/assets/sdn-stack-nav/1.0.0/sdn-stack-nav.36a36359ce18322185e9ff179f88175bab67d5ad84a14d9c08a54f2ff27267e7.css" data-nav-style-integrity="sha384-c4M8Fg+kYaeOYYtJVr7jJsde24IhSWkWaRyAOHEZU9jozhRck089aw+mnHwxymds" data-wallet-client-url="https://static.spacedatanetwork.org/assets/hd-wallet-ui/2.0.28/sdn-wallet-public-client.f611e7e151a3b5c38384272f8894a4c6634f0a29bf925b0e02e0e27f8db0bfff.js" data-wallet-client-integrity="sha384-R+QqsKoWJIS7iWrtPmgJ49DVnb1hSGjZokupbLInJd1PLp8RwQhtF/hnaerc33ci" data-wallet-style-url="https://static.spacedatanetwork.org/assets/hd-wallet-ui/2.0.28/sdn-wallet-public-client.c3f68d1cfd88478f10d836a5e829d1dfc6a10157972cf0f7d4d319d0636f2cc4.css" data-wallet-style-integrity="sha384-fICuhN4I9xqOK1F5vGGzl26opuO+xQIvTZXMSV76lWTBiQ6AfzztMGLLDw8yRT8i" data-wallet-client-id="sdn-module-sdk-pages-v1" data-wallet-callback-uri="https://digitalarsenal.github.io/space-data-module-sdk/wallet-callback.html" data-wallet-registry-sha256="e1ce6fe903c9700484a8a87d96581c8cad97063dabf63030b4518a31a3bdaa93"></script>
13
+ <!-- SDN_CONSUMER_ASSETS_END -->
14
+ </head>
15
+ <body>
16
+ <sdn-stack-nav active="module-sdk"></sdn-stack-nav>
17
+ <header class="site-header">
18
+ <a class="site-brand" href="./">Space Data Module SDK</a>
19
+ <a class="stack-button" href="#stack">Stack</a>
20
+ </header>
21
+
22
+ <main>
23
+ <section class="hero" aria-labelledby="page-title">
24
+ <div class="hero-copy">
25
+ <p class="eyebrow">Space Data Network</p>
26
+ <h1 id="page-title">Space Data Module SDK</h1>
27
+ <p class="lede">
28
+ Build portable WebAssembly modules with embedded FlatBuffer manifests,
29
+ standards-aware validation, browser and WasmEdge harnesses, and signed
30
+ delivery records for SDN hosts.
31
+ </p>
32
+ <div class="actions" aria-label="Primary links">
33
+ <a class="button primary" href="https://github.com/DigitalArsenal/space-data-module-sdk">GitHub</a>
34
+ <a class="button" href="./module-publication-standard.md">Publication Standard</a>
35
+ <a class="button" href="./testing-harness.md">Testing Harness</a>
36
+ </div>
37
+ </div>
38
+ <figure class="architecture">
39
+ <img src="./architecture.svg" alt="Module architecture overview" />
40
+ </figure>
41
+ </section>
42
+
43
+ <section class="quick-grid" aria-label="SDK capabilities">
44
+ <article>
45
+ <h2>Author</h2>
46
+ <p>Start from the examples and declare module methods, ports, runtime targets, and standards references in one manifest.</p>
47
+ </article>
48
+ <article>
49
+ <h2>Validate</h2>
50
+ <p>Check manifests and wasm artifacts against the SDK contract, exported ABI symbols, and canonical SDS type names.</p>
51
+ </article>
52
+ <article>
53
+ <h2>Package</h2>
54
+ <p>Append REC and MBL bundle metadata, attach publication records, and keep module artifacts single-file deployable.</p>
55
+ </article>
56
+ <article>
57
+ <h2>Run</h2>
58
+ <p>Exercise the same module through browser, Node, process, and WasmEdge harnesses before publishing to SDN hosts.</p>
59
+ </article>
60
+ </section>
61
+
62
+ <section class="docs-list" aria-labelledby="docs-title">
63
+ <div class="section-head">
64
+ <p class="eyebrow">Reference</p>
65
+ <h2 id="docs-title">Core Documents</h2>
66
+ </div>
67
+ <div class="link-list">
68
+ <a href="./module-publication-standard.md">
69
+ <span>Module Publication Standard</span>
70
+ <small>Manifest, REC, MBL, PNM, and ENC publication contract.</small>
71
+ </a>
72
+ <a href="./flatsql-streaming-standard.md">
73
+ <span>FlatSQL Streaming Standard</span>
74
+ <small>Binary FlatBuffer stream transport and runtime-host storage.</small>
75
+ </a>
76
+ <a href="./browser-wasmedge-isomorphic.md">
77
+ <span>Browser and WasmEdge Isomorphic Runtime</span>
78
+ <small>One module artifact across browser and server-side execution.</small>
79
+ </a>
80
+ <a href="./testing-harness.md">
81
+ <span>Testing Harness</span>
82
+ <small>Process, browser, WasmEdge, and module stream test entrypoints.</small>
83
+ </a>
84
+ <a href="./protocol-installation.md">
85
+ <span>Protocol Installation</span>
86
+ <small>Protocol identity, deployment routing, and installation metadata.</small>
87
+ </a>
88
+ <a href="./secrets-capability.md">
89
+ <span>Credential Lanes</span>
90
+ <small>Operator-defined secrets lanes, per-lane approval, and plaintext handling rules.</small>
91
+ </a>
92
+ </div>
93
+ </section>
94
+
95
+ <section id="stack" class="stack-list" aria-labelledby="stack-title">
96
+ <div class="section-head">
97
+ <p class="eyebrow">SDN Stack</p>
98
+ <h2 id="stack-title">Connected Sites</h2>
99
+ </div>
100
+ <div class="link-list">
101
+ <a href="https://spacedatastandards.org/">
102
+ <span>Standards</span>
103
+ <small>Canonical schemas, record contracts, and generated bindings.</small>
104
+ </a>
105
+ <a href="https://digitalarsenal.github.io/flatbuffers/">
106
+ <span>FlatBuffers</span>
107
+ <small>Binary encoding, schema tooling, and runtime documentation.</small>
108
+ </a>
109
+ <a href="https://digitalarsenal.github.io/flatsql/">
110
+ <span>FlatSQL</span>
111
+ <small>SQL-style queries over FlatBuffer-backed datasets and streams.</small>
112
+ </a>
113
+ <a href="https://spacedatanetwork.org/">
114
+ <span>SDN</span>
115
+ <small>Distributed publication, discovery, delivery, and marketplace infrastructure.</small>
116
+ </a>
117
+ <a href="https://digitalarsenal.github.io/space-data-module-sdk/" class="active">
118
+ <span>Module SDK</span>
119
+ <small>WASM module packaging, validation, and host compatibility tooling.</small>
120
+ </a>
121
+ </div>
122
+ </section>
123
+ </main>
124
+ </body>
125
+ </html>
@@ -0,0 +1,188 @@
1
+ # Isomorphic Pthreads: Enforced, Validated wasi-threads Artifacts
2
+
3
+ `space-data-module-sdk` is the **enforced source of truth** for isomorphic
4
+ pthreads module artifacts. When a module is compiled for the pthreads thread
5
+ model, the SDK guarantees two things that used to be optional and unchecked:
6
+
7
+ 1. The final link **cannot omit** the thread-enabling flags, and it targets the
8
+ **wasi-threads** toolchain (not Emscripten's browser Web-Worker model).
9
+ 2. The emitted `.wasm` is **parsed and validated** to be a real wasi-threads
10
+ artifact. A module that claims pthreads but does not emit the wasi-threads
11
+ contract **fails the compile** — it does not ship.
12
+
13
+ The goal is one compiled `.wasm` that threads in **both** the browser (via
14
+ `SharedArrayBuffer` + a wasi-threads Worker shim) and WasmEdge (via wasi-threads),
15
+ mirroring the `analysis/conjunction-assessment` module's `std::thread` workers.
16
+
17
+ ## Why wasi-threads and NOT Emscripten `-pthread`
18
+
19
+ This is the load-bearing decision. Emscripten's `-pthread` — even with
20
+ `-s STANDALONE_WASM=1` — emits the **browser-only** thread model:
21
+
22
+ - it imports `env.__pthread_create_js` and `env._emscripten_*` mailbox /
23
+ `postMessage` hooks (a JS Web Worker protocol), and
24
+ - it has **no** wasi thread-spawn contract.
25
+
26
+ That artifact **cannot spawn threads under WasmEdge** — there is no JS runtime to
27
+ satisfy those imports; instantiation fails on the unknown imports, and stubbing
28
+ them would require host-side thread orchestration (which is separately
29
+ forbidden). It has shared memory and atomics, but those are **necessary, not
30
+ sufficient**: a browser-only Emscripten build has them too.
31
+
32
+ WasmEdge's actual thread mechanism is **wasi-threads**: the guest imports
33
+ `wasi.thread-spawn` and exports `wasi_thread_start` over an imported shared
34
+ memory. Compiling with `clang --target=wasm32-wasip1-threads -pthread`
35
+ (wasi-sdk / wasi-libc + wasi-runtimes threads sysroot) produces exactly that
36
+ contract, which threads under WasmEdge and loads in the browser through a
37
+ wasi-threads shim.
38
+
39
+ `-mthreads` is likewise never used — it is a MinGW driver flag, invalid for the
40
+ wasm target.
41
+
42
+ ## Thread Models
43
+
44
+ `ModuleThreadModel` (see `src/compiler/compileModule.js`):
45
+
46
+ - `single-thread` — portable, no shared memory, no atomics. Default for
47
+ `runtimeTargets: ["browser"]` and `["browser", "wasmedge"]`. Built with
48
+ Emscripten (emception, in-process).
49
+ - `emscripten-pthreads` — the isomorphic threaded model (the enum value string
50
+ is historical; it now compiles to a **wasi-threads** artifact, not an
51
+ Emscripten Web-Worker build). Default for `runtimeTargets: ["wasmedge"]`.
52
+ Built with the wasi-threads toolchain.
53
+
54
+ `resolveThreadModel({ manifest, threadModel })` resolves the model; an explicit
55
+ `threadModel` option always wins over `runtimeTargets` inference.
56
+
57
+ ## 1. Enforced Flags (non-bypassable)
58
+
59
+ The pthreads final link routes through one flag-assembler (`buildCompilerArgs` in
60
+ `src/compiler/compileModule.js`, backed by `PTHREAD_FINAL_LINK_FLAGS` in
61
+ `src/compiler/pthreadArtifactGuard.js`). For the pthreads model it **always**
62
+ carries the wasm-ld / clang flags:
63
+
64
+ ```
65
+ -pthread -matomics -mbulk-memory -Wl,--import-memory -Wl,--shared-memory -Wl,--max-memory=2147483648
66
+ ```
67
+
68
+ plus the toolchain args resolved by `src/compiler/wasiThreadsToolchain.js`
69
+ (`--target=wasm32-wasip1-threads --sysroot=… -resource-dir=…`). Object files are
70
+ compiled `-matomics -fno-exceptions -pthread` (the wasi-threads libc++ is built
71
+ without exceptions, so throwing code otherwise fails to link).
72
+
73
+ `buildCompilerArgs` asserts its own output (`assertPthreadFlagsPresent`) so a
74
+ future edit that removes a mandated flag fails loudly. There are deliberately
75
+ **no** Emscripten `-s` settings here — those produce the browser-only build.
76
+
77
+ The toolchain is resolved with sensible defaults and env overrides
78
+ (`SDN_WASI_CLANG`, `SDN_WASI_CLANGXX`, `SDN_WASI_TARGET`, `SDN_WASI_SYSROOT`,
79
+ `SDN_WASI_RESOURCE_DIR`). If a wasi-threads sysroot is unavailable, the pthreads
80
+ compile fails with a clear, actionable error.
81
+
82
+ ## 2. Validated Artifact (the part that matters most)
83
+
84
+ After the final `.wasm` is emitted, `compileModuleFromSource` calls
85
+ `assertPthreadArtifact(wasmBytes)` for the pthreads model. It parses the wasm and
86
+ REJECTS the compile unless ALL of the following hold:
87
+
88
+ - **Shared memory** — an imported or declared memory with the shared limits flag
89
+ (`flags & 0x02`, i.e. `0x03`/`0x07`).
90
+ - **Atomics usage** — the code section is walked with a real instruction decoder
91
+ that counts genuine `0xFE`-prefixed atomic instructions. This is **not** a byte
92
+ scan: a naive scan for `0xFE` false-positives on `i32.const` / LEB128 /
93
+ memory-offset immediates (memory load/store opcodes `0x28`–`0x3E` carry a
94
+ memarg). `target_features` is honored when present.
95
+ - **wasi thread-spawn import** — `wasi.thread-spawn` (the host contract WasmEdge
96
+ invokes to spawn a guest thread).
97
+ - **`wasi_thread_start` export** — the entry a host calls to run a spawned
98
+ thread.
99
+ - **No Emscripten thread hooks** — the artifact must NOT import
100
+ `env.__pthread_create_js` or the `env._emscripten_*` mailbox/postMessage hooks.
101
+ Their presence means it is a browser-only Web-Worker build and it is rejected.
102
+
103
+ Shared memory + atomics **alone** are necessary but insufficient (the browser-only
104
+ Emscripten build has both), which is exactly why the wasi-threads contract check
105
+ exists. The analysis is returned on the compilation result as
106
+ `result.threadFeatures` (`{ hasSharedMemory, usesAtomics, atomicInstructionCount,
107
+ hasWasiThreadSpawnImport, hasWasiThreadStartExport, emscriptenThreadHooks,
108
+ isIsomorphicPthreads, … }`).
109
+
110
+ `analyzeWasmThreadFeatures(wasmBytes)` and `assertPthreadArtifact(wasmBytes)` are
111
+ exported from `src/compiler/index.js` (and the package root) for reuse by
112
+ downstream validators, deploy gates, and tests.
113
+
114
+ Note that the wasi-threads contract (thread-spawn import + `wasi_thread_start`
115
+ export) appears only when the module **actually spawns threads** — the linker
116
+ pulls in that machinery on demand. A module declared `emscripten-pthreads` that
117
+ never spawns a thread will therefore fail this guardrail; such a module should
118
+ use the `single-thread` model instead.
119
+
120
+ ## Guest-link symbol namespacing (collision-proof, metadata-authoritative)
121
+
122
+ For monolithic flow composition, each module also emits a **guest-link** wasm
123
+ object whose exported method symbols are namespaced by a per-plugin prefix so
124
+ that independently-built modules can be linked together with `wasm-ld -r` without
125
+ symbol clashes. `guestLinkSymbolPrefix(pluginId)` in
126
+ `src/compiler/compileModule.js` produces that prefix as:
127
+
128
+ ```
129
+ sdm_guest_<full-lowercase-hex-of-pluginId-UTF8-bytes>_
130
+ ```
131
+
132
+ The prefix uses the **full** hex encoding of the pluginId — it is **not**
133
+ truncated. Hex encoding is injective, so distinct pluginIds always map to
134
+ distinct prefixes. (A prior `.slice(0, 24)` truncation to 12 bytes collided real
135
+ plugin ids that share a 12-byte stem — e.g. `com.orbpro.iss-source` and
136
+ `com.orbpro.intelsat-source` both collapsed to `hex("com.orbpro.i")`
137
+ `636f6d2e6f726270726f2e69`, which would silently merge/clash their symbols at
138
+ compose time.) Wasm symbol names have no meaningful length limit, so the full hex
139
+ is always safe.
140
+
141
+ The emitted `symbolPrefix` and the per-method `methodSymbols` map are recorded in
142
+ the guest-link **metadata** (`sds.guest-link`). **That metadata is the sole
143
+ authoritative source consumers read at compose time** — `generateFlowTables` in
144
+ `src/flow/flowCompiler.js` declares and calls
145
+ `dependency.guestLink.metadata.methodSymbols[methodId]` and never re-derives the
146
+ prefix from the pluginId. This keeps already-committed artifacts compatible: an
147
+ object that shipped with a legacy (e.g. truncated) prefix still composes, because
148
+ its own metadata carries the exact symbol names its object bytes define.
149
+
150
+ ## 3. Compile-Time vs. Runtime: an honest boundary
151
+
152
+ Passing this guardrail proves the **artifact** is a valid wasi-threads
153
+ shared-memory/atomics wasm. It does **not** prove that a given WasmEdge build
154
+ actually spawns and runs guest threads.
155
+
156
+ > **Rule:** Do not claim WasmEdge thread support until a real runtime invocation
157
+ > spawns threads and runs. Compile-time validation (wasi-threads contract +
158
+ > shared memory + atomics) is necessary but not sufficient; runtime thread-spawn
159
+ > verification is owned by the deploy/benchmark node, not by this SDK.
160
+
161
+ Record any WasmEdge runtime limitation honestly. An artifact that validates here
162
+ but only compiles — and does not instantiate/spawn threads under the target
163
+ runtime — must be reported as such.
164
+
165
+ ## Tests
166
+
167
+ - `test/pthreads-artifact-guardrail.test.js` — flag-assembler invariants; a
168
+ positive compile that emits a validated wasi-threads shared-memory/atomics
169
+ wasm; a single-thread artifact rejected; a **browser-only Emscripten `-pthread`
170
+ artifact rejected** (has shared memory + atomics but no wasi-threads contract);
171
+ a shared-flag-stripped artifact rejected; and a false-positive guard proving
172
+ the atomics decoder ignores `0xFE` immediates.
173
+ - `test/guest-link-symbol-prefix.test.js` — the guest-link prefix is the full
174
+ injective hex of the pluginId; two previously-colliding ids now get distinct
175
+ prefixes; fresh prefixes match the committed modules-branch artifacts
176
+ byte-for-byte; and the compose path treats the guest-link metadata's
177
+ `symbolPrefix` / `methodSymbols` as authoritative (never re-derived), keeping a
178
+ legacy truncated-prefix artifact compatible.
179
+
180
+ ## See also
181
+
182
+ - [`docs/browser-wasmedge-isomorphic.md`](./browser-wasmedge-isomorphic.md) —
183
+ the one-artifact browser + WasmEdge loading profile.
184
+ - `.claude/skills/wasmedge-pthreads/Skills.md` — the operating rules.
185
+ - `src/compiler/pthreadArtifactGuard.js` — the flag list + wasm validator.
186
+ - `src/compiler/wasiThreadsToolchain.js` — the wasi-threads toolchain resolver.
187
+ - `src/compiler/compileModule.js` — `ModuleThreadModel`, `buildCompilerArgs`,
188
+ `compileWithWasiThreads`, `resolveThreadModel`, `compileModuleFromSource`.
@@ -0,0 +1,167 @@
1
+ # Isomorphic SDN Runtime Plan
2
+
3
+ ## Goal
4
+
5
+ Run the same signed Space Data modules across browser, server, OrbPro, and
6
+ WasmEdge without changing the module contract.
7
+
8
+ The runtime differences are host differences, not module differences.
9
+
10
+ ## Current Direction
11
+
12
+ `space-data-module-sdk` is the source of truth for:
13
+
14
+ - the canonical module artifact
15
+ - the canonical module ABI
16
+ - the canonical dynamic runtime host
17
+ - the canonical WasmEdge/browser/server harness model
18
+
19
+ Host runtime packages are layered on top of that runtime host as:
20
+
21
+ - graph/program compiler
22
+ - deployment planner
23
+ - editor/runtime authoring surface
24
+ - optional `emception`-backed build tooling
25
+
26
+ It is no longer the intended source of truth for a separate runtime model.
27
+
28
+ ## Canonical Identity Model
29
+
30
+ ### Standards Rows
31
+
32
+ Standards payloads are always addressed by:
33
+
34
+ - `($SCHEMA_FILE_ID, rowId)`
35
+
36
+ Rules:
37
+
38
+ - `rowId` is append-only
39
+ - `rowId` is never reused
40
+ - rows are not individually recycled
41
+ - if a host needs a new retention window, it recreates the mounted table/range
42
+
43
+ FlatSQL is the only query backend for standards rows.
44
+
45
+ ### Runtime Aligned-Binary Records
46
+
47
+ High-performance derived runtime state is always addressed by:
48
+
49
+ - `(regionId, recordIndex)`
50
+
51
+ Rules:
52
+
53
+ - the host allocates all regions
54
+ - regions are dynamically requested at runtime
55
+ - regions are fixed-layout aligned-binary memory regions
56
+ - records stay stable for the lifetime of a region
57
+ - regions are not indexed in FlatSQL
58
+
59
+ ### Raw Pointers
60
+
61
+ Raw pointers are valid only as internal execution details inside a live host or
62
+ module instance.
63
+
64
+ They are not a durable public contract.
65
+
66
+ ## Host Responsibilities
67
+
68
+ The canonical SDK runtime host is responsible for:
69
+
70
+ - installing and loading modules dynamically
71
+ - exposing one canonical module registry for install/load/unload/invoke
72
+ - exposing FlatSQL-backed standards storage
73
+ - exposing canonical streamed FlatBuffer ingest into host-owned rows
74
+ - exposing row-handle resolution
75
+ - allocating aligned-binary runtime regions
76
+ - exposing region-record resolution
77
+ - routing typed invoke traffic across loaded modules
78
+ - hosting the same model in browser, server, and WasmEdge
79
+
80
+ The recommended outer transport / invoke / storage split is documented in
81
+ [`./flatsql-streaming-standard.md`](./flatsql-streaming-standard.md).
82
+
83
+ ## OrbPro
84
+
85
+ OrbPro is not a separate storage/runtime architecture.
86
+
87
+ OrbPro adds a host-side entity/view layer over the same core model:
88
+
89
+ - standards rows live in FlatSQL
90
+ - WasmEngine owns transient zero-copy render/runtime views
91
+ - workers own query and index work
92
+ - main thread resolves transient shared-memory views for rendering and UI
93
+ - propagators write into host-managed aligned-binary regions
94
+
95
+ So OrbPro is:
96
+
97
+ - canonical SDK runtime host
98
+ - plus Cesium-facing entity/view helpers
99
+
100
+ ## Server and Browser Node
101
+
102
+ Server and browser-node use the same core host model:
103
+
104
+ - FlatSQL-backed standards rows
105
+ - host-managed runtime regions
106
+ - dynamic module loading
107
+ - typed invoke routing
108
+
109
+ They do not need the OrbPro entity facade.
110
+
111
+ ## WasmEdge
112
+
113
+ WasmEdge is a host target for the same runtime model.
114
+
115
+ The SDK’s WasmEdge runner should evolve from:
116
+
117
+ - single top-level guest launcher
118
+
119
+ to:
120
+
121
+ - dynamic multi-module host
122
+ - FlatSQL row service host
123
+ - runtime-region allocator host
124
+ - typed invoke router
125
+
126
+ This is a host concern, not a second guest ABI.
127
+
128
+ ## Capability Model
129
+
130
+ The capabilities that matter most for this runtime model are:
131
+
132
+ - `database`
133
+ - `storage_query`
134
+ - `storage_write`
135
+ - `filesystem` only when backing FlatSQL to disk
136
+ - `pipe`
137
+ - `http`
138
+ - `network`
139
+ - `timers`
140
+
141
+ But direct standards-row reads and runtime-region reads should still happen
142
+ through the host’s typed row/region services rather than ad hoc JSON APIs.
143
+
144
+ ## Dynamic Loading vs Compiled Flows
145
+
146
+ Dynamic module loading is the default runtime model.
147
+
148
+ Compiled flows remain useful, but only as an optional deployment/build mode:
149
+
150
+ - freezing a graph into one artifact
151
+ - minimizing moving parts
152
+ - packaging one sealed runtime
153
+
154
+ Compiled flow output must target the same runtime host contract, not invent a
155
+ parallel execution model.
156
+
157
+ ## Definition of Done
158
+
159
+ This runtime model is complete when:
160
+
161
+ - the SDK ships one canonical runtime host surface
162
+ - the SDK host surface exposes row-handle, region, and registry services
163
+ - OrbPro, browser/server SDN nodes, and WasmEdge all consume that same host
164
+ - host runtime packages compile and deploy into that host rather than re-owning runtime behavior
165
+ - standards identity is always `($SCHEMA_FILE_ID, rowId)`
166
+ - aligned-binary runtime identity is always `(regionId, recordIndex)`
167
+ - Aerospace and SOCRATES validation pass on the composed host path