space-data-module-sdk 0.8.5 → 0.8.7

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 (34) hide show
  1. package/README.md +13 -0
  2. package/docs/AGENTS.md +5 -0
  3. package/docs/browser-wasmedge-isomorphic.md +64 -0
  4. package/docs/provider-access-abi.md +600 -0
  5. package/package.json +3 -2
  6. package/schemas/orbpro/Propagator.fbs +19 -3
  7. package/src/compiler/compileModule.js +24 -1
  8. package/src/flow/flowCompiler.js +141 -2
  9. package/src/flow/flowRuntimeHost.js +7 -1
  10. package/src/flow/vendor/sdn-flow/MethodRegistry.js +6 -1
  11. package/src/generated/orbpro/propagator/propagator-source-description.js +2 -2
  12. package/src/generated/orbpro/propagator/propagator-source-description.ts +2 -2
  13. package/src/generated/orbpro/propagator/propagator-source-kind.js +13 -2
  14. package/src/generated/orbpro/propagator/propagator-source-kind.ts +13 -2
  15. package/src/generated/spacedatastandards/plg/pluginCategory.d.ts +18 -1
  16. package/src/generated/spacedatastandards/plg/pluginCategory.d.ts.map +1 -1
  17. package/src/generated/spacedatastandards/plg/pluginCategory.js +17 -0
  18. package/src/generated/spacedatastandards/plg/pluginCategory.ts +21 -1
  19. package/src/host/index.js +6 -0
  20. package/src/host/providerAccess.js +727 -0
  21. package/src/host/providerAccessAbi.js +403 -0
  22. package/src/host/providerAccessEngineAdapter.js +338 -0
  23. package/src/host/providerAccessFixtureAdapter.js +444 -0
  24. package/src/host/providerAccessTileStoreAdapter.js +366 -0
  25. package/src/host/terrainSourceSeam.js +205 -0
  26. package/src/host/wasiThreadHost.js +12 -1
  27. package/src/index.d.ts +39 -4
  28. package/src/testing/browserModuleHarness.js +48 -0
  29. package/src/testing/index.d.ts +12 -1
  30. package/src/testing/parityBrowserRunner.js +8 -1
  31. package/src/testing/workerModuleHarness.js +36 -7
  32. package/src/testing/workerModuleHarnessWorker.js +5 -4
  33. package/src/transport/pki.js +57 -7
  34. package/templates/provider-access-module/include/space_data_provider_abi.h +227 -0
package/README.md CHANGED
@@ -277,6 +277,19 @@ GPU-accelerated modules should follow the host-owned GPU capability standard in
277
277
  header and starter manifest live in
278
278
  [`templates/gpu-module`](./templates/gpu-module).
279
279
 
280
+ Modules that need to control imagery/terrain providers or read the decoded tile
281
+ bytes those providers already hold use the Provider Access ABI in
282
+ [`docs/provider-access-abi.md`](./docs/provider-access-abi.md); the guest header
283
+ is
284
+ [`templates/provider-access-module/include/space_data_provider_abi.h`](./templates/provider-access-module/include/space_data_provider_abi.h).
285
+ It is one generalized port over two planes — control on the existing
286
+ `space_data_module_host` bridge, data on three dedicated `space_data_provider`
287
+ imports that write straight into guest linear memory (one copy, no re-decode).
288
+ In the browser it is satisfied from live engine provider objects; under
289
+ WasmEdge from a host-side tile store built on the existing `filesystem`/`http`
290
+ capabilities; and where nothing is bound it returns the same error code every
291
+ runtime returns, as a value rather than a trap.
292
+
280
293
  The GPU surface is intentionally host-owned. A portable module advertises the
281
294
  optional `gpu_compute` capability with scope `webgpu.v1`, keeps a correct CPU
282
295
  fallback in `dist/isomorphic/module.wasm`, and lets the embedding host choose a
package/docs/AGENTS.md CHANGED
@@ -19,6 +19,11 @@ they use words like "canonical", "required", or "must".
19
19
  - Keep binary FlatBuffer ingest guidance aligned with
20
20
  `docs/flatsql-streaming-standard.md`.
21
21
  - Keep testing claims aligned with `docs/testing-harness.md`.
22
+ - Imagery/terrain provider access is `docs/provider-access-abi.md`. The guest
23
+ port is exactly three `space_data_provider` imports, all i32; control rides
24
+ the existing `space_data_module_host` bridge as `provider.*`. Never add a
25
+ fourth import, never put tile bytes in a hostcall envelope, and never let an
26
+ adapter exceed the request's declared `maxCost`.
22
27
  - If you change user-facing behavior, update the nearest example README as well.
23
28
 
24
29
  ## Read These First
