@simulatte/webgpu 0.2.1 → 0.2.3

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.
@@ -0,0 +1,353 @@
1
+ # Proposed support contracts for core, full, and browser boundary
2
+
3
+ Contract status: `draft`
4
+
5
+ Scope:
6
+
7
+ - proposed future layering for Doe's JS-facing package surfaces
8
+ - headless WebGPU package/runtime contracts only
9
+ - browser-owned Chromium semantics are called out explicitly as outside package
10
+ ownership
11
+ - no runtime behavior changes are enabled by this document
12
+
13
+ This document defines three explicit layers:
14
+
15
+ 1. `core`
16
+ - compute-first headless WebGPU
17
+ - minimal releaseable package/runtime surface
18
+ - explicit unsupported for sampled/render/browser gaps
19
+ 2. `full`
20
+ - full headless WebGPU
21
+ - strict superset of `core`
22
+ - still not a browser-process integration contract
23
+ 3. browser / Track A
24
+ - Chromium-only integration seam
25
+ - not package-owned
26
+ - owns DOM/canvas/process/fallback/proc-surface concerns
27
+
28
+ This split is intentionally separate from Chromium Track A. Chromium integration
29
+ depends on the full runtime artifact plus browser-specific gates; it must not
30
+ depend on npm packaging shape.
31
+
32
+ Boundary-enforcement and refactor-order details are defined in
33
+ `LAYERING_PLAN.md`.
34
+
35
+ ## Dependency contract
36
+
37
+ The layering rule is one-way:
38
+
39
+ 1. `full` may import and extend `core`.
40
+ 2. `core` must not import `full`.
41
+ 3. browser / Track A may depend on the full runtime artifact and browser-owned
42
+ contracts.
43
+ 4. `core` and `full` must not own Track A browser behavior.
44
+ 5. `core` must remain releaseable and testable without `full`.
45
+
46
+ Implementation intent:
47
+
48
+ 1. Zig:
49
+ - `zig/src/core/**` contains shared runtime, compute, copy/upload, limited
50
+ compute-visible texture handling, trace/replay, and backend-common code
51
+ - `zig/src/full/**` contains sampled textures, render, surface, and broader
52
+ lifecycle/parity layers built on `core`
53
+ 2. Lean:
54
+ - `lean/Fawn/Core/**` contains shared invariants
55
+ - `lean/Fawn/Full/**` may import `Core` and add render/lifecycle proofs
56
+ 3. Build outputs:
57
+ - `core` and `full` can be emitted as separate artifacts
58
+ - if separate binaries are used, `full` is built from `core` sources; `core`
59
+ must not dynamically depend on a `full` artifact
60
+
61
+ ## Product boundary
62
+
63
+ Three surfaces are implied by this split:
64
+
65
+ 1. `core`
66
+ - headless compute-first package/runtime
67
+ 2. `full`
68
+ - headless full WebGPU package/runtime
69
+ 3. browser / Track A
70
+ - browser integration seam, wire/proc/drop-in parity, fallback policy,
71
+ process topology, and browser-specific gates
72
+
73
+ `full` is the top of the headless stack, not the browser stack.
74
+ Browser-owned semantics remain outside both `core` and `full`.
75
+
76
+ ## Ownership matrix
77
+
78
+ | Capability area | `core` | `full` | browser / Track A |
79
+ | --- | --- | --- | --- |
80
+ | `GPU`, `GPUAdapter`, `GPUDevice`, `GPUQueue` | `required` | inherits `core` | not package-owned |
81
+ | `GPUBuffer` | `required` | inherits `core` | not package-owned |
82
+ | `GPUShaderModule` for compute WGSL | `required` | inherits `core` | not package-owned |
83
+ | `GPUBindGroupLayout`, `GPUBindGroup`, `GPUPipelineLayout` | `required` | inherits `core` | not package-owned |
84
+ | `GPUComputePipeline` | `required` | inherits `core` | not package-owned |
85
+ | `GPUCommandEncoder` for copy/upload/clear/barrier/compute | `required` | inherits `core` | not package-owned |
86
+ | `GPUComputePassEncoder` | `required` | inherits `core` | not package-owned |
87
+ | `dispatchWorkgroups`, `dispatchWorkgroupsIndirect` | `required` | inherits `core` | not package-owned |
88
+ | `GPUTexture` / `GPUTextureView` for compute-visible usages only | `required` | inherits and extends | not package-owned |
89
+ | `GPUSampler` | `out_of_scope` | `required` | not package-owned |
90
+ | `GPURenderPipeline` | `out_of_scope` | `required` | not package-owned |
91
+ | `GPURenderPassEncoder` | `out_of_scope` | `required` | not package-owned |
92
+ | `GPURenderBundleEncoder` | `out_of_scope` | `required` | not package-owned |
93
+ | Vertex / index buffers and draw variants | `out_of_scope` | `required` | not package-owned |
94
+ | Blend / depth-stencil / multisample | `out_of_scope` | `required` | not package-owned |
95
+ | Render-attachment textures | `out_of_scope` | `required` | not package-owned |
96
+ | Broader texture / view / format coverage | `limited` | `required` | not package-owned |
97
+ | `GPUCanvasContext` | `out_of_scope` | `out_of_scope` | `required` |
98
+ | DOM / canvas ownership | `out_of_scope` | `out_of_scope` | `required` |
99
+ | Proc-surface parity | `out_of_scope` | `out_of_scope` | `required` |
100
+ | Fallback policy / denylist / kill switch | `out_of_scope` | `out_of_scope` | `required` |
101
+ | Chromium process behavior | `out_of_scope` | `out_of_scope` | `required` |
102
+
103
+ ## Core support contract
104
+
105
+ ### Target user
106
+
107
+ - ML inference
108
+ - simulation
109
+ - data processing
110
+ - CI and benchmark orchestration
111
+ - deterministic headless command execution
112
+
113
+ ### Promise
114
+
115
+ `core` promises a stable compute-first headless WebGPU surface with explicit
116
+ unsupported behavior for sampled-texture, render, and browser-owned semantics.
117
+
118
+ ### Included object model
119
+
120
+ `core` includes:
121
+
122
+ - `GPU`, `GPUAdapter`, `GPUDevice`, `GPUQueue`
123
+ - `GPUBuffer`
124
+ - `GPUShaderModule` for compute WGSL
125
+ - `GPUBindGroupLayout`, `GPUBindGroup`, `GPUPipelineLayout`
126
+ - `GPUComputePipeline`
127
+ - `GPUCommandEncoder` for copy, upload, clear, barrier, and compute encoding
128
+ - `GPUComputePassEncoder`
129
+ - `dispatchWorkgroups`
130
+ - `dispatchWorkgroupsIndirect`
131
+
132
+ ### Texture contract
133
+
134
+ `core` gets samplerless compute textures only.
135
+
136
+ Included usage classes:
137
+
138
+ - `COPY_SRC`
139
+ - `COPY_DST`
140
+ - `TEXTURE_BINDING`
141
+ - `STORAGE_BINDING`
142
+
143
+ Excluded from `core`:
144
+
145
+ - `GPUSampler`
146
+ - sampled-texture semantics
147
+ - render-attachment semantics
148
+ - browser presentation semantics
149
+
150
+ Best rule:
151
+
152
+ - `core` gets samplerless compute textures only
153
+ - `full` gets sampled textures and render semantics
154
+
155
+ ### WGSL contract
156
+
157
+ WGSL required in `core`:
158
+
159
+ - storage buffers
160
+ - uniform buffers
161
+ - workgroup buffers
162
+ - atomics
163
+ - barriers
164
+ - `textureLoad`
165
+ - `textureStore`
166
+
167
+ WGSL out of scope for `core`:
168
+
169
+ - sampler declarations and binding semantics
170
+ - `textureSample*`
171
+ - vertex stage
172
+ - fragment stage
173
+ - render-attachment behavior
174
+
175
+ ### Explicit exclusions
176
+
177
+ `core` does not own:
178
+
179
+ - `GPUSampler`
180
+ - `GPURenderPipeline`
181
+ - `GPURenderPassEncoder`
182
+ - `GPURenderBundleEncoder`
183
+ - vertex/index input state
184
+ - draw/drawIndexed/drawIndirect
185
+ - blend/depth-stencil/multisample
186
+ - render-attachment textures
187
+ - `GPUCanvasContext`
188
+ - DOM/canvas ownership
189
+ - proc-surface parity
190
+ - Chromium fallback/process policy
191
+
192
+ ### Release gates for `core`
193
+
194
+ `core` acceptance requires:
195
+
196
+ 1. schema, correctness, and trace gates green
197
+ 2. package contract tests green for Node and declared Bun surface
198
+ 3. CTS subset coverage for:
199
+ - adapter/device acquisition
200
+ - buffers
201
+ - copy/upload
202
+ - compute pipeline
203
+ - compute dispatch
204
+ - compute-visible texture load/store paths
205
+ 4. benchmark cube evidence limited to:
206
+ - upload
207
+ - compute e2e
208
+ - dispatch-only
209
+ 5. explicit unsupported taxonomy for any sampler, sampled-texture, render,
210
+ surface, or browser API request outside the `core` contract
211
+
212
+ ### Non-goals for `core`
213
+
214
+ 1. full WebGPU JS object-model parity
215
+ 2. sampled-texture semantics
216
+ 3. render pipeline completeness
217
+ 4. browser presentation parity
218
+ 5. Chromium drop-in readiness by itself
219
+
220
+ ## Full support contract
221
+
222
+ ### Target user
223
+
224
+ - headless rendering
225
+ - offscreen graphics testing
226
+ - broader WebGPU package compatibility
227
+ - future Chromium runtime-artifact dependency
228
+
229
+ ### Promise
230
+
231
+ `full` promises a full headless WebGPU surface. It is a strict superset of
232
+ `core`, but it still does not claim browser-process ownership, DOM integration,
233
+ or Chromium wire/drop-in readiness by itself.
234
+
235
+ ### Added object model
236
+
237
+ `full` adds:
238
+
239
+ - `GPURenderPipeline`
240
+ - `GPURenderPassEncoder`
241
+ - `GPURenderBundleEncoder`
242
+ - vertex buffers
243
+ - index buffers
244
+ - `draw`
245
+ - `drawIndexed`
246
+ - `drawIndirect`
247
+ - render-state objects and behavior for blend, depth-stencil, and multisample
248
+ - `GPUSampler`
249
+
250
+ ### Texture contract
251
+
252
+ `full` adds the texture/render surface that `core` deliberately excludes:
253
+
254
+ - sampled textures
255
+ - render-attachment textures
256
+ - broader texture/view/format coverage
257
+ - texture/view behavior needed by render pipelines and broader headless package
258
+ compatibility
259
+
260
+ ### WGSL additions
261
+
262
+ WGSL added in `full`:
263
+
264
+ - sampler declarations and binding semantics
265
+ - `textureSample*`
266
+ - vertex stage
267
+ - fragment stage
268
+
269
+ `full` therefore owns the shader and object-model pieces needed for sampled
270
+ textures and render semantics. It still does not own DOM/canvas behavior.
271
+
272
+ ### Still outside `full`
273
+
274
+ `full` still does not own:
275
+
276
+ - `GPUCanvasContext`
277
+ - DOM/canvas ownership
278
+ - proc-surface parity
279
+ - browser fallback policy
280
+ - Chromium process behavior
281
+
282
+ ### Release gates for `full`
283
+
284
+ `full` acceptance requires:
285
+
286
+ 1. every `core` gate remains green
287
+ 2. full contract tests green for Node and declared Bun surface
288
+ 3. broader CTS subset coverage for:
289
+ - render pipeline creation
290
+ - render pass execution
291
+ - render bundles where contract-required
292
+ - texture formats and sampling
293
+ - bind-group and pipeline-layout behavior
294
+ - query/lifecycle/error-scope paths
295
+ 4. benchmark cube evidence may include:
296
+ - upload
297
+ - compute e2e
298
+ - render
299
+ - texture/raster
300
+ 5. explicit unsupported taxonomy for any capability not yet in the full release
301
+ contract
302
+ 6. no marketing or docs claim browser parity unless Track A browser gates also
303
+ pass
304
+
305
+ ### Non-goals for `full`
306
+
307
+ 1. replacing Chromium's process model
308
+ 2. owning browser fallback policy
309
+ 3. claiming `navigator.gpu` parity in the browser
310
+ 4. bypassing Track A symbol/behavior/replay/drop-in gates
311
+
312
+ ## Browser / Track A boundary contract
313
+
314
+ The following capabilities are not owned by `core` or `full` package contracts:
315
+
316
+ - `GPUCanvasContext`
317
+ - DOM/canvas ownership
318
+ - `navigator.gpu` behavior inside Chromium
319
+ - proc-surface completeness requirements
320
+ - browser fallback policy, denylist policy, and kill-switch policy
321
+ - renderer/GPU-process topology
322
+ - Chromium process behavior
323
+
324
+ These belong to Chromium Track A and must be governed by:
325
+
326
+ - `nursery/fawn-browser/README.md`
327
+ - `nursery/fawn-browser/plan.md`
328
+ - drop-in symbol/behavior/benchmark gates
329
+ - browser replay and claimability artifacts
330
+
331
+ ## Current repo reality
332
+
333
+ This split is not yet how the repo is physically organized today.
334
+
335
+ Current state:
336
+
337
+ 1. the canonical package is still a single `@simulatte/webgpu` surface
338
+ 2. current package code already exposes some render objects and methods
339
+ 3. current Zig/runtime docs track a single Doe runtime capability ledger
340
+
341
+ This document is therefore a target contract for future sharding, not a claim
342
+ that the split already exists.
343
+
344
+ ## Adoption rules
345
+
346
+ Before naming or shipping separate `core` and `full` products:
347
+
348
+ 1. create separate support ledgers and gates for each surface
349
+ 2. enforce one-way import boundaries in Zig and Lean
350
+ 3. move render, sampled-texture, and surface/lifecycle code out of the shared
351
+ core path
352
+ 4. define separate package API contracts and compatibility scopes
353
+ 5. keep Chromium depending on the full runtime artifact, not on npm packaging