flatsql 3.11.0 → 3.12.0

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 (181) hide show
  1. package/README.md +61 -795
  2. package/bin/flatsql.mjs +76 -0
  3. package/cpp/README.md +18 -0
  4. package/cpp/include/flatsql/flatsql.h +162 -0
  5. package/cpp/include/flatsql/flatsql_io.h +159 -0
  6. package/docs/API-3.12.md +114 -0
  7. package/package.json +28 -123
  8. package/wasm/flatsql.wasm +0 -0
  9. package/wasm/index.d.ts +61 -548
  10. package/wasm/index.js +280 -1281
  11. package/wasm/integrity.json +6 -26
  12. package/wasm/runtime/LICENSE.sdk.txt +190 -0
  13. package/wasm/runtime/NOTICE.txt +2 -0
  14. package/wasm/runtime/browser-guest.mjs +1 -0
  15. package/wasm/runtime/browser-host.mjs +1 -0
  16. package/wasm/runtime/node-guest.mjs +2 -0
  17. package/wasm/runtime/node-host.mjs +5 -0
  18. package/wasm/runtime/opfsIoWorker.mjs +1 -0
  19. package/wasm/runtime/wasiThreadBrowserWorker.mjs +1 -0
  20. package/dist/artifacts/index.d.ts +0 -3
  21. package/dist/artifacts/index.d.ts.map +0 -1
  22. package/dist/artifacts/index.js +0 -3
  23. package/dist/artifacts/index.js.map +0 -1
  24. package/dist/artifacts/transport.d.ts +0 -5
  25. package/dist/artifacts/transport.d.ts.map +0 -1
  26. package/dist/artifacts/transport.js +0 -45
  27. package/dist/artifacts/transport.js.map +0 -1
  28. package/dist/artifacts/types.d.ts +0 -34
  29. package/dist/artifacts/types.d.ts.map +0 -1
  30. package/dist/artifacts/types.js +0 -2
  31. package/dist/artifacts/types.js.map +0 -1
  32. package/dist/btree/btree.d.ts +0 -34
  33. package/dist/btree/btree.d.ts.map +0 -1
  34. package/dist/btree/btree.js +0 -234
  35. package/dist/btree/btree.js.map +0 -1
  36. package/dist/btree/index.d.ts +0 -3
  37. package/dist/btree/index.d.ts.map +0 -1
  38. package/dist/btree/index.js +0 -3
  39. package/dist/btree/index.js.map +0 -1
  40. package/dist/btree/types.d.ts +0 -36
  41. package/dist/btree/types.d.ts.map +0 -1
  42. package/dist/btree/types.js +0 -55
  43. package/dist/btree/types.js.map +0 -1
  44. package/dist/cluster/index.d.ts +0 -11
  45. package/dist/cluster/index.d.ts.map +0 -1
  46. package/dist/cluster/index.js +0 -59
  47. package/dist/cluster/index.js.map +0 -1
  48. package/dist/response/artifact.d.ts +0 -4
  49. package/dist/response/artifact.d.ts.map +0 -1
  50. package/dist/response/artifact.js +0 -102
  51. package/dist/response/artifact.js.map +0 -1
  52. package/dist/response/cache-key.d.ts +0 -6
  53. package/dist/response/cache-key.d.ts.map +0 -1
  54. package/dist/response/cache-key.js +0 -114
  55. package/dist/response/cache-key.js.map +0 -1
  56. package/dist/response/index.d.ts +0 -5
  57. package/dist/response/index.d.ts.map +0 -1
  58. package/dist/response/index.js +0 -5
  59. package/dist/response/index.js.map +0 -1
  60. package/dist/response/memory-cache.d.ts +0 -17
  61. package/dist/response/memory-cache.d.ts.map +0 -1
  62. package/dist/response/memory-cache.js +0 -76
  63. package/dist/response/memory-cache.js.map +0 -1
  64. package/dist/response/types.d.ts +0 -57
  65. package/dist/response/types.d.ts.map +0 -1
  66. package/dist/response/types.js +0 -2
  67. package/dist/response/types.js.map +0 -1
  68. package/dist/schema/index.d.ts +0 -3
  69. package/dist/schema/index.d.ts.map +0 -1
  70. package/dist/schema/index.js +0 -3
  71. package/dist/schema/index.js.map +0 -1
  72. package/dist/schema/parser.d.ts +0 -25
  73. package/dist/schema/parser.d.ts.map +0 -1
  74. package/dist/schema/parser.js +0 -474
  75. package/dist/schema/parser.js.map +0 -1
  76. package/dist/schema/types.d.ts +0 -33
  77. package/dist/schema/types.d.ts.map +0 -1
  78. package/dist/schema/types.js +0 -29
  79. package/dist/schema/types.js.map +0 -1
  80. package/dist/standalone/index.d.ts +0 -3
  81. package/dist/standalone/index.d.ts.map +0 -1
  82. package/dist/standalone/index.js +0 -3
  83. package/dist/standalone/index.js.map +0 -1
  84. package/dist/standalone/process-client.d.ts +0 -85
  85. package/dist/standalone/process-client.d.ts.map +0 -1
  86. package/dist/standalone/process-client.js +0 -537
  87. package/dist/standalone/process-client.js.map +0 -1
  88. package/dist/standalone/wasmedge-runner.d.ts +0 -19
  89. package/dist/standalone/wasmedge-runner.d.ts.map +0 -1
  90. package/dist/standalone/wasmedge-runner.js +0 -108
  91. package/dist/standalone/wasmedge-runner.js.map +0 -1
  92. package/dist/storage/index.d.ts +0 -3
  93. package/dist/storage/index.d.ts.map +0 -1
  94. package/dist/storage/index.js +0 -3
  95. package/dist/storage/index.js.map +0 -1
  96. package/dist/storage/stacked-flatbuffers.d.ts +0 -38
  97. package/dist/storage/stacked-flatbuffers.d.ts.map +0 -1
  98. package/dist/storage/stacked-flatbuffers.js +0 -253
  99. package/dist/storage/stacked-flatbuffers.js.map +0 -1
  100. package/dist/storage/types.d.ts +0 -23
  101. package/dist/storage/types.d.ts.map +0 -1
  102. package/dist/storage/types.js +0 -27
  103. package/dist/storage/types.js.map +0 -1
  104. package/dist/stress/aggregate.d.ts +0 -3
  105. package/dist/stress/aggregate.d.ts.map +0 -1
  106. package/dist/stress/aggregate.js +0 -61
  107. package/dist/stress/aggregate.js.map +0 -1
  108. package/dist/stress/docker-compose.d.ts +0 -17
  109. package/dist/stress/docker-compose.d.ts.map +0 -1
  110. package/dist/stress/docker-compose.js +0 -156
  111. package/dist/stress/docker-compose.js.map +0 -1
  112. package/dist/stress/index.d.ts +0 -10
  113. package/dist/stress/index.d.ts.map +0 -1
  114. package/dist/stress/index.js +0 -10
  115. package/dist/stress/index.js.map +0 -1
  116. package/dist/stress/metrics.d.ts +0 -3
  117. package/dist/stress/metrics.d.ts.map +0 -1
  118. package/dist/stress/metrics.js +0 -83
  119. package/dist/stress/metrics.js.map +0 -1
  120. package/dist/stress/native-publish-event-workload.d.ts +0 -3
  121. package/dist/stress/native-publish-event-workload.d.ts.map +0 -1
  122. package/dist/stress/native-publish-event-workload.js +0 -465
  123. package/dist/stress/native-publish-event-workload.js.map +0 -1
  124. package/dist/stress/production-gate.d.ts +0 -4
  125. package/dist/stress/production-gate.d.ts.map +0 -1
  126. package/dist/stress/production-gate.js +0 -12
  127. package/dist/stress/production-gate.js.map +0 -1
  128. package/dist/stress/report.d.ts +0 -3
  129. package/dist/stress/report.d.ts.map +0 -1
  130. package/dist/stress/report.js +0 -174
  131. package/dist/stress/report.js.map +0 -1
  132. package/dist/stress/sds-discovery.d.ts +0 -4
  133. package/dist/stress/sds-discovery.d.ts.map +0 -1
  134. package/dist/stress/sds-discovery.js +0 -40
  135. package/dist/stress/sds-discovery.js.map +0 -1
  136. package/dist/stress/smoke-runner.d.ts +0 -3
  137. package/dist/stress/smoke-runner.d.ts.map +0 -1
  138. package/dist/stress/smoke-runner.js +0 -64
  139. package/dist/stress/smoke-runner.js.map +0 -1
  140. package/dist/stress/types.d.ts +0 -219
  141. package/dist/stress/types.d.ts.map +0 -1
  142. package/dist/stress/types.js +0 -2
  143. package/dist/stress/types.js.map +0 -1
  144. package/dist/stress/workload.d.ts +0 -6
  145. package/dist/stress/workload.d.ts.map +0 -1
  146. package/dist/stress/workload.js +0 -144
  147. package/dist/stress/workload.js.map +0 -1
  148. package/docs/PARTITION-STORE-WASM.md +0 -338
  149. package/docs/PARTITION-STORE.md +0 -2380
  150. package/docs/agents/response-artifacts.md +0 -65
  151. package/docs/response-artifacts.md +0 -86
  152. package/scripts/stress-docker.sh +0 -279
  153. package/sdm/flatsql-spatial.wasm +0 -0
  154. package/sdm/index.d.ts +0 -88
  155. package/sdm/index.js +0 -253
  156. package/sdm/manifest.json +0 -402
  157. package/stress/docker/Dockerfile +0 -11
  158. package/stress/docker/docker-compose.yml +0 -51
  159. package/stress/sds/aggregate.mjs +0 -97
  160. package/stress/sds/run.mjs +0 -105
  161. package/stress/sds/write-compose.mjs +0 -96
  162. package/wasm/flatsql-client.js +0 -280
  163. package/wasm/flatsql-io.d.ts +0 -97
  164. package/wasm/flatsql-io.js +0 -621
  165. package/wasm/flatsql-p4-threads.wasm +0 -0
  166. package/wasm/flatsql-ps-threads.wasm +0 -0
  167. package/wasm/flatsql-wasi-noeh.wasm +0 -0
  168. package/wasm/flatsql-wasi.wasm +0 -0
  169. package/wasm/flatsql.js +0 -2
  170. package/wasm/flatsql.worker.js +0 -209
  171. package/wasm/native/flatsql_wasmedge_runner.cpp +0 -858
  172. package/wasm/ps-node-fault.d.mts +0 -23
  173. package/wasm/ps-node-fault.mjs +0 -381
  174. package/wasm/ps-node-guest.mjs +0 -173
  175. package/wasm/ps-node-host.d.mts +0 -95
  176. package/wasm/ps-node-host.mjs +0 -476
  177. package/wasm/ps-node-imports.mjs +0 -847
  178. package/wasm/ps.d.ts +0 -21
  179. package/wasm/ps.js +0 -75
  180. package/wasm/wasi.d.ts +0 -11
  181. package/wasm/wasi.js +0 -51