@@ -43,6 +43,70 @@ worker hooks, or the compile is rejected. That guardrail is documented in
43
43
  covers the portable `single-thread` loading profile; read the pthreads doc
44
44
  before shipping a threaded WasmEdge artifact.
45
45
 
46
+ ## Cross-Origin Isolation Is Required For Any wasi-threads/wasi-sequential Guest
47
+
48
+ **Settled policy** (`module-sdk-target-forces-sab-coop-coep`, arbitrated
49
+ 2026-07-28, closed 2026-08-06): a host serving a module built through the
50
+ `wasm32-wasip1-threads` toolchain — the `emscripten-pthreads` (real threading)
51
+ model **or** the `wasi-sequential` model — to a browser MUST serve that page
52
+ cross-origin isolated (`Cross-Origin-Opener-Policy: same-origin` +
53
+ `Cross-Origin-Embedder-Policy: require-corp`, or the equivalent). There is no
54
+ build-flag escape hatch:
55
+
56
+ - `--target=wasm32-wasip1-threads` with **zero** feature flags still emits
57
+ `+atomics` — the triple implies atomics.
58
+ - A driver-default link on that triple declares a **shared** memory (limits
59
+ flags `0x03`) with no `--shared-memory`/`--import-memory` on the link line.
60
+ - `--no-shared-memory` is not a wasm-ld flag. Nothing in `compileModule.js`
61
+ can produce an unshared artifact on this triple. See the guardrail chain in
62
+ [`src/compiler/pthreadArtifactGuard.js`](/Users/tj/software/space-data-module-sdk/src/compiler/pthreadArtifactGuard.js)
63
+ (`assertSequentialArtifact`) and [`docs/isomorphic-pthreads.md`](./isomorphic-pthreads.md).
64
+
65
+ This means an inherently-sequential guest (`wasi-sequential`, no real
66
+ threading) still needs a shared-memory instantiation — same as a real threaded
67
+ guest — because it shares the same compiled triple. The portable
68
+ **`single-thread`** profile this document otherwise covers (Emscripten/
69
+ emception, the `["browser"]` / `["browser","wasmedge"]` default: no shared
70
+ memory, no atomics) is the one exception and needs **no** cross-origin
71
+ isolation. Check which profile a guest actually uses — `runtimeTargets` alone
72
+ does not tell you; an explicit `threadModel` does — before assuming either
73
+ way.
74
+
75
+ **How production achieves it today** (both patterns are live and
76
+ `crossOriginIsolated`-verified, not hypothetical):
77
+
78
+ 1. **Native headers**, when the host directly fronts the origin (e.g. a
79
+ Caddy-fronted droplet): set `Cross-Origin-Opener-Policy: same-origin` and
80
+ `Cross-Origin-Embedder-Policy: require-corp` at the web server, which
81
+ survives a CDN in front of it.
82
+ 2. **A COI service worker**, when the host is a static CDN that cannot set
83
+ custom response headers (GitHub Pages is the concrete case: Pages sends no
84
+ COOP/COEP at all). The worker intercepts navigation/asset fetches and
85
+ re-serves them with the isolation headers injected, then the page does one
86
+ capped self-heal reload. Reference implementation:
87
+ `coi-serviceworker.js` + `coi-bootstrap.js` in the `spaceaware-ui`
88
+ (`sdn-js`) and OrbPro Pages surfaces — verified live via
89
+ `window.crossOriginIsolated === true` and `typeof SharedArrayBuffer !==
90
+ "undefined"` in a real browser, per `deployment/topology.json`. Do not
91
+ invent a second shim; port that one.
92
+
93
+ Either path additionally constrains **every other subresource** the page
94
+ loads to be CORP/CORS-clean under `require-corp` — third-party embeds, fonts,
95
+ tiles, imagery all have to cooperate. This is exactly the surface the
96
+ standing "node UIs load ZERO external-origin bytes" law removes as a concern
97
+ for the surfaces that already follow it; a new module-serving surface that
98
+ does NOT yet follow that law has to solve subresource compatibility
99
+ separately, before COI, not after.
100
+
101
+ **The guardrail, concretely**: verify `crossOriginIsolated`/`SharedArrayBuffer`
102
+ with a real browser (`live-verify.mjs`-style, not a raw `curl -I` — a
103
+ service-worker-injected header is invisible to a plain HTTP request) as part
104
+ of standing up ANY new surface that serves a `wasi-threads`/`wasi-sequential`
105
+ artifact, before assuming module instantiation works. A silent regression here
106
+ fails as an instantiation error in the browser console, not a build error —
107
+ there is currently no automated CI check for it; add one alongside the new
108
+ surface's own verify tooling rather than assuming this document is enough.
109
+
46
110
  ## Canonical Module Repo Layout
47
111
 
48
112
  Module repos should publish the shared compiled artifact under a stable runtime