space-data-module-sdk 0.8.4 → 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 +25 -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,141 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 520" fill="none">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0" y1="0" x2="900" y2="520" gradientUnits="userSpaceOnUse">
4
+ <stop offset="0" stop-color="#0d1117"/>
5
+ <stop offset="1" stop-color="#161b22"/>
6
+ </linearGradient>
7
+ <linearGradient id="accent" x1="0" y1="0" x2="1" y2="1">
8
+ <stop offset="0" stop-color="#58a6ff"/>
9
+ <stop offset="1" stop-color="#1f6feb"/>
10
+ </linearGradient>
11
+ <linearGradient id="green" x1="0" y1="0" x2="1" y2="1">
12
+ <stop offset="0" stop-color="#3fb950"/>
13
+ <stop offset="1" stop-color="#238636"/>
14
+ </linearGradient>
15
+ <linearGradient id="purple" x1="0" y1="0" x2="1" y2="1">
16
+ <stop offset="0" stop-color="#bc8cff"/>
17
+ <stop offset="1" stop-color="#8b5cf6"/>
18
+ </linearGradient>
19
+ <linearGradient id="orange" x1="0" y1="0" x2="1" y2="1">
20
+ <stop offset="0" stop-color="#f0883e"/>
21
+ <stop offset="1" stop-color="#d29922"/>
22
+ </linearGradient>
23
+ <filter id="glow">
24
+ <feGaussianBlur stdDeviation="3" result="blur"/>
25
+ <feMerge><feMergeNode in="blur"/><feMergeNode in="SourceGraphic"/></feMerge>
26
+ </filter>
27
+ </defs>
28
+
29
+ <rect width="900" height="520" rx="12" fill="url(#bg)"/>
30
+
31
+ <!-- Title -->
32
+ <text x="450" y="40" text-anchor="middle" font-family="system-ui, -apple-system, sans-serif" font-size="18" font-weight="700" fill="#e6edf3">Space Data Module Architecture</text>
33
+
34
+ <!-- Source Layer -->
35
+ <rect x="30" y="70" width="180" height="170" rx="10" fill="#161b22" stroke="#30363d" stroke-width="1.5"/>
36
+ <text x="120" y="95" text-anchor="middle" font-family="system-ui, sans-serif" font-size="13" font-weight="600" fill="#e6edf3">Source</text>
37
+
38
+ <rect x="50" y="110" width="140" height="36" rx="6" fill="#1c2128" stroke="#58a6ff" stroke-width="1"/>
39
+ <text x="120" y="133" text-anchor="middle" font-family="monospace" font-size="11" fill="#58a6ff">module.c / .cpp</text>
40
+
41
+ <rect x="50" y="155" width="140" height="36" rx="6" fill="#1c2128" stroke="#f0883e" stroke-width="1"/>
42
+ <text x="120" y="178" text-anchor="middle" font-family="monospace" font-size="11" fill="#f0883e">manifest.json</text>
43
+
44
+ <rect x="50" y="200" width="140" height="28" rx="6" fill="#1c2128" stroke="#3fb950" stroke-width="1"/>
45
+ <text x="120" y="219" text-anchor="middle" font-family="monospace" font-size="10" fill="#3fb950">spacedatastandards.org</text>
46
+
47
+ <!-- Arrow: Source -> SDK -->
48
+ <line x1="210" y1="155" x2="260" y2="155" stroke="#484f58" stroke-width="2" marker-end="url(#arrowGray)"/>
49
+
50
+ <!-- SDK Core -->
51
+ <rect x="265" y="70" width="370" height="280" rx="10" fill="#161b22" stroke="#58a6ff" stroke-width="1.5"/>
52
+ <rect x="265" y="70" width="370" height="30" rx="10" fill="#1f6feb" fill-opacity="0.15"/>
53
+ <text x="450" y="91" text-anchor="middle" font-family="system-ui, sans-serif" font-size="13" font-weight="700" fill="#58a6ff">space-data-module-sdk</text>
54
+
55
+ <!-- Compile -->
56
+ <rect x="285" y="115" width="150" height="50" rx="8" fill="#1c2128" stroke="#f0883e" stroke-width="1"/>
57
+ <text x="360" y="136" text-anchor="middle" font-family="system-ui, sans-serif" font-size="11" font-weight="600" fill="#f0883e">Compile</text>
58
+ <text x="360" y="153" text-anchor="middle" font-family="monospace" font-size="9" fill="#8b949e">emcc / em++ -> .wasm</text>
59
+
60
+ <!-- Validate -->
61
+ <rect x="465" y="115" width="150" height="50" rx="8" fill="#1c2128" stroke="#3fb950" stroke-width="1"/>
62
+ <text x="540" y="136" text-anchor="middle" font-family="system-ui, sans-serif" font-size="11" font-weight="600" fill="#3fb950">Validate</text>
63
+ <text x="540" y="153" text-anchor="middle" font-family="monospace" font-size="9" fill="#8b949e">compliance + standards</text>
64
+
65
+ <!-- Arrow: Compile -> Validate -->
66
+ <line x1="435" y1="140" x2="465" y2="140" stroke="#484f58" stroke-width="1.5" marker-end="url(#arrowGray)"/>
67
+
68
+ <!-- Embed Manifest -->
69
+ <rect x="285" y="185" width="150" height="50" rx="8" fill="#1c2128" stroke="#bc8cff" stroke-width="1"/>
70
+ <text x="360" y="206" text-anchor="middle" font-family="system-ui, sans-serif" font-size="11" font-weight="600" fill="#bc8cff">Embed Manifest</text>
71
+ <text x="360" y="223" text-anchor="middle" font-family="monospace" font-size="9" fill="#8b949e">FlatBuffers binary ABI</text>
72
+
73
+ <!-- Sign -->
74
+ <rect x="465" y="185" width="150" height="50" rx="8" fill="#1c2128" stroke="#d29922" stroke-width="1"/>
75
+ <text x="540" y="206" text-anchor="middle" font-family="system-ui, sans-serif" font-size="11" font-weight="600" fill="#d29922">Sign</text>
76
+ <text x="540" y="223" text-anchor="middle" font-family="monospace" font-size="9" fill="#8b949e">HD wallet + secp256k1</text>
77
+
78
+ <!-- Encrypt -->
79
+ <rect x="375" y="255" width="150" height="50" rx="8" fill="#1c2128" stroke="#f778ba" stroke-width="1"/>
80
+ <text x="450" y="276" text-anchor="middle" font-family="system-ui, sans-serif" font-size="11" font-weight="600" fill="#f778ba">Encrypt</text>
81
+ <text x="450" y="293" text-anchor="middle" font-family="monospace" font-size="9" fill="#8b949e">X25519 + AES-256-GCM</text>
82
+
83
+ <!-- Internal arrows -->
84
+ <line x1="360" y1="165" x2="360" y2="185" stroke="#484f58" stroke-width="1.5" marker-end="url(#arrowGray)"/>
85
+ <line x1="540" y1="165" x2="540" y2="185" stroke="#484f58" stroke-width="1.5" marker-end="url(#arrowGray)"/>
86
+ <line x1="435" y1="210" x2="465" y2="210" stroke="#484f58" stroke-width="1.5" marker-end="url(#arrowGray)"/>
87
+ <path d="M 450 235 L 450 255" stroke="#484f58" stroke-width="1.5" marker-end="url(#arrowGray)"/>
88
+
89
+ <!-- Arrow: SDK -> Output -->
90
+ <line x1="635" y1="210" x2="685" y2="210" stroke="#484f58" stroke-width="2" marker-end="url(#arrowGray)"/>
91
+
92
+ <!-- Output: Protected Module Package -->
93
+ <rect x="690" y="70" width="180" height="280" rx="10" fill="#161b22" stroke="#30363d" stroke-width="1.5"/>
94
+ <text x="780" y="95" text-anchor="middle" font-family="system-ui, sans-serif" font-size="13" font-weight="600" fill="#e6edf3">Protected Package</text>
95
+
96
+ <rect x="710" y="110" width="140" height="30" rx="6" fill="#1c2128" stroke="#bc8cff" stroke-width="1"/>
97
+ <text x="780" y="130" text-anchor="middle" font-family="monospace" font-size="10" fill="#bc8cff">manifest.fb</text>
98
+
99
+ <rect x="710" y="150" width="140" height="30" rx="6" fill="#1c2128" stroke="#58a6ff" stroke-width="1"/>
100
+ <text x="780" y="170" text-anchor="middle" font-family="monospace" font-size="10" fill="#58a6ff">module.wasm</text>
101
+
102
+ <rect x="710" y="190" width="140" height="30" rx="6" fill="#1c2128" stroke="#d29922" stroke-width="1"/>
103
+ <text x="780" y="210" text-anchor="middle" font-family="monospace" font-size="10" fill="#d29922">authorization.sig</text>
104
+
105
+ <rect x="710" y="230" width="140" height="30" rx="6" fill="#1c2128" stroke="#f778ba" stroke-width="1"/>
106
+ <text x="780" y="250" text-anchor="middle" font-family="monospace" font-size="10" fill="#f778ba">encrypted envelope</text>
107
+
108
+ <rect x="710" y="280" width="140" height="30" rx="6" fill="#1c2128" stroke="#3fb950" stroke-width="1"/>
109
+ <text x="780" y="300" text-anchor="middle" font-family="monospace" font-size="10" fill="#3fb950">compliance report</text>
110
+
111
+ <!-- Deployment targets -->
112
+ <rect x="30" y="380" width="840" height="120" rx="10" fill="#161b22" stroke="#30363d" stroke-width="1.5"/>
113
+ <rect x="30" y="380" width="840" height="30" rx="10" fill="#238636" fill-opacity="0.1"/>
114
+ <text x="450" y="401" text-anchor="middle" font-family="system-ui, sans-serif" font-size="13" font-weight="700" fill="#3fb950">Deployment Targets</text>
115
+
116
+ <rect x="54" y="420" width="180" height="60" rx="8" fill="#1c2128" stroke="#3fb950" stroke-width="1"/>
117
+ <text x="144" y="447" text-anchor="middle" font-family="system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6edf3">Mission Systems</text>
118
+ <text x="144" y="465" text-anchor="middle" font-family="system-ui, sans-serif" font-size="10" fill="#8b949e">Analysis / Planning / Ops</text>
119
+
120
+ <rect x="258" y="420" width="180" height="60" rx="8" fill="#1c2128" stroke="#3fb950" stroke-width="1"/>
121
+ <text x="348" y="447" text-anchor="middle" font-family="system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6edf3">SDN Nodes</text>
122
+ <text x="348" y="465" text-anchor="middle" font-family="system-ui, sans-serif" font-size="10" fill="#8b949e">Peer-to-Peer Data Network</text>
123
+
124
+ <rect x="462" y="420" width="180" height="60" rx="8" fill="#1c2128" stroke="#3fb950" stroke-width="1"/>
125
+ <text x="552" y="447" text-anchor="middle" font-family="system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6edf3">Edge Runtimes</text>
126
+ <text x="552" y="465" text-anchor="middle" font-family="system-ui, sans-serif" font-size="10" fill="#8b949e">Satellite / Ground Station</text>
127
+
128
+ <rect x="666" y="420" width="180" height="60" rx="8" fill="#1c2128" stroke="#3fb950" stroke-width="1"/>
129
+ <text x="756" y="447" text-anchor="middle" font-family="system-ui, sans-serif" font-size="12" font-weight="600" fill="#e6edf3">Browser</text>
130
+ <text x="756" y="465" text-anchor="middle" font-family="system-ui, sans-serif" font-size="10" fill="#8b949e">Module Lab / WebAssembly</text>
131
+
132
+ <!-- Arrows down to deployment -->
133
+ <line x1="450" y1="350" x2="450" y2="380" stroke="#484f58" stroke-width="2" marker-end="url(#arrowGray)"/>
134
+
135
+ <!-- Arrow markers -->
136
+ <defs>
137
+ <marker id="arrowGray" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
138
+ <path d="M 0 0 L 10 5 L 0 10 z" fill="#484f58"/>
139
+ </marker>
140
+ </defs>
141
+ </svg>
@@ -0,0 +1,179 @@
1
+ # Browser + WasmEdge Isomorphic Artifacts
2
+
3
+ Use this profile when you want one compiled `.wasm` artifact that can be loaded
4
+ unchanged in:
5
+
6
+ - the browser harness
7
+ - the WasmEdge command/runtime harness
8
+
9
+ ## Canonical Build Rule
10
+
11
+ Declare:
12
+
13
+ ```json
14
+ {
15
+ "runtimeTargets": ["browser", "wasmedge"]
16
+ }
17
+ ```
18
+
19
+ That target pair now defaults to the shared `single-thread` artifact profile.
20
+
21
+ The compiler logic lives in
22
+ [`src/compiler/compileModule.js`](/Users/tj/software/space-data-module-sdk/src/compiler/compileModule.js).
23
+
24
+ The practical effect is:
25
+
26
+ - `["wasmedge"]` keeps the higher-capability WasmEdge pthread default
27
+ - `["browser", "wasmedge"]` chooses the portable single-thread artifact instead
28
+
29
+ Use the pure `["wasmedge"]` target when you want maximum WasmEdge-native guest
30
+ capability and do not need browser loading from the same binary.
31
+
32
+ ### Pthreads variant (shared-memory, isomorphic threading)
33
+
34
+ When a module needs real guest threads (the `emscripten-pthreads` thread model,
35
+ default for `["wasmedge"]`), the SDK compiles it through the **wasi-threads**
36
+ toolchain (`clang --target=wasm32-wasip1-threads -pthread`), **not** Emscripten
37
+ `-pthread` (which emits a browser-only Web-Worker build that cannot thread under
38
+ WasmEdge). It **enforces** the wasi-threads link flags and **validates the
39
+ emitted `.wasm`** — the artifact must import `wasi.thread-spawn`, export
40
+ `wasi_thread_start`, be a shared-memory/atomics wasm, and carry no Emscripten
41
+ worker hooks, or the compile is rejected. That guardrail is documented in
42
+ [`docs/isomorphic-pthreads.md`](./isomorphic-pthreads.md). This present document
43
+ covers the portable `single-thread` loading profile; read the pthreads doc
44
+ before shipping a threaded WasmEdge artifact.
45
+
46
+ ## Canonical Module Repo Layout
47
+
48
+ Module repos should publish the shared compiled artifact under a stable runtime
49
+ path, not a plugin-named filename:
50
+
51
+ - required: `dist/isomorphic/module.wasm`
52
+
53
+ If a repo also ships a browser-specific adapter, place it under:
54
+
55
+ - optional: `dist/browser/module.js`
56
+ - optional: `dist/browser/module.wasm`
57
+
58
+ That keeps the artifact name stable across repos and lets runtime intent live in
59
+ the path rather than in the filename.
60
+
61
+ ## Toolchain Options
62
+
63
+ The recommended browser-side build selector for module repos is:
64
+
65
+ - `SDN_WASM_TOOLCHAIN=local-emsdk`: default. Build with a repo-local
66
+ `deps/emsdk` checkout and avoid Homebrew or any other machine-global
67
+ Emscripten install.
68
+ - `SDN_WASM_TOOLCHAIN=sdn-emception`: optional SDK-first path for repos that use
69
+ `compileModuleFromSource(...)` or an SDK-driven build script to emit the
70
+ shared `dist/isomorphic/module.wasm` artifact.
71
+ - `SDN_WASM_TOOLCHAIN=path`: explicit escape hatch when a repo intentionally
72
+ wants to use a preinstalled Emscripten toolchain from `PATH`.
73
+
74
+ The isomorphic contract is the compiled wasm path, not the browser wrapper. A
75
+ repo can publish only `dist/isomorphic/module.wasm` and still satisfy the
76
+ browser/WasmEdge shared-artifact requirement when it loads through the SDK
77
+ harnesses.
78
+
79
+ ## Loader Entry Points
80
+
81
+ The supported browser/WasmEdge entry points are:
82
+
83
+ - browser entry bundle: [`src/browser.js`](/Users/tj/software/space-data-module-sdk/src/browser.js)
84
+ - isomorphic loader: [`src/host/isomorphicLoader.js`](/Users/tj/software/space-data-module-sdk/src/host/isomorphicLoader.js)
85
+ - browser harness: [`src/testing/browserModuleHarness.js`](/Users/tj/software/space-data-module-sdk/src/testing/browserModuleHarness.js)
86
+ - browser WASI shim: [`src/host/wasiShim.js`](/Users/tj/software/space-data-module-sdk/src/host/wasiShim.js)
87
+ - browser edge shims: [`src/host/browserEdgeShims.js`](/Users/tj/software/space-data-module-sdk/src/host/browserEdgeShims.js)
88
+ - browser host adapter: [`src/host/browserHost.js`](/Users/tj/software/space-data-module-sdk/src/host/browserHost.js)
89
+
90
+ On the server path, [`loadModule(...)`](/Users/tj/software/space-data-module-sdk/src/host/isomorphicLoader.js)
91
+ now chooses the raw WasmEdge command harness automatically for standalone
92
+ artifacts with `_start`. The `--serve-plugin-invoke` runner protocol remains
93
+ available for explicit runtime-host / runner-backed flows.
94
+
95
+ ## What The Browser Shims Cover
96
+
97
+ The browser edge shims map host capabilities onto browser-native surfaces:
98
+
99
+ - `filesystem`: in-memory virtual filesystem with `resolvePath`, `readFile`,
100
+ `writeFile`, `appendFile`, `deleteFile`, `mkdir`, `readdir`, `stat`, `rename`
101
+ - `http`: `fetch`
102
+ - `websocket`: browser `WebSocket`
103
+ - `network`: async browser-host dispatch that routes to the available transport
104
+ adapters
105
+ - `ipfs`, `protocol_handle`, `protocol_dial`: async browser-host adapters that
106
+ can be supplied by the embedding runtime
107
+ - `clock`, `random`, `timers`, `schedule_cron`, `context_*`, `crypto_*`:
108
+ browser-native implementations in the browser host adapter
109
+
110
+ These are host shims, not raw WasmEdge socket imports. When an embedding host
111
+ needs to override the reference behavior, pass `capabilityAdapters` keyed by
112
+ the canonical capability ids. That same generic async capability boundary is
113
+ shared by `BrowserHost`, `NodeHost`, `createRuntimeHost()`, `loadModule(...)`,
114
+ and `createBrowserModuleHarness(...)`.
115
+
116
+ ## Current Boundary
117
+
118
+ One binary can load in both browser and WasmEdge today when it stays within the
119
+ shared profile:
120
+
121
+ - standalone WASI imports
122
+ - optional sync `space_data_module_host` imports
123
+ - command invoke surfaces through `_start` on WasmEdge and direct or command
124
+ invoke surfaces in the browser harness
125
+ - no Emscripten pthread imports
126
+
127
+ Not browser-portable from the same raw guest binary:
128
+
129
+ - WasmEdge-native socket/TLS extension imports
130
+ - pthread-oriented `env.*` imports
131
+ - raw guest async hostcalls that need a broader ABI than the current sync
132
+ `space_data_module_host` bridge
133
+
134
+ Today’s portable split is:
135
+
136
+ - the guest-visible `space_data_module_host` import remains a sync-only subset for sync-safe
137
+ operations
138
+ - the host and harness APIs can still await filesystem, network, IPFS, and
139
+ protocol adapters through the generic async capability boundary in both
140
+ browser and Node-hosted test/runtime flows
141
+
142
+ For browser-hosted networking and IPFS/protocol work, use the browser edge
143
+ shims or host-delegated adapters instead of relying on raw WasmEdge socket
144
+ extensions.
145
+
146
+ ## Checked-In Demo
147
+
148
+ The canonical example is:
149
+
150
+ - [`examples/isomorphic-loader/README.md`](/Users/tj/software/space-data-module-sdk/examples/isomorphic-loader/README.md)
151
+
152
+ That example includes:
153
+
154
+ - manifest: [`examples/isomorphic-loader/manifest.json`](/Users/tj/software/space-data-module-sdk/examples/isomorphic-loader/manifest.json)
155
+ - guest source: [`examples/isomorphic-loader/module.c`](/Users/tj/software/space-data-module-sdk/examples/isomorphic-loader/module.c)
156
+ - build script: [`examples/isomorphic-loader/build-demo.mjs`](/Users/tj/software/space-data-module-sdk/examples/isomorphic-loader/build-demo.mjs)
157
+ - browser loader: [`examples/isomorphic-loader/browser-demo.mjs`](/Users/tj/software/space-data-module-sdk/examples/isomorphic-loader/browser-demo.mjs)
158
+ - browser page: [`examples/isomorphic-loader/browser-demo.html`](/Users/tj/software/space-data-module-sdk/examples/isomorphic-loader/browser-demo.html)
159
+ - WasmEdge loader: [`examples/isomorphic-loader/wasmedge-demo.mjs`](/Users/tj/software/space-data-module-sdk/examples/isomorphic-loader/wasmedge-demo.mjs)
160
+
161
+ Both demos load the same generated artifact:
162
+
163
+ - `examples/isomorphic-loader/generated/dist/isomorphic/module.wasm`
164
+
165
+ ## Streaming Into The Same Artifact
166
+
167
+ If that shared artifact owns resident state, such as an SDN module that imports
168
+ `flatsql` internally, stream raw FlatBuffer frames into the live instance with
169
+ `createModuleFlatBufferStreamPump(...)`.
170
+
171
+ Use:
172
+
173
+ - a persistent `direct` browser harness for browser-resident state
174
+ - a persistent runtime-backed harness on the server/WasmEdge side
175
+ - chunked size-prefixed FlatBuffer stream input
176
+ - many small invokes, not one monolithic invoke envelope
177
+
178
+ That path is documented in
179
+ [`docs/flatsql-streaming-standard.md`](/Users/tj/software/space-data-module-sdk/docs/flatsql-streaming-standard.md).
@@ -0,0 +1,341 @@
1
+ # FlatBuffer Streaming Into FlatSQL
2
+
3
+ This document defines the recommended standard for getting streamed
4
+ FlatBuffer payloads into FlatSQL-backed storage while keeping the same model
5
+ portable across browser, server, OrbPro, and WasmEdge.
6
+
7
+ ## Short Version
8
+
9
+ Use three layers, not one:
10
+
11
+ 1. Transport stream:
12
+ little-endian `u32` size prefix + one FlatBuffer payload per frame
13
+ 2. Module invoke ABI:
14
+ SDS `$PIV` request/response envelopes with `TAB` frame descriptors
15
+ 3. Durable storage identity:
16
+ host-owned append-only row handles and host-owned runtime regions
17
+
18
+ Do not treat a module-owned mutable FlatSQL database as the canonical ABI.
19
+ That can exist as an adapter or example, but it is not the durable cross-host
20
+ contract.
21
+
22
+ ## Canonical Transport
23
+
24
+ The canonical transport for streamed FlatBuffers is:
25
+
26
+ - `4-byte little-endian payload length`
27
+ - followed by one FlatBuffer payload
28
+ - repeated until end of stream
29
+ - payload bytes stay binary end-to-end; the canonical ingest path does not
30
+ transcode frames through JSON
31
+
32
+ Each payload must carry a readable FlatBuffer file identifier. The runtime uses
33
+ that identifier to derive the durable `schemaFileId`.
34
+
35
+ This transport is intentionally separate from module invocation. It is the
36
+ right shape for:
37
+
38
+ - WebSocket feeds
39
+ - HTTP chunk/file ingestion
40
+ - local file replay
41
+ - browser worker or server-side stream processing
42
+
43
+ It is not the same thing as a SDS `$PIV` invoke envelope.
44
+
45
+ ## Canonical Durable Storage
46
+
47
+ The durable storage model is host-owned.
48
+
49
+ Standards records are addressed by:
50
+
51
+ - `($SCHEMA_FILE_ID, rowId)`
52
+
53
+ Rules:
54
+
55
+ - `rowId` is append-only
56
+ - `rowId` is never reused
57
+ - logical updates create new rows
58
+ - "latest" or "upsert" views are host-side projections or indexes
59
+ - row payloads remain raw binary or native in-memory values; the canonical
60
+ runtime-host row path does not stringify payloads
61
+
62
+ High-performance derived runtime state is addressed by:
63
+
64
+ - `(regionId, recordIndex)`
65
+
66
+ Rules:
67
+
68
+ - the host allocates or registers regions
69
+ - regions are fixed-layout aligned-binary buffers
70
+ - regions are not indexed in FlatSQL
71
+ - raw pointers remain internal execution details only
72
+
73
+ The stable storage ABI lives in [`schemas/HostStorageAbi.fbs`](../schemas/HostStorageAbi.fbs).
74
+
75
+ ## Canonical Module ABI
76
+
77
+ When streamed payloads must cross into a module, use the invoke ABI:
78
+
79
+ - SDS `$PIV` `REQUEST`
80
+ - SDS `$PIV` `RESPONSE`
81
+ - SDS `TAB` frame descriptors
82
+
83
+ Each input frame should preserve:
84
+
85
+ - `portId`
86
+ - `typeRef`
87
+ - `streamId`
88
+ - `sequence`
89
+ - `endOfStream`
90
+ - alignment metadata when required
91
+
92
+ This is the correct way to tell a module "these frames belong to the same
93
+ logical stream."
94
+
95
+ It is not a byte-streaming transport. The current invoke ABI is still
96
+ buffer-oriented:
97
+
98
+ - the full request is materialized before `plugin_invoke_stream(...)`
99
+ - the full response is materialized before it is returned
100
+
101
+ So a single 1 GiB SDS `$PIV` invoke request is not the intended path.
102
+
103
+ ## FlatSQL-Specific Rules
104
+
105
+ If the goal is "stream FlatBuffers into FlatSQL", standardize the host-side
106
+ behavior first:
107
+
108
+ 1. split the outer size-prefixed transport stream into payload frames
109
+ 2. derive `schemaFileId` from the FlatBuffer file identifier
110
+ 3. append immutable host-owned rows
111
+ 4. maintain host-side logical indexes or latest-record projections as needed
112
+ 5. expose query and row-resolution APIs on top of that store
113
+
114
+ That means the durable primitive is `append`, not `upsert`.
115
+
116
+ `upsert_records` is allowed as a higher-level adapter surface, but only if it
117
+ is defined as:
118
+
119
+ - append new immutable row(s)
120
+ - update a logical index/view
121
+ - never rewrite an existing durable `rowId`
122
+
123
+ If a module or flow needs fast numeric state, keep that data in runtime regions,
124
+ not in FlatSQL tables.
125
+
126
+ ## Browser and WasmEdge
127
+
128
+ The same transport/storage model should be used in both:
129
+
130
+ - browser: host-side stream ingest + host-owned rows/regions
131
+ - WasmEdge: host-side stream ingest + host-owned rows/regions
132
+
133
+ Use module invocation for:
134
+
135
+ - compute batches
136
+ - typed transformation steps
137
+ - stateful direct-surface module sessions
138
+
139
+ Use host-side stream ingest for:
140
+
141
+ - large continuous feeds
142
+ - catalog replay
143
+ - ingestion into host-owned FlatSQL-backed stores
144
+ - any workload that should not be forced through one contiguous invoke buffer
145
+
146
+ The new helper for this outer transport path is
147
+ `createFlatBufferStreamIngestor(...)`, exported from
148
+ `space-data-module-sdk/runtime-host`.
149
+
150
+ ## Streaming Into A Module-Owned FlatSQL Engine
151
+
152
+ If the goal is not a host-owned durable store, but a stateful SDN module that
153
+ imports `flatsql` internally and owns its own in-memory query state, use a
154
+ persistent direct-surface module instance plus chunked binary invokes.
155
+
156
+ Rules:
157
+
158
+ - do not change `flatsql` itself
159
+ - import `flatsql` inside the SDN module implementation
160
+ - keep the module instance resident across invokes
161
+ - feed it many small FlatBuffer frames, not one giant invoke envelope
162
+ - use command surface only for stateless one-shot work; use direct surface for
163
+ resident FlatSQL state
164
+
165
+ The SDK helper for this path is `createModuleFlatBufferStreamPump(...)`,
166
+ exported from `space-data-module-sdk/testing` and the browser/root package
167
+ surfaces.
168
+
169
+ That helper:
170
+
171
+ - accepts the same outer size-prefixed FlatBuffer stream chunks
172
+ - decodes frames incrementally
173
+ - emits small SDS `$PIV` request batches into a live module instance
174
+ - preserves `streamId`, `sequence`, and final `endOfStream`
175
+ - never routes payloads through JSON
176
+
177
+ Example:
178
+
179
+ ```js
180
+ import {
181
+ createBrowserModuleHarness,
182
+ createModuleFlatBufferStreamPump,
183
+ } from "space-data-module-sdk";
184
+
185
+ const harness = await createBrowserModuleHarness({
186
+ wasmSource,
187
+ surface: "direct",
188
+ });
189
+
190
+ const pump = createModuleFlatBufferStreamPump({
191
+ harness,
192
+ methodId: "upsert_records",
193
+ portId: "records",
194
+ maxFramesPerInvoke: 64,
195
+ typeResolver(_payload, context) {
196
+ return {
197
+ acceptsAnyFlatbuffer: true,
198
+ fileIdentifier: context.rawFileIdentifier,
199
+ };
200
+ },
201
+ });
202
+
203
+ await pump.pushBytes(chunkA);
204
+ await pump.pushBytes(chunkB);
205
+ await pump.finish();
206
+ ```
207
+
208
+ This is the right shape for OrbPro-style browser ingest when:
209
+
210
+ - the raw FlatBuffer payloads are the source of truth
211
+ - the UI/runtime should not materialize JS record mirrors
212
+ - a resident module should own FlatSQL/query state directly
213
+
214
+ It is still batch-oriented per invoke, but it removes the architectural
215
+ anti-pattern of building one monolithic request envelope for a long-running
216
+ stream.
217
+
218
+ ## Example Import Path
219
+
220
+ ```js
221
+ import {
222
+ createFlatBufferStreamIngestor,
223
+ createRuntimeHost,
224
+ } from "space-data-module-sdk/runtime-host";
225
+
226
+ const host = createRuntimeHost();
227
+ const ingestor = createFlatBufferStreamIngestor({
228
+ rows: host.rows,
229
+ });
230
+
231
+ ingestor.pushBytes(chunkA);
232
+ ingestor.pushBytes(chunkB);
233
+ ingestor.finish();
234
+
235
+ const rows = host.rows.listRows("OMM");
236
+ ```
237
+
238
+ ## Performance Guidance
239
+
240
+ There are two distinct performance questions:
241
+
242
+ 1. Outer transport ingest throughput
243
+ 2. Module invoke throughput
244
+
245
+ Do not mix them into one benchmark.
246
+
247
+ ### Outer Transport Benchmark
248
+
249
+ Use the runtime-host stream ingestor.
250
+
251
+ Commands:
252
+
253
+ ```bash
254
+ npm run test:stream-ingest
255
+ npm run benchmark:stream-1gib
256
+ ```
257
+
258
+ Optional tuning:
259
+
260
+ - `SPACE_DATA_MODULE_SDK_STREAM_BENCH_BYTES`
261
+ - `SPACE_DATA_MODULE_SDK_STREAM_BENCH_PAYLOAD_BYTES`
262
+ - `SPACE_DATA_MODULE_SDK_STREAM_BENCH_CHUNK_BYTES`
263
+
264
+ The 1 GiB benchmark is env-gated on purpose. It is a local stress path, not a
265
+ default suite member.
266
+
267
+ ### Module Invoke Benchmark
268
+
269
+ Benchmark direct invoke separately with many smaller requests and a tiny
270
+ response. Treat the current invoke ABI as batch-oriented, not as a raw stream
271
+ transport.
272
+
273
+ Recommended total sizes:
274
+
275
+ - CI / regular local: `1 MiB`, `8 MiB`, `32 MiB`, `128 MiB`
276
+ - local stress: `256 MiB` or higher in chunked totals
277
+
278
+ Avoid a single 1 GiB request envelope on the current codepath.
279
+
280
+ For the resident module-ingest shape, use:
281
+
282
+ ```bash
283
+ npm run test:module-stream
284
+ npm run benchmark:module-stream-1gib
285
+ ```
286
+
287
+ That benchmark exercises the chunked module stream-pump path, not a single huge
288
+ invoke buffer.
289
+
290
+ ## Current Non-Canonical Example
291
+
292
+ [`examples/flatsql-store-local`](../examples/flatsql-store-local) is still
293
+ useful as an adapter example, but it is not the canonical durable identity
294
+ model. It exposes a module-owned mutable logical database. The canonical model
295
+ for cross-host durability is host-owned rows plus host-owned runtime regions.
296
+
297
+ ## Body-Reference Delivery (`"deliver":"ref"`)
298
+
299
+ Loop C.5c adds an OPTIONAL near-zero-copy egress mode for capability
300
+ hostcalls whose result is an aligned stream that the module passes through
301
+ VERBATIM to an HTTP response body (the retrieval flow's flatbuffer branch).
302
+ The election is always the GUEST's; hosts never invent it.
303
+
304
+ 1. The module adds `"deliver":"ref"` to the hostcall payload
305
+ (`storage.flatsql_query_stream` / `storage.flatsql_epoch_stream`).
306
+ 2. A ref-capable host keeps the materialized bytes in ITS memory, registers
307
+ them on the calling instance's hostcall-bridge body-ref registry, and
308
+ answers with NO binary segment:
309
+
310
+ ```json
311
+ {"ok":true,"result":{"rows":N,"columns":M,
312
+ "ref":{"token":T,"size":S,"frames":F,"fnv1a64":"<16 hex>"}}}
313
+ ```
314
+
315
+ - `token` — opaque, single-use, scoped to this module instance's bridge
316
+ and the current exchange.
317
+ - `size` — byte length of the referenced stream.
318
+ - `frames` — size-prefixed frame count, skipping zero-length prefixes
319
+ (the `x-sdn-record-count` rule); omitted when the framing is malformed.
320
+ - `fnv1a64` — word-folded FNV-1a 64 content hash (`fnv1a64Hex` in
321
+ `space-data-module-sdk/http` is the reference implementation; it is
322
+ bit-identical to foundation/decision-gate's in-wasm hasher, so
323
+ reference-mode entity tags equal hashed-stream entity tags).
324
+
325
+ A host that does not understand `deliver` simply returns the byte
326
+ segment as always; modules MUST fall back to verbatim byte passthrough.
327
+ 3. The module forwards the reference in-band as a small JSON descriptor
328
+ frame `{"$sdnbodyref":1,"token":T,"size":S,"frames":F,"fnv1a64":"…"}`
329
+ (an aligned stream can never collide: it starts with a `u32le` size
330
+ prefix, not `{`).
331
+ 4. `foundation/http-respond` recognizes the descriptor on its body port and
332
+ emits `$HTR` with `BODY_REF_TOKEN`/`BODY_REF_SIZE` set and NO inline
333
+ body (schema `HttpResponseAbi.fbs`).
334
+ 5. The host egress substitutes the byte buffer registered under the token
335
+ (Go: `flowrt.htrPipe` + `modulert.HostBridge.TakeBodyRef`; JS:
336
+ `createBodyRefRegistry` from `space-data-module-sdk/http`). Tokens are
337
+ single-use; hosts drop unconsumed references at end-of-exchange (304 and
338
+ error paths never consume theirs).
339
+
340
+ The stream bytes therefore never enter the flow's linear memory: the only
341
+ byte movement left on a warm request is the host's socket write.