@@ -1,65 +0,0 @@
1
- # Agent Guide: Response Bandwidth
2
-
3
- Use this guide when modifying FlatSQL response caching, SDS stress tests, or Space Data Network FILE_ID behavior.
4
-
5
- ## Rules
6
-
7
- - Do not add FlatSQL-specific fields or annotations to canonical SDS schemas.
8
- - Treat `FILE_ID` as a Space Data Network publish-event policy key.
9
- - Use runtime indexes or external SDN index profiles for lookup speed.
10
- - Measure response bytes separately from query latency and cache hits.
11
- - Prefer raw FlatBuffer artifacts for repeated high-volume responses.
12
- - Tune native query-template cache limits with `configureQueryCache({ maxEntries, maxRows })` when hot FILE_ID traffic needs more than the defaults.
13
-
14
- ## Library Responsibilities
15
-
16
- FlatSQL response bandwidth work belongs in these primitives:
17
-
18
- - native `buildResponseArtifactCacheKey(...)` bindings for deterministic query/result cache keys
19
- - `createQueryResponseArtifact(...)` for immutable byte artifacts
20
- - `getResponseArtifactChunk(...)` for range-addressable chunk reads
21
- - `MemoryResponseArtifactCache.getOrCreateByKey(...)` for bounded process-local artifact reuse with native keys
22
-
23
- Deployment code is responsible for CDN, browser Cache API, WasmEdge host filesystem cache, auth, quotas, routing, and regional replication.
24
-
25
- ## Required Tests
26
-
27
- When changing response artifacts, run:
28
-
29
- ```bash
30
- npm test -- --runInBand --runTestsByPath test/response-artifact.test.ts
31
- npm test -- --runInBand --runTestsByPath test/wasm-query-params.test.ts test/standalone-shim.test.ts test/standalone-artifact-builder.test.ts test/wasmedge-runner.test.ts
32
- npm test -- --runInBand --runTestsByPath test/stress-harness.test.ts
33
- npm run build
34
- ```
35
-
36
- Before claiming production readiness, also run:
37
-
38
- ```bash
39
- npm test -- --runInBand
40
- npm run stress:sds:full-config -- --run-id sds-full-config-check
41
- docker compose -f stress/results/sds-full-config-check/docker-compose.full.yml config
42
- git diff --check
43
- ```
44
-
45
- ## SDS Stress Interpretation
46
-
47
- The SDS harness reports measured events. A cache hit is not enough. If `responseBytes` remains high, repeated clients are still consuming bandwidth unless the response artifact is served from edge/browser/WasmEdge host cache.
48
-
49
- For hot publish events, look at:
50
-
51
- - `hot-file-id-cache.responseBytes`
52
- - `raw-flatbuffer-retrieval.responseBytes`
53
- - `sql-projection-query.responseBytes`
54
- - `bulk-streaming-ingest.requestBytes`
55
- - aggregate `ingestRecordsPerSecond` and `minNodeIngestRecordsPerSecond`; every node must stay at or above 75 fps for production readiness
56
- - `bandwidth-constrained-streaming.requestBytes`
57
- - per-node `storageBytes` and storage fill percentage; every node must reach at least 95% of its configured storage target
58
-
59
- ## Common Mistakes
60
-
61
- - Calling a run successful because query latency improved while response bytes remain unchanged.
62
- - Requiring fields like `file_identifier`, `indexed`, `key`, or `id` in SDS schemas.
63
- - Returning JSON for large repeated query results when raw FlatBuffer bytes are acceptable.
64
- - Building a process-local cache and assuming it solves 2M-user egress.
65
- - Omitting schema version, projection, format, or publish-event key from a cache key.
@@ -1,86 +0,0 @@
1
- # Response Artifacts
2
-
3
- FlatSQL reduces response bandwidth by producing cacheable response artifacts. The library owns deterministic byte output, cache keys, hashes, ETags, and chunk metadata. Deployment infrastructure owns CDN placement, global invalidation, routing, authorization, and quotas.
4
-
5
- ## Boundary
6
-
7
- FlatSQL should do:
8
-
9
- - build deterministic cache keys in the C++/WASM core from query shape, schema version, format, projection, params, and publish-event key
10
- - encode raw FlatBuffer query results as size-prefixed byte streams
11
- - encode JSON results only when callers explicitly request JSON
12
- - produce content hashes and ETags for immutable artifacts
13
- - split artifacts into range-addressable chunks
14
- - expose small process-local caches for repeated query artifacts
15
-
16
- FlatSQL should not do:
17
-
18
- - add database-specific annotations to canonical SDS schemas
19
- - implement a CDN or global cache-invalidation service
20
- - decide authorization or tenant-specific cache policy
21
- - route users to regions or nodes
22
- - hide response byte cost behind a query-cache hit counter
23
-
24
- ## Recommended FILE_ID Flow
25
-
26
- For Space Data Network publish events, `FILE_ID` is a network policy key, not a schema requirement.
27
-
28
- 1. Ingest records for a publish event.
29
- 2. Apply `FILE_ID` indexes through runtime policy or SDN index profiles.
30
- 3. Query the publish event with a stable projection and format.
31
- 4. Create a response artifact.
32
- 5. Serve the artifact by `ETag` or content hash from edge, browser, WasmEdge host storage, or a CDN.
33
- 6. Recompute only when the publish event, schema version, projection, or format changes.
34
-
35
- ```ts
36
- import {
37
- createQueryResponseArtifact,
38
- MemoryResponseArtifactCache,
39
- } from 'flatsql/response';
40
- import initFlatSQL from 'flatsql/wasm';
41
-
42
- const flatsql = await initFlatSQL();
43
- const sql = "SELECT _data FROM PublishEventRecord WHERE FILE_ID = ?";
44
- const cacheKey = flatsql.buildResponseArtifactCacheKey('PublishEventRecord', '1', sql, {
45
- format: 'raw-flatbuffer-stream',
46
- publishEventKey: 'publish-1',
47
- projection: ['_data'],
48
- params: ['publish-1'],
49
- });
50
- const result = db.query(sql);
51
- const cache = new MemoryResponseArtifactCache();
52
-
53
- const artifact = cache.getOrCreateByKey(cacheKey, () => createQueryResponseArtifact(result, {
54
- schemaName: 'PublishEventRecord',
55
- schemaVersion: 1,
56
- sql,
57
- params: ['publish-1'],
58
- format: 'raw-flatbuffer-stream',
59
- publishEventKey: 'publish-1',
60
- projection: ['_data'],
61
- cacheKey,
62
- chunkBytes: 1024 * 1024,
63
- }));
64
-
65
- console.log(cacheKey);
66
- console.log(artifact.metadata.etag);
67
- console.log(artifact.metadata.chunks);
68
- ```
69
-
70
- ## Production Checks
71
-
72
- Before relying on response artifacts in production:
73
-
74
- - verify `cacheKey` includes every dimension that can change bytes
75
- - verify browser and WasmEdge runtimes produce the same native response cache key
76
- - prefer `raw-flatbuffer-stream` for high-volume SDS responses
77
- - verify `responseBytes` and `flatbufferBytes`, not only query latency
78
- - tune native `configureQueryCache({ maxEntries, maxRows })` limits for hot FILE_ID query templates
79
- - set chunk sizes based on edge/cache/range-request behavior
80
- - cap in-process caches with `maxEntries` and `maxBytes`
81
- - keep authorization outside shared immutable artifacts unless all callers are allowed to read identical bytes
82
- - test hot `FILE_ID` traffic separately from cold fanout
83
-
84
- ## Runtime Notes
85
-
86
- Browser deployments should call the native `buildResponseArtifactCacheKey(...)` binding through `flatsql/wasm` or `flatsql/standalone`, then map artifact metadata to HTTP cache headers and the browser Cache API where appropriate. WasmEdge deployments should call the same binding through `flatsql/artifacts/standalone` and map artifacts to host filesystem or edge-local object cache. FlatSQL response artifacts are intentionally plain bytes plus metadata so either runtime can use the same cache key and ETag semantics.
@@ -1,279 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -euo pipefail
4
-
5
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
- PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
7
-
8
- COMMAND="smoke"
9
- if [[ $# -gt 0 ]]; then
10
- COMMAND="$1"
11
- shift
12
- fi
13
-
14
- RUN_ID="${RUN_ID:-sds-$(date -u +%Y%m%dT%H%M%SZ)}"
15
- SDS_SCHEMA_ROOT="${SDS_SCHEMA_ROOT:-$PROJECT_ROOT/../spacedatastandards.org/schema}"
16
- if [[ -n "${OUTPUT_DIR:-}" ]]; then
17
- OUTPUT_DIR_EXPLICIT=1
18
- else
19
- OUTPUT_DIR_EXPLICIT=0
20
- OUTPUT_DIR="$PROJECT_ROOT/stress/results/$RUN_ID"
21
- fi
22
-
23
- EXTRA_RUNNER_ARGS=()
24
- while [[ $# -gt 0 ]]; do
25
- case "$1" in
26
- --schema-root)
27
- SDS_SCHEMA_ROOT="$2"
28
- shift 2
29
- ;;
30
- --schema-root=*)
31
- SDS_SCHEMA_ROOT="${1#*=}"
32
- shift
33
- ;;
34
- --output-dir)
35
- OUTPUT_DIR="$2"
36
- OUTPUT_DIR_EXPLICIT=1
37
- shift 2
38
- ;;
39
- --output-dir=*)
40
- OUTPUT_DIR="${1#*=}"
41
- OUTPUT_DIR_EXPLICIT=1
42
- shift
43
- ;;
44
- --nodes)
45
- NODE_COUNT="$2"
46
- shift 2
47
- ;;
48
- --nodes=*)
49
- NODE_COUNT="${1#*=}"
50
- shift
51
- ;;
52
- --node-id-offset)
53
- NODE_ID_OFFSET="$2"
54
- shift 2
55
- ;;
56
- --node-id-offset=*)
57
- NODE_ID_OFFSET="${1#*=}"
58
- shift
59
- ;;
60
- --storage-gb)
61
- NODE_STORAGE_GB="$2"
62
- shift 2
63
- ;;
64
- --storage-gb=*)
65
- NODE_STORAGE_GB="${1#*=}"
66
- shift
67
- ;;
68
- --records-per-node)
69
- RECORDS_PER_NODE="$2"
70
- shift 2
71
- ;;
72
- --records-per-node=*)
73
- RECORDS_PER_NODE="${1#*=}"
74
- shift
75
- ;;
76
- --batch-bytes)
77
- BATCH_BYTES="$2"
78
- shift 2
79
- ;;
80
- --batch-bytes=*)
81
- BATCH_BYTES="${1#*=}"
82
- shift
83
- ;;
84
- --query-concurrency)
85
- QUERY_CONCURRENCY="$2"
86
- shift 2
87
- ;;
88
- --query-concurrency=*)
89
- QUERY_CONCURRENCY="${1#*=}"
90
- shift
91
- ;;
92
- --hot-query-ratio)
93
- HOT_QUERY_RATIO="$2"
94
- shift 2
95
- ;;
96
- --hot-query-ratio=*)
97
- HOT_QUERY_RATIO="${1#*=}"
98
- shift
99
- ;;
100
- --runtime)
101
- RUNTIME="$2"
102
- shift 2
103
- ;;
104
- --runtime=*)
105
- RUNTIME="${1#*=}"
106
- shift
107
- ;;
108
- --node-isolation)
109
- NODE_ISOLATION="$2"
110
- shift 2
111
- ;;
112
- --node-isolation=*)
113
- NODE_ISOLATION="${1#*=}"
114
- shift
115
- ;;
116
- --run-id)
117
- RUN_ID="$2"
118
- shift 2
119
- ;;
120
- --run-id=*)
121
- RUN_ID="${1#*=}"
122
- shift
123
- ;;
124
- *)
125
- EXTRA_RUNNER_ARGS+=("$1")
126
- shift
127
- ;;
128
- esac
129
- done
130
- if [[ "$OUTPUT_DIR_EXPLICIT" -eq 0 ]]; then
131
- OUTPUT_DIR="$PROJECT_ROOT/stress/results/$RUN_ID"
132
- fi
133
- if [[ "${#EXTRA_RUNNER_ARGS[@]}" -gt 0 ]]; then
134
- set -- "${EXTRA_RUNNER_ARGS[@]}"
135
- else
136
- set --
137
- fi
138
-
139
- run_local_smoke() {
140
- local runner_args=(
141
- --mode "${STRESS_MODE:-smoke}"
142
- --schema-root "$SDS_SCHEMA_ROOT"
143
- --output-dir "$OUTPUT_DIR"
144
- --nodes "${NODE_COUNT:-2}"
145
- --storage-gb "${NODE_STORAGE_GB:-0.01}"
146
- --records-per-node "${RECORDS_PER_NODE:-25}"
147
- --run-id "$RUN_ID"
148
- )
149
- if [[ -n "${NODE_ID_OFFSET:-}" ]]; then runner_args+=(--node-id-offset "$NODE_ID_OFFSET"); fi
150
- if [[ -n "${BATCH_BYTES:-}" ]]; then runner_args+=(--batch-bytes "$BATCH_BYTES"); fi
151
- if [[ -n "${QUERY_CONCURRENCY:-}" ]]; then runner_args+=(--query-concurrency "$QUERY_CONCURRENCY"); fi
152
- if [[ -n "${HOT_QUERY_RATIO:-}" ]]; then runner_args+=(--hot-query-ratio "$HOT_QUERY_RATIO"); fi
153
- if [[ -n "${RUNTIME:-}" ]]; then runner_args+=(--runtime "$RUNTIME"); fi
154
- if [[ -n "${NODE_ISOLATION:-}" ]]; then runner_args+=(--node-isolation "$NODE_ISOLATION"); fi
155
- if [[ "$#" -gt 0 ]]; then runner_args+=("$@"); fi
156
-
157
- npm run build
158
- node "$PROJECT_ROOT/stress/sds/run.mjs" "${runner_args[@]}"
159
- }
160
-
161
- run_docker() {
162
- docker info >/dev/null
163
- local schema_root_abs
164
- schema_root_abs="$(cd "$SDS_SCHEMA_ROOT" && pwd)"
165
- mkdir -p "$OUTPUT_DIR"
166
- local output_dir_abs
167
- output_dir_abs="$(cd "$OUTPUT_DIR" && pwd)"
168
- SDS_SCHEMA_ROOT_HOST="$schema_root_abs" \
169
- OUTPUT_DIR_HOST="$output_dir_abs" \
170
- RUN_ID="$RUN_ID" \
171
- STRESS_MODE="${STRESS_MODE:-smoke}" \
172
- NODE_COUNT="${NODE_COUNT:-2}" \
173
- NODE_STORAGE_GB="${NODE_STORAGE_GB:-0.01}" \
174
- RECORDS_PER_NODE="${RECORDS_PER_NODE:-25}" \
175
- BATCH_BYTES="${BATCH_BYTES:-1048576}" \
176
- QUERY_CONCURRENCY="${QUERY_CONCURRENCY:-4}" \
177
- HOT_QUERY_RATIO="${HOT_QUERY_RATIO:-0.9}" \
178
- RUNTIME="${RUNTIME:-standalone}" \
179
- NODE_ISOLATION="${NODE_ISOLATION:-logical}" \
180
- docker compose -f "$PROJECT_ROOT/stress/docker/docker-compose.yml" up \
181
- --build \
182
- --abort-on-container-exit \
183
- --exit-code-from controller \
184
- controller
185
- }
186
-
187
- prepare_container_fleet_compose() {
188
- npm run build
189
-
190
- local schema_root_abs
191
- schema_root_abs="$(cd "$SDS_SCHEMA_ROOT" && pwd)"
192
- mkdir -p "$OUTPUT_DIR"
193
- local output_dir_abs
194
- output_dir_abs="$(cd "$OUTPUT_DIR" && pwd)"
195
- FLEET_COMPOSE_FILE="$output_dir_abs/docker-compose.full.yml"
196
-
197
- node "$PROJECT_ROOT/stress/sds/write-compose.mjs" \
198
- --output-file "$FLEET_COMPOSE_FILE" \
199
- --project-root "$PROJECT_ROOT" \
200
- --schema-root-host "$schema_root_abs" \
201
- --output-dir-host "$output_dir_abs" \
202
- --run-id "$RUN_ID" \
203
- --mode "${STRESS_MODE:-smoke}" \
204
- --nodes "${NODE_COUNT:-2}" \
205
- --storage-gb "${NODE_STORAGE_GB:-0.01}" \
206
- --records-per-node "${RECORDS_PER_NODE:-25}" \
207
- --batch-bytes "${BATCH_BYTES:-1048576}" \
208
- --query-concurrency "${QUERY_CONCURRENCY:-4}" \
209
- --hot-query-ratio "${HOT_QUERY_RATIO:-0.9}" \
210
- --runtime "${RUNTIME:-standalone}"
211
- }
212
-
213
- run_container_fleet() {
214
- prepare_container_fleet_compose
215
- docker info >/dev/null
216
-
217
- local node_count="${NODE_COUNT:-2}"
218
- local worker_services=()
219
- local node_id
220
- for ((node_id = 0; node_id < node_count; node_id++)); do
221
- worker_services+=("worker-$node_id")
222
- done
223
-
224
- docker compose -f "$FLEET_COMPOSE_FILE" up --build "${worker_services[@]}"
225
- docker compose -f "$FLEET_COMPOSE_FILE" build aggregator
226
- docker compose -f "$FLEET_COMPOSE_FILE" run --no-deps --rm aggregator
227
- }
228
-
229
- run_full() {
230
- if [[ "${CONFIRM_FULL_STRESS:-}" != "1" ]]; then
231
- echo "Full stress requires CONFIRM_FULL_STRESS=1 because it targets 100 nodes and 1 GB/node." >&2
232
- exit 2
233
- fi
234
-
235
- local parent
236
- parent="$(dirname "$OUTPUT_DIR")"
237
- mkdir -p "$parent"
238
- local available_kb
239
- available_kb="$(df -Pk "$parent" | awk 'NR == 2 { print $4 }')"
240
- local required_kb=$((110 * 1024 * 1024))
241
- if [[ "$available_kb" -lt "$required_kb" ]]; then
242
- echo "Full stress requires at least 110 GB free near $parent; available KB: $available_kb." >&2
243
- exit 3
244
- fi
245
-
246
- RECORDS_PER_NODE="${RECORDS_PER_NODE:-20000}"
247
- QUERY_CONCURRENCY="${QUERY_CONCURRENCY:-64}"
248
- HOT_QUERY_RATIO="${HOT_QUERY_RATIO:-0.01}"
249
- STRESS_MODE=full NODE_COUNT=100 NODE_STORAGE_GB=1 NODE_ISOLATION=container run_container_fleet
250
- }
251
-
252
- case "$COMMAND" in
253
- smoke)
254
- run_local_smoke "$@"
255
- ;;
256
- docker-smoke)
257
- run_docker "$@"
258
- ;;
259
- docker-fleet)
260
- STRESS_MODE="${STRESS_MODE:-smoke}" NODE_ISOLATION=container run_container_fleet "$@"
261
- ;;
262
- full-config)
263
- RECORDS_PER_NODE="${RECORDS_PER_NODE:-20000}" \
264
- QUERY_CONCURRENCY="${QUERY_CONCURRENCY:-64}" \
265
- HOT_QUERY_RATIO="${HOT_QUERY_RATIO:-0.01}" \
266
- STRESS_MODE=full \
267
- NODE_COUNT="${NODE_COUNT:-100}" \
268
- NODE_STORAGE_GB="${NODE_STORAGE_GB:-1}" \
269
- NODE_ISOLATION=container \
270
- prepare_container_fleet_compose
271
- ;;
272
- full)
273
- run_full "$@"
274
- ;;
275
- *)
276
- echo "Usage: scripts/stress-docker.sh [smoke|docker-smoke|docker-fleet|full-config|full] [runner args]" >&2
277
- exit 2
278
- ;;
279
- esac
Binary file
package/sdm/index.d.ts DELETED
@@ -1,88 +0,0 @@
1
- /**
2
- * FlatSQL Spatial Engine — Space Data Module (SDM)
3
- * TypeScript type definitions
4
- *
5
- * @see https://github.com/DigitalArsenal/space-data-module-sdk
6
- */
7
-
8
- export interface ECEFPoint {
9
- x: number;
10
- y: number;
11
- z: number;
12
- }
13
-
14
- export interface GeodeticPoint {
15
- lat: number;
16
- lon: number;
17
- alt: number;
18
- }
19
-
20
- export interface MethodResult {
21
- status: number;
22
- output: string;
23
- }
24
-
25
- export interface PluginManifest {
26
- pluginId: string;
27
- name: string;
28
- version: string;
29
- pluginFamily: string;
30
- description: string;
31
- capabilities: string[];
32
- externalInterfaces: string[];
33
- methods: Array<{
34
- methodId: string;
35
- description: string;
36
- inputPorts: Array<{
37
- portId: string;
38
- schemaNames: string[];
39
- maxItems: number;
40
- }>;
41
- outputPorts: Array<{
42
- portId: string;
43
- schemaNames: string[];
44
- maxItems: number;
45
- }>;
46
- maxBatch: number;
47
- drainPolicy: string;
48
- }>;
49
- runtimeTargets: string[];
50
- }
51
-
52
- export interface FlatSQLSpatialSDM {
53
- /** Get the embedded plugin manifest */
54
- getManifest(): PluginManifest;
55
-
56
- /** Compute haversine distance between two WGS84 points (km) */
57
- computeDistance(lat1: number, lon1: number, lat2: number, lon2: number): number;
58
-
59
- /** Compute forward azimuth between two WGS84 points (degrees 0-360) */
60
- computeBearing(lat1: number, lon1: number, lat2: number, lon2: number): number;
61
-
62
- /** Test if a WGS84 point is inside a WKT polygon */
63
- pointInPolygon(wkt: string, lat: number, lon: number): boolean;
64
-
65
- /** Compute intersection of two WKT polygons */
66
- polygonIntersection(wkt1: string, wkt2: string): string;
67
-
68
- /** Compute union of two WKT polygons */
69
- polygonUnion(wkt1: string, wkt2: string): string;
70
-
71
- /** Compute Voronoi diagram from multipoint WKT within bounds */
72
- computeVoronoi(multipointWkt: string, boundsWkt: string): string;
73
-
74
- /** Compute Delaunay triangulation from multipoint WKT */
75
- computeDelaunay(multipointWkt: string): string;
76
-
77
- /** Transform WGS84 geodetic to ECEF */
78
- toECEF(lat: number, lon: number, alt: number): ECEFPoint;
79
-
80
- /** Transform ECEF to WGS84 geodetic */
81
- fromECEF(x: number, y: number, z: number): GeodeticPoint;
82
-
83
- /** Low-level method call */
84
- callMethod(methodName: string, input: string): MethodResult;
85
- }
86
-
87
- /** Initialize the FlatSQL Spatial SDM module */
88
- export function initSpatialSDM(): Promise<FlatSQLSpatialSDM>